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

test: improve slow tests #3487

Merged
merged 7 commits into from
Jul 2, 2023
Merged

test: improve slow tests #3487

merged 7 commits into from
Jul 2, 2023

Conversation

onbjerg
Copy link
Member

@onbjerg onbjerg commented Jun 29, 2023

  • Limits the amount of block bodies to 20 in BlockBodies (eth wire)
  • Limits the number of blocks in Receipts (eth wire) to 50, each with 5 receipts
  • Limits the number of transactions per block to 100
  • Limits the number of ommers per block to 2 (as per spec)
  • Limits the amount of withdrawals per block to 16 (as per spec)
  • Limits the amount of topics per log to 5
  • Limits the amount of logs per receipt to 20
  • Limits the amount of access list items per access list to 20
  • Limits the amount of slots per access list item to 20
  • Restricts the incremental state root fuzz test to 128 cases, instead of 256.

(All of these are just for proptest tests)

The slowest part is now the build, which can be addressed separately.

Closes #3409

@onbjerg onbjerg added the C-test A change that impacts how or what we test label Jun 29, 2023
@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

Merging #3487 (9b7b0e0) into main (2126c01) will decrease coverage by 0.04%.
The diff coverage is 66.66%.

Impacted file tree graph

Impacted Files Coverage Δ
crates/blockchain-tree/src/blockchain_tree.rs 82.26% <ø> (ø)
crates/net/network/src/eth_requests.rs 75.72% <0.00%> (-0.75%) ⬇️
crates/primitives/src/block.rs 78.69% <ø> (ø)
crates/primitives/src/log.rs 100.00% <ø> (ø)
crates/primitives/src/receipt.rs 83.00% <ø> (ø)
crates/rpc/rpc/src/eth/api/fees.rs 48.41% <0.00%> (ø)
crates/net/nat/src/lib.rs 45.00% <33.33%> (-0.33%) ⬇️
crates/blockchain-tree/src/block_indices.rs 84.45% <50.00%> (ø)
crates/net/network/src/peers/manager.rs 84.15% <50.00%> (+0.01%) ⬆️
crates/net/eth-wire/src/p2pstream.rs 80.30% <100.00%> (+0.03%) ⬆️
... and 6 more

... and 7 files with indirect coverage changes

Flag Coverage Δ
integration-tests 16.29% <8.33%> (+0.02%) ⬆️
unit-tests 64.11% <66.66%> (-0.05%) ⬇️

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

Components Coverage Δ
reth binary 23.05% <ø> (ø)
blockchain tree 81.69% <50.00%> (ø)
pipeline 87.10% <ø> (ø)
storage (db) 73.94% <100.00%> (+<0.01%) ⬆️
trie 95.64% <100.00%> (+<0.01%) ⬆️
txpool 51.14% <ø> (-0.65%) ⬇️
networking 77.89% <53.84%> (-0.02%) ⬇️
rpc 58.16% <0.00%> (-0.02%) ⬇️
consensus 62.78% <ø> (ø)
revm 35.07% <ø> (ø)
payload builder 6.83% <ø> (ø)
primitives 88.50% <100.00%> (ø)

@onbjerg onbjerg marked this pull request as ready for review June 30, 2023 01:51
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.

not familiar with the proptest/arbitrary stuff

defer to @joshieDo

@@ -68,11 +68,17 @@ impl From<Vec<H256>> for GetBlockBodies {

/// The response to [`GetBlockBodies`], containing the block bodies that the peer knows about if
/// any were found.
#[derive_arbitrary(rlp, 1)]
#[derive_arbitrary(rlp, 16)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

what does the number represent in this derive macro?

Copy link
Member Author

Choose a reason for hiding this comment

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

the number of test cases, default is 256, but we set it to 1 previously because it was expensive. with these changes we can bump it to 16, and while still relatively costly, this is manageable. imo better to have more test cases than a single large test case

Comment on lines +76 to +81
#[cfg_attr(
any(test, feature = "arbitrary"),
proptest(
strategy = "proptest::collection::vec(proptest::arbitrary::any::<BlockBody>(), 0..=20)"
)
)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't really understand how proptest works,
why does this need to be specified at all?
I would expect that these things would be configured when the proptest is created, or is this how we pass this information to the macro?

this looks a bit weird at first but I don't really care as long as this speeds up tests

Copy link
Member Author

Choose a reason for hiding this comment

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

the issue is that we are deriving proptest::Arbitrary instead of specifying how it should create these types, so it's very opaque. by default, all vecs have a range of 0..100, so this type in particular by default will have 0..100 block bodies, each with 0..100 ommers, 0..100 transactions (which can have 0..100 access list items, which can have 0..100 storage slots in each item) and so on. as you can see, this quickly explodes.

since the test is auto-generated, we can't configure this in there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

a bit ugly :(, but necessary

@mattsse mattsse added this pull request to the merge queue Jul 2, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 2, 2023
@mattsse mattsse enabled auto-merge July 2, 2023 10:05
@mattsse mattsse requested a review from rakita as a code owner July 2, 2023 10:14
@mattsse mattsse added this pull request to the merge queue Jul 2, 2023
Merged via the queue into main with commit d14f995 Jul 2, 2023
@mattsse mattsse deleted the onbjerg/slow-tests branch July 2, 2023 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-test A change that impacts how or what we test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate slow tests
3 participants