Commit graph

1229 commits

Author SHA1 Message Date
Andrew Poelstra
a2d24eff9e
fuzz: remove dead code from simplicity_tx.cpp 2025-02-13 23:09:51 +00:00
Andrew Poelstra
69c241592f
fuzz: update simplicity_tx target to hit simplicity CMR error 2025-02-13 23:08:57 +00:00
Andrew Poelstra
3fe5d12c57
fuzz: simplicity: use zero CMR for invalid programs
When we have an invalid program, use a zero CMR and create a valid
control block/taptweak. Otherwise we fail to hit the Simplicity logic at
all with bad programs.

#
# You are committing on CAMUS
#

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch 2024-12--simple-fuzz
# Changes to be committed:
#	modified:   src/test/fuzz/simplicity_tx.cpp
#
# Untracked files:
#	reduced-corpus/
#	run-fuzz-merge-dir-CPzq/
#	run-fuzz-merge-dir-sscf/
#
2025-02-11 16:12:29 +00: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
Andrew Poelstra
363c5101c2
fuzz: change int to unsigned in witness_program
Avoids a signed/unsigned integer conversion.
2025-02-11 04:04:25 +00:00
Andrew Poelstra
86d740b5eb
fuzz: fix crash on null pointer in witness_program target 2025-02-11 02:53:44 +00:00
Andrew Poelstra
ff6482fc29
fuzz: add SelectParams to rbf.cpp
We cannot fuzz RBF (or do anything mempool-related, really) without
chainparams. This has been true since 2019 at least. I suspect this fuzz
test has never really been run.
2025-02-06 21:31:47 +00:00
Byron Hambly
54660d006f
ci: fix unused member function warning in checkqueue.cpp 2023-09-07 13:32:06 +02:00
Byron Hambly
3911e7e2b3
build: fix compilation warnings 2023-09-01 16:39:08 +02:00
James Dorfman
265ba04f55 Add extra optimization initally left out during the merge of bitcoin/bitcoin#23114 in 81d5607ec8 2023-07-21 01:58:35 +00:00
Byron Hambly
1dc6ad6ea9 Merge ba11eb354b into merged_master (Bitcoin PR bitcoin/bitcoin#23542) 2023-07-03 09:44:18 +00:00
Byron Hambly
a573a48bf9 Merge 292a841553 into merged_master (Bitcoin PR bitcoin/bitcoin#24449) 2023-07-02 16:32:16 +00:00
Byron Hambly
6c57005ffe Merge 16d05cf6b9 into merged_master (Bitcoin PR bitcoin/bitcoin#24406) 2023-07-02 14:13:58 +00:00
Byron Hambly
1fe3769ff8 Merge e44423c9d3 into merged_master (Bitcoin PR bitcoin/bitcoin#24224) 2023-07-02 06:23:04 +00:00
Byron Hambly
9f8cb83e1f Merge edc0d327f1 into merged_master (Bitcoin PR bitcoin/bitcoin#24349) 2023-06-30 21:12:13 +00:00
Byron Hambly
5649610340 Merge 3dc0bb9552 into merged_master (Bitcoin PR bitcoin/bitcoin#24298) 2023-06-30 11:46:17 +00:00
Byron Hambly
dfc4ef427a Merge fa65f26f4d into merged_master (Bitcoin PR bitcoin/bitcoin#24237) 2023-06-30 09:30:02 +00:00
Byron Hambly
939c63e1fc Merge e8a3882e20 into merged_master (Bitcoin PR bitcoin/bitcoin#23604) 2023-06-30 07:46:24 +00:00
Byron Hambly
4988afcbc2 Merge 3ace3a17c9 into merged_master (Bitcoin PR bitcoin/bitcoin#20744) 2023-06-30 07:38:29 +00:00
Byron Hambly
4e5e47d2d5 Merge 5f4c07b799 into merged_master (Bitcoin PR bitcoin/bitcoin#24136) 2023-06-29 13:43:18 +00:00
Byron Hambly
1f5c978989 Merge 9237bdaac1 into merged_master (Bitcoin PR bitcoin/bitcoin#24179) 2023-06-29 13:20:43 +00:00
Byron Hambly
5931d7d47c Merge d4e92d8436 into merged_master (Bitcoin PR bitcoin/bitcoin#23508) 2023-06-29 11:46:17 +00:00
Byron Hambly
a992ccaac2 Merge 196b459920 into merged_master (Bitcoin PR bitcoin/bitcoin#23438) 2023-06-29 08:37:35 +00:00
Byron Hambly
063acc7793 Merge cf5bb048e8 into merged_master (Bitcoin PR bitcoin/bitcoin#22932) 2023-06-28 17:12:24 +00:00
Byron Hambly
6bd5dfb3bd Merge d87a37a4ab into merged_master (Bitcoin PR bitcoin/bitcoin#24167) 2023-06-28 16:52:04 +00:00
Byron Hambly
23ffcd4fc8 Merge bd482b3ffe into merged_master (Bitcoin PR bitcoin/bitcoin#24105) 2023-06-21 11:44:35 +00:00
Byron Hambly
97153c657b Merge 973c390298 into merged_master (Bitcoin PR bitcoin/bitcoin#24078) 2023-06-20 13:11:19 +00:00
Byron Hambly
5fd03f5cdb Merge 6d859cbd79 into merged_master (Bitcoin PR bitcoin/bitcoin#24021) 2023-06-20 12:55:58 +00:00
Byron Hambly
d87b47ba1f Merge d0bf9bb6a5 into merged_master (Bitcoin PR bitcoin/bitcoin#23373) 2023-06-20 11:37:17 +00:00
Byron Hambly
b535b87e0e Merge 7de2cf9b25 into merged_master (Bitcoin PR bitcoin/bitcoin#23992) 2023-06-20 11:11:11 +00:00
Byron Hambly
c3b3592742 Merge 290ff5ef6d into merged_master (Bitcoin PR bitcoin/bitcoin#24041) 2023-06-19 10:29:14 +00:00
Byron Hambly
e6b8c52041 Merge 1f7acfdcca into merged_master (Bitcoin PR bitcoin/bitcoin#24024) 2023-06-19 09:48:16 +00:00
Byron Hambly
7878ba47b9 Merge c561f2f06e into merged_master (Bitcoin PR bitcoin/bitcoin#23497) 2023-06-19 09:28:31 +00:00
Byron Hambly
57f75b6da7 Merge 3d0850cec1 into merged_master (Bitcoin PR bitcoin/bitcoin#23994) 2023-06-15 14:45:02 +00:00
Byron Hambly
cf130c6587 Merge 70395bab4e into merged_master (Bitcoin PR bitcoin/bitcoin#23760) 2023-06-15 11:15:18 +00:00
Byron Hambly
2643bd7860 Merge 8f1c28a609 into merged_master (Bitcoin PR bitcoin/bitcoin#21879) 2023-06-15 08:00:33 +00:00
Byron Hambly
b8e9358d8c Merge e31cdb0238 into merged_master (Bitcoin PR bitcoin/bitcoin#23411) 2023-06-15 07:42:35 +00:00
Byron Hambly
47626b5a64 Merge 623745ca74 into merged_master (Bitcoin PR bitcoin/bitcoin#23912) 2023-06-14 15:44:11 +00:00
Byron Hambly
8ddbecc5a8 Merge 45249e70d9 into merged_master (Bitcoin PR bitcoin/bitcoin#23881) 2023-06-14 14:12:28 +00:00
Byron Hambly
65a0b564c6 Merge c006ab29ce into merged_master (Bitcoin PR bitcoin/bitcoin#23219) 2023-06-13 16:27:34 +00:00
Byron Hambly
b2ace54856 Merge 98a2ddcd6e into merged_master (Bitcoin PR bitcoin/bitcoin#23806) 2023-06-13 15:53:48 +00:00
Byron Hambly
b53864eef4 Merge 4ad59042b3 into merged_master (Bitcoin PR bitcoin/bitcoin#22704) 2023-06-13 14:42:08 +00:00
Byron Hambly
8edcc34130 Merge 60b5795133 into merged_master (Bitcoin PR bitcoin/bitcoin#23758) 2023-06-13 12:26:03 +00:00
Byron Hambly
5494a066ab Merge 498fe4b780 into merged_master (Bitcoin PR bitcoin/bitcoin#23575) 2023-06-13 09:58:15 +00:00
James Dorfman
7600af2c48 Merge 7d746bdd18 into merged_master (Bitcoin PR bitcoin/bitcoin#23733) 2023-06-13 04:12:36 +00:00
Byron Hambly
c7c59a27a9 Merge 926fc2a0d4 into merged_master (Bitcoin PR bitcoin/bitcoin#23707) 2023-06-06 09:35:00 +00:00
Byron Hambly
b0b2f3deff Merge f6013265b7 into merged_master (Bitcoin PR bitcoin/bitcoin#20295) 2023-06-06 09:10:04 +00:00
Byron Hambly
f97b7f0c64 Merge 84d921e79c into merged_master (Bitcoin PR bitcoin/bitcoin#23465) 2023-06-06 09:00:13 +00:00