Skip to content

feat(pruner): transaction lookup#3892

Merged
shekhirin merged 10 commits intomainfrom
alexey/pruner-transaction-lookup
Jul 25, 2023
Merged

feat(pruner): transaction lookup#3892
shekhirin merged 10 commits intomainfrom
alexey/pruner-transaction-lookup

Conversation

@shekhirin
Copy link
Member

@shekhirin shekhirin commented Jul 24, 2023

Resolves #3696

This PR adds pruning of transaction lookup entries from the TxHashNumber table. It works in the following way:

  1. Calculate starting and ending transaction number according to the previously saved checkpoint (if any) and the block, to which the pruning needs to be done.
  2. Because TxHashNumber has hashes as keys (hence, ordered by hashes), we need to retrieve the hashes for transaction numbers first. We do that in batches of 10k. So, for each 10k batch of transaction numbers, resolve their hashes in parallel.
  3. Pre-sort hashes to make the deletion from the table sequential without backward jumps.
  4. Prune table, passing the sorted list of hashes.
  5. Repeat for each batch of 10k transaction numbers.

10k transactions take around 2MB in the memory, so we can increase batch size to decrease the number of random jumps needed during the deletion. But we also need to benchmark that.

@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Merging #3892 (174dea5) into main (9a07f57) will increase coverage by 0.00%.
The diff coverage is 91.97%.

Impacted file tree graph

Files Changed Coverage Δ
crates/prune/src/error.rs 0.00% <ø> (ø)
...torage/provider/src/providers/database/provider.rs 77.63% <75.00%> (-0.02%) ⬇️
crates/prune/src/pruner.rs 90.32% <92.37%> (+0.07%) ⬆️
crates/stages/src/test_utils/test_db.rs 83.46% <100.00%> (+0.76%) ⬆️

... and 12 files with indirect coverage changes

Flag Coverage Δ
integration-tests 15.48% <0.00%> (-0.02%) ⬇️
unit-tests 64.49% <91.97%> (+<0.01%) ⬆️

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

Components Coverage Δ
reth binary 27.24% <ø> (ø)
blockchain tree 83.01% <ø> (ø)
pipeline 89.68% <100.00%> (+0.01%) ⬆️
storage (db) 74.19% <75.00%> (-0.01%) ⬇️
trie 94.70% <ø> (ø)
txpool 46.00% <ø> (-0.60%) ⬇️
networking 77.66% <ø> (+0.02%) ⬆️
rpc 58.36% <ø> (-0.03%) ⬇️
consensus 64.46% <ø> (ø)
revm 33.68% <ø> (ø)
payload builder 6.61% <ø> (ø)
primitives 88.06% <ø> (+0.02%) ⬆️

@shekhirin shekhirin marked this pull request as ready for review July 25, 2023 14:03
@shekhirin shekhirin requested review from joshieDo and mattsse July 25, 2023 14:03
@shekhirin shekhirin added C-enhancement New feature or request A-pruning Related to pruning or full node labels Jul 25, 2023
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,

love the tests

Comment on lines 203 to 206
Copy link
Collaborator

Choose a reason for hiding this comment

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

this looks correct but I'd appreciate a note about batch logic

@shekhirin shekhirin force-pushed the alexey/pruner-transaction-lookup branch from 6ba3ea4 to 7228862 Compare July 25, 2023 16:52
@shekhirin shekhirin added this pull request to the merge queue Jul 25, 2023
Merged via the queue into main with commit 736de20 Jul 25, 2023
@shekhirin shekhirin deleted the alexey/pruner-transaction-lookup branch July 25, 2023 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-pruning Related to pruning or full node C-enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Respect Transaction Lookup prune part in the pruner

2 participants