CashScript / cashscript

⚖️ Easily write and interact with Bitcoin Cash smart contracts
https://cashscript.org
MIT License
115 stars 80 forks source link

Optimisation: Remove final verify from branches (if they are the final statement of the function) #188

Open rkalis opened 5 months ago

rkalis commented 5 months ago

Currently, if the final "require" statement in a function happens within a branch, we do not remove it, instead we leave it as OP_VERIFY OP_1 to ensure that the "implicit verify" at the end of the execution succeeds. It would save 2 bytes per case if we can remove that. We need to make sure to do it in a correct and safe way though, which can be hard considering edge cases.

If/when we implement this, we also need to make sure that this does not break the "require message" debug functionality, but this should be covered by current tests.

This is not a very high priority.