-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(pruner, primitives): move prune batch sizes to ChainSpec
#4318
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
Changes from all commits
cf670f2
689d267
d9115be
bbf5c0c
adffcf6
8fa4757
80a53ef
1d149e0
54a67f6
4939ab9
8451bed
c10eeb5
df14e1e
0498b18
a092d72
bedb5a4
1ac798b
08f71e2
b941ed4
9b4925a
ceded5f
cc581aa
7d6f561
8c06a5d
e9cbd3a
bd0808f
de2d739
d9595b7
d4e760a
a042bf6
7d43486
2d40ea1
407bdcc
3e511ca
623f3a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| use paste::paste; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| /// Batch sizes for configuring the pruner. | ||
| /// The batch size for each prune part should be both large enough to prune the data which was | ||
| /// generated with each new block, and small enough to not generate an excessive load on the | ||
| /// database due to deletion of too many rows at once. | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] | ||
| pub struct PruneBatchSizes { | ||
| /// Maximum number of receipts to prune, per block. | ||
| receipts: usize, | ||
| /// Maximum number of transaction lookup entries to prune, per block. | ||
| transaction_lookup: usize, | ||
| /// Maximum number of transaction senders to prune, per block. | ||
| transaction_senders: usize, | ||
| /// Maximum number of account history entries to prune, per block. | ||
| /// Measured in the number of `AccountChangeSet` table rows. | ||
| account_history: usize, | ||
| /// Maximum number of storage history entries to prune, per block. | ||
| /// Measured in the number of `StorageChangeSet` table rows. | ||
| storage_history: usize, | ||
| } | ||
|
|
||
| macro_rules! impl_prune_batch_size_methods { | ||
| ($(($human_name:expr, $name:ident)),+) => { | ||
| paste! { | ||
| impl PruneBatchSizes { | ||
| $( | ||
| #[doc = concat!("Maximum number of ", $human_name, " to prune, accounting for the block interval.")] | ||
| pub fn $name(&self, block_interval: usize) -> usize { | ||
| self.$name * block_interval | ||
| } | ||
|
|
||
| #[doc = concat!("Set the maximum number of ", $human_name, " to prune per block.")] | ||
| pub fn [<with_ $name>](mut self, batch_size: usize) -> Self { | ||
| self.$name = batch_size; | ||
| self | ||
| } | ||
| )+ | ||
| } | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| impl_prune_batch_size_methods!( | ||
| ("receipts", receipts), | ||
| ("transaction lookup entries", transaction_lookup), | ||
| ("transaction senders", transaction_senders), | ||
| ("account history entries", account_history), | ||
| ("storage history entries", storage_history) | ||
| ); | ||
|
|
||
| impl PruneBatchSizes { | ||
| /// Default prune batch sizes for Ethereum mainnet. | ||
| /// These settings are sufficient to prune more data than generated with each new block. | ||
| pub const fn mainnet() -> Self { | ||
| Self { | ||
| receipts: 250, | ||
| transaction_lookup: 250, | ||
| transaction_senders: 250, | ||
| account_history: 1000, | ||
|
Comment on lines
+55
to
+61
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. assuming these are heuristics/made up?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I just added a new DB metric #4316 which will allow to measure these values more accurately, as I was gathering the data just snapshotting the |
||
| storage_history: 1000, | ||
| } | ||
| } | ||
|
|
||
| /// Default prune batch sizes for Ethereum testnets. | ||
| /// These settings are sufficient to prune more data than generated with each new block. | ||
| pub const fn testnet() -> Self { | ||
| Self { | ||
| receipts: 100, | ||
| transaction_lookup: 100, | ||
| transaction_senders: 100, | ||
| account_history: 500, | ||
| storage_history: 500, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl Default for PruneBatchSizes { | ||
| fn default() -> Self { | ||
| Self::mainnet() | ||
| } | ||
| } | ||
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.
nice