Skip to content

Commit

Permalink
feat(interpreter): remove SPEC generic from gas calculation functions (
Browse files Browse the repository at this point in the history
…bluealloy#1243)

* feat(interpreter): remove SPEC generic from gas calculation functions

* feat(interpreter): make most gas cost calculation functions `const`

* set_final_refund

* unused

* fix: optimism

* chore: use `is_london: bool` instead of `SpecId` in `Gas::set_final_refund`
  • Loading branch information
DaniPopes authored Apr 3, 2024
1 parent 5d5c5f1 commit 96dda38
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 110 deletions.
5 changes: 2 additions & 3 deletions crates/interpreter/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod constants;

pub use calc::*;
pub use constants::*;
use revm_primitives::{Spec, SpecId::LONDON};

/// Represents the state of gas during execution.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -94,8 +93,8 @@ impl Gas {
///
/// Related to EIP-3529: Reduction in refunds
#[inline]
pub fn set_final_refund<SPEC: Spec>(&mut self) {
let max_refund_quotient = if SPEC::enabled(LONDON) { 5 } else { 2 };
pub fn set_final_refund(&mut self, is_london: bool) {
let max_refund_quotient = if is_london { 5 } else { 2 };
self.refunded = (self.refunded() as u64).min(self.spent() / max_refund_quotient) as i64;
}

Expand Down
Loading

0 comments on commit 96dda38

Please sign in to comment.