<oembed><type>rich</type><version>1.0</version><author_name>npub1r3san9v5njl6798hvauyu9ntm6r9c7u8s0t65wls58gpfdcvqp5sa48d0u</author_name><author_url>https://nostr.ae/npub1r3san9v5njl6798hvauyu9ntm6r9c7u8s0t65wls58gpfdcvqp5sa48d0u</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2017-09-19&#xA;📝 Original message:&gt; On Sep 18, 2017, at 8:09 PM, Luke Dashjr &lt;luke at dashjr.org&gt; wrote:&#xA;&gt; &#xA;&gt; On Tuesday 19 September 2017 12:46:30 AM Mark Friedenbach via bitcoin-dev &#xA;&gt; wrote:&#xA;&gt;&gt; After the main discussion session it was observed that tail-call semantics&#xA;&gt;&gt; could still be maintained if the alt stack is used for transferring&#xA;&gt;&gt; arguments to the policy script.&#xA;&gt; &#xA;&gt; Isn&#39;t this a bug in the cleanstack rule?&#xA;&#xA;Well in the sense that &#34;cleanstack&#34; doesn&#39;t do what it says, sure.&#xA;&#xA;However cleanstack was introduced as a consensus rule to prevent a&#xA;possible denial of service vulnerability where a third party could&#xA;intercept any* transaction broadcast and arbitrarily add data to the&#xA;witness stack, since witness data is not covered by a checksig.&#xA;&#xA;Cleanstack as-is accomplishes this because any extra items on the&#xA;stack would pass through all realistic scripts, remaining on the stack&#xA;and thereby violating the rule. There is no reason to prohibit extra&#xA;items on the altstack as those items can only arrive there&#xA;purposefully as an action of the script itself, not a third party&#xA;malleation of witness data. You could of course use DEPTH to write a&#xA;script that takes a variable number of parameters and sends them to&#xA;the altstack. Such a script would be malleable if those extra&#xA;parameters are not used. But that is predicated on the script being&#xA;specifically written in such a way as to be vulnerable; why protect&#xA;against that?&#xA;&#xA;There are other solutions to this problem that could have been taken&#xA;instead, such as committing to the number of items or maximum size of&#xA;the stack as part of the sighash data, but cleanstack was the approach&#xA;taken. Arguably for a future script version upgrade one of these other&#xA;approaches should be taken to allow for shorter tail-call scripts.&#xA;&#xA;Mark&#xA;&#xA;* Well, almost any. You could end the script with DEPTH EQUAL and that&#xA;  is a compact way of ensuring the stack is clean (assuming the script&#xA;  finished with just &#34;true&#34; on the stack). Nobody does this however&#xA;  and burning two witness bytes of every redeem script going forward&#xA;  as a protective measure seems like an unnecessary ask.</html></oembed>