Skip to content

Commit

Permalink
chore(merkle): remove last walker key from checkpoint (#5069)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrasiuk authored Oct 18, 2023
1 parent f92e388 commit f7fc01c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
31 changes: 2 additions & 29 deletions crates/primitives/src/stage/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,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 @@ -33,13 +30,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 @@ -56,10 +47,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 @@ -79,10 +66,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 @@ -92,16 +75,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 @@ -375,7 +349,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

0 comments on commit f7fc01c

Please sign in to comment.