Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
rust: [ "stable", "beta", "nightly" ]
flags: [ "--no-default-features", "", "--all-features" ]
flags: [ "--no-default-features", "" ]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
Expand Down
45 changes: 23 additions & 22 deletions crates/context/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,32 @@ database.workspace = true
[features]
default = ["std"]
std = [
"serde?/std",
"bytecode/std",
"context-interface/std",
"database/std",
"database-interface/std",
"primitives/std",
"state/std",
"serde?/std",
"bytecode/std",
"context-interface/std",
"database/std",
"database-interface/std",
"primitives/std",
"state/std",
]
serde = [
"dep:serde",
"primitives/serde",
"state/serde",
"context-interface/serde",
"bytecode/serde",
"database/serde",
"database-interface/serde",
"derive-where/serde",
"dep:serde",
"primitives/serde",
"state/serde",
"context-interface/serde",
"bytecode/serde",
"database/serde",
"database-interface/serde",
"derive-where/serde",
]
dev = [
"memory_limit",
"optional_balance_check",
"optional_block_gas_limit",
"optional_eip3541",
"optional_eip3607",
"optional_no_base_fee",
"optional_priority_fee_check",
"memory_limit",
"optional_balance_check",
"optional_block_gas_limit",
"optional_eip3541",
"optional_eip3607",
"optional_no_base_fee",
"optional_priority_fee_check",
]
memory_limit = []
optional_balance_check = []
Expand All @@ -71,3 +71,4 @@ optional_eip3541 = []
optional_eip3607 = []
optional_no_base_fee = []
optional_priority_fee_check = []
optional_eip7708 = []
14 changes: 14 additions & 0 deletions crates/context/src/journal/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ use context_interface::{
};
use core::mem;
use database_interface::Database;
#[cfg(feature = "optional_eip7708")]
use primitives::eip7708::create_eip7708_log;
use primitives::{
hardfork::SpecId::{self, *},
hash_map::Entry,
Address, HashMap, HashSet, Log, StorageKey, StorageValue, B256, KECCAK_EMPTY, U256,
};
use state::{Account, EvmState, EvmStorageSlot, TransientStorage};
use std::vec::Vec;

/// Inner journal state that contains journal and state changes.
///
/// Spec Id is a essential information for the Journal.
Expand Down Expand Up @@ -382,6 +385,10 @@ impl<ENTRY: JournalEntryTr> JournalInner<ENTRY> {
self.journal
.push(ENTRY::balance_transfer(from, to, balance));

// Emit native transfer log
#[cfg(feature = "optional_eip7708")]
self.log(create_eip7708_log(from, to, balance));

Ok(None)
}

Expand Down Expand Up @@ -461,6 +468,10 @@ impl<ENTRY: JournalEntryTr> JournalInner<ENTRY> {
// add journal entry of transferred balance
last_journal.push(ENTRY::balance_transfer(caller, target_address, balance));

// Emit native transfer log
#[cfg(feature = "optional_eip7708")]
self.log(create_eip7708_log(caller, target_address, balance));

Ok(checkpoint)
}

Expand Down Expand Up @@ -557,6 +568,9 @@ impl<ENTRY: JournalEntryTr> JournalInner<ENTRY> {
))
} else if address != target {
acc.info.balance = U256::ZERO;
// Emit native transfer log
#[cfg(feature = "optional_eip7708")]
self.log(create_eip7708_log(address, target, balance));
Some(ENTRY::balance_transfer(address, target, balance))
} else {
// State is not changed:
Expand Down
34 changes: 34 additions & 0 deletions crates/primitives/src/eip7708.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//! EIP-7708: ETH transfers emit a log
//!
//! <https://eips.ethereum.org/EIPS/eip-7708>
use alloy_primitives::{address, b256, Address, Log, LogData, B256, U256};
use std::vec;

/// keccak256 of "Transfer(address,address,uint256)" that notifies
/// about native transfer of eth
///
/// EIP-7708 is a draft, but we need native events for efficient call trace extraction
pub const NATIVE_TRANSFER_KECCAK: B256 =
b256!("ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef");

/// A system address that is used to identify system contracts
///
/// It's used in EIP-2935
pub const NATIVE_TRANSFER_ADDRESS: Address = address!("0xfffffffffffffffffffffffffffffffffffffffe");

/// Creates a log entry conforming to the EIP-7708 standard that represents
/// a native token transfer between two addresses.
pub fn create_eip7708_log(caller: Address, callee: Address, transfer_value: U256) -> Log {
let transfer_value: B256 = transfer_value.into();
Log {
address: NATIVE_TRANSFER_ADDRESS,
data: LogData::new_unchecked(
vec![
NATIVE_TRANSFER_KECCAK,
caller.into_word(),
callee.into_word(),
],
transfer_value.into(),
),
}
}
1 change: 1 addition & 0 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod eip170;
pub mod eip3860;
pub mod eip4844;
pub mod eip7702;
pub mod eip7708;
pub mod eip7823;
pub mod eip7825;
pub mod eip7907;
Expand Down
61 changes: 31 additions & 30 deletions crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,32 @@ serde = { workspace = true, features = ["derive"] }
[features]
default = ["std", "c-kzg", "secp256k1", "portable", "blst", "tracer"]
std = [
"interpreter/std",
"precompile/std",
"handler/std",
"context/std",
"context-interface/std",
"bytecode/std",
"database/std",
"database-interface/std",
"inspector/std",
"primitives/std",
"state/std",
"serde/std",
"serde_json/std",
"interpreter/std",
"precompile/std",
"handler/std",
"context/std",
"context-interface/std",
"bytecode/std",
"database/std",
"database-interface/std",
"inspector/std",
"primitives/std",
"state/std",
"serde/std",
"serde_json/std",
]
hashbrown = ["interpreter/hashbrown", "precompile/hashbrown"]
serde = [
"interpreter/serde",
"database-interface/serde",
"primitives/serde",
"handler/serde",
"context-interface/serde",
"bytecode/serde",
"context/serde",
"database/serde",
"inspector/serde",
"state/serde",
"interpreter/serde",
"database-interface/serde",
"primitives/serde",
"handler/serde",
"context-interface/serde",
"bytecode/serde",
"context/serde",
"database/serde",
"inspector/serde",
"state/serde",
]
arbitrary = ["primitives/arbitrary"]
asm-keccak = ["primitives/asm-keccak"]
Expand All @@ -76,25 +76,26 @@ serde-json = ["serde", "inspector/tracer"]
tracer = ["inspector/tracer"]

dev = [
"memory_limit",
"optional_balance_check",
"optional_block_gas_limit",
"optional_eip3541",
"optional_eip3607",
"optional_no_base_fee",
"memory_limit",
"optional_balance_check",
"optional_block_gas_limit",
"optional_eip3541",
"optional_eip3607",
"optional_no_base_fee",
]
memory_limit = ["context/memory_limit", "interpreter/memory_limit"]
optional_balance_check = ["context/optional_balance_check"]
optional_block_gas_limit = ["context/optional_block_gas_limit"]
optional_eip3541 = ["context/optional_eip3541"]
optional_eip3607 = ["context/optional_eip3607"]
optional_no_base_fee = ["context/optional_no_base_fee"]
optional_eip7708 = ["context/optional_eip7708"]

# Precompiles features

secp256k1 = ["precompile/secp256k1"] # See comments in `precompile`
c-kzg = [
"precompile/c-kzg",
"precompile/c-kzg",
] # `kzg-rs` is not audited but useful for `no_std` environment, use it with causing and default to `c-kzg` if possible.
kzg-rs = ["precompile/kzg-rs"]
blst = ["precompile/blst"]
Expand Down

This file was deleted.

Loading