CashScript / cashscript

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

Failing Mecenas contract after updating #47

Closed rkalis closed 4 years ago

rkalis commented 4 years ago

This was reported by @dagurval on Telegram. There was a bug in the Mecenas contract example, which he pointed out. However, after fixing this, the script failed to execute in meep.

meep debug --tx=0200000001e5c5b76dd077b0cde74cdb1abfda9bdb09ef7de34a5ce25281b19d48a4f9106d01000000fd9d02416cdee82ef6bd2038c1ea4af0d6f49c66b8c47d999a6a22bbc2be4db0cf085a52d391dcffa4ff3ede8060a4cd31afe077ea3a8332c51f214cc5deeaf4ba6c65564121021ed9d1795a0c4a10fabb9f4678c70015b6d4ee7a39fa2d9e5eec3b6465d6eeb04d6801020000008028a2d856c79777e5e744351c58672e58f3a8bfc7fd5cf492c919da4348b58018606b350cd8bf565266bc352f0caddcf01e8fa789dd8a15386327cf8cabe198e5c5b76dd077b0cde74cdb1abfda9bdb09ef7de34a5ce25281b19d48a4f9106d01000000cb0210271420d56150addb7cfc411e2e846d5e847eb54d1be21412b60afc04b42a6837bc590ec007eaf78b8e73cf5379009c63547901697f77820134947f587f547f7701207f75597a597a6e7c828c7f755b7aa87bbbad02e8035279815779527993a1635279817894588076041976a9147e56797e0288ac7e76aa547988756757795880547981597994537994588078041976a9147e58797e0288ac7e780317a9147e5879a97e01877e6e7eaa5779886d686d6d6d6d6d755167537a519c635379a97b8872ac7777670068688096980000000000feffffff97a383e0b0c905c59e9c469e7034aa570d36a4aa19f77192bb4bc489a9aa910a9fa1140041000000004ccb0210271420d56150addb7cfc411e2e846d5e847eb54d1be21412b60afc04b42a6837bc590ec007eaf78b8e73cf5379009c63547901697f77820134947f587f547f7701207f75597a597a6e7c828c7f755b7aa87bbbad02e8035279815779527993a1635279817894588076041976a9147e56797e0288ac7e76aa547988756757795880547981597994537994588078041976a9147e58797e0288ac7e780317a9147e5879a97e01877e6e7eaa5779886d686d6d6d6d6d755167537a519c635379a97b8872ac777767006868feffffff0210270000000000001976a91412b60afc04b42a6837bc590ec007eaf78b8e73cf88ac886b98000000000017a91486a0a33b4c5eaab3bd3d6d5b05b44fc6c858f01f879fa11400 --idx=0 --amt=10000000 --pkscript=a91486a0a33b4c5eaab3bd3d6d5b05b44fc6c858f01f87
rkalis commented 4 years ago

This turned out to be caused by a bug in stack cleaning at the end of an if-statement block. Due to a wrong for-loop only half of the necessary values are dropped. This will be fixed in the next release.

rkalis commented 4 years ago

This has been fixed in https://github.com/Bitcoin-com/cashscript/commit/35a908ea1815688bdb5d75bbfd7ccc7862d017dc.