Skip to content
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
12 changes: 12 additions & 0 deletions crates/context/interface/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ pub trait Cfg {
/// Returns whether the fee charge is disabled.
fn is_fee_charge_disabled(&self) -> bool;

/// Returns whether EIP-7708 (ETH transfers emit logs) is disabled.
fn is_eip7708_disabled(&self) -> bool;

/// Returns whether EIP-7708 delayed burn logging is disabled.
///
/// When enabled, revm tracks all self-destructed addresses and emits logs for
/// accounts that still have remaining balance at the end of the transaction.
/// This can be disabled for performance reasons as it requires storing and
/// iterating over all self-destructed accounts. When disabled, the logging
/// can be done outside of revm when applying accounts to database state.
fn is_eip7708_delayed_burn_disabled(&self) -> bool;

/// Returns the limit in bytes for the memory buffer.
fn memory_limit(&self) -> u64;

Expand Down
11 changes: 11 additions & 0 deletions crates/context/interface/src/journaled_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ pub trait JournalTr {
/// Sets the spec id.
fn set_spec_id(&mut self, spec_id: SpecId);

/// Sets EIP-7708 configuration flags.
///
/// - `disabled`: Whether EIP-7708 (ETH transfers emit logs) is completely disabled.
/// - `delayed_burn_disabled`: Whether delayed burn logging is disabled. When enabled,
/// revm tracks all self-destructed addresses and emits logs for accounts that still
/// have remaining balance at the end of the transaction. This can be disabled for
/// performance reasons as it requires storing and iterating over all self-destructed
/// accounts. When disabled, the logging can be done outside of revm when applying
/// accounts to database state.
fn set_eip7708_config(&mut self, disabled: bool, delayed_burn_disabled: bool);

/// Touches the account.
fn touch_account(&mut self, address: Address);

Expand Down
26 changes: 26 additions & 0 deletions crates/context/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ pub struct CfgEnv<SPEC = SpecId> {
/// By default, it is set to `false`.
#[cfg(feature = "optional_fee_charge")]
pub disable_fee_charge: bool,
/// Disables EIP-7708 (ETH transfers emit logs).
///
/// By default, it is set to `false`.
pub amsterdam_eip7708_disabled: bool,
/// Disables EIP-7708 delayed burn logging.
///
/// When enabled, revm tracks all self-destructed addresses and emits logs for
/// accounts that still have remaining balance at the end of the transaction.
/// This can be disabled for performance reasons as it requires storing and
/// iterating over all self-destructed accounts. When disabled, the logging
/// can be done outside of revm when applying accounts to database state.
///
/// By default, it is set to `false`.
pub amsterdam_eip7708_delayed_burn_disabled: bool,
}

impl CfgEnv {
Expand Down Expand Up @@ -171,6 +185,8 @@ impl<SPEC> CfgEnv<SPEC> {
disable_priority_fee_check: false,
#[cfg(feature = "optional_fee_charge")]
disable_fee_charge: false,
amsterdam_eip7708_disabled: false,
amsterdam_eip7708_delayed_burn_disabled: false,
}
}

Expand Down Expand Up @@ -273,6 +289,8 @@ impl<SPEC> CfgEnv<SPEC> {
disable_priority_fee_check: self.disable_priority_fee_check,
#[cfg(feature = "optional_fee_charge")]
disable_fee_charge: self.disable_fee_charge,
amsterdam_eip7708_disabled: self.amsterdam_eip7708_disabled,
amsterdam_eip7708_delayed_burn_disabled: self.amsterdam_eip7708_delayed_burn_disabled,
}
}

Expand Down Expand Up @@ -488,6 +506,14 @@ impl<SPEC: Into<SpecId> + Clone> Cfg for CfgEnv<SPEC> {
}
}

fn is_eip7708_disabled(&self) -> bool {
self.amsterdam_eip7708_disabled
}

fn is_eip7708_delayed_burn_disabled(&self) -> bool {
self.amsterdam_eip7708_delayed_burn_disabled
}

fn memory_limit(&self) -> u64 {
cfg_if::cfg_if! {
if #[cfg(feature = "memory_limit")] {
Expand Down
39 changes: 33 additions & 6 deletions crates/context/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,17 @@ impl<
///
/// This will create a new [`Journal`] object.
pub fn new(db: DB, spec: SPEC) -> Self {
let cfg = CfgEnv::new_with_spec(spec);
let mut journaled_state = JOURNAL::new(db);
journaled_state.set_spec_id(spec.clone().into());
journaled_state.set_spec_id(cfg.spec.clone().into());
journaled_state.set_eip7708_config(
cfg.amsterdam_eip7708_disabled,
cfg.amsterdam_eip7708_delayed_burn_disabled,
);
Self {
tx: TX::default(),
block: BLOCK::default(),
cfg: CfgEnv::new_with_spec(spec),
cfg,
local: LOCAL::default(),
journaled_state,
chain: Default::default(),
Expand All @@ -170,6 +175,10 @@ where
mut journal: OJOURNAL,
) -> Context<BLOCK, TX, CFG, DB, OJOURNAL, CHAIN, LOCAL> {
journal.set_spec_id(self.cfg.spec().into());
journal.set_eip7708_config(
self.cfg.is_eip7708_disabled(),
self.cfg.is_eip7708_delayed_burn_disabled(),
);
Context {
tx: self.tx,
block: self.block,
Expand All @@ -188,9 +197,12 @@ where
self,
db: ODB,
) -> Context<BLOCK, TX, CFG, ODB, Journal<ODB>, CHAIN, LOCAL> {
let spec = self.cfg.spec().into();
let mut journaled_state = Journal::new(db);
journaled_state.set_spec_id(spec);
journaled_state.set_spec_id(self.cfg.spec().into());
journaled_state.set_eip7708_config(
self.cfg.is_eip7708_disabled(),
self.cfg.is_eip7708_delayed_burn_disabled(),
);
Context {
tx: self.tx,
block: self.block,
Expand All @@ -208,9 +220,12 @@ where
db: ODB,
) -> Context<BLOCK, TX, CFG, WrapDatabaseRef<ODB>, Journal<WrapDatabaseRef<ODB>>, CHAIN, LOCAL>
{
let spec = self.cfg.spec().into();
let mut journaled_state = Journal::new(WrapDatabaseRef(db));
journaled_state.set_spec_id(spec);
journaled_state.set_spec_id(self.cfg.spec().into());
journaled_state.set_eip7708_config(
self.cfg.is_eip7708_disabled(),
self.cfg.is_eip7708_delayed_burn_disabled(),
);
Context {
tx: self.tx,
block: self.block,
Expand Down Expand Up @@ -272,6 +287,10 @@ where
cfg: OCFG,
) -> Context<BLOCK, TX, OCFG, DB, JOURNAL, CHAIN, LOCAL> {
self.journaled_state.set_spec_id(cfg.spec().into());
self.journaled_state.set_eip7708_config(
cfg.is_eip7708_disabled(),
cfg.is_eip7708_delayed_burn_disabled(),
);
Context {
tx: self.tx,
block: self.block,
Expand Down Expand Up @@ -307,6 +326,10 @@ where
{
f(&mut self.cfg);
self.journaled_state.set_spec_id(self.cfg.spec().into());
self.journaled_state.set_eip7708_config(
self.cfg.is_eip7708_disabled(),
self.cfg.is_eip7708_delayed_burn_disabled(),
);
self
}

Expand Down Expand Up @@ -383,6 +406,10 @@ where
{
f(&mut self.cfg);
self.journaled_state.set_spec_id(self.cfg.spec().into());
self.journaled_state.set_eip7708_config(
self.cfg.is_eip7708_disabled(),
self.cfg.is_eip7708_delayed_burn_disabled(),
);
}

/// Modifies the context chain.
Expand Down
12 changes: 9 additions & 3 deletions crates/context/src/journal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod inner;
pub mod warm_addresses;

pub use context_interface::journaled_state::entry::{JournalEntry, JournalEntryTr};
pub use inner::JournalInner;
pub use inner::{JournalCfg, JournalInner};

use bytecode::Bytecode;
use context_interface::{
Expand Down Expand Up @@ -196,7 +196,13 @@ impl<DB: Database, ENTRY: JournalEntryTr> JournalTr for Journal<DB, ENTRY> {

#[inline]
fn set_spec_id(&mut self, spec_id: SpecId) {
self.inner.spec = spec_id;
self.inner.cfg.spec = spec_id;
}

#[inline]
fn set_eip7708_config(&mut self, disabled: bool, delayed_burn_disabled: bool) {
self.inner
.set_eip7708_config(disabled, delayed_burn_disabled);
}

#[inline]
Expand Down Expand Up @@ -384,7 +390,7 @@ impl<DB: Database, ENTRY: JournalEntryTr> JournalTr for Journal<DB, ENTRY> {
load_code: bool,
skip_cold_load: bool,
) -> Result<AccountInfoLoad<'_>, JournalLoadError<<Self::Database as Database>::Error>> {
let spec = self.inner.spec;
let spec = self.inner.cfg.spec;
self.inner
.load_account_optional(&mut self.database, address, load_code, skip_cold_load)
.map(|a| {
Expand Down
Loading