Skip to content

Commit

Permalink
Nit: replace block and sender with RecoveredBlock in ExecutedBlock (#…
Browse files Browse the repository at this point in the history
…13804)

Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
voidash and mattsse authored Jan 16, 2025
1 parent 7df9838 commit 13ecd6a
Show file tree
Hide file tree
Showing 12 changed files with 443 additions and 380 deletions.
256 changes: 130 additions & 126 deletions crates/chain-state/src/in_memory.rs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions crates/chain-state/src/memory_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ impl<'a, N: NodePrimitives> MemoryOverlayStateProviderRef<'a, N> {
impl<N: NodePrimitives> BlockHashReader for MemoryOverlayStateProviderRef<'_, N> {
fn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>> {
for block in &self.in_memory {
if block.block.number() == number {
return Ok(Some(block.block.hash()));
if block.recovered_block().number() == number {
return Ok(Some(block.recovered_block().hash()));
}
}

Expand All @@ -82,9 +82,9 @@ impl<N: NodePrimitives> BlockHashReader for MemoryOverlayStateProviderRef<'_, N>
let mut earliest_block_number = None;
let mut in_memory_hashes = Vec::new();
for block in &self.in_memory {
if range.contains(&block.block.number()) {
in_memory_hashes.insert(0, block.block.hash());
earliest_block_number = Some(block.block.number());
if range.contains(&block.recovered_block().number()) {
in_memory_hashes.insert(0, block.recovered_block().hash());
earliest_block_number = Some(block.recovered_block().number());
}
}

Expand Down
5 changes: 2 additions & 3 deletions crates/chain-state/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ impl<N: NodePrimitives> TestBlockBuilder<N> {

let (block, senders) = block_with_senders.split_sealed();
ExecutedBlock::new(
Arc::new(block),
Arc::new(senders),
Arc::new(RecoveredBlock::new_sealed(block, senders)),
Arc::new(ExecutionOutcome::new(
BundleState::default(),
receipts,
Expand Down Expand Up @@ -251,7 +250,7 @@ impl<N: NodePrimitives> TestBlockBuilder<N> {
range.map(move |number| {
let current_parent_hash = parent_hash;
let block = self.get_executed_block_with_number(number, current_parent_hash);
parent_hash = block.block.hash();
parent_hash = block.recovered_block().hash();
block
})
}
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/tree/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl<T: EngineTypes, N: NodePrimitives> Display for EngineApiRequest<T, N> {
match self {
Self::Beacon(msg) => msg.fmt(f),
Self::InsertExecutedBlock(block) => {
write!(f, "InsertExecutedBlock({:?})", block.block().num_hash())
write!(f, "InsertExecutedBlock({:?})", block.recovered_block().num_hash())
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions crates/engine/tree/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ where
&self,
blocks: Vec<ExecutedBlock<N::Primitives>>,
) -> Result<Option<BlockNumHash>, PersistenceError> {
debug!(target: "engine::persistence", first=?blocks.first().map(|b| b.block.num_hash()), last=?blocks.last().map(|b| b.block.num_hash()), "Saving range of blocks");
debug!(target: "engine::persistence", first=?blocks.first().map(|b| b.recovered_block.num_hash()), last=?blocks.last().map(|b| b.recovered_block.num_hash()), "Saving range of blocks");
let start_time = Instant::now();
let last_block_hash_num = blocks.last().map(|block| BlockNumHash {
hash: block.block().hash(),
number: block.block().header().number(),
hash: block.recovered_block().hash(),
number: block.recovered_block().header().number(),
});

if last_block_hash_num.is_some() {
Expand Down Expand Up @@ -339,7 +339,7 @@ mod tests {
let mut test_block_builder = TestBlockBuilder::eth();
let executed =
test_block_builder.get_executed_block_with_number(block_number, B256::random());
let block_hash = executed.block().hash();
let block_hash = executed.recovered_block().hash();

let blocks = vec![executed];
let (tx, rx) = oneshot::channel();
Expand All @@ -363,7 +363,7 @@ mod tests {

let mut test_block_builder = TestBlockBuilder::eth();
let blocks = test_block_builder.get_executed_blocks(0..5).collect::<Vec<_>>();
let last_hash = blocks.last().unwrap().block().hash();
let last_hash = blocks.last().unwrap().recovered_block().hash();
let (tx, rx) = oneshot::channel();

persistence_handle.save_blocks(blocks, tx).unwrap();
Expand All @@ -380,7 +380,7 @@ mod tests {
let mut test_block_builder = TestBlockBuilder::eth();
for range in ranges {
let blocks = test_block_builder.get_executed_blocks(range).collect::<Vec<_>>();
let last_hash = blocks.last().unwrap().block().hash();
let last_hash = blocks.last().unwrap().recovered_block().hash();
let (tx, rx) = oneshot::channel();

persistence_handle.save_blocks(blocks, tx).unwrap();
Expand Down
Loading

0 comments on commit 13ecd6a

Please sign in to comment.