<div dir="ltr"><div>Thanks Russell!</div><div><br></div><div>Is the 13 seconds expression search time a fundamental limitation related to the AST search, or is it more a result of the implementation currently? I ask because it seems like jets could be marked by their merkle roots and stored in a hash table. If this is the case, it's not immediately obvious why the search would be any different during the first time than the others.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 20, 2020 at 10:16 AM Russell O'Connor <<a href="mailto:roconnor@blockstream.com">roconnor@blockstream.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear all,</div><div><br></div><div>I know of a couple of people who are getting into the nitty-gritty of developing Simplicity programs despite the lack of tooling support. I appreciate the efforts of these bold persons, so I'll be trying to give more updates on this mailing list.</div><div><br></div><div>While the main focus of my efforts are still on the consensus critical components of the C library, I want to put some effort into helping Simplicity developers. Right now, Simplicity programs are best developed in using the Simplicity Haskell library. However, testing of Simplicity programs by directly interpreting the Simplicity expressions is very slow for all but the simplest programs.</div><div><br></div><div>Recently I've pushed an experimental branch, <<a href="https://github.com/ElementsProject/simplicity/tree/haskell-ffi-jets-secp256k1" target="_blank">https://github.com/ElementsProject/simplicity/tree/haskell-ffi-jets-secp256k1</a>>. This branch adds 'Simplicity.Elements.Jets.fastEval' and 'Simplicity.Bitcoin.Jets.fastEval' functions that searches for subexpressions with known jets, and evaluates these subexpressions using jets, making FFI calls to a C implementation in some cases. At the moment, the set of known jets includes 32-bit arithmetic, sha-256 compression, and (old-style) schnorr signature assertion. More jets will be developed.</div><div><br></div><div>While the overhead of searching for jets is quite high, once completed an expression can be repeatedly evaluated, making this process quite suitable for randomized testing. Observe below that by sharing <span style="font-family:monospace">fastSchnorrAssert</span> the first evaluation takes 13 seconds, but subsequent evaluations take 0.02 seconds. Without using jets, the direct interpretation of <span style="font-family:monospace">schnorrAssert</span> using <span style="font-family:monospace">Simplicity.Elements.Semantics.sem</span> could take hours.<br></div><div><br></div><div><span style="font-family:monospace"> Prelude Simplicity.Ty.Word> let fastSchnorrAssert = Simplicity.Elements.Jets.fastEval Simplicity.Programs.LibSecp256k1.Lib.schnorrAssert<br> (0.02 secs, 102,456 bytes)<br> Prelude Simplicity.Ty.Word> let {pk = toWord256 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798; m = toWord256 0; sig = toWord512 0x528F745793E8472C0329742A463F59E58F3A3F1A4AC09C28F6F8514D4D0322A258BD08398F82CF67B812AB2C7717CE566F877C2F8795C846146978E8F04782AE} in fastSchnorrAssert undefined ((pk,m),sig)<br> Just ()<br> (12.71 secs, 17,984,271,240 bytes)<br> Prelude Simplicity.Ty.Word> let {pk = toWord256 0xEEFDEA4CDB677750A420FEE807EACF21EB9898AE79B9768766E4FAA04A2D4A34; m = toWord256 0x243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89; sig = toWord512 0x667C2F778E0616E611BD0C14B8A600C5884551701A949EF0EBFD72D452D64E844160BCFC3F466ECB8FACD19ADE57D8699D74E7207D78C6AEDC3799B52A8E0598} in fastSchnorrAssert undefined ((pk,m),sig)<br> Nothing<br> (0.02 secs, 555,224 bytes)<br> Prelude Simplicity.Ty.Word> let {pk = toWord256 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798; m = toWord256 0; sig = toWord512 0x528F745793E8472C0329742A463F59E58F3A3F1A4AC09C28F6F8514D4D0322A258BD08398F82CF67B812AB2C7717CE566F877C2F8795C846146978E8F04782AE} in fastSchnorrAssert undefined ((pk,m),sig)<br> Just ()<br> (0.02 secs, 526,288 bytes)</span></div><div><br></div><div>This feature is still under development; however, I want to make it available as early as possible, because I think it will be especially helpful for some folks, even at this early stage.<br></div></div>
-- <br>
Simplicity mailing list<br>
<a href="mailto:Simplicity@lists.ozlabs.org" target="_blank">Simplicity@lists.ozlabs.org</a><br>
<a href="https://lists.ozlabs.org/listinfo/simplicity" rel="noreferrer" target="_blank">https://lists.ozlabs.org/listinfo/simplicity</a><br>
</blockquote></div>