-
Notifications
You must be signed in to change notification settings - Fork 100
feat(l1): add prune-blocks
tool
#4138
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
base: main
Are you sure you want to change the base?
Conversation
Lines of code reportTotal lines added: Detailed view
|
.map_err(StoreError::LibmdbxError)? | ||
else { | ||
// Block must have been already purged | ||
txn.commit().map_err(StoreError::LibmdbxError)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to commit here? Can't we just abort or discard the tx?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some problems because of this when testing it
// Remove transaction location and receipts. Note that if the block was obtained via snap sync these are not guaranteed to exist | ||
for (idx, tx_hash) in block_body | ||
.transactions | ||
.iter() | ||
.map(|tx| tx.hash()) | ||
.enumerate() | ||
{ | ||
txn.delete::<TransactionLocations>(tx_hash.into(), None) | ||
.map_err(StoreError::LibmdbxError)?; | ||
txn.delete::<Receipts>((block_hash, idx as u64).into(), None) | ||
.map_err(StoreError::LibmdbxError)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these aren't guaranteed to exist, should we ignore any errors then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't get an error if they don't exist
tooling/prune-blocks/src/README.md
Outdated
|
||
The tool takes two optional arguments: | ||
*`datadir`: The path to the DB location, will use the default one if not provided | ||
*`blocks_to_keep`: The amount of latest blocks that will be kept in the DB. This value must be al least 128 and lower than the current amount of blocks in the chain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*`blocks_to_keep`: The amount of latest blocks that will be kept in the DB. This value must be al least 128 and lower than the current amount of blocks in the chain. | |
*`blocks_to_keep`: The number of latest blocks that will be kept in the DB. This value must be at least 128 and lower than the current number of blocks in the chain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer amount
instead of number
as number could be confused with an actual block number (aka keep blocks in store as of block number X instead of keeping X amount of blocks from the latest). Fixed the typo
Co-authored-by: Tomás Grüner <[email protected]>
Co-authored-by: Tomás Grüner <[email protected]>
Co-authored-by: Tomás Grüner <[email protected]>
Motivation
Ethrex nodes can get pretty heavy. In order to lower the space of the DB when full syncing large networks this PR proposes adding a
prune-blocks
tool which will remove old blocks and their associated data.Description
prune-blocks
toolCloses #issue_number