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(pruner): storage history #4006

Merged
merged 43 commits into from
Aug 2, 2023
Merged

feat(pruner): storage history #4006

merged 43 commits into from
Aug 2, 2023

Conversation

shekhirin
Copy link
Collaborator

@shekhirin shekhirin commented Jul 31, 2023

Resolves #3694

Prunes:

  1. StorageChangeSet table: all keys starting with block numbers (and their subkeys which are storage keys) which need to be pruned
  2. StorageHistory table:
    1. If the shard has highest_block_number less than or equal to the target block number for pruning, delete the shard completely.
    2. If the shard has highest_block_number greater than the target block number for pruning, filter block numbers inside the shard which are less than the target block number for pruning.

@shekhirin shekhirin force-pushed the alexey/pruner-storage-history branch from 2f5365c to ae9bb3a Compare July 31, 2023 16:53
@shekhirin shekhirin force-pushed the alexey/pruner-account-history branch 2 times, most recently from b9a7784 to 13131a4 Compare July 31, 2023 16:55
@shekhirin shekhirin force-pushed the alexey/pruner-storage-history branch from ae9bb3a to 2f5365c Compare July 31, 2023 16:55
@shekhirin shekhirin requested a review from Rjected as a code owner August 2, 2023 10:45
@shekhirin shekhirin force-pushed the alexey/pruner-storage-history branch from ee60036 to e5fe91b Compare August 2, 2023 13:35
@codecov
Copy link

codecov bot commented Aug 2, 2023

Codecov Report

Merging #4006 (0f0d0bc) into main (88f83fc) will increase coverage by 0.01%.
The diff coverage is 84.61%.

Impacted file tree graph

Files Changed Coverage Δ
crates/rpc/rpc-builder/src/lib.rs 63.59% <0.00%> (ø)
crates/prune/src/pruner.rs 84.70% <85.34%> (+0.10%) ⬆️

... and 8 files with indirect coverage changes

Flag Coverage Δ
integration-tests 16.48% <0.00%> (-0.02%) ⬇️
unit-tests 64.18% <84.61%> (+0.02%) ⬆️

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

Components Coverage Δ
reth binary 25.84% <ø> (ø)
blockchain tree 83.04% <ø> (ø)
pipeline 90.13% <ø> (+0.03%) ⬆️
storage (db) 74.33% <ø> (ø)
trie 94.70% <ø> (ø)
txpool 47.96% <ø> (-0.03%) ⬇️
networking 77.43% <ø> (-0.03%) ⬇️
rpc 58.28% <0.00%> (-0.01%) ⬇️
consensus 63.50% <ø> (ø)
revm 32.71% <ø> (ø)
payload builder 6.58% <ø> (ø)
primitives 87.99% <ø> (-0.02%) ⬇️

@shekhirin shekhirin requested a review from joshieDo August 2, 2023 13:46
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

Comment on lines +511 to +513
// Shard contains block numbers that are higher than the target one, so we need to
// filter it. It is guaranteed that further shards for this address and storage slot
// will not contain the target block number, as it's in this shard.
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a very useful comment

Comment on lines +514 to +517
let blocks = blocks
.iter(0)
.skip_while(|block| *block <= to_block as usize)
.collect::<Vec<_>>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

these are only numbers and not the actual blocks, so we can safely load them

Comment on lines +520 to +525
// shards are not allowed.
if key.sharded_key.highest_block_number == u64::MAX {
// If current shard is the last shard for this address and storage slot,
// replace it with the previous shard.
if let Some((prev_key, prev_value)) = cursor.prev()? {
if prev_key.address == key.address &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

even if we have a bunch of levels, this is still readable imo

Base automatically changed from alexey/pruner-account-history to main August 2, 2023 14:22
@github-actions github-actions bot requested a review from rkrasiuk as a code owner August 2, 2023 14:22
@shekhirin shekhirin force-pushed the alexey/pruner-storage-history branch 2 times, most recently from f5652d1 to 1317aea Compare August 2, 2023 14:56
@shekhirin shekhirin added this pull request to the merge queue Aug 2, 2023
Merged via the queue into main with commit 8f1bc8a Aug 2, 2023
24 checks passed
@shekhirin shekhirin deleted the alexey/pruner-storage-history branch August 2, 2023 15:16
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 Storage History prune part in the pruner
3 participants