Skip to content
Merged
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
12 changes: 11 additions & 1 deletion anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,11 @@ impl Backend {
(self.spec_id() as u8) >= (SpecId::LONDON as u8)
}

/// Returns true for post Merge
pub fn is_eip3675(&self) -> bool {
(self.spec_id() as u8) >= (SpecId::MERGE as u8)
}

/// Returns true for post Berlin
pub fn is_eip2930(&self) -> bool {
(self.spec_id() as u8) >= (SpecId::BERLIN as u8)
Expand Down Expand Up @@ -842,7 +847,12 @@ impl Backend {
// update block metadata
storage.best_number = block_number;
storage.best_hash = block_hash;
storage.total_difficulty = storage.total_difficulty.saturating_add(header.difficulty);
// Difficulty is removed and not used after Paris (aka TheMerge). Value is replaced with
// prevrandao. https://github.com/bluealloy/revm/blob/1839b3fce8eaeebb85025576f2519b80615aca1e/crates/interpreter/src/instructions/host_env.rs#L27
if !self.is_eip3675() {
storage.total_difficulty =
storage.total_difficulty.saturating_add(header.difficulty);
}

storage.blocks.insert(block_hash, block);
storage.hashes.insert(block_number, block_hash);
Expand Down