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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion bins/revme/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ revm = { path = "../../crates/revm", version = "3.5.0", default-features = false
"c-kzg",
] }
alloy-rlp = { version = "0.3", default-features = false, features = [
"arrayvec",
"arrayvec",
"derive",
] }
serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
Expand Down
7 changes: 3 additions & 4 deletions crates/interpreter/src/host.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::{
primitives::{Address, Bytecode, Bytes, Env, B256, U256},
primitives::{Address, Bytecode, Env, Log, B256, U256},
SelfDestructResult,
};
use alloc::vec::Vec;

mod dummy;
pub use dummy::DummyHost;
Expand Down Expand Up @@ -48,8 +47,8 @@ pub trait Host {
/// Set the transient storage value of `address` at `index`.
fn tstore(&mut self, address: Address, index: U256, value: U256);

/// Emit a log owned by `address` with given `topics` and `data`.
fn log(&mut self, address: Address, topics: Vec<B256>, data: Bytes);
/// Emit a log owned by `address` with given `LogData`.
fn log(&mut self, log: Log);

/// Mark `address` to be deleted, with funds transferred to `target`.
fn selfdestruct(&mut self, address: Address, target: Address) -> Option<SelfDestructResult>;
Expand Down
10 changes: 3 additions & 7 deletions crates/interpreter/src/host/dummy.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::primitives::{hash_map::Entry, Bytecode, Bytes, HashMap, U256};
use crate::primitives::{hash_map::Entry, Bytecode, HashMap, U256};
use crate::{
primitives::{Address, Env, Log, B256, KECCAK_EMPTY},
Host, SelfDestructResult,
Expand Down Expand Up @@ -106,12 +106,8 @@ impl Host for DummyHost {
}

#[inline]
fn log(&mut self, address: Address, topics: Vec<B256>, data: Bytes) {
self.log.push(Log {
address,
topics,
data,
})
fn log(&mut self, log: Log) {
self.log.push(log)
}

#[inline]
Expand Down
9 changes: 7 additions & 2 deletions crates/interpreter/src/instructions/host.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
gas::{self, COLD_ACCOUNT_ACCESS_COST, WARM_STORAGE_READ_COST},
interpreter::{Interpreter, InterpreterAction},
primitives::{Address, Bytes, Spec, SpecId::*, B256, U256},
primitives::{Address, Bytes, Log, LogData, Spec, SpecId::*, B256, U256},
CallContext, CallInputs, CallScheme, CreateInputs, CreateScheme, Host, InstructionResult,
Transfer, MAX_INITCODE_SIZE,
};
Expand Down Expand Up @@ -211,7 +211,12 @@ pub fn log<const N: usize, H: Host>(interpreter: &mut Interpreter, host: &mut H)
topics.push(B256::from(unsafe { interpreter.stack.pop_unsafe() }));
}

host.log(interpreter.contract.address, topics, data);
let log = Log {
address: interpreter.contract.address,
data: LogData::new(topics, data).expect("LogData should have <=4 topics"),
};

host.log(log);
}

pub fn selfdestruct<H: Host, SPEC: Spec>(interpreter: &mut Interpreter, host: &mut H) {
Expand Down
9 changes: 1 addition & 8 deletions crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use once_cell::race::OnceBox;
pub use revm_primitives as primitives;
pub use revm_primitives::{
precompile::{PrecompileError as Error, *},
Address, Bytes, HashMap, B256,
Address, Bytes, HashMap, Log, B256,
};

pub fn calc_linear_cost_u32(len: usize, base: u64, word: u64) -> u64 {
Expand All @@ -41,13 +41,6 @@ pub struct PrecompileOutput {
pub logs: Vec<Log>,
}

#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct Log {
pub address: Address,
pub topics: Vec<B256>,
pub data: Bytes,
}

impl PrecompileOutput {
pub fn without_logs(cost: u64, output: Vec<u8>) -> Self {
Self {
Expand Down
2 changes: 0 additions & 2 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ rustdoc-args = ["--cfg", "docsrs"]
alloy-primitives = { version = "0.6", default-features = false, features = [
"rlp",
] }
alloy-rlp = { version = "0.3", default-features = false, features = ["derive"] }
hashbrown = "0.14"
auto_impl = "1.1"
bitvec = { version = "1", default-features = false, features = ["alloc"] }
Expand All @@ -44,7 +43,6 @@ hex = "0.4"
default = ["std", "c-kzg"]
std = [
"alloy-primitives/std",
"alloy-rlp/std",
"hex/std",
"bitvec/std",
"bitflags/std",
Expand Down
4 changes: 1 addition & 3 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub mod db;
pub mod env;
#[cfg(feature = "c-kzg")]
pub mod kzg;
mod log;
pub mod precompile;
pub mod result;
pub mod specification;
Expand All @@ -24,7 +23,7 @@ pub mod utilities;

pub use alloy_primitives::{
self, address, b256, bytes, fixed_bytes, hex, hex_literal, ruint, uint, Address, Bytes,
FixedBytes, B256, I256, U256,
FixedBytes, Log, LogData, B256, I256, U256,
};
pub use bitvec;
pub use bytecode::*;
Expand All @@ -33,7 +32,6 @@ pub use env::*;
pub use hashbrown::{hash_map, hash_set, HashMap, HashSet};
#[cfg(feature = "c-kzg")]
pub use kzg::{EnvKzgSettings, KzgSettings};
pub use log::*;
pub use precompile::*;
pub use result::*;
pub use specification::*;
Expand Down
11 changes: 0 additions & 11 deletions crates/primitives/src/log.rs

This file was deleted.

12 changes: 4 additions & 8 deletions crates/revm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::{
SelfDestructResult, SharedMemory,
},
primitives::{
specification::SpecId, Address, Bytecode, Bytes, EVMError, EVMResult, Env, ExecutionResult,
Log, Output, ResultAndState, TransactTo, B256, U256,
specification::SpecId, Address, Bytecode, EVMError, EVMResult, Env, ExecutionResult, Log,
Output, ResultAndState, TransactTo, B256, U256,
},
CallStackFrame, Context, FrameOrResult,
};
Expand Down Expand Up @@ -343,12 +343,8 @@ impl<EXT, DB: Database> Host for Evm<'_, EXT, DB> {
self.context.evm.tstore(address, index, value)
}

fn log(&mut self, address: Address, topics: Vec<B256>, data: Bytes) {
self.context.evm.journaled_state.log(Log {
address,
topics,
data,
});
fn log(&mut self, log: Log) {
self.context.evm.journaled_state.log(log);
}

fn selfdestruct(&mut self, address: Address, target: Address) -> Option<SelfDestructResult> {
Expand Down