Skip to content

Commit

Permalink
fix eip3155 summary gas_used bug and add fork name (#1216)
Browse files Browse the repository at this point in the history
Co-authored-by: PanaW <[email protected]>
  • Loading branch information
Pana and PanaW authored Mar 22, 2024
1 parent 4c15846 commit 882211c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
34 changes: 34 additions & 0 deletions crates/primitives/src/specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,40 @@ impl From<&str> for SpecId {
}
}

impl From<SpecId> for &'static str {
fn from(spec_id: SpecId) -> Self {
match spec_id {
SpecId::FRONTIER => "Frontier",
SpecId::FRONTIER_THAWING => "Frontier Thawing",
SpecId::HOMESTEAD => "Homestead",
SpecId::DAO_FORK => "DAO Fork",
SpecId::TANGERINE => "Tangerine",
SpecId::SPURIOUS_DRAGON => "Spurious",
SpecId::BYZANTIUM => "Byzantium",
SpecId::CONSTANTINOPLE => "Constantinople",
SpecId::PETERSBURG => "Petersburg",
SpecId::ISTANBUL => "Istanbul",
SpecId::MUIR_GLACIER => "MuirGlacier",
SpecId::BERLIN => "Berlin",
SpecId::LONDON => "London",
SpecId::ARROW_GLACIER => "Arrow Glacier",
SpecId::GRAY_GLACIER => "Gray Glacier",
SpecId::MERGE => "Merge",
SpecId::SHANGHAI => "Shanghai",
SpecId::CANCUN => "Cancun",
#[cfg(feature = "optimism")]
SpecId::BEDROCK => "Bedrock",
#[cfg(feature = "optimism")]
SpecId::REGOLITH => "Regolith",
#[cfg(feature = "optimism")]
SpecId::CANYON => "Canyon",
#[cfg(feature = "optimism")]
SpecId::ECOTONE => "Ecotone",
SpecId::LATEST => "Latest",
}
}
}

pub trait Spec: Sized + 'static {
/// The specification ID.
const SPEC_ID: SpecId;
Expand Down
5 changes: 3 additions & 2 deletions crates/revm/src/inspector/eip3155.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,15 @@ impl<DB: Database> Inspector<DB> for TracerEip3155 {
) -> CallOutcome {
let outcome = self.gas_inspector.call_end(context, inputs, outcome);
if self.print_summary && context.journaled_state.depth() == 0 {
let spec_name: &str = context.spec_id().into();
let value = Summary {
state_root: B256::ZERO.to_string(),
output: outcome.result.output.to_string(),
gas_used: hex_number(self.gas_inspector.gas_remaining()),
gas_used: hex_number(inputs.gas_limit - self.gas_inspector.gas_remaining()),
pass: outcome.result.is_ok(),

time: None,
fork: None,
fork: Some(spec_name.to_string()),
};
let _ = self.write_value(&value);
}
Expand Down

0 comments on commit 882211c

Please sign in to comment.