diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bc0d8a5a2..4d464c5f50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,19 @@ Because this is workspace with multi libraries, tags will be simplified, and with this document you can match version of project with git tag. +# v20 tag +date 23.01.2023 +Big release. primitives and interpreter libs and optimizations. +This tag can be found in `main` + +* revm: v3.0.0 +* revm-precompile: v2.0.0 +* revm-primitives: v1.0.0 +* revm-interpreter: v1.0.0 + # v19 tag data 22.11.2022 Bump dependency in revm and precompiles +Found on same branch as v17 tag. * revm: v2.3.1 * revm_precompiles: v1.1.2 diff --git a/Cargo.lock b/Cargo.lock index b780476721..2b81e4e5a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1569,7 +1569,7 @@ dependencies = [ [[package]] name = "revm" -version = "2.3.1" +version = "3.0.0" dependencies = [ "auto_impl", "ethers-core", @@ -1584,7 +1584,7 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "3.0.0" +version = "1.0.0" dependencies = [ "arbitrary", "derive_more", @@ -1598,7 +1598,7 @@ dependencies = [ [[package]] name = "revm-precompiles" -version = "1.1.2" +version = "2.0.0" dependencies = [ "hex", "k256", @@ -1614,7 +1614,7 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "3.0.0" +version = "1.0.0" dependencies = [ "arbitrary", "auto_impl", @@ -1641,7 +1641,6 @@ dependencies = [ "hex", "microbench", "revm", - "revm-interpreter", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e9d0e48cfd..49aafc6d2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,6 @@ members = [ default-members = ["crates/revm"] [profile.release] -debug = true lto = true codegen-units = 1 diff --git a/README.md b/README.md index 974fdb31a9..60948e047d 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,18 @@ Here is list of things that i would like to use as guide in this project: structure: * crates - * revm -> main EVM library - * revm_precompiles -> EVM precompiles are standalone - * revmjs -> Binding for js. (in not finished state) + * revm -> main EVM library. + * revm-primitives -> Primitive data types. + * revm-interpreter -> Execution loop with instructions + * revm-precompiles -> EVM precompiles * bins: * revme: cli binary, used for running state test json - * revm-test: test binaries with contracts, used mostly to check performance (will probably merge it inside revme). + * revm-test: test binaries with contracts, used mostly to check performance There were some big efforts on optimization of revm: * Optimizing interpreter loop: https://github.com/bluealloy/revm/issues/7 * Introducing Bytecode format (and better bytecode analysis): https://github.com/bluealloy/revm/issues/121 +* Unification of instruction signatures: https://github.com/bluealloy/revm/pull/283 # Running eth tests @@ -44,9 +46,12 @@ cargo run --package revm-test --release --bin snailtracer cargo flamegraph --root --freq 4000 --min-width 0.001 --package revm-test --bin snailtracer ``` -# Used by +# Used by: -* Foundry project (as their main EVM): https://github.com/foundry-rs/foundry +* Foundry: https://github.com/foundry-rs/foundry +* Helios: https://github.com/a16z/helios +* Hardhat (transitioning to it): https://github.com/NomicFoundation/hardhat/tree/rethnet/main +* Reth: https://github.com/paradigmxyz/reth (If you want to add your project to the list, ping me or open the PR) diff --git a/bins/revm-test/Cargo.toml b/bins/revm-test/Cargo.toml index 6a16efa985..5ac4fa7768 100644 --- a/bins/revm-test/Cargo.toml +++ b/bins/revm-test/Cargo.toml @@ -7,8 +7,7 @@ edition = "2021" [dependencies] bytes = "1.1" hex = "0.4" -revm = { path = "../../crates/revm", version = "2.3.1" } -revm-interpreter = { path = "../../crates/interpreter", version = "3.0.0" } +revm = { path = "../../crates/revm", version = "3.0.0" } microbench = "0.5" [[bin]] diff --git a/bins/revm-test/src/bin/snailtracer.rs b/bins/revm-test/src/bin/snailtracer.rs index ff50ba33a0..a649a9079b 100644 --- a/bins/revm-test/src/bin/snailtracer.rs +++ b/bins/revm-test/src/bin/snailtracer.rs @@ -3,7 +3,7 @@ use std::time::Duration; use bytes::Bytes; use revm::{ db::BenchmarkDB, - interpreter::{analysis::to_analysed, BytecodeLocked, DummyHost}, + interpreter::{analysis::to_analysed, BytecodeLocked, Contract, DummyHost, Interpreter}, primitives::{BerlinSpec, Bytecode, TransactTo}, }; extern crate alloc; @@ -40,7 +40,7 @@ pub fn simple_example() { ); // revm interpreter - let contract = revm_interpreter::Contract { + let contract = Contract { input: evm.env.tx.data, bytecode: BytecodeLocked::try_from(bytecode).unwrap(), ..Default::default() @@ -48,7 +48,7 @@ pub fn simple_example() { let mut host = DummyHost::new(env); microbench::bench(&bench_options, "Snailtracer Interpreter benchmark", || { - let mut interpreter = revm_interpreter::Interpreter::new(contract.clone(), u64::MAX, false); + let mut interpreter = Interpreter::new(contract.clone(), u64::MAX, false); interpreter.run::<_, BerlinSpec>(&mut host); host.clear() }); diff --git a/bins/revme/Cargo.toml b/bins/revme/Cargo.toml index 0d431cb137..1c29e36e07 100644 --- a/bins/revme/Cargo.toml +++ b/bins/revme/Cargo.toml @@ -17,7 +17,7 @@ hex = "0.4" indicatif = "0.17" plain_hasher = "0.2" primitive-types = { version = "0.12", features = ["rlp", "serde"] } -revm = { path = "../../crates/revm", version = "2.3.1", default-features = false, features = [ +revm = { path = "../../crates/revm", version = "3.0.0", default-features = false, features = [ "ethersdb", "std", "secp256k1", diff --git a/crates/interpreter/CHANGELOG.md b/crates/interpreter/CHANGELOG.md index 7e7c3799e5..410794a68f 100644 --- a/crates/interpreter/CHANGELOG.md +++ b/crates/interpreter/CHANGELOG.md @@ -1,3 +1,4 @@ -# v3.0.0 +# v1.0.0 +date: 29.01.2023 -Interpreter was extracted from main REVM crate. Before v3.0.0 version, this code was part of REVM. \ No newline at end of file +Interpreter was extracted from main revm crate at the revm v3.0.0 version. \ No newline at end of file diff --git a/crates/interpreter/Cargo.toml b/crates/interpreter/Cargo.toml index e4f2ce2b40..5ea1b9b7f9 100644 --- a/crates/interpreter/Cargo.toml +++ b/crates/interpreter/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["no_std", "ethereum", "vm", "evm", "revm", "interpreter"] license = "MIT" name = "revm-interpreter" repository = "https://github.com/bluealloy/revm" -version = "3.0.0" +version = "1.0.0" readme = "../../README.md" [dependencies] diff --git a/crates/precompiles/CHANGELOG.md b/crates/precompiles/CHANGELOG.md index 834188bb10..a03b9d1aa5 100644 --- a/crates/precompiles/CHANGELOG.md +++ b/crates/precompiles/CHANGELOG.md @@ -1,3 +1,8 @@ +# v2.0.0 +date: 29.01.2023 + +Renamed to `revm-precompiles` from `revm_precompiles` + # v1.1.2 date: 22.11.2022 diff --git a/crates/precompiles/Cargo.toml b/crates/precompiles/Cargo.toml index e5ffde4fc3..7cc183e773 100644 --- a/crates/precompiles/Cargo.toml +++ b/crates/precompiles/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["no_std", "ethereum", "evm", "precompiles"] license = "MIT" name = "revm-precompiles" repository = "https://github.com/bluealloy/revm" -version = "1.1.2" +version = "2.0.0" [dependencies] revm-primitives = { path = "../primitives", default-features = false } diff --git a/crates/primitives/CHANGELOG.md b/crates/primitives/CHANGELOG.md index 7e7c3799e5..410794a68f 100644 --- a/crates/primitives/CHANGELOG.md +++ b/crates/primitives/CHANGELOG.md @@ -1,3 +1,4 @@ -# v3.0.0 +# v1.0.0 +date: 29.01.2023 -Interpreter was extracted from main REVM crate. Before v3.0.0 version, this code was part of REVM. \ No newline at end of file +Interpreter was extracted from main revm crate at the revm v3.0.0 version. \ No newline at end of file diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 652af57e52..3b4631008b 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["no_std", "ethereum", "vm", "evm", "revm", "primitives", "types"] license = "MIT" name = "revm-primitives" repository = "https://github.com/bluealloy/revm" -version = "3.0.0" +version = "1.0.0" readme = "../../README.md" [dependencies] @@ -76,4 +76,5 @@ arbitrary = [ "dep:arbitrary", "dep:proptest", "dep:proptest-derive", -] \ No newline at end of file +] +optimism = [] diff --git a/crates/primitives/src/env.rs b/crates/primitives/src/env.rs index 5ffc615d15..619b5a69d7 100644 --- a/crates/primitives/src/env.rs +++ b/crates/primitives/src/env.rs @@ -42,6 +42,13 @@ pub struct TxEnv { pub chain_id: Option, pub nonce: Option, pub access_list: Vec<(B160, Vec)>, + + #[cfg(feature = "optimism")] + pub mint: Option, + #[cfg(feature = "optimism")] + pub is_deposit_tx: bool, + #[cfg(feature = "optimism")] + pub is_system_tx: bool, } #[derive(Clone, Debug)] @@ -172,6 +179,13 @@ impl Default for TxEnv { chain_id: None, nonce: None, access_list: Vec::new(), + + #[cfg(feature = "optimism")] + mint: None, + #[cfg(feature = "optimism")] + is_deposit_tx: false, + #[cfg(feature = "optimism")] + is_system_tx: false, } } } diff --git a/crates/revm/CHANGELOG.md b/crates/revm/CHANGELOG.md index 4cf04014ab..ea342af5e7 100644 --- a/crates/revm/CHANGELOG.md +++ b/crates/revm/CHANGELOG.md @@ -1,3 +1,53 @@ +# v3.0.0 +date 29.01.2022 + +This is big release that has core changes that breaks compatibility. In summary: +* Project is refactored into `revm-primitives`,`revm-precompiles`,`revm-interpreter` and `revm` to have more flexibility and separation of concerns. And include paths in revm reflect that. So try to find include as `revm::primitives` or `revm::interpreter` +* Parity `primitive-types` was replaced with `ruint` for big numbers and subset of macros are used for native `B160`/`B256` types. +* Interpreter instructions are unified and now all of them have same signature. +* web3 db was replaces with ethers alternative. +* revmjs lib was removed from crates. +* `revm_precompile` was renamed to `revm-precompile.` + +* Return types are made to have more insight of what have happened inside revm. +* Snailtracer benchmark got around 20% faster. + +Github Changelog: +* dc9818f - (HEAD -> o/bump, origin/bump_v20) Bump v20 (13 hours ago) +* 75ef0f1 - (origin/main, origin/HEAD) feat: Staticcall internal return (#349) (13 hours ago) +* 0194b37 - (t) fix bug introduced in last commit (13 hours ago) +* 7b00f32 - Cleanup imports (#348) (14 hours ago) +* c14d7ea - fix: enable the examples to run with the current revm (#347) (16 hours ago) +* 329fd94 - Wrap all calls to interpreter.gas.erase_cost with checks if USE_GAS is enabled (#346) (2 days ago) +* 72355f4 - improvement: add logs & return value to revert (#343) (3 days ago) +* 142a1c9 - expose hashbrown::HashMap in primitives (#345) (3 days ago) +* ba393d7 - fix: disable balance check (#342) (4 days ago) +* 876fad1 - refactor: simplify DatabaseComponentError (#339) (6 days ago) +* 81534ad - chore: includes to libs (#338) (7 days ago) +* e2f4d32 - Creating revm-primitives, revm better errors and db components (#334) (10 days ago) +* de83db6 - fix: feature flags (#330) (2 weeks ago) +* b60269c - `revm`: mark `with-serde` feature as deprecated (#328) (2 weeks ago) +* 63bf475 - make load_account pub (#325) (3 weeks ago) +* 0ef0197 - Cleanup, move hot fields toggether in Interpreter (#321) (3 weeks ago) +* 81942d6 - enable proptest with arbitrary feature (#323) (3 weeks ago) +* 2be3798 - feat: revm-interpreter created (#320) (3 weeks ago) +* 7e98fef - fix: feature flag compiler errors (#256) (5 weeks ago) +* 488ef8a - Add example for fork + ref_transact impl (#296) (6 weeks ago) <0xDmtri> +* 56e6c22 - feat: allow disabling of balance checks (#297) (6 weeks ago) +* 8661467 - feat: Export CustomPrinter insector from revm (#300) (6 weeks ago) +* 222b8e9 - feature: substitute web3db to ethersdb (#293) (6 weeks ago) <0xDmtri> +* fd01083 - feature(revm): Return `bytes` in Create calls (#289) (7 weeks ago) +* 2fb0933 - docs: Correct typo (#282) (7 weeks ago) +* 90fe01e - feat(interpreter): Unify instruction fn signature (#283) (7 weeks ago) +* 54e0333 - bug: Integer overflow while calculating the remaining gas in GasInspector (#287) (8 weeks ago) +* acdbaac - native bits (#278) (8 weeks ago) +* 69e302b - feat(revm): Add prevrandao field to EnvBlock (#271) (2 months ago) +* d1703cd - Export StorageSlot (#265) (3 months ago) +* 560bb03 - Fix: typos (#263) (3 months ago) +* 369244e - feat(refactor): make keccak in one place. (#247) (3 months ago) +* c96c878 - feat: Migrate `primitive_types::U256` to `ruint::Uint<256, 4>` (#239) (3 months ago) + + # v2.3.1 date: 22.11.2022 diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index 98552e56b4..b3caba1c30 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -6,12 +6,12 @@ keywords = ["no_std", "ethereum", "evm", "revm"] license = "MIT" name = "revm" repository = "https://github.com/bluealloy/revm" -version = "2.3.1" +version = "3.0.0" readme = "../../README.md" [dependencies] -revm-precompiles = { path = "../precompiles", version = "1.1.2", default-features = false } -revm-interpreter = { path = "../interpreter", default-features = false } +revm-precompiles = { path = "../precompiles", version = "2.0.0", default-features = false } +revm-interpreter = { path = "../interpreter", version = "1.0.0", default-features = false } auto_impl = { version = "1.0", default-features = false } @@ -50,6 +50,7 @@ optional_gas_refund = ["revm-interpreter/optional_gas_refund"] std = ["revm-interpreter/std"] ethersdb = ["tokio", "futures", "ethers-providers", "ethers-core"] serde = ["dep:serde", "revm-interpreter/serde"] +optimism = [] # deprecated feature web3db = [] with-serde = [] diff --git a/crates/revm/src/evm_impl.rs b/crates/revm/src/evm_impl.rs index 6c23e196ae..e6268b8330 100644 --- a/crates/revm/src/evm_impl.rs +++ b/crates/revm/src/evm_impl.rs @@ -45,6 +45,9 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> Transact let gas_limit = self.data.env.tx.gas_limit; let effective_gas_price = self.data.env.effective_gas_price(); + let is_deposit = self.data.env.tx.is_deposit_tx; + let is_system_tx = self.data.env.tx.is_system_tx; + if GSPEC::enabled(MERGE) && self.data.env.block.prevrandao.is_none() { return Err(EVMError::PrevrandaoNotSet); } @@ -89,7 +92,7 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> Transact let disable_eip3607 = false; // EIP-3607: Reject transactions from senders with deployed code - // This EIP is introduced after london but there was no colision in past + // This EIP is introduced after london but there was no collision in past // so we can leave it enabled always if !disable_eip3607 && self.data.journaled_state.account(caller).info.code_hash != KECCAK_EMPTY @@ -123,6 +126,12 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> Transact return Err(InvalidTransaction::LackOfFundForGasLimit.into()); } + #[cfg(feature = "optimism")] + if let Some(minted) = self.data.env.tx.mint { + // Add minted amount to caller balance + *caller_balance = caller_balance.saturating_add(minted); + } + // Reduce gas_limit*gas_price amount of caller account. // unwrap_or can only occur if disable_balance_check is enabled *caller_balance = caller_balance @@ -227,6 +236,16 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> Transact } }; + // TODO: if deposit failed, update the sender nonce anyway + // and set the gas used to the gas limit + if is_deposit && !result.is_success() { + // if the fail reason is not that the block ran out of gas. Otherwise, + // don't count the deposit as executed. + // The problem is that this check can only be done in the + // external function that executes the block in op-reth, not here. + self.data.journaled_state.inc_nonce(caller); + } + Ok(ResultAndState { result, state }) } }