-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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(pruning): prune storage history by contract or slots #4580
base: main
Are you sure you want to change the base?
feat(pruning): prune storage history by contract or slots #4580
Conversation
Sorry for the delay in review, been busy with working on new features. Will take a look today! |
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 one pass, will take another look. Also would appreciate @joshieDo's review because the logic is similar to receipts by logs pruning.
Overall seems ok, I wonder if we can somehow unify the lowest_block_with_distance
and group_by_block
logics between receipts and storages? Because we will also probably add the same pruning for accounts, and it'll be the 3rd implementation of almost the same functionality.
They seem the same. Maybe we can make a common trait (given that we will add even more), add a default impl that takes the |
Yes, sure we can add a common trait. Maybe I can wait for some other reviews / feedbacks and then work on it all together. Let me know. |
Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
Codecov ReportAttention:
Additional details and impacted files
... and 521 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more.
|
335f738
to
2472339
Compare
…-by-contract-or-slot
2472339
to
7fc3f3f
Compare
crates/primitives/src/prune/mod.rs
Outdated
/// Helper struct for `StorageHistoryPruneConfig`. | ||
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, Ord, PartialOrd)] | ||
pub struct AddressAndSlots { | ||
/// Address to exclude from storage history pruning | ||
pub address: Address, | ||
/// Slots to exclude from storage history pruning | ||
pub slots: Vec<StorageKey>, | ||
} | ||
|
||
/// Configuration for pruning storage history not associated with specifies address. | ||
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] | ||
pub struct StorageHistoryPruneConfig(pub BTreeMap<AddressAndSlots, PruneMode>); |
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.
is it possible to set this configuration from TOML config file? IIUC it needs to have a map with AddressAndSlots
as a key, but TOML doesn't support non-string keys.
I think it would be better to stick to a format like so
pub struct AddressAndSlots {
pub address: Address,
pub slots: Vec<StorageKey>,
}
pub struct StorageHistoryPruneAddressConfig {
pub mode: Option<PruneMode>,
pub slots: BTreeMap<StorageKey, PruneMode>,
}
pub struct StorageHistoryPruneConfig(pub BTreeMap<Address, StorageHistoryPruneAddressConfig>);
to be able to set the configuration according to the format I've mentioned in #4350 (comment)
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'm going to sync a node on this PR by changing the default configuration for this segment, and see if the expected contract storages or storage slots are preserved.
Hi @alessandromazza98 what's your plan here for next steps? Would love to get it in, or else would like to close anything stale |
Hei @gakonst , thanks for pinging me. I'd like to go ahead with it. I'm gonna think what are best next steps and do them. I'll update the issue very shortly, thanks. |
I tested with a TOML file like this:
Those are two contracts on Ethereum mainnet (USDC the first one). I also added another test to verify for the pruning of a contract AND a storage slot. Basically you can filter like this in the TOML file:
|
Closes #4350
This is my attempt to solve that issue. I would like to receive some review and feedback on it please. @shekhirin
I tried to also add a test for it but it's incomplete for now because I was not able to properly test
StorageHistory
table.As of now my test only tests that, after pruning specifying a contract address (and not a slot), inside
StorageChangeSet
table there are only changes related to the specified address or that are unprunable (tip - 128).I took a lot of inspiration from the previous pruning_receipts_by_log feature.