-
Notifications
You must be signed in to change notification settings - Fork 37.7k
fuzz: improve utxo_snapshot target #30329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
2e129c4
to
a270cb8
Compare
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
a270cb8
to
65c5321
Compare
Concept ACK |
65c5321
to
3c8d883
Compare
3c8d883
to
b9ba1a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. Thanks!
@@ -495,12 +495,19 @@ class CRegTestParams : public CChainParams | |||
}; | |||
|
|||
m_assumeutxo_data = { | |||
{ | |||
{ // For use by unit tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe also list the filename here, like in the other cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't do that because there are already multiple files that use it (validation_chainstatemanager_tests
, validation_chainstate_tests
). Seems less likely that the same would happen for fuzz tests.
src/kernel/chainparams.cpp
Outdated
.height = 200, | ||
.hash_serialized = AssumeutxoHash{uint256S("0x998b6a337899f04a1cd298ecf0fdc6ab66bfb428f00e5a48998505e91b3b55e0")}, | ||
.nChainTx = 201, | ||
.blockhash = uint256S("0x5e93653318f294fb5aa339d00bbf8cf1c3515488ad99412c37608b139ea63b27,") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit: Missing trailing ,
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, the "," went into the hash by mistake (and was ignored). I also fixed the hash_serialized
, which was wrong somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "," went into the hash by mistake (and was ignored)
ugh. I didn't even notice this
src/test/fuzz/utxo_snapshot.cpp
Outdated
outfile << Span{metadata}; | ||
} else { | ||
DataStream data_stream{}; | ||
auto msg_start = Params().MessageStart(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style-nit:
auto msg_start = Params().MessageStart(); | |
auto msg_start = chainman.Params().MessageStart(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, here and at one more spot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK b9ba1a7 🎯
Show signature
Signature:
untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: ACK b9ba1a73094f4ad593b527e23d2681f41c22539 🎯
iTX6VgeBMzgsveHFGIl5Qnsj/cWt0KYcv2B3dvhxmLm6ljOkWyT0bGPRv0zKVRDXMpcDBJcwelxlW8o6WHPEDw==
I checked if there is anything we could do in the testing setup to make the test faster. With this patchset, the test takes around 1:15 min for 10k runs on my machine. Removing the validation interface from the test setup cuts it down to 1:05 min , if I remove the networking setup, it takes 35 sec to complete. I also removed the mempool and it crashed when reaching validation.cpp:5684. Is it a hard requirement when using assumeutxo that a mempool exists, or is this a bug? |
That appears to be a bug. We actually require the mempool to be empty so it not being there should not be a problem. I will open a PR. |
This should work fjahr@21530b4, but on second thought I am not sure if we need this (yet). Conceptually it makes sense that we change this because, as I said, we don't need the mempool. However, since we don't use the mempool I think this should also not make an impact on the testing speed and even in blocksonly mode there still is a mempool, so this won't be an issue. This might be getting off-topic so I can open a separate issue to move the discussion. |
Nice. Would be good to have a pull request with this, so that it can be reviewed and merged. |
utACK b9ba1a7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK b9ba1a7
... but it would be nice to address the nits, will re-ACK quickly :)
Add the possibility of giving more guidance to the creation of the metadata and/or coins, so that the fuzzer gets the chance to reach more error conditions in ActivateSnapshot and sometimes successfully creates a valid snapshot. This also changes the asserts for the success case that were outdated, and only didn't result in a crash because the fuzzer wasn't able to reach this code before.
b9ba1a7
to
de71d4d
Compare
Thanks for the reviews! I addressed the feedback by @maflcko and also corrected
Sound like good ideas for a follow-up! |
re-ACK de71d4d 🎆 Show signatureSignature:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK de71d4d
utACK de71d4d |
FYI, confirmed for myself on another computer that this was just an error, and the snapshot can be loaded by the fuzzer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Post-merge code review ACK de71d4d
This seems like a good change in principle, but I'm not actually sure what additional test coverage it provides. The only valid snapshot that can be loaded seems to be one that is hardcoded for a chain with height 200 and no transactions except for coinbases. After the snapshot is generated there is only a single ConsumeBool
call determining whether or not headers for the blocks are added before loading the snapshot.
So basically it creates a hardcoded snapshot, and then tests loading it with and without headers. I could be missing something, but it seems like that is not really taking advantage of the fuzzer or testing something that would be not more convenient to run as a unit test.
It would probably open up a lot more flexibility for the fuzz test if it were able to modify the m_assumeutxo_data
vector instead of relying on hardcoded values.
.height = 200, | ||
.hash_serialized = AssumeutxoHash{uint256S("0x4f34d431c3e482f6b0d67b64609ece3964dc8d7976d02ac68dd7c9c1421738f2")}, | ||
.nChainTx = 201, | ||
.blockhash = uint256S("0x5e93653318f294fb5aa339d00bbf8cf1c3515488ad99412c37608b139ea63b27"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "fuzz: improve utxo_snapshot target" (de71d4d)
Since fuzz test is not deterministic, and doesn't give us an easy way to know hash values here actually allow snapshot to be loaded, it might be good to write a separate regtest generating a an empty chain with height 200 and verifying these hashes.
Note that loading a valid snapshot is not the only goal of this PR. It also allows for a better coverage of I think for more interesting fuzzing we'd have to think about allowing dynamic registration of snapshots in tests (or enabling an option to just skip the check for the hash in chainparams). Some time ago, I thought about this in the context of functional tests (to avoid having to edit chainparams whenever we change something in a functional test), but after realizing that the registered snapshot data from chainparams is not only necessary during registration but also in a restart ( |
Found #30514 |
160799d test: refactor: introduce `create_ephemeral_dust_package` helper (Sebastian Falbesoner) 61e18de doc: ephemeral policy: add missing closing double quote (Sebastian Falbesoner) Pull request description: This small PR contains ephemeral dust follow-ups mentioned in #30329 that were not tackled in the first follow-up PR #31279: #30239 (comment) #30239 (comment) Happy to add more if I missed some or anyone has concrete commits to add. ACKs for top commit: rkrux: tACK 160799d instagibbs: ACK 160799d tdb3: Code review ACK 160799d Tree-SHA512: e9a80c6733f1e7fe9e834d81b404f6e8ef7a61fe986f61b3dcdbda1a0bc547145fc279ec02f54361df56cb4e62a6fedaa0f3991c6e084c3a703ed1b1bfbdbe4e
Add the possibility of giving more guidance to the creation of the metadata and/or coins, so that the fuzzer gets the chance
to reach more error conditions in ActivateSnapshot and sometimes successfully creates a valid snapshot.
This also changes the asserts for the success case that were outdated (after #29370) and only didn't result in a crash because the fuzzer wasn't able to reach this code before.