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

feat: roundtrip fuzz harness for PooledTransactions #5125

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

0xalpharush
Copy link
Contributor

Add a roundtrip fuzz harness for PooledTransactions by converting an existing unit test into a fuzz test. This harness identified a new bug (cc @Rjected). Run the harness with cargo test-fuzz -p reth-eth-wire --run-until-crash and reproduce the crash with cargo test-fuzz -p reth-eth-wire --replay crashes.

Partially addresses #4962

@codecov
Copy link

codecov bot commented Oct 21, 2023

Codecov Report

Merging #5125 (3f25e25) into main (3a8fe5a) will increase coverage by 0.00%.
Report is 57 commits behind head on main.
The diff coverage is n/a.

❗ Current head 3f25e25 differs from pull request most recent head 9eb594c. Consider uploading reports for the commit 9eb594c to get more accurate results

Impacted file tree graph

see 5 files with indirect coverage changes

Flag Coverage Δ
integration-tests 17.07% <ø> (+<0.01%) ⬆️
unit-tests 62.16% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
reth binary 30.85% <ø> (ø)
blockchain tree 80.82% <ø> (ø)
pipeline 88.36% <ø> (ø)
storage (db) 74.60% <ø> (ø)
trie 94.96% <ø> (+0.03%) ⬆️
txpool 55.33% <ø> (ø)
networking 78.17% <ø> (+0.02%) ⬆️
rpc 57.96% <ø> (ø)
consensus 63.01% <ø> (ø)
revm 24.47% <ø> (ø)
payload builder 7.95% <ø> (ø)
primitives 84.71% <ø> (ø)

@mattsse
Copy link
Collaborator

mattsse commented Oct 22, 2023

what's the bug?

@Rjected
Copy link
Member

Rjected commented Oct 23, 2023

what's the bug?

recmo/uint#335 is one surfaced by this fuzz test

Another is related to payload length checks, PR soon

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

Just one comment about preserving existing behavior from decode_pooled_transactions_data in at least one test

Comment on lines 34 to 41
#[test]
fn decode_pooled_transactions_data() {
let network_data_path =
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("testdata/pooled_transactions_with_blob");
let data = fs::read_to_string(network_data_path).expect("Unable to read file");
let hex_data = hex::decode(data.trim()).unwrap();
roundtrip_pooled_transactions(hex_data);
}
Copy link
Member

Choose a reason for hiding this comment

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

hmm, we should probably keep the test as-is, since previously it would panic on unsuccessful decoding. so we want to keep:

    let txs = PooledTransactions::decode(&mut &hex_data[..]).unwrap();

Maybe we could have another test that iterates over our existing testdata/ files and runs the roundtrip test. Then we could both cover unsuccessful initial decoding, and failed roundtrips.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added an assertion that the existing tests decodes successfully in 9eb594c

@0xalpharush 0xalpharush force-pushed the feat/PooledTransactions-fuzzing branch from d855f4e to 9eb594c Compare October 29, 2023 19:23
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm, pending @Rjected

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

LGTM!

@Rjected Rjected added this pull request to the merge queue Oct 30, 2023
Merged via the queue into paradigmxyz:main with commit 64d5064 Oct 30, 2023
@0xalpharush 0xalpharush deleted the feat/PooledTransactions-fuzzing branch October 30, 2023 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants