Skip to content
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

fuzz: Improve stability for txorphan and mini_miner harnesses #30306

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

dergoegge
Copy link
Member

See #29018.

Stability for txorphan is now >90%. mini_miner needs further investigation, stability still low (although slightly improved by this PR) at ~62%.

The addresses of the iterator values are non-deterministic (i.e. they
depend on where the values were allocated). This causes stability issues
when fuzzing (e.g. in the `txorphan` and `mini_miner` harnesses), due
the orders (derived from IteratorComparator) not being deterministic.

Improve stability by comparing the first element in the iterator value
pair instead of using the the value addresses.
@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 19, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK marcofleon, glozow

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@DrahtBot DrahtBot added the Tests label Jun 19, 2024
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some questions

src/node/mini_miner.h Show resolved Hide resolved
@@ -92,7 +92,7 @@ class TxOrphanage {
template<typename I>
bool operator()(const I& a, const I& b) const
{
return &(*a) < &(*b);
return a->first < b->first;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the set could just be made a vector, because duplicates shouldn't happen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe but this sounds like more effort than I wanted to spend on this.

I don't think the comparison change here is gonna have any noticeable impact on performance tbh. In most cases the first 8 byte of the txids are already gonna differ, so the performance should be similar to comparing the pointers (assuming 8 byte addresses) most of the time.

Copy link
Contributor

@marcofleon marcofleon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK e009bf6. Using afl++, stability for txorphan went from 82% to ~94% and for mini_miner it went from 84% to 97%. I ran them both using the corpora in qa-assets.

Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK e009bf6

Didn't check stability, but using txid seems fine.

@fanquake fanquake merged commit 4c573e5 into bitcoin:master Jul 1, 2024
16 checks passed
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jul 19, 2024
Summary:
Backport of [[bitcoin/bitcoin#30186 | core#30186]] and [[bitcoin/bitcoin#30306 | core#30306]].

Note that we don't have the fuzz test yet, the point is to get the module up-to-date with upstream.

Depends on D16505.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D16507
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants