From c2a04cbb2ba5862e56212caa6ceca2c11bcac3d0 Mon Sep 17 00:00:00 2001 From: rakita Date: Tue, 18 Jun 2024 12:23:11 +0200 Subject: [PATCH 1/8] fix(eof): output gas for eofcreate (#1540) --- crates/interpreter/src/gas.rs | 5 +++++ crates/interpreter/src/instructions/contract.rs | 4 +--- .../interpreter/src/instructions/contract/call_helpers.rs | 6 ++++-- crates/revm/src/context/inner_evm_context.rs | 8 ++++++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/crates/interpreter/src/gas.rs b/crates/interpreter/src/gas.rs index 01a3ebea..1407ae7b 100644 --- a/crates/interpreter/src/gas.rs +++ b/crates/interpreter/src/gas.rs @@ -72,6 +72,11 @@ impl Gas { self.remaining } + /// Return remaining gas after subtracting 63/64 parts. + pub const fn remaining_63_of_64_parts(&self) -> u64 { + self.remaining - self.remaining / 64 + } + /// Erases a gas cost from the totals. #[inline] pub fn erase_cost(&mut self, returned: u64) { diff --git a/crates/interpreter/src/instructions/contract.rs b/crates/interpreter/src/instructions/contract.rs index f57a7869..aac3d38f 100644 --- a/crates/interpreter/src/instructions/contract.rs +++ b/crates/interpreter/src/instructions/contract.rs @@ -62,10 +62,8 @@ pub fn eofcreate(interpreter: &mut Interpreter, _host: &mut H) .target_address .create2(salt.to_be_bytes(), keccak256(sub_container)); - let gas_reduce = max(interpreter.gas.remaining() / 64, 5000); - let gas_limit = interpreter.gas().remaining().saturating_sub(gas_reduce); + let gas_limit = interpreter.gas().remaining_63_of_64_parts(); gas!(interpreter, gas_limit); - // Send container for execution container is preverified. interpreter.instruction_result = InstructionResult::CallOrCreate; interpreter.next_action = InterpreterAction::EOFCreate { diff --git a/crates/interpreter/src/instructions/contract/call_helpers.rs b/crates/interpreter/src/instructions/contract/call_helpers.rs index f9acc749..77fa16d6 100644 --- a/crates/interpreter/src/instructions/contract/call_helpers.rs +++ b/crates/interpreter/src/instructions/contract/call_helpers.rs @@ -55,9 +55,11 @@ pub fn calc_call_gas( // EIP-150: Gas cost changes for IO-heavy operations let gas_limit = if SPEC::enabled(TANGERINE) { - let gas = interpreter.gas().remaining(); // take l64 part of gas_limit - min(gas - gas / 64, local_gas_limit) + min( + interpreter.gas().remaining_63_of_64_parts(), + local_gas_limit, + ) } else { local_gas_limit }; diff --git a/crates/revm/src/context/inner_evm_context.rs b/crates/revm/src/context/inner_evm_context.rs index 200345dc..c83d5ec1 100644 --- a/crates/revm/src/context/inner_evm_context.rs +++ b/crates/revm/src/context/inner_evm_context.rs @@ -334,6 +334,14 @@ impl InnerEvmContext { return; } + // deduct gas for code deployment. + let gas_for_code = interpreter_result.output.len() as u64 * gas::CODEDEPOSIT; + if !interpreter_result.gas.record_cost(gas_for_code) { + self.journaled_state.checkpoint_revert(journal_checkpoint); + interpreter_result.result = InstructionResult::OutOfGas; + return; + } + // commit changes reduces depth by -1. self.journaled_state.checkpoint_commit(); From 2f46a13679a8cf4cd8d3c405cbe25fb2a6f6b2f3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 18 Jun 2024 21:56:59 +0200 Subject: [PATCH 2/8] chore: simplify Interpreter serde (#1544) --- crates/interpreter/src/interpreter/serde.rs | 296 ++++++-------------- 1 file changed, 90 insertions(+), 206 deletions(-) diff --git a/crates/interpreter/src/interpreter/serde.rs b/crates/interpreter/src/interpreter/serde.rs index eb4d8524..2cc8fd04 100644 --- a/crates/interpreter/src/interpreter/serde.rs +++ b/crates/interpreter/src/interpreter/serde.rs @@ -1,36 +1,67 @@ +use super::Interpreter; use crate::{ Contract, FunctionStack, Gas, InstructionResult, InterpreterAction, SharedMemory, Stack, }; - -use super::Interpreter; use revm_primitives::Bytes; -use serde::de::{self, MapAccess, Visitor}; -use serde::ser::SerializeStruct; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::fmt; + +#[derive(Serialize)] +struct InterpreterSerde<'a> { + program_counter: usize, + + gas: &'a Gas, + contract: &'a Contract, + instruction_result: InstructionResult, + bytecode: &'a Bytes, + is_eof: bool, + is_eof_init: bool, + shared_memory: &'a SharedMemory, + stack: &'a Stack, + function_stack: &'a FunctionStack, + return_data_buffer: &'a Bytes, + is_static: bool, + next_action: &'a InterpreterAction, +} + +#[derive(Deserialize)] +struct InterpreterDe { + program_counter: usize, + + gas: Gas, + contract: Contract, + instruction_result: InstructionResult, + bytecode: Bytes, + is_eof: bool, + is_eof_init: bool, + shared_memory: SharedMemory, + stack: Stack, + function_stack: FunctionStack, + return_data_buffer: Bytes, + is_static: bool, + next_action: InterpreterAction, +} impl Serialize for Interpreter { fn serialize(&self, serializer: S) -> Result where S: Serializer, { - let mut state = serializer.serialize_struct("Interpreter", 8)?; - // Convert the instruction pointer to a usize for serialization - let program_counter = self.program_counter(); - state.serialize_field("program_counter", &program_counter)?; - state.serialize_field("gas", &self.gas)?; - state.serialize_field("contract", &self.contract)?; - state.serialize_field("instruction_result", &self.instruction_result)?; - state.serialize_field("bytecode", &self.bytecode)?; - state.serialize_field("is_eof", &self.is_eof)?; - state.serialize_field("is_eof_init", &self.is_eof_init)?; - state.serialize_field("shared_memory", &self.shared_memory)?; - state.serialize_field("stack", &self.stack)?; - state.serialize_field("function_stack", &self.function_stack)?; - state.serialize_field("return_data_buffer", &self.return_data_buffer)?; - state.serialize_field("is_static", &self.is_static)?; - state.serialize_field("next_action", &self.next_action)?; - state.end() + InterpreterSerde { + program_counter: self.program_counter(), + gas: &self.gas, + contract: &self.contract, + instruction_result: self.instruction_result, + bytecode: &self.bytecode, + is_eof: self.is_eof, + is_eof_init: self.is_eof_init, + shared_memory: &self.shared_memory, + stack: &self.stack, + function_stack: &self.function_stack, + return_data_buffer: &self.return_data_buffer, + is_static: self.is_static, + next_action: &self.next_action, + } + .serialize(serializer) } } @@ -39,192 +70,45 @@ impl<'de> Deserialize<'de> for Interpreter { where D: Deserializer<'de>, { - struct InterpreterVisitor; - - #[derive(serde::Deserialize)] - #[serde(field_identifier, rename_all = "lowercase")] - enum InterpreterFields { - ProgramCounter, - Gas, - Contract, - InstructionResult, - Bytecode, - IsEof, - IsEofInit, - SharedMemory, - Stack, - FunctionStack, - ReturnDataBuffer, - IsStatic, - NextAction, - } - - #[allow(clippy::too_many_arguments)] - fn rebuild_interp( - program_counter: isize, - gas: Gas, - contract: Contract, - instruction_result: InstructionResult, - bytecode: Bytes, - is_eof: bool, - is_eof_init: bool, - shared_memory: SharedMemory, - stack: Stack, - function_stack: FunctionStack, - return_data_buffer: Bytes, - is_static: bool, - next_action: InterpreterAction, - ) -> Result { - // Reconstruct the instruction pointer from usize - if program_counter < 0 || program_counter >= bytecode.len() as isize { - return Err("program_counter index out of range"); - } - - // SAFETY: range of program_counter checked above - let instruction_pointer = unsafe { bytecode.as_ptr().offset(program_counter) }; - - // Construct and return the Interpreter instance - Ok(Interpreter { - instruction_pointer, - gas, - contract, - instruction_result, - bytecode, - is_eof, - is_eof_init, - shared_memory, - stack, - function_stack, - return_data_buffer, - is_static, - next_action, - }) - } - - impl<'de> Visitor<'de> for InterpreterVisitor { - type Value = Interpreter; - - fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - formatter.write_str("struct Interpreter") - } - - fn visit_seq(self, mut seq: A) -> Result - where - A: de::SeqAccess<'de>, - { - macro_rules! extract_field { - ($i:ident, $idx:expr) => { - let $i = seq - .next_element()? - .ok_or_else(|| de::Error::invalid_length($idx, &self))?; - }; - } - extract_field!(instruction_pointer, 0); - extract_field!(gas, 1); - extract_field!(contract, 2); - extract_field!(instruction_result, 3); - extract_field!(bytecode, 4); - extract_field!(is_eof, 5); - extract_field!(is_eof_init, 6); - extract_field!(shared_memory, 7); - extract_field!(stack, 8); - extract_field!(function_stack, 9); - extract_field!(return_data_buffer, 10); - extract_field!(is_static, 11); - extract_field!(next_action, 12); - rebuild_interp( - instruction_pointer, - gas, - contract, - instruction_result, - bytecode, - is_eof, - is_eof_init, - shared_memory, - stack, - function_stack, - return_data_buffer, - is_static, - next_action, - ) - .map_err(de::Error::custom) - } - - fn visit_map(self, mut map: V) -> Result - where - V: MapAccess<'de>, - { - macro_rules! parse_map { - ( $(($enum:pat, $var_name:ident)),* ) => { - $( - let mut $var_name = None; - )* - while let Some(key) = map.next_key()? { - match key { - $( - $enum => { - $var_name = Some(map.next_value()?); - } - )* - } - } - $( - let $var_name = $var_name.ok_or_else(|| de::Error::missing_field(stringify!($var_name)))?; - )* - }; - } - parse_map!( - (InterpreterFields::ProgramCounter, program_counter), - (InterpreterFields::Gas, gas), - (InterpreterFields::Contract, contract), - (InterpreterFields::InstructionResult, instruction_result), - (InterpreterFields::Bytecode, bytecode), - (InterpreterFields::IsEof, is_eof), - (InterpreterFields::IsEofInit, is_eof_init), - (InterpreterFields::SharedMemory, shared_memory), - (InterpreterFields::Stack, stack), - (InterpreterFields::FunctionStack, function_stack), - (InterpreterFields::ReturnDataBuffer, return_data_buffer), - (InterpreterFields::IsStatic, is_static), - (InterpreterFields::NextAction, next_action) - ); - - rebuild_interp( - program_counter, - gas, - contract, - instruction_result, - bytecode, - is_eof, - is_eof_init, - shared_memory, - stack, - function_stack, - return_data_buffer, - is_static, - next_action, - ) - .map_err(de::Error::custom) - } + let InterpreterDe { + program_counter, + gas, + contract, + instruction_result, + bytecode, + is_eof, + is_eof_init, + shared_memory, + stack, + function_stack, + return_data_buffer, + is_static, + next_action, + } = InterpreterDe::deserialize(deserializer)?; + + // Reconstruct the instruction pointer from usize + if program_counter >= bytecode.len() { + return Err(serde::de::Error::custom("program_counter out of bounds")); } - const FIELDS: &[&str] = &[ - "program_counter", - "gas", - "contract", - "instruction_result", - "bytecode", - "is_eof", - "is_eof_init", - "shared_memory", - "stack", - "function_stack", - "return_data_buffer", - "is_static", - "next_action", - ]; - - deserializer.deserialize_struct("Interpreter", FIELDS, InterpreterVisitor) + // SAFETY: range of program_counter checked above + let instruction_pointer = unsafe { bytecode.as_ptr().add(program_counter) }; + + Ok(Interpreter { + instruction_pointer, + gas, + contract, + instruction_result, + bytecode, + is_eof, + is_eof_init, + shared_memory, + stack, + function_stack, + return_data_buffer, + is_static, + next_action, + }) } } From e6b52af25d61207c2f9b728c16280c00aeee8506 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 19 Jun 2024 13:05:35 +0200 Subject: [PATCH 3/8] chore: remove DatabaseWithDebugError (#1545) --- crates/primitives/src/db.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/crates/primitives/src/db.rs b/crates/primitives/src/db.rs index ca4ced98..80c232cc 100644 --- a/crates/primitives/src/db.rs +++ b/crates/primitives/src/db.rs @@ -67,12 +67,6 @@ impl From for WrapDatabaseRef { } } -pub trait DatabaseWithDebugError: Database -where - ::Error: std::fmt::Debug + std::fmt::Display, -{ -} - impl Database for WrapDatabaseRef { type Error = T::Error; From 7db1adcfc29480d3f0c0af134b9757aadd7f3b6b Mon Sep 17 00:00:00 2001 From: Wodann Date: Wed, 19 Jun 2024 06:07:54 -0500 Subject: [PATCH 4/8] refactor: replace TransactTo with TxKind (#1542) * refactor: replace TransactTo with TxKind * misc: apply review suggestions --- bins/revm-test/src/bin/analysis.rs | 4 +- bins/revm-test/src/bin/burntpix/main.rs | 4 +- bins/revm-test/src/bin/snailtracer.rs | 4 +- bins/revm-test/src/bin/transfer.rs | 4 +- bins/revme/src/cmd/evmrunner.rs | 4 +- bins/revme/src/cmd/statetest/runner.rs | 6 +-- .../interpreter/src/interpreter/contract.rs | 8 ++-- .../src/interpreter_action/call_inputs.rs | 4 +- .../src/interpreter_action/create_inputs.rs | 4 +- crates/primitives/src/env.rs | 41 +++---------------- crates/primitives/src/lib.rs | 2 +- crates/revm/benches/bench.rs | 8 ++-- crates/revm/src/builder.rs | 6 +-- crates/revm/src/evm.rs | 6 +-- .../revm/src/handler/mainnet/pre_execution.rs | 4 +- crates/revm/src/inspector/customprinter.rs | 2 +- crates/revm/src/inspector/gas.rs | 5 +-- crates/revm/src/inspector/handler_register.rs | 5 +-- crates/revm/src/optimism/fast_lz.rs | 5 +-- .../src/crates/primitives/environment.md | 2 +- examples/fork_ref_transact.rs | 4 +- examples/generate_block_traces.rs | 8 ++-- examples/uniswap_v2_usdc_swap.rs | 12 +++--- 23 files changed, 59 insertions(+), 93 deletions(-) diff --git a/bins/revm-test/src/bin/analysis.rs b/bins/revm-test/src/bin/analysis.rs index 40bbcf39..a6fa92f4 100644 --- a/bins/revm-test/src/bin/analysis.rs +++ b/bins/revm-test/src/bin/analysis.rs @@ -1,7 +1,7 @@ use revm::{ db::BenchmarkDB, interpreter::analysis::to_analysed, - primitives::{address, bytes, Bytecode, Bytes, TransactTo}, + primitives::{address, bytes, Bytecode, Bytes, TxKind}, Evm, }; use std::time::Instant; @@ -17,7 +17,7 @@ fn main() { .modify_tx_env(|tx| { // execution globals block hash/gas_limit/coinbase/timestamp.. tx.caller = address!("1000000000000000000000000000000000000000"); - tx.transact_to = TransactTo::Call(address!("0000000000000000000000000000000000000000")); + tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000")); //evm.env.tx.data = Bytes::from(hex::decode("30627b7c").unwrap()); tx.data = bytes!("8035F0CE"); }) diff --git a/bins/revm-test/src/bin/burntpix/main.rs b/bins/revm-test/src/bin/burntpix/main.rs index 8cd9eea6..ea1ac56f 100644 --- a/bins/revm-test/src/bin/burntpix/main.rs +++ b/bins/revm-test/src/bin/burntpix/main.rs @@ -5,7 +5,7 @@ use revm::{ db::{CacheDB, EmptyDB}, primitives::{ address, hex, keccak256, AccountInfo, Address, Bytecode, Bytes, ExecutionResult, Output, - TransactTo, B256, U256, + TxKind, B256, U256, }, Evm, }; @@ -38,7 +38,7 @@ fn main() { let mut evm = Evm::builder() .modify_tx_env(|tx| { tx.caller = address!("1000000000000000000000000000000000000000"); - tx.transact_to = TransactTo::Call(BURNTPIX_MAIN_ADDRESS); + tx.transact_to = TxKind::Call(BURNTPIX_MAIN_ADDRESS); tx.data = run_call_data.clone().into(); }) .with_db(db) diff --git a/bins/revm-test/src/bin/snailtracer.rs b/bins/revm-test/src/bin/snailtracer.rs index a931dc3a..cebe950a 100644 --- a/bins/revm-test/src/bin/snailtracer.rs +++ b/bins/revm-test/src/bin/snailtracer.rs @@ -1,7 +1,7 @@ use revm::{ db::BenchmarkDB, interpreter::analysis::to_analysed, - primitives::{address, bytes, Bytecode, Bytes, TransactTo}, + primitives::{address, bytes, Bytecode, Bytes, TxKind}, Evm, }; @@ -14,7 +14,7 @@ pub fn simple_example() { .modify_tx_env(|tx| { // execution globals block hash/gas_limit/coinbase/timestamp.. tx.caller = address!("1000000000000000000000000000000000000000"); - tx.transact_to = TransactTo::Call(address!("0000000000000000000000000000000000000000")); + tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000")); tx.data = bytes!("30627b7c"); }) .build(); diff --git a/bins/revm-test/src/bin/transfer.rs b/bins/revm-test/src/bin/transfer.rs index 8abd0910..4fa1f29b 100644 --- a/bins/revm-test/src/bin/transfer.rs +++ b/bins/revm-test/src/bin/transfer.rs @@ -1,6 +1,6 @@ use revm::{ db::BenchmarkDB, - primitives::{Bytecode, TransactTo, U256}, + primitives::{Bytecode, TxKind, U256}, Evm, }; @@ -16,7 +16,7 @@ fn main() { .parse() .unwrap(); tx.value = U256::from(10); - tx.transact_to = TransactTo::Call( + tx.transact_to = TxKind::Call( "0x0000000000000000000000000000000000000000" .parse() .unwrap(), diff --git a/bins/revme/src/cmd/evmrunner.rs b/bins/revme/src/cmd/evmrunner.rs index 8c93d318..50a75a8d 100644 --- a/bins/revme/src/cmd/evmrunner.rs +++ b/bins/revme/src/cmd/evmrunner.rs @@ -2,7 +2,7 @@ use revm::{ db::BenchmarkDB, inspector_handle_register, inspectors::TracerEip3155, - primitives::{Address, Bytecode, TransactTo}, + primitives::{Address, Bytecode, TxKind}, Evm, }; use std::io::Error as IoError; @@ -86,7 +86,7 @@ impl Cmd { tx.caller = "0x0000000000000000000000000000000000000001" .parse() .unwrap(); - tx.transact_to = TransactTo::Call(Address::ZERO); + tx.transact_to = TxKind::Call(Address::ZERO); tx.data = input; }) .build(); diff --git a/bins/revme/src/cmd/statetest/runner.rs b/bins/revme/src/cmd/statetest/runner.rs index df14560a..06ab1d64 100644 --- a/bins/revme/src/cmd/statetest/runner.rs +++ b/bins/revme/src/cmd/statetest/runner.rs @@ -10,7 +10,7 @@ use revm::{ inspectors::TracerEip3155, primitives::{ calc_excess_blob_gas, keccak256, Bytecode, Bytes, EVMResultGeneric, Env, Eof, - ExecutionResult, SpecId, TransactTo, B256, EOF_MAGIC_BYTES, U256, + ExecutionResult, SpecId, TxKind, B256, EOF_MAGIC_BYTES, U256, }, Evm, State, }; @@ -364,8 +364,8 @@ pub fn execute_test_suite( .collect(); let to = match unit.transaction.to { - Some(add) => TransactTo::Call(add), - None => TransactTo::Create, + Some(add) => TxKind::Call(add), + None => TxKind::Create, }; env.tx.transact_to = to; diff --git a/crates/interpreter/src/interpreter/contract.rs b/crates/interpreter/src/interpreter/contract.rs index f8625e85..49e511f6 100644 --- a/crates/interpreter/src/interpreter/contract.rs +++ b/crates/interpreter/src/interpreter/contract.rs @@ -1,6 +1,8 @@ +use revm_primitives::TxKind; + use super::analysis::to_analysed; use crate::{ - primitives::{Address, Bytecode, Bytes, Env, TransactTo, B256, U256}, + primitives::{Address, Bytecode, Bytes, Env, B256, U256}, CallInputs, }; @@ -50,8 +52,8 @@ impl Contract { #[inline] pub fn new_env(env: &Env, bytecode: Bytecode, hash: Option) -> Self { let contract_address = match env.tx.transact_to { - TransactTo::Call(caller) => caller, - TransactTo::Create => Address::ZERO, + TxKind::Call(caller) => caller, + TxKind::Create => Address::ZERO, }; Self::new( env.tx.data.clone(), diff --git a/crates/interpreter/src/interpreter_action/call_inputs.rs b/crates/interpreter/src/interpreter_action/call_inputs.rs index 0e51bd5e..85d0c8fb 100644 --- a/crates/interpreter/src/interpreter_action/call_inputs.rs +++ b/crates/interpreter/src/interpreter_action/call_inputs.rs @@ -1,4 +1,4 @@ -use crate::primitives::{Address, Bytes, TransactTo, TxEnv, U256}; +use crate::primitives::{Address, Bytes, TxEnv, TxKind, U256}; use core::ops::Range; use std::boxed::Box; @@ -47,7 +47,7 @@ impl CallInputs { /// /// Returns `None` if the transaction is not a call. pub fn new(tx_env: &TxEnv, gas_limit: u64) -> Option { - let TransactTo::Call(target_address) = tx_env.transact_to else { + let TxKind::Call(target_address) = tx_env.transact_to else { return None; }; Some(CallInputs { diff --git a/crates/interpreter/src/interpreter_action/create_inputs.rs b/crates/interpreter/src/interpreter_action/create_inputs.rs index 6db95183..adae96ac 100644 --- a/crates/interpreter/src/interpreter_action/create_inputs.rs +++ b/crates/interpreter/src/interpreter_action/create_inputs.rs @@ -1,5 +1,5 @@ pub use crate::primitives::CreateScheme; -use crate::primitives::{Address, Bytes, TransactTo, TxEnv, U256}; +use crate::primitives::{Address, Bytes, TxEnv, TxKind, U256}; use std::boxed::Box; /// Inputs for a create call. @@ -21,7 +21,7 @@ pub struct CreateInputs { impl CreateInputs { /// Creates new create inputs. pub fn new(tx_env: &TxEnv, gas_limit: u64) -> Option { - let TransactTo::Create = tx_env.transact_to else { + let TxKind::Create = tx_env.transact_to else { return None; }; diff --git a/crates/primitives/src/env.rs b/crates/primitives/src/env.rs index 44b07369..fde04c57 100644 --- a/crates/primitives/src/env.rs +++ b/crates/primitives/src/env.rs @@ -1,5 +1,6 @@ pub mod handler_cfg; +use alloy_primitives::TxKind; pub use handler_cfg::{CfgEnvWithHandlerCfg, EnvWithHandlerCfg, HandlerCfg}; use crate::{ @@ -503,7 +504,7 @@ pub struct TxEnv { /// The gas price of the transaction. pub gas_price: U256, /// The destination of the transaction. - pub transact_to: TransactTo, + pub transact_to: TxKind, /// The value sent to `transact_to`. pub value: U256, /// The data of the transaction. @@ -585,7 +586,7 @@ impl Default for TxEnv { gas_limit: u64::MAX, gas_price: U256::ZERO, gas_priority_fee: None, - transact_to: TransactTo::Call(Address::ZERO), // will do nothing + transact_to: TxKind::Call(Address::ZERO), // will do nothing value: U256::ZERO, data: Bytes::new(), chain_id: None, @@ -658,40 +659,8 @@ pub struct OptimismFields { pub enveloped_tx: Option, } -/// Transaction destination. -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum TransactTo { - /// Simple call to an address. - Call(Address), - /// Contract creation. - Create, -} - -impl TransactTo { - /// Calls the given address. - #[inline] - pub fn call(address: Address) -> Self { - Self::Call(address) - } - - /// Creates a contract. - #[inline] - pub fn create() -> Self { - Self::Create - } - /// Returns `true` if the transaction is `Call`. - #[inline] - pub fn is_call(&self) -> bool { - matches!(self, Self::Call(_)) - } - - /// Returns `true` if the transaction is `Create` or `Create2`. - #[inline] - pub fn is_create(&self) -> bool { - matches!(self, Self::Create) - } -} +/// Transaction destination +pub type TransactTo = TxKind; /// Create scheme. #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index c57f900b..35019aa0 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -21,7 +21,7 @@ pub mod state; pub mod utilities; pub use alloy_primitives::{ self, address, b256, bytes, fixed_bytes, hex, hex_literal, ruint, uint, Address, Bytes, - FixedBytes, Log, LogData, B256, I256, U256, + FixedBytes, Log, LogData, TxKind, B256, I256, U256, }; pub use bitvec; pub use bytecode::*; diff --git a/crates/revm/benches/bench.rs b/crates/revm/benches/bench.rs index b45beefd..a135a367 100644 --- a/crates/revm/benches/bench.rs +++ b/crates/revm/benches/bench.rs @@ -4,7 +4,7 @@ use criterion::{ use revm::{ db::BenchmarkDB, interpreter::{analysis::to_analysed, Contract, DummyHost, Interpreter}, - primitives::{address, bytes, hex, BerlinSpec, Bytecode, Bytes, TransactTo, U256}, + primitives::{address, bytes, hex, BerlinSpec, Bytecode, Bytes, TxKind, U256}, Evm, }; use revm_interpreter::{opcode::make_instruction_table, SharedMemory, EMPTY_SHARED_MEMORY}; @@ -14,7 +14,7 @@ fn analysis(c: &mut Criterion) { let evm = Evm::builder() .modify_tx_env(|tx| { tx.caller = address!("0000000000000000000000000000000000000002"); - tx.transact_to = TransactTo::Call(address!("0000000000000000000000000000000000000000")); + tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000")); // evm.env.tx.data = bytes!("30627b7c"); tx.data = bytes!("8035F0CE"); }) @@ -50,7 +50,7 @@ fn snailtracer(c: &mut Criterion) { .with_db(BenchmarkDB::new_bytecode(bytecode(SNAILTRACER))) .modify_tx_env(|tx| { tx.caller = address!("1000000000000000000000000000000000000000"); - tx.transact_to = TransactTo::Call(address!("0000000000000000000000000000000000000000")); + tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000")); tx.data = bytes!("30627b7c"); }) .build(); @@ -70,7 +70,7 @@ fn transfer(c: &mut Criterion) { .with_db(BenchmarkDB::new_bytecode(Bytecode::new())) .modify_tx_env(|tx| { tx.caller = address!("0000000000000000000000000000000000000001"); - tx.transact_to = TransactTo::Call(address!("0000000000000000000000000000000000000000")); + tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000")); tx.value = U256::from(10); }) .build(); diff --git a/crates/revm/src/builder.rs b/crates/revm/src/builder.rs index a09f7c0b..c66b61f5 100644 --- a/crates/revm/src/builder.rs +++ b/crates/revm/src/builder.rs @@ -444,7 +444,7 @@ mod test { inspector::inspector_handle_register, inspectors::NoOpInspector, primitives::{ - address, AccountInfo, Address, Bytecode, Bytes, PrecompileResult, TransactTo, U256, + address, AccountInfo, Address, Bytecode, Bytes, PrecompileResult, TxKind, U256, }, Context, ContextPrecompile, ContextStatefulPrecompile, Evm, InMemoryDB, InnerEvmContext, }; @@ -474,7 +474,7 @@ mod test { .modify_db(|db| { db.insert_account_info(to_addr, AccountInfo::new(U256::ZERO, 0, code_hash, code)) }) - .modify_tx_env(|tx| tx.transact_to = TransactTo::Call(to_addr)) + .modify_tx_env(|tx| tx.transact_to = TxKind::Call(to_addr)) // we need to use handle register box to capture the custom context in the handle // register .append_handler_register_box(Box::new(move |handler| { @@ -523,7 +523,7 @@ mod test { .modify_db(|db| { db.insert_account_info(to_addr, AccountInfo::new(U256::ZERO, 0, code_hash, code)) }) - .modify_tx_env(|tx| tx.transact_to = TransactTo::Call(to_addr)) + .modify_tx_env(|tx| tx.transact_to = TxKind::Call(to_addr)) .append_handler_register(|handler| { handler.instruction_table.insert(0xEF, custom_instruction) }) diff --git a/crates/revm/src/evm.rs b/crates/revm/src/evm.rs index d5b853d2..5cb64af8 100644 --- a/crates/revm/src/evm.rs +++ b/crates/revm/src/evm.rs @@ -8,7 +8,7 @@ use crate::{ }, primitives::{ specification::SpecId, BlockEnv, Bytes, CfgEnv, EVMError, EVMResult, EnvWithHandlerCfg, - ExecutionResult, HandlerCfg, ResultAndState, TransactTo, TxEnv, + ExecutionResult, HandlerCfg, ResultAndState, TxEnv, TxKind, }, Context, ContextWithHandlerCfg, Frame, FrameOrResult, FrameResult, }; @@ -344,11 +344,11 @@ impl Evm<'_, EXT, DB> { let exec = self.handler.execution(); // call inner handling of call/create let first_frame_or_result = match ctx.evm.env.tx.transact_to { - TransactTo::Call(_) => exec.call( + TxKind::Call(_) => exec.call( ctx, CallInputs::new_boxed(&ctx.evm.env.tx, gas_limit).unwrap(), )?, - TransactTo::Create => { + TxKind::Create => { // if first byte of data is magic 0xEF00, then it is EOFCreate. if spec_id.is_enabled_in(SpecId::PRAGUE) && ctx diff --git a/crates/revm/src/handler/mainnet/pre_execution.rs b/crates/revm/src/handler/mainnet/pre_execution.rs index d3b9759d..3cc1d89a 100644 --- a/crates/revm/src/handler/mainnet/pre_execution.rs +++ b/crates/revm/src/handler/mainnet/pre_execution.rs @@ -8,7 +8,7 @@ use crate::{ db::Database, Account, EVMError, Env, Spec, SpecId::{CANCUN, PRAGUE, SHANGHAI}, - TransactTo, BLOCKHASH_STORAGE_ADDRESS, U256, + TxKind, BLOCKHASH_STORAGE_ADDRESS, U256, }, Context, ContextPrecompiles, }; @@ -68,7 +68,7 @@ pub fn deduct_caller_inner(caller_account: &mut Account, env: &Env) caller_account.info.balance = caller_account.info.balance.saturating_sub(gas_cost); // bump the nonce for calls. Nonce for CREATE will be bumped in `handle_create`. - if matches!(env.tx.transact_to, TransactTo::Call(_)) { + if matches!(env.tx.transact_to, TxKind::Call(_)) { // Nonce is already checked caller_account.info.nonce = caller_account.info.nonce.saturating_add(1); } diff --git a/crates/revm/src/inspector/customprinter.rs b/crates/revm/src/inspector/customprinter.rs index ac7dd265..ed42c4f7 100644 --- a/crates/revm/src/inspector/customprinter.rs +++ b/crates/revm/src/inspector/customprinter.rs @@ -140,7 +140,7 @@ mod test { }) .modify_tx_env(|tx| { tx.caller = address!("5fdcca53617f4d2b9134b29090c87d01058e27e0"); - tx.transact_to = crate::primitives::TransactTo::Call(callee); + tx.transact_to = crate::primitives::TxKind::Call(callee); tx.data = crate::primitives::Bytes::new(); tx.value = crate::primitives::U256::ZERO; }) diff --git a/crates/revm/src/inspector/gas.rs b/crates/revm/src/inspector/gas.rs index 7542c3d3..1100bd98 100644 --- a/crates/revm/src/inspector/gas.rs +++ b/crates/revm/src/inspector/gas.rs @@ -162,7 +162,7 @@ mod tests { db::BenchmarkDB, inspector::inspector_handle_register, interpreter::opcode, - primitives::{address, Bytecode, Bytes, TransactTo}, + primitives::{address, Bytecode, Bytes, TxKind}, Evm, }; @@ -189,8 +189,7 @@ mod tests { .modify_tx_env(|tx| { tx.clear(); tx.caller = address!("1000000000000000000000000000000000000000"); - tx.transact_to = - TransactTo::Call(address!("0000000000000000000000000000000000000000")); + tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000")); tx.gas_limit = 21100; }) .append_handler_register(inspector_handle_register) diff --git a/crates/revm/src/inspector/handler_register.rs b/crates/revm/src/inspector/handler_register.rs index 0c500588..7c48284a 100644 --- a/crates/revm/src/inspector/handler_register.rs +++ b/crates/revm/src/inspector/handler_register.rs @@ -334,7 +334,7 @@ mod tests { db::BenchmarkDB, inspector::inspector_handle_register, interpreter::opcode, - primitives::{address, Bytecode, Bytes, TransactTo}, + primitives::{address, Bytecode, Bytes, TxKind}, Evm, }; @@ -360,8 +360,7 @@ mod tests { .modify_tx_env(|tx| { tx.clear(); tx.caller = address!("1000000000000000000000000000000000000000"); - tx.transact_to = - TransactTo::Call(address!("0000000000000000000000000000000000000000")); + tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000")); tx.gas_limit = 21100; }) .append_handler_register(inspector_handle_register) diff --git a/crates/revm/src/optimism/fast_lz.rs b/crates/revm/src/optimism/fast_lz.rs index 51ea82d4..3906bcb3 100644 --- a/crates/revm/src/optimism/fast_lz.rs +++ b/crates/revm/src/optimism/fast_lz.rs @@ -112,7 +112,7 @@ mod tests { use crate::db::BenchmarkDB; use crate::{ primitives::address, primitives::bytes, primitives::Bytecode, primitives::Bytes, - primitives::TransactTo, primitives::U256, Evm, + primitives::TxKind, primitives::U256, Evm, }; use rstest::rstest; @@ -166,8 +166,7 @@ mod tests { .with_db(BenchmarkDB::new_bytecode(contract_bytecode.clone())) .modify_tx_env(|tx| { tx.caller = address!("1000000000000000000000000000000000000000"); - tx.transact_to = - TransactTo::Call(address!("0000000000000000000000000000000000000000")); + tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000")); tx.data = FastLz::fastLzCall::new((input,)).abi_encode().into(); }) .build(); diff --git a/documentation/src/crates/primitives/environment.md b/documentation/src/crates/primitives/environment.md index 8e331815..8d56024b 100644 --- a/documentation/src/crates/primitives/environment.md +++ b/documentation/src/crates/primitives/environment.md @@ -1,5 +1,5 @@ # Environment -A significant module that manages the execution environment of the EVM. The module contains objects and methods associated with processing transactions and blocks within such a blockchain environment. It defines several structures: `Env`, `BlockEnv`, `TxEnv`, `CfgEnv`, `TransactTo`, and `CreateScheme`. These structures contain various fields representing the block data, transaction data, environmental configurations, transaction recipient details, and the method of contract creation respectively. +A significant module that manages the execution environment of the EVM. The module contains objects and methods associated with processing transactions and blocks within such a blockchain environment. It defines several structures: `Env`, `BlockEnv`, `TxEnv`, `CfgEnv`, and `CreateScheme`. These structures contain various fields representing the block data, transaction data, environmental configurations, transaction recipient details, and the method of contract creation respectively. The `Env` structure, which encapsulates the environment of the EVM, contains methods for calculating effective gas prices and for validating block and transaction data. It also checks transactions against the current state of the associated account, which is necessary to validate the transaction's nonce and the account balance. Various Ethereum Improvement Proposals (EIPs) are also considered in these validations, such as [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) for the base fee, [EIP-3607](https://eips.ethereum.org/EIPS/eip-3607) for rejecting transactions from senders with deployed code, and [EIP-3298](https://eips.ethereum.org/EIPS/eip-3298) for disabling gas refunds. The code is structured to include optional features and to allow for changes in the EVM specifications. diff --git a/examples/fork_ref_transact.rs b/examples/fork_ref_transact.rs index 6953fda2..33258b46 100644 --- a/examples/fork_ref_transact.rs +++ b/examples/fork_ref_transact.rs @@ -3,7 +3,7 @@ use alloy_sol_types::SolCall; use ethers_providers::{Http, Provider}; use revm::{ db::{CacheDB, EmptyDB, EthersDB}, - primitives::{address, ExecutionResult, Output, TransactTo, U256}, + primitives::{address, ExecutionResult, Output, TxKind, U256}, Database, Evm, }; use std::sync::Arc; @@ -70,7 +70,7 @@ async fn main() -> anyhow::Result<()> { // change that to whatever caller you want to be tx.caller = address!("0000000000000000000000000000000000000000"); // account you want to transact with - tx.transact_to = TransactTo::Call(pool_address); + tx.transact_to = TxKind::Call(pool_address); // calldata formed via abigen tx.data = encoded.into(); // transaction value in wei diff --git a/examples/generate_block_traces.rs b/examples/generate_block_traces.rs index cfd8f030..59d9d036 100644 --- a/examples/generate_block_traces.rs +++ b/examples/generate_block_traces.rs @@ -6,7 +6,7 @@ use ethers_providers::{Http, Provider}; use indicatif::ProgressBar; use revm::db::{CacheDB, EthersDB, StateBuilder}; use revm::inspectors::TracerEip3155; -use revm::primitives::{Address, TransactTo, U256}; +use revm::primitives::{Address, TxKind, U256}; use revm::{inspector_handle_register, Evm}; use std::fs::OpenOptions; use std::io::BufWriter; @@ -143,10 +143,8 @@ async fn main() -> anyhow::Result<()> { } etx.transact_to = match tx.to { - Some(to_address) => { - TransactTo::Call(Address::from(to_address.as_fixed_bytes())) - } - None => TransactTo::create(), + Some(to_address) => TxKind::Call(Address::from(to_address.as_fixed_bytes())), + None => TxKind::Create, }; }) .build(); diff --git a/examples/uniswap_v2_usdc_swap.rs b/examples/uniswap_v2_usdc_swap.rs index a57a9826..3f9905bf 100644 --- a/examples/uniswap_v2_usdc_swap.rs +++ b/examples/uniswap_v2_usdc_swap.rs @@ -7,7 +7,7 @@ use reqwest::Client; use revm::{ db::{AlloyDB, CacheDB}, primitives::{ - address, keccak256, AccountInfo, Address, Bytes, ExecutionResult, Output, TransactTo, U256, + address, keccak256, AccountInfo, Address, Bytes, ExecutionResult, Output, TxKind, U256, }, Evm, }; @@ -95,7 +95,7 @@ fn balance_of(token: Address, address: Address, cache_db: &mut AlloyCacheDB) -> .modify_tx_env(|tx| { // 0x1 because calling USDC proxy from zero address fails tx.caller = address!("0000000000000000000000000000000000000001"); - tx.transact_to = TransactTo::Call(token); + tx.transact_to = TxKind::Call(token); tx.data = encoded.into(); tx.value = U256::from(0); }) @@ -139,7 +139,7 @@ async fn get_amount_out( .with_db(cache_db) .modify_tx_env(|tx| { tx.caller = address!("0000000000000000000000000000000000000000"); - tx.transact_to = TransactTo::Call(uniswap_v2_router); + tx.transact_to = TxKind::Call(uniswap_v2_router); tx.data = encoded.into(); tx.value = U256::from(0); }) @@ -172,7 +172,7 @@ fn get_reserves(pair_address: Address, cache_db: &mut AlloyCacheDB) -> Result<(U .with_db(cache_db) .modify_tx_env(|tx| { tx.caller = address!("0000000000000000000000000000000000000000"); - tx.transact_to = TransactTo::Call(pair_address); + tx.transact_to = TxKind::Call(pair_address); tx.data = encoded.into(); tx.value = U256::from(0); }) @@ -221,7 +221,7 @@ fn swap( .with_db(cache_db) .modify_tx_env(|tx| { tx.caller = from; - tx.transact_to = TransactTo::Call(pool_address); + tx.transact_to = TxKind::Call(pool_address); tx.data = encoded.into(); tx.value = U256::from(0); }) @@ -254,7 +254,7 @@ fn transfer( .with_db(cache_db) .modify_tx_env(|tx| { tx.caller = from; - tx.transact_to = TransactTo::Call(token); + tx.transact_to = TxKind::Call(token); tx.data = encoded.into(); tx.value = U256::from(0); }) From 6e7715aa9da62a15859536a10aebc05a4f3d8968 Mon Sep 17 00:00:00 2001 From: Brian Bland Date: Thu, 20 Jun 2024 05:45:46 -0700 Subject: [PATCH 5/8] chore: Add CI build target for no-std + optimism, use matrix builds (#1551) --- .github/workflows/ci.yml | 38 ++++++++++------------------- crates/revm/src/optimism/l1block.rs | 2 +- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbea7ba5..9aaad96a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,45 +32,33 @@ jobs: - run: cargo test --workspace ${{ matrix.flags }} test-no-std: - name: test no_std + name: test no_std ${{ matrix.features }} runs-on: ubuntu-latest timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + features: ["", "optimism"] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: targets: riscv32imac-unknown-none-elf - - run: cargo check --target riscv32imac-unknown-none-elf --no-default-features - - check-no-default-features: - name: check no-default-features - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - run: | - cd crates/revm - cargo check --no-default-features + - run: cargo check --target riscv32imac-unknown-none-elf --no-default-features --features=${{ matrix.features }} - check-serde: - name: check serde - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - run: | - cd crates/revm - cargo check --no-default-features --features serde - - check-std: - name: check std + check: + name: check ${{ matrix.features }} runs-on: ubuntu-latest timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + features: ["", "serde", "std"] steps: - uses: actions/checkout@v4 - run: | cd crates/revm - cargo check --no-default-features --features std + cargo check --no-default-features --features=${{ matrix.features }} clippy: name: clippy diff --git a/crates/revm/src/optimism/l1block.rs b/crates/revm/src/optimism/l1block.rs index 631b9a5d..e348718d 100644 --- a/crates/revm/src/optimism/l1block.rs +++ b/crates/revm/src/optimism/l1block.rs @@ -223,7 +223,7 @@ impl L1BlockInfo { estimated_size .saturating_mul(l1_fee_scaled) - .wrapping_div(U256::from(1000000000000u64)) + .wrapping_div(U256::from(1_000_000_000_000u64)) } // l1BaseFee*16*l1BaseFeeScalar + l1BlobBaseFee*l1BlobBaseFeeScalar From 09451cb0ed424336e077049f2b0458a6b4533145 Mon Sep 17 00:00:00 2001 From: rakita Date: Thu, 20 Jun 2024 15:12:34 +0200 Subject: [PATCH 6/8] fix(eof): fixture 2 tests (#1550) * eof fixes * fix(eof): create initcode starting with 0xff00 * Include PragueEOF * spec missing * add helper function to get address * clippy * include box * move EOF to PragueEOF --- bins/revm-test/src/bin/burntpix/main.rs | 2 +- bins/revme/src/cmd/statetest/models/spec.rs | 2 + crates/interpreter/src/instruction_result.rs | 58 +++++++--- .../interpreter/src/instructions/contract.rs | 31 ++++-- .../interpreter/src/instructions/control.rs | 2 +- crates/interpreter/src/interpreter.rs | 8 +- crates/interpreter/src/interpreter_action.rs | 4 +- .../interpreter_action/eof_create_inputs.rs | 105 +++++++++++++----- .../interpreter_action/eof_create_outcome.rs | 71 ------------ crates/interpreter/src/lib.rs | 2 +- crates/precompile/src/lib.rs | 2 +- crates/primitives/src/bytecode/eof/header.rs | 32 +++--- crates/primitives/src/result.rs | 9 +- crates/primitives/src/specification.rs | 14 +++ crates/revm/src/context/inner_evm_context.rs | 66 ++++++++--- crates/revm/src/evm.rs | 51 ++------- crates/revm/src/frame.rs | 15 +-- .../src/handler/handle_types/execution.rs | 12 +- crates/revm/src/handler/mainnet/execution.rs | 12 +- .../src/handler/mainnet/post_execution.rs | 4 +- crates/revm/src/inspector.rs | 25 ++--- 21 files changed, 284 insertions(+), 243 deletions(-) delete mode 100644 crates/interpreter/src/interpreter_action/eof_create_outcome.rs diff --git a/bins/revm-test/src/bin/burntpix/main.rs b/bins/revm-test/src/bin/burntpix/main.rs index ea1ac56f..ef0b78ea 100644 --- a/bins/revm-test/src/bin/burntpix/main.rs +++ b/bins/revm-test/src/bin/burntpix/main.rs @@ -100,7 +100,7 @@ fn try_from_hex_to_u32(hex: &str) -> eyre::Result { } fn insert_account_info(cache_db: &mut CacheDB, addr: Address, code: Bytes) { - let code_hash = hex::encode(keccak256(code.clone())); + let code_hash = hex::encode(keccak256(&code)); let account_info = AccountInfo::new( U256::from(0), 0, diff --git a/bins/revme/src/cmd/statetest/models/spec.rs b/bins/revme/src/cmd/statetest/models/spec.rs index dac05f04..50903323 100644 --- a/bins/revme/src/cmd/statetest/models/spec.rs +++ b/bins/revme/src/cmd/statetest/models/spec.rs @@ -24,6 +24,7 @@ pub enum SpecName { Shanghai, Cancun, Prague, + PragueEOF, #[serde(other)] Unknown, } @@ -46,6 +47,7 @@ impl SpecName { Self::Shanghai => SpecId::SHANGHAI, Self::Cancun => SpecId::CANCUN, Self::Prague => SpecId::PRAGUE, + Self::PragueEOF => SpecId::PRAGUE_EOF, Self::ByzantiumToConstantinopleAt5 | Self::Constantinople => { panic!("Overridden with PETERSBURG") } diff --git a/crates/interpreter/src/instruction_result.rs b/crates/interpreter/src/instruction_result.rs index 121e12ea..aed0da33 100644 --- a/crates/interpreter/src/instruction_result.rs +++ b/crates/interpreter/src/instruction_result.rs @@ -16,6 +16,10 @@ pub enum InstructionResult { Revert = 0x10, // revert opcode CallTooDeep, OutOfFunds, + /// Revert if CREATE/CREATE2 starts with 0xEF00 + CreateInitCodeStartingEF00, + /// Invalid EOF initcode, + InvalidEOFInitCode, // Actions CallOrCreate = 0x20, @@ -29,7 +33,7 @@ pub enum InstructionResult { OpcodeNotFound, CallNotAllowedInsideStatic, StateChangeDuringStaticCall, - InvalidFEOpcode, + InvalidEFOpcode, InvalidJump, NotActivated, StackUnderflow, @@ -53,6 +57,10 @@ pub enum InstructionResult { EOFOpcodeDisabledInLegacy, /// EOF function stack overflow EOFFunctionStackOverflow, + /// Aux data overflow, new aux data is larger tha u16 max size. + EofAuxDataOverflow, + /// Aud data is smaller then already present data size. + EofAuxDataTooSmall, } impl From for InstructionResult { @@ -77,7 +85,7 @@ impl From for InstructionResult { OutOfGasError::Precompile => Self::PrecompileOOG, }, HaltReason::OpcodeNotFound => Self::OpcodeNotFound, - HaltReason::InvalidFEOpcode => Self::InvalidFEOpcode, + HaltReason::InvalidEFOpcode => Self::InvalidEFOpcode, HaltReason::InvalidJump => Self::InvalidJump, HaltReason::NotActivated => Self::NotActivated, HaltReason::StackOverflow => Self::StackOverflow, @@ -94,6 +102,9 @@ impl From for InstructionResult { HaltReason::CallNotAllowedInsideStatic => Self::CallNotAllowedInsideStatic, HaltReason::OutOfFunds => Self::OutOfFunds, HaltReason::CallTooDeep => Self::CallTooDeep, + HaltReason::EofAuxDataOverflow => Self::EofAuxDataOverflow, + HaltReason::EofAuxDataTooSmall => Self::EofAuxDataTooSmall, + HaltReason::EOFFunctionStackOverflow => Self::EOFFunctionStackOverflow, #[cfg(feature = "optimism")] HaltReason::FailedDeposit => Self::FatalExternalError, } @@ -114,7 +125,11 @@ macro_rules! return_ok { #[macro_export] macro_rules! return_revert { () => { - InstructionResult::Revert | InstructionResult::CallTooDeep | InstructionResult::OutOfFunds + InstructionResult::Revert + | InstructionResult::CallTooDeep + | InstructionResult::OutOfFunds + | InstructionResult::InvalidEOFInitCode + | InstructionResult::CreateInitCodeStartingEF00 }; } @@ -129,7 +144,7 @@ macro_rules! return_error { | InstructionResult::OpcodeNotFound | InstructionResult::CallNotAllowedInsideStatic | InstructionResult::StateChangeDuringStaticCall - | InstructionResult::InvalidFEOpcode + | InstructionResult::InvalidEFOpcode | InstructionResult::InvalidJump | InstructionResult::NotActivated | InstructionResult::StackUnderflow @@ -146,6 +161,8 @@ macro_rules! return_error { | InstructionResult::ReturnContractInNotInitEOF | InstructionResult::EOFOpcodeDisabledInLegacy | InstructionResult::EOFFunctionStackOverflow + | InstructionResult::EofAuxDataTooSmall + | InstructionResult::EofAuxDataOverflow }; } @@ -169,16 +186,24 @@ impl InstructionResult { } } +/// Internal result that are not ex +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum InternalResult { + /// Internal instruction that signals Interpreter should continue running. + InternalContinue, + /// Internal instruction that signals call or create. + InternalCallOrCreate, + /// Internal CREATE/CREATE starts with 0xEF00 + CreateInitCodeStartingEF00, +} + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum SuccessOrHalt { Success(SuccessReason), Revert, Halt(HaltReason), FatalExternalError, - /// Internal instruction that signals Interpreter should continue running. - InternalContinue, - /// Internal instruction that signals call or create. - InternalCallOrCreate, + Internal(InternalResult), } impl SuccessOrHalt { @@ -222,12 +247,13 @@ impl SuccessOrHalt { impl From for SuccessOrHalt { fn from(result: InstructionResult) -> Self { match result { - InstructionResult::Continue => Self::InternalContinue, // used only in interpreter loop + InstructionResult::Continue => Self::Internal(InternalResult::InternalContinue), // used only in interpreter loop InstructionResult::Stop => Self::Success(SuccessReason::Stop), InstructionResult::Return => Self::Success(SuccessReason::Return), InstructionResult::SelfDestruct => Self::Success(SuccessReason::SelfDestruct), InstructionResult::Revert => Self::Revert, - InstructionResult::CallOrCreate => Self::InternalCallOrCreate, // used only in interpreter loop + InstructionResult::CreateInitCodeStartingEF00 => Self::Revert, + InstructionResult::CallOrCreate => Self::Internal(InternalResult::InternalCallOrCreate), // used only in interpreter loop InstructionResult::CallTooDeep => Self::Halt(HaltReason::CallTooDeep), // not gonna happen for first call InstructionResult::OutOfFunds => Self::Halt(HaltReason::OutOfFunds), // Check for first call is done separately. InstructionResult::OutOfGas => Self::Halt(HaltReason::OutOfGas(OutOfGasError::Basic)), @@ -250,7 +276,7 @@ impl From for SuccessOrHalt { InstructionResult::StateChangeDuringStaticCall => { Self::Halt(HaltReason::StateChangeDuringStaticCall) } - InstructionResult::InvalidFEOpcode => Self::Halt(HaltReason::InvalidFEOpcode), + InstructionResult::InvalidEFOpcode => Self::Halt(HaltReason::InvalidEFOpcode), InstructionResult::InvalidJump => Self::Halt(HaltReason::InvalidJump), InstructionResult::NotActivated => Self::Halt(HaltReason::NotActivated), InstructionResult::StackUnderflow => Self::Halt(HaltReason::StackUnderflow), @@ -267,10 +293,16 @@ impl From for SuccessOrHalt { InstructionResult::CreateInitCodeSizeLimit => { Self::Halt(HaltReason::CreateInitCodeSizeLimit) } + // TODO (EOF) add proper Revert subtype. + InstructionResult::InvalidEOFInitCode => Self::Revert, InstructionResult::FatalExternalError => Self::FatalExternalError, InstructionResult::EOFOpcodeDisabledInLegacy => Self::Halt(HaltReason::OpcodeNotFound), - InstructionResult::EOFFunctionStackOverflow => Self::FatalExternalError, + InstructionResult::EOFFunctionStackOverflow => { + Self::Halt(HaltReason::EOFFunctionStackOverflow) + } InstructionResult::ReturnContract => Self::Success(SuccessReason::EofReturnContract), + InstructionResult::EofAuxDataOverflow => Self::Halt(HaltReason::EofAuxDataOverflow), + InstructionResult::EofAuxDataTooSmall => Self::Halt(HaltReason::EofAuxDataTooSmall), } } } @@ -325,7 +357,7 @@ mod tests { InstructionResult::OpcodeNotFound, InstructionResult::CallNotAllowedInsideStatic, InstructionResult::StateChangeDuringStaticCall, - InstructionResult::InvalidFEOpcode, + InstructionResult::InvalidEFOpcode, InstructionResult::InvalidJump, InstructionResult::NotActivated, InstructionResult::StackUnderflow, diff --git a/crates/interpreter/src/instructions/contract.rs b/crates/interpreter/src/instructions/contract.rs index aac3d38f..ea58ad40 100644 --- a/crates/interpreter/src/instructions/contract.rs +++ b/crates/interpreter/src/instructions/contract.rs @@ -1,12 +1,13 @@ mod call_helpers; pub use call_helpers::{calc_call_gas, get_memory_input_and_out_ranges, resize_memory}; -use revm_primitives::{keccak256, BerlinSpec}; use crate::{ gas::{self, cost_per_word, EOF_CREATE_GAS, KECCAK256WORD}, interpreter::Interpreter, - primitives::{Address, Bytes, Eof, Spec, SpecId::*, U256}, + primitives::{ + eof::EofHeader, keccak256, Address, BerlinSpec, Bytes, Eof, Spec, SpecId::*, U256, + }, CallInputs, CallScheme, CallValue, CreateInputs, CreateScheme, EOFCreateInputs, Host, InstructionResult, InterpreterAction, InterpreterResult, LoadAccountResult, MAX_INITCODE_SIZE, }; @@ -67,7 +68,7 @@ pub fn eofcreate(interpreter: &mut Interpreter, _host: &mut H) // Send container for execution container is preverified. interpreter.instruction_result = InstructionResult::CallOrCreate; interpreter.next_action = InterpreterAction::EOFCreate { - inputs: Box::new(EOFCreateInputs::new( + inputs: Box::new(EOFCreateInputs::new_opcode( interpreter.contract.target_address, created_address, value, @@ -92,10 +93,11 @@ pub fn return_contract(interpreter: &mut Interpreter, _host: & .body .container_section .get(deploy_container_index as usize) - .expect("EOF is checked"); + .expect("EOF is checked") + .clone(); // convert to EOF so we can check data section size. - let new_eof = Eof::decode(container.clone()).expect("Container is verified"); + let (eof_header, _) = EofHeader::decode(&container).expect("valid EOF header"); let aux_slice = if aux_data_size != 0 { let aux_data_offset = as_usize_or_fail!(interpreter, aux_data_offset); @@ -108,20 +110,27 @@ pub fn return_contract(interpreter: &mut Interpreter, _host: & &[] }; - let new_data_size = new_eof.body.data_section.len() + aux_slice.len(); + let static_aux_size = eof_header.eof_size() - container.len(); + + // data_size - static_aux_size give us current data `container` size. + // and with aux_slice len we can calculate new data size. + let new_data_size = eof_header.data_size as usize - static_aux_size + aux_slice.len(); if new_data_size > 0xFFFF { // aux data is too big - interpreter.instruction_result = InstructionResult::FatalExternalError; + interpreter.instruction_result = InstructionResult::EofAuxDataOverflow; return; } - if new_data_size < new_eof.header.data_size as usize { + if new_data_size < eof_header.data_size as usize { // aux data is too small - interpreter.instruction_result = InstructionResult::FatalExternalError; + interpreter.instruction_result = InstructionResult::EofAuxDataTooSmall; return; } + let new_data_size = (new_data_size as u16).to_be_bytes(); - // append data bytes - let output = [new_eof.raw(), aux_slice].concat().into(); + let mut output = [&container, aux_slice].concat(); + // set new data size in eof bytes as we know exact index. + output[eof_header.data_size_raw_i()..][..2].clone_from_slice(&new_data_size); + let output: Bytes = output.into(); let result = InstructionResult::ReturnContract; interpreter.instruction_result = result; diff --git a/crates/interpreter/src/instructions/control.rs b/crates/interpreter/src/instructions/control.rs index 4aacffd9..3bf4e435 100644 --- a/crates/interpreter/src/instructions/control.rs +++ b/crates/interpreter/src/instructions/control.rs @@ -194,7 +194,7 @@ pub fn stop(interpreter: &mut Interpreter, _host: &mut H) { /// Invalid opcode. This opcode halts the execution. pub fn invalid(interpreter: &mut Interpreter, _host: &mut H) { - interpreter.instruction_result = InstructionResult::InvalidFEOpcode; + interpreter.instruction_result = InstructionResult::InvalidEFOpcode; } /// Unknown opcode. This opcode halts the execution. diff --git a/crates/interpreter/src/interpreter.rs b/crates/interpreter/src/interpreter.rs index d74f7d08..4fa58165 100644 --- a/crates/interpreter/src/interpreter.rs +++ b/crates/interpreter/src/interpreter.rs @@ -9,7 +9,6 @@ pub use contract::Contract; pub use shared_memory::{num_words, SharedMemory, EMPTY_SHARED_MEMORY}; pub use stack::{Stack, STACK_LIMIT}; -use crate::EOFCreateOutcome; use crate::{ gas, primitives::Bytes, push, push_b256, return_ok, return_revert, CallOutcome, CreateOutcome, FunctionStack, Gas, Host, InstructionResult, InterpreterAction, @@ -192,7 +191,7 @@ impl Interpreter { } } - pub fn insert_eofcreate_outcome(&mut self, create_outcome: EOFCreateOutcome) { + pub fn insert_eofcreate_outcome(&mut self, create_outcome: CreateOutcome) { self.instruction_result = InstructionResult::Continue; let instruction_result = create_outcome.instruction_result(); @@ -206,7 +205,10 @@ impl Interpreter { match instruction_result { InstructionResult::ReturnContract => { - push_b256!(self, create_outcome.address.into_word()); + push_b256!( + self, + create_outcome.address.expect("EOF Address").into_word() + ); self.gas.erase_cost(create_outcome.gas().remaining()); self.gas.record_refund(create_outcome.gas().refunded()); } diff --git a/crates/interpreter/src/interpreter_action.rs b/crates/interpreter/src/interpreter_action.rs index 1459b022..1d2c27d6 100644 --- a/crates/interpreter/src/interpreter_action.rs +++ b/crates/interpreter/src/interpreter_action.rs @@ -3,14 +3,12 @@ mod call_outcome; mod create_inputs; mod create_outcome; mod eof_create_inputs; -mod eof_create_outcome; pub use call_inputs::{CallInputs, CallScheme, CallValue}; pub use call_outcome::CallOutcome; pub use create_inputs::{CreateInputs, CreateScheme}; pub use create_outcome::CreateOutcome; -pub use eof_create_inputs::EOFCreateInputs; -pub use eof_create_outcome::EOFCreateOutcome; +pub use eof_create_inputs::{EOFCreateInputs, EOFCreateKind}; use crate::InterpreterResult; use std::boxed::Box; diff --git a/crates/interpreter/src/interpreter_action/eof_create_inputs.rs b/crates/interpreter/src/interpreter_action/eof_create_inputs.rs index 4dc8190b..30bc525a 100644 --- a/crates/interpreter/src/interpreter_action/eof_create_inputs.rs +++ b/crates/interpreter/src/interpreter_action/eof_create_inputs.rs @@ -1,5 +1,48 @@ -use crate::primitives::{eof::EofDecodeError, Address, Bytes, Eof, TxEnv, U256}; -use std::boxed::Box; +use crate::primitives::{Address, Bytes, Eof, TxEnv, U256}; + +/// EOF create can be called from two places: +/// * EOFCREATE opcode +/// * Creation transaction. +/// +/// Creation transaction uses initdata and packs EOF and initdata inside it. +/// This eof bytecode needs to be validated. +/// +/// Opcode creation uses already validated EOF bytecode, and input from Interpreter memory. +/// Address is already known and is passed as an argument. +#[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub enum EOFCreateKind { + Tx { + initdata: Bytes, + }, + Opcode { + initcode: Eof, + input: Bytes, + created_address: Address, + }, +} + +impl EOFCreateKind { + /// Returns created address + pub fn created_address(&self) -> Option<&Address> { + match self { + EOFCreateKind::Opcode { + created_address, .. + } => Some(created_address), + EOFCreateKind::Tx { .. } => None, + } + } +} + +impl Default for EOFCreateKind { + fn default() -> Self { + EOFCreateKind::Opcode { + initcode: Eof::default(), + input: Bytes::default(), + created_address: Address::default(), + } + } +} /// Inputs for EOF create call. #[derive(Debug, Default, Clone, PartialEq, Eq)] @@ -7,42 +50,42 @@ use std::boxed::Box; pub struct EOFCreateInputs { /// Caller of Eof Craate pub caller: Address, - /// New contract address. - pub created_address: Address, /// Values of ether transfered pub value: U256, - /// Init eof code that is going to be executed. - pub eof_init_code: Eof, - /// Call data the input of the EOFCREATE call. - pub input: Bytes, /// Gas limit for the create call. pub gas_limit: u64, + /// EOF Create kind + pub kind: EOFCreateKind, } impl EOFCreateInputs { - /// Returns boxed EOFCreateInput or error. - /// Internally calls [`Self::new_tx`]. - pub fn new_tx_boxed(tx: &TxEnv, nonce: u64) -> Result, EofDecodeError> { - Ok(Box::new(Self::new_tx(tx, nonce)?)) - } - /// Create new EOF crate input from transaction that has concatenated eof init code and calldata. /// /// Legacy transaction still have optional nonce so we need to obtain it. - pub fn new_tx(tx: &TxEnv, nonce: u64) -> Result { - let (eof_init_code, input) = Eof::decode_dangling(tx.data.clone())?; - Ok(EOFCreateInputs { - caller: tx.caller, - created_address: tx.caller.create(nonce), - value: tx.value, - eof_init_code, - gas_limit: tx.gas_limit, - input, - }) + pub fn new(caller: Address, value: U256, gas_limit: u64, kind: EOFCreateKind) -> Self { + //let (eof_init_code, input) = Eof::decode_dangling(tx.data.clone())?; + EOFCreateInputs { + caller, + value, + gas_limit, + kind, + } + } + + /// Creates new EOFCreateInputs from transaction. + pub fn new_tx(tx: &TxEnv, gas_limit: u64) -> Self { + EOFCreateInputs::new( + tx.caller, + tx.value, + gas_limit, + EOFCreateKind::Tx { + initdata: tx.data.clone(), + }, + ) } /// Returns a new instance of EOFCreateInput. - pub fn new( + pub fn new_opcode( caller: Address, created_address: Address, value: U256, @@ -50,13 +93,15 @@ impl EOFCreateInputs { gas_limit: u64, input: Bytes, ) -> EOFCreateInputs { - EOFCreateInputs { + EOFCreateInputs::new( caller, - created_address, value, - eof_init_code, gas_limit, - input, - } + EOFCreateKind::Opcode { + initcode: eof_init_code, + input, + created_address, + }, + ) } } diff --git a/crates/interpreter/src/interpreter_action/eof_create_outcome.rs b/crates/interpreter/src/interpreter_action/eof_create_outcome.rs deleted file mode 100644 index beeda24e..00000000 --- a/crates/interpreter/src/interpreter_action/eof_create_outcome.rs +++ /dev/null @@ -1,71 +0,0 @@ -use crate::{Gas, InstructionResult, InterpreterResult}; -use revm_primitives::{Address, Bytes}; - -/// Represents the outcome of a create operation in an interpreter. -/// -/// This struct holds the result of the operation along with an optional address. -/// It provides methods to determine the next action based on the result of the operation. -#[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EOFCreateOutcome { - /// The result of the interpreter operation. - pub result: InterpreterResult, - /// An optional address associated with the create operation. - pub address: Address, -} - -impl EOFCreateOutcome { - /// Constructs a new [`EOFCreateOutcome`]. - /// - /// # Arguments - /// - /// * `result` - An `InterpreterResult` representing the result of the interpreter operation. - /// * `address` - An optional `Address` associated with the create operation. - /// * `return_memory_range` - The memory range that Revert bytes are going to be written. - /// - /// # Returns - /// - /// A new [`EOFCreateOutcome`] instance. - pub fn new(result: InterpreterResult, address: Address) -> Self { - Self { result, address } - } - - /// Retrieves a reference to the [`InstructionResult`] from the [`InterpreterResult`]. - /// - /// This method provides access to the `InstructionResult` which represents the - /// outcome of the instruction execution. It encapsulates the result information - /// such as whether the instruction was executed successfully, resulted in a revert, - /// or encountered a fatal error. - /// - /// # Returns - /// - /// A reference to the `InstructionResult`. - pub fn instruction_result(&self) -> &InstructionResult { - &self.result.result - } - - /// Retrieves a reference to the output bytes from the `InterpreterResult`. - /// - /// This method returns the output of the interpreted operation. The output is - /// typically used when the operation successfully completes and returns data. - /// - /// # Returns - /// - /// A reference to the output `Bytes`. - pub fn output(&self) -> &Bytes { - &self.result.output - } - - /// Retrieves a reference to the `Gas` details from the `InterpreterResult`. - /// - /// This method provides access to the gas details of the operation, which includes - /// information about gas used, remaining, and refunded. It is essential for - /// understanding the gas consumption of the operation. - /// - /// # Returns - /// - /// A reference to the `Gas` details. - pub fn gas(&self) -> &Gas { - &self.result.gas - } -} diff --git a/crates/interpreter/src/lib.rs b/crates/interpreter/src/lib.rs index 64167dd4..da95f089 100644 --- a/crates/interpreter/src/lib.rs +++ b/crates/interpreter/src/lib.rs @@ -37,7 +37,7 @@ pub use interpreter::{ }; pub use interpreter_action::{ CallInputs, CallOutcome, CallScheme, CallValue, CreateInputs, CreateOutcome, CreateScheme, - EOFCreateInputs, EOFCreateOutcome, InterpreterAction, + EOFCreateInputs, EOFCreateKind, InterpreterAction, }; pub use opcode::{Instruction, OpCode, OPCODE_INFO_JUMPTABLE}; pub use primitives::{MAX_CODE_SIZE, MAX_INITCODE_SIZE}; diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index e930f2cd..1425f342 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -281,7 +281,7 @@ impl PrecompileSpecId { ISTANBUL | MUIR_GLACIER => Self::ISTANBUL, BERLIN | LONDON | ARROW_GLACIER | GRAY_GLACIER | MERGE | SHANGHAI => Self::BERLIN, CANCUN => Self::CANCUN, - PRAGUE => Self::PRAGUE, + PRAGUE | PRAGUE_EOF => Self::PRAGUE, LATEST => Self::LATEST, #[cfg(feature = "optimism")] BEDROCK | REGOLITH | CANYON => Self::BERLIN, diff --git a/crates/primitives/src/bytecode/eof/header.rs b/crates/primitives/src/bytecode/eof/header.rs index 1074f066..c3482968 100644 --- a/crates/primitives/src/bytecode/eof/header.rs +++ b/crates/primitives/src/bytecode/eof/header.rs @@ -62,25 +62,23 @@ fn consume_header_section_size(input: &[u8]) -> Result<(&[u8], Vec, usize), impl EofHeader { /// Length of the header in bytes. /// - /// Length is calculated as: - /// magic 2 byte + - /// version 1 byte + - /// types section 3 bytes + - /// code section 3 bytes + - /// num_code_sections * 2 + - /// if num_container_sections != 0 { container section 3 bytes} + - /// num_container_sections * 2 + - /// data section 3 bytes + - /// terminator 1 byte - /// /// It is minimum 15 bytes (there is at least one code section). pub fn size(&self) -> usize { - let optional_container_sizes = if self.container_sizes.is_empty() { - 0 - } else { - 3 + self.container_sizes.len() * 2 - }; - 13 + self.code_sizes.len() * 2 + optional_container_sizes + 2 + // magic + 1 + // version + 3 + // types section + 3 + // code section + 2 * self.code_sizes.len() + // num_code_sections + if self.container_sizes.is_empty() { 0 } else { 3 + 2 * self.container_sizes.len() } + // container + 3 + // data section. + 1 // terminator + } + + /// Return index where data size starts. + /// Data size is two bytes long. + pub fn data_size_raw_i(&self) -> usize { + // termination(1byte) + code size(2) bytes. + self.size() - 3 } /// Returns number of types. diff --git a/crates/primitives/src/result.rs b/crates/primitives/src/result.rs index 28f35ce8..2a61883a 100644 --- a/crates/primitives/src/result.rs +++ b/crates/primitives/src/result.rs @@ -400,7 +400,7 @@ pub enum SuccessReason { pub enum HaltReason { OutOfGas(OutOfGasError), OpcodeNotFound, - InvalidFEOpcode, + InvalidEFOpcode, InvalidJump, NotActivated, StackUnderflow, @@ -423,6 +423,13 @@ pub enum HaltReason { OutOfFunds, CallTooDeep, + /// Aux data overflow, new aux data is larger tha u16 max size. + EofAuxDataOverflow, + /// Aud data is smaller then already present data size. + EofAuxDataTooSmall, + /// EOF Subroutine stack overflow + EOFFunctionStackOverflow, + /* Optimism errors */ #[cfg(feature = "optimism")] FailedDeposit, diff --git a/crates/primitives/src/specification.rs b/crates/primitives/src/specification.rs index d7c1d3e6..51d18010 100644 --- a/crates/primitives/src/specification.rs +++ b/crates/primitives/src/specification.rs @@ -29,6 +29,7 @@ pub enum SpecId { SHANGHAI = 16, // Shanghai 17034870 (Timestamp: 1681338455) CANCUN = 17, // Cancun 19426587 (Timestamp: 1710338135) PRAGUE = 18, // Praque TBD + PRAGUE_EOF = 19, // Praque+EOF TBD #[default] LATEST = u8::MAX, } @@ -65,6 +66,7 @@ pub enum SpecId { ECOTONE = 21, FJORD = 22, PRAGUE = 23, + PRAGUE_EOF = 24, #[default] LATEST = u8::MAX, } @@ -107,6 +109,7 @@ impl From<&str> for SpecId { "Shanghai" => Self::SHANGHAI, "Cancun" => Self::CANCUN, "Prague" => Self::PRAGUE, + "PragueEOF" => Self::PRAGUE_EOF, #[cfg(feature = "optimism")] "Bedrock" => SpecId::BEDROCK, #[cfg(feature = "optimism")] @@ -144,6 +147,7 @@ impl From for &'static str { SpecId::SHANGHAI => "Shanghai", SpecId::CANCUN => "Cancun", SpecId::PRAGUE => "Prague", + SpecId::PRAGUE_EOF => "PragueEOF", #[cfg(feature = "optimism")] SpecId::BEDROCK => "Bedrock", #[cfg(feature = "optimism")] @@ -200,6 +204,7 @@ spec!(MERGE, MergeSpec); spec!(SHANGHAI, ShanghaiSpec); spec!(CANCUN, CancunSpec); spec!(PRAGUE, PragueSpec); +spec!(PRAGUE_EOF, PragueEofSpec); spec!(LATEST, LatestSpec); @@ -278,6 +283,10 @@ macro_rules! spec_to_generic { use $crate::PragueSpec as SPEC; $e } + $crate::SpecId::PRAGUE_EOF => { + use $crate::PragueEofSpec as SPEC; + $e + } } }}; } @@ -345,6 +354,10 @@ macro_rules! spec_to_generic { use $crate::PragueSpec as SPEC; $e } + $crate::SpecId::PRAGUE_EOF => { + use $crate::PragueEofSpec as SPEC; + $e + } $crate::SpecId::BEDROCK => { use $crate::BedrockSpec as SPEC; $e @@ -406,6 +419,7 @@ mod tests { #[cfg(feature = "optimism")] spec_to_generic!(FJORD, assert_eq!(SPEC::SPEC_ID, FJORD)); spec_to_generic!(PRAGUE, assert_eq!(SPEC::SPEC_ID, PRAGUE)); + spec_to_generic!(PRAGUE_EOF, assert_eq!(SPEC::SPEC_ID, PRAGUE_EOF)); spec_to_generic!(LATEST, assert_eq!(SPEC::SPEC_ID, LATEST)); } } diff --git a/crates/revm/src/context/inner_evm_context.rs b/crates/revm/src/context/inner_evm_context.rs index c83d5ec1..c1662951 100644 --- a/crates/revm/src/context/inner_evm_context.rs +++ b/crates/revm/src/context/inner_evm_context.rs @@ -1,7 +1,8 @@ use crate::{ db::Database, interpreter::{ - analysis::to_analysed, gas, return_ok, Contract, CreateInputs, EOFCreateInputs, Gas, + analysis::{to_analysed, validate_eof}, + gas, return_ok, Contract, CreateInputs, EOFCreateInputs, EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterResult, LoadAccountResult, SStoreResult, SelfDestructResult, MAX_CODE_SIZE, }, @@ -254,10 +255,41 @@ impl InnerEvmContext { gas: Gas::new(inputs.gas_limit), output: Bytes::new(), }, - inputs.created_address, + None, )) }; + let (input, initcode, created_address) = match &inputs.kind { + EOFCreateKind::Opcode { + initcode, + input, + created_address, + } => (input.clone(), initcode.clone(), *created_address), + EOFCreateKind::Tx { initdata } => { + // Use nonce from tx (if set) or from account (if not). + // Nonce for call is bumped in deduct_caller + // TODO(make this part of nonce increment code) + let nonce = self.env.tx.nonce.unwrap_or_else(|| { + let caller = self.env.tx.caller; + self.load_account(caller) + .map(|(a, _)| a.info.nonce) + .unwrap_or_default() + }); + + // decode eof and init code. + let Ok((eof, input)) = Eof::decode_dangling(initdata.clone()) else { + return return_error(InstructionResult::InvalidEOFInitCode); + }; + + if validate_eof(&eof).is_err() { + // TODO (EOF) new error type. + return return_error(InstructionResult::InvalidEOFInitCode); + } + + (input, eof, self.env.tx.caller.create(nonce)) + } + }; + // Check depth if self.journaled_state.depth() > CALL_STACK_LIMIT { return return_error(InstructionResult::CallTooDeep); @@ -279,12 +311,12 @@ impl InnerEvmContext { // Load account so it needs to be marked as warm for access list. self.journaled_state - .load_account(inputs.created_address, &mut self.db)?; + .load_account(created_address, &mut self.db)?; // create account, transfer funds and make the journal checkpoint. let checkpoint = match self.journaled_state.create_account_checkpoint( inputs.caller, - inputs.created_address, + created_address, inputs.value, spec_id, ) { @@ -295,11 +327,11 @@ impl InnerEvmContext { }; let contract = Contract::new( - inputs.input.clone(), + input.clone(), // fine to clone as it is Bytes. - Bytecode::Eof(Arc::new(inputs.eof_init_code.clone())), + Bytecode::Eof(Arc::new(initcode.clone())), None, - inputs.created_address, + created_address, inputs.caller, inputs.value, ); @@ -309,7 +341,7 @@ impl InnerEvmContext { interpreter.set_is_eof_init(); Ok(FrameOrResult::new_eofcreate_frame( - inputs.created_address, + created_address, checkpoint, interpreter, )) @@ -334,6 +366,12 @@ impl InnerEvmContext { return; } + if interpreter_result.output.len() > MAX_CODE_SIZE { + self.journaled_state.checkpoint_revert(journal_checkpoint); + interpreter_result.result = InstructionResult::CreateContractSizeLimit; + return; + } + // deduct gas for code deployment. let gas_for_code = interpreter_result.output.len() as u64 * gas::CODEDEPOSIT; if !interpreter_result.gas.record_cost(gas_for_code) { @@ -361,14 +399,11 @@ impl InnerEvmContext { spec_id: SpecId, inputs: &CreateInputs, ) -> Result> { - // Prepare crate. - let gas = Gas::new(inputs.gas_limit); - let return_error = |e| { Ok(FrameOrResult::new_create_result( InterpreterResult { result: e, - gas, + gas: Gas::new(inputs.gas_limit), output: Bytes::new(), }, None, @@ -380,6 +415,11 @@ impl InnerEvmContext { return return_error(InstructionResult::CallTooDeep); } + // Prague EOF + if spec_id.is_enabled_in(PRAGUE_EOF) && inputs.init_code.get(..2) == Some(&[0xEF, 00]) { + return return_error(InstructionResult::CreateInitCodeStartingEF00); + } + // Fetch balance of caller. let (caller_balance, _) = self.balance(inputs.caller)?; @@ -437,7 +477,7 @@ impl InnerEvmContext { Ok(FrameOrResult::new_create_frame( created_address, checkpoint, - Interpreter::new(contract, gas.limit(), false), + Interpreter::new(contract, inputs.gas_limit, false), )) } diff --git a/crates/revm/src/evm.rs b/crates/revm/src/evm.rs index 5cb64af8..9c67a8e9 100644 --- a/crates/revm/src/evm.rs +++ b/crates/revm/src/evm.rs @@ -3,17 +3,16 @@ use crate::{ db::{Database, DatabaseCommit, EmptyDB}, handler::Handler, interpreter::{ - analysis::validate_eof, CallInputs, CreateInputs, EOFCreateInputs, EOFCreateOutcome, Gas, - Host, InstructionResult, InterpreterAction, InterpreterResult, SharedMemory, + CallInputs, CreateInputs, EOFCreateInputs, Host, InterpreterAction, SharedMemory, }, primitives::{ - specification::SpecId, BlockEnv, Bytes, CfgEnv, EVMError, EVMResult, EnvWithHandlerCfg, + specification::SpecId, BlockEnv, CfgEnv, EVMError, EVMResult, EnvWithHandlerCfg, ExecutionResult, HandlerCfg, ResultAndState, TxEnv, TxKind, }, Context, ContextWithHandlerCfg, Frame, FrameOrResult, FrameResult, }; use core::fmt; -use std::vec::Vec; +use std::{boxed::Box, vec::Vec}; /// EVM call stack limit. pub const CALL_STACK_LIMIT: u64 = 1024; @@ -350,51 +349,19 @@ impl Evm<'_, EXT, DB> { )?, TxKind::Create => { // if first byte of data is magic 0xEF00, then it is EOFCreate. - if spec_id.is_enabled_in(SpecId::PRAGUE) + if spec_id.is_enabled_in(SpecId::PRAGUE_EOF) && ctx .env() .tx .data - .get(0..=1) + .get(0..2) .filter(|&t| t == [0xEF, 00]) .is_some() { - // TODO Should we just check 0xEF it seems excessive to switch to legacy only - // if it 0xEF00? - - // get nonce from tx (if set) or from account (if not). - // Nonce for call is bumped in deduct_caller while - // for CREATE it is not (it is done inside exec handlers). - let nonce = ctx.evm.env.tx.nonce.unwrap_or_else(|| { - let caller = ctx.evm.env.tx.caller; - ctx.evm - .load_account(caller) - .map(|(a, _)| a.info.nonce) - .unwrap_or_default() - }); - - // Create EOFCreateInput from transaction initdata. - let eofcreate = EOFCreateInputs::new_tx_boxed(&ctx.evm.env.tx, nonce) - .ok() - .and_then(|eofcreate| { - // validate EOF initcode - validate_eof(&eofcreate.eof_init_code).ok()?; - Some(eofcreate) - }); - - if let Some(eofcreate) = eofcreate { - exec.eofcreate(ctx, eofcreate)? - } else { - // Return result, as code is invalid. - FrameOrResult::Result(FrameResult::EOFCreate(EOFCreateOutcome::new( - InterpreterResult::new( - InstructionResult::Stop, - Bytes::new(), - Gas::new(gas_limit), - ), - ctx.env().tx.caller.create(nonce), - ))) - } + exec.eofcreate( + ctx, + Box::new(EOFCreateInputs::new_tx(&ctx.evm.env.tx, gas_limit)), + )? } else { // Safe to unwrap because we are sure that it is create tx. exec.create( diff --git a/crates/revm/src/frame.rs b/crates/revm/src/frame.rs index c36ffe07..2ef01db5 100644 --- a/crates/revm/src/frame.rs +++ b/crates/revm/src/frame.rs @@ -4,9 +4,7 @@ use crate::{ JournalCheckpoint, }; use core::ops::Range; -use revm_interpreter::{ - CallOutcome, CreateOutcome, EOFCreateOutcome, Gas, InstructionResult, InterpreterResult, -}; +use revm_interpreter::{CallOutcome, CreateOutcome, Gas, InstructionResult, InterpreterResult}; use std::boxed::Box; /// Call CallStackFrame. @@ -59,7 +57,7 @@ pub enum Frame { pub enum FrameResult { Call(CallOutcome), Create(CreateOutcome), - EOFCreate(EOFCreateOutcome), + EOFCreate(CreateOutcome), } impl FrameResult { @@ -82,7 +80,7 @@ impl FrameResult { Output::Create(outcome.result.output.clone(), outcome.address) } FrameResult::EOFCreate(outcome) => { - Output::Create(outcome.result.output.clone(), Some(outcome.address)) + Output::Create(outcome.result.output.clone(), outcome.address) } } } @@ -277,8 +275,11 @@ impl FrameOrResult { })) } - pub fn new_eofcreate_result(interpreter_result: InterpreterResult, address: Address) -> Self { - FrameOrResult::Result(FrameResult::EOFCreate(EOFCreateOutcome { + pub fn new_eofcreate_result( + interpreter_result: InterpreterResult, + address: Option
, + ) -> Self { + FrameOrResult::Result(FrameResult::EOFCreate(CreateOutcome { result: interpreter_result, address, })) diff --git a/crates/revm/src/handler/handle_types/execution.rs b/crates/revm/src/handler/handle_types/execution.rs index 9e17def0..27d31eb1 100644 --- a/crates/revm/src/handler/handle_types/execution.rs +++ b/crates/revm/src/handler/handle_types/execution.rs @@ -6,8 +6,8 @@ use crate::{ CallFrame, Context, CreateFrame, Frame, FrameOrResult, FrameResult, }; use revm_interpreter::{ - opcode::InstructionTables, CallOutcome, CreateOutcome, EOFCreateInputs, EOFCreateOutcome, - InterpreterAction, InterpreterResult, + opcode::InstructionTables, CallOutcome, CreateOutcome, EOFCreateInputs, InterpreterAction, + InterpreterResult, }; use std::{boxed::Box, sync::Arc}; @@ -102,7 +102,7 @@ pub type FrameEOFCreateReturnHandle<'a, EXT, DB> = Arc< &mut Context, Box, InterpreterResult, - ) -> Result::Error>> + ) -> Result::Error>> + 'a, >; @@ -111,7 +111,7 @@ pub type InsertEOFCreateOutcomeHandle<'a, EXT, DB> = Arc< dyn Fn( &mut Context, &mut Frame, - EOFCreateOutcome, + CreateOutcome, ) -> Result<(), EVMError<::Error>> + 'a, >; @@ -267,7 +267,7 @@ impl<'a, EXT, DB: Database> ExecutionHandler<'a, EXT, DB> { context: &mut Context, frame: Box, interpreter_result: InterpreterResult, - ) -> Result> { + ) -> Result> { (self.eofcreate_return)(context, frame, interpreter_result) } @@ -277,7 +277,7 @@ impl<'a, EXT, DB: Database> ExecutionHandler<'a, EXT, DB> { &self, context: &mut Context, frame: &mut Frame, - outcome: EOFCreateOutcome, + outcome: CreateOutcome, ) -> Result<(), EVMError> { (self.insert_eofcreate_outcome)(context, frame, outcome) } diff --git a/crates/revm/src/handler/mainnet/execution.rs b/crates/revm/src/handler/mainnet/execution.rs index 4ee557f8..928d1735 100644 --- a/crates/revm/src/handler/mainnet/execution.rs +++ b/crates/revm/src/handler/mainnet/execution.rs @@ -10,8 +10,8 @@ use crate::{ }; use core::mem; use revm_interpreter::{ - opcode::InstructionTables, CallOutcome, EOFCreateInputs, EOFCreateOutcome, InterpreterAction, - InterpreterResult, EMPTY_SHARED_MEMORY, + opcode::InstructionTables, CallOutcome, EOFCreateInputs, InterpreterAction, InterpreterResult, + EMPTY_SHARED_MEMORY, }; use std::boxed::Box; @@ -174,15 +174,15 @@ pub fn eofcreate_return( context: &mut Context, frame: Box, mut interpreter_result: InterpreterResult, -) -> Result> { +) -> Result> { context.evm.eofcreate_return::( &mut interpreter_result, frame.created_address, frame.frame_data.checkpoint, ); - Ok(EOFCreateOutcome::new( + Ok(CreateOutcome::new( interpreter_result, - frame.created_address, + Some(frame.created_address), )) } @@ -190,7 +190,7 @@ pub fn eofcreate_return( pub fn insert_eofcreate_outcome( context: &mut Context, frame: &mut Frame, - outcome: EOFCreateOutcome, + outcome: CreateOutcome, ) -> Result<(), EVMError> { core::mem::replace(&mut context.evm.error, Ok(()))?; frame diff --git a/crates/revm/src/handler/mainnet/post_execution.rs b/crates/revm/src/handler/mainnet/post_execution.rs index bf732361..0e5cb4e1 100644 --- a/crates/revm/src/handler/mainnet/post_execution.rs +++ b/crates/revm/src/handler/mainnet/post_execution.rs @@ -111,9 +111,7 @@ pub fn output( gas_used: final_gas_used, }, // Only two internal return flags. - flag @ (SuccessOrHalt::FatalExternalError - | SuccessOrHalt::InternalContinue - | SuccessOrHalt::InternalCallOrCreate) => { + flag @ (SuccessOrHalt::FatalExternalError | SuccessOrHalt::Internal(_)) => { panic!( "Encountered unexpected internal return flag: {:?} with instruction result: {:?}", flag, instruction_result diff --git a/crates/revm/src/inspector.rs b/crates/revm/src/inspector.rs index 26551c8d..3225ed35 100644 --- a/crates/revm/src/inspector.rs +++ b/crates/revm/src/inspector.rs @@ -1,10 +1,3 @@ -use crate::{ - interpreter::{CallInputs, CreateInputs, EOFCreateInputs, EOFCreateOutcome, Interpreter}, - primitives::{db::Database, Address, Log, U256}, - EvmContext, -}; -use auto_impl::auto_impl; - #[cfg(feature = "std")] mod customprinter; #[cfg(all(feature = "std", feature = "serde-json"))] @@ -13,10 +6,16 @@ mod gas; mod handler_register; mod noop; -// Exports. - pub use handler_register::{inspector_handle_register, GetInspector}; -use revm_interpreter::{CallOutcome, CreateOutcome}; + +use crate::{ + interpreter::{ + CallInputs, CallOutcome, CreateInputs, CreateOutcome, EOFCreateInputs, Interpreter, + }, + primitives::{db::Database, Address, Log, U256}, + EvmContext, +}; +use auto_impl::auto_impl; /// [Inspector] implementations. pub mod inspectors { @@ -142,7 +141,7 @@ pub trait Inspector { &mut self, context: &mut EvmContext, inputs: &mut EOFCreateInputs, - ) -> Option { + ) -> Option { let _ = context; let _ = inputs; None @@ -153,8 +152,8 @@ pub trait Inspector { &mut self, context: &mut EvmContext, inputs: &EOFCreateInputs, - outcome: EOFCreateOutcome, - ) -> EOFCreateOutcome { + outcome: CreateOutcome, + ) -> CreateOutcome { let _ = context; let _ = inputs; outcome From eee57298af0a42b3c67ccc89691697d04214d975 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 20 Jun 2024 19:21:46 +0200 Subject: [PATCH 7/8] chore: release (#1548) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- Cargo.lock | 10 ++-- bins/revm-test/CHANGELOG.md | 90 +++++++++++++++++++++++++++++++++ bins/revm-test/Cargo.toml | 2 +- bins/revme/CHANGELOG.md | 13 +++++ bins/revme/Cargo.toml | 4 +- crates/interpreter/CHANGELOG.md | 49 ++++++++++++++++++ crates/interpreter/Cargo.toml | 4 +- crates/precompile/CHANGELOG.md | 22 ++++++++ crates/precompile/Cargo.toml | 4 +- crates/primitives/CHANGELOG.md | 27 ++++++++++ crates/primitives/Cargo.toml | 2 +- crates/revm/CHANGELOG.md | 47 +++++++++++++++++ crates/revm/Cargo.toml | 6 +-- 13 files changed, 264 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5087985f..23560d9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3079,7 +3079,7 @@ dependencies = [ [[package]] name = "revm" -version = "9.0.0" +version = "10.0.0" dependencies = [ "alloy-eips", "alloy-provider", @@ -3105,7 +3105,7 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "5.0.0" +version = "6.0.0" dependencies = [ "bincode", "paste", @@ -3118,7 +3118,7 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "7.0.0" +version = "8.0.0" dependencies = [ "aurora-engine-modexp", "blst", @@ -3142,7 +3142,7 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "4.0.0" +version = "5.0.0" dependencies = [ "alloy-primitives", "auto_impl", @@ -3175,7 +3175,7 @@ dependencies = [ [[package]] name = "revme" -version = "0.5.0" +version = "0.6.0" dependencies = [ "alloy-rlp", "hash-db", diff --git a/bins/revm-test/CHANGELOG.md b/bins/revm-test/CHANGELOG.md index 4821d7ec..63053a34 100644 --- a/bins/revm-test/CHANGELOG.md +++ b/bins/revm-test/CHANGELOG.md @@ -6,6 +6,96 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.1.0](https://github.com/bluealloy/revm/releases/tag/revm-test-v0.1.0) - 2024-06-20 + +### Added +- EOF (Ethereum Object Format) ([#1143](https://github.com/bluealloy/revm/pull/1143)) +- add tests for shift instructions ([#1254](https://github.com/bluealloy/revm/pull/1254)) +- EvmBuilder and External Contexts ([#888](https://github.com/bluealloy/revm/pull/888)) +- separate initial checks ([#486](https://github.com/bluealloy/revm/pull/486)) +- revm-interpreter created ([#320](https://github.com/bluealloy/revm/pull/320)) +- *(interpreter)* Unify instruction fn signature ([#283](https://github.com/bluealloy/revm/pull/283)) +- Migrate `primitive_types::U256` to `ruint::Uint<256, 4>` ([#239](https://github.com/bluealloy/revm/pull/239)) +- Introduce ByteCode format, Update Readme ([#156](https://github.com/bluealloy/revm/pull/156)) + +### Fixed +- *(eof)* fixture 2 tests ([#1550](https://github.com/bluealloy/revm/pull/1550)) +- *(clippy)* fix some clippy lints + +### Other +- replace TransactTo with TxKind ([#1542](https://github.com/bluealloy/revm/pull/1542)) +- *(deps)* bump regex from 1.10.4 to 1.10.5 ([#1502](https://github.com/bluealloy/revm/pull/1502)) +- release ([#1261](https://github.com/bluealloy/revm/pull/1261)) +- *(interpreter)* rewrite gas accounting for memory expansion ([#1361](https://github.com/bluealloy/revm/pull/1361)) +- revert snailtracer without microbench ([#1259](https://github.com/bluealloy/revm/pull/1259)) +- release ([#1231](https://github.com/bluealloy/revm/pull/1231)) +- *(deps)* bump other alloy deps 0.7.0 ([#1252](https://github.com/bluealloy/revm/pull/1252)) +- *(deps)* bump regex from 1.10.3 to 1.10.4 ([#1223](https://github.com/bluealloy/revm/pull/1223)) +- *(deps)* bump bytes from 1.5.0 to 1.6.0 ([#1224](https://github.com/bluealloy/revm/pull/1224)) +- release ([#1175](https://github.com/bluealloy/revm/pull/1175)) +- tag v32 revm v7.1.0 ([#1176](https://github.com/bluealloy/revm/pull/1176)) +- release ([#1125](https://github.com/bluealloy/revm/pull/1125)) +- *(deps)* bump alloy-sol-types from 0.6.3 to 0.6.4 ([#1148](https://github.com/bluealloy/revm/pull/1148)) +- *(deps)* bump alloy-sol-macro from 0.6.3 to 0.6.4 ([#1136](https://github.com/bluealloy/revm/pull/1136)) +- release tag v30 revm v6.1.0 ([#1100](https://github.com/bluealloy/revm/pull/1100)) +- clippy cleanup ([#1112](https://github.com/bluealloy/revm/pull/1112)) +- *(deps)* bump alloy-sol-types from 0.6.2 to 0.6.3 ([#1103](https://github.com/bluealloy/revm/pull/1103)) +- release ([#1082](https://github.com/bluealloy/revm/pull/1082)) +- *(deps)* bump alloy-sol-macro from 0.6.2 to 0.6.3 ([#1094](https://github.com/bluealloy/revm/pull/1094)) +- license date and revm docs ([#1080](https://github.com/bluealloy/revm/pull/1080)) +- release ([#1067](https://github.com/bluealloy/revm/pull/1067)) +- tag v27, revm v4.0.0 release ([#1061](https://github.com/bluealloy/revm/pull/1061)) +- *(deps)* bump eyre from 0.6.11 to 0.6.12 ([#1051](https://github.com/bluealloy/revm/pull/1051)) +- *(deps)* bump alloy-sol-types from 0.6.0 to 0.6.2 ([#1035](https://github.com/bluealloy/revm/pull/1035)) +- *(deps)* bump alloy-sol-macro from 0.6.0 to 0.6.2 ([#1013](https://github.com/bluealloy/revm/pull/1013)) +- chore(Test) : const to static ([#1016](https://github.com/bluealloy/revm/pull/1016)) +- Burntpix criterion bench ([#1004](https://github.com/bluealloy/revm/pull/1004)) +- Instruction table ([#759](https://github.com/bluealloy/revm/pull/759)) +- rewrite revm-test as a criterion bench ([#579](https://github.com/bluealloy/revm/pull/579)) +- optimize stack usage for recursive `call` and `create` programs ([#522](https://github.com/bluealloy/revm/pull/522)) +- Bump v24, revm v3.3.0 ([#476](https://github.com/bluealloy/revm/pull/476)) +- Release v23, revm v3.2.0 ([#464](https://github.com/bluealloy/revm/pull/464)) +- Release v22, revm v3.1.1 ([#460](https://github.com/bluealloy/revm/pull/460)) +- v21, revm v3.1.0 ([#444](https://github.com/bluealloy/revm/pull/444)) +- remove gas blocks ([#391](https://github.com/bluealloy/revm/pull/391)) +- *(deps)* bump bytes from 1.3.0 to 1.4.0 ([#355](https://github.com/bluealloy/revm/pull/355)) +- Bump v20, changelog ([#350](https://github.com/bluealloy/revm/pull/350)) +- includes to libs ([#338](https://github.com/bluealloy/revm/pull/338)) +- Creating revm-primitives, revm better errors and db components ([#334](https://github.com/bluealloy/revm/pull/334)) +- Cleanup, move hot fields toggether in Interpreter ([#321](https://github.com/bluealloy/revm/pull/321)) +- native bits ([#278](https://github.com/bluealloy/revm/pull/278)) +- *(release)* Bump revm and precompiles versions +- Bump primitive_types. Add statetest spec +- Bump revm v2.1.0 ([#224](https://github.com/bluealloy/revm/pull/224)) +- revm bump v2.0.0, precompile bump v1.1.1 ([#212](https://github.com/bluealloy/revm/pull/212)) +- Cfg choose create analysis, option on bytecode size limit ([#210](https://github.com/bluealloy/revm/pull/210)) +- Cargo sort. Bump lib versions ([#208](https://github.com/bluealloy/revm/pull/208)) +- Return `ExecutionResult`, which includes `gas_refunded` ([#169](https://github.com/bluealloy/revm/pull/169)) +- Bytecode hash, remove override_spec, ([#165](https://github.com/bluealloy/revm/pull/165)) +- revm bump 1.8. update libs. snailtracer rename ([#159](https://github.com/bluealloy/revm/pull/159)) +- v6 changelog, bump versions +- Big Refactor. Machine to Interpreter. refactor instructions. call/create struct ([#52](https://github.com/bluealloy/revm/pull/52)) +- [revm] pop_top and unsafe comments ([#51](https://github.com/bluealloy/revm/pull/51)) +- [precompiles] remove unused borsh +- [recompl] Bump precompile deps, cargo sort on workspace +- [revm] output log. Stetetest test log output. fmt +- Bump versions, Changelogs, fmt, revm readme, clippy. +- [revm] Run test multiple times. fmt, BenchmarkDB +- Multiple changes: web3 db, debugger initial commit, precompile load +- Memory to usize, clippy,fmt +- wip optimize i256 +- TEMP switch stacks H256 with U256 +- [revm] some perfs +- [revm] Perfs stack pop. Benchmark snailtracer. +- [revm] cleanup +- fmt +- EVM Interface changed. Inspector called separately +- Bump revm v0.3.0. README updated +- DB ref mut polished +- And now we debug +- [revm] Interface. Inspector added, Env cleanup. revm-test passes +- Rename bin to bins + ## [0.1.0](https://github.com/bluealloy/revm/releases/tag/revm-test-v0.1.0) - 2024-02-07 ### Added diff --git a/bins/revm-test/Cargo.toml b/bins/revm-test/Cargo.toml index 01a5ab9a..c18da113 100644 --- a/bins/revm-test/Cargo.toml +++ b/bins/revm-test/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] bytes = "1.6" hex = "0.4" -revm = { path = "../../crates/revm", version = "9.0.0", default-features=false } +revm = { path = "../../crates/revm", version = "10.0.0", default-features=false } microbench = "0.5" alloy-sol-macro = "0.7.0" alloy-sol-types = "0.7.0" diff --git a/bins/revme/CHANGELOG.md b/bins/revme/CHANGELOG.md index 41e89545..fdd65001 100644 --- a/bins/revme/CHANGELOG.md +++ b/bins/revme/CHANGELOG.md @@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.6.0](https://github.com/bluealloy/revm/compare/revme-v0.5.0...revme-v0.6.0) - 2024-06-20 + +### Added +- *(EOF)* Put EOF bytecode behind an Arc ([#1517](https://github.com/bluealloy/revm/pull/1517)) +- *(revme)* add prague spec ([#1506](https://github.com/bluealloy/revm/pull/1506)) + +### Fixed +- *(eof)* fixture 2 tests ([#1550](https://github.com/bluealloy/revm/pull/1550)) + +### Other +- replace TransactTo with TxKind ([#1542](https://github.com/bluealloy/revm/pull/1542)) +- skip tests with storage check and return status ([#1452](https://github.com/bluealloy/revm/pull/1452)) + ## [0.5.0](https://github.com/bluealloy/revm/compare/revme-v0.4.0...revme-v0.5.0) - 2024-05-12 ### Added diff --git a/bins/revme/Cargo.toml b/bins/revme/Cargo.toml index 71d9d654..04f9b264 100644 --- a/bins/revme/Cargo.toml +++ b/bins/revme/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["ethereum", "evm"] license = "MIT" repository = "https://github.com/bluealloy/revm" description = "Rust Ethereum Virtual Machine Executable" -version = "0.5.0" +version = "0.6.0" [dependencies] hash-db = "0.15" @@ -15,7 +15,7 @@ hashbrown = "0.14" indicatif = "0.17" microbench = "0.5" plain_hasher = "0.2" -revm = { path = "../../crates/revm", version = "9.0.0", default-features = false, features = [ +revm = { path = "../../crates/revm", version = "10.0.0", default-features = false, features = [ "ethersdb", "std", "serde-json", diff --git a/crates/interpreter/CHANGELOG.md b/crates/interpreter/CHANGELOG.md index be64279f..2ae9a3ca 100644 --- a/crates/interpreter/CHANGELOG.md +++ b/crates/interpreter/CHANGELOG.md @@ -6,6 +6,55 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [6.0.0](https://github.com/bluealloy/revm/compare/revm-interpreter-v5.0.0...revm-interpreter-v6.0.0) - 2024-06-20 + +### Added +- *(EOF)* Put EOF bytecode behind an Arc ([#1517](https://github.com/bluealloy/revm/pull/1517)) +- *(EOF)* EXTCODECOPY,EXTCODESIZE,EXTCODEHASH eof support ([#1504](https://github.com/bluealloy/revm/pull/1504)) +- add helpers for working with instruction tables ([#1493](https://github.com/bluealloy/revm/pull/1493)) +- *(EOF)* change oob behavior of RETURNDATALOAD and RETURNDATACOPY ([#1476](https://github.com/bluealloy/revm/pull/1476)) +- *(EOF)* EIP-7698 eof creation transaction ([#1467](https://github.com/bluealloy/revm/pull/1467)) +- adjust gas-costs for EIP-2935 BLOCKHASH ([#1422](https://github.com/bluealloy/revm/pull/1422)) +- add Opcode::modifies_memory back ([#1421](https://github.com/bluealloy/revm/pull/1421)) +- *(EOF)* Add CALLF/JUMPF stack checks ([#1417](https://github.com/bluealloy/revm/pull/1417)) +- *(EOF)* remove TXCREATE ([#1415](https://github.com/bluealloy/revm/pull/1415)) + +### Fixed +- *(eof)* fixture 2 tests ([#1550](https://github.com/bluealloy/revm/pull/1550)) +- *(eof)* output gas for eofcreate ([#1540](https://github.com/bluealloy/revm/pull/1540)) +- *(EOF)* set CallOrCreate result in EOFCREATE ([#1535](https://github.com/bluealloy/revm/pull/1535)) +- *(EOF)* target needed for EOFCREATE created address ([#1536](https://github.com/bluealloy/revm/pull/1536)) +- *(EOF)* ext*call return values ([#1515](https://github.com/bluealloy/revm/pull/1515)) +- *(EOF)* Remove redundunt ext call gas cost ([#1513](https://github.com/bluealloy/revm/pull/1513)) +- *(EOF)* add DATACOPY copy gas ([#1510](https://github.com/bluealloy/revm/pull/1510)) +- *(EOF)* extstaticcall make static ([#1508](https://github.com/bluealloy/revm/pull/1508)) +- *(EOF)* jumpf gas was changes ([#1507](https://github.com/bluealloy/revm/pull/1507)) +- *(EOF)* panic on empty input range, and continue exec after eofcreate ([#1477](https://github.com/bluealloy/revm/pull/1477)) +- *(eof)* EOFCREATE spend gas and apply 63/64 rule ([#1471](https://github.com/bluealloy/revm/pull/1471)) +- *(stack)* pop with five items was not correct ([#1472](https://github.com/bluealloy/revm/pull/1472)) +- *(EOF)* returncontract immediate is one byte ([#1468](https://github.com/bluealloy/revm/pull/1468)) +- *(Interpreter)* wrong block number used ([#1458](https://github.com/bluealloy/revm/pull/1458)) +- *(interpreter)* avoid overflow when checking if mem limit reached ([#1429](https://github.com/bluealloy/revm/pull/1429)) +- blockchash for devnet-0 ([#1427](https://github.com/bluealloy/revm/pull/1427)) + +### Other +- replace TransactTo with TxKind ([#1542](https://github.com/bluealloy/revm/pull/1542)) +- simplify Interpreter serde ([#1544](https://github.com/bluealloy/revm/pull/1544)) +- *(interpreter)* use U256::arithmetic_shr in SAR ([#1525](https://github.com/bluealloy/revm/pull/1525)) +- pluralize EOFCreateInput ([#1523](https://github.com/bluealloy/revm/pull/1523)) +- added simular to used-by ([#1521](https://github.com/bluealloy/revm/pull/1521)) +- Removed .clone() in ExecutionHandler::call, and reusing output buffer in Interpreter ([#1512](https://github.com/bluealloy/revm/pull/1512)) +- *(revme)* add new line in revme EOF printer ([#1503](https://github.com/bluealloy/revm/pull/1503)) +- remove old deprecated items ([#1489](https://github.com/bluealloy/revm/pull/1489)) +- *(interpreter)* use max gas limit in `impl Default for Interpreter` ([#1478](https://github.com/bluealloy/revm/pull/1478)) +- *(interpreter)* optimisation for BYTE, SHL, SHR and SAR ([#1418](https://github.com/bluealloy/revm/pull/1418)) +- Revert "Revert "feat: implement EIP-2935 ([#1354](https://github.com/bluealloy/revm/pull/1354))" ([#1424](https://github.com/bluealloy/revm/pull/1424))" ([#1426](https://github.com/bluealloy/revm/pull/1426)) +- Revert "feat: implement EIP-2935 ([#1354](https://github.com/bluealloy/revm/pull/1354))" ([#1424](https://github.com/bluealloy/revm/pull/1424)) +- *(EOF)* rename extcall opcode/names ([#1416](https://github.com/bluealloy/revm/pull/1416)) +- point to gas! in Gas::record_cost ([#1413](https://github.com/bluealloy/revm/pull/1413)) +- pop_address should use crate scope ([#1410](https://github.com/bluealloy/revm/pull/1410)) +- Remove Host constrain from calc_call_gas ([#1409](https://github.com/bluealloy/revm/pull/1409)) + ## [5.0.0](https://github.com/bluealloy/revm/compare/revm-interpreter-v4.0.0...revm-interpreter-v5.0.0) - 2024-05-12 ### Added diff --git a/crates/interpreter/Cargo.toml b/crates/interpreter/Cargo.toml index cd6b3d96..91777aa6 100644 --- a/crates/interpreter/Cargo.toml +++ b/crates/interpreter/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["no_std", "ethereum", "evm", "revm", "interpreter"] license = "MIT" name = "revm-interpreter" repository = "https://github.com/bluealloy/revm" -version = "5.0.0" +version = "6.0.0" readme = "../../README.md" [package.metadata.docs.rs] @@ -22,7 +22,7 @@ rust_2018_idioms = "deny" all = "warn" [dependencies] -revm-primitives = { path = "../primitives", version = "4.0.0", default-features = false } +revm-primitives = { path = "../primitives", version = "5.0.0", default-features = false } paste = { version = "1.0", optional = true } phf = { version = "0.11", default-features = false, optional = true, features = [ diff --git a/crates/precompile/CHANGELOG.md b/crates/precompile/CHANGELOG.md index ac868f2e..9edb307a 100644 --- a/crates/precompile/CHANGELOG.md +++ b/crates/precompile/CHANGELOG.md @@ -6,6 +6,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [8.0.0](https://github.com/bluealloy/revm/compare/revm-precompile-v7.0.0...revm-precompile-v8.0.0) - 2024-06-20 + +### Added +- *(precompiles)* fatal error for precompiles ([#1499](https://github.com/bluealloy/revm/pull/1499)) +- add ecAdd to precompile bench ([#1496](https://github.com/bluealloy/revm/pull/1496)) +- *(optimism)* Add secp256r1 precompile for Fjord ([#1436](https://github.com/bluealloy/revm/pull/1436)) + +### Fixed +- *(eof)* fixture 2 tests ([#1550](https://github.com/bluealloy/revm/pull/1550)) +- check canonical Fp elements ([#1434](https://github.com/bluealloy/revm/pull/1434)) +- *(precompile)* ignore infinity points in G1 MSM ([#1432](https://github.com/bluealloy/revm/pull/1432)) +- *(precompile)* BLS G2 MSM ([#1428](https://github.com/bluealloy/revm/pull/1428)) + +### Other +- avoid cloning precompiles ([#1486](https://github.com/bluealloy/revm/pull/1486)) +- *(precompiles)* Fix some nits in bls12_381 ([#1495](https://github.com/bluealloy/revm/pull/1495)) +- *(deps)* allow multiple versions of secp256k1 ([#1490](https://github.com/bluealloy/revm/pull/1490)) +- *(deps)* bump rstest from 0.19.0 to 0.21.0 ([#1482](https://github.com/bluealloy/revm/pull/1482)) +- *(deps)* bump blst from 0.3.11 to 0.3.12 ([#1481](https://github.com/bluealloy/revm/pull/1481)) +- add test for map_fp_to_g1 precompile ([#1465](https://github.com/bluealloy/revm/pull/1465)) +- add docs for BLS scalar input decoding ([#1446](https://github.com/bluealloy/revm/pull/1446)) + ## [7.0.0](https://github.com/bluealloy/revm/compare/revm-precompile-v6.0.0...revm-precompile-v7.0.0) - 2024-05-12 ### Added diff --git a/crates/precompile/Cargo.toml b/crates/precompile/Cargo.toml index 097985ed..b27ef6f3 100644 --- a/crates/precompile/Cargo.toml +++ b/crates/precompile/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["no_std", "ethereum", "evm", "revm", "precompiles"] license = "MIT" name = "revm-precompile" repository = "https://github.com/bluealloy/revm" -version = "7.0.0" +version = "8.0.0" [package.metadata.docs.rs] all-features = true @@ -21,7 +21,7 @@ rust_2018_idioms = "deny" all = "warn" [dependencies] -revm-primitives = { path = "../primitives", version = "4.0.0", default-features = false } +revm-primitives = { path = "../primitives", version = "5.0.0", default-features = false } once_cell = { version = "1.19", default-features = false, features = ["alloc"] } # ecRecover diff --git a/crates/primitives/CHANGELOG.md b/crates/primitives/CHANGELOG.md index ad68b29b..3aebb966 100644 --- a/crates/primitives/CHANGELOG.md +++ b/crates/primitives/CHANGELOG.md @@ -6,6 +6,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [5.0.0](https://github.com/bluealloy/revm/compare/revm-primitives-v4.0.0...revm-primitives-v5.0.0) - 2024-06-20 + +### Added +- *(EOF)* Put EOF bytecode behind an Arc ([#1517](https://github.com/bluealloy/revm/pull/1517)) +- *(EOF)* EXTCODECOPY,EXTCODESIZE,EXTCODEHASH eof support ([#1504](https://github.com/bluealloy/revm/pull/1504)) +- *(precompiles)* fatal error for precompiles ([#1499](https://github.com/bluealloy/revm/pull/1499)) +- Persist reverted account and storage slot lookups in `JournaledState` ([#1437](https://github.com/bluealloy/revm/pull/1437)) +- *(EOF)* EIP-7698 eof creation transaction ([#1467](https://github.com/bluealloy/revm/pull/1467)) +- *(optimism)* Add secp256r1 precompile for Fjord ([#1436](https://github.com/bluealloy/revm/pull/1436)) +- *(EOF)* Add CALLF/JUMPF stack checks ([#1417](https://github.com/bluealloy/revm/pull/1417)) +- *(EOF)* remove TXCREATE ([#1415](https://github.com/bluealloy/revm/pull/1415)) + +### Fixed +- *(eof)* fixture 2 tests ([#1550](https://github.com/bluealloy/revm/pull/1550)) +- *(primitives)* specify the optimism cfg on spec_to_generic ([#1412](https://github.com/bluealloy/revm/pull/1412)) + +### Other +- replace TransactTo with TxKind ([#1542](https://github.com/bluealloy/revm/pull/1542)) +- remove DatabaseWithDebugError ([#1545](https://github.com/bluealloy/revm/pull/1545)) +- avoid cloning precompiles ([#1486](https://github.com/bluealloy/revm/pull/1486)) +- added simular to used-by ([#1521](https://github.com/bluealloy/revm/pull/1521)) +- derive PartialEq and Hash on EnvKzgSettings ([#1494](https://github.com/bluealloy/revm/pull/1494)) +- remove old deprecated items ([#1489](https://github.com/bluealloy/revm/pull/1489)) +- *(primitives)* rename State/Storage to EvmState/EvmStorage ([#1459](https://github.com/bluealloy/revm/pull/1459)) +- Revert "Revert "feat: implement EIP-2935 ([#1354](https://github.com/bluealloy/revm/pull/1354))" ([#1424](https://github.com/bluealloy/revm/pull/1424))" ([#1426](https://github.com/bluealloy/revm/pull/1426)) +- Revert "feat: implement EIP-2935 ([#1354](https://github.com/bluealloy/revm/pull/1354))" ([#1424](https://github.com/bluealloy/revm/pull/1424)) + ## [4.0.0](https://github.com/bluealloy/revm/compare/revm-primitives-v3.1.1...revm-primitives-v4.0.0) - 2024-05-12 ### Added diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index a9d009d2..eeb36da1 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["no_std", "ethereum", "evm", "revm", "types"] license = "MIT" name = "revm-primitives" repository = "https://github.com/bluealloy/revm" -version = "4.0.0" +version = "5.0.0" readme = "../../README.md" [package.metadata.docs.rs] diff --git a/crates/revm/CHANGELOG.md b/crates/revm/CHANGELOG.md index fc2408cb..0822ca73 100644 --- a/crates/revm/CHANGELOG.md +++ b/crates/revm/CHANGELOG.md @@ -6,6 +6,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [10.0.0](https://github.com/bluealloy/revm/compare/revm-v9.0.0...revm-v10.0.0) - 2024-06-20 + +### Added +- *(revm)* derive serde for `BundleState` ([#1539](https://github.com/bluealloy/revm/pull/1539)) +- bump alloy, re-enable alloydb ([#1533](https://github.com/bluealloy/revm/pull/1533)) +- mutable access for all fields in BundleBuilder ([#1524](https://github.com/bluealloy/revm/pull/1524)) +- *(EOF)* Put EOF bytecode behind an Arc ([#1517](https://github.com/bluealloy/revm/pull/1517)) +- *(EOF)* EXTCODECOPY,EXTCODESIZE,EXTCODEHASH eof support ([#1504](https://github.com/bluealloy/revm/pull/1504)) +- add helpers for working with instruction tables ([#1493](https://github.com/bluealloy/revm/pull/1493)) +- *(precompiles)* fatal error for precompiles ([#1499](https://github.com/bluealloy/revm/pull/1499)) +- Persist reverted account and storage slot lookups in `JournaledState` ([#1437](https://github.com/bluealloy/revm/pull/1437)) +- *(EOF)* EIP-7698 eof creation transaction ([#1467](https://github.com/bluealloy/revm/pull/1467)) +- *(EOF)* Add EOF to inspector handle register ([#1469](https://github.com/bluealloy/revm/pull/1469)) +- *(optimism)* Implement new L1 cost function for Fjord ([#1420](https://github.com/bluealloy/revm/pull/1420)) +- *(optimism)* Add secp256r1 precompile for Fjord ([#1436](https://github.com/bluealloy/revm/pull/1436)) +- *(revm)* revert EIP-2935 BLOCKHASH opcode changes ([#1450](https://github.com/bluealloy/revm/pull/1450)) +- load account should return db error ([#1447](https://github.com/bluealloy/revm/pull/1447)) +- *(EOF)* remove TXCREATE ([#1415](https://github.com/bluealloy/revm/pull/1415)) + +### Fixed +- *(eof)* fixture 2 tests ([#1550](https://github.com/bluealloy/revm/pull/1550)) +- *(eof)* output gas for eofcreate ([#1540](https://github.com/bluealloy/revm/pull/1540)) +- *(revm)* remove storage reset that clears is_cold flag ([#1518](https://github.com/bluealloy/revm/pull/1518)) +- *(op)* Remove `U256::from()` ([#1498](https://github.com/bluealloy/revm/pull/1498)) +- *(EOF)* panic on empty input range, and continue exec after eofcreate ([#1477](https://github.com/bluealloy/revm/pull/1477)) +- *(Interpreter)* wrong block number used ([#1458](https://github.com/bluealloy/revm/pull/1458)) +- blockchash for devnet-0 ([#1427](https://github.com/bluealloy/revm/pull/1427)) + +### Other +- Add CI build target for no-std + optimism, use matrix builds ([#1551](https://github.com/bluealloy/revm/pull/1551)) +- replace TransactTo with TxKind ([#1542](https://github.com/bluealloy/revm/pull/1542)) +- avoid cloning precompiles ([#1486](https://github.com/bluealloy/revm/pull/1486)) +- add setters to `BundleBuilder` with `&mut self` ([#1527](https://github.com/bluealloy/revm/pull/1527)) +- pluralize EOFCreateInput ([#1523](https://github.com/bluealloy/revm/pull/1523)) +- added simular to used-by ([#1521](https://github.com/bluealloy/revm/pull/1521)) +- Removed .clone() in ExecutionHandler::call, and reusing output buffer in Interpreter ([#1512](https://github.com/bluealloy/revm/pull/1512)) +- remove old deprecated items ([#1489](https://github.com/bluealloy/revm/pull/1489)) +- *(deps)* bump rstest from 0.19.0 to 0.21.0 ([#1482](https://github.com/bluealloy/revm/pull/1482)) +- *(deps)* bump tokio from 1.37.0 to 1.38.0 ([#1480](https://github.com/bluealloy/revm/pull/1480)) +- *(primitives)* rename State/Storage to EvmState/EvmStorage ([#1459](https://github.com/bluealloy/revm/pull/1459)) +- remove 'checked' bytecode bench causing benchmarks to crash due to name ([#1461](https://github.com/bluealloy/revm/pull/1461)) +- cargo update ([#1451](https://github.com/bluealloy/revm/pull/1451)) +- cleanup host blockhash fn ([#1430](https://github.com/bluealloy/revm/pull/1430)) +- Revert "Revert "feat: implement EIP-2935 ([#1354](https://github.com/bluealloy/revm/pull/1354))" ([#1424](https://github.com/bluealloy/revm/pull/1424))" ([#1426](https://github.com/bluealloy/revm/pull/1426)) +- Revert "feat: implement EIP-2935 ([#1354](https://github.com/bluealloy/revm/pull/1354))" ([#1424](https://github.com/bluealloy/revm/pull/1424)) +- *(deps)* bump anyhow from 1.0.82 to 1.0.83 ([#1404](https://github.com/bluealloy/revm/pull/1404)) + ## [9.0.0](https://github.com/bluealloy/revm/compare/revm-v8.0.0...revm-v9.0.0) - 2024-05-12 ### Added diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index 7ca55cd7..bae81991 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["no_std", "ethereum", "evm", "revm"] license = "MIT" name = "revm" repository = "https://github.com/bluealloy/revm" -version = "9.0.0" +version = "10.0.0" readme = "../../README.md" [package.metadata.docs.rs] @@ -23,8 +23,8 @@ all = "warn" [dependencies] # revm -revm-interpreter = { path = "../interpreter", version = "5.0.0", default-features = false } -revm-precompile = { path = "../precompile", version = "7.0.0", default-features = false } +revm-interpreter = { path = "../interpreter", version = "6.0.0", default-features = false } +revm-precompile = { path = "../precompile", version = "8.0.0", default-features = false } # misc auto_impl = { version = "1.2", default-features = false } From 99367b1db2c436359c0155ed8965c19fc5503a1b Mon Sep 17 00:00:00 2001 From: rakita Date: Thu, 20 Jun 2024 19:54:29 +0200 Subject: [PATCH 8/8] release: main Readme (#1555) --- CHANGELOG.md | 53 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd62fd2c..cd0cee81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ Because this is workspace with multi libraries, tags will be simplified, and with this document you can match version of project with git tag. +# v37 tag +date: 20.06.2024 + +Audit of the codebase announced: https://hackmd.io/G7zazTX4TtekCnj6xlgctQ +secp256r1 precompile added. + +Prague changes: +* EOF bugs squashed. +* Introducing PragueEOF hardfork. +* EIP-2935 (blockhashes) modified for devnet-1. +* Fixed for BLS12-381 curve. + +Versions: +* revme: 0.5.0 -> 0.6.0 +* revm: 9.0.0 -> 10.0.0 +* revm-interpreter: 5.0.0 -> 6.0.0 +* revm-primitives: 4.0.0 -> 5.0.0 +* revm-precompile: 7.0.0 -> 8.0.0 + # v36 tag date: 12.05.2024 @@ -10,35 +29,35 @@ Support for prague EIPs. EOF removed BytecodeLocked, OpCode table got changed, and CallInputs got refactored. -revme: 0.4.0 -> 0.5.0 (⚠️ API breaking changes) -revm: 8.0.0 -> 9.0.0 (⚠️ API breaking changes) -revm-interpreter: 4.0.0 -> 5.0.0 (⚠️ API breaking changes) -revm-primitives: 3.1.1 -> 4.0.0 (⚠️ API breaking changes) -revm-precompile: 6.0.0 -> 7.0.0 (⚠️ API breaking changes) -revm-test: 0.1.0 +* revme: 0.4.0 -> 0.5.0 (⚠️ API breaking changes) +* revm: 8.0.0 -> 9.0.0 (⚠️ API breaking changes) +* revm-interpreter: 4.0.0 -> 5.0.0 (⚠️ API breaking changes) +* revm-primitives: 3.1.1 -> 4.0.0 (⚠️ API breaking changes) +* revm-precompile: 6.0.0 -> 7.0.0 (⚠️ API breaking changes) +* revm-test: 0.1.0 # v35 tag date: 02.04.2024 Small release. Alloy bump. Small refactors and deprecated functions removed. -revme: 0.3.1 -> 0.4.0 (✓ API compatible changes) -revm: 7.2.0 -> 8.0.0 (⚠️ API breaking changes) -revm-interpreter: 3.4.0 -> 4.0.0 (⚠️ API breaking changes) -revm-primitives: 3.1.0 -> 3.1.1 (✓ API compatible changes) -revm-precompile: 5.1.0 -> 6.0.0 (⚠️ API breaking changes) -revm-test: 0.1.0 +* revme: 0.3.1 -> 0.4.0 (✓ API compatible changes) +* revm: 7.2.0 -> 8.0.0 (⚠️ API breaking changes) +* revm-interpreter: 3.4.0 -> 4.0.0 (⚠️ API breaking changes) +* revm-primitives: 3.1.0 -> 3.1.1 (✓ API compatible changes) +* revm-precompile: 5.1.0 -> 6.0.0 (⚠️ API breaking changes) +* revm-test: 0.1.0 # v34 tag date: 20.03.2024 Small release, few utilities and refactoring, precompiles fn and Interpreter helper macros are made public. -revme: 0.3.0 -> 0.3.1 (✓ API compatible changes) -revm: 7.1.0 -> 7.2.0 (✓ API compatible changes) -revm-interpreter: 3.3.0 -> 3.4.0 (✓ API compatible changes) -revm-primitives: 3.0.0 -> 3.1.0 (✓ API compatible changes) -revm-precompile: 5.0.0 -> 5.1.0 (✓ API compatible changes) +* revme: 0.3.0 -> 0.3.1 (✓ API compatible changes) +* revm: 7.1.0 -> 7.2.0 (✓ API compatible changes) +* revm-interpreter: 3.3.0 -> 3.4.0 (✓ API compatible changes) +* revm-primitives: 3.0.0 -> 3.1.0 (✓ API compatible changes) +* revm-precompile: 5.0.0 -> 5.1.0 (✓ API compatible changes) # v33 tag TODO