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

bump revm to 19.0 #68

Merged
merged 3 commits into from
Jan 6, 2025
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
24 changes: 12 additions & 12 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ revmc-cranelift = { version = "0.1.0", path = "crates/revmc-cranelift", default-
revmc-llvm = { version = "0.1.0", path = "crates/revmc-llvm", default-features = false }

alloy-primitives = { version = "0.8", default-features = false }
revm = { version = "18.0", default-features = false }
revm-primitives = { version = "14.0", default-features = false }
revm-interpreter = { version = "14.0", default-features = false }
revm = { version = "19.0", default-features = false }
revm-primitives = { version = "15.1", default-features = false }
revm-interpreter = { version = "15.0", default-features = false }
ruint = { version = "1.12", default-features = false }

color-eyre = "0.6"
eyre = "0.6"
rustc-hash = "2.0"
rustc-hash = "2.1"
tracing = "0.1"
tracing-subscriber = "0.3"
tracing-tracy = "0.11"
Expand Down
19 changes: 12 additions & 7 deletions crates/revmc-builtins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ extern crate tracing;
use alloc::{boxed::Box, vec::Vec};
use revm_interpreter::{
as_u64_saturated, as_usize_saturated, CallInputs, CallScheme, CallValue, CreateInputs,
EOFCreateInputs, FunctionStack, InstructionResult, InterpreterAction, InterpreterResult,
EOFCreateInputs, Eip7702CodeLoad, FunctionStack, InstructionResult, InterpreterAction,
InterpreterResult,
};
use revm_primitives::{
eof::EofHeader, Address, Bytes, CreateScheme, Eof, Log, LogData, SpecId, KECCAK_EMPTY,
Expand Down Expand Up @@ -205,7 +206,9 @@ pub unsafe extern "C" fn __revmc_builtin_extcodesize(
address: &mut EvmWord,
spec_id: SpecId,
) -> InstructionResult {
let (code, state) = try_host!(ecx.host.code(address.to_address())).into_components();
let (code, state) =
Eip7702CodeLoad::new_state_load(try_host!(ecx.host.code(address.to_address())))
.into_components();
*address = code.len().into();
let gas = if spec_id.is_enabled_in(SpecId::BERLIN) {
gas::warm_cold_cost_with_delegation(state)
Expand All @@ -224,16 +227,16 @@ pub unsafe extern "C" fn __revmc_builtin_extcodecopy(
rev![address, memory_offset, code_offset, len]: &mut [EvmWord; 4],
spec_id: SpecId,
) -> InstructionResult {
let (code, state) = try_host!(ecx.host.code(address.to_address())).into_components();
let state_load = try_host!(ecx.host.code(address.to_address()));

let len = try_into_usize!(len);
gas_opt!(ecx, gas::extcodecopy_cost(spec_id, len as u64, state));
gas_opt!(ecx, gas::extcodecopy_cost(spec_id, len as u64, state_load.is_cold));
if len != 0 {
let memory_offset = try_into_usize!(memory_offset);
let code_offset = code_offset.to_u256();
let code_offset = as_usize_saturated!(code_offset).min(code.len());
let code_offset = as_usize_saturated!(code_offset).min(state_load.data.len());
ensure_memory!(ecx, memory_offset, len);
ecx.memory.set_data(memory_offset, code_offset, len, &code);
ecx.memory.set_data(memory_offset, code_offset, len, &state_load.data);
}
InstructionResult::Continue
}
Expand Down Expand Up @@ -265,7 +268,9 @@ pub unsafe extern "C" fn __revmc_builtin_extcodehash(
address: &mut EvmWord,
spec_id: SpecId,
) -> InstructionResult {
let (hash, state) = try_host!(ecx.host.code_hash(address.to_address())).into_components();
let (hash, state) =
Eip7702CodeLoad::new_state_load(try_host!(ecx.host.code_hash(address.to_address())))
.into_components();
*address = EvmWord::from_be_bytes(hash.0);
let gas = if spec_id.is_enabled_in(SpecId::BERLIN) {
gas::warm_cold_cost_with_delegation(state)
Expand Down
5 changes: 2 additions & 3 deletions crates/revmc-context/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,14 +832,13 @@ mod tests {
fn code(
&mut self,
address: Address,
) -> Option<revm_interpreter::Eip7702CodeLoad<Bytes>> {
) -> Option<revm_interpreter::StateLoad<revm_primitives::Bytes>> {
unimplemented!()
}
fn code_hash(
&mut self,
address: Address,
) -> Option<revm_interpreter::Eip7702CodeLoad<revm_primitives::FixedBytes<32>>>
{
) -> Option<revm_interpreter::StateLoad<revm_primitives::FixedBytes<32>>> {
unimplemented!()
}
fn sload(
Expand Down
12 changes: 6 additions & 6 deletions crates/revmc/src/tests/runner.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use interpreter::{AccountLoad, Eip7702CodeLoad, SStoreResult, StateLoad};
use interpreter::{AccountLoad, SStoreResult, StateLoad};
use revm_interpreter::{opcode as op, Contract, DummyHost, Host, SelfDestructResult};
use revm_primitives::{
spec_to_generic, BlobExcessGasAndPrice, BlockEnv, CfgEnv, Env, HashMap, TxEnv, EOF_MAGIC_BYTES,
Expand Down Expand Up @@ -148,7 +148,7 @@ pub fn def_env() -> &'static Env {
basefee: U256::from(0x1231),
difficulty: U256::from(0xcdef),
prevrandao: Some(U256::from(0x0123).into()),
blob_excess_gas_and_price: Some(BlobExcessGasAndPrice::new(50)),
blob_excess_gas_and_price: Some(BlobExcessGasAndPrice::new(50, false)),
},
tx: TxEnv {
caller: Address::repeat_byte(0xcc),
Expand Down Expand Up @@ -262,14 +262,14 @@ impl Host for TestHost {
Some(StateLoad::new(U256::from(*address.last().unwrap()), false))
}

fn code(&mut self, address: Address) -> Option<Eip7702CodeLoad<Bytes>> {
fn code(&mut self, address: Address) -> Option<StateLoad<Bytes>> {
let code = self.code_map.get(&address).map(|b| b.original_bytes()).unwrap_or_default();
Some(Eip7702CodeLoad::new_not_delegated(code, false))
Some(StateLoad::new(code, false))
}

fn code_hash(&mut self, address: Address) -> Option<Eip7702CodeLoad<B256>> {
fn code_hash(&mut self, address: Address) -> Option<StateLoad<B256>> {
let code_hash = self.code_map.get(&address).map(|b| b.hash_slow()).unwrap_or(KECCAK_EMPTY);
Some(Eip7702CodeLoad::new_not_delegated(code_hash, false))
Some(StateLoad::new(code_hash, false))
}

fn sload(&mut self, address: Address, index: U256) -> Option<StateLoad<U256>> {
Expand Down
Loading