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

chore(merkle): remove last walker key from checkpoint #5069

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 2 additions & 29 deletions crates/primitives/src/stage/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ pub struct MerkleCheckpoint {
pub target_block: BlockNumber,
/// The last hashed account key processed.
pub last_account_key: B256,
// TODO: remove in the next breaking release.
/// The last walker key processed.
pub last_walker_key: Vec<u8>,
/// Previously recorded walker stack.
pub walker_stack: Vec<StoredSubNode>,
/// The hash builder state.
Expand All @@ -34,13 +31,7 @@ impl MerkleCheckpoint {
walker_stack: Vec<StoredSubNode>,
state: HashBuilderState,
) -> Self {
Self {
target_block,
last_account_key,
walker_stack,
state,
last_walker_key: Vec::default(),
}
Self { target_block, last_account_key, walker_stack, state }
}
}

Expand All @@ -57,10 +48,6 @@ impl Compact for MerkleCheckpoint {
buf.put_slice(self.last_account_key.as_slice());
len += self.last_account_key.len();

buf.put_u16(self.last_walker_key.len() as u16);
buf.put_slice(&self.last_walker_key[..]);
len += 2 + self.last_walker_key.len();

buf.put_u16(self.walker_stack.len() as u16);
len += 2;
for item in self.walker_stack.into_iter() {
Expand All @@ -80,10 +67,6 @@ impl Compact for MerkleCheckpoint {
let last_account_key = B256::from_slice(&buf[..32]);
buf.advance(32);

let last_walker_key_len = buf.get_u16() as usize;
let last_walker_key = Vec::from(&buf[..last_walker_key_len]);
buf.advance(last_walker_key_len);

let walker_stack_len = buf.get_u16() as usize;
let mut walker_stack = Vec::with_capacity(walker_stack_len);
for _ in 0..walker_stack_len {
Expand All @@ -93,16 +76,7 @@ impl Compact for MerkleCheckpoint {
}

let (state, buf) = HashBuilderState::from_compact(buf, 0);
(
MerkleCheckpoint {
target_block,
last_account_key,
last_walker_key,
walker_stack,
state,
},
buf,
)
(MerkleCheckpoint { target_block, last_account_key, walker_stack, state }, buf)
}
}

Expand Down Expand Up @@ -402,7 +376,6 @@ mod tests {
let checkpoint = MerkleCheckpoint {
target_block: rng.gen(),
last_account_key: rng.gen(),
last_walker_key: B256::random_with(&mut rng).to_vec(),
walker_stack: vec![StoredSubNode {
key: B256::random_with(&mut rng).to_vec(),
nibble: Some(rng.gen()),
Expand Down
3 changes: 0 additions & 3 deletions crates/stages/src/stages/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use reth_db::{
};
use reth_interfaces::consensus;
use reth_primitives::{
hex,
stage::{EntitiesCheckpoint, MerkleCheckpoint, StageCheckpoint, StageId},
trie::StoredSubNode,
BlockNumber, SealedHeader, B256,
Expand Down Expand Up @@ -125,7 +124,6 @@ impl MerkleStage {
debug!(
target: "sync::stages::merkle::exec",
last_account_key = ?checkpoint.last_account_key,
last_walker_key = ?hex::encode(&checkpoint.last_walker_key),
"Saving inner merkle checkpoint"
);
checkpoint.to_compact(&mut buf);
Expand Down Expand Up @@ -184,7 +182,6 @@ impl<DB: Database> Stage<DB> for MerkleStage {
current = ?current_block_number,
target = ?to_block,
last_account_key = ?checkpoint.last_account_key,
last_walker_key = ?hex::encode(&checkpoint.last_walker_key),
"Continuing inner merkle checkpoint"
);

Expand Down
Loading