diff --git a/bins/revm-test/Cargo.toml b/bins/revm-test/Cargo.toml index 3f3d57ba60..54b774dba9 100644 --- a/bins/revm-test/Cargo.toml +++ b/bins/revm-test/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "revm-test" version = "0.1.0" -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/bins/revme/Cargo.toml b/bins/revme/Cargo.toml index 84c3aa3f5b..3ac097cb6c 100644 --- a/bins/revme/Cargo.toml +++ b/bins/revme/Cargo.toml @@ -1,6 +1,6 @@ [package] authors = ["Dragan Rakita "] -edition = "2018" +edition = "2021" name = "revme" keywords = ["ethereum", "evm"] license = "MIT" diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index 1b0013dca7..019ba5335f 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Dragan Rakita "] description = "REVM - Rust Ethereum Virtual Machine" -edition = "2018" +edition = "2021" keywords = ["no_std", "ethereum", "evm", "revm"] license = "MIT" name = "revm" diff --git a/crates/revm/src/evm_impl.rs b/crates/revm/src/evm_impl.rs index 790166a249..372da1a419 100644 --- a/crates/revm/src/evm_impl.rs +++ b/crates/revm/src/evm_impl.rs @@ -5,8 +5,8 @@ use crate::{ interpreter::{Contract, Interpreter}, journaled_state::{Account, JournaledState, State}, models::SelfDestructResult, - return_ok, return_revert, CallContext, CallInputs, CallScheme, CreateInputs, CreateScheme, Env, - ExecutionResult, Gas, Inspector, Log, Return, Spec, + return_ok, return_revert, AnalysisKind, CallContext, CallInputs, CallScheme, CreateInputs, + CreateScheme, Env, ExecutionResult, Gas, Inspector, Log, Return, Spec, SpecId::{self, *}, TransactOut, TransactTo, Transfer, KECCAK_EMPTY, }; @@ -482,7 +482,7 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> EVMImpl<'a, GSPEC, DB, // EIP-170: Contract code size limit // By default limit is 0x6000 (~25kb) if SPEC::enabled(SPURIOUS_DRAGON) - && bytes.len() > self.data.env.cfg.limit_contract_code_size + && bytes.len() > self.data.env.cfg.limit_contract_code_size.unwrap_or(0x6000) { self.data.journaled_state.checkpoint_revert(checkpoint); return (Return::CreateContractLimit, ret, interp.gas, b); @@ -505,7 +505,12 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> EVMImpl<'a, GSPEC, DB, // if we have enought gas self.data.journaled_state.checkpoint_commit(); // Do analasis of bytecode streight away. - let bytecode = Bytecode::new_raw(bytes).to_analysed::(); + let bytecode = match self.data.env.cfg.perf_analyse_created_bytecodes { + AnalysisKind::Raw => Bytecode::new_raw(bytes), + AnalysisKind::Check => Bytecode::new_raw(bytes).to_checked(), + AnalysisKind::Analyse => Bytecode::new_raw(bytes).to_analysed::(), + }; + self.data .journaled_state .set_code(created_address, bytecode); diff --git a/crates/revm/src/models.rs b/crates/revm/src/models.rs index 24b524f074..fa447c4493 100644 --- a/crates/revm/src/models.rs +++ b/crates/revm/src/models.rs @@ -226,11 +226,13 @@ pub struct CfgEnv { /// safe to be set to `true`, depending on the chain. pub perf_all_precompiles_have_balance: bool, /// Bytecode that is created with CREATE/CREATE2 is by default analysed and jumptable is created. - /// This is very benefitial for testing and speeds up execution of that bytecode when - pub perf_analyse_created_bytecodes: bool, - /// Effects EIP-170: Contract code size limit. Usefull to increase this because of tests. + /// This is very benefitial for testing and speeds up execution of that bytecode when. + /// It will have side effect if it is enabled in client that switches between forks. + /// Default: Analyse + pub perf_analyse_created_bytecodes: AnalysisKind, + /// If some it will effects EIP-170: Contract code size limit. Usefull to increase this because of tests. /// By default it is 0x6000 (~25kb). - pub limit_contract_code_size: usize, + pub limit_contract_code_size: Option, /// A hard memory limit in bytes beyond which [Memory] cannot be resized. /// /// In cases where the gas limit may be extraordinarily high, it is recommended to set this to @@ -240,14 +242,23 @@ pub struct CfgEnv { pub memory_limit: u64, } +#[derive(Clone, Default, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +pub enum AnalysisKind { + Raw, + Check, + #[default] + Analyse, +} + impl Default for CfgEnv { fn default() -> CfgEnv { CfgEnv { chain_id: 1.into(), spec_id: SpecId::LATEST, perf_all_precompiles_have_balance: false, - perf_analyse_created_bytecodes: true, - limit_contract_code_size: 0x6000, + perf_analyse_created_bytecodes: Default::default(), + limit_contract_code_size: None, #[cfg(feature = "memory_limit")] memory_limit: 2u64.pow(32) - 1, } diff --git a/crates/revm_precompiles/Cargo.toml b/crates/revm_precompiles/Cargo.toml index f8f7caf0f7..b6e36c2aff 100644 --- a/crates/revm_precompiles/Cargo.toml +++ b/crates/revm_precompiles/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Dragan Rakita "] description = "REVM Precompiles - Ethereum compatible precompiled contracts" -edition = "2018" +edition = "2021" keywords = ["no_std", "ethereum", "evm", "precompiles"] license = "MIT" name = "revm_precompiles" diff --git a/crates/revmjs/Cargo.toml b/crates/revmjs/Cargo.toml index 20cd8f8282..2848a75adc 100644 --- a/crates/revmjs/Cargo.toml +++ b/crates/revmjs/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Dragan Rakita "] description = "REVM WASM - Rust Ethereum Virtual Machine Web Assembly lib" -edition = "2018" +edition = "2021" keywords = ["ethereum", "evm", "rust"] license = "MIT" name = "revmjs"