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

fix Eip3155 inspector summary gas_used bug and add fork name #1216

Merged
merged 1 commit into from
Mar 22, 2024
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
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()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool find

pass: outcome.result.is_ok(),

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