-
Notifications
You must be signed in to change notification settings - Fork 10
feat: create index table to efficiently prune history tables #280
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
698ae77
483c93a
9264e1a
5825d4f
b51a024
c3c3ab0
2bd59d6
b107104
fbe67f5
8a09b1a
1129d5c
4d274ff
d9df8ec
3b90e7e
9aac65a
af0af9a
3eea2ea
b519783
e24dd00
5d1eeae
51136d0
0a8d374
cd2508b
665432b
fef227a
1319a24
bbcc4e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,125 @@ | ||||||||||||||||
| use crate::db::{HashedStorageKey, StorageTrieKey}; | ||||||||||||||||
| use alloy_primitives::B256; | ||||||||||||||||
| use reth_db::{ | ||||||||||||||||
| table::{self, Decode, Encode}, | ||||||||||||||||
| DatabaseError, | ||||||||||||||||
| }; | ||||||||||||||||
| use reth_trie::StoredNibbles; | ||||||||||||||||
| use serde::{Deserialize, Serialize}; | ||||||||||||||||
|
|
||||||||||||||||
| /// The keys of the entries in the history tables. | ||||||||||||||||
| #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] | ||||||||||||||||
| pub struct ChangeSet { | ||||||||||||||||
| /// Keys changed in [`AccountTrieHistory`](super::AccountTrieHistory) table. | ||||||||||||||||
| pub account_trie_keys: Vec<StoredNibbles>, | ||||||||||||||||
| /// Keys changed in [`StorageTrieHistory`](super::StorageTrieHistory) table. | ||||||||||||||||
| pub storage_trie_keys: Vec<StorageTrieKey>, | ||||||||||||||||
| /// Keys changed in [`HashedAccountHistory`](super::HashedAccountHistory) table. | ||||||||||||||||
| pub hashed_account_keys: Vec<B256>, | ||||||||||||||||
| /// Keys changed in [`HashedStorageHistory`](super::HashedStorageHistory) table. | ||||||||||||||||
| pub hashed_storage_keys: Vec<HashedStorageKey>, | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| impl table::Encode for ChangeSet { | ||||||||||||||||
| type Encoded = Vec<u8>; | ||||||||||||||||
|
|
||||||||||||||||
| fn encode(self) -> Self::Encoded { | ||||||||||||||||
| bincode::serialize(&self).expect("ChangeSet serialization should not fail") | ||||||||||||||||
|
||||||||||||||||
| bincode::serialize(&self).expect("ChangeSet serialization should not fail") | |
| bincode::serialize(&self).unwrap_or_else(|e| { | |
| panic!( | |
| "ChangeSet serialization failed for {:?}: {}", | |
| self, e | |
| ) | |
| }) |
Copilot
AI
Oct 27, 2025
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.
Unnecessary clone before encoding. The compress_to_buf method takes &self, so you can serialize directly without cloning. Consider implementing compress_to_buf without the intermediate clone.
Uh oh!
There was an error while loading. Please reload this page.