Commit graph

5 commits

Author SHA1 Message Date
Russell O'Connor
0a0a69f315 Update Simplicity integeration
This Simplicity update has
- renamed a few types
- moved some files around
- added a minCost parameter, currently set to 0
- added a new error code
2025-06-24 11:38:08 -04:00
Russell O'Connor
3a80782963 Avoid double free in simplicity pointer when copying PrecomputedTransactionData
We cannot put a raw pointer into a class that has a default copy constructor.
2025-03-03 17:35:07 -05:00
Andrew Poelstra
eea423e3d6
fuzz: add second simplicity fuzz test
The first fuzztest takes a Simplicity program and a transaction and
directly calls the Simplicity interpreter with some context cobbled
together from the transaction. It also tries messing with the budget
and computes AMRs to check that the AMR-check works, even though on
the blockchain AMRs are never used.

It also attempts mangling programs to directly fuzz the parser, type
inference and CMR checking.

THIS test, on the other hand, takes a transaction, looks for Simplicity
programs (or witnesses which look like Simplicity programs), computes
their CMRs to produce a correct corresponding scriptPubKey, creates
scriptchecks, and executes them. This should do an end-to-end coverage
of the whole Simplicity consensus logic, including all the new branches
in interpreter.cpp.

To produce seeds for this, I have a a local fuzz target which uses
rust-simplicity and rust-elements to produce programs, deep Taproot trees,
and transactions. I run this to get high coverage, then dump the
resulting complete transactions to disk, where they can be used as
seeds for this test.
2025-02-11 16:12:29 +00:00
Andrew Poelstra
a87e4cf70b
simplicity: rewrite fuzz target
This fuzz target takes its seeds in a simple and well-defined format: a
four-byte LE budget, then a transaction, Simplicity program and witness,
each prefixed by a four-byte LE length. The fuzz target extracts any
additional randomness it needs from the txid of the first input of the
transaction, since this data is not interpreted in any other way we
therefore won't confuse the fuzzer.

The reason for this design, rather than a more typical "just query the
fuzzer when you need stuff", is to make it possible to fairly easily
generate test vectors from sources other than this fuzz test. (For
example, I have an alternate target which uses Rust code to generate
well-formed Simplicity programs, which quickly gets high coverage at the
expense of being an unmaintainable mess.)

This commit includes a .c file with a small function to comute the AMR
of a program. This is needed to pass a correct AMR to the Simplicity
interpreter, to exercise all the AMR-checking paths. In practice this is
not really necessary; Elements passes NULL to disable these AMR checks.
2025-02-11 16:12:28 +00:00
Byron Hambly
52642b1afd
simplicity: add fuzz target 2025-02-11 16:12:28 +00:00