From 3e5a3079daf609c18a58d1992a9c1f0588989c92 Mon Sep 17 00:00:00 2001 From: rakita Date: Wed, 18 Sep 2024 15:14:45 +0200 Subject: [PATCH] feat: project restructuring Part1 (#1776) * feat: project restructuring * refactor * restructuring * restructure * restructure * move revm-test bins to revme bench * rm ethersdb and revm-test * move kzg to wiring * fmt, clippy, cleanup * fix test and doc * fix kzg-rs build * Use hashbrown for revme * docs fix * fix merged change * fmt --- .github/workflows/cachegrind.yml | 4 +- Cargo.lock | 966 ++++-------------- Cargo.toml | 19 +- bins/revm-test/CHANGELOG.md | 647 ------------ bins/revm-test/Cargo.toml | 28 - bins/revme/Cargo.toml | 19 +- bins/revme/src/cmd.rs | 7 + bins/revme/src/cmd/bench.rs | 33 + .../bin => revme/src/cmd/bench}/analysis.rs | 7 +- .../src/cmd/bench/burntpix.rs} | 40 +- .../src/cmd/bench}/burntpix/static_data.rs | 0 .../src/cmd/bench}/snailtracer.rs | 6 +- .../bin => revme/src/cmd/bench}/transfer.rs | 6 +- bins/revme/src/cmd/bytecode.rs | 3 +- bins/revme/src/cmd/evmrunner.rs | 4 +- .../revme/src/cmd/statetest/models/eip7702.rs | 9 +- bins/revme/src/cmd/statetest/models/mod.rs | 5 +- bins/revme/src/cmd/statetest/models/spec.rs | 2 +- bins/revme/src/cmd/statetest/runner.rs | 16 +- crates/bytecode/CHANGELOG.md | 0 crates/bytecode/Cargo.toml | 42 + {bins/revm-test => crates/bytecode}/LICENSE | 0 .../bytecode.rs => bytecode/src/eip7702.rs} | 2 +- .../src/bytecode => bytecode/src}/eof.rs | 4 +- .../src/bytecode => bytecode/src}/eof/body.rs | 2 +- .../src}/eof/decode_helpers.rs | 0 .../bytecode => bytecode/src}/eof/header.rs | 3 +- .../src}/eof/types_section.rs | 0 crates/bytecode/src/errors.rs | 36 + .../src/bytecode => bytecode/src}/legacy.rs | 2 +- .../src}/legacy/jump_map.rs | 2 +- .../src/bytecode.rs => bytecode/src/lib.rs} | 54 +- crates/database/interface/CHANGELOG.md | 0 crates/database/interface/Cargo.toml | 47 + crates/database/interface/LICENSE | 21 + .../interface/src/empty_db.rs} | 9 +- .../db.rs => database/interface/src/lib.rs} | 18 +- crates/gas/CHANGELOG.md | 0 crates/gas/Cargo.toml | 41 + crates/gas/LICENSE | 21 + crates/gas/src/lib.rs | 8 + crates/inspector/CHANGELOG.md | 0 crates/inspector/Cargo.toml | 38 + crates/inspector/LICENSE | 21 + crates/inspector/src/lib.rs | 6 + crates/interface/CHANGELOG.md | 0 crates/interface/Cargo.toml | 35 + crates/interface/LICENSE | 21 + crates/interface/src/lib.rs | 8 + crates/interpreter/Cargo.toml | 37 +- crates/interpreter/src/gas/calc.rs | 10 +- crates/interpreter/src/host.rs | 7 +- crates/interpreter/src/host/dummy.rs | 14 +- crates/interpreter/src/instruction_result.rs | 8 +- .../src/instructions/arithmetic.rs | 8 +- .../interpreter/src/instructions/bitwise.rs | 12 +- .../interpreter/src/instructions/contract.rs | 11 +- .../src/instructions/contract/call_helpers.rs | 9 +- .../interpreter/src/instructions/control.rs | 22 +- crates/interpreter/src/instructions/data.rs | 7 +- crates/interpreter/src/instructions/host.rs | 3 +- .../interpreter/src/instructions/host_env.rs | 9 +- crates/interpreter/src/instructions/i256.rs | 4 +- crates/interpreter/src/instructions/macros.rs | 10 +- crates/interpreter/src/instructions/memory.rs | 8 +- crates/interpreter/src/instructions/stack.rs | 13 +- crates/interpreter/src/instructions/system.rs | 15 +- crates/interpreter/src/interpreter.rs | 14 +- .../interpreter/src/interpreter/analysis.rs | 21 +- .../interpreter/src/interpreter/contract.rs | 10 +- crates/interpreter/src/interpreter/serde.rs | 2 +- .../src/interpreter/shared_memory.rs | 9 +- crates/interpreter/src/interpreter/stack.rs | 6 +- crates/interpreter/src/interpreter_action.rs | 2 +- .../src/interpreter_action/call_inputs.rs | 5 +- .../src/interpreter_action/call_outcome.rs | 2 +- .../src/interpreter_action/create_inputs.rs | 6 +- .../src/interpreter_action/create_outcome.rs | 2 +- .../interpreter_action/eof_create_inputs.rs | 6 +- crates/interpreter/src/lib.rs | 8 +- crates/interpreter/src/opcode.rs | 3 +- crates/interpreter/src/opcode/eof_printer.rs | 4 +- crates/interpreter/src/opcode/tables.rs | 3 +- crates/optimism/Cargo.toml | 14 +- crates/optimism/src/bn128.rs | 17 +- crates/optimism/src/env.rs | 12 +- crates/optimism/src/fast_lz.rs | 4 +- crates/optimism/src/handler_register.rs | 19 +- crates/optimism/src/l1block.rs | 5 +- crates/optimism/src/lib.rs | 5 +- crates/optimism/src/result.rs | 2 +- crates/optimism/src/spec.rs | 7 +- crates/precompile/Cargo.toml | 22 +- crates/precompile/benches/bench.rs | 3 +- crates/precompile/src/blake2.rs | 12 +- crates/precompile/src/bls12_381.rs | 8 +- crates/precompile/src/bls12_381/g1.rs | 3 +- crates/precompile/src/bls12_381/g1_add.rs | 3 +- crates/precompile/src/bls12_381/g1_msm.rs | 3 +- crates/precompile/src/bls12_381/g1_mul.rs | 3 +- crates/precompile/src/bls12_381/g2.rs | 3 +- crates/precompile/src/bls12_381/g2_add.rs | 3 +- crates/precompile/src/bls12_381/g2_msm.rs | 3 +- crates/precompile/src/bls12_381/g2_mul.rs | 3 +- .../precompile/src/bls12_381/map_fp2_to_g2.rs | 3 +- .../precompile/src/bls12_381/map_fp_to_g1.rs | 3 +- crates/precompile/src/bls12_381/pairing.rs | 9 +- crates/precompile/src/bls12_381/utils.rs | 2 +- crates/precompile/src/bn128.rs | 71 +- crates/precompile/src/fatal_precompile.rs | 7 +- crates/precompile/src/hash.rs | 10 +- crates/precompile/src/identity.rs | 8 +- crates/precompile/src/interface.rs | 250 +++++ crates/precompile/src/kzg_point_evaluation.rs | 15 +- crates/precompile/src/lib.rs | 17 +- crates/precompile/src/modexp.rs | 16 +- crates/precompile/src/secp256k1.rs | 13 +- crates/precompile/src/secp256r1.rs | 10 +- crates/precompile/src/utilities.rs | 2 +- crates/primitives/Cargo.toml | 77 +- crates/primitives/src/db/components.rs | 83 -- .../src/db/components/block_hash.rs | 45 - crates/primitives/src/db/components/state.rs | 73 -- crates/primitives/src/eip7702.rs | 26 - crates/primitives/src/kzg.rs | 31 - crates/primitives/src/lib.rs | 48 +- crates/revm/Cargo.toml | 62 +- crates/revm/benches/bench.rs | 7 +- crates/revm/src/builder.rs | 32 +- crates/revm/src/context.rs | 17 +- .../revm/src/context/context_precompiles.rs | 12 +- crates/revm/src/context/evm_context.rs | 65 +- crates/revm/src/context/inner_evm_context.rs | 29 +- crates/revm/src/db.rs | 12 +- crates/revm/src/db/alloydb.rs | 6 +- crates/revm/src/db/ethersdb.rs | 4 +- crates/revm/src/db/in_memory_db.rs | 15 +- crates/revm/src/db/states/bundle_account.rs | 4 +- crates/revm/src/db/states/bundle_state.rs | 6 +- crates/revm/src/db/states/cache.rs | 6 +- crates/revm/src/db/states/cache_account.rs | 4 +- crates/revm/src/db/states/changes.rs | 4 +- crates/revm/src/db/states/plain_account.rs | 3 +- crates/revm/src/db/states/reverts.rs | 3 +- crates/revm/src/db/states/state.rs | 11 +- crates/revm/src/db/states/state_builder.rs | 7 +- .../revm/src/db/states/transition_account.rs | 20 +- crates/revm/src/db/states/transition_state.rs | 2 +- crates/revm/src/evm.rs | 34 +- crates/revm/src/evm_wiring.rs | 6 +- crates/revm/src/frame.rs | 12 +- crates/revm/src/handler.rs | 24 +- .../src/handler/handle_types/execution.rs | 15 +- .../revm/src/handler/handle_types/generic.rs | 3 +- .../handler/handle_types/post_execution.rs | 10 +- .../src/handler/handle_types/pre_execution.rs | 8 +- .../src/handler/handle_types/validation.rs | 12 +- crates/revm/src/handler/mainnet/execution.rs | 26 +- .../src/handler/mainnet/post_execution.rs | 16 +- .../revm/src/handler/mainnet/pre_execution.rs | 22 +- crates/revm/src/handler/mainnet/validation.rs | 15 +- crates/revm/src/inspector.rs | 11 +- crates/revm/src/inspector/customprinter.rs | 38 +- crates/revm/src/inspector/eip3155.rs | 16 +- crates/revm/src/inspector/gas.rs | 44 +- crates/revm/src/inspector/handler_register.rs | 32 +- crates/revm/src/journaled_state.rs | 19 +- crates/revm/src/lib.rs | 23 +- crates/specification/CHANGELOG.md | 0 crates/specification/Cargo.toml | 49 + crates/specification/LICENSE | 21 + crates/specification/src/eip170.rs | 6 + crates/specification/src/eip2.rs | 10 + crates/specification/src/eip2930.rs | 1 + crates/specification/src/eip7702.rs | 9 + .../src/eip7702/authorization_list.rs | 53 +- crates/specification/src/eip7702/constants.rs | 7 + .../src/eip7702/recovered_authorization.rs | 51 + .../src/hardfork.rs} | 64 +- crates/specification/src/lib.rs | 12 + crates/state/CHANGELOG.md | 0 crates/state/Cargo.toml | 49 + crates/state/LICENSE | 21 + crates/state/src/account_info.rs | 144 +++ .../src/state.rs => state/src/lib.rs} | 226 +--- crates/state/src/types.rs | 11 + crates/wiring/CHANGELOG.md | 0 crates/wiring/Cargo.toml | 79 ++ crates/wiring/LICENSE | 21 + crates/{primitives => wiring}/src/block.rs | 16 +- .../utilities.rs => wiring/src/block/blob.rs} | 34 +- .../src/env.rs => wiring/src/default.rs} | 156 +-- crates/wiring/src/default/block.rs | 108 ++ crates/wiring/src/default/transaction.rs | 1 + .../{primitives => wiring}/src/evm_wiring.rs | 25 +- crates/wiring/src/kzg.rs | 47 + crates/wiring/src/lib.rs | 32 + .../{primitives => wiring}/src/precompile.rs | 3 +- crates/{primitives => wiring}/src/result.rs | 13 +- .../{primitives => wiring}/src/transaction.rs | 18 +- examples/db_by_ref.rs | 8 +- examples/deploy.rs | 10 +- examples/fork_ref_transact.rs | 34 +- examples/generate_block_traces.rs | 110 +- examples/split_db_trait.rs | 207 ++++ 205 files changed, 2793 insertions(+), 3125 deletions(-) delete mode 100644 bins/revm-test/CHANGELOG.md delete mode 100644 bins/revm-test/Cargo.toml create mode 100644 bins/revme/src/cmd/bench.rs rename bins/{revm-test/src/bin => revme/src/cmd/bench}/analysis.rs (98%) rename bins/{revm-test/src/bin/burntpix/main.rs => revme/src/cmd/bench/burntpix.rs} (87%) rename bins/{revm-test/src/bin => revme/src/cmd/bench}/burntpix/static_data.rs (100%) rename bins/{revm-test/src/bin => revme/src/cmd/bench}/snailtracer.rs (99%) rename bins/{revm-test/src/bin => revme/src/cmd/bench}/transfer.rs (90%) create mode 100644 crates/bytecode/CHANGELOG.md create mode 100644 crates/bytecode/Cargo.toml rename {bins/revm-test => crates/bytecode}/LICENSE (100%) rename crates/{primitives/src/eip7702/bytecode.rs => bytecode/src/eip7702.rs} (99%) rename crates/{primitives/src/bytecode => bytecode/src}/eof.rs (99%) rename crates/{primitives/src/bytecode => bytecode/src}/eof/body.rs (99%) rename crates/{primitives/src/bytecode => bytecode/src}/eof/decode_helpers.rs (100%) rename crates/{primitives/src/bytecode => bytecode/src}/eof/header.rs (99%) rename crates/{primitives/src/bytecode => bytecode/src}/eof/types_section.rs (100%) create mode 100644 crates/bytecode/src/errors.rs rename crates/{primitives/src/bytecode => bytecode/src}/legacy.rs (98%) rename crates/{primitives/src/bytecode => bytecode/src}/legacy/jump_map.rs (97%) rename crates/{primitives/src/bytecode.rs => bytecode/src/lib.rs} (85%) create mode 100644 crates/database/interface/CHANGELOG.md create mode 100644 crates/database/interface/Cargo.toml create mode 100644 crates/database/interface/LICENSE rename crates/{primitives/src/db/emptydb.rs => database/interface/src/empty_db.rs} (95%) rename crates/{primitives/src/db.rs => database/interface/src/lib.rs} (88%) create mode 100644 crates/gas/CHANGELOG.md create mode 100644 crates/gas/Cargo.toml create mode 100644 crates/gas/LICENSE create mode 100644 crates/gas/src/lib.rs create mode 100644 crates/inspector/CHANGELOG.md create mode 100644 crates/inspector/Cargo.toml create mode 100644 crates/inspector/LICENSE create mode 100644 crates/inspector/src/lib.rs create mode 100644 crates/interface/CHANGELOG.md create mode 100644 crates/interface/Cargo.toml create mode 100644 crates/interface/LICENSE create mode 100644 crates/interface/src/lib.rs create mode 100644 crates/precompile/src/interface.rs delete mode 100644 crates/primitives/src/db/components.rs delete mode 100644 crates/primitives/src/db/components/block_hash.rs delete mode 100644 crates/primitives/src/db/components/state.rs delete mode 100644 crates/primitives/src/eip7702.rs delete mode 100644 crates/primitives/src/kzg.rs create mode 100644 crates/specification/CHANGELOG.md create mode 100644 crates/specification/Cargo.toml create mode 100644 crates/specification/LICENSE create mode 100644 crates/specification/src/eip170.rs create mode 100644 crates/specification/src/eip2.rs create mode 100644 crates/specification/src/eip2930.rs create mode 100644 crates/specification/src/eip7702.rs rename crates/{primitives => specification}/src/eip7702/authorization_list.rs (70%) create mode 100644 crates/specification/src/eip7702/constants.rs create mode 100644 crates/specification/src/eip7702/recovered_authorization.rs rename crates/{primitives/src/specification.rs => specification/src/hardfork.rs} (82%) create mode 100644 crates/specification/src/lib.rs create mode 100644 crates/state/CHANGELOG.md create mode 100644 crates/state/Cargo.toml create mode 100644 crates/state/LICENSE create mode 100644 crates/state/src/account_info.rs rename crates/{primitives/src/state.rs => state/src/lib.rs} (65%) create mode 100644 crates/state/src/types.rs create mode 100644 crates/wiring/CHANGELOG.md create mode 100644 crates/wiring/Cargo.toml create mode 100644 crates/wiring/LICENSE rename crates/{primitives => wiring}/src/block.rs (85%) rename crates/{primitives/src/utilities.rs => wiring/src/block/blob.rs} (85%) rename crates/{primitives/src/env.rs => wiring/src/default.rs} (84%) create mode 100644 crates/wiring/src/default/block.rs create mode 100644 crates/wiring/src/default/transaction.rs rename crates/{primitives => wiring}/src/evm_wiring.rs (73%) create mode 100644 crates/wiring/src/kzg.rs create mode 100644 crates/wiring/src/lib.rs rename crates/{primitives => wiring}/src/precompile.rs (99%) rename crates/{primitives => wiring}/src/result.rs (97%) rename crates/{primitives => wiring}/src/transaction.rs (77%) create mode 100644 examples/split_db_trait.rs diff --git a/.github/workflows/cachegrind.yml b/.github/workflows/cachegrind.yml index ad79a05a3e..25050ae047 100644 --- a/.github/workflows/cachegrind.yml +++ b/.github/workflows/cachegrind.yml @@ -23,8 +23,8 @@ jobs: - name: Run Valgrind run: | - cargo b -r -p revm-test --bin snailtracer - valgrind --tool=cachegrind target/release/snailtracer 2>&1 | tee cachegrind_results.txt + cargo b -r -p revme + valgrind --tool=cachegrind target/release/revme bench snailtracer 2>&1 | tee cachegrind_results.txt - name: Valgrind results id: valgrind_results diff --git a/Cargo.lock b/Cargo.lock index 8795fcc676..8ac74f9d91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,8 +87,6 @@ checksum = "0069cf0642457f87a01a014f6dc29d5d893cd4fd8fddf0c3cdfad1bb3ebafc41" dependencies = [ "alloy-primitives", "alloy-rlp", - "arbitrary", - "rand", "serde", ] @@ -100,9 +98,7 @@ checksum = "37d319bb544ca6caeab58c39cea8921c55d924d4f68f2c60f24f914673f9a74a" dependencies = [ "alloy-primitives", "alloy-rlp", - "arbitrary", "k256", - "rand", "serde", ] @@ -117,7 +113,6 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-serde", - "arbitrary", "c-kzg", "once_cell", "serde", @@ -126,9 +121,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9996daf962fd0a90d3c93b388033228865953b92de7bb1959b891d78750a4091" +checksum = "a28ecae8b5315daecd0075084eb47f4374b3037777346ca52fc8d9c327693f02" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -184,9 +179,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "411aff151f2a73124ee473708e82ed51b2535f68928b6a1caa8bc1246ae6f7cd" +checksum = "ccb865df835f851b367ae439d6c82b117ded971628c8888b24fed411a290e38a" dependencies = [ "alloy-rlp", "arbitrary", @@ -210,9 +205,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d2a195caa6707f5ce13905794865765afc6d9ea92c3a56e3a973c168d703bc" +checksum = "1376948df782ffee83a54cac4b2aba14134edd997229a3db97da0a606586eb5c" dependencies = [ "alloy-chains", "alloy-consensus", @@ -233,7 +228,7 @@ dependencies = [ "futures-utils-wasm", "lru", "pin-project", - "reqwest 0.12.7", + "reqwest", "serde", "serde_json", "thiserror", @@ -275,12 +270,12 @@ dependencies = [ "alloy-transport-http", "futures", "pin-project", - "reqwest 0.12.7", + "reqwest", "serde", "serde_json", "tokio", "tokio-stream", - "tower 0.4.13", + "tower", "tracing", "url", ] @@ -311,7 +306,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfd260ede54f0b53761fdd04133acc10ae70427f66a69aa9590529bbd066cd58" dependencies = [ "alloy-primitives", - "arbitrary", "serde", "serde_json", ] @@ -332,9 +326,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0458ccb02a564228fcd76efb8eb5a520521a8347becde37b402afec9a1b83859" +checksum = "e2dc5201ca0018afb7a3e0cd8bd15f7ca6aca924333b5f3bb87463b41d0c4ef2" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -346,9 +340,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc65475025fc1e84bf86fc840f04f63fcccdcf3cf12053c99918e4054dfbc69" +checksum = "155f63dc6945885aa4532601800201fddfaa3b20901fda8e8c2570327242fe0e" dependencies = [ "alloy-sol-macro-input", "const-hex", @@ -364,9 +358,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed10f0715a0b69fde3236ff3b9ae5f6f7c97db5a387747100070d3016b9266b" +checksum = "847700aa9cb59d3c7b290b2d05976cd8d76b64d73bb63116a9533132d995586b" dependencies = [ "const-hex", "dunce", @@ -379,9 +373,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3edae8ea1de519ccba896b6834dec874230f72fe695ff3c9c118e90ec7cff783" +checksum = "3a6b5d462d4520bd9ed70d8364c6280aeff13baa46ea26be1ddd33538dbbe6ac" dependencies = [ "serde", "winnow 0.6.18", @@ -389,9 +383,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1eb88e4da0a1b697ed6a9f811fdba223cf4d5c21410804fd1707836af73a462b" +checksum = "83665e5607725a7a1aab3cb0dea708f4a05e70776954ec7f0a9461439175c957" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -402,19 +396,19 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.3.5" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7a669caa427abe8802184c8776f5103302f9337bb30a5b36bdebc332946c14" +checksum = "454220c714857cf68af87d788d1f0638ad8766268b94f6a49fed96cbc2ab382c" dependencies = [ "alloy-json-rpc", - "base64 0.22.1", + "base64", "futures-util", "futures-utils-wasm", "serde", "serde_json", "thiserror", "tokio", - "tower 0.5.1", + "tower", "tracing", "url", ] @@ -427,9 +421,9 @@ checksum = "377f2353d7fea03a2dba6b9ffbb7d610402c040dd5700d1fae8b9ec2673eed9b" dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.12.7", + "reqwest", "serde_json", - "tower 0.4.13", + "tower", "tracing", "url", ] @@ -476,7 +470,7 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -486,7 +480,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -500,9 +494,6 @@ name = "arbitrary" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" -dependencies = [ - "derive_arbitrary", -] [[package]] name = "ark-ff" @@ -667,17 +658,6 @@ dependencies = [ "syn 2.0.70", ] -[[package]] -name = "async_io_stream" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" -dependencies = [ - "futures", - "pharos", - "rustc_version 0.4.0", -] - [[package]] name = "atomic-waker" version = "1.1.2" @@ -732,18 +712,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "base64" version = "0.22.1" @@ -780,19 +748,12 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" dependencies = [ - "arbitrary", "serde", ] @@ -982,7 +943,7 @@ dependencies = [ "lazy_static", "libc", "unicode-width", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -1132,12 +1093,6 @@ dependencies = [ "parking_lot_core", ] -[[package]] -name = "data-encoding" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" - [[package]] name = "der" version = "0.7.9" @@ -1148,15 +1103,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "deranged" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" -dependencies = [ - "powerfmt", -] - [[package]] name = "derivative" version = "2.2.0" @@ -1309,24 +1255,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "enr" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a3d8dc56e02f954cac8eb489772c552c473346fc34f67412bb6244fd647f7e4" -dependencies = [ - "base64 0.21.7", - "bytes", - "hex", - "k256", - "log", - "rand", - "rlp", - "serde", - "sha3", - "zeroize", -] - [[package]] name = "enumn" version = "0.1.14" @@ -1351,7 +1279,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -1445,44 +1373,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "ethers-providers" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6434c9a33891f1effc9c75472e12666db2fa5a0fec4b29af6221680a6fe83ab2" -dependencies = [ - "async-trait", - "auto_impl", - "base64 0.21.7", - "bytes", - "const-hex", - "enr", - "ethers-core", - "futures-channel", - "futures-core", - "futures-timer", - "futures-util", - "hashers", - "http 0.2.12", - "instant", - "jsonwebtoken", - "once_cell", - "pin-project", - "reqwest 0.11.27", - "serde", - "serde_json", - "thiserror", - "tokio", - "tokio-tungstenite", - "tracing", - "tracing-futures", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "ws_stream_wasm", -] - [[package]] name = "eyre" version = "0.6.12" @@ -1662,10 +1552,6 @@ name = "futures-timer" version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" -dependencies = [ - "gloo-timers", - "send_wrapper 0.4.0", -] [[package]] name = "futures-util" @@ -1691,15 +1577,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -1734,18 +1611,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "gloo-timers" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] - [[package]] name = "group" version = "0.13.0" @@ -1757,25 +1622,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "h2" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 0.2.12", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "h2" version = "0.4.5" @@ -1787,7 +1633,7 @@ dependencies = [ "fnv", "futures-core", "futures-sink", - "http 1.1.0", + "http", "indexmap", "slab", "tokio", @@ -1822,15 +1668,6 @@ dependencies = [ "serde", ] -[[package]] -name = "hashers" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2bca93b15ea5a746f220e56587f71e73c6165eab783df9e26590069953e3c30" -dependencies = [ - "fxhash", -] - [[package]] name = "heck" version = "0.5.0" @@ -1867,17 +1704,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "http" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - [[package]] name = "http" version = "1.1.0" @@ -1889,17 +1715,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http 0.2.12", - "pin-project-lite", -] - [[package]] name = "http-body" version = "1.0.0" @@ -1907,7 +1722,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" dependencies = [ "bytes", - "http 1.1.0", + "http", ] [[package]] @@ -1918,8 +1733,8 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.1.0", - "http-body 1.0.0", + "http", + "http-body", "pin-project-lite", ] @@ -1929,36 +1744,6 @@ version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - -[[package]] -name = "hyper" -version = "0.14.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - [[package]] name = "hyper" version = "1.4.1" @@ -1968,9 +1753,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.5", - "http 1.1.0", - "http-body 1.0.0", + "h2", + "http", + "http-body", "httparse", "itoa", "pin-project-lite", @@ -1979,20 +1764,6 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-rustls" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" -dependencies = [ - "futures-util", - "http 0.2.12", - "hyper 0.14.30", - "rustls 0.21.12", - "tokio", - "tokio-rustls 0.24.1", -] - [[package]] name = "hyper-rustls" version = "0.27.2" @@ -2000,13 +1771,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", - "http 1.1.0", - "hyper 1.4.1", + "http", + "hyper", "hyper-util", - "rustls 0.23.11", + "rustls", "rustls-pki-types", "tokio", - "tokio-rustls 0.26.0", + "tokio-rustls", "tower-service", ] @@ -2018,7 +1789,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.4.1", + "hyper", "hyper-util", "native-tls", "tokio", @@ -2035,13 +1806,13 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.1.0", - "http-body 1.0.0", - "hyper 1.4.1", + "http", + "http-body", + "hyper", "pin-project-lite", "socket2", "tokio", - "tower 0.4.13", + "tower", "tower-service", "tracing", ] @@ -2146,7 +1917,7 @@ checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -2188,20 +1959,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "jsonwebtoken" -version = "8.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" -dependencies = [ - "base64 0.21.7", - "pem", - "ring 0.16.20", - "serde", - "serde_json", - "simple_asn1", -] - [[package]] name = "k256" version = "0.13.3" @@ -2245,7 +2002,7 @@ dependencies = [ "hex", "sha2", "sp1_bls12_381", - "spin 0.9.8", + "spin", ] [[package]] @@ -2254,7 +2011,7 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ - "spin 0.9.8", + "spin", ] [[package]] @@ -2336,7 +2093,7 @@ dependencies = [ "hermit-abi", "libc", "wasi", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -2400,12 +2157,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-conv" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" - [[package]] name = "num-integer" version = "0.1.46" @@ -2495,9 +2246,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" @@ -2536,7 +2287,7 @@ version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.6.0", + "bitflags", "cfg-if", "foreign-types", "libc", @@ -2631,7 +2382,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -2640,15 +2391,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - [[package]] name = "percent-encoding" version = "2.3.1" @@ -2666,16 +2408,6 @@ dependencies = [ "ucd-trie", ] -[[package]] -name = "pharos" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" -dependencies = [ - "futures", - "rustc_version 0.4.0", -] - [[package]] name = "phf" version = "0.11.2" @@ -2809,12 +2541,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2892,7 +2618,7 @@ checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.6.0", + "bitflags", "lazy_static", "num-traits", "rand", @@ -3001,7 +2727,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ - "bitflags 2.6.0", + "bitflags", ] [[package]] @@ -3039,64 +2765,23 @@ version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" -[[package]] -name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.30", - "hyper-rustls 0.24.2", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls 0.21.12", - "rustls-pemfile 1.0.4", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 0.1.2", - "system-configuration 0.5.1", - "tokio", - "tokio-rustls 0.24.1", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots", - "winreg", -] - [[package]] name = "reqwest" version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ - "base64 0.22.1", + "base64", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2 0.4.5", - "http 1.1.0", - "http-body 1.0.0", + "h2", + "http", + "http-body", "http-body-util", - "hyper 1.4.1", - "hyper-rustls 0.27.2", + "hyper", + "hyper-rustls", "hyper-tls", "hyper-util", "ipnet", @@ -3107,12 +2792,12 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile 2.1.2", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.1", - "system-configuration 0.6.1", + "sync_wrapper", + "system-configuration", "tokio", "tokio-native-tls", "tower-service", @@ -3137,18 +2822,46 @@ dependencies = [ "derive-where", "dyn-clone", "ethers-contract", - "ethers-core", - "ethers-providers", "indicatif", - "reqwest 0.12.7", + "reqwest", + "revm-bytecode", + "revm-database-interface", "revm-interpreter", "revm-precompile", + "revm-primitives", + "revm-specification", + "revm-state", + "revm-wiring", "rstest", "serde", "serde_json", "tokio", ] +[[package]] +name = "revm-bytecode" +version = "1.0.0" +dependencies = [ + "bitvec", + "revm-primitives", + "serde", +] + +[[package]] +name = "revm-database-interface" +version = "1.0.0" +dependencies = [ + "alloy-sol-types", + "anyhow", + "auto_impl", + "criterion", + "indicatif", + "revm-primitives", + "revm-state", + "rstest", + "serde", +] + [[package]] name = "revm-interpreter" version = "10.0.1" @@ -3157,7 +2870,11 @@ dependencies = [ "derive-where", "paste", "phf", + "revm-bytecode", + "revm-database-interface", "revm-primitives", + "revm-specification", + "revm-wiring", "serde", "serde_json", "walkdir", @@ -3187,6 +2904,7 @@ dependencies = [ "c-kzg", "cfg-if", "criterion", + "dyn-clone", "eyre", "k256", "kzg-rs", @@ -3194,6 +2912,8 @@ dependencies = [ "p256", "rand", "revm-primitives", + "revm-specification", + "revm-wiring", "ripemd", "rstest", "secp256k1", @@ -3208,33 +2928,48 @@ dependencies = [ name = "revm-primitives" version = "9.0.1" dependencies = [ - "alloy-eips", "alloy-primitives", - "auto_impl", - "bitflags 2.6.0", - "bitvec", - "c-kzg", "cfg-if", - "dyn-clone", - "enumn", "hashbrown", "hex", - "kzg-rs", +] + +[[package]] +name = "revm-specification" +version = "1.0.0" +dependencies = [ + "alloy-eips", + "alloy-primitives", + "enumn", + "revm-primitives", "serde", ] [[package]] -name = "revm-test" -version = "0.1.0" +name = "revm-state" +version = "1.0.0" dependencies = [ - "alloy-sol-macro", - "alloy-sol-types", - "bytes", - "eyre", - "hex", - "microbench", - "regex", - "revm", + "bitflags", + "revm-bytecode", + "revm-primitives", + "revm-specification", + "serde", +] + +[[package]] +name = "revm-wiring" +version = "1.0.0" +dependencies = [ + "c-kzg", + "cfg-if", + "dyn-clone", + "kzg-rs", + "once_cell", + "revm-database-interface", + "revm-primitives", + "revm-specification", + "revm-state", + "serde", ] [[package]] @@ -3242,6 +2977,8 @@ name = "revme" version = "0.10.1" dependencies = [ "alloy-rlp", + "alloy-sol-macro", + "alloy-sol-types", "clap", "hash-db", "hashbrown", @@ -3268,21 +3005,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", -] - [[package]] name = "ring" version = "0.17.8" @@ -3293,9 +3015,9 @@ dependencies = [ "cfg-if", "getrandom", "libc", - "spin 0.9.8", - "untrusted 0.9.0", - "windows-sys 0.52.0", + "spin", + "untrusted", + "windows-sys", ] [[package]] @@ -3426,23 +3148,11 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.6.0", + "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", -] - -[[package]] -name = "rustls" -version = "0.21.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" -dependencies = [ - "log", - "ring 0.17.8", - "rustls-webpki 0.101.7", - "sct", + "windows-sys", ] [[package]] @@ -3453,27 +3163,18 @@ checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" dependencies = [ "once_cell", "rustls-pki-types", - "rustls-webpki 0.102.5", + "rustls-webpki", "subtle", "zeroize", ] -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - [[package]] name = "rustls-pemfile" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.22.1", + "base64", "rustls-pki-types", ] @@ -3483,25 +3184,15 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" -[[package]] -name = "rustls-webpki" -version = "0.101.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" -dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", -] - [[package]] name = "rustls-webpki" version = "0.102.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" dependencies = [ - "ring 0.17.8", + "ring", "rustls-pki-types", - "untrusted 0.9.0", + "untrusted", ] [[package]] @@ -3567,7 +3258,7 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -3576,16 +3267,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", -] - [[package]] name = "sec1" version = "0.7.3" @@ -3625,7 +3306,7 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 2.6.0", + "bitflags", "core-foundation", "core-foundation-sys", "libc", @@ -3666,18 +3347,6 @@ dependencies = [ "pest", ] -[[package]] -name = "send_wrapper" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" - -[[package]] -name = "send_wrapper" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" - [[package]] name = "serde" version = "1.0.209" @@ -3723,17 +3392,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - [[package]] name = "sha2" version = "0.10.8" @@ -3775,18 +3433,6 @@ dependencies = [ "rand_core", ] -[[package]] -name = "simple_asn1" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" -dependencies = [ - "num-bigint 0.4.6", - "num-traits", - "thiserror", - "time", -] - [[package]] name = "siphasher" version = "0.3.11" @@ -3825,7 +3471,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -3857,12 +3503,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -3956,9 +3596,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b95156f8b577cb59dc0b1df15c6f29a10afc5f8a7ac9786b0b5c68c19149278" +checksum = "f1e1355d44af21638c8e05d45097db6cb5ec2aa3e970c51cb2901605cf3344fa" dependencies = [ "paste", "proc-macro2", @@ -3966,12 +3606,6 @@ dependencies = [ "syn 2.0.70", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - [[package]] name = "sync_wrapper" version = "1.0.1" @@ -3981,36 +3615,15 @@ dependencies = [ "futures-core", ] -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys 0.5.0", -] - [[package]] name = "system-configuration" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 2.6.0", + "bitflags", "core-foundation", - "system-configuration-sys 0.6.0", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", + "system-configuration-sys", ] [[package]] @@ -4038,7 +3651,7 @@ dependencies = [ "cfg-if", "fastrand", "rustix", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -4070,37 +3683,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "time" -version = "0.3.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" -dependencies = [ - "deranged", - "itoa", - "num-conv", - "powerfmt", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" - -[[package]] -name = "time-macros" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" -dependencies = [ - "num-conv", - "time-core", -] - [[package]] name = "tiny-keccak" version = "2.0.2" @@ -4148,7 +3730,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -4172,23 +3754,13 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls 0.21.12", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.11", + "rustls", "rustls-pki-types", "tokio", ] @@ -4205,21 +3777,6 @@ dependencies = [ "tokio-util", ] -[[package]] -name = "tokio-tungstenite" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" -dependencies = [ - "futures-util", - "log", - "rustls 0.21.12", - "tokio", - "tokio-rustls 0.24.1", - "tungstenite", - "webpki-roots", -] - [[package]] name = "tokio-util" version = "0.7.11" @@ -4266,31 +3823,17 @@ dependencies = [ "tracing", ] -[[package]] -name = "tower" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" -dependencies = [ - "futures-core", - "futures-util", - "pin-project-lite", - "sync_wrapper 0.1.2", - "tower-layer", - "tower-service", -] - [[package]] name = "tower-layer" -version = "0.3.3" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" [[package]] name = "tower-service" -version = "0.3.3" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" @@ -4324,16 +3867,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project", - "tracing", -] - [[package]] name = "triehash" version = "0.8.4" @@ -4350,26 +3883,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "tungstenite" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 0.2.12", - "httparse", - "log", - "rand", - "rustls 0.21.12", - "sha1", - "thiserror", - "url", - "utf-8", -] - [[package]] name = "typenum" version = "1.17.0" @@ -4433,12 +3946,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - [[package]] name = "untrusted" version = "0.9.0" @@ -4456,12 +3963,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "utf-8" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" - [[package]] name = "utf8parse" version = "0.2.2" @@ -4596,43 +4097,15 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki-roots" -version = "0.25.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "windows-sys 0.52.0", + "windows-sys", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-registry" version = "0.2.0" @@ -4641,7 +4114,7 @@ checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ "windows-result", "windows-strings", - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -4650,7 +4123,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -4660,16 +4133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" dependencies = [ "windows-result", - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", + "windows-targets", ] [[package]] @@ -4678,22 +4142,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] @@ -4702,46 +4151,28 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -4754,48 +4185,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -4820,35 +4227,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - -[[package]] -name = "ws_stream_wasm" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" -dependencies = [ - "async_io_stream", - "futures", - "js-sys", - "log", - "pharos", - "rustc_version 0.4.0", - "send_wrapper 0.6.0", - "thiserror", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 12d19a5568..2d48060191 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,33 @@ [workspace] members = [ "bins/revme", - "bins/revm-test", "crates/revm", "crates/primitives", "crates/interpreter", "crates/precompile", "crates/optimism", + "crates/database/interface", + "crates/bytecode", + "crates/state", + "crates/wiring", + "crates/specification", ] resolver = "2" default-members = ["crates/revm"] +[workspace.dependencies] +# revm +primitives = { path = "crates/primitives", package = "revm-primitives", version = "9.0.1", default-features = false } +bytecode = { path = "crates/bytecode", package = "revm-bytecode", version = "1.0.0", default-features = false } +database-interface = { path = "crates/database/interface", package = "revm-database-interface", version = "1.0.0", default-features = false } +specification = { path = "crates/specification", package = "revm-specification", version = "1.0.0", default-features = false } +state = { path = "crates/state", package = "revm-state", version = "1.0.0", default-features = false } +wiring = { path = "crates/wiring", package = "revm-wiring", version = "1.0.0", default-features = false } +revm = { path = "crates/revm", version = "14.0.1", default-features = false } +interpreter = { path = "crates/interpreter", package = "revm-interpreter", version = "10.0.1", default-features = false } +precompile = { path = "crates/precompile", package = "revm-precompile", version = "11.0.1", default-features = false } +# misc + [workspace.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] diff --git a/bins/revm-test/CHANGELOG.md b/bins/revm-test/CHANGELOG.md deleted file mode 100644 index 19d50a211f..0000000000 --- a/bins/revm-test/CHANGELOG.md +++ /dev/null @@ -1,647 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [Unreleased] - -## [0.1.0](https://github.com/bluealloy/revm/releases/tag/revm-test-v0.1.0) - 2024-08-30 - -### 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 -- release ([#1722](https://github.com/bluealloy/revm/pull/1722)) -- *(deps)* bump alloy and primitives ([#1725](https://github.com/bluealloy/revm/pull/1725)) -- *(deps)* bump bytes from 1.6.1 to 1.7.1 ([#1700](https://github.com/bluealloy/revm/pull/1700)) -- tag v41 revm v13.0.0 ([#1692](https://github.com/bluealloy/revm/pull/1692)) -- release ([#1683](https://github.com/bluealloy/revm/pull/1683)) -- *(deps)* bump regex from 1.10.5 to 1.10.6 ([#1682](https://github.com/bluealloy/revm/pull/1682)) -- bump versions bcs of primitives ([#1631](https://github.com/bluealloy/revm/pull/1631)) -- release ([#1620](https://github.com/bluealloy/revm/pull/1620)) -- *(deps)* bump alloy-sol-types from 0.7.6 to 0.7.7 ([#1614](https://github.com/bluealloy/revm/pull/1614)) -- *(deps)* bump alloy-sol-macro from 0.7.6 to 0.7.7 ([#1613](https://github.com/bluealloy/revm/pull/1613)) -- release ([#1579](https://github.com/bluealloy/revm/pull/1579)) -- release ([#1548](https://github.com/bluealloy/revm/pull/1548)) -- 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-08-29 - -### 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 -- *(deps)* bump alloy and primitives ([#1725](https://github.com/bluealloy/revm/pull/1725)) -- *(deps)* bump bytes from 1.6.1 to 1.7.1 ([#1700](https://github.com/bluealloy/revm/pull/1700)) -- tag v41 revm v13.0.0 ([#1692](https://github.com/bluealloy/revm/pull/1692)) -- release ([#1683](https://github.com/bluealloy/revm/pull/1683)) -- *(deps)* bump regex from 1.10.5 to 1.10.6 ([#1682](https://github.com/bluealloy/revm/pull/1682)) -- bump versions bcs of primitives ([#1631](https://github.com/bluealloy/revm/pull/1631)) -- release ([#1620](https://github.com/bluealloy/revm/pull/1620)) -- *(deps)* bump alloy-sol-types from 0.7.6 to 0.7.7 ([#1614](https://github.com/bluealloy/revm/pull/1614)) -- *(deps)* bump alloy-sol-macro from 0.7.6 to 0.7.7 ([#1613](https://github.com/bluealloy/revm/pull/1613)) -- release ([#1579](https://github.com/bluealloy/revm/pull/1579)) -- release ([#1548](https://github.com/bluealloy/revm/pull/1548)) -- 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-08-08 - -### 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 -- *(deps)* bump regex from 1.10.5 to 1.10.6 ([#1682](https://github.com/bluealloy/revm/pull/1682)) -- bump versions bcs of primitives ([#1631](https://github.com/bluealloy/revm/pull/1631)) -- release ([#1620](https://github.com/bluealloy/revm/pull/1620)) -- *(deps)* bump alloy-sol-types from 0.7.6 to 0.7.7 ([#1614](https://github.com/bluealloy/revm/pull/1614)) -- *(deps)* bump alloy-sol-macro from 0.7.6 to 0.7.7 ([#1613](https://github.com/bluealloy/revm/pull/1613)) -- release ([#1579](https://github.com/bluealloy/revm/pull/1579)) -- release ([#1548](https://github.com/bluealloy/revm/pull/1548)) -- 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-07-16 - -### 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 -- *(deps)* bump alloy-sol-types from 0.7.6 to 0.7.7 ([#1614](https://github.com/bluealloy/revm/pull/1614)) -- *(deps)* bump alloy-sol-macro from 0.7.6 to 0.7.7 ([#1613](https://github.com/bluealloy/revm/pull/1613)) -- release ([#1579](https://github.com/bluealloy/revm/pull/1579)) -- release ([#1548](https://github.com/bluealloy/revm/pull/1548)) -- 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-07-08 - -### 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 -- release ([#1548](https://github.com/bluealloy/revm/pull/1548)) -- 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-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 -- 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 -- *(clippy)* fix some clippy lints - -### Other -- *(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 diff --git a/bins/revm-test/Cargo.toml b/bins/revm-test/Cargo.toml deleted file mode 100644 index 6688fe905c..0000000000 --- a/bins/revm-test/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "revm-test" -version = "0.1.0" -edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -bytes = "1.7" -hex = "0.4" -revm = { path = "../../crates/revm", version = "14.0.1", default-features=false } -microbench = "0.5" -alloy-sol-macro = "0.8.0" -alloy-sol-types = "0.8.2" -regex = "1.10.6" -eyre = "0.6.12" - - -[[bin]] -name = "analysis" - -[[bin]] -name = "snailtracer" - -[[bin]] -name = "transfer" - -[[bin]] -name = "burntpix" diff --git a/bins/revme/Cargo.toml b/bins/revme/Cargo.toml index b8f02f90d2..14e510bbbc 100644 --- a/bins/revme/Cargo.toml +++ b/bins/revme/Cargo.toml @@ -9,23 +9,28 @@ description = "Rust Ethereum Virtual Machine Executable" version = "0.10.1" [dependencies] +# revm +revm = { workspace = true, features = [ + "std", + "serde-json", + "hashbrown", + "c-kzg", + "blst", +] } + hash-db = "0.15" hex = "0.4" hashbrown = "0.14" indicatif = "0.17" microbench = "0.5" plain_hasher = "0.2" -revm = { path = "../../crates/revm", version = "14.0.1", default-features = false, features = [ - "ethersdb", - "std", - "serde-json", - "c-kzg", - "blst", -] } + alloy-rlp = { version = "0.3", default-features = false, features = [ "arrayvec", "derive", ] } +alloy-sol-macro = "0.8.0" +alloy-sol-types = "0.8.2" serde = { version = "1.0", features = ["derive", "rc"] } serde_json = { version = "1.0", features = ["preserve_order"] } clap = { version = "4", features = ["derive"] } diff --git a/bins/revme/src/cmd.rs b/bins/revme/src/cmd.rs index a36a637a6e..2a7e13ba36 100644 --- a/bins/revme/src/cmd.rs +++ b/bins/revme/src/cmd.rs @@ -1,3 +1,4 @@ +pub mod bench; pub mod bytecode; pub mod eofvalidation; pub mod evmrunner; @@ -17,6 +18,8 @@ pub enum MainCmd { Evm(evmrunner::Cmd), /// Print the structure of an EVM bytecode. Bytecode(bytecode::Cmd), + /// Run bench from specified list. + Bench(bench::Cmd), } #[derive(Debug, thiserror::Error)] @@ -44,6 +47,10 @@ impl MainCmd { cmd.run(); Ok(()) } + Self::Bench(cmd) => { + cmd.run(); + Ok(()) + } } } } diff --git a/bins/revme/src/cmd/bench.rs b/bins/revme/src/cmd/bench.rs new file mode 100644 index 0000000000..d0ac5bc393 --- /dev/null +++ b/bins/revme/src/cmd/bench.rs @@ -0,0 +1,33 @@ +pub mod analysis; +pub mod burntpix; +pub mod snailtracer; +pub mod transfer; + +use clap::{Parser, ValueEnum}; + +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] +pub enum BenchName { + Analysis, + Burntpix, + Snailtracer, + Transfer, +} + +/// `bytecode` subcommand. +#[derive(Parser, Debug)] +pub struct Cmd { + #[arg(value_enum)] + name: BenchName, +} + +impl Cmd { + /// Run bench command. + pub fn run(&self) { + match self.name { + BenchName::Analysis => analysis::run(), + BenchName::Burntpix => burntpix::run(), + BenchName::Snailtracer => snailtracer::run(), + BenchName::Transfer => transfer::run(), + } + } +} diff --git a/bins/revm-test/src/bin/analysis.rs b/bins/revme/src/cmd/bench/analysis.rs similarity index 98% rename from bins/revm-test/src/bin/analysis.rs rename to bins/revme/src/cmd/bench/analysis.rs index c71e50c863..472fabd1b5 100644 --- a/bins/revm-test/src/bin/analysis.rs +++ b/bins/revme/src/cmd/bench/analysis.rs @@ -1,12 +1,13 @@ use revm::{ + bytecode::Bytecode, db::{BenchmarkDB, EthereumBenchmarkWiring}, interpreter::analysis::to_analysed, - primitives::{address, bytes, Bytecode, Bytes, TxKind}, + primitives::{address, bytes, Bytes, TxKind}, Evm, }; use std::time::Instant; -fn main() { +pub fn run() { let contract_data : Bytes = hex::decode( "6060604052341561000f57600080fd5b604051610dd1380380610dd18339810160405280805190602001909190805182019190602001805190602001909190805182019190505083600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508360008190555082600390805190602001906100a79291906100e3565b5081600460006101000a81548160ff021916908360ff16021790555080600590805190602001906100d99291906100e3565b5050505050610188565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061012457805160ff1916838001178555610152565b82800160010185558215610152579182015b82811115610151578251825591602001919060010190610136565b5b50905061015f9190610163565b5090565b61018591905b80821115610181576000816000905550600101610169565b5090565b90565b610c3a806101976000396000f3006060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b4578063095ea7b31461014257806318160ddd1461019c57806323b872dd146101c557806327e235e31461023e578063313ce5671461028b5780635c658165146102ba57806370a082311461032657806395d89b4114610373578063a9059cbb14610401578063dd62ed3e1461045b575b600080fd5b34156100bf57600080fd5b6100c76104c7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101075780820151818401526020810190506100ec565b50505050905090810190601f1680156101345780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014d57600080fd5b610182600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610565565b604051808215151515815260200191505060405180910390f35b34156101a757600080fd5b6101af610657565b6040518082815260200191505060405180910390f35b34156101d057600080fd5b610224600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061065d565b604051808215151515815260200191505060405180910390f35b341561024957600080fd5b610275600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108f7565b6040518082815260200191505060405180910390f35b341561029657600080fd5b61029e61090f565b604051808260ff1660ff16815260200191505060405180910390f35b34156102c557600080fd5b610310600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610922565b6040518082815260200191505060405180910390f35b341561033157600080fd5b61035d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610947565b6040518082815260200191505060405180910390f35b341561037e57600080fd5b610386610990565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103c65780820151818401526020810190506103ab565b50505050905090810190601f1680156103f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561040c57600080fd5b610441600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610a2e565b604051808215151515815260200191505060405180910390f35b341561046657600080fd5b6104b1600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610b87565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561055d5780601f106105325761010080835404028352916020019161055d565b820191906000526020600020905b81548152906001019060200180831161054057829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b600080600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015801561072e5750828110155b151561073957600080fd5b82600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555082600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110156108865782600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b60016020528060005260406000206000915090505481565b600460009054906101000a900460ff1681565b6002602052816000526040600020602052806000526040600020600091509150505481565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a265780601f106109fb57610100808354040283529160200191610a26565b820191906000526020600020905b815481529060010190602001808311610a0957829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610a7e57600080fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820df254047bc8f2904ad3e966b6db116d703bebd40efadadb5e738c836ffc8f58a0029").unwrap().into(); let bytecode_raw = Bytecode::new_raw(contract_data.clone()); @@ -22,6 +23,7 @@ fn main() { tx.data = bytes!("8035F0CE"); }) .with_db(BenchmarkDB::new_bytecode(bytecode_raw)) + .with_default_ext_ctx() .build(); // Just to warm up the processor. @@ -38,6 +40,7 @@ fn main() { let mut evm = evm .modify() .with_db(BenchmarkDB::new_bytecode(bytecode_analysed)) + .with_default_ext_ctx() .build(); let timer = Instant::now(); diff --git a/bins/revm-test/src/bin/burntpix/main.rs b/bins/revme/src/cmd/bench/burntpix.rs similarity index 87% rename from bins/revm-test/src/bin/burntpix/main.rs rename to bins/revme/src/cmd/bench/burntpix.rs index 581f611204..663987f700 100644 --- a/bins/revm-test/src/bin/burntpix/main.rs +++ b/bins/revme/src/cmd/bench/burntpix.rs @@ -1,25 +1,29 @@ +pub mod static_data; + +use static_data::{ + BURNTPIX_ADDRESS_ONE, BURNTPIX_ADDRESS_THREE, BURNTPIX_ADDRESS_TWO, BURNTPIX_BYTECODE_FOUR, + BURNTPIX_BYTECODE_ONE, BURNTPIX_BYTECODE_THREE, BURNTPIX_BYTECODE_TWO, BURNTPIX_MAIN_ADDRESS, + STORAGE_ONE, STORAGE_TWO, STORAGE_ZERO, +}; + use alloy_sol_macro::sol; use alloy_sol_types::SolCall; -use regex::bytes::Regex; use revm::{ - db::{CacheDB, EmptyDB}, - primitives::{ - address, hex, keccak256, AccountInfo, Address, Bytecode, Bytes, EthereumWiring, - ExecutionResult, Output, TxKind, B256, U256, + database_interface::EmptyDB, + db::CacheDB, + primitives::{address, hex, keccak256, Address, Bytes, TxKind, B256, U256}, + state::{AccountInfo, Bytecode}, + wiring::{ + result::{ExecutionResult, Output}, + EthereumWiring, }, Evm, }; -use static_data::{ - BURNTPIX_ADDRESS_ONE, BURNTPIX_ADDRESS_THREE, BURNTPIX_ADDRESS_TWO, BURNTPIX_BYTECODE_FOUR, - BURNTPIX_BYTECODE_ONE, BURNTPIX_BYTECODE_THREE, BURNTPIX_BYTECODE_TWO, BURNTPIX_MAIN_ADDRESS, - STORAGE_ONE, STORAGE_TWO, STORAGE_ZERO, -}; use std::fs::File; use std::{error::Error, time::Instant}; use std::{io::Write, str::FromStr}; -pub mod static_data; sol! { #[derive(Debug, PartialEq, Eq)] @@ -30,7 +34,7 @@ sol! { type EthereumCacheDbWiring = EthereumWiring, ()>; -fn main() { +pub fn run() { let (seed, iterations) = try_init_env_vars().expect("Failed to parse env vars"); let run_call_data = IBURNTPIX::runCall { seed, iterations }.abi_encode(); @@ -44,6 +48,7 @@ fn main() { tx.data = run_call_data.clone().into(); }) .with_db(db) + .with_default_ext_ctx() .build(); let started = Instant::now(); @@ -67,11 +72,12 @@ fn main() { let data = &return_data[returndata_offset..]; // remove trailing zeros - let re = Regex::new(r"[0\x00]+$").unwrap(); - let trimmed_data = re.replace_all(data, &[]); + let trimmed_data = data + .split_at(data.len() - data.iter().rev().filter(|&x| *x == 0).count()) + .0; let file_name = format!("{}_{}", seed, iterations); - svg(file_name, &trimmed_data).expect("Failed to store svg"); + svg(file_name, trimmed_data).expect("Failed to store svg"); } fn svg(filename: String, svg_data: &[u8]) -> Result<(), Box> { @@ -96,9 +102,9 @@ fn try_init_env_vars() -> Result<(u32, U256), Box> { Ok((seed, iterations)) } -fn try_from_hex_to_u32(hex: &str) -> eyre::Result { +fn try_from_hex_to_u32(hex: &str) -> Result> { let trimmed = hex.strip_prefix("0x").unwrap_or(hex); - u32::from_str_radix(trimmed, 16).map_err(|e| eyre::eyre!("Failed to parse hex: {}", e)) + u32::from_str_radix(trimmed, 16).map_err(|e| format!("Failed to parse hex: {}", e).into()) } fn insert_account_info(cache_db: &mut CacheDB, addr: Address, code: Bytes) { diff --git a/bins/revm-test/src/bin/burntpix/static_data.rs b/bins/revme/src/cmd/bench/burntpix/static_data.rs similarity index 100% rename from bins/revm-test/src/bin/burntpix/static_data.rs rename to bins/revme/src/cmd/bench/burntpix/static_data.rs diff --git a/bins/revm-test/src/bin/snailtracer.rs b/bins/revme/src/cmd/bench/snailtracer.rs similarity index 99% rename from bins/revm-test/src/bin/snailtracer.rs rename to bins/revme/src/cmd/bench/snailtracer.rs index 3a874a44e0..989bdc15d2 100644 --- a/bins/revm-test/src/bin/snailtracer.rs +++ b/bins/revme/src/cmd/bench/snailtracer.rs @@ -1,7 +1,8 @@ use revm::{ + bytecode::Bytecode, db::{BenchmarkDB, EthereumBenchmarkWiring}, interpreter::analysis::to_analysed, - primitives::{address, bytes, Bytecode, Bytes, TxKind}, + primitives::{address, bytes, Bytes, TxKind}, Evm, }; @@ -11,6 +12,7 @@ pub fn simple_example() { // BenchmarkDB is dummy state that implements Database trait. let mut evm = Evm::::builder() .with_db(BenchmarkDB::new_bytecode(bytecode.clone())) + .with_default_ext_ctx() .modify_tx_env(|tx| { // execution globals block hash/gas_limit/coinbase/timestamp.. tx.caller = address!("1000000000000000000000000000000000000000"); @@ -22,7 +24,7 @@ pub fn simple_example() { let _ = evm.transact().unwrap(); } -fn main() { +pub fn run() { println!("Running snailtracer example!"); let start = std::time::Instant::now(); simple_example(); diff --git a/bins/revm-test/src/bin/transfer.rs b/bins/revme/src/cmd/bench/transfer.rs similarity index 90% rename from bins/revm-test/src/bin/transfer.rs rename to bins/revme/src/cmd/bench/transfer.rs index b0845fa34f..03ac702f8a 100644 --- a/bins/revm-test/src/bin/transfer.rs +++ b/bins/revme/src/cmd/bench/transfer.rs @@ -1,14 +1,16 @@ use revm::{ + bytecode::Bytecode, db::{BenchmarkDB, EthereumBenchmarkWiring}, - primitives::{Bytecode, TxKind, U256}, + primitives::{TxKind, U256}, Evm, }; use std::time::Duration; -fn main() { +pub fn run() { // BenchmarkDB is dummy state that implements Database trait. let mut evm = Evm::::builder() .with_db(BenchmarkDB::new_bytecode(Bytecode::new())) + .with_default_ext_ctx() .modify_tx_env(|tx| { // execution globals block hash/gas_limit/coinbase/timestamp.. tx.caller = "0x0000000000000000000000000000000000000001" diff --git a/bins/revme/src/cmd/bytecode.rs b/bins/revme/src/cmd/bytecode.rs index a0843a9492..26f39141df 100644 --- a/bins/revme/src/cmd/bytecode.rs +++ b/bins/revme/src/cmd/bytecode.rs @@ -1,10 +1,11 @@ use clap::Parser; use revm::{ + bytecode::Eof, interpreter::{ analysis::{validate_eof_inner, CodeType, EofError}, opcode::eof_printer::print_eof_code, }, - primitives::{Bytes, Eof, MAX_INITCODE_SIZE}, + primitives::{Bytes, MAX_INITCODE_SIZE}, }; use std::io; diff --git a/bins/revme/src/cmd/evmrunner.rs b/bins/revme/src/cmd/evmrunner.rs index 381b153de4..4d378000d0 100644 --- a/bins/revme/src/cmd/evmrunner.rs +++ b/bins/revme/src/cmd/evmrunner.rs @@ -1,9 +1,11 @@ use clap::Parser; use revm::{ + bytecode::{Bytecode, BytecodeDecodeError}, db::BenchmarkDB, inspector_handle_register, inspectors::TracerEip3155, - primitives::{address, Address, Bytecode, BytecodeDecodeError, EthereumWiring, TxKind}, + primitives::{address, Address, TxKind}, + wiring::EthereumWiring, Database, Evm, }; use std::io::Error as IoError; diff --git a/bins/revme/src/cmd/statetest/models/eip7702.rs b/bins/revme/src/cmd/statetest/models/eip7702.rs index 628a2dc34e..50883a2cb3 100644 --- a/bins/revme/src/cmd/statetest/models/eip7702.rs +++ b/bins/revme/src/cmd/statetest/models/eip7702.rs @@ -1,5 +1,12 @@ use alloy_rlp::{Decodable, Error as RlpError, Header}; -use revm::primitives::{AccessList, Bytes, Signature, SignedAuthorization, TxKind, U256}; +use revm::{ + primitives::{Bytes, TxKind, U256}, + specification::{ + eip2930::AccessList, + eip7702::{Signature, SignedAuthorization}, + }, +}; + use std::vec::Vec; /// TODO remove it when new tests are generated that has a Authorization json field. diff --git a/bins/revme/src/cmd/statetest/models/mod.rs b/bins/revme/src/cmd/statetest/models/mod.rs index 0a38b514b2..97959b27d8 100644 --- a/bins/revme/src/cmd/statetest/models/mod.rs +++ b/bins/revme/src/cmd/statetest/models/mod.rs @@ -6,7 +6,10 @@ use deserializer::*; pub use eip7702::TxEip7702; pub use spec::SpecName; -use revm::primitives::{AccessList, Address, AuthorizationList, Bytes, HashMap, B256, U256}; +use revm::{ + primitives::{Address, Bytes, HashMap, B256, U256}, + specification::{eip2930::AccessList, eip7702::AuthorizationList}, +}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; diff --git a/bins/revme/src/cmd/statetest/models/spec.rs b/bins/revme/src/cmd/statetest/models/spec.rs index e3fde73da5..bd3fea9dba 100644 --- a/bins/revme/src/cmd/statetest/models/spec.rs +++ b/bins/revme/src/cmd/statetest/models/spec.rs @@ -1,4 +1,4 @@ -use revm::primitives::SpecId; +use revm::specification::hardfork::SpecId; use serde::Deserialize; #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize, Hash)] diff --git a/bins/revme/src/cmd/statetest/runner.rs b/bins/revme/src/cmd/statetest/runner.rs index 78a909f70a..c6adcd186a 100644 --- a/bins/revme/src/cmd/statetest/runner.rs +++ b/bins/revme/src/cmd/statetest/runner.rs @@ -5,13 +5,19 @@ use super::{ }; use indicatif::{ProgressBar, ProgressDrawTarget}; use revm::{ - db::{EmptyDB, State}, + bytecode::Bytecode, + database_interface::EmptyDB, + db::State, inspector_handle_register, inspectors::TracerEip3155, interpreter::analysis::to_analysed, - primitives::{ - calc_excess_blob_gas, keccak256, Bytecode, Bytes, EVMResultGeneric, EnvWiring, - EthereumWiring, ExecutionResult, HaltReason, SpecId, TxKind, B256, + primitives::{keccak256, Bytes, TxKind, B256}, + specification::hardfork::SpecId, + wiring::{ + block::calc_excess_blob_gas, + default::EnvWiring, + result::{EVMResultGeneric, ExecutionResult, HaltReason}, + EthereumWiring, }, Evm, }; @@ -274,7 +280,7 @@ pub fn execute_test_suite( for (address, info) in unit.pre { let code_hash = keccak256(&info.code); let bytecode = to_analysed(Bytecode::new_raw(info.code)); - let acc_info = revm::primitives::AccountInfo { + let acc_info = revm::state::AccountInfo { balance: info.balance, code_hash, code: Some(bytecode), diff --git a/crates/bytecode/CHANGELOG.md b/crates/bytecode/CHANGELOG.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/bytecode/Cargo.toml b/crates/bytecode/Cargo.toml new file mode 100644 index 0000000000..6b9f24dacc --- /dev/null +++ b/crates/bytecode/Cargo.toml @@ -0,0 +1,42 @@ +[package] +authors = ["Dragan Rakita "] +description = "Revm Database interface" +edition = "2021" +keywords = ["ethereum", "evm", "revm", "no_std"] +license = "MIT" +name = "revm-bytecode" +repository = "https://github.com/bluealloy/revm" +version = "1.0.0" +readme = "../../README.md" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints.rust] +unreachable_pub = "warn" +unused_must_use = "deny" +rust_2018_idioms = "deny" + +[lints.rustdoc] +all = "warn" + +[dependencies] +# revm +primitives.workspace = true + +# Jumpmap +bitvec = { version = "1", default-features = false, features = ["alloc"] } + +# Optional +serde = { version = "1.0", default-features = false, features = [ + "derive", + "rc", +], optional = true } + +[features] +default = ["std"] +std = ["serde?/std", "primitives/std"] +hashbrown = ["primitives/hashbrown"] +serde = ["dep:serde", "primitives/serde", "bitvec/serde"] +serde-json = ["serde"] diff --git a/bins/revm-test/LICENSE b/crates/bytecode/LICENSE similarity index 100% rename from bins/revm-test/LICENSE rename to crates/bytecode/LICENSE diff --git a/crates/primitives/src/eip7702/bytecode.rs b/crates/bytecode/src/eip7702.rs similarity index 99% rename from crates/primitives/src/eip7702/bytecode.rs rename to crates/bytecode/src/eip7702.rs index 89a8082389..191a0c33da 100644 --- a/crates/primitives/src/eip7702/bytecode.rs +++ b/crates/bytecode/src/eip7702.rs @@ -1,5 +1,5 @@ -use crate::{bytes, Address, Bytes}; use core::fmt; +use primitives::{bytes, Address, Bytes}; /// EIP-7702 Version Magic in u16 form. pub const EIP7702_MAGIC: u16 = 0xEF01; diff --git a/crates/primitives/src/bytecode/eof.rs b/crates/bytecode/src/eof.rs similarity index 99% rename from crates/primitives/src/bytecode/eof.rs rename to crates/bytecode/src/eof.rs index d25f61f6d9..5dcab9e83f 100644 --- a/crates/primitives/src/bytecode/eof.rs +++ b/crates/bytecode/src/eof.rs @@ -7,8 +7,8 @@ pub use body::EofBody; pub use header::EofHeader; pub use types_section::TypesSection; -use crate::{b256, bytes, Bytes, B256}; use core::cmp::min; +use primitives::{b256, bytes, Bytes, B256}; use std::{fmt, vec, vec::Vec}; /// Hash of EF00 bytes that is used for EXTCODEHASH when called from legacy bytecode. @@ -188,7 +188,7 @@ impl core::error::Error for EofDecodeError {} mod test { use super::*; - use crate::bytes; + use primitives::bytes; #[test] fn decode_eof() { diff --git a/crates/primitives/src/bytecode/eof/body.rs b/crates/bytecode/src/eof/body.rs similarity index 99% rename from crates/primitives/src/bytecode/eof/body.rs rename to crates/bytecode/src/eof/body.rs index e4e9ab904c..66ccd9707c 100644 --- a/crates/primitives/src/bytecode/eof/body.rs +++ b/crates/bytecode/src/eof/body.rs @@ -1,5 +1,5 @@ use super::{Eof, EofDecodeError, EofHeader, TypesSection}; -use crate::Bytes; +use primitives::Bytes; use std::vec::Vec; /// EOF container body. diff --git a/crates/primitives/src/bytecode/eof/decode_helpers.rs b/crates/bytecode/src/eof/decode_helpers.rs similarity index 100% rename from crates/primitives/src/bytecode/eof/decode_helpers.rs rename to crates/bytecode/src/eof/decode_helpers.rs diff --git a/crates/primitives/src/bytecode/eof/header.rs b/crates/bytecode/src/eof/header.rs similarity index 99% rename from crates/primitives/src/bytecode/eof/header.rs rename to crates/bytecode/src/eof/header.rs index 45b2d03544..a1226678cf 100644 --- a/crates/primitives/src/bytecode/eof/header.rs +++ b/crates/bytecode/src/eof/header.rs @@ -234,7 +234,8 @@ impl EofHeader { #[cfg(test)] mod tests { use super::*; - use crate::hex; + use primitives::hex; + use std::vec; #[test] fn sanity_header_decode() { diff --git a/crates/primitives/src/bytecode/eof/types_section.rs b/crates/bytecode/src/eof/types_section.rs similarity index 100% rename from crates/primitives/src/bytecode/eof/types_section.rs rename to crates/bytecode/src/eof/types_section.rs diff --git a/crates/bytecode/src/errors.rs b/crates/bytecode/src/errors.rs new file mode 100644 index 0000000000..719a9f76c5 --- /dev/null +++ b/crates/bytecode/src/errors.rs @@ -0,0 +1,36 @@ +use crate::{eip7702::Eip7702DecodeError, eof::EofDecodeError}; +use core::fmt::Debug; +use std::fmt; + +/// EOF decode errors. +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub enum BytecodeDecodeError { + /// EOF decode error + Eof(EofDecodeError), + /// EIP-7702 decode error + Eip7702(Eip7702DecodeError), +} + +impl From for BytecodeDecodeError { + fn from(error: EofDecodeError) -> Self { + Self::Eof(error) + } +} + +impl From for BytecodeDecodeError { + fn from(error: Eip7702DecodeError) -> Self { + Self::Eip7702(error) + } +} + +impl core::error::Error for BytecodeDecodeError {} + +impl fmt::Display for BytecodeDecodeError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Eof(e) => fmt::Display::fmt(e, f), + Self::Eip7702(e) => fmt::Display::fmt(e, f), + } + } +} diff --git a/crates/primitives/src/bytecode/legacy.rs b/crates/bytecode/src/legacy.rs similarity index 98% rename from crates/primitives/src/bytecode/legacy.rs rename to crates/bytecode/src/legacy.rs index 2a44fefd43..2fe1cdd5c7 100644 --- a/crates/primitives/src/bytecode/legacy.rs +++ b/crates/bytecode/src/legacy.rs @@ -2,8 +2,8 @@ mod jump_map; pub use jump_map::JumpTable; -use crate::Bytes; use bitvec::{bitvec, order::Lsb0}; +use primitives::Bytes; use std::sync::Arc; /// Legacy analyzed diff --git a/crates/primitives/src/bytecode/legacy/jump_map.rs b/crates/bytecode/src/legacy/jump_map.rs similarity index 97% rename from crates/primitives/src/bytecode/legacy/jump_map.rs rename to crates/bytecode/src/legacy/jump_map.rs index af86178775..bd791646fa 100644 --- a/crates/primitives/src/bytecode/legacy/jump_map.rs +++ b/crates/bytecode/src/legacy/jump_map.rs @@ -1,5 +1,5 @@ -use crate::hex; use bitvec::vec::BitVec; +use primitives::hex; use std::{fmt::Debug, sync::Arc}; /// A map of valid `jump` destinations. diff --git a/crates/primitives/src/bytecode.rs b/crates/bytecode/src/lib.rs similarity index 85% rename from crates/primitives/src/bytecode.rs rename to crates/bytecode/src/lib.rs index d3fbbd2868..0d57202637 100644 --- a/crates/primitives/src/bytecode.rs +++ b/crates/bytecode/src/lib.rs @@ -1,17 +1,24 @@ +//! Optimism-specific constants, types, and helpers. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(not(feature = "std"))] +extern crate alloc as std; + +pub mod eip7702; pub mod eof; +pub mod errors; pub mod legacy; +pub use bitvec; pub use eof::{Eof, EOF_MAGIC, EOF_MAGIC_BYTES, EOF_MAGIC_HASH}; +pub use errors::BytecodeDecodeError; pub use legacy::{JumpTable, LegacyAnalyzedBytecode}; -use crate::{ - eip7702::bytecode::Eip7702DecodeError, keccak256, Bytes, Eip7702Bytecode, B256, - EIP7702_MAGIC_BYTES, KECCAK_EMPTY, -}; -use alloy_primitives::Address; use core::fmt::Debug; -use eof::EofDecodeError; -use std::{fmt, sync::Arc}; +use eip7702::{Eip7702Bytecode, EIP7702_MAGIC_BYTES}; +use primitives::{keccak256, Address, Bytes, B256, KECCAK_EMPTY}; +use std::sync::Arc; /// State of the [`Bytecode`] analysis. #[derive(Clone, Debug, PartialEq, Eq, Hash)] @@ -213,39 +220,6 @@ impl Bytecode { } } -/// EOF decode errors. -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum BytecodeDecodeError { - /// EOF decode error - Eof(EofDecodeError), - /// EIP-7702 decode error - Eip7702(Eip7702DecodeError), -} - -impl From for BytecodeDecodeError { - fn from(error: EofDecodeError) -> Self { - Self::Eof(error) - } -} - -impl From for BytecodeDecodeError { - fn from(error: Eip7702DecodeError) -> Self { - Self::Eip7702(error) - } -} - -impl core::error::Error for BytecodeDecodeError {} - -impl fmt::Display for BytecodeDecodeError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::Eof(e) => fmt::Display::fmt(e, f), - Self::Eip7702(e) => fmt::Display::fmt(e, f), - } - } -} - #[cfg(test)] mod tests { use super::{Bytecode, Eof}; diff --git a/crates/database/interface/CHANGELOG.md b/crates/database/interface/CHANGELOG.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/database/interface/Cargo.toml b/crates/database/interface/Cargo.toml new file mode 100644 index 0000000000..bc67977713 --- /dev/null +++ b/crates/database/interface/Cargo.toml @@ -0,0 +1,47 @@ +[package] +authors = ["Dragan Rakita "] +description = "Revm Database interface" +edition = "2021" +keywords = ["ethereum", "evm", "revm", "no_std"] +license = "MIT" +name = "revm-database-interface" +repository = "https://github.com/bluealloy/revm" +version = "1.0.0" +readme = "../../README.md" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints.rust] +unreachable_pub = "warn" +unused_must_use = "deny" +rust_2018_idioms = "deny" + +[lints.rustdoc] +all = "warn" + +[dependencies] +state.workspace = true +primitives.workspace = true + +auto_impl = "1.2" + +# Optional +serde = { version = "1.0", default-features = false, features = [ + "derive", + "rc", +], optional = true } + + +[dev-dependencies] +anyhow = "1.0.83" +criterion = "0.5" +indicatif = "0.17" +rstest = "0.22.0" +alloy-sol-types = "0.8" + +[features] +default = ["std"] +std = ["serde?/std"] +serde = ["dep:serde"] diff --git a/crates/database/interface/LICENSE b/crates/database/interface/LICENSE new file mode 100644 index 0000000000..ad98ff22cc --- /dev/null +++ b/crates/database/interface/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2024 draganrakita + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/primitives/src/db/emptydb.rs b/crates/database/interface/src/empty_db.rs similarity index 95% rename from crates/primitives/src/db/emptydb.rs rename to crates/database/interface/src/empty_db.rs index 8f9783e82a..3c5445c405 100644 --- a/crates/primitives/src/db/emptydb.rs +++ b/crates/database/interface/src/empty_db.rs @@ -1,8 +1,7 @@ -use crate::{ - db::{Database, DatabaseRef}, - keccak256, AccountInfo, Address, Bytecode, B256, U256, -}; +use crate::{Database, DatabaseRef}; use core::{convert::Infallible, fmt, marker::PhantomData}; +use primitives::{keccak256, Address, B256, U256}; +use state::{AccountInfo, Bytecode}; use std::string::ToString; /// An empty database that always returns default values when queried. @@ -104,7 +103,7 @@ impl DatabaseRef for EmptyDBTyped { #[cfg(test)] mod tests { use super::*; - use crate::b256; + use primitives::b256; #[test] fn conform_block_hash_calculation() { diff --git a/crates/primitives/src/db.rs b/crates/database/interface/src/lib.rs similarity index 88% rename from crates/primitives/src/db.rs rename to crates/database/interface/src/lib.rs index 0b01009831..a3b68fc90a 100644 --- a/crates/primitives/src/db.rs +++ b/crates/database/interface/src/lib.rs @@ -1,13 +1,17 @@ -use crate::{Account, AccountInfo, Address, Bytecode, HashMap, B256, U256}; +//! Optimism-specific constants, types, and helpers. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(not(feature = "std"))] +extern crate alloc as std; + use auto_impl::auto_impl; +use primitives::{Address, HashMap, B256, U256}; +use state::{Account, AccountInfo, Bytecode}; -pub mod components; -pub mod emptydb; +pub mod empty_db; -pub use components::{ - BlockHash, BlockHashRef, DatabaseComponentError, DatabaseComponents, State, StateRef, -}; -pub use emptydb::{EmptyDB, EmptyDBTyped}; +pub use empty_db::{EmptyDB, EmptyDBTyped}; /// EVM database interface. #[auto_impl(&mut, Box)] diff --git a/crates/gas/CHANGELOG.md b/crates/gas/CHANGELOG.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/gas/Cargo.toml b/crates/gas/Cargo.toml new file mode 100644 index 0000000000..435e80f935 --- /dev/null +++ b/crates/gas/Cargo.toml @@ -0,0 +1,41 @@ +[package] +authors = ["Dragan Rakita "] +description = "Revm Database interface" +edition = "2021" +keywords = ["ethereum", "evm", "revm", "no_std"] +license = "MIT" +name = "revm-gas" +repository = "https://github.com/bluealloy/revm" +version = "1.0.0" +readme = "../../README.md" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints.rust] +unreachable_pub = "warn" +unused_must_use = "deny" +rust_2018_idioms = "deny" + +[lints.rustdoc] +all = "warn" + +[dependencies] + +# Optional +serde = { version = "1.0", default-features = false, features = [ + "derive", + "rc", +], optional = true } + + +[dev-dependencies] + +[features] +default = ["std",] +std = [ + "serde?/std", +] +serde = ["dep:serde"] +serde-json = ["serde"] \ No newline at end of file diff --git a/crates/gas/LICENSE b/crates/gas/LICENSE new file mode 100644 index 0000000000..ad98ff22cc --- /dev/null +++ b/crates/gas/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2024 draganrakita + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/gas/src/lib.rs b/crates/gas/src/lib.rs new file mode 100644 index 0000000000..b3ceb57058 --- /dev/null +++ b/crates/gas/src/lib.rs @@ -0,0 +1,8 @@ +//! Optimism-specific constants, types, and helpers. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(not(feature = "std"))] +extern crate alloc as std; + + diff --git a/crates/inspector/CHANGELOG.md b/crates/inspector/CHANGELOG.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/inspector/Cargo.toml b/crates/inspector/Cargo.toml new file mode 100644 index 0000000000..053b6ae583 --- /dev/null +++ b/crates/inspector/Cargo.toml @@ -0,0 +1,38 @@ +[package] +authors = ["Dragan Rakita "] +description = "Revm Database interface" +edition = "2021" +keywords = ["ethereum", "evm", "revm", "no_std"] +license = "MIT" +name = "revm-inspector" +repository = "https://github.com/bluealloy/revm" +version = "1.0.0" +readme = "../../README.md" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints.rust] +unreachable_pub = "warn" +unused_must_use = "deny" +rust_2018_idioms = "deny" + +[lints.rustdoc] +all = "warn" + +[dependencies] +# Optional +serde = { version = "1.0", default-features = false, features = [ + "derive", + "rc", +], optional = true } + + +[features] +default = ["std",] +std = [ + "serde?/std", +] +serde = ["dep:serde"] +serde-json = ["serde"] \ No newline at end of file diff --git a/crates/inspector/LICENSE b/crates/inspector/LICENSE new file mode 100644 index 0000000000..ad98ff22cc --- /dev/null +++ b/crates/inspector/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2024 draganrakita + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/inspector/src/lib.rs b/crates/inspector/src/lib.rs new file mode 100644 index 0000000000..349d232839 --- /dev/null +++ b/crates/inspector/src/lib.rs @@ -0,0 +1,6 @@ +//! Optimism-specific constants, types, and helpers. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(not(feature = "std"))] +extern crate alloc as std; diff --git a/crates/interface/CHANGELOG.md b/crates/interface/CHANGELOG.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/interface/Cargo.toml b/crates/interface/Cargo.toml new file mode 100644 index 0000000000..25793f6d78 --- /dev/null +++ b/crates/interface/Cargo.toml @@ -0,0 +1,35 @@ +[package] +authors = ["Dragan Rakita "] +description = "Revm Database interface" +edition = "2021" +keywords = ["ethereum", "evm", "revm", "no_std"] +license = "MIT" +name = "revm-interface" +repository = "https://github.com/bluealloy/revm" +version = "1.0.0" +readme = "../../README.md" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints.rust] +unreachable_pub = "warn" +unused_must_use = "deny" +rust_2018_idioms = "deny" + +[lints.rustdoc] +all = "warn" + +[dependencies] +# Optional +serde = { version = "1.0", default-features = false, features = [ + "derive", + "rc", +], optional = true } + +[features] +default = ["std"] +std = ["serde?/std"] +serde = ["dep:serde"] +serde-json = ["serde"] diff --git a/crates/interface/LICENSE b/crates/interface/LICENSE new file mode 100644 index 0000000000..ad98ff22cc --- /dev/null +++ b/crates/interface/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2024 draganrakita + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/interface/src/lib.rs b/crates/interface/src/lib.rs new file mode 100644 index 0000000000..b3ceb57058 --- /dev/null +++ b/crates/interface/src/lib.rs @@ -0,0 +1,8 @@ +//! Optimism-specific constants, types, and helpers. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(not(feature = "std"))] +extern crate alloc as std; + + diff --git a/crates/interpreter/Cargo.toml b/crates/interpreter/Cargo.toml index 114c89c415..baf356978c 100644 --- a/crates/interpreter/Cargo.toml +++ b/crates/interpreter/Cargo.toml @@ -22,7 +22,11 @@ rust_2018_idioms = "deny" all = "warn" [dependencies] -revm-primitives = { path = "../primitives", version = "9.0.1", default-features = false } +# revm +bytecode.workspace = true +primitives.workspace = true +specification.workspace = true +wiring.workspace = true derive-where = { version = "1.2.7", default-features = false } paste = { version = "1.0", optional = true } @@ -37,35 +41,16 @@ serde = { version = "1.0", default-features = false, features = [ ], optional = true } [dev-dependencies] +database-interface.workspace = true walkdir = "2.5" serde_json = "1.0" bincode = "1.3" [features] default = ["std", "parse"] -std = ["serde?/std", "revm-primitives/std"] -hashbrown = ["revm-primitives/hashbrown"] -serde = ["dep:serde", "revm-primitives/serde"] -arbitrary = ["std", "revm-primitives/arbitrary"] -asm-keccak = ["revm-primitives/asm-keccak"] -portable = ["revm-primitives/portable"] +std = ["serde?/std", "primitives/std", "wiring/std"] +hashbrown = ["primitives/hashbrown"] +serde = ["dep:serde", "primitives/serde", "bytecode/serde", "wiring/serde"] +arbitrary = ["std", "primitives/arbitrary"] parse = ["dep:paste", "dep:phf"] - -dev = [ - "memory_limit", - "optional_balance_check", - "optional_block_gas_limit", - "optional_eip3607", - "optional_gas_refund", - "optional_no_base_fee", - "optional_beneficiary_reward", -] -memory_limit = ["revm-primitives/memory_limit"] -optional_balance_check = ["revm-primitives/optional_balance_check"] -optional_block_gas_limit = ["revm-primitives/optional_block_gas_limit"] -optional_eip3607 = ["revm-primitives/optional_eip3607"] -optional_gas_refund = ["revm-primitives/optional_gas_refund"] -optional_no_base_fee = ["revm-primitives/optional_no_base_fee"] -optional_beneficiary_reward = ["revm-primitives/optional_beneficiary_reward"] - -kzg-rs = ["revm-primitives/kzg-rs"] +memory_limit = ["wiring/memory_limit"] diff --git a/crates/interpreter/src/gas/calc.rs b/crates/interpreter/src/gas/calc.rs index a56261859b..4af87c3d3b 100644 --- a/crates/interpreter/src/gas/calc.rs +++ b/crates/interpreter/src/gas/calc.rs @@ -1,11 +1,7 @@ -use revm_primitives::eip7702; - use super::constants::*; -use crate::{ - num_words, - primitives::{AccessListItem, SpecId, U256}, - AccountLoad, Eip7702CodeLoad, SStoreResult, SelfDestructResult, StateLoad, -}; +use crate::{num_words, AccountLoad, Eip7702CodeLoad, SStoreResult, SelfDestructResult, StateLoad}; +use primitives::U256; +use specification::{eip2930::AccessListItem, eip7702, hardfork::SpecId}; /// `const` Option `?`. macro_rules! tri { diff --git a/crates/interpreter/src/host.rs b/crates/interpreter/src/host.rs index 377985b0d8..de1a3cc115 100644 --- a/crates/interpreter/src/host.rs +++ b/crates/interpreter/src/host.rs @@ -1,9 +1,9 @@ -use crate::primitives::{Address, Bytes, Log, B256, U256}; use core::ops::{Deref, DerefMut}; +use primitives::{Address, Bytes, Log, B256, U256}; mod dummy; pub use dummy::DummyHost; -use revm_primitives::{EnvWiring, EvmWiring}; +use wiring::{default::EnvWiring, EvmWiring}; /// EVM context host. pub trait Host { @@ -259,7 +259,8 @@ pub struct SelfDestructResult { #[cfg(test)] mod tests { - use revm_primitives::{db::EmptyDB, EthereumWiring}; + use database_interface::EmptyDB; + use wiring::EthereumWiring; use super::*; diff --git a/crates/interpreter/src/host/dummy.rs b/crates/interpreter/src/host/dummy.rs index 88f0bf4063..724519777d 100644 --- a/crates/interpreter/src/host/dummy.rs +++ b/crates/interpreter/src/host/dummy.rs @@ -1,13 +1,11 @@ +use crate::{Host, SStoreResult, SelfDestructResult}; use derive_where::derive_where; -use revm_primitives::EnvWiring; - -use crate::{ - primitives::{ - hash_map::Entry, Address, Bytes, Env, EvmWiring, HashMap, Log, B256, KECCAK_EMPTY, U256, - }, - Host, SStoreResult, SelfDestructResult, -}; +use primitives::{hash_map::Entry, Address, Bytes, HashMap, Log, B256, KECCAK_EMPTY, U256}; use std::vec::Vec; +use wiring::{ + default::{Env, EnvWiring}, + EvmWiring, +}; use super::{AccountLoad, Eip7702CodeLoad, StateLoad}; diff --git a/crates/interpreter/src/instruction_result.rs b/crates/interpreter/src/instruction_result.rs index e73ce1abc8..e42e7132e8 100644 --- a/crates/interpreter/src/instruction_result.rs +++ b/crates/interpreter/src/instruction_result.rs @@ -1,8 +1,8 @@ use core::fmt::Debug; - -use revm_primitives::HaltReasonTrait; - -use crate::primitives::{HaltReason, OutOfGasError, SuccessReason}; +use wiring::{ + result::{HaltReason, OutOfGasError, SuccessReason}, + HaltReasonTrait, +}; #[repr(u8)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] diff --git a/crates/interpreter/src/instructions/arithmetic.rs b/crates/interpreter/src/instructions/arithmetic.rs index da11b79b9c..0f3753bb3b 100644 --- a/crates/interpreter/src/instructions/arithmetic.rs +++ b/crates/interpreter/src/instructions/arithmetic.rs @@ -1,9 +1,7 @@ use super::i256::{i256_div, i256_mod}; -use crate::{ - gas, - primitives::{Spec, U256}, - Host, Interpreter, -}; +use crate::{gas, Host, Interpreter}; +use primitives::U256; +use specification::hardfork::Spec; pub fn add(interpreter: &mut Interpreter, _host: &mut H) { gas!(interpreter, gas::VERYLOW); diff --git a/crates/interpreter/src/instructions/bitwise.rs b/crates/interpreter/src/instructions/bitwise.rs index c9f4ecb221..0d9ec0d59e 100644 --- a/crates/interpreter/src/instructions/bitwise.rs +++ b/crates/interpreter/src/instructions/bitwise.rs @@ -1,10 +1,8 @@ use super::i256::i256_cmp; -use crate::{ - gas, - primitives::{Spec, U256}, - Host, Interpreter, -}; +use crate::{gas, Host, Interpreter}; use core::cmp::Ordering; +use primitives::U256; +use specification::hardfork::Spec; pub fn lt(interpreter: &mut Interpreter, _host: &mut H) { gas!(interpreter, gas::VERYLOW); @@ -125,7 +123,9 @@ pub fn sar(interpreter: &mut Interpreter, _host: & mod tests { use crate::instructions::bitwise::{byte, sar, shl, shr}; use crate::{Contract, DummyHost, Interpreter}; - use revm_primitives::{uint, DefaultEthereumWiring, Env, LatestSpec, U256}; + use primitives::{uint, U256}; + use specification::hardfork::LatestSpec; + use wiring::{default::Env, DefaultEthereumWiring}; #[test] fn test_shift_left() { diff --git a/crates/interpreter/src/instructions/contract.rs b/crates/interpreter/src/instructions/contract.rs index 281e147582..06be29e18d 100644 --- a/crates/interpreter/src/instructions/contract.rs +++ b/crates/interpreter/src/instructions/contract.rs @@ -5,14 +5,15 @@ pub use call_helpers::{calc_call_gas, get_memory_input_and_out_ranges, resize_me use crate::{ gas::{self, cost_per_word, EOF_CREATE_GAS, KECCAK256WORD, MIN_CALLEE_GAS}, interpreter::Interpreter, - primitives::{ - eof::EofHeader, keccak256, Address, BerlinSpec, Bytes, Eof, Spec, SpecId::*, B256, U256, - }, - CallInputs, CallScheme, CallValue, CreateInputs, CreateScheme, EOFCreateInputs, Host, - InstructionResult, InterpreterAction, InterpreterResult, MAX_INITCODE_SIZE, + CallInputs, CallScheme, CallValue, CreateInputs, EOFCreateInputs, Host, InstructionResult, + InterpreterAction, InterpreterResult, MAX_INITCODE_SIZE, }; +use bytecode::eof::{Eof, EofHeader}; use core::cmp::max; +use primitives::{keccak256, Address, Bytes, B256, U256}; +use specification::hardfork::{BerlinSpec, Spec, SpecId::*}; use std::boxed::Box; +use wiring::default::CreateScheme; /// EOF Create instruction pub fn eofcreate(interpreter: &mut Interpreter, _host: &mut H) { diff --git a/crates/interpreter/src/instructions/contract/call_helpers.rs b/crates/interpreter/src/instructions/contract/call_helpers.rs index 3755fe4c16..0de9baa548 100644 --- a/crates/interpreter/src/instructions/contract/call_helpers.rs +++ b/crates/interpreter/src/instructions/contract/call_helpers.rs @@ -1,10 +1,7 @@ -use crate::{ - gas, - interpreter::Interpreter, - primitives::{Bytes, Spec, SpecId::*, U256}, - AccountLoad, -}; +use crate::{gas, interpreter::Interpreter, AccountLoad}; use core::{cmp::min, ops::Range}; +use primitives::{Bytes, U256}; +use specification::hardfork::{Spec, SpecId::*}; #[inline] pub fn get_memory_input_and_out_ranges( diff --git a/crates/interpreter/src/instructions/control.rs b/crates/interpreter/src/instructions/control.rs index 5fdf025c18..a9faa5c02a 100644 --- a/crates/interpreter/src/instructions/control.rs +++ b/crates/interpreter/src/instructions/control.rs @@ -1,9 +1,7 @@ use super::utility::{read_i16, read_u16}; -use crate::{ - gas, - primitives::{Bytes, Spec, U256}, - Host, InstructionResult, Interpreter, InterpreterResult, -}; +use crate::{gas, Host, InstructionResult, Interpreter, InterpreterResult}; +use primitives::{Bytes, U256}; +use specification::hardfork::Spec; pub fn rjump(interpreter: &mut Interpreter, _host: &mut H) { require_eof!(interpreter); @@ -204,17 +202,19 @@ pub fn unknown(interpreter: &mut Interpreter, _host: &mut H) { #[cfg(test)] mod test { - use std::sync::Arc; - - use revm_primitives::{ - bytes, eof::TypesSection, Bytecode, DefaultEthereumWiring, Eof, PragueSpec, - }; - use super::*; use crate::{ opcode::{make_instruction_table, CALLF, JUMPF, NOP, RETF, RJUMP, RJUMPI, RJUMPV, STOP}, DummyHost, FunctionReturnFrame, Gas, Interpreter, }; + use bytecode::{ + eof::{Eof, TypesSection}, + Bytecode, + }; + use primitives::bytes; + use specification::hardfork::PragueSpec; + use std::sync::Arc; + use wiring::DefaultEthereumWiring; #[test] fn rjump() { diff --git a/crates/interpreter/src/instructions/data.rs b/crates/interpreter/src/instructions/data.rs index 86ce32024d..dcd332ac4a 100644 --- a/crates/interpreter/src/instructions/data.rs +++ b/crates/interpreter/src/instructions/data.rs @@ -2,9 +2,9 @@ use crate::{ gas::{cost_per_word, BASE, DATA_LOAD_GAS, VERYLOW}, instructions::utility::read_u16, interpreter::Interpreter, - primitives::U256, Host, }; +use primitives::U256; pub fn data_load(interpreter: &mut Interpreter, _host: &mut H) { require_eof!(interpreter); @@ -83,8 +83,11 @@ pub fn data_copy(interpreter: &mut Interpreter, _host: &mut H) #[cfg(test)] mod test { - use revm_primitives::{b256, bytes, Bytecode, Bytes, DefaultEthereumWiring, Eof, PragueSpec}; + use bytecode::{Bytecode, Eof}; + use primitives::{b256, bytes, Bytes}; + use specification::hardfork::PragueSpec; use std::sync::Arc; + use wiring::DefaultEthereumWiring; use super::*; use crate::{ diff --git a/crates/interpreter/src/instructions/host.rs b/crates/interpreter/src/instructions/host.rs index 612cbac5c1..8baf5e84ae 100644 --- a/crates/interpreter/src/instructions/host.rs +++ b/crates/interpreter/src/instructions/host.rs @@ -1,10 +1,11 @@ use crate::{ gas::{self, warm_cold_cost, warm_cold_cost_with_delegation}, interpreter::Interpreter, - primitives::{Bytes, Log, LogData, Spec, SpecId::*, B256, U256}, Host, InstructionResult, }; use core::cmp::min; +use primitives::{Bytes, Log, LogData, B256, U256}; +use specification::hardfork::{Spec, SpecId::*}; use std::vec::Vec; pub fn balance(interpreter: &mut Interpreter, host: &mut H) { diff --git a/crates/interpreter/src/instructions/host_env.rs b/crates/interpreter/src/instructions/host_env.rs index fa95533e4f..17f9879ab8 100644 --- a/crates/interpreter/src/instructions/host_env.rs +++ b/crates/interpreter/src/instructions/host_env.rs @@ -1,8 +1,7 @@ -use crate::{ - gas, - primitives::{Block, Spec, SpecId::*, Transaction, U256}, - Host, Interpreter, -}; +use crate::{gas, Host, Interpreter}; +use primitives::U256; +use specification::hardfork::{Spec, SpecId::*}; +use wiring::{Block, Transaction}; /// EIP-1344: ChainID opcode pub fn chainid(interpreter: &mut Interpreter, host: &mut H) { diff --git a/crates/interpreter/src/instructions/i256.rs b/crates/interpreter/src/instructions/i256.rs index 07d897450a..92145b4bdb 100644 --- a/crates/interpreter/src/instructions/i256.rs +++ b/crates/interpreter/src/instructions/i256.rs @@ -1,5 +1,5 @@ -use crate::primitives::U256; use core::cmp::Ordering; +use primitives::U256; #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(i8)] @@ -132,8 +132,8 @@ pub fn i256_mod(mut first: U256, mut second: U256) -> U256 { #[cfg(test)] mod tests { use super::*; - use crate::primitives::uint; use core::num::Wrapping; + use primitives::uint; #[test] fn div_i256() { diff --git a/crates/interpreter/src/instructions/macros.rs b/crates/interpreter/src/instructions/macros.rs index 4df6f62d1a..e37d6f0757 100644 --- a/crates/interpreter/src/instructions/macros.rs +++ b/crates/interpreter/src/instructions/macros.rs @@ -38,8 +38,8 @@ macro_rules! require_init_eof { macro_rules! check { ($interp:expr, $min:ident) => { if const { - !::SPEC_ID - .is_enabled_in($crate::primitives::SpecId::$min) + !::SPEC_ID + .is_enabled_in(specification::hardfork::SpecId::$min) } { $interp.instruction_result = $crate::InstructionResult::NotActivated; return; @@ -132,7 +132,7 @@ macro_rules! pop_address_ret { return $ret; } // SAFETY: Length is checked above. - let $x1 = $crate::primitives::Address::from_word($crate::primitives::B256::from(unsafe { + let $x1 = ::primitives::Address::from_word(::primitives::B256::from(unsafe { $interp.stack.pop_unsafe() })); }; @@ -142,10 +142,10 @@ macro_rules! pop_address_ret { return $ret; } // SAFETY: Length is checked above. - let $x1 = $crate::primitives::Address::from_word($crate::primitives::B256::from(unsafe { + let $x1 = ::primitives::Address::from_word(::primitives::B256::from(unsafe { $interp.stack.pop_unsafe() })); - let $x2 = $crate::primitives::Address::from_word($crate::primitives::B256::from(unsafe { + let $x2 = ::primitives::Address::from_word(::primitives::B256::from(unsafe { $interp.stack.pop_unsafe() })); }; diff --git a/crates/interpreter/src/instructions/memory.rs b/crates/interpreter/src/instructions/memory.rs index e5bdde911c..1e02b75b33 100644 --- a/crates/interpreter/src/instructions/memory.rs +++ b/crates/interpreter/src/instructions/memory.rs @@ -1,9 +1,7 @@ -use crate::{ - gas, - primitives::{Spec, U256}, - Host, Interpreter, -}; +use crate::{gas, Host, Interpreter}; use core::cmp::max; +use primitives::U256; +use specification::hardfork::Spec; pub fn mload(interpreter: &mut Interpreter, _host: &mut H) { gas!(interpreter, gas::VERYLOW); diff --git a/crates/interpreter/src/instructions/stack.rs b/crates/interpreter/src/instructions/stack.rs index f249823b4d..c7893d4310 100644 --- a/crates/interpreter/src/instructions/stack.rs +++ b/crates/interpreter/src/instructions/stack.rs @@ -1,8 +1,6 @@ -use crate::{ - gas, - primitives::{Spec, U256}, - Host, Interpreter, -}; +use crate::{gas, Host, Interpreter}; +use primitives::U256; +use specification::hardfork::Spec; pub fn pop(interpreter: &mut Interpreter, _host: &mut H) { gas!(interpreter, gas::BASE); @@ -90,9 +88,12 @@ mod test { use super::*; use crate::{ opcode::{make_instruction_table, DUPN, EXCHANGE, SWAPN}, - primitives::{Bytecode, Bytes, DefaultEthereumWiring, PragueSpec}, DummyHost, Gas, InstructionResult, }; + use bytecode::Bytecode; + use primitives::Bytes; + use specification::hardfork::PragueSpec; + use wiring::DefaultEthereumWiring; #[test] fn dupn() { diff --git a/crates/interpreter/src/instructions/system.rs b/crates/interpreter/src/instructions/system.rs index 659951f733..7daea5b16c 100644 --- a/crates/interpreter/src/instructions/system.rs +++ b/crates/interpreter/src/instructions/system.rs @@ -1,9 +1,7 @@ -use crate::{ - gas, - primitives::{Spec, B256, KECCAK_EMPTY, U256}, - Host, InstructionResult, Interpreter, -}; +use crate::{gas, Host, InstructionResult, Interpreter}; use core::ptr; +use primitives::{B256, KECCAK_EMPTY, U256}; +use specification::hardfork::Spec; pub fn keccak256(interpreter: &mut Interpreter, _host: &mut H) { pop_top!(interpreter, offset, len_ptr); @@ -14,7 +12,7 @@ pub fn keccak256(interpreter: &mut Interpreter, _host: &mut H) } else { let from = as_usize_or_fail!(interpreter, offset); resize_memory!(interpreter, from, len); - crate::primitives::keccak256(interpreter.shared_memory.slice(from, len)) + primitives::keccak256(interpreter.shared_memory.slice(from, len)) }; *len_ptr = hash.into(); } @@ -189,9 +187,12 @@ mod test { use super::*; use crate::{ opcode::{make_instruction_table, RETURNDATACOPY, RETURNDATALOAD}, - primitives::{bytes, Bytecode, DefaultEthereumWiring, PragueSpec}, DummyHost, Gas, InstructionResult, }; + use bytecode::Bytecode; + use primitives::bytes; + use specification::hardfork::PragueSpec; + use wiring::DefaultEthereumWiring; #[test] fn returndataload() { diff --git a/crates/interpreter/src/interpreter.rs b/crates/interpreter/src/interpreter.rs index 2b796366f2..d8e5e236a3 100644 --- a/crates/interpreter/src/interpreter.rs +++ b/crates/interpreter/src/interpreter.rs @@ -10,11 +10,12 @@ pub use shared_memory::{num_words, SharedMemory, EMPTY_SHARED_MEMORY}; pub use stack::{Stack, STACK_LIMIT}; use crate::{ - gas, primitives::Bytes, push, push_b256, return_ok, return_revert, CallOutcome, CreateOutcome, - FunctionStack, Gas, Host, InstructionResult, InterpreterAction, + gas, push, push_b256, return_ok, return_revert, CallOutcome, CreateOutcome, FunctionStack, Gas, + Host, InstructionResult, InterpreterAction, }; +use bytecode::{Bytecode, Eof}; use core::cmp::min; -use revm_primitives::{Bytecode, Eof, U256}; +use primitives::{Bytes, U256}; use std::borrow::ToOwned; use std::sync::Arc; @@ -112,9 +113,9 @@ impl Interpreter { Bytes::new(), bytecode, None, - crate::primitives::Address::default(), + primitives::Address::default(), None, - crate::primitives::Address::default(), + primitives::Address::default(), U256::ZERO, ), 0, @@ -469,7 +470,8 @@ pub fn resize_memory(memory: &mut SharedMemory, gas: &mut Gas, new_size: usize) mod tests { use super::*; use crate::{opcode::InstructionTable, DummyHost}; - use revm_primitives::{CancunSpec, DefaultEthereumWiring}; + use specification::hardfork::CancunSpec; + use wiring::DefaultEthereumWiring; #[test] fn object_safety() { diff --git a/crates/interpreter/src/interpreter/analysis.rs b/crates/interpreter/src/interpreter/analysis.rs index c2ea93506c..6935a6dad8 100644 --- a/crates/interpreter/src/interpreter/analysis.rs +++ b/crates/interpreter/src/interpreter/analysis.rs @@ -1,16 +1,15 @@ -use revm_primitives::MAX_INITCODE_SIZE; - use crate::{ instructions::utility::{read_i16, read_u16}, - opcode, - primitives::{ - bitvec::prelude::{bitvec, BitVec, Lsb0}, - eof::{EofDecodeError, TypesSection}, - legacy::JumpTable, - Bytecode, Bytes, Eof, LegacyAnalyzedBytecode, - }, - OPCODE_INFO_JUMPTABLE, STACK_LIMIT, + opcode, OPCODE_INFO_JUMPTABLE, STACK_LIMIT, +}; +use bytecode::{ + bitvec::prelude::{bitvec, BitVec, Lsb0}, + eof::{Eof, EofDecodeError, TypesSection}, + legacy::{JumpTable, LegacyAnalyzedBytecode}, + Bytecode, }; +use primitives::{Bytes, MAX_INITCODE_SIZE}; + use core::{convert::identity, mem}; use std::{borrow::Cow, fmt, sync::Arc, vec, vec::Vec}; @@ -807,7 +806,7 @@ pub fn validate_eof_code( #[cfg(test)] mod test { use super::*; - use revm_primitives::hex; + use primitives::hex; #[test] fn test1() { diff --git a/crates/interpreter/src/interpreter/contract.rs b/crates/interpreter/src/interpreter/contract.rs index 5dc50f4d0d..683be21cae 100644 --- a/crates/interpreter/src/interpreter/contract.rs +++ b/crates/interpreter/src/interpreter/contract.rs @@ -1,10 +1,8 @@ -use revm_primitives::{EnvWiring, EvmWiring}; - use super::analysis::to_analysed; -use crate::{ - primitives::{Address, Bytecode, Bytes, Transaction, TxKind, B256, U256}, - CallInputs, -}; +use crate::CallInputs; +use bytecode::Bytecode; +use primitives::{Address, Bytes, TxKind, B256, U256}; +use wiring::{default::EnvWiring, EvmWiring, Transaction}; /// EVM contract information. #[derive(Clone, Debug, Default)] diff --git a/crates/interpreter/src/interpreter/serde.rs b/crates/interpreter/src/interpreter/serde.rs index 2cc8fd0496..829b1baef3 100644 --- a/crates/interpreter/src/interpreter/serde.rs +++ b/crates/interpreter/src/interpreter/serde.rs @@ -2,7 +2,7 @@ use super::Interpreter; use crate::{ Contract, FunctionStack, Gas, InstructionResult, InterpreterAction, SharedMemory, Stack, }; -use revm_primitives::Bytes; +use primitives::Bytes; use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[derive(Serialize)] diff --git a/crates/interpreter/src/interpreter/shared_memory.rs b/crates/interpreter/src/interpreter/shared_memory.rs index 601379b553..4bb5a9f09d 100644 --- a/crates/interpreter/src/interpreter/shared_memory.rs +++ b/crates/interpreter/src/interpreter/shared_memory.rs @@ -1,5 +1,5 @@ use core::{cmp::min, fmt, ops::Range}; -use revm_primitives::{B256, U256}; +use primitives::{hex, B256, U256}; use std::vec::Vec; /// A sequential memory shared between calls, which uses @@ -16,7 +16,7 @@ pub struct SharedMemory { checkpoints: Vec, /// Invariant: equals `self.checkpoints.last()` last_checkpoint: usize, - /// Memory limit. See [`CfgEnv`](revm_primitives::CfgEnv). + /// Memory limit. See [`CfgEnv`](wiring::default::CfgEnv). #[cfg(feature = "memory_limit")] memory_limit: u64, } @@ -36,10 +36,7 @@ impl fmt::Debug for SharedMemory { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SharedMemory") .field("current_len", &self.len()) - .field( - "context_memory", - &crate::primitives::hex::encode(self.context_memory()), - ) + .field("context_memory", &hex::encode(self.context_memory())) .finish_non_exhaustive() } } diff --git a/crates/interpreter/src/interpreter/stack.rs b/crates/interpreter/src/interpreter/stack.rs index 28b0baf3c1..6b3a27dc38 100644 --- a/crates/interpreter/src/interpreter/stack.rs +++ b/crates/interpreter/src/interpreter/stack.rs @@ -1,8 +1,6 @@ -use crate::{ - primitives::{B256, U256}, - InstructionResult, -}; +use crate::InstructionResult; use core::{fmt, ptr}; +use primitives::{B256, U256}; use std::vec::Vec; /// EVM interpreter stack limit. diff --git a/crates/interpreter/src/interpreter_action.rs b/crates/interpreter/src/interpreter_action.rs index 9beded2310..2bcde57ffa 100644 --- a/crates/interpreter/src/interpreter_action.rs +++ b/crates/interpreter/src/interpreter_action.rs @@ -6,7 +6,7 @@ mod eof_create_inputs; pub use call_inputs::{CallInputs, CallScheme, CallValue}; pub use call_outcome::CallOutcome; -pub use create_inputs::{CreateInputs, CreateScheme}; +pub use create_inputs::CreateInputs; pub use create_outcome::CreateOutcome; pub use eof_create_inputs::{EOFCreateInputs, EOFCreateKind}; diff --git a/crates/interpreter/src/interpreter_action/call_inputs.rs b/crates/interpreter/src/interpreter_action/call_inputs.rs index 7695bd8980..3adaa05e57 100644 --- a/crates/interpreter/src/interpreter_action/call_inputs.rs +++ b/crates/interpreter/src/interpreter_action/call_inputs.rs @@ -1,8 +1,7 @@ -use revm_primitives::Transaction; - -use crate::primitives::{Address, Bytes, TxKind, U256}; use core::ops::Range; +use primitives::{Address, Bytes, TxKind, U256}; use std::boxed::Box; +use wiring::Transaction; /// Inputs for a call. #[derive(Clone, Debug, PartialEq, Eq, Hash)] diff --git a/crates/interpreter/src/interpreter_action/call_outcome.rs b/crates/interpreter/src/interpreter_action/call_outcome.rs index f51c01fca7..3fc9f4b6b2 100644 --- a/crates/interpreter/src/interpreter_action/call_outcome.rs +++ b/crates/interpreter/src/interpreter_action/call_outcome.rs @@ -1,6 +1,6 @@ use crate::{Gas, InstructionResult, InterpreterResult}; use core::ops::Range; -use revm_primitives::Bytes; +use primitives::Bytes; /// Represents the outcome of a call operation in a virtual machine. /// diff --git a/crates/interpreter/src/interpreter_action/create_inputs.rs b/crates/interpreter/src/interpreter_action/create_inputs.rs index 151df91d21..5c333cca07 100644 --- a/crates/interpreter/src/interpreter_action/create_inputs.rs +++ b/crates/interpreter/src/interpreter_action/create_inputs.rs @@ -1,8 +1,6 @@ -use revm_primitives::Transaction; - -pub use crate::primitives::CreateScheme; -use crate::primitives::{Address, Bytes, TxKind, U256}; +use primitives::{Address, Bytes, TxKind, U256}; use std::boxed::Box; +use wiring::{default::CreateScheme, Transaction}; /// Inputs for a create call. #[derive(Clone, Debug, PartialEq, Eq, Hash)] diff --git a/crates/interpreter/src/interpreter_action/create_outcome.rs b/crates/interpreter/src/interpreter_action/create_outcome.rs index 5cdfcf41b8..76d4b44ddb 100644 --- a/crates/interpreter/src/interpreter_action/create_outcome.rs +++ b/crates/interpreter/src/interpreter_action/create_outcome.rs @@ -1,5 +1,5 @@ use crate::{Gas, InstructionResult, InterpreterResult}; -use revm_primitives::{Address, Bytes}; +use primitives::{Address, Bytes}; /// Represents the outcome of a create operation in an interpreter. /// diff --git a/crates/interpreter/src/interpreter_action/eof_create_inputs.rs b/crates/interpreter/src/interpreter_action/eof_create_inputs.rs index f63480d8bc..e0bfe51243 100644 --- a/crates/interpreter/src/interpreter_action/eof_create_inputs.rs +++ b/crates/interpreter/src/interpreter_action/eof_create_inputs.rs @@ -1,6 +1,6 @@ -use revm_primitives::EvmWiring; - -use crate::primitives::{Address, Bytes, Eof, Transaction, U256}; +use bytecode::Eof; +use primitives::{Address, Bytes, U256}; +use wiring::{EvmWiring, Transaction}; /// EOF create can be called from two places: /// * EOFCREATE opcode diff --git a/crates/interpreter/src/lib.rs b/crates/interpreter/src/lib.rs index 4564d0d198..fe9ff6c8e3 100644 --- a/crates/interpreter/src/lib.rs +++ b/crates/interpreter/src/lib.rs @@ -38,11 +38,9 @@ pub use interpreter::{ EMPTY_SHARED_MEMORY, STACK_LIMIT, }; pub use interpreter_action::{ - CallInputs, CallOutcome, CallScheme, CallValue, CreateInputs, CreateOutcome, CreateScheme, - EOFCreateInputs, EOFCreateKind, InterpreterAction, + CallInputs, CallOutcome, CallScheme, CallValue, CreateInputs, CreateOutcome, EOFCreateInputs, + EOFCreateKind, InterpreterAction, }; pub use opcode::{Instruction, OpCode, OPCODE_INFO_JUMPTABLE}; pub use primitives::{MAX_CODE_SIZE, MAX_INITCODE_SIZE}; - -#[doc(hidden)] -pub use revm_primitives as primitives; +pub use wiring::default::CreateScheme; diff --git a/crates/interpreter/src/opcode.rs b/crates/interpreter/src/opcode.rs index 587810f5d6..97b98b8c17 100644 --- a/crates/interpreter/src/opcode.rs +++ b/crates/interpreter/src/opcode.rs @@ -9,8 +9,9 @@ pub use tables::{ InstructionTables, }; -use crate::{instructions::*, primitives::Spec, Host}; +use crate::{instructions::*, Host}; use core::{fmt, ptr::NonNull}; +use specification::hardfork::Spec; /// An error indicating that an opcode is invalid. #[derive(Debug, PartialEq, Eq)] diff --git a/crates/interpreter/src/opcode/eof_printer.rs b/crates/interpreter/src/opcode/eof_printer.rs index e48f153dae..995da4be7a 100644 --- a/crates/interpreter/src/opcode/eof_printer.rs +++ b/crates/interpreter/src/opcode/eof_printer.rs @@ -2,7 +2,7 @@ pub fn print_eof_code(code: &[u8]) { use super::*; use crate::instructions::utility::read_i16; - use revm_primitives::hex; + use primitives::hex; // We can check validity and jump destinations in one pass. let mut i = 0; @@ -60,7 +60,7 @@ pub fn print_eof_code(code: &[u8]) { #[cfg(test)] mod test { use super::*; - use revm_primitives::hex; + use primitives::hex; #[test] fn sanity_test() { diff --git a/crates/interpreter/src/opcode/tables.rs b/crates/interpreter/src/opcode/tables.rs index a2a66bc218..d53a345d42 100644 --- a/crates/interpreter/src/opcode/tables.rs +++ b/crates/interpreter/src/opcode/tables.rs @@ -1,7 +1,8 @@ #![allow(clippy::wrong_self_convention)] use super::instruction; -use crate::{instructions::control, primitives::Spec, Host, Interpreter}; +use crate::{instructions::control, Host, Interpreter}; +use specification::hardfork::Spec; use std::boxed::Box; /// EVM opcode function signature. diff --git a/crates/optimism/Cargo.toml b/crates/optimism/Cargo.toml index 65a979b9f4..fbf7b0138f 100644 --- a/crates/optimism/Cargo.toml +++ b/crates/optimism/Cargo.toml @@ -23,10 +23,8 @@ all = "warn" [dependencies] # revm -revm = { path = "../revm", version = "14.0.1", default-features = false } -revm-precompile = { path = "../precompile", version = "11.0.1", default-features = false, features = [ - "secp256r1", -] } +revm.workspace = true +precompile = { workspace = true, features = ["secp256r1"] } # misc enumn = { version = "0.1" } @@ -47,11 +45,7 @@ alloy-sol-types = "0.8" [features] default = ["std", "c-kzg", "secp256k1", "portable", "blst"] -std = [ - "serde?/std", - "revm/std", - "revm-precompile/std", -] +std = ["serde?/std", "revm/std", "precompile/std"] hashbrown = ["revm/hashbrown"] serde = ["dep:serde", "revm/serde"] serde-json = ["serde", "revm/serde-json"] @@ -64,7 +58,6 @@ dev = [ "optional_eip3607", "optional_gas_refund", "optional_no_base_fee", - "optional_beneficiary_reward", ] memory_limit = ["revm/memory_limit"] optional_balance_check = ["revm/optional_balance_check"] @@ -72,7 +65,6 @@ optional_block_gas_limit = ["revm/optional_block_gas_limit"] optional_eip3607 = ["revm/optional_eip3607"] optional_gas_refund = ["revm/optional_gas_refund"] optional_no_base_fee = ["revm/optional_no_base_fee"] -optional_beneficiary_reward = ["revm/optional_beneficiary_reward"] # See comments in `revm-precompile` secp256k1 = ["revm/secp256k1"] diff --git a/crates/optimism/src/bn128.rs b/crates/optimism/src/bn128.rs index b61be4ac34..6603e70394 100644 --- a/crates/optimism/src/bn128.rs +++ b/crates/optimism/src/bn128.rs @@ -1,5 +1,5 @@ -use revm_precompile::{ - bn128, {Error, Precompile, PrecompileResult, PrecompileWithAddress}, +use precompile::{ + bn128, {Precompile, PrecompileError, PrecompileResult, PrecompileWithAddress}, }; pub(crate) mod pair { @@ -13,7 +13,7 @@ pub(crate) mod pair { pub(crate) fn run_pair(input: &[u8], gas_limit: u64) -> PrecompileResult { if input.len() > GRANITE_MAX_INPUT_SIZE { - return Err(Error::Bn128PairLength.into()); + return Err(PrecompileError::Bn128PairLength.into()); } bn128::run_pair( input, @@ -27,7 +27,7 @@ pub(crate) mod pair { #[cfg(test)] mod tests { use super::*; - use revm::primitives::{hex, PrecompileErrors}; + use revm::{precompile::PrecompileErrors, primitives::hex}; use std::vec; #[test] @@ -67,20 +67,23 @@ mod tests { let res = pair::run_pair(&input, 260_000); assert!(matches!( res, - Err(PrecompileErrors::Error(Error::Bn128PairLength)) + Err(PrecompileErrors::Error(PrecompileError::Bn128PairLength)) )); // valid input length shorter than 112687 let input = vec![1u8; 586 * bn128::PAIR_ELEMENT_LEN]; let res = pair::run_pair(&input, 260_000); - assert!(matches!(res, Err(PrecompileErrors::Error(Error::OutOfGas)))); + assert!(matches!( + res, + Err(PrecompileErrors::Error(PrecompileError::OutOfGas)) + )); // input length longer than 112687 let input = vec![1u8; 587 * bn128::PAIR_ELEMENT_LEN]; let res = pair::run_pair(&input, 260_000); assert!(matches!( res, - Err(PrecompileErrors::Error(Error::Bn128PairLength)) + Err(PrecompileErrors::Error(PrecompileError::Bn128PairLength)) )); } } diff --git a/crates/optimism/src/env.rs b/crates/optimism/src/env.rs index 15467030f0..520436baf4 100644 --- a/crates/optimism/src/env.rs +++ b/crates/optimism/src/env.rs @@ -1,6 +1,10 @@ -use revm::primitives::{ - AccessListItem, Address, AuthorizationList, Bytes, Transaction, TransactionValidation, TxKind, - B256, U256, +use revm::{ + primitives::{Address, Bytes, TxKind, B256, U256}, + specification::{eip2930::AccessListItem, eip7702::AuthorizationList}, + wiring::{ + default::TxEnv as EthTxEnv, + transaction::{Transaction, TransactionValidation}, + }, }; use super::{OptimismInvalidTransaction, OptimismTransaction}; @@ -10,7 +14,7 @@ use super::{OptimismInvalidTransaction, OptimismTransaction}; #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TxEnv { #[cfg_attr(feature = "serde", serde(flatten))] - pub base: revm::primitives::TxEnv, + pub base: EthTxEnv, /// The source hash is used to make sure that deposit transactions do /// not have identical hashes. diff --git a/crates/optimism/src/fast_lz.rs b/crates/optimism/src/fast_lz.rs index cdcaff5849..b0cef1fe43 100644 --- a/crates/optimism/src/fast_lz.rs +++ b/crates/optimism/src/fast_lz.rs @@ -109,8 +109,10 @@ mod tests { use alloy_sol_types::sol; use alloy_sol_types::SolCall; use revm::{ + bytecode::Bytecode, db::BenchmarkDB, - primitives::{address, bytes, Bytecode, Bytes, EthereumWiring, TxKind, U256}, + primitives::{address, bytes, Bytes, TxKind, U256}, + wiring::EthereumWiring, Evm, }; use std::vec::Vec; diff --git a/crates/optimism/src/handler_register.rs b/crates/optimism/src/handler_register.rs index 800ea1a210..495d81b638 100644 --- a/crates/optimism/src/handler_register.rs +++ b/crates/optimism/src/handler_register.rs @@ -7,15 +7,22 @@ use super::{ use crate::{BASE_FEE_RECIPIENT, L1_FEE_RECIPIENT}; use core::ops::Mul; use revm::{ + database_interface::Database, handler::{ mainnet::{self, deduct_caller_inner}, register::EvmHandler, }, interpreter::{return_ok, return_revert, Gas, InstructionResult}, precompile::{secp256r1, PrecompileSpecId}, - primitives::{ - db::Database, Account, Block, EVMError, EVMResult, EVMResultGeneric, EnvWiring, - ExecutionResult, HashMap, InvalidTransaction, ResultAndState, Transaction, U256, + primitives::{HashMap, U256}, + state::Account, + wiring::{ + default::EnvWiring, + result::{ + EVMError, EVMResult, EVMResultGeneric, ExecutionResult, InvalidTransaction, + ResultAndState, + }, + Block, Transaction, }, Context, ContextPrecompiles, FrameResult, }; @@ -423,9 +430,11 @@ mod tests { use super::*; use crate::{BedrockSpec, L1BlockInfo, LatestSpec, OptimismEvmWiring, RegolithSpec}; use revm::{ - db::{EmptyDB, InMemoryDB}, + database_interface::EmptyDB, + db::InMemoryDB, interpreter::{CallOutcome, InterpreterResult}, - primitives::{bytes, state::AccountInfo, Address, Bytes, B256}, + primitives::{bytes, Address, Bytes, B256}, + state::AccountInfo, }; use std::boxed::Box; diff --git a/crates/optimism/src/l1block.rs b/crates/optimism/src/l1block.rs index e8cf1973b2..5fdc9c794e 100644 --- a/crates/optimism/src/l1block.rs +++ b/crates/optimism/src/l1block.rs @@ -1,6 +1,9 @@ use crate::fast_lz::flz_compress_len; use core::ops::Mul; -use revm::primitives::{address, db::Database, Address, U256}; +use revm::{ + database_interface::Database, + primitives::{address, Address, U256}, +}; use super::OptimismSpecId; diff --git a/crates/optimism/src/lib.rs b/crates/optimism/src/lib.rs index c53a2a25db..3b602b6297 100644 --- a/crates/optimism/src/lib.rs +++ b/crates/optimism/src/lib.rs @@ -20,7 +20,10 @@ pub use handler_register::{ }; pub use l1block::{L1BlockInfo, BASE_FEE_RECIPIENT, L1_BLOCK_CONTRACT, L1_FEE_RECIPIENT}; pub use result::{OptimismHaltReason, OptimismInvalidTransaction}; -use revm::primitives::{Bytes, TransactionValidation, B256}; +use revm::{ + primitives::{Bytes, B256}, + wiring::TransactionValidation, +}; pub use spec::*; pub trait OptimismContext { diff --git a/crates/optimism/src/result.rs b/crates/optimism/src/result.rs index 63093fc9f5..80f724943b 100644 --- a/crates/optimism/src/result.rs +++ b/crates/optimism/src/result.rs @@ -1,5 +1,5 @@ use core::fmt::Display; -use revm::primitives::{EVMError, HaltReason, InvalidTransaction}; +use revm::wiring::result::{EVMError, HaltReason, InvalidTransaction}; /// Optimism transaction validation error. #[derive(Debug, Clone, PartialEq, Eq, Hash)] diff --git a/crates/optimism/src/spec.rs b/crates/optimism/src/spec.rs index 370e855f39..a8be1a6690 100644 --- a/crates/optimism/src/spec.rs +++ b/crates/optimism/src/spec.rs @@ -3,9 +3,12 @@ use crate::{ }; use core::marker::PhantomData; use revm::{ + database_interface::Database, handler::register::HandleRegisters, precompile::PrecompileSpecId, - primitives::{db::Database, BlockEnv, EvmWiring, Spec, SpecId}, + specification::hardfork::{Spec, SpecId}, + wiring::default::block::BlockEnv, + wiring::EvmWiring, EvmHandler, }; @@ -184,7 +187,7 @@ impl From for PrecompileSpecId { /// String identifiers for Optimism hardforks. pub mod id { // Re-export the Ethereum hardforks. - pub use revm::primitives::specification::id::*; + pub use revm::specification::hardfork::id::*; pub const BEDROCK: &str = "Bedrock"; pub const REGOLITH: &str = "Regolith"; diff --git a/crates/precompile/Cargo.toml b/crates/precompile/Cargo.toml index b29bac7aeb..a7d1baae69 100644 --- a/crates/precompile/Cargo.toml +++ b/crates/precompile/Cargo.toml @@ -22,8 +22,13 @@ rust_2018_idioms = "deny" all = "warn" [dependencies] -revm-primitives = { path = "../primitives", version = "9.0.1", default-features = false } -once_cell = { version = "1.20", default-features = false, features = ["alloc"] } +# revm +primitives.workspace = true +wiring.workspace = true +specification.workspace = true + +# static precompile sets. +once_cell = { version = "1.19", default-features = false, features = ["alloc"] } # ecRecover k256 = { version = "0.13.3", default-features = false, features = ["ecdsa"] } @@ -62,6 +67,7 @@ p256 = { version = "0.13.2", optional = true, default-features = false, features # utils cfg-if = { version = "1.0", default-features = false } +dyn-clone = "1.0" [dev-dependencies] criterion = "0.5" @@ -75,7 +81,7 @@ serde_derive = "1.0" [features] default = ["std", "c-kzg", "secp256k1", "portable", "blst"] std = [ - "revm-primitives/std", + "primitives/std", "k256/std", "once_cell/std", "ripemd/std", @@ -83,8 +89,8 @@ std = [ "c-kzg?/std", "secp256k1?/std", ] -hashbrown = ["revm-primitives/hashbrown"] -asm-keccak = ["revm-primitives/asm-keccak"] +hashbrown = ["primitives/hashbrown"] +asm-keccak = ["primitives/asm-keccak"] # Enables the p256verify precompile. secp256r1 = ["dep:p256"] @@ -92,11 +98,11 @@ secp256r1 = ["dep:p256"] # These libraries may not work on all no_std platforms as they depend on C. # Enables the KZG point evaluation precompile. -c-kzg = ["dep:c-kzg", "revm-primitives/c-kzg"] +c-kzg = ["dep:c-kzg", "wiring/c-kzg"] # `kzg-rs` is not audited but useful for `no_std` environment, use it with causing and default to `c-kzg` if possible. -kzg-rs = ["dep:kzg-rs", "revm-primitives/kzg-rs"] +kzg-rs = ["dep:kzg-rs", "wiring/kzg-rs"] -portable = ["revm-primitives/portable", "c-kzg?/portable"] +portable = ["c-kzg", "c-kzg?/portable"] # Use `secp256k1` as a faster alternative to `k256`. # The problem that `secp256k1` has is it fails to build for `wasm` target on Windows and Mac as it is c lib. diff --git a/crates/precompile/benches/bench.rs b/crates/precompile/benches/bench.rs index 366b6331a2..c480862c2d 100644 --- a/crates/precompile/benches/bench.rs +++ b/crates/precompile/benches/bench.rs @@ -1,4 +1,5 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use primitives::{hex, keccak256, U256, VERSIONED_HASH_VERSION_KZG}; use revm_precompile::{ bn128::{ add::ISTANBUL_ADD_GAS_COST, @@ -9,9 +10,9 @@ use revm_precompile::{ secp256k1::ec_recover_run, Bytes, }; -use revm_primitives::{hex, keccak256, CfgEnv, U256, VERSIONED_HASH_VERSION_KZG}; use secp256k1::{Message, SecretKey, SECP256K1}; use sha2::{Digest, Sha256}; +use wiring::default::CfgEnv; /// Benchmarks different cryptography-related precompiles. pub fn benchmark_crypto_precompiles(c: &mut Criterion) { diff --git a/crates/precompile/src/blake2.rs b/crates/precompile/src/blake2.rs index 6ecf55bebe..bf22b019a7 100644 --- a/crates/precompile/src/blake2.rs +++ b/crates/precompile/src/blake2.rs @@ -1,5 +1,7 @@ -use crate::{Error, Precompile, PrecompileResult, PrecompileWithAddress}; -use revm_primitives::{Bytes, PrecompileOutput}; +use crate::{ + Precompile, PrecompileError, PrecompileOutput, PrecompileResult, PrecompileWithAddress, +}; +use primitives::Bytes; const F_ROUND: u64 = 1; const INPUT_LENGTH: usize = 213; @@ -14,20 +16,20 @@ pub fn run(input: &Bytes, gas_limit: u64) -> PrecompileResult { let input = &input[..]; if input.len() != INPUT_LENGTH { - return Err(Error::Blake2WrongLength.into()); + return Err(PrecompileError::Blake2WrongLength.into()); } // rounds 4 bytes let rounds = u32::from_be_bytes(input[..4].try_into().unwrap()) as usize; let gas_used = rounds as u64 * F_ROUND; if gas_used > gas_limit { - return Err(Error::OutOfGas.into()); + return Err(PrecompileError::OutOfGas.into()); } let f = match input[212] { 1 => true, 0 => false, - _ => return Err(Error::Blake2WrongFinalIndicatorFlag.into()), + _ => return Err(PrecompileError::Blake2WrongFinalIndicatorFlag.into()), }; let mut h = [0u64; 8]; diff --git a/crates/precompile/src/bls12_381.rs b/crates/precompile/src/bls12_381.rs index 75e774ded4..b329829864 100644 --- a/crates/precompile/src/bls12_381.rs +++ b/crates/precompile/src/bls12_381.rs @@ -42,8 +42,9 @@ mod test { use super::map_fp_to_g1; use super::msm::msm_required_gas; use super::pairing; + use crate::PrecompileResult; use eyre::Result; - use revm_primitives::{hex::FromHex, Bytes, PrecompileResult}; + use primitives::{hex::FromHex, Bytes}; use rstest::rstest; use serde_derive::{Deserialize, Serialize}; use std::{fs, path::Path}; @@ -109,9 +110,8 @@ mod test { let Some(gas) = vector.gas else { panic!("gas is missing in {test_name}"); }; - let outcome = res.unwrap_or_else(|e: revm_primitives::PrecompileErrors| { - panic!("precompile call failed for {test_name}: {e}") - }); + let outcome = + res.unwrap_or_else(|e| panic!("precompile call failed for {test_name}: {e}")); assert_eq!( gas, outcome.gas_used, "expected gas: {}, actual gas: {} in {test_name}", diff --git a/crates/precompile/src/bls12_381/g1.rs b/crates/precompile/src/bls12_381/g1.rs index 30374b9688..dc6ac01e70 100644 --- a/crates/precompile/src/bls12_381/g1.rs +++ b/crates/precompile/src/bls12_381/g1.rs @@ -1,6 +1,7 @@ use super::utils::{fp_from_bendian, fp_to_bytes, remove_padding, PADDED_FP_LENGTH}; -use crate::primitives::{Bytes, PrecompileError}; +use crate::PrecompileError; use blst::{blst_p1_affine, blst_p1_affine_in_g1, blst_p1_affine_on_curve}; +use primitives::Bytes; /// Length of each of the elements in a g1 operation input. pub(super) const G1_INPUT_ITEM_LENGTH: usize = 128; diff --git a/crates/precompile/src/bls12_381/g1_add.rs b/crates/precompile/src/bls12_381/g1_add.rs index da671aab49..f1b4d628c1 100644 --- a/crates/precompile/src/bls12_381/g1_add.rs +++ b/crates/precompile/src/bls12_381/g1_add.rs @@ -1,9 +1,10 @@ use super::g1::{encode_g1_point, extract_g1_input, G1_INPUT_ITEM_LENGTH}; use crate::{u64_to_address, PrecompileWithAddress}; +use crate::{Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; use blst::{ blst_p1, blst_p1_add_or_double_affine, blst_p1_affine, blst_p1_from_affine, blst_p1_to_affine, }; -use revm_primitives::{Bytes, Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; +use primitives::Bytes; /// [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537#specification) BLS12_G1ADD precompile. pub const PRECOMPILE: PrecompileWithAddress = diff --git a/crates/precompile/src/bls12_381/g1_msm.rs b/crates/precompile/src/bls12_381/g1_msm.rs index b62077c6c6..0d1d4cdadb 100644 --- a/crates/precompile/src/bls12_381/g1_msm.rs +++ b/crates/precompile/src/bls12_381/g1_msm.rs @@ -5,8 +5,9 @@ use super::{ utils::{extract_scalar_input, NBITS, SCALAR_LENGTH}, }; use crate::{u64_to_address, PrecompileWithAddress}; +use crate::{Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; use blst::{blst_p1, blst_p1_affine, blst_p1_from_affine, blst_p1_to_affine, p1_affines}; -use revm_primitives::{Bytes, Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; +use primitives::Bytes; /// [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537#specification) BLS12_G1MSM precompile. pub const PRECOMPILE: PrecompileWithAddress = diff --git a/crates/precompile/src/bls12_381/g1_mul.rs b/crates/precompile/src/bls12_381/g1_mul.rs index aee9524448..fbc3b28013 100644 --- a/crates/precompile/src/bls12_381/g1_mul.rs +++ b/crates/precompile/src/bls12_381/g1_mul.rs @@ -3,8 +3,9 @@ use super::{ utils::{extract_scalar_input, NBITS}, }; use crate::{u64_to_address, PrecompileWithAddress}; +use crate::{Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; use blst::{blst_p1, blst_p1_affine, blst_p1_from_affine, blst_p1_mult, blst_p1_to_affine}; -use revm_primitives::{Bytes, Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; +use primitives::Bytes; /// [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537#specification) BLS12_G1MUL precompile. pub const PRECOMPILE: PrecompileWithAddress = diff --git a/crates/precompile/src/bls12_381/g2.rs b/crates/precompile/src/bls12_381/g2.rs index c6520c6464..53fedbe071 100644 --- a/crates/precompile/src/bls12_381/g2.rs +++ b/crates/precompile/src/bls12_381/g2.rs @@ -1,6 +1,7 @@ use super::utils::{fp_from_bendian, fp_to_bytes, remove_padding, FP_LENGTH, PADDED_FP_LENGTH}; -use crate::primitives::{Bytes, PrecompileError}; +use crate::PrecompileError; use blst::{blst_fp2, blst_p2_affine, blst_p2_affine_in_g2, blst_p2_affine_on_curve}; +use primitives::Bytes; /// Length of each of the elements in a g2 operation input. pub(super) const G2_INPUT_ITEM_LENGTH: usize = 256; diff --git a/crates/precompile/src/bls12_381/g2_add.rs b/crates/precompile/src/bls12_381/g2_add.rs index 9b1e26f184..6fd03df38b 100644 --- a/crates/precompile/src/bls12_381/g2_add.rs +++ b/crates/precompile/src/bls12_381/g2_add.rs @@ -1,9 +1,10 @@ use super::g2::{encode_g2_point, extract_g2_input, G2_INPUT_ITEM_LENGTH}; use crate::{u64_to_address, PrecompileWithAddress}; +use crate::{Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; use blst::{ blst_p2, blst_p2_add_or_double_affine, blst_p2_affine, blst_p2_from_affine, blst_p2_to_affine, }; -use revm_primitives::{Bytes, Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; +use primitives::Bytes; /// [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537#specification) BLS12_G2ADD precompile. pub const PRECOMPILE: PrecompileWithAddress = diff --git a/crates/precompile/src/bls12_381/g2_msm.rs b/crates/precompile/src/bls12_381/g2_msm.rs index 456a66517b..b28be86543 100644 --- a/crates/precompile/src/bls12_381/g2_msm.rs +++ b/crates/precompile/src/bls12_381/g2_msm.rs @@ -5,8 +5,9 @@ use super::{ utils::{extract_scalar_input, NBITS, SCALAR_LENGTH}, }; use crate::{u64_to_address, PrecompileWithAddress}; +use crate::{Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; use blst::{blst_p2, blst_p2_affine, blst_p2_from_affine, blst_p2_to_affine, p2_affines}; -use revm_primitives::{Bytes, Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; +use primitives::Bytes; /// [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537#specification) BLS12_G2MSM precompile. pub const PRECOMPILE: PrecompileWithAddress = diff --git a/crates/precompile/src/bls12_381/g2_mul.rs b/crates/precompile/src/bls12_381/g2_mul.rs index e39edf0751..e64af370a5 100644 --- a/crates/precompile/src/bls12_381/g2_mul.rs +++ b/crates/precompile/src/bls12_381/g2_mul.rs @@ -3,8 +3,9 @@ use super::{ utils::{extract_scalar_input, NBITS}, }; use crate::{u64_to_address, PrecompileWithAddress}; +use crate::{Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; use blst::{blst_p2, blst_p2_affine, blst_p2_from_affine, blst_p2_mult, blst_p2_to_affine}; -use revm_primitives::{Bytes, Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; +use primitives::Bytes; /// [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537#specification) BLS12_G2MUL precompile. pub const PRECOMPILE: PrecompileWithAddress = diff --git a/crates/precompile/src/bls12_381/map_fp2_to_g2.rs b/crates/precompile/src/bls12_381/map_fp2_to_g2.rs index 584008ec62..8abdcfd925 100644 --- a/crates/precompile/src/bls12_381/map_fp2_to_g2.rs +++ b/crates/precompile/src/bls12_381/map_fp2_to_g2.rs @@ -4,8 +4,9 @@ use super::{ utils::{remove_padding, PADDED_FP2_LENGTH, PADDED_FP_LENGTH}, }; use crate::{u64_to_address, PrecompileWithAddress}; +use crate::{Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; use blst::{blst_map_to_g2, blst_p2, blst_p2_affine, blst_p2_to_affine}; -use revm_primitives::{Bytes, Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; +use primitives::Bytes; /// [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537#specification) BLS12_MAP_FP2_TO_G2 precompile. pub const PRECOMPILE: PrecompileWithAddress = diff --git a/crates/precompile/src/bls12_381/map_fp_to_g1.rs b/crates/precompile/src/bls12_381/map_fp_to_g1.rs index b92df60a18..330d399622 100644 --- a/crates/precompile/src/bls12_381/map_fp_to_g1.rs +++ b/crates/precompile/src/bls12_381/map_fp_to_g1.rs @@ -3,8 +3,9 @@ use super::{ utils::{fp_from_bendian, remove_padding, PADDED_FP_LENGTH}, }; use crate::{u64_to_address, PrecompileWithAddress}; +use crate::{Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; use blst::{blst_map_to_g1, blst_p1, blst_p1_affine, blst_p1_to_affine}; -use revm_primitives::{Bytes, Precompile, PrecompileError, PrecompileOutput, PrecompileResult}; +use primitives::Bytes; /// [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537#specification) BLS12_MAP_FP_TO_G1 precompile. pub const PRECOMPILE: PrecompileWithAddress = diff --git a/crates/precompile/src/bls12_381/pairing.rs b/crates/precompile/src/bls12_381/pairing.rs index a786a8b7dc..a54af3dc76 100644 --- a/crates/precompile/src/bls12_381/pairing.rs +++ b/crates/precompile/src/bls12_381/pairing.rs @@ -2,11 +2,12 @@ use super::{ g1::{extract_g1_input, G1_INPUT_ITEM_LENGTH}, g2::{extract_g2_input, G2_INPUT_ITEM_LENGTH}, }; -use crate::{u64_to_address, PrecompileWithAddress}; -use blst::{blst_final_exp, blst_fp12, blst_fp12_is_one, blst_fp12_mul, blst_miller_loop}; -use revm_primitives::{ - Bytes, Precompile, PrecompileError, PrecompileOutput, PrecompileResult, B256, +use crate::{ + u64_to_address, Precompile, PrecompileError, PrecompileOutput, PrecompileResult, + PrecompileWithAddress, }; +use blst::{blst_final_exp, blst_fp12, blst_fp12_is_one, blst_fp12_mul, blst_miller_loop}; +use primitives::{Bytes, B256}; /// [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537#specification) BLS12_PAIRING precompile. pub const PRECOMPILE: PrecompileWithAddress = diff --git a/crates/precompile/src/bls12_381/utils.rs b/crates/precompile/src/bls12_381/utils.rs index b576fcc53f..259d581d85 100644 --- a/crates/precompile/src/bls12_381/utils.rs +++ b/crates/precompile/src/bls12_381/utils.rs @@ -1,8 +1,8 @@ +use crate::PrecompileError; use blst::{ blst_bendian_from_fp, blst_fp, blst_fp_from_bendian, blst_scalar, blst_scalar_from_bendian, }; use core::cmp::Ordering; -use revm_primitives::PrecompileError; /// Number of bits used in the BLS12-381 curve finite field elements. pub(super) const NBITS: usize = 256; diff --git a/crates/precompile/src/bn128.rs b/crates/precompile/src/bn128.rs index 416a41672f..c98ada1d2c 100644 --- a/crates/precompile/src/bn128.rs +++ b/crates/precompile/src/bn128.rs @@ -1,9 +1,9 @@ use crate::{ utilities::{bool_to_bytes32, right_pad}, - Address, Error, Precompile, PrecompileResult, PrecompileWithAddress, + Address, Precompile, PrecompileError, PrecompileOutput, PrecompileResult, + PrecompileWithAddress, }; use bn::{AffineG1, AffineG2, Fq, Fq2, Group, Gt, G1, G2}; -use revm_primitives::PrecompileOutput; use std::vec::Vec; pub mod add { @@ -95,8 +95,8 @@ pub const PAIR_ELEMENT_LEN: usize = 64 + 128; /// /// Panics if the input is not at least 32 bytes long. #[inline] -pub fn read_fq(input: &[u8]) -> Result { - Fq::from_slice(&input[..32]).map_err(|_| Error::Bn128FieldPointNotAMember) +pub fn read_fq(input: &[u8]) -> Result { + Fq::from_slice(&input[..32]).map_err(|_| PrecompileError::Bn128FieldPointNotAMember) } /// Reads the `x` and `y` points from the input slice. @@ -105,26 +105,26 @@ pub fn read_fq(input: &[u8]) -> Result { /// /// Panics if the input is not at least 64 bytes long. #[inline] -pub fn read_point(input: &[u8]) -> Result { +pub fn read_point(input: &[u8]) -> Result { let px = read_fq(&input[0..32])?; let py = read_fq(&input[32..64])?; new_g1_point(px, py) } /// Creates a new `G1` point from the given `x` and `y` coordinates. -pub fn new_g1_point(px: Fq, py: Fq) -> Result { +pub fn new_g1_point(px: Fq, py: Fq) -> Result { if px == Fq::zero() && py == Fq::zero() { Ok(G1::zero()) } else { AffineG1::new(px, py) .map(Into::into) - .map_err(|_| Error::Bn128AffineGFailedToCreate) + .map_err(|_| PrecompileError::Bn128AffineGFailedToCreate) } } pub fn run_add(input: &[u8], gas_cost: u64, gas_limit: u64) -> PrecompileResult { if gas_cost > gas_limit { - return Err(Error::OutOfGas.into()); + return Err(PrecompileError::OutOfGas.into()); } let input = right_pad::(input); @@ -142,7 +142,7 @@ pub fn run_add(input: &[u8], gas_cost: u64, gas_limit: u64) -> PrecompileResult pub fn run_mul(input: &[u8], gas_cost: u64, gas_limit: u64) -> PrecompileResult { if gas_cost > gas_limit { - return Err(Error::OutOfGas.into()); + return Err(PrecompileError::OutOfGas.into()); } let input = right_pad::(input); @@ -168,11 +168,11 @@ pub fn run_pair( ) -> PrecompileResult { let gas_used = (input.len() / PAIR_ELEMENT_LEN) as u64 * pair_per_point_cost + pair_base_cost; if gas_used > gas_limit { - return Err(Error::OutOfGas.into()); + return Err(PrecompileError::OutOfGas.into()); } if input.len() % PAIR_ELEMENT_LEN != 0 { - return Err(Error::Bn128PairLength.into()); + return Err(PrecompileError::Bn128PairLength.into()); } let success = if input.is_empty() { @@ -190,7 +190,7 @@ pub fn run_pair( // SAFETY: We're reading `6 * 32 == PAIR_ELEMENT_LEN` bytes from `input[idx..]` // per iteration. This is guaranteed to be in-bounds. let slice = unsafe { input.get_unchecked(start..start + 32) }; - Fq::from_slice(slice).map_err(|_| Error::Bn128FieldPointNotAMember) + Fq::from_slice(slice).map_err(|_| PrecompileError::Bn128FieldPointNotAMember) }; let ax = read_fq_at(0)?; let ay = read_fq_at(1)?; @@ -207,7 +207,10 @@ pub fn run_pair( if ba.is_zero() && bb.is_zero() { G2::zero() } else { - G2::from(AffineG2::new(ba, bb).map_err(|_| Error::Bn128AffineGFailedToCreate)?) + G2::from( + AffineG2::new(ba, bb) + .map_err(|_| PrecompileError::Bn128AffineGFailedToCreate)?, + ) } }; @@ -223,10 +226,15 @@ pub fn run_pair( #[cfg(test)] mod tests { - use crate::bn128::add::BYZANTIUM_ADD_GAS_COST; - use crate::bn128::mul::BYZANTIUM_MUL_GAS_COST; - use crate::bn128::pair::{BYZANTIUM_PAIR_BASE, BYZANTIUM_PAIR_PER_POINT}; - use revm_primitives::{hex, PrecompileErrors}; + use crate::{ + bn128::{ + add::BYZANTIUM_ADD_GAS_COST, + mul::BYZANTIUM_MUL_GAS_COST, + pair::{BYZANTIUM_PAIR_BASE, BYZANTIUM_PAIR_PER_POINT}, + }, + PrecompileError, PrecompileErrors, + }; + use primitives::hex; use super::*; @@ -281,7 +289,10 @@ mod tests { let res = run_add(&input, BYZANTIUM_ADD_GAS_COST, 499); println!("{:?}", res); - assert!(matches!(res, Err(PrecompileErrors::Error(Error::OutOfGas)))); + assert!(matches!( + res, + Err(PrecompileErrors::Error(PrecompileError::OutOfGas)) + )); // no input test let input = [0u8; 0]; @@ -308,7 +319,9 @@ mod tests { let res = run_add(&input, BYZANTIUM_ADD_GAS_COST, 500); assert!(matches!( res, - Err(PrecompileErrors::Error(Error::Bn128AffineGFailedToCreate)) + Err(PrecompileErrors::Error( + PrecompileError::Bn128AffineGFailedToCreate + )) )); } @@ -341,7 +354,10 @@ mod tests { .unwrap(); let res = run_mul(&input, BYZANTIUM_MUL_GAS_COST, 39_999); - assert!(matches!(res, Err(PrecompileErrors::Error(Error::OutOfGas)))); + assert!(matches!( + res, + Err(PrecompileErrors::Error(PrecompileError::OutOfGas)) + )); // zero multiplication test let input = hex::decode( @@ -385,7 +401,9 @@ mod tests { let res = run_mul(&input, BYZANTIUM_MUL_GAS_COST, 40_000); assert!(matches!( res, - Err(PrecompileErrors::Error(Error::Bn128AffineGFailedToCreate)) + Err(PrecompileErrors::Error( + PrecompileError::Bn128AffineGFailedToCreate + )) )); } @@ -444,7 +462,10 @@ mod tests { BYZANTIUM_PAIR_BASE, 259_999, ); - assert!(matches!(res, Err(PrecompileErrors::Error(Error::OutOfGas)))); + assert!(matches!( + res, + Err(PrecompileErrors::Error(PrecompileError::OutOfGas)) + )); // no input test let input = [0u8; 0]; @@ -481,7 +502,9 @@ mod tests { ); assert!(matches!( res, - Err(PrecompileErrors::Error(Error::Bn128AffineGFailedToCreate)) + Err(PrecompileErrors::Error( + PrecompileError::Bn128AffineGFailedToCreate + )) )); // invalid input length @@ -502,7 +525,7 @@ mod tests { ); assert!(matches!( res, - Err(PrecompileErrors::Error(Error::Bn128PairLength)) + Err(PrecompileErrors::Error(PrecompileError::Bn128PairLength)) )); } } diff --git a/crates/precompile/src/fatal_precompile.rs b/crates/precompile/src/fatal_precompile.rs index 8a01cd58a1..67780caec6 100644 --- a/crates/precompile/src/fatal_precompile.rs +++ b/crates/precompile/src/fatal_precompile.rs @@ -1,8 +1,9 @@ -use crate::primitives::{ - Address, Bytes, CfgEnv, Precompile, PrecompileErrors, PrecompileResult, StatefulPrecompile, +use crate::primitives::{Address, Bytes}; +use crate::{ + Precompile, PrecompileErrors, PrecompileResult, PrecompileWithAddress, StatefulPrecompile, }; -use crate::PrecompileWithAddress; use std::{string::String, sync::Arc}; +use wiring::default::CfgEnv; /// Disable kzg precompile. This will return Fatal error on precompile call pub fn fatal_precompile(address: Address, msg: String) -> PrecompileWithAddress { diff --git a/crates/precompile/src/hash.rs b/crates/precompile/src/hash.rs index 1ea5e73dfc..cad78606d6 100644 --- a/crates/precompile/src/hash.rs +++ b/crates/precompile/src/hash.rs @@ -1,6 +1,8 @@ use super::calc_linear_cost_u32; -use crate::{Error, Precompile, PrecompileResult, PrecompileWithAddress}; -use revm_primitives::{Bytes, PrecompileOutput}; +use crate::{ + Precompile, PrecompileError, PrecompileOutput, PrecompileResult, PrecompileWithAddress, +}; +use primitives::Bytes; use sha2::Digest; pub const SHA256: PrecompileWithAddress = @@ -20,7 +22,7 @@ pub const RIPEMD160: PrecompileWithAddress = PrecompileWithAddress( pub fn sha256_run(input: &Bytes, gas_limit: u64) -> PrecompileResult { let cost = calc_linear_cost_u32(input.len(), 60, 12); if cost > gas_limit { - Err(Error::OutOfGas.into()) + Err(PrecompileError::OutOfGas.into()) } else { let output = sha2::Sha256::digest(input); Ok(PrecompileOutput::new(cost, output.to_vec().into())) @@ -36,7 +38,7 @@ pub fn sha256_run(input: &Bytes, gas_limit: u64) -> PrecompileResult { pub fn ripemd160_run(input: &Bytes, gas_limit: u64) -> PrecompileResult { let gas_used = calc_linear_cost_u32(input.len(), 600, 120); if gas_used > gas_limit { - Err(Error::OutOfGas.into()) + Err(PrecompileError::OutOfGas.into()) } else { let mut hasher = ripemd::Ripemd160::new(); hasher.update(input); diff --git a/crates/precompile/src/identity.rs b/crates/precompile/src/identity.rs index ab869cd047..420813a0ab 100644 --- a/crates/precompile/src/identity.rs +++ b/crates/precompile/src/identity.rs @@ -1,6 +1,8 @@ use super::calc_linear_cost_u32; -use crate::{Error, Precompile, PrecompileResult, PrecompileWithAddress}; -use revm_primitives::{Bytes, PrecompileOutput}; +use crate::{ + Precompile, PrecompileError, PrecompileOutput, PrecompileResult, PrecompileWithAddress, +}; +use primitives::Bytes; pub const FUN: PrecompileWithAddress = PrecompileWithAddress(crate::u64_to_address(4), Precompile::Standard(identity_run)); @@ -17,7 +19,7 @@ pub const IDENTITY_PER_WORD: u64 = 3; pub fn identity_run(input: &Bytes, gas_limit: u64) -> PrecompileResult { let gas_used = calc_linear_cost_u32(input.len(), IDENTITY_BASE, IDENTITY_PER_WORD); if gas_used > gas_limit { - return Err(Error::OutOfGas.into()); + return Err(PrecompileError::OutOfGas.into()); } Ok(PrecompileOutput::new(gas_used, input.clone())) } diff --git a/crates/precompile/src/interface.rs b/crates/precompile/src/interface.rs new file mode 100644 index 0000000000..c73e89280e --- /dev/null +++ b/crates/precompile/src/interface.rs @@ -0,0 +1,250 @@ +use core::fmt; +use dyn_clone::DynClone; +use primitives::Bytes; +use std::{boxed::Box, string::String, sync::Arc}; +use wiring::default::CfgEnv; + +/// A precompile operation result. +/// +/// Returns either `Ok((gas_used, return_bytes))` or `Err(error)`. +pub type PrecompileResult = Result; + +/// Precompile execution output +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub struct PrecompileOutput { + /// Gas used by the precompile. + pub gas_used: u64, + /// Output bytes. + pub bytes: Bytes, +} + +impl PrecompileOutput { + /// Returns new precompile output with the given gas used and output bytes. + pub fn new(gas_used: u64, bytes: Bytes) -> Self { + Self { gas_used, bytes } + } +} + +pub type StandardPrecompileFn = fn(&Bytes, u64) -> PrecompileResult; +pub type EnvPrecompileFn = fn(&Bytes, u64, env: &CfgEnv) -> PrecompileResult; + +/// Stateful precompile trait. It is used to create +/// a arc precompile Precompile::Stateful. +pub trait StatefulPrecompile: Sync + Send { + fn call(&self, bytes: &Bytes, gas_limit: u64, env: &CfgEnv) -> PrecompileResult; +} + +/// Mutable stateful precompile trait. It is used to create +/// a boxed precompile in Precompile::StatefulMut. +pub trait StatefulPrecompileMut: DynClone + Send + Sync { + fn call_mut(&mut self, bytes: &Bytes, gas_limit: u64, env: &CfgEnv) -> PrecompileResult; +} + +dyn_clone::clone_trait_object!(StatefulPrecompileMut); + +/// Arc over stateful precompile. +pub type StatefulPrecompileArc = Arc; + +/// Box over mutable stateful precompile +pub type StatefulPrecompileBox = Box; + +/// Precompile and its handlers. +#[derive(Clone)] +pub enum Precompile { + /// Standard simple precompile that takes input and gas limit. + Standard(StandardPrecompileFn), + /// Similar to Standard but takes reference to [`CfgEnv`]. + Env(EnvPrecompileFn), + /// Stateful precompile that is Arc over [`StatefulPrecompile`] trait. + /// It takes a reference to input, gas limit and [`CfgEnv`]. + Stateful(StatefulPrecompileArc), + /// Mutable stateful precompile that is Box over [`StatefulPrecompileMut`] trait. + /// It takes a reference to input, gas limit and [`CfgEnv`]. + StatefulMut(StatefulPrecompileBox), +} + +impl From for Precompile { + fn from(p: StandardPrecompileFn) -> Self { + Precompile::Standard(p) + } +} + +impl From for Precompile { + fn from(p: EnvPrecompileFn) -> Self { + Precompile::Env(p) + } +} + +impl From for Precompile { + fn from(p: StatefulPrecompileArc) -> Self { + Precompile::Stateful(p) + } +} + +impl From for Precompile { + fn from(p: StatefulPrecompileBox) -> Self { + Precompile::StatefulMut(p) + } +} + +impl fmt::Debug for Precompile { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Precompile::Standard(_) => f.write_str("Standard"), + Precompile::Env(_) => f.write_str("Env"), + Precompile::Stateful(_) => f.write_str("Stateful"), + Precompile::StatefulMut(_) => f.write_str("StatefulMut"), + } + } +} + +impl Precompile { + /// Create a new stateful precompile. + pub fn new_stateful(p: P) -> Self { + Self::Stateful(Arc::new(p)) + } + + /// Create a new mutable stateful precompile. + pub fn new_stateful_mut(p: P) -> Self { + Self::StatefulMut(Box::new(p)) + } + + /// Call the precompile with the given input and gas limit and return the result. + pub fn call(&mut self, bytes: &Bytes, gas_limit: u64, env: &CfgEnv) -> PrecompileResult { + match *self { + Precompile::Standard(p) => p(bytes, gas_limit), + Precompile::Env(p) => p(bytes, gas_limit, env), + Precompile::Stateful(ref p) => p.call(bytes, gas_limit, env), + Precompile::StatefulMut(ref mut p) => p.call_mut(bytes, gas_limit, env), + } + } + + /// Call the precompile with the given input and gas limit and return the result. + /// + /// Returns an error if the precompile is mutable. + pub fn call_ref(&self, bytes: &Bytes, gas_limit: u64, env: &CfgEnv) -> PrecompileResult { + match *self { + Precompile::Standard(p) => p(bytes, gas_limit), + Precompile::Env(p) => p(bytes, gas_limit, env), + Precompile::Stateful(ref p) => p.call(bytes, gas_limit, env), + Precompile::StatefulMut(_) => Err(PrecompileErrors::Fatal { + msg: "call_ref on mutable stateful precompile".into(), + }), + } + } +} + +/// Precompile errors. +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub enum PrecompileErrors { + Error(PrecompileError), + Fatal { msg: String }, +} + +impl core::error::Error for PrecompileErrors {} + +impl fmt::Display for PrecompileErrors { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Error(e) => e.fmt(f), + Self::Fatal { msg } => f.write_str(msg), + } + } +} + +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub enum PrecompileError { + /// out of gas is the main error. Others are here just for completeness + OutOfGas, + // Blake2 errors + Blake2WrongLength, + Blake2WrongFinalIndicatorFlag, + // Modexp errors + ModexpExpOverflow, + ModexpBaseOverflow, + ModexpModOverflow, + // Bn128 errors + Bn128FieldPointNotAMember, + Bn128AffineGFailedToCreate, + Bn128PairLength, + // Blob errors + /// The input length is not exactly 192 bytes. + BlobInvalidInputLength, + /// The commitment does not match the versioned hash. + BlobMismatchedVersion, + /// The proof verification failed. + BlobVerifyKzgProofFailed, + /// Catch-all variant for other errors. + Other(String), +} + +impl PrecompileError { + /// Returns an other error with the given message. + pub fn other(err: impl Into) -> Self { + Self::Other(err.into()) + } + + /// Returns true if the error is out of gas. + pub fn is_oog(&self) -> bool { + matches!(self, Self::OutOfGas) + } +} + +impl From for PrecompileErrors { + fn from(err: PrecompileError) -> Self { + PrecompileErrors::Error(err) + } +} + +impl core::error::Error for PrecompileError {} + +impl fmt::Display for PrecompileError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let s = match self { + Self::OutOfGas => "out of gas", + Self::Blake2WrongLength => "wrong input length for blake2", + Self::Blake2WrongFinalIndicatorFlag => "wrong final indicator flag for blake2", + Self::ModexpExpOverflow => "modexp exp overflow", + Self::ModexpBaseOverflow => "modexp base overflow", + Self::ModexpModOverflow => "modexp mod overflow", + Self::Bn128FieldPointNotAMember => "field point not a member of bn128 curve", + Self::Bn128AffineGFailedToCreate => "failed to create affine g point for bn128 curve", + Self::Bn128PairLength => "bn128 invalid pair length", + Self::BlobInvalidInputLength => "invalid blob input length", + Self::BlobMismatchedVersion => "mismatched blob version", + Self::BlobVerifyKzgProofFailed => "verifying blob kzg proof failed", + Self::Other(s) => s, + }; + f.write_str(s) + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn stateful_precompile_mut() { + #[derive(Default, Clone)] + struct MyPrecompile {} + + impl StatefulPrecompileMut for MyPrecompile { + fn call_mut( + &mut self, + _bytes: &Bytes, + _gas_limit: u64, + _env: &CfgEnv, + ) -> PrecompileResult { + Err(PrecompileError::OutOfGas.into()) + } + } + + let mut p = Precompile::new_stateful_mut(MyPrecompile::default()); + match &mut p { + Precompile::StatefulMut(p) => { + let _ = p.call_mut(&Bytes::new(), 0, &CfgEnv::default()); + } + _ => panic!("not a state"), + } + } +} diff --git a/crates/precompile/src/kzg_point_evaluation.rs b/crates/precompile/src/kzg_point_evaluation.rs index 98c4fe10d3..37eea7061d 100644 --- a/crates/precompile/src/kzg_point_evaluation.rs +++ b/crates/precompile/src/kzg_point_evaluation.rs @@ -1,4 +1,6 @@ -use crate::{Address, Error, Precompile, PrecompileResult, PrecompileWithAddress}; +use crate::{ + Address, Precompile, PrecompileError, PrecompileOutput, PrecompileResult, PrecompileWithAddress, +}; cfg_if::cfg_if! { if #[cfg(feature = "c-kzg")] { use c_kzg::{Bytes32, Bytes48, KzgProof, KzgSettings}; @@ -6,8 +8,9 @@ cfg_if::cfg_if! { use kzg_rs::{Bytes32, Bytes48, KzgProof, KzgSettings}; } } -use revm_primitives::{hex_literal::hex, Bytes, CfgEnv, PrecompileOutput}; +use primitives::{hex_literal::hex, Bytes}; use sha2::{Digest, Sha256}; +use wiring::default::CfgEnv; pub const POINT_EVALUATION: PrecompileWithAddress = PrecompileWithAddress(ADDRESS, Precompile::Env(run)); @@ -32,19 +35,19 @@ pub const RETURN_VALUE: &[u8; 64] = &hex!( /// with z and y being padded 32 byte big endian values pub fn run(input: &Bytes, gas_limit: u64, cfg: &CfgEnv) -> PrecompileResult { if gas_limit < GAS_COST { - return Err(Error::OutOfGas.into()); + return Err(PrecompileError::OutOfGas.into()); } // Verify input length. if input.len() != 192 { - return Err(Error::BlobInvalidInputLength.into()); + return Err(PrecompileError::BlobInvalidInputLength.into()); } // Verify commitment matches versioned_hash let versioned_hash = &input[..32]; let commitment = &input[96..144]; if kzg_to_versioned_hash(commitment) != versioned_hash { - return Err(Error::BlobMismatchedVersion.into()); + return Err(PrecompileError::BlobMismatchedVersion.into()); } // Verify KZG proof with z and y in big endian format @@ -53,7 +56,7 @@ pub fn run(input: &Bytes, gas_limit: u64, cfg: &CfgEnv) -> PrecompileResult { let y = as_bytes32(&input[64..96]); let proof = as_bytes48(&input[144..192]); if !verify_kzg_proof(commitment, z, y, proof, cfg.kzg_settings.get()) { - return Err(Error::BlobVerifyKzgProofFailed.into()); + return Err(PrecompileError::BlobVerifyKzgProofFailed.into()); } // Return FIELD_ELEMENTS_PER_BLOB and BLS_MODULUS as padded 32 byte big endian values diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index 14a605ef1d..bc0551dd6e 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -15,6 +15,7 @@ pub mod bn128; pub mod fatal_precompile; pub mod hash; pub mod identity; +pub mod interface; #[cfg(any(feature = "c-kzg", feature = "kzg-rs"))] pub mod kzg_point_evaluation; pub mod modexp; @@ -25,15 +26,13 @@ pub mod utilities; pub use fatal_precompile::fatal_precompile; +pub use interface::*; #[cfg(all(feature = "c-kzg", feature = "kzg-rs"))] // silence kzg-rs lint as c-kzg will be used as default if both are enabled. use kzg_rs as _; -pub use primitives::{ - precompile::{PrecompileError as Error, *}, - Address, Bytes, HashMap, HashSet, Log, B256, -}; -#[doc(hidden)] -pub use revm_primitives as primitives; +pub use primitives::{Address, Bytes, HashMap, HashSet, Log, B256}; + +pub use primitives; use cfg_if::cfg_if; use core::hash::Hash; @@ -281,9 +280,9 @@ pub enum PrecompileSpecId { } impl PrecompileSpecId { - /// Returns the appropriate precompile Spec for the primitive [SpecId](revm_primitives::SpecId) - pub const fn from_spec_id(spec_id: revm_primitives::SpecId) -> Self { - use revm_primitives::SpecId::*; + /// Returns the appropriate precompile Spec for the primitive [SpecId](specification::hardfork::SpecId) + pub const fn from_spec_id(spec_id: specification::hardfork::SpecId) -> Self { + use specification::hardfork::SpecId::*; match spec_id { FRONTIER | FRONTIER_THAWING | HOMESTEAD | DAO_FORK | TANGERINE | SPURIOUS_DRAGON => { Self::HOMESTEAD diff --git a/crates/precompile/src/modexp.rs b/crates/precompile/src/modexp.rs index 4839bff751..b4d2987958 100644 --- a/crates/precompile/src/modexp.rs +++ b/crates/precompile/src/modexp.rs @@ -1,11 +1,11 @@ use crate::{ primitives::U256, utilities::{left_pad, left_pad_vec, right_pad_vec, right_pad_with_offset}, - Error, Precompile, PrecompileResult, PrecompileWithAddress, + Precompile, PrecompileError, PrecompileOutput, PrecompileResult, PrecompileWithAddress, }; use aurora_engine_modexp::modexp; use core::cmp::{max, min}; -use revm_primitives::{Bytes, PrecompileOutput}; +use primitives::Bytes; pub const BYZANTIUM: PrecompileWithAddress = PrecompileWithAddress( crate::u64_to_address(5), @@ -50,7 +50,7 @@ where { // If there is no minimum gas, return error. if min_gas > gas_limit { - return Err(Error::OutOfGas.into()); + return Err(PrecompileError::OutOfGas.into()); } // The format of input is: @@ -66,10 +66,10 @@ where // cast base and modulus to usize, it does not make sense to handle larger values let Ok(base_len) = usize::try_from(base_len) else { - return Err(Error::ModexpBaseOverflow.into()); + return Err(PrecompileError::ModexpBaseOverflow.into()); }; let Ok(mod_len) = usize::try_from(mod_len) else { - return Err(Error::ModexpModOverflow.into()); + return Err(PrecompileError::ModexpModOverflow.into()); }; // Handle a special case when both the base and mod length are zero. @@ -79,7 +79,7 @@ where // Cast exponent length to usize, since it does not make sense to handle larger values. let Ok(exp_len) = usize::try_from(exp_len) else { - return Err(Error::ModexpModOverflow.into()); + return Err(PrecompileError::ModexpModOverflow.into()); }; // Used to extract ADJUSTED_EXPONENT_LENGTH. @@ -99,7 +99,7 @@ where // Check if we have enough gas. let gas_cost = calc_gas(base_len as u64, exp_len as u64, mod_len as u64, &exp_highp); if gas_cost > gas_limit { - return Err(Error::OutOfGas.into()); + return Err(PrecompileError::OutOfGas.into()); } // Padding is needed if the input does not contain all 3 values. @@ -168,7 +168,7 @@ pub fn berlin_gas_calc( #[cfg(test)] mod tests { use super::*; - use revm_primitives::hex; + use primitives::hex; use std::vec::Vec; struct Test { diff --git a/crates/precompile/src/secp256k1.rs b/crates/precompile/src/secp256k1.rs index 86794b38db..72b5c602de 100644 --- a/crates/precompile/src/secp256k1.rs +++ b/crates/precompile/src/secp256k1.rs @@ -1,5 +1,8 @@ -use crate::{utilities::right_pad, Error, Precompile, PrecompileResult, PrecompileWithAddress}; -use revm_primitives::{alloy_primitives::B512, Bytes, PrecompileOutput, B256}; +use crate::{ + utilities::right_pad, Precompile, PrecompileError, PrecompileOutput, PrecompileResult, + PrecompileWithAddress, +}; +use primitives::{alloy_primitives::B512, Bytes, B256}; pub const ECRECOVER: PrecompileWithAddress = PrecompileWithAddress( crate::u64_to_address(1), @@ -12,7 +15,7 @@ pub use self::secp256k1::ecrecover; #[allow(clippy::module_inception)] mod secp256k1 { use k256::ecdsa::{Error, RecoveryId, Signature, VerifyingKey}; - use revm_primitives::{alloy_primitives::B512, keccak256, B256}; + use primitives::{alloy_primitives::B512, keccak256, B256}; pub fn ecrecover(sig: &B512, mut recid: u8, msg: &B256) -> Result { // parse signature @@ -43,7 +46,7 @@ mod secp256k1 { #[cfg(feature = "secp256k1")] #[allow(clippy::module_inception)] mod secp256k1 { - use revm_primitives::{alloy_primitives::B512, keccak256, B256}; + use primitives::{alloy_primitives::B512, keccak256, B256}; use secp256k1::{ ecdsa::{RecoverableSignature, RecoveryId}, Message, Secp256k1, @@ -70,7 +73,7 @@ pub fn ec_recover_run(input: &Bytes, gas_limit: u64) -> PrecompileResult { const ECRECOVER_BASE: u64 = 3_000; if ECRECOVER_BASE > gas_limit { - return Err(Error::OutOfGas.into()); + return Err(PrecompileError::OutOfGas.into()); } let input = right_pad::<128>(input); diff --git a/crates/precompile/src/secp256r1.rs b/crates/precompile/src/secp256r1.rs index 46f00b7405..16aaebec31 100644 --- a/crates/precompile/src/secp256r1.rs +++ b/crates/precompile/src/secp256r1.rs @@ -6,9 +6,12 @@ //! The main purpose of this precompile is to verify ECDSA signatures that use the secp256r1, or //! P256 elliptic curve. The [`P256VERIFY`] const represents the implementation of this precompile, //! with the address that it is currently deployed at. -use crate::{u64_to_address, Precompile, PrecompileWithAddress}; +use crate::{ + u64_to_address, Precompile, PrecompileError, PrecompileOutput, PrecompileResult, + PrecompileWithAddress, +}; use p256::ecdsa::{signature::hazmat::PrehashVerifier, Signature, VerifyingKey}; -use revm_primitives::{Bytes, PrecompileError, PrecompileOutput, PrecompileResult, B256}; +use primitives::{Bytes, B256}; /// Base gas fee for secp256r1 p256verify operation. const P256VERIFY_BASE: u64 = 3450; @@ -73,7 +76,8 @@ pub fn verify_impl(input: &[u8]) -> Option<()> { #[cfg(test)] mod test { use super::*; - use crate::primitives::{hex::FromHex, PrecompileErrors}; + use crate::PrecompileErrors; + use primitives::hex::FromHex; use rstest::rstest; #[rstest] diff --git a/crates/precompile/src/utilities.rs b/crates/precompile/src/utilities.rs index 6e59010a5d..c850bfe9bd 100644 --- a/crates/precompile/src/utilities.rs +++ b/crates/precompile/src/utilities.rs @@ -1,4 +1,4 @@ -use revm_primitives::{b256, Bytes, B256}; +use primitives::{b256, Bytes, B256}; use std::borrow::Cow; /// Right-pads the given slice at `offset` with zeroes until `LEN`. diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 9d07abb98f..72adf8d5ef 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -22,87 +22,22 @@ rust_2018_idioms = "deny" all = "warn" [dependencies] -alloy-eips = { version = "0.3", default-features = false, features = ["k256"] } alloy-primitives = { version = "0.8.2", default-features = false, features = [ "rlp", ] } hashbrown = "0.14" -auto_impl = "1.2" -bitvec = { version = "1", default-features = false, features = ["alloc"] } -bitflags = { version = "2.6.0", default-features = false } -# For setting the CfgEnv KZGSettings. Enabled by c-kzg flag. -c-kzg = { version = "1.0.3", default-features = false, optional = true, features = [ - "ethereum_kzg_settings", -] } - -# Optionally use `kzg-rs` for a pure Rust implementation of KZG. -kzg-rs = { version = "0.2.3", default-features = false, optional = true } - -# utility -enumn = "0.1" -cfg-if = "1" -dyn-clone = "1.0" - -# optional -serde = { version = "1.0", default-features = false, features = [ - "derive", - "rc", -], optional = true } +# utils +cfg-if = { version = "1.0", default-features = false } [build-dependencies] hex = { version = "0.4", default-features = false } [features] -default = ["std", "c-kzg", "portable"] -std = [ - "serde?/std", - "alloy-eips/std", - "alloy-primitives/std", - "hex/std", - "bitvec/std", - "bitflags/std", -] +default = ["std"] +std = ["alloy-primitives/std", "hex/std"] hashbrown = [] -serde = [ - "dep:serde", - "alloy-eips/serde", - "alloy-primitives/serde", - "hex/serde", - "hashbrown/serde", - "bitvec/serde", - "bitflags/serde", - "c-kzg?/serde", -] -arbitrary = [ - "std", - "alloy-eips/arbitrary", - "alloy-primitives/arbitrary", - "bitflags/arbitrary", -] +serde = ["alloy-primitives/serde", "hex/serde", "hashbrown/serde"] +arbitrary = ["std", "alloy-primitives/arbitrary"] asm-keccak = ["alloy-primitives/asm-keccak"] -portable = ["c-kzg?/portable"] - -dev = [ - "memory_limit", - "optional_balance_check", - "optional_block_gas_limit", - "optional_eip3607", - "optional_gas_refund", - "optional_no_base_fee", - "optional_beneficiary_reward", -] -memory_limit = [] -optional_balance_check = [] -optional_block_gas_limit = [] -optional_eip3607 = [] -optional_gas_refund = [] -optional_no_base_fee = [] -optional_beneficiary_reward = [] rand = ["alloy-primitives/rand"] - -# See comments in `revm-precompile` -c-kzg = ["dep:c-kzg"] -# `kzg-rs` is not audited but useful for `no_std` environment. -# use it with causing and default to `c-kzg` if possible! -kzg-rs = ["dep:kzg-rs"] diff --git a/crates/primitives/src/db/components.rs b/crates/primitives/src/db/components.rs deleted file mode 100644 index 5a2c5259f6..0000000000 --- a/crates/primitives/src/db/components.rs +++ /dev/null @@ -1,83 +0,0 @@ -//! Database that is split on State and BlockHash traits. -pub mod block_hash; -pub mod state; - -pub use block_hash::{BlockHash, BlockHashRef}; -pub use state::{State, StateRef}; - -use crate::{ - db::{Database, DatabaseRef}, - Account, AccountInfo, Address, Bytecode, HashMap, B256, U256, -}; - -use super::DatabaseCommit; - -#[derive(Debug)] -pub struct DatabaseComponents { - pub state: S, - pub block_hash: BH, -} - -#[derive(Debug)] -pub enum DatabaseComponentError { - State(SE), - BlockHash(BHE), -} - -impl Database for DatabaseComponents { - type Error = DatabaseComponentError; - - fn basic(&mut self, address: Address) -> Result, Self::Error> { - self.state.basic(address).map_err(Self::Error::State) - } - - fn code_by_hash(&mut self, code_hash: B256) -> Result { - self.state - .code_by_hash(code_hash) - .map_err(Self::Error::State) - } - - fn storage(&mut self, address: Address, index: U256) -> Result { - self.state - .storage(address, index) - .map_err(Self::Error::State) - } - - fn block_hash(&mut self, number: u64) -> Result { - self.block_hash - .block_hash(number) - .map_err(Self::Error::BlockHash) - } -} - -impl DatabaseRef for DatabaseComponents { - type Error = DatabaseComponentError; - - fn basic_ref(&self, address: Address) -> Result, Self::Error> { - self.state.basic(address).map_err(Self::Error::State) - } - - fn code_by_hash_ref(&self, code_hash: B256) -> Result { - self.state - .code_by_hash(code_hash) - .map_err(Self::Error::State) - } - - fn storage_ref(&self, address: Address, index: U256) -> Result { - self.state - .storage(address, index) - .map_err(Self::Error::State) - } - - fn block_hash_ref(&self, number: u64) -> Result { - self.block_hash - .block_hash(number) - .map_err(Self::Error::BlockHash) - } -} - -impl DatabaseCommit for DatabaseComponents { - fn commit(&mut self, changes: HashMap) { - self.state.commit(changes); - } -} diff --git a/crates/primitives/src/db/components/block_hash.rs b/crates/primitives/src/db/components/block_hash.rs deleted file mode 100644 index 8093f278ec..0000000000 --- a/crates/primitives/src/db/components/block_hash.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! BlockHash database component from [`crate::db::Database`] -//! it is used inside [`crate::db::DatabaseComponents`] - -use crate::B256; -use auto_impl::auto_impl; -use core::ops::Deref; -use std::sync::Arc; - -#[auto_impl(&mut, Box)] -pub trait BlockHash { - type Error; - - /// Get block hash by block number - fn block_hash(&mut self, number: u64) -> Result; -} - -#[auto_impl(&, &mut, Box, Rc, Arc)] -pub trait BlockHashRef { - type Error; - - /// Get block hash by block number - fn block_hash(&self, number: u64) -> Result; -} - -impl BlockHash for &T -where - T: BlockHashRef, -{ - type Error = ::Error; - - fn block_hash(&mut self, number: u64) -> Result { - BlockHashRef::block_hash(*self, number) - } -} - -impl BlockHash for Arc -where - T: BlockHashRef, -{ - type Error = ::Error; - - fn block_hash(&mut self, number: u64) -> Result { - self.deref().block_hash(number) - } -} diff --git a/crates/primitives/src/db/components/state.rs b/crates/primitives/src/db/components/state.rs deleted file mode 100644 index d3b948ddaa..0000000000 --- a/crates/primitives/src/db/components/state.rs +++ /dev/null @@ -1,73 +0,0 @@ -//! State database component from [`crate::db::Database`] -//! it is used inside [`crate::db::DatabaseComponents`] - -use crate::{AccountInfo, Address, Bytecode, B256, U256}; -use auto_impl::auto_impl; -use core::ops::Deref; -use std::sync::Arc; - -#[auto_impl(&mut, Box)] -pub trait State { - type Error; - - /// Get basic account information. - fn basic(&mut self, address: Address) -> Result, Self::Error>; - - /// Get account code by its hash - fn code_by_hash(&mut self, code_hash: B256) -> Result; - - /// Get storage value of address at index. - fn storage(&mut self, address: Address, index: U256) -> Result; -} - -#[auto_impl(&, &mut, Box, Rc, Arc)] -pub trait StateRef { - type Error; - - /// Get basic account information. - fn basic(&self, address: Address) -> Result, Self::Error>; - - /// Get account code by its hash - fn code_by_hash(&self, code_hash: B256) -> Result; - - /// Get storage value of address at index. - fn storage(&self, address: Address, index: U256) -> Result; -} - -impl State for &T -where - T: StateRef, -{ - type Error = ::Error; - - fn basic(&mut self, address: Address) -> Result, Self::Error> { - StateRef::basic(*self, address) - } - - fn code_by_hash(&mut self, code_hash: B256) -> Result { - StateRef::code_by_hash(*self, code_hash) - } - - fn storage(&mut self, address: Address, index: U256) -> Result { - StateRef::storage(*self, address, index) - } -} - -impl State for Arc -where - T: StateRef, -{ - type Error = ::Error; - - fn basic(&mut self, address: Address) -> Result, Self::Error> { - self.deref().basic(address) - } - - fn code_by_hash(&mut self, code_hash: B256) -> Result { - self.deref().code_by_hash(code_hash) - } - - fn storage(&mut self, address: Address, index: U256) -> Result { - self.deref().storage(address, index) - } -} diff --git a/crates/primitives/src/eip7702.rs b/crates/primitives/src/eip7702.rs deleted file mode 100644 index f63600b904..0000000000 --- a/crates/primitives/src/eip7702.rs +++ /dev/null @@ -1,26 +0,0 @@ -pub mod authorization_list; -pub mod bytecode; - -use crate::U256; -pub use authorization_list::{ - Authorization, AuthorizationList, InvalidAuthorization, RecoveredAuthorization, Signature, - SignedAuthorization, -}; -pub use bytecode::{ - Eip7702Bytecode, Eip7702DecodeError, EIP7702_MAGIC, EIP7702_MAGIC_BYTES, EIP7702_VERSION, -}; - -// Base cost of updating authorized account. -pub const PER_AUTH_BASE_COST: u64 = 2500; - -/// Cost of creating authorized account that was previously empty. -pub const PER_EMPTY_ACCOUNT_COST: u64 = 25000; - -/// The order of the secp256k1 curve, divided by two. Signatures that should be checked according -/// to EIP-2 should have an S value less than or equal to this. -/// -/// `57896044618658097711785492504343953926418782139537452191302581570759080747168` -const SECP256K1N_HALF: U256 = U256::from_be_bytes([ - 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x5D, 0x57, 0x6E, 0x73, 0x57, 0xA4, 0x50, 0x1D, 0xDF, 0xE9, 0x2F, 0x46, 0x68, 0x1B, 0x20, 0xA0, -]); diff --git a/crates/primitives/src/kzg.rs b/crates/primitives/src/kzg.rs deleted file mode 100644 index 88aeb35be6..0000000000 --- a/crates/primitives/src/kzg.rs +++ /dev/null @@ -1,31 +0,0 @@ -cfg_if::cfg_if! { - if #[cfg(feature = "c-kzg")] { - pub use c_kzg::KzgSettings; - /// KZG Settings that allow us to specify a custom trusted setup. - /// or use hardcoded default settings. - #[derive(Debug, Clone, Default, PartialEq, Eq )] - pub enum EnvKzgSettings { - /// Default mainnet trusted setup - #[default] - Default, - /// Custom trusted setup. - Custom(std::sync::Arc), - } - - impl EnvKzgSettings { - /// Return set KZG settings. - /// - /// In will initialize the default settings if it is not already loaded. - pub fn get(&self) -> &c_kzg::KzgSettings { - match self { - Self::Default => { - c_kzg::ethereum_kzg_settings() - } - Self::Custom(settings) => settings, - } - } - } - } else if #[cfg(feature = "kzg-rs")] { - pub use kzg_rs::{KzgSettings,EnvKzgSettings}; - } -} diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 8255ffb9fb..bc8366c6b3 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -4,39 +4,13 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] -extern crate alloc as std; - -pub mod block; -pub mod db; -pub mod eip7702; -pub mod env; - -mod bytecode; mod constants; -mod evm_wiring; -#[cfg(any(feature = "c-kzg", feature = "kzg-rs"))] -pub mod kzg; -pub mod precompile; -pub mod result; -pub mod specification; -pub mod state; -pub mod transaction; -pub mod utilities; -pub use alloy_eips::eip2930::{AccessList, AccessListItem}; pub use alloy_primitives::{ - self, address, b256, bytes, fixed_bytes, hex, hex_literal, ruint, uint, Address, Bytes, - FixedBytes, Log, LogData, TxKind, B256, I256, U256, + self, address, b256, bytes, fixed_bytes, hex, hex_literal, keccak256, ruint, uint, Address, + Bytes, FixedBytes, Log, LogData, TxKind, B256, I256, U256, }; -pub use bitvec; -pub use bytecode::*; + pub use constants::*; -pub use eip7702::{ - Authorization, AuthorizationList, Eip7702Bytecode, Eip7702DecodeError, InvalidAuthorization, - RecoveredAuthorization, Signature, SignedAuthorization, EIP7702_MAGIC, EIP7702_MAGIC_BYTES, -}; -pub use env::*; -pub use evm_wiring::*; cfg_if::cfg_if! { if #[cfg(all(not(feature = "hashbrown"), feature = "std"))] { @@ -47,16 +21,6 @@ cfg_if::cfg_if! { } } -pub use block::Block; -#[cfg(any(feature = "c-kzg", feature = "kzg-rs"))] -pub use kzg::{EnvKzgSettings, KzgSettings}; -pub use precompile::*; -pub use result::*; -pub use specification::*; -pub use state::*; -pub use transaction::Transaction; -pub use utilities::*; - -#[cfg(all(feature = "c-kzg", feature = "kzg-rs"))] -// silence kzg-rs lint as c-kzg will be used as default if both are enabled. -use kzg_rs as _; +/// The Keccak-256 hash of the empty string `""`. +pub const KECCAK_EMPTY: B256 = + b256!("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"); diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index 41df82427f..87e6be0544 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -23,8 +23,14 @@ all = "warn" [dependencies] # revm -revm-interpreter = { path = "../interpreter", version = "10.0.1", default-features = false } -revm-precompile = { path = "../precompile", version = "11.0.1", default-features = false } +interpreter.workspace = true +precompile.workspace = true +wiring.workspace = true +primitives.workspace = true +database-interface.workspace = true +state.workspace = true +specification.workspace = true +bytecode.workspace = true # misc auto_impl = { version = "1.2", default-features = false } @@ -40,15 +46,11 @@ serde_json = { version = "1.0", default-features = false, features = [ "alloc", ], optional = true } -# ethersdb +# alloydb tokio = { version = "1.40", features = [ "rt-multi-thread", "macros", ], optional = true } -ethers-providers = { version = "2.0", optional = true } -ethers-core = { version = "2.0", optional = true } - -# alloydb alloy-provider = { version = "0.3", optional = true, default-features = false } alloy-eips = { version = "0.3", optional = true, default-features = false } alloy-transport = { version = "0.3", optional = true, default-features = false } @@ -72,20 +74,18 @@ std = [ "serde?/std", "serde_json?/std", "serde_json?/preserve_order", - "revm-interpreter/std", - "revm-precompile/std", + "interpreter/std", + "precompile/std", ] -hashbrown = ["revm-interpreter/hashbrown", "revm-precompile/hashbrown"] -serde = ["dep:serde", "revm-interpreter/serde"] +hashbrown = ["interpreter/hashbrown", "precompile/hashbrown"] +serde = ["dep:serde", "interpreter/serde", "database-interface/serde"] serde-json = ["serde", "dep:serde_json"] -arbitrary = ["revm-interpreter/arbitrary"] -asm-keccak = ["revm-interpreter/asm-keccak", "revm-precompile/asm-keccak"] -portable = ["revm-precompile/portable", "revm-interpreter/portable"] +arbitrary = ["primitives/arbitrary"] +asm-keccak = ["primitives/asm-keccak"] +portable = ["wiring/portable"] test-utils = [] -ethersdb = ["std", "dep:tokio", "dep:ethers-providers", "dep:ethers-core"] - alloydb = [ "std", "dep:tokio", @@ -101,32 +101,30 @@ dev = [ "optional_eip3607", "optional_gas_refund", "optional_no_base_fee", - "optional_beneficiary_reward", ] -memory_limit = ["revm-interpreter/memory_limit"] -optional_balance_check = ["revm-interpreter/optional_balance_check"] -optional_block_gas_limit = ["revm-interpreter/optional_block_gas_limit"] -optional_eip3607 = ["revm-interpreter/optional_eip3607"] -optional_gas_refund = ["revm-interpreter/optional_gas_refund"] -optional_no_base_fee = ["revm-interpreter/optional_no_base_fee"] -optional_beneficiary_reward = ["revm-interpreter/optional_beneficiary_reward"] - -# See comments in `revm-precompile` -secp256k1 = ["revm-precompile/secp256k1"] -c-kzg = ["revm-precompile/c-kzg"] +memory_limit = ["wiring/memory_limit", "interpreter/memory_limit"] +optional_balance_check = ["wiring/optional_balance_check"] +optional_block_gas_limit = ["wiring/optional_block_gas_limit"] +optional_eip3607 = ["wiring/optional_eip3607"] +optional_gas_refund = ["wiring/optional_gas_refund"] +optional_no_base_fee = ["wiring/optional_no_base_fee"] + +# See comments in `precompile` +secp256k1 = ["precompile/secp256k1"] +c-kzg = ["precompile/c-kzg"] # `kzg-rs` is not audited but useful for `no_std` environment, use it with causing and default to `c-kzg` if possible. -kzg-rs = ["revm-precompile/kzg-rs"] -blst = ["revm-precompile/blst"] +kzg-rs = ["precompile/kzg-rs"] +blst = ["precompile/blst"] [[example]] name = "fork_ref_transact" path = "../../examples/fork_ref_transact.rs" -required-features = ["ethersdb"] +required-features = ["alloydb"] [[example]] name = "generate_block_traces" path = "../../examples/generate_block_traces.rs" -required-features = ["std", "serde-json", "ethersdb"] +required-features = ["std", "serde-json", "alloydb"] [[example]] name = "db_by_ref" diff --git a/crates/revm/benches/bench.rs b/crates/revm/benches/bench.rs index fd8f7d193a..f4f22544d5 100644 --- a/crates/revm/benches/bench.rs +++ b/crates/revm/benches/bench.rs @@ -1,13 +1,16 @@ use criterion::{ criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion, }; +use interpreter::{opcode::make_instruction_table, SharedMemory, EMPTY_SHARED_MEMORY}; use revm::{ + bytecode::Bytecode, db::BenchmarkDB, interpreter::{analysis::to_analysed, Contract, DummyHost, Interpreter}, - primitives::{address, bytes, hex, BerlinSpec, Bytecode, Bytes, EthereumWiring, TxKind, U256}, + primitives::{address, bytes, hex, Bytes, TxKind, U256}, + specification::hardfork::BerlinSpec, + wiring::EthereumWiring, Evm, }; -use revm_interpreter::{opcode::make_instruction_table, SharedMemory, EMPTY_SHARED_MEMORY}; use std::time::Duration; fn analysis(c: &mut Criterion) { diff --git a/crates/revm/src/builder.rs b/crates/revm/src/builder.rs index e3db22bed8..1380c0ebb4 100644 --- a/crates/revm/src/builder.rs +++ b/crates/revm/src/builder.rs @@ -1,11 +1,13 @@ -use crate::{ - db::EmptyDB, - handler::register, - primitives::{CfgEnv, EnvWiring, EthereumWiring, InvalidTransaction, TransactionValidation}, - Context, Evm, EvmContext, EvmWiring, Handler, -}; +use crate::{handler::register, Context, Evm, EvmContext, EvmWiring, Handler}; use core::marker::PhantomData; +use database_interface::EmptyDB; use std::boxed::Box; +use wiring::{ + default::{CfgEnv, EnvWiring}, + result::InvalidTransaction, + transaction::TransactionValidation, + EthereumWiring, +}; /// Evm Builder allows building or modifying EVM. /// Note that some of the methods that changes underlying structures @@ -287,8 +289,11 @@ impl<'a, BuilderStage, EvmWiringT: EvmWiring> EvmBuilder<'a, BuilderStage, EvmWi /// /// # Example /// ```rust - /// use revm::{EvmBuilder, EvmHandler, db::EmptyDB, primitives::{EthereumWiring, SpecId}}; - /// use revm_interpreter::primitives::CancunSpec; + /// use revm::{EvmBuilder, EvmHandler}; + /// use wiring::EthereumWiring; + /// use database_interface::EmptyDB; + /// use specification::hardfork::{SpecId,CancunSpec}; + /// /// let builder = EvmBuilder::default().with_default_db().with_default_ext_ctx(); /// /// // get the desired handler @@ -460,12 +465,13 @@ where #[cfg(test)] mod test { - use crate::{ - interpreter::Interpreter, - primitives::{address, AccountInfo, Bytecode, EthereumWiring, TxKind, U256}, - Context, Evm, InMemoryDB, - }; + use crate::{Context, Evm, InMemoryDB}; + use bytecode::Bytecode; + use interpreter::Interpreter; + use primitives::{address, TxKind, U256}; + use state::AccountInfo; use std::{cell::RefCell, rc::Rc}; + use wiring::EthereumWiring; /// Custom evm context #[derive(Default, Clone, Debug)] diff --git a/crates/revm/src/context.rs b/crates/revm/src/context.rs index c4fd5231a7..ea6da4bc1a 100644 --- a/crates/revm/src/context.rs +++ b/crates/revm/src/context.rs @@ -9,17 +9,16 @@ pub use context_precompiles::{ use derive_where::derive_where; pub use evm_context::EvmContext; pub use inner_evm_context::InnerEvmContext; -use revm_interpreter::{as_u64_saturated, Eip7702CodeLoad, StateLoad}; - -use crate::{ - db::{Database, EmptyDB}, - interpreter::{AccountLoad, Host, SStoreResult, SelfDestructResult}, - primitives::{ - Address, Block, Bytes, EnvWiring, EthereumWiring, Log, B256, BLOCK_HASH_HISTORY, U256, - }, - EvmWiring, + +use crate::EvmWiring; +use database_interface::{Database, EmptyDB}; +use interpreter::{ + as_u64_saturated, AccountLoad, Eip7702CodeLoad, Host, SStoreResult, SelfDestructResult, + StateLoad, }; +use primitives::{Address, Bytes, Log, B256, BLOCK_HASH_HISTORY, U256}; use std::boxed::Box; +use wiring::{default::EnvWiring, Block, EthereumWiring}; /// Main Context structure that contains both EvmContext and External context. #[derive_where(Clone; EvmWiringT::Block, EvmWiringT::ChainContext, EvmWiringT::Transaction, EvmWiringT::Database, ::Error, EvmWiringT::ExternalContext)] diff --git a/crates/revm/src/context/context_precompiles.rs b/crates/revm/src/context/context_precompiles.rs index 2b1c141214..e14bb71823 100644 --- a/crates/revm/src/context/context_precompiles.rs +++ b/crates/revm/src/context/context_precompiles.rs @@ -1,13 +1,13 @@ use super::InnerEvmContext; -use crate::{ - precompile::{Precompile, PrecompileResult}, - primitives::{Address, Bytes, EvmWiring, HashMap, HashSet}, -}; use core::fmt::Debug; use derive_where::derive_where; use dyn_clone::DynClone; -use revm_precompile::{PrecompileSpecId, PrecompileWithAddress, Precompiles}; +use precompile::{ + Precompile, PrecompileResult, PrecompileSpecId, PrecompileWithAddress, Precompiles, +}; +use primitives::{Address, Bytes, HashMap, HashSet}; use std::{boxed::Box, sync::Arc}; +use wiring::EvmWiring; /// A single precompile handler. #[derive_where(Clone)] @@ -221,7 +221,7 @@ impl From for ContextPrecompile { #[cfg(test)] mod tests { use super::*; - use crate::primitives::DefaultEthereumWiring; + use wiring::DefaultEthereumWiring; #[test] fn test_precompiles_context() { diff --git a/crates/revm/src/context/evm_context.rs b/crates/revm/src/context/evm_context.rs index bc7df8a67c..ea1978346b 100644 --- a/crates/revm/src/context/evm_context.rs +++ b/crates/revm/src/context/evm_context.rs @@ -1,24 +1,23 @@ -use derive_where::derive_where; -use revm_interpreter::CallValue; -use revm_precompile::PrecompileErrors; - use super::inner_evm_context::InnerEvmContext; -use crate::{ - db::Database, - interpreter::{ - analysis::validate_eof, return_ok, CallInputs, Contract, CreateInputs, EOFCreateInputs, - EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterResult, - }, - primitives::{ - keccak256, Address, Bytecode, Bytes, CreateScheme, EVMError, EVMResultGeneric, EnvWiring, - Eof, - SpecId::{self, *}, - Transaction, B256, EOF_MAGIC_BYTES, - }, - ContextPrecompiles, EvmWiring, FrameOrResult, CALL_STACK_LIMIT, -}; +use crate::{ContextPrecompiles, EvmWiring, FrameOrResult, CALL_STACK_LIMIT}; +use bytecode::{Bytecode, Eof, EOF_MAGIC_BYTES}; use core::ops::{Deref, DerefMut}; +use database_interface::Database; +use derive_where::derive_where; +use interpreter::CallValue; +use interpreter::{ + analysis::validate_eof, return_ok, CallInputs, Contract, CreateInputs, EOFCreateInputs, + EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterResult, +}; +use precompile::PrecompileErrors; +use primitives::{keccak256, Address, Bytes, B256}; +use specification::hardfork::SpecId::{self, *}; use std::{boxed::Box, sync::Arc}; +use wiring::{ + default::{CreateScheme, EnvWiring}, + result::{EVMError, EVMResultGeneric}, + Transaction, +}; /// EVM context that contains the inner EVM context and precompiles. #[derive_where(Clone, Debug; EvmWiringT::Block, EvmWiringT::ChainContext, EvmWiringT::Transaction, EvmWiringT::Database, ::Error)] @@ -464,12 +463,12 @@ where #[cfg(any(test, feature = "test-utils"))] pub(crate) mod test_utils { use super::*; - use crate::primitives::U256; - use crate::{ - db::{CacheDB, EmptyDB}, - journaled_state::JournaledState, - primitives::{address, HashSet, SpecId, B256}, - }; + use crate::{db::CacheDB, journaled_state::JournaledState}; + use database_interface::EmptyDB; + use interpreter::CallScheme; + use primitives::{address, HashSet, B256, U256}; + use specification::hardfork::SpecId; + use state::AccountInfo; /// Mock caller address. pub const MOCK_CALLER: Address = address!("0000000000000000000000000000000000000000"); @@ -483,7 +482,7 @@ pub(crate) mod test_utils { target_address: to, caller: MOCK_CALLER, value: CallValue::Transfer(U256::ZERO), - scheme: revm_interpreter::CallScheme::Call, + scheme: CallScheme::Call, is_eof: false, is_static: false, return_memory_offset: 0..0, @@ -502,7 +501,7 @@ pub(crate) mod test_utils { ) -> EvmContext { db.insert_account_info( test_utils::MOCK_CALLER, - crate::primitives::AccountInfo { + AccountInfo { nonce: 0, balance, code_hash: B256::default(), @@ -550,14 +549,14 @@ pub(crate) mod test_utils { #[cfg(test)] mod tests { use super::*; - use crate::primitives::U256; - use crate::{ - db::{CacheDB, EmptyDB}, - primitives::{address, Bytecode, DefaultEthereumWiring, EthereumWiring}, - Frame, JournalEntry, - }; + use crate::{db::CacheDB, Frame, JournalEntry}; + use bytecode::Bytecode; + use database_interface::EmptyDB; + use primitives::{address, U256}; + use state::AccountInfo; use std::boxed::Box; use test_utils::*; + use wiring::{DefaultEthereumWiring, EthereumWiring}; // Tests that the `EVMContext::make_call_frame` function returns an error if the // call stack is too deep. @@ -632,7 +631,7 @@ mod tests { let contract = address!("dead10000000000000000000000000000001dead"); cdb.insert_account_info( contract, - crate::primitives::AccountInfo { + AccountInfo { nonce: 0, balance: bal, code_hash: by.clone().hash_slow(), diff --git a/crates/revm/src/context/inner_evm_context.rs b/crates/revm/src/context/inner_evm_context.rs index 8ce88ef030..85770a110b 100644 --- a/crates/revm/src/context/inner_evm_context.rs +++ b/crates/revm/src/context/inner_evm_context.rs @@ -1,21 +1,26 @@ use derive_where::derive_where; -use crate::{ - db::Database, - interpreter::{ - analysis::to_analysed, gas, return_ok, AccountLoad, Eip7702CodeLoad, InstructionResult, - InterpreterResult, SStoreResult, SelfDestructResult, StateLoad, - }, - journaled_state::JournaledState, - primitives::{ - AccessListItem, Account, Address, AnalysisKind, Bytecode, Bytes, CfgEnv, EnvWiring, Eof, - EvmWiring, HashSet, Spec, +use crate::{journaled_state::JournaledState, JournalCheckpoint}; +use bytecode::{Bytecode, Eof, EOF_MAGIC_BYTES, EOF_MAGIC_HASH}; +use database_interface::Database; +use interpreter::{ + analysis::to_analysed, gas, return_ok, AccountLoad, Eip7702CodeLoad, InstructionResult, + InterpreterResult, SStoreResult, SelfDestructResult, StateLoad, +}; +use primitives::{Address, Bytes, HashSet, B256, U256}; +use specification::{ + eip2930::AccessListItem, + hardfork::{ + Spec, SpecId::{self, *}, - Transaction, B256, EOF_MAGIC_BYTES, EOF_MAGIC_HASH, U256, }, - JournalCheckpoint, }; +use state::Account; use std::{boxed::Box, sync::Arc}; +use wiring::{ + default::{AnalysisKind, CfgEnv, EnvWiring}, + EvmWiring, Transaction, +}; /// EVM contexts contains data that EVM needs for execution. #[derive_where(Clone, Debug; EvmWiringT::Block, EvmWiringT::ChainContext, EvmWiringT::Transaction, EvmWiringT::Database, ::Error)] diff --git a/crates/revm/src/db.rs b/crates/revm/src/db.rs index 5ec08ede12..6e0566aec9 100644 --- a/crates/revm/src/db.rs +++ b/crates/revm/src/db.rs @@ -1,21 +1,17 @@ -//! [Database] implementations. +//! Database implementations. -#[cfg(any(feature = "alloydb", feature = "ethersdb"))] +#[cfg(feature = "alloydb")] mod utils; #[cfg(feature = "alloydb")] mod alloydb; -#[cfg(feature = "ethersdb")] -mod ethersdb; + pub mod in_memory_db; pub mod states; -pub use crate::primitives::db::*; -pub use crate::primitives::db::{EmptyDB, EmptyDBTyped}; #[cfg(feature = "alloydb")] pub use alloydb::AlloyDB; -#[cfg(feature = "ethersdb")] -pub use ethersdb::EthersDB; + pub use in_memory_db::*; pub use states::{ AccountRevert, AccountStatus, BundleAccount, BundleState, CacheState, DBBox, diff --git a/crates/revm/src/db/alloydb.rs b/crates/revm/src/db/alloydb.rs index f03685282f..f0196ac6bc 100644 --- a/crates/revm/src/db/alloydb.rs +++ b/crates/revm/src/db/alloydb.rs @@ -1,6 +1,8 @@ use crate::{ - db::{Database, DatabaseRef}, - primitives::{AccountInfo, Address, Bytecode, B256, U256}, + bytecode::Bytecode, + database_interface::{Database, DatabaseRef}, + primitives::{Address, B256, U256}, + state::AccountInfo, }; use alloy_eips::BlockId; use alloy_provider::{ diff --git a/crates/revm/src/db/ethersdb.rs b/crates/revm/src/db/ethersdb.rs index 6e4f813a1b..7918dfe792 100644 --- a/crates/revm/src/db/ethersdb.rs +++ b/crates/revm/src/db/ethersdb.rs @@ -4,8 +4,10 @@ use ethers_core::types::{Block, BlockId, TxHash, H160 as eH160, H256, U64 as eU6 use ethers_providers::Middleware; use tokio::runtime::{Handle, Runtime}; -use crate::primitives::{AccountInfo, Address, Bytecode, B256, U256}; use crate::{Database, DatabaseRef}; +use bytecode::Bytecode; +use primitives::{Address, B256, U256}; +use state::AccountInfo; use super::utils::HandleOrRuntime; diff --git a/crates/revm/src/db/in_memory_db.rs b/crates/revm/src/db/in_memory_db.rs index c77efefa57..29cae75811 100644 --- a/crates/revm/src/db/in_memory_db.rs +++ b/crates/revm/src/db/in_memory_db.rs @@ -1,11 +1,10 @@ -use super::{DatabaseCommit, DatabaseRef, EmptyDB}; -use crate::primitives::{ - hash_map::Entry, Account, AccountInfo, Address, Bytecode, EthereumWiring, HashMap, Log, B256, - KECCAK_EMPTY, U256, -}; -use crate::Database; +use bytecode::Bytecode; use core::convert::Infallible; +use database_interface::{Database, DatabaseCommit, DatabaseRef, EmptyDB}; +use primitives::{hash_map::Entry, Address, HashMap, Log, B256, KECCAK_EMPTY, U256}; +use state::{Account, AccountInfo}; use std::vec::Vec; +use wiring::EthereumWiring; /// A [Database] implementation that stores all state changes in memory. pub type InMemoryDB = CacheDB; @@ -414,7 +413,9 @@ impl Database for BenchmarkDB { #[cfg(test)] mod tests { use super::{CacheDB, EmptyDB}; - use crate::primitives::{db::Database, AccountInfo, Address, U256}; + use database_interface::Database; + use primitives::{Address, U256}; + use state::AccountInfo; #[test] fn test_insert_account_storage() { diff --git a/crates/revm/src/db/states/bundle_account.rs b/crates/revm/src/db/states/bundle_account.rs index 5abf397bf7..a758da533b 100644 --- a/crates/revm/src/db/states/bundle_account.rs +++ b/crates/revm/src/db/states/bundle_account.rs @@ -2,8 +2,8 @@ use super::{ reverts::AccountInfoRevert, AccountRevert, AccountStatus, RevertToSlot, StorageSlot, StorageWithOriginalValues, TransitionAccount, }; -use revm_interpreter::primitives::{AccountInfo, U256}; -use revm_precompile::HashMap; +use primitives::{HashMap, U256}; +use state::AccountInfo; /// Account information focused on creating of database changesets /// and Reverts. diff --git a/crates/revm/src/db/states/bundle_state.rs b/crates/revm/src/db/states/bundle_state.rs index e8a05bbaef..6b57bf8641 100644 --- a/crates/revm/src/db/states/bundle_state.rs +++ b/crates/revm/src/db/states/bundle_state.rs @@ -4,11 +4,13 @@ use super::{ AccountRevert, AccountStatus, BundleAccount, PlainStateReverts, RevertToSlot, StorageSlot, TransitionState, }; +use bytecode::Bytecode; use core::{mem, ops::RangeInclusive}; -use revm_interpreter::primitives::{ +use primitives::{ hash_map::{self, Entry}, - AccountInfo, Address, Bytecode, HashMap, HashSet, B256, KECCAK_EMPTY, U256, + Address, HashMap, HashSet, B256, KECCAK_EMPTY, U256, }; +use state::AccountInfo; use std::{ collections::{BTreeMap, BTreeSet}, vec::Vec, diff --git a/crates/revm/src/db/states/cache.rs b/crates/revm/src/db/states/cache.rs index 5dd6770d49..eae3031e38 100644 --- a/crates/revm/src/db/states/cache.rs +++ b/crates/revm/src/db/states/cache.rs @@ -1,9 +1,9 @@ use super::{ plain_account::PlainStorage, transition_account::TransitionAccount, CacheAccount, PlainAccount, }; -use revm_interpreter::primitives::{ - Account, AccountInfo, Address, Bytecode, EvmState, HashMap, B256, -}; +use bytecode::Bytecode; +use primitives::{Address, HashMap, B256}; +use state::{Account, AccountInfo, EvmState}; use std::vec::Vec; /// Cache state contains both modified and original values. diff --git a/crates/revm/src/db/states/cache_account.rs b/crates/revm/src/db/states/cache_account.rs index 126ce2ffe7..442b3f888b 100644 --- a/crates/revm/src/db/states/cache_account.rs +++ b/crates/revm/src/db/states/cache_account.rs @@ -2,8 +2,8 @@ use super::{ plain_account::PlainStorage, AccountStatus, BundleAccount, PlainAccount, StorageWithOriginalValues, TransitionAccount, }; -use revm_interpreter::primitives::{AccountInfo, U256}; -use revm_precompile::HashMap; +use primitives::{HashMap, U256}; +use state::AccountInfo; /// Cache account contains plain state that gets updated /// at every transaction when evm output is applied to CacheState. diff --git a/crates/revm/src/db/states/changes.rs b/crates/revm/src/db/states/changes.rs index 555ba1e015..81eae46fd2 100644 --- a/crates/revm/src/db/states/changes.rs +++ b/crates/revm/src/db/states/changes.rs @@ -1,5 +1,7 @@ use super::RevertToSlot; -use revm_interpreter::primitives::{AccountInfo, Address, Bytecode, B256, U256}; +use bytecode::Bytecode; +use primitives::{Address, B256, U256}; +use state::AccountInfo; use std::vec::Vec; /// accounts/storages/contracts for inclusion into database. diff --git a/crates/revm/src/db/states/plain_account.rs b/crates/revm/src/db/states/plain_account.rs index 4f64c59629..0091bbae0e 100644 --- a/crates/revm/src/db/states/plain_account.rs +++ b/crates/revm/src/db/states/plain_account.rs @@ -1,4 +1,5 @@ -use crate::primitives::{AccountInfo, EvmStorageSlot, HashMap, U256}; +use primitives::{HashMap, U256}; +use state::{AccountInfo, EvmStorageSlot}; // TODO rename this to BundleAccount. As for the block level we have original state. #[derive(Clone, Debug, Default, PartialEq, Eq)] diff --git a/crates/revm/src/db/states/reverts.rs b/crates/revm/src/db/states/reverts.rs index b6aa9dfff7..3c14154cdc 100644 --- a/crates/revm/src/db/states/reverts.rs +++ b/crates/revm/src/db/states/reverts.rs @@ -3,7 +3,8 @@ use super::{ StorageWithOriginalValues, }; use core::ops::{Deref, DerefMut}; -use revm_interpreter::primitives::{AccountInfo, Address, HashMap, U256}; +use primitives::{Address, HashMap, U256}; +use state::AccountInfo; use std::vec::Vec; /// Contains reverts of multiple account in multiple transitions (Transitions as a block). diff --git a/crates/revm/src/db/states/state.rs b/crates/revm/src/db/states/state.rs index 9c3cc114e7..c0bb51c340 100644 --- a/crates/revm/src/db/states/state.rs +++ b/crates/revm/src/db/states/state.rs @@ -2,11 +2,10 @@ use super::{ bundle_state::BundleRetention, cache::CacheState, plain_account::PlainStorage, BundleState, CacheAccount, StateBuilder, TransitionAccount, TransitionState, }; -use crate::db::EmptyDB; -use revm_interpreter::primitives::{ - db::{Database, DatabaseCommit}, - hash_map, Account, AccountInfo, Address, Bytecode, HashMap, B256, BLOCK_HASH_HISTORY, U256, -}; +use bytecode::Bytecode; +use database_interface::{Database, DatabaseCommit, EmptyDB}; +use primitives::{hash_map, Address, HashMap, B256, BLOCK_HASH_HISTORY, U256}; +use state::{Account, AccountInfo}; use std::{ boxed::Box, collections::{btree_map, BTreeMap}, @@ -307,7 +306,7 @@ mod tests { states::{reverts::AccountInfoRevert, StorageSlot}, AccountRevert, AccountStatus, BundleAccount, RevertToSlot, }; - use revm_interpreter::primitives::keccak256; + use primitives::keccak256; #[test] fn block_hash_cache() { diff --git a/crates/revm/src/db/states/state_builder.rs b/crates/revm/src/db/states/state_builder.rs index f029ae13d4..377059f067 100644 --- a/crates/revm/src/db/states/state_builder.rs +++ b/crates/revm/src/db/states/state_builder.rs @@ -1,9 +1,6 @@ use super::{cache::CacheState, state::DBBox, BundleState, State, TransitionState}; -use crate::db::EmptyDB; -use revm_interpreter::primitives::{ - db::{Database, DatabaseRef, WrapDatabaseRef}, - B256, -}; +use database_interface::{Database, DatabaseRef, EmptyDB, WrapDatabaseRef}; +use primitives::B256; use std::collections::BTreeMap; /// Allows building of State and initializing it with different options. diff --git a/crates/revm/src/db/states/transition_account.rs b/crates/revm/src/db/states/transition_account.rs index 599bc290b0..5f35de7686 100644 --- a/crates/revm/src/db/states/transition_account.rs +++ b/crates/revm/src/db/states/transition_account.rs @@ -1,6 +1,7 @@ -use super::{AccountRevert, BundleAccount, StorageWithOriginalValues}; -use crate::db::AccountStatus; -use revm_interpreter::primitives::{hash_map, AccountInfo, Bytecode, B256, I256, U256}; +use super::{AccountRevert, AccountStatus, BundleAccount, StorageWithOriginalValues}; +use bytecode::Bytecode; +use primitives::{hash_map, B256, U256}; +use state::AccountInfo; /// Account Created when EVM state is merged to cache state. /// And it is sent to Block state. @@ -69,19 +70,6 @@ impl TransitionAccount { .unwrap_or_default() } - /// Calculate the change in account's balance for this transition. - /// Returns `None` if delta does not fit in [I256]. - pub fn balance_delta(&self) -> Option { - let previous_balance = self.previous_balance(); - let current_balance = self.current_balance(); - let delta = I256::try_from(previous_balance.abs_diff(current_balance)).ok()?; - if current_balance >= previous_balance { - Some(delta) - } else { - delta.checked_neg() - } - } - /// Update new values of transition. Don't override old values. /// Both account info and old storages need to be left intact. pub fn update(&mut self, other: Self) { diff --git a/crates/revm/src/db/states/transition_state.rs b/crates/revm/src/db/states/transition_state.rs index 8a5556cc77..a1986d6d10 100644 --- a/crates/revm/src/db/states/transition_state.rs +++ b/crates/revm/src/db/states/transition_state.rs @@ -1,5 +1,5 @@ use super::TransitionAccount; -use revm_interpreter::primitives::{hash_map::Entry, Address, HashMap}; +use primitives::{hash_map::Entry, Address, HashMap}; use std::vec::Vec; #[derive(Clone, Default, Debug, PartialEq, Eq)] diff --git a/crates/revm/src/evm.rs b/crates/revm/src/evm.rs index f674018f73..f20372dfed 100644 --- a/crates/revm/src/evm.rs +++ b/crates/revm/src/evm.rs @@ -1,19 +1,23 @@ -use revm_interpreter::Host as _; - use crate::{ builder::{EvmBuilder, SetGenericStage}, - db::{Database, DatabaseCommit}, handler::Handler, - interpreter::{CallInputs, CreateInputs, EOFCreateInputs, InterpreterAction, SharedMemory}, - primitives::{ - CfgEnv, EVMError, EVMResult, EVMResultGeneric, EnvWiring, ExecutionResult, ResultAndState, - SpecId, Transaction, TxKind, EOF_MAGIC_BYTES, - }, Context, ContextWithEvmWiring, EvmContext, EvmWiring, Frame, FrameOrResult, FrameResult, InnerEvmContext, }; +use bytecode::EOF_MAGIC_BYTES; use core::fmt::{self, Debug}; +use database_interface::{Database, DatabaseCommit}; +use interpreter::{ + CallInputs, CreateInputs, EOFCreateInputs, Host, InterpreterAction, SharedMemory, +}; +use primitives::TxKind; +use specification::hardfork::SpecId; use std::{boxed::Box, vec::Vec}; +use wiring::{ + default::{CfgEnv, EnvWiring}, + result::{EVMError, EVMResult, EVMResultGeneric, ExecutionResult, ResultAndState}, + Transaction, +}; /// EVM call stack limit. pub const CALL_STACK_LIMIT: u64 = 1024; @@ -423,14 +427,12 @@ impl Evm<'_, EvmWiringT> { mod tests { use super::*; - use crate::{ - db::BenchmarkDB, - interpreter::opcode::{PUSH1, SSTORE}, - primitives::{ - address, Authorization, Bytecode, EthereumWiring, RecoveredAuthorization, Signature, - U256, - }, - }; + use crate::db::BenchmarkDB; + use bytecode::Bytecode; + use interpreter::opcode::{PUSH1, SSTORE}; + use primitives::{address, U256}; + use specification::eip7702::{Authorization, RecoveredAuthorization, Signature}; + use wiring::EthereumWiring; #[test] fn sanity_eip7702_tx() { diff --git a/crates/revm/src/evm_wiring.rs b/crates/revm/src/evm_wiring.rs index 437dc71f40..72f6a9ce23 100644 --- a/crates/revm/src/evm_wiring.rs +++ b/crates/revm/src/evm_wiring.rs @@ -1,11 +1,13 @@ use crate::{ handler::{ExecutionHandler, PostExecutionHandler, PreExecutionHandler, ValidationHandler}, - interpreter::opcode::InstructionTables, - primitives::{db::Database, spec_to_generic, EthereumWiring, EvmWiring as PrimitiveEvmWiring}, EvmHandler, }; +use database_interface::Database; +use interpreter::opcode::InstructionTables; +use specification::spec_to_generic; use std::fmt::Debug; use std::vec::Vec; +use wiring::{EthereumWiring, EvmWiring as PrimitiveEvmWiring}; pub trait EvmWiring: PrimitiveEvmWiring { /// Creates a new handler with the given hardfork. diff --git a/crates/revm/src/frame.rs b/crates/revm/src/frame.rs index 2ef01db561..4df3622ff2 100644 --- a/crates/revm/src/frame.rs +++ b/crates/revm/src/frame.rs @@ -1,11 +1,11 @@ -use crate::{ - interpreter::Interpreter, - primitives::{Address, Output}, - JournalCheckpoint, -}; +use crate::JournalCheckpoint; use core::ops::Range; -use revm_interpreter::{CallOutcome, CreateOutcome, Gas, InstructionResult, InterpreterResult}; +use interpreter::{ + CallOutcome, CreateOutcome, Gas, InstructionResult, Interpreter, InterpreterResult, +}; +use primitives::Address; use std::boxed::Box; +use wiring::result::Output; /// Call CallStackFrame. #[derive(Debug)] diff --git a/crates/revm/src/handler.rs b/crates/revm/src/handler.rs index 042c3e6108..60f5009184 100644 --- a/crates/revm/src/handler.rs +++ b/crates/revm/src/handler.rs @@ -7,14 +7,17 @@ pub mod register; pub use handle_types::*; // Includes. -use crate::{ - interpreter::{opcode::InstructionTables, Host, InterpreterAction, SharedMemory}, - primitives::{spec_to_generic, EVMResultGeneric, InvalidTransaction, TransactionValidation}, - Context, EvmWiring, Frame, -}; + +use crate::{Context, EvmWiring, Frame}; use core::mem; +use interpreter::{opcode::InstructionTables, Host, InterpreterAction, SharedMemory}; use register::{EvmHandler, HandleRegisters}; +use specification::spec_to_generic; use std::vec::Vec; +use wiring::{ + result::{EVMResultGeneric, InvalidTransaction}, + transaction::TransactionValidation, +}; use self::register::{HandleRegister, HandleRegisterBox}; @@ -167,16 +170,13 @@ impl<'a, EvmWiringT: EvmWiring> EvmHandler<'a, EvmWiringT> { #[cfg(test)] mod test { use core::cell::RefCell; - - use crate::{ - db::EmptyDB, - primitives::{self, EVMError}, - }; + use database_interface::EmptyDB; use std::{rc::Rc, sync::Arc}; + use wiring::{result::EVMError, EthereumWiring, EvmWiring}; use super::*; - type TestEvmWiring = primitives::EthereumWiring; + type TestEvmWiring = EthereumWiring; #[test] fn test_handler_register_pop() { @@ -189,7 +189,7 @@ mod test { }; let mut handler = EvmHandler::<'_, TestEvmWiring>::mainnet_with_spec( - ::Hardfork::default(), + ::Hardfork::default(), ); let test = Rc::new(RefCell::new(0)); diff --git a/crates/revm/src/handler/handle_types/execution.rs b/crates/revm/src/handler/handle_types/execution.rs index d5d3fbc86c..7907922afb 100644 --- a/crates/revm/src/handler/handle_types/execution.rs +++ b/crates/revm/src/handler/handle_types/execution.rs @@ -1,15 +1,14 @@ use crate::{ - frame::EOFCreateFrame, - handler::mainnet, - interpreter::{CallInputs, CreateInputs, SharedMemory}, - primitives::{EVMResultGeneric, Spec}, - CallFrame, Context, CreateFrame, EvmWiring, Frame, FrameOrResult, FrameResult, + frame::EOFCreateFrame, handler::mainnet, CallFrame, Context, CreateFrame, EvmWiring, Frame, + FrameOrResult, FrameResult, }; -use revm_interpreter::{ - opcode::InstructionTables, CallOutcome, CreateOutcome, EOFCreateInputs, InterpreterAction, - InterpreterResult, +use interpreter::{ + opcode::InstructionTables, CallInputs, CallOutcome, CreateInputs, CreateOutcome, + EOFCreateInputs, InterpreterAction, InterpreterResult, SharedMemory, }; +use specification::hardfork::Spec; use std::{boxed::Box, sync::Arc}; +use wiring::result::EVMResultGeneric; /// Handles first frame return handle. pub type LastFrameReturnHandle<'a, EvmWiringT> = Arc< diff --git a/crates/revm/src/handler/handle_types/generic.rs b/crates/revm/src/handler/handle_types/generic.rs index 52ec25651f..b68deb7375 100644 --- a/crates/revm/src/handler/handle_types/generic.rs +++ b/crates/revm/src/handler/handle_types/generic.rs @@ -1,5 +1,6 @@ -use crate::{primitives::EVMResultGeneric, Context}; +use crate::Context; use std::sync::Arc; +use wiring::result::EVMResultGeneric; /// Generic Handle that takes a mutable reference to the context and returns a result. pub type GenericContextHandle<'a, EvmWiring> = GenericContextHandleRet<'a, EvmWiring, ()>; diff --git a/crates/revm/src/handler/handle_types/post_execution.rs b/crates/revm/src/handler/handle_types/post_execution.rs index 56380b9fad..66ca67675c 100644 --- a/crates/revm/src/handler/handle_types/post_execution.rs +++ b/crates/revm/src/handler/handle_types/post_execution.rs @@ -1,11 +1,9 @@ // Includes. -use crate::{ - handler::mainnet, - interpreter::Gas, - primitives::{EVMResult, EVMResultGeneric, ResultAndState, Spec}, - Context, EvmWiring, FrameResult, -}; +use crate::{handler::mainnet, Context, EvmWiring, FrameResult}; +use interpreter::Gas; +use specification::hardfork::Spec; use std::sync::Arc; +use wiring::result::{EVMResult, EVMResultGeneric, ResultAndState}; /// Reimburse the caller with ethereum it didn't spent. pub type ReimburseCallerHandle<'a, EvmWiringT> = diff --git a/crates/revm/src/handler/handle_types/pre_execution.rs b/crates/revm/src/handler/handle_types/pre_execution.rs index 7a4f3a2474..b00f7944bb 100644 --- a/crates/revm/src/handler/handle_types/pre_execution.rs +++ b/crates/revm/src/handler/handle_types/pre_execution.rs @@ -1,11 +1,9 @@ // Includes. use super::{GenericContextHandle, GenericContextHandleRet}; -use crate::{ - handler::mainnet, - primitives::{EVMResultGeneric, Spec}, - Context, ContextPrecompiles, EvmWiring, -}; +use crate::{handler::mainnet, Context, ContextPrecompiles, EvmWiring}; +use specification::hardfork::Spec; use std::sync::Arc; +use wiring::result::EVMResultGeneric; /// Loads precompiles into Evm pub type LoadPrecompilesHandle<'a, EvmWiringT> = diff --git a/crates/revm/src/handler/handle_types/validation.rs b/crates/revm/src/handler/handle_types/validation.rs index c5f7309622..90239cede0 100644 --- a/crates/revm/src/handler/handle_types/validation.rs +++ b/crates/revm/src/handler/handle_types/validation.rs @@ -1,9 +1,11 @@ -use crate::{ - handler::mainnet, - primitives::{EVMResultGeneric, EnvWiring, InvalidTransaction, Spec, TransactionValidation}, - Context, EvmWiring, -}; +use crate::{handler::mainnet, Context, EvmWiring}; +use specification::hardfork::Spec; use std::sync::Arc; +use wiring::{ + default::EnvWiring, + result::{EVMResultGeneric, InvalidTransaction}, + transaction::TransactionValidation, +}; /// Handle that validates env. pub type ValidateEnvHandle<'a, EvmWiringT> = diff --git a/crates/revm/src/handler/mainnet/execution.rs b/crates/revm/src/handler/mainnet/execution.rs index 0c5bb0ecf0..1d48c2d736 100644 --- a/crates/revm/src/handler/mainnet/execution.rs +++ b/crates/revm/src/handler/mainnet/execution.rs @@ -1,18 +1,19 @@ use crate::{ - frame::EOFCreateFrame, - interpreter::{ - return_ok, return_revert, CallInputs, CreateInputs, CreateOutcome, Gas, InstructionResult, - SharedMemory, - }, - primitives::{EVMError, EVMResultGeneric, Spec, Transaction}, - CallFrame, Context, CreateFrame, EvmWiring, Frame, FrameOrResult, FrameResult, + frame::EOFCreateFrame, CallFrame, Context, CreateFrame, EvmWiring, Frame, FrameOrResult, + FrameResult, }; use core::mem; -use revm_interpreter::{ - opcode::InstructionTables, CallOutcome, EOFCreateInputs, InterpreterAction, InterpreterResult, - EMPTY_SHARED_MEMORY, +use interpreter::{ + opcode::InstructionTables, return_ok, return_revert, CallInputs, CallOutcome, CreateInputs, + CreateOutcome, EOFCreateInputs, Gas, InstructionResult, InterpreterAction, InterpreterResult, + SharedMemory, EMPTY_SHARED_MEMORY, }; +use specification::hardfork::Spec; use std::boxed::Box; +use wiring::{ + result::{EVMError, EVMResultGeneric}, + Transaction, +}; /// Execute frame #[inline] @@ -193,8 +194,9 @@ pub fn insert_eofcreate_outcome( mod tests { use super::*; use crate::handler::mainnet::refund; - use crate::primitives::{CancunSpec, DefaultEthereumWiring, EnvWiring}; - use revm_precompile::Bytes; + use primitives::Bytes; + use specification::hardfork::CancunSpec; + use wiring::{default::EnvWiring, DefaultEthereumWiring}; /// Creates frame result. fn call_last_frame_return(instruction_result: InstructionResult, gas: Gas) -> Gas { diff --git a/crates/revm/src/handler/mainnet/post_execution.rs b/crates/revm/src/handler/mainnet/post_execution.rs index c010b7a0bb..5cfd7d5d32 100644 --- a/crates/revm/src/handler/mainnet/post_execution.rs +++ b/crates/revm/src/handler/mainnet/post_execution.rs @@ -1,10 +1,10 @@ -use crate::{ - interpreter::{Gas, SuccessOrHalt}, - primitives::{ - Block, EVMError, EVMResult, EVMResultGeneric, ExecutionResult, ResultAndState, Spec, - SpecId, SpecId::LONDON, Transaction, U256, - }, - Context, EvmWiring, FrameResult, +use crate::{Context, EvmWiring, FrameResult}; +use interpreter::{Gas, SuccessOrHalt}; +use primitives::U256; +use specification::hardfork::{Spec, SpecId}; +use wiring::{ + result::{EVMError, EVMResult, EVMResultGeneric, ExecutionResult, ResultAndState}, + Block, Transaction, }; /// Mainnet end handle does not change the output. @@ -35,7 +35,7 @@ pub fn reward_beneficiary( // transfer fee to coinbase/beneficiary. // EIP-1559 discard basefee for coinbase transfer. Basefee amount of gas is discarded. - let coinbase_gas_price = if SPEC::enabled(LONDON) { + let coinbase_gas_price = if SPEC::enabled(SpecId::LONDON) { effective_gas_price.saturating_sub(*context.evm.env.block.basefee()) } else { effective_gas_price diff --git a/crates/revm/src/handler/mainnet/pre_execution.rs b/crates/revm/src/handler/mainnet/pre_execution.rs index 2cebe246f6..e81f091db8 100644 --- a/crates/revm/src/handler/mainnet/pre_execution.rs +++ b/crates/revm/src/handler/mainnet/pre_execution.rs @@ -2,13 +2,19 @@ //! //! They handle initial setup of the EVM, call loop and the final return of the EVM -use crate::{ - precompile::PrecompileSpecId, - primitives::{ - eip7702, Account, Block, Bytecode, EVMError, EVMResultGeneric, EnvWiring, Spec, SpecId, - Transaction, BLOCKHASH_STORAGE_ADDRESS, PRAGUE, U256, - }, - Context, ContextPrecompiles, EvmWiring, +use crate::{Context, ContextPrecompiles, EvmWiring}; +use bytecode::Bytecode; +use precompile::PrecompileSpecId; +use primitives::{BLOCKHASH_STORAGE_ADDRESS, U256}; +use specification::{ + eip7702, + hardfork::{Spec, SpecId}, +}; +use state::Account; +use wiring::{ + default::EnvWiring, + result::{EVMError, EVMResultGeneric}, + Block, Transaction, }; /// Main precompile load @@ -108,7 +114,7 @@ pub fn apply_eip7702_auth_list( context: &mut Context, ) -> EVMResultGeneric { // EIP-7702. Load bytecode to authorized accounts. - if !SPEC::enabled(PRAGUE) { + if !SPEC::enabled(SpecId::PRAGUE) { return Ok(0); } diff --git a/crates/revm/src/handler/mainnet/validation.rs b/crates/revm/src/handler/mainnet/validation.rs index 4fd11a25c2..e50cdb29bb 100644 --- a/crates/revm/src/handler/mainnet/validation.rs +++ b/crates/revm/src/handler/mainnet/validation.rs @@ -1,11 +1,10 @@ -use revm_interpreter::gas; - -use crate::{ - primitives::{ - EVMError, EVMResultGeneric, EnvWiring, InvalidTransaction, Spec, Transaction, - TransactionValidation, - }, - Context, EvmWiring, +use crate::{Context, EvmWiring}; +use interpreter::gas; +use specification::hardfork::Spec; +use wiring::{ + default::EnvWiring, + result::{EVMError, EVMResultGeneric, InvalidTransaction}, + transaction::{Transaction, TransactionValidation}, }; /// Validate environment for the mainnet. diff --git a/crates/revm/src/inspector.rs b/crates/revm/src/inspector.rs index b84c85b43c..70db076d2d 100644 --- a/crates/revm/src/inspector.rs +++ b/crates/revm/src/inspector.rs @@ -8,14 +8,13 @@ mod noop; pub use handler_register::{inspector_handle_register, GetInspector}; -use crate::{ - interpreter::{ - CallInputs, CallOutcome, CreateInputs, CreateOutcome, EOFCreateInputs, Interpreter, - }, - primitives::{Address, Log, U256}, - EvmContext, EvmWiring, +use interpreter::{ + CallInputs, CallOutcome, CreateInputs, CreateOutcome, EOFCreateInputs, Interpreter, }; + +use crate::{EvmContext, EvmWiring}; use auto_impl::auto_impl; +use primitives::{Address, Log, U256}; /// [Inspector] implementations. pub mod inspectors { diff --git a/crates/revm/src/inspector/customprinter.rs b/crates/revm/src/inspector/customprinter.rs index c7abd718fb..d5259a0a68 100644 --- a/crates/revm/src/inspector/customprinter.rs +++ b/crates/revm/src/inspector/customprinter.rs @@ -1,16 +1,9 @@ //! Custom print inspector, it has step level information of execution. //! It is a great tool if some debugging is needed. -use revm_interpreter::CallOutcome; -use revm_interpreter::CreateOutcome; -use revm_interpreter::OpCode; - -use crate::{ - inspectors::GasInspector, - interpreter::{CallInputs, CreateInputs, Interpreter}, - primitives::{Address, U256}, - EvmContext, EvmWiring, Inspector, -}; +use crate::{inspectors::GasInspector, EvmContext, EvmWiring, Inspector}; +use interpreter::{CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter, OpCode}; +use primitives::{Address, U256}; /// Custom print [Inspector], it has step level information of execution. /// @@ -117,12 +110,13 @@ impl Inspector for CustomPrintTracer { #[cfg(test)] mod test { - use crate::{ - inspector_handle_register, - inspectors::CustomPrintTracer, - primitives::{address, bytes, EthereumWiring, SpecId}, - Evm, InMemoryDB, - }; + use super::*; + use crate::{inspector_handle_register, Evm, InMemoryDB}; + use bytecode::Bytecode; + use primitives::{address, bytes, keccak256, Bytes, TxKind, U256}; + use specification::hardfork::SpecId; + use state::AccountInfo; + use wiring::EthereumWiring; #[test] fn gas_calculation_underflow() { @@ -135,19 +129,19 @@ mod test { .with_default_ext_ctx() .modify_db(|db| { let code = bytes!("5b597fb075978b6c412c64d169d56d839a8fe01b3f4607ed603b2c78917ce8be1430fe6101e8527ffe64706ecad72a2f5c97a95e006e279dc57081902029ce96af7edae5de116fec610208527f9fc1ef09d4dd80683858ae3ea18869fe789ddc365d8d9d800e26c9872bac5e5b6102285260276102485360d461024953601661024a53600e61024b53607d61024c53600961024d53600b61024e5360b761024f5360596102505360796102515360a061025253607261025353603a6102545360fb61025553601261025653602861025753600761025853606f61025953601761025a53606161025b53606061025c5360a661025d53602b61025e53608961025f53607a61026053606461026153608c6102625360806102635360d56102645360826102655360ae61026653607f6101e8610146610220677a814b184591c555735fdcca53617f4d2b9134b29090c87d01058e27e962047654f259595947443b1b816b65cdb6277f4b59c10a36f4e7b8658f5a5e6f5561"); - let info = crate::primitives::AccountInfo { + let info = AccountInfo { balance: "0x100c5d668240db8e00".parse().unwrap(), - code_hash: crate::primitives::keccak256(&code), - code: Some(crate::primitives::Bytecode::new_raw(code.clone())), + code_hash: keccak256(&code), + code: Some(Bytecode::new_raw(code.clone())), nonce: 1, }; db.insert_account_info(callee, info); }) .modify_tx_env(|tx| { tx.caller = address!("5fdcca53617f4d2b9134b29090c87d01058e27e0"); - tx.transact_to = crate::primitives::TxKind::Call(callee); - tx.data = crate::primitives::Bytes::new(); - tx.value = crate::primitives::U256::ZERO; + tx.transact_to = TxKind::Call(callee); + tx.data = Bytes::new(); + tx.value = U256::ZERO; }) .with_spec_id(SpecId::BERLIN) .append_handler_register(inspector_handle_register) diff --git a/crates/revm/src/inspector/eip3155.rs b/crates/revm/src/inspector/eip3155.rs index eeb04e5592..394a5dee91 100644 --- a/crates/revm/src/inspector/eip3155.rs +++ b/crates/revm/src/inspector/eip3155.rs @@ -1,15 +1,13 @@ -use crate::{ - inspectors::GasInspector, - interpreter::{ - CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter, InterpreterResult, - }, - primitives::{hex, HashMap, Transaction, B256, U256}, - EvmContext, EvmWiring, Inspector, -}; +use crate::{inspectors::GasInspector, EvmContext, EvmWiring, Inspector}; use derive_where::derive_where; -use revm_interpreter::OpCode; + +use interpreter::{ + CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter, InterpreterResult, OpCode, +}; +use primitives::{hex, HashMap, B256, U256}; use serde::Serialize; use std::io::Write; +use wiring::Transaction; /// [EIP-3155](https://eips.ethereum.org/EIPS/eip-3155) tracer [Inspector]. #[derive_where(Debug)] diff --git a/crates/revm/src/inspector/gas.rs b/crates/revm/src/inspector/gas.rs index 587802b805..94eb607dbc 100644 --- a/crates/revm/src/inspector/gas.rs +++ b/crates/revm/src/inspector/gas.rs @@ -1,11 +1,7 @@ //! GasIspector. Helper Inspector to calculate gas for others. -use revm_interpreter::CallOutcome; - -use crate::{ - interpreter::{CallInputs, CreateInputs, CreateOutcome}, - EvmContext, EvmWiring, Inspector, -}; +use crate::{EvmContext, EvmWiring, Inspector}; +use interpreter::{CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter}; /// Helper [Inspector] that keeps track of gas. #[allow(dead_code)] @@ -28,25 +24,17 @@ impl GasInspector { impl Inspector for GasInspector { fn initialize_interp( &mut self, - interp: &mut crate::interpreter::Interpreter, + interp: &mut Interpreter, _context: &mut EvmContext, ) { self.gas_remaining = interp.gas.limit(); } - fn step( - &mut self, - interp: &mut crate::interpreter::Interpreter, - _context: &mut EvmContext, - ) { + fn step(&mut self, interp: &mut Interpreter, _context: &mut EvmContext) { self.gas_remaining = interp.gas.remaining(); } - fn step_end( - &mut self, - interp: &mut crate::interpreter::Interpreter, - _context: &mut EvmContext, - ) { + fn step_end(&mut self, interp: &mut Interpreter, _context: &mut EvmContext) { let remaining = interp.gas.remaining(); self.last_gas_cost = self.gas_remaining.saturating_sub(remaining); self.gas_remaining = remaining; @@ -82,13 +70,13 @@ impl Inspector for GasInspector { #[cfg(test)] mod tests { use super::*; + use crate::{db::BenchmarkDB, inspector::inspector_handle_register, Evm, EvmWiring}; + use bytecode::Bytecode; + use interpreter::{opcode, Interpreter}; + use primitives::{address, Bytes, Log, TxKind}; + use wiring::{DefaultEthereumWiring, EthereumWiring, EvmWiring as PrimitiveEvmWiring}; - use crate::{ - interpreter::Interpreter, - primitives::{self, EthereumWiring, Log}, - }; - - type TestEvmWiring = primitives::DefaultEthereumWiring; + type TestEvmWiring = DefaultEthereumWiring; #[derive(Default, Debug)] struct StackInspector { @@ -164,14 +152,6 @@ mod tests { #[test] fn test_gas_inspector() { - use crate::{ - db::BenchmarkDB, - inspector::inspector_handle_register, - interpreter::opcode, - primitives::{address, Bytecode, Bytes, TxKind}, - Evm, - }; - let contract_data: Bytes = Bytes::from(vec![ opcode::PUSH1, 0x1, @@ -193,7 +173,7 @@ mod tests { .with_db(BenchmarkDB::new_bytecode(bytecode.clone())) .with_default_ext_ctx() .modify_tx_env(|tx| { - *tx = ::Transaction::default(); + *tx = ::Transaction::default(); tx.caller = address!("1000000000000000000000000000000000000000"); tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000")); diff --git a/crates/revm/src/inspector/handler_register.rs b/crates/revm/src/inspector/handler_register.rs index 885d7d7d96..35bf2e60fc 100644 --- a/crates/revm/src/inspector/handler_register.rs +++ b/crates/revm/src/inspector/handler_register.rs @@ -1,12 +1,11 @@ use crate::{ - handler::register::EvmHandler, - interpreter::{opcode, InstructionResult, Interpreter}, - primitives::EVMResultGeneric, - Context, EvmWiring, FrameOrResult, FrameResult, Inspector, JournalEntry, + handler::register::EvmHandler, Context, EvmWiring, FrameOrResult, FrameResult, Inspector, + JournalEntry, }; use core::cell::RefCell; -use revm_interpreter::opcode::DynInstruction; +use interpreter::{opcode, opcode::DynInstruction, InstructionResult, Interpreter}; use std::{rc::Rc, sync::Arc, vec::Vec}; +use wiring::result::EVMResultGeneric; /// Provides access to an `Inspector` instance. pub trait GetInspector { @@ -263,13 +262,16 @@ fn inspector_instruction( mod tests { use super::*; use crate::{ - inspectors::NoOpInspector, - interpreter::{CallInputs, CallOutcome, CreateInputs, CreateOutcome}, - primitives::{self, db::EmptyDB, EthereumWiring}, - Evm, EvmContext, + db::BenchmarkDB, inspector::inspector_handle_register, inspectors::NoOpInspector, Evm, + EvmContext, EvmWiring, }; + use bytecode::Bytecode; + use database_interface::EmptyDB; + use interpreter::{opcode, CallInputs, CallOutcome, CreateInputs, CreateOutcome}; + use primitives::{address, Bytes, TxKind}; + use wiring::{DefaultEthereumWiring, EthereumWiring, EvmWiring as PrimitiveEvmWiring}; - type TestEvmWiring = primitives::DefaultEthereumWiring; + type TestEvmWiring = DefaultEthereumWiring; #[derive(Default, Debug)] struct StackInspector { @@ -349,14 +351,6 @@ mod tests { #[test] fn test_inspector_handlers() { - use crate::{ - db::BenchmarkDB, - inspector::inspector_handle_register, - interpreter::opcode, - primitives::{address, Bytecode, Bytes, TxKind}, - Evm, - }; - let contract_data: Bytes = Bytes::from(vec![ opcode::PUSH1, 0x1, @@ -378,7 +372,7 @@ mod tests { .with_db(BenchmarkDB::new_bytecode(bytecode.clone())) .with_external_context(StackInspector::default()) .modify_tx_env(|tx| { - *tx = ::Transaction::default(); + *tx = ::Transaction::default(); tx.caller = address!("1000000000000000000000000000000000000000"); tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000")); diff --git a/crates/revm/src/journaled_state.rs b/crates/revm/src/journaled_state.rs index b839355005..3eedcfb944 100644 --- a/crates/revm/src/journaled_state.rs +++ b/crates/revm/src/journaled_state.rs @@ -1,13 +1,14 @@ -use revm_interpreter::Eip7702CodeLoad; - -use crate::{ - interpreter::{AccountLoad, InstructionResult, SStoreResult, SelfDestructResult, StateLoad}, - primitives::{ - db::Database, hash_map::Entry, Account, Address, Bytecode, EvmState, EvmStorageSlot, - HashMap, HashSet, Log, SpecId, SpecId::*, TransientStorage, B256, KECCAK_EMPTY, - PRECOMPILE3, U256, - }, +use bytecode::Bytecode; +use database_interface::Database; +use interpreter::{ + AccountLoad, Eip7702CodeLoad, InstructionResult, SStoreResult, SelfDestructResult, StateLoad, +}; +use primitives::{ + hash_map::Entry, Address, HashMap, HashSet, Log, B256, KECCAK_EMPTY, PRECOMPILE3, U256, }; +use specification::hardfork::{SpecId, SpecId::*}; +use state::{Account, EvmState, EvmStorageSlot, TransientStorage}; + use core::mem; use std::vec::Vec; diff --git a/crates/revm/src/lib.rs b/crates/revm/src/lib.rs index 33f77cff9d..8711786400 100644 --- a/crates/revm/src/lib.rs +++ b/crates/revm/src/lib.rs @@ -6,11 +6,19 @@ #[cfg(not(feature = "std"))] extern crate alloc as std; -// Define modules. +// reexport dependencies +pub use bytecode; +pub use database_interface; +pub use interpreter; +pub use precompile; +pub use primitives; +pub use specification; +pub use state; +pub use wiring; +// Define modules. mod builder; mod context; - #[cfg(any(test, feature = "test-utils"))] pub mod test_utils; @@ -30,21 +38,14 @@ pub use context::{ ContextStatefulPrecompileArc, ContextStatefulPrecompileBox, ContextStatefulPrecompileMut, ContextWithEvmWiring, EvmContext, InnerEvmContext, }; +pub use database_interface::{Database, DatabaseCommit, DatabaseRef}; +pub use db::InMemoryDB; pub use db::{ CacheState, DBBox, State, StateBuilder, StateDBBox, TransitionAccount, TransitionState, }; -pub use db::{Database, DatabaseCommit, DatabaseRef, InMemoryDB}; pub use evm::{Evm, CALL_STACK_LIMIT}; pub use evm_wiring::EvmWiring; pub use frame::{CallFrame, CreateFrame, Frame, FrameData, FrameOrResult, FrameResult}; pub use handler::{register::EvmHandler, Handler}; pub use inspector::{inspector_handle_register, inspectors, GetInspector, Inspector}; pub use journaled_state::{JournalCheckpoint, JournalEntry, JournaledState}; -// Reexport libraries - -#[doc(inline)] -pub use revm_interpreter as interpreter; -#[doc(inline)] -pub use revm_interpreter::primitives; -#[doc(inline)] -pub use revm_precompile as precompile; diff --git a/crates/specification/CHANGELOG.md b/crates/specification/CHANGELOG.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/specification/Cargo.toml b/crates/specification/Cargo.toml new file mode 100644 index 0000000000..02ea8850f3 --- /dev/null +++ b/crates/specification/Cargo.toml @@ -0,0 +1,49 @@ +[package] +authors = ["Dragan Rakita "] +description = "Revm Database interface" +edition = "2021" +keywords = ["ethereum", "evm", "revm", "no_std"] +license = "MIT" +name = "revm-specification" +repository = "https://github.com/bluealloy/revm" +version = "1.0.0" +readme = "../../README.md" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints.rust] +unreachable_pub = "warn" +unused_must_use = "deny" +rust_2018_idioms = "deny" + +[lints.rustdoc] +all = "warn" + +[dependencies] +primitives = { path = "../primitives", package = "revm-primitives", version = "9.0.1", default-features = false } + +# alloy +alloy-eips = { version = "0.3", default-features = false, features = ["k256"] } +alloy-primitives = { version = "0.8.2", default-features = false, features = [ + "rlp", +] } + +# misc +enumn = { version = "0.1" } + +# Optional +serde = { version = "1.0", default-features = false, features = [ + "derive", + "rc", +], optional = true } + + +[dev-dependencies] + +[features] +default = ["std"] +std = ["serde?/std"] +serde = ["dep:serde", "alloy-eips/serde", "alloy-primitives/serde"] +serde-json = ["serde"] diff --git a/crates/specification/LICENSE b/crates/specification/LICENSE new file mode 100644 index 0000000000..ad98ff22cc --- /dev/null +++ b/crates/specification/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2024 draganrakita + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/specification/src/eip170.rs b/crates/specification/src/eip170.rs new file mode 100644 index 0000000000..46fa7f3b58 --- /dev/null +++ b/crates/specification/src/eip170.rs @@ -0,0 +1,6 @@ +//! EIP-170: Contract code size limit + +/// EIP-170: Contract code size limit +/// +/// By default the limit is `0x6000` (~25kb) +pub const MAX_CODE_SIZE: usize = 0x6000; diff --git a/crates/specification/src/eip2.rs b/crates/specification/src/eip2.rs new file mode 100644 index 0000000000..79f3b13c40 --- /dev/null +++ b/crates/specification/src/eip2.rs @@ -0,0 +1,10 @@ +use primitives::U256; + +/// The order of the secp256k1 curve, divided by two. Signatures that should be checked according +/// to EIP-2 should have an S value less than or equal to this. +/// +/// `57896044618658097711785492504343953926418782139537452191302581570759080747168` +pub const SECP256K1N_HALF: U256 = U256::from_be_bytes([ + 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x5D, 0x57, 0x6E, 0x73, 0x57, 0xA4, 0x50, 0x1D, 0xDF, 0xE9, 0x2F, 0x46, 0x68, 0x1B, 0x20, 0xA0, +]); diff --git a/crates/specification/src/eip2930.rs b/crates/specification/src/eip2930.rs new file mode 100644 index 0000000000..f9e60653a9 --- /dev/null +++ b/crates/specification/src/eip2930.rs @@ -0,0 +1 @@ +pub use alloy_eips::eip2930::{AccessList, AccessListItem}; diff --git a/crates/specification/src/eip7702.rs b/crates/specification/src/eip7702.rs new file mode 100644 index 0000000000..e0ee45dacd --- /dev/null +++ b/crates/specification/src/eip7702.rs @@ -0,0 +1,9 @@ +mod authorization_list; +mod constants; +mod recovered_authorization; + +pub use authorization_list::*; +pub use constants::*; +pub use recovered_authorization::*; + +pub use alloy_eips::eip7702::{Authorization, SignedAuthorization}; diff --git a/crates/primitives/src/eip7702/authorization_list.rs b/crates/specification/src/eip7702/authorization_list.rs similarity index 70% rename from crates/primitives/src/eip7702/authorization_list.rs rename to crates/specification/src/eip7702/authorization_list.rs index 6032bcdcd1..546fea6dcc 100644 --- a/crates/primitives/src/eip7702/authorization_list.rs +++ b/crates/specification/src/eip7702/authorization_list.rs @@ -1,9 +1,7 @@ -pub use alloy_eips::eip7702::{Authorization, SignedAuthorization}; +use super::RecoveredAuthorization; +use crate::{eip2::SECP256K1N_HALF, eip7702::SignedAuthorization}; pub use alloy_primitives::{Parity, Signature}; - -use super::SECP256K1N_HALF; -use crate::Address; -use core::{fmt, ops::Deref}; +use core::fmt; use std::{boxed::Box, vec::Vec}; /// Authorization list for EIP-7702 transaction type. @@ -62,7 +60,7 @@ impl AuthorizationList { Self::Signed(signed) => signed.iter().try_for_each(validate)?, Self::Recovered(recovered) => recovered .iter() - .map(|recovered| &recovered.inner) + .map(|recovered| recovered.inner()) .try_for_each(validate)?, }; @@ -96,49 +94,6 @@ impl AuthorizationList { } } -/// A recovered authorization. -#[derive(Debug, Clone, Hash, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RecoveredAuthorization { - #[cfg_attr(feature = "serde", serde(flatten))] - inner: SignedAuthorization, - authority: Option
, -} - -impl RecoveredAuthorization { - /// Instantiate without performing recovery. This should be used carefully. - pub const fn new_unchecked(inner: SignedAuthorization, authority: Option
) -> Self { - Self { inner, authority } - } - - /// Get the `authority` for the authorization. - /// - /// If this is `None`, then the authority could not be recovered. - pub const fn authority(&self) -> Option
{ - self.authority - } - - /// Splits the authorization into parts. - pub const fn into_parts(self) -> (SignedAuthorization, Option
) { - (self.inner, self.authority) - } -} - -impl From for RecoveredAuthorization { - fn from(signed_auth: SignedAuthorization) -> Self { - let authority = signed_auth.recover_authority().ok(); - Self::new_unchecked(signed_auth, authority) - } -} - -impl Deref for RecoveredAuthorization { - type Target = Authorization; - - fn deref(&self) -> &Self::Target { - &self.inner - } -} - #[derive(Debug, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum InvalidAuthorization { diff --git a/crates/specification/src/eip7702/constants.rs b/crates/specification/src/eip7702/constants.rs new file mode 100644 index 0000000000..626b70dbbd --- /dev/null +++ b/crates/specification/src/eip7702/constants.rs @@ -0,0 +1,7 @@ +//! EIP-7702 constants. + +// Base cost of updating authorized account. +pub const PER_AUTH_BASE_COST: u64 = 2500; + +/// Cost of creating authorized account that was previously empty. +pub const PER_EMPTY_ACCOUNT_COST: u64 = 25000; diff --git a/crates/specification/src/eip7702/recovered_authorization.rs b/crates/specification/src/eip7702/recovered_authorization.rs new file mode 100644 index 0000000000..41f3d401fc --- /dev/null +++ b/crates/specification/src/eip7702/recovered_authorization.rs @@ -0,0 +1,51 @@ +use crate::eip7702::{Authorization, SignedAuthorization}; +use core::ops::Deref; +use primitives::Address; + +/// A recovered authorization. +#[derive(Debug, Clone, Hash, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct RecoveredAuthorization { + #[cfg_attr(feature = "serde", serde(flatten))] + inner: SignedAuthorization, + authority: Option
, +} + +impl RecoveredAuthorization { + /// Instantiate without performing recovery. This should be used carefully. + pub const fn new_unchecked(inner: SignedAuthorization, authority: Option
) -> Self { + Self { inner, authority } + } + + /// Returns a reference to the inner [`SignedAuthorization`]. + pub fn inner(&self) -> &SignedAuthorization { + &self.inner + } + + /// Get the `authority` for the authorization. + /// + /// If this is `None`, then the authority could not be recovered. + pub const fn authority(&self) -> Option
{ + self.authority + } + + /// Splits the authorization into parts. + pub const fn into_parts(self) -> (SignedAuthorization, Option
) { + (self.inner, self.authority) + } +} + +impl From for RecoveredAuthorization { + fn from(signed_auth: SignedAuthorization) -> Self { + let authority = signed_auth.recover_authority().ok(); + Self::new_unchecked(signed_auth, authority) + } +} + +impl Deref for RecoveredAuthorization { + type Target = Authorization; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} diff --git a/crates/primitives/src/specification.rs b/crates/specification/src/hardfork.rs similarity index 82% rename from crates/primitives/src/specification.rs rename to crates/specification/src/hardfork.rs index 933bad621b..56d7590a6b 100644 --- a/crates/primitives/src/specification.rs +++ b/crates/specification/src/hardfork.rs @@ -184,66 +184,66 @@ spec!(LATEST, LatestSpec); macro_rules! spec_to_generic { ($spec_id:expr, $e:expr) => {{ match $spec_id { - $crate::SpecId::FRONTIER | $crate::SpecId::FRONTIER_THAWING => { - use $crate::FrontierSpec as SPEC; + $crate::hardfork::SpecId::FRONTIER | $crate::hardfork::SpecId::FRONTIER_THAWING => { + use $crate::hardfork::FrontierSpec as SPEC; $e } - $crate::SpecId::HOMESTEAD | $crate::SpecId::DAO_FORK => { - use $crate::HomesteadSpec as SPEC; + $crate::hardfork::SpecId::HOMESTEAD | $crate::hardfork::SpecId::DAO_FORK => { + use $crate::hardfork::HomesteadSpec as SPEC; $e } - $crate::SpecId::TANGERINE => { - use $crate::TangerineSpec as SPEC; + $crate::hardfork::SpecId::TANGERINE => { + use $crate::hardfork::TangerineSpec as SPEC; $e } - $crate::SpecId::SPURIOUS_DRAGON => { - use $crate::SpuriousDragonSpec as SPEC; + $crate::hardfork::SpecId::SPURIOUS_DRAGON => { + use $crate::hardfork::SpuriousDragonSpec as SPEC; $e } - $crate::SpecId::BYZANTIUM => { - use $crate::ByzantiumSpec as SPEC; + $crate::hardfork::SpecId::BYZANTIUM => { + use $crate::hardfork::ByzantiumSpec as SPEC; $e } - $crate::SpecId::PETERSBURG | $crate::SpecId::CONSTANTINOPLE => { - use $crate::PetersburgSpec as SPEC; + $crate::hardfork::SpecId::PETERSBURG | $crate::hardfork::SpecId::CONSTANTINOPLE => { + use $crate::hardfork::PetersburgSpec as SPEC; $e } - $crate::SpecId::ISTANBUL | $crate::SpecId::MUIR_GLACIER => { - use $crate::IstanbulSpec as SPEC; + $crate::hardfork::SpecId::ISTANBUL | $crate::hardfork::SpecId::MUIR_GLACIER => { + use $crate::hardfork::IstanbulSpec as SPEC; $e } - $crate::SpecId::BERLIN => { - use $crate::BerlinSpec as SPEC; + $crate::hardfork::SpecId::BERLIN => { + use $crate::hardfork::BerlinSpec as SPEC; $e } - $crate::SpecId::LONDON - | $crate::SpecId::ARROW_GLACIER - | $crate::SpecId::GRAY_GLACIER => { - use $crate::LondonSpec as SPEC; + $crate::hardfork::SpecId::LONDON + | $crate::hardfork::SpecId::ARROW_GLACIER + | $crate::hardfork::SpecId::GRAY_GLACIER => { + use $crate::hardfork::LondonSpec as SPEC; $e } - $crate::SpecId::MERGE => { - use $crate::MergeSpec as SPEC; + $crate::hardfork::SpecId::MERGE => { + use $crate::hardfork::MergeSpec as SPEC; $e } - $crate::SpecId::SHANGHAI => { - use $crate::ShanghaiSpec as SPEC; + $crate::hardfork::SpecId::SHANGHAI => { + use $crate::hardfork::ShanghaiSpec as SPEC; $e } - $crate::SpecId::CANCUN => { - use $crate::CancunSpec as SPEC; + $crate::hardfork::SpecId::CANCUN => { + use $crate::hardfork::CancunSpec as SPEC; $e } - $crate::SpecId::LATEST => { - use $crate::LatestSpec as SPEC; + $crate::hardfork::SpecId::LATEST => { + use $crate::hardfork::LatestSpec as SPEC; $e } - $crate::SpecId::PRAGUE => { - use $crate::PragueSpec as SPEC; + $crate::hardfork::SpecId::PRAGUE => { + use $crate::hardfork::PragueSpec as SPEC; $e } - $crate::SpecId::PRAGUE_EOF => { - use $crate::PragueEofSpec as SPEC; + $crate::hardfork::SpecId::PRAGUE_EOF => { + use $crate::hardfork::PragueEofSpec as SPEC; $e } } diff --git a/crates/specification/src/lib.rs b/crates/specification/src/lib.rs new file mode 100644 index 0000000000..45fe59d601 --- /dev/null +++ b/crates/specification/src/lib.rs @@ -0,0 +1,12 @@ +//! Optimism-specific constants, types, and helpers. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(not(feature = "std"))] +extern crate alloc as std; + +pub mod eip170; +pub mod eip2; +pub mod eip2930; +pub mod eip7702; +pub mod hardfork; diff --git a/crates/state/CHANGELOG.md b/crates/state/CHANGELOG.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/state/Cargo.toml b/crates/state/Cargo.toml new file mode 100644 index 0000000000..79d747eb1a --- /dev/null +++ b/crates/state/Cargo.toml @@ -0,0 +1,49 @@ +[package] +authors = ["Dragan Rakita "] +description = "Revm state types" +edition = "2021" +keywords = ["ethereum", "evm", "revm", "no_std"] +license = "MIT" +name = "revm-state" +repository = "https://github.com/bluealloy/revm" +version = "1.0.0" +readme = "../../README.md" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints.rust] +unreachable_pub = "warn" +unused_must_use = "deny" +rust_2018_idioms = "deny" + +[lints.rustdoc] +all = "warn" + +[dependencies] +# revm +primitives.workspace = true +bytecode.workspace = true +specification.workspace = true + +# misc +bitflags = { version = "2.6.0", default-features = false } + +# Optional +serde = { version = "1.0", default-features = false, features = [ + "derive", + "rc", +], optional = true } + + +[features] +serde = [ + "dep:serde", + "primitives/serde", + "bitflags/serde", + "bytecode/serde", + "specification/serde", +] +default = ["std"] +std = ["serde?/std", "primitives/std"] diff --git a/crates/state/LICENSE b/crates/state/LICENSE new file mode 100644 index 0000000000..ad98ff22cc --- /dev/null +++ b/crates/state/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2024 draganrakita + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/state/src/account_info.rs b/crates/state/src/account_info.rs new file mode 100644 index 0000000000..ecdd8eabc9 --- /dev/null +++ b/crates/state/src/account_info.rs @@ -0,0 +1,144 @@ +use bytecode::Bytecode; +use core::hash::{Hash, Hasher}; +use primitives::{B256, KECCAK_EMPTY, U256}; + +/// AccountInfo account information. +#[derive(Clone, Debug, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct AccountInfo { + /// Account balance. + pub balance: U256, + /// Account nonce. + pub nonce: u64, + /// code hash, + pub code_hash: B256, + /// code: if None, `code_by_hash` will be used to fetch it if code needs to be loaded from + /// inside `revm`. + pub code: Option, +} + +impl Default for AccountInfo { + fn default() -> Self { + Self { + balance: U256::ZERO, + code_hash: KECCAK_EMPTY, + code: Some(Bytecode::default()), + nonce: 0, + } + } +} + +impl PartialEq for AccountInfo { + fn eq(&self, other: &Self) -> bool { + self.balance == other.balance + && self.nonce == other.nonce + && self.code_hash == other.code_hash + } +} + +impl Hash for AccountInfo { + fn hash(&self, state: &mut H) { + self.balance.hash(state); + self.nonce.hash(state); + self.code_hash.hash(state); + } +} + +impl AccountInfo { + pub fn new(balance: U256, nonce: u64, code_hash: B256, code: Bytecode) -> Self { + Self { + balance, + nonce, + code: Some(code), + code_hash, + } + } + + /// Returns a copy of this account with the [`Bytecode`] removed. This is + /// useful when creating journals or snapshots of the state, where it is + /// desirable to store the code blobs elsewhere. + /// + /// ## Note + /// + /// This is distinct from [`AccountInfo::without_code`] in that it returns + /// a new `AccountInfo` instance with the code removed. + /// [`AccountInfo::without_code`] will modify and return the same instance. + pub fn copy_without_code(&self) -> Self { + Self { + balance: self.balance, + nonce: self.nonce, + code_hash: self.code_hash, + code: None, + } + } + + /// Strip the [`Bytecode`] from this account and drop it. This is + /// useful when creating journals or snapshots of the state, where it is + /// desirable to store the code blobs elsewhere. + /// + /// ## Note + /// + /// This is distinct from [`AccountInfo::copy_without_code`] in that it + /// modifies the account in place. [`AccountInfo::copy_without_code`] + /// will copy the non-code fields and return a new `AccountInfo` instance. + pub fn without_code(mut self) -> Self { + self.take_bytecode(); + self + } + + /// Returns if an account is empty. + /// + /// An account is empty if the following conditions are met. + /// - code hash is zero or set to the Keccak256 hash of the empty string `""` + /// - balance is zero + /// - nonce is zero + pub fn is_empty(&self) -> bool { + let code_empty = self.is_empty_code_hash() || self.code_hash.is_zero(); + code_empty && self.balance.is_zero() && self.nonce == 0 + } + + /// Returns `true` if the account is not empty. + pub fn exists(&self) -> bool { + !self.is_empty() + } + + /// Returns `true` if account has no nonce and code. + pub fn has_no_code_and_nonce(&self) -> bool { + self.is_empty_code_hash() && self.nonce == 0 + } + + /// Return bytecode hash associated with this account. + /// If account does not have code, it returns `KECCAK_EMPTY` hash. + pub fn code_hash(&self) -> B256 { + self.code_hash + } + + /// Returns true if the code hash is the Keccak256 hash of the empty string `""`. + #[inline] + pub fn is_empty_code_hash(&self) -> bool { + self.code_hash == KECCAK_EMPTY + } + + /// Take bytecode from account. Code will be set to None. + pub fn take_bytecode(&mut self) -> Option { + self.code.take() + } + + pub fn from_balance(balance: U256) -> Self { + AccountInfo { + balance, + ..Default::default() + } + } + + pub fn from_bytecode(bytecode: Bytecode) -> Self { + let hash = bytecode.hash_slow(); + + AccountInfo { + balance: U256::ZERO, + nonce: 1, + code: Some(bytecode), + code_hash: hash, + } + } +} diff --git a/crates/primitives/src/state.rs b/crates/state/src/lib.rs similarity index 65% rename from crates/primitives/src/state.rs rename to crates/state/src/lib.rs index 8415170d36..06c730ab7c 100644 --- a/crates/primitives/src/state.rs +++ b/crates/state/src/lib.rs @@ -1,15 +1,19 @@ -use crate::{Address, Bytecode, HashMap, SpecId, B256, KECCAK_EMPTY, U256}; -use bitflags::bitflags; -use core::hash::{Hash, Hasher}; +//! Optimism-specific constants, types, and helpers. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(not(feature = "std"), no_std)] -/// EVM State is a mapping from addresses to accounts. -pub type EvmState = HashMap; +mod account_info; +mod types; -/// Structure used for EIP-1153 transient storage. -pub type TransientStorage = HashMap<(Address, U256), U256>; +pub use account_info::AccountInfo; +pub use bytecode::Bytecode; +pub use primitives; +pub use types::{EvmState, EvmStorage, TransientStorage}; -/// An account's Storage is a mapping from 256-bit integer keys to [EvmStorageSlot]s. -pub type EvmStorage = HashMap; +use bitflags::bitflags; +use core::hash::Hash; +use primitives::{HashMap, U256}; +use specification::hardfork::SpecId; #[derive(Debug, Clone, PartialEq, Eq, Default)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] @@ -22,36 +26,6 @@ pub struct Account { pub status: AccountStatus, } -// The `bitflags!` macro generates `struct`s that manage a set of flags. -bitflags! { - #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] - #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - #[cfg_attr(feature = "serde", serde(transparent))] - pub struct AccountStatus: u8 { - /// When account is loaded but not touched or interacted with. - /// This is the default state. - const Loaded = 0b00000000; - /// When account is newly created we will not access database - /// to fetch storage values - const Created = 0b00000001; - /// If account is marked for self destruction. - const SelfDestructed = 0b00000010; - /// Only when account is marked as touched we will save it to database. - const Touched = 0b00000100; - /// used only for pre spurious dragon hardforks where existing and empty were two separate states. - /// it became same state after EIP-161: State trie clearing - const LoadedAsNotExisting = 0b0001000; - /// used to mark account as cold - const Cold = 0b0010000; - } -} - -impl Default for AccountStatus { - fn default() -> Self { - Self::Loaded - } -} - impl Account { /// Create new account and mark it as non existing. pub fn new_not_existing() -> Self { @@ -164,6 +138,36 @@ impl From for Account { } } +// The `bitflags!` macro generates `struct`s that manage a set of flags. +bitflags! { + #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", serde(transparent))] + pub struct AccountStatus: u8 { + /// When account is loaded but not touched or interacted with. + /// This is the default state. + const Loaded = 0b00000000; + /// When account is newly created we will not access database + /// to fetch storage values + const Created = 0b00000001; + /// If account is marked for self destruction. + const SelfDestructed = 0b00000010; + /// Only when account is marked as touched we will save it to database. + const Touched = 0b00000100; + /// used only for pre spurious dragon hardforks where existing and empty were two separate states. + /// it became same state after EIP-161: State trie clearing + const LoadedAsNotExisting = 0b0001000; + /// used to mark account as cold + const Cold = 0b0010000; + } +} + +impl Default for AccountStatus { + fn default() -> Self { + Self::Loaded + } +} + /// This type keeps track of the current value of a storage slot. #[derive(Debug, Clone, Default, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] @@ -220,150 +224,10 @@ impl EvmStorageSlot { } } -/// AccountInfo account information. -#[derive(Clone, Debug, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AccountInfo { - /// Account balance. - pub balance: U256, - /// Account nonce. - pub nonce: u64, - /// code hash, - pub code_hash: B256, - /// code: if None, `code_by_hash` will be used to fetch it if code needs to be loaded from - /// inside `revm`. - pub code: Option, -} - -impl Default for AccountInfo { - fn default() -> Self { - Self { - balance: U256::ZERO, - code_hash: KECCAK_EMPTY, - code: Some(Bytecode::default()), - nonce: 0, - } - } -} - -impl PartialEq for AccountInfo { - fn eq(&self, other: &Self) -> bool { - self.balance == other.balance - && self.nonce == other.nonce - && self.code_hash == other.code_hash - } -} - -impl Hash for AccountInfo { - fn hash(&self, state: &mut H) { - self.balance.hash(state); - self.nonce.hash(state); - self.code_hash.hash(state); - } -} - -impl AccountInfo { - pub fn new(balance: U256, nonce: u64, code_hash: B256, code: Bytecode) -> Self { - Self { - balance, - nonce, - code: Some(code), - code_hash, - } - } - - /// Returns a copy of this account with the [`Bytecode`] removed. This is - /// useful when creating journals or snapshots of the state, where it is - /// desirable to store the code blobs elsewhere. - /// - /// ## Note - /// - /// This is distinct from [`AccountInfo::without_code`] in that it returns - /// a new `AccountInfo` instance with the code removed. - /// [`AccountInfo::without_code`] will modify and return the same instance. - pub fn copy_without_code(&self) -> Self { - Self { - balance: self.balance, - nonce: self.nonce, - code_hash: self.code_hash, - code: None, - } - } - - /// Strip the [`Bytecode`] from this account and drop it. This is - /// useful when creating journals or snapshots of the state, where it is - /// desirable to store the code blobs elsewhere. - /// - /// ## Note - /// - /// This is distinct from [`AccountInfo::copy_without_code`] in that it - /// modifies the account in place. [`AccountInfo::copy_without_code`] - /// will copy the non-code fields and return a new `AccountInfo` instance. - pub fn without_code(mut self) -> Self { - self.take_bytecode(); - self - } - - /// Returns if an account is empty. - /// - /// An account is empty if the following conditions are met. - /// - code hash is zero or set to the Keccak256 hash of the empty string `""` - /// - balance is zero - /// - nonce is zero - pub fn is_empty(&self) -> bool { - let code_empty = self.is_empty_code_hash() || self.code_hash.is_zero(); - code_empty && self.balance.is_zero() && self.nonce == 0 - } - - /// Returns `true` if the account is not empty. - pub fn exists(&self) -> bool { - !self.is_empty() - } - - /// Returns `true` if account has no nonce and code. - pub fn has_no_code_and_nonce(&self) -> bool { - self.is_empty_code_hash() && self.nonce == 0 - } - - /// Return bytecode hash associated with this account. - /// If account does not have code, it returns `KECCAK_EMPTY` hash. - pub fn code_hash(&self) -> B256 { - self.code_hash - } - - /// Returns true if the code hash is the Keccak256 hash of the empty string `""`. - #[inline] - pub fn is_empty_code_hash(&self) -> bool { - self.code_hash == KECCAK_EMPTY - } - - /// Take bytecode from account. Code will be set to None. - pub fn take_bytecode(&mut self) -> Option { - self.code.take() - } - - pub fn from_balance(balance: U256) -> Self { - AccountInfo { - balance, - ..Default::default() - } - } - - pub fn from_bytecode(bytecode: Bytecode) -> Self { - let hash = bytecode.hash_slow(); - - AccountInfo { - balance: U256::ZERO, - nonce: 1, - code: Some(bytecode), - code_hash: hash, - } - } -} - #[cfg(test)] mod tests { - use crate::{Account, KECCAK_EMPTY, U256}; + use crate::Account; + use primitives::{KECCAK_EMPTY, U256}; #[test] fn account_is_empty_balance() { diff --git a/crates/state/src/types.rs b/crates/state/src/types.rs new file mode 100644 index 0000000000..66a29b84e6 --- /dev/null +++ b/crates/state/src/types.rs @@ -0,0 +1,11 @@ +use super::{Account, EvmStorageSlot}; +use primitives::{Address, HashMap, U256}; + +/// EVM State is a mapping from addresses to accounts. +pub type EvmState = HashMap; + +/// Structure used for EIP-1153 transient storage. +pub type TransientStorage = HashMap<(Address, U256), U256>; + +/// An account's Storage is a mapping from 256-bit integer keys to [EvmStorageSlot]s. +pub type EvmStorage = HashMap; diff --git a/crates/wiring/CHANGELOG.md b/crates/wiring/CHANGELOG.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/wiring/Cargo.toml b/crates/wiring/Cargo.toml new file mode 100644 index 0000000000..242141280a --- /dev/null +++ b/crates/wiring/Cargo.toml @@ -0,0 +1,79 @@ +[package] +authors = ["Dragan Rakita "] +description = "Revm generic types wiring" +edition = "2021" +keywords = ["ethereum", "evm", "revm", "no_std"] +license = "MIT" +name = "revm-wiring" +repository = "https://github.com/bluealloy/revm" +version = "1.0.0" +readme = "../../README.md" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints.rust] +unreachable_pub = "warn" +unused_must_use = "deny" +rust_2018_idioms = "deny" + +[lints.rustdoc] +all = "warn" + +[dependencies] +# revm +primitives.workspace = true +database-interface.workspace = true +specification.workspace = true +state.workspace = true + +# mics +dyn-clone = "1.0" + +# Optional +serde = { version = "1.0", default-features = false, features = [ + "derive", + "rc", +], optional = true } + + +# For setting the CfgEnv KZGSettings. Enabled by c-kzg flag. +# Optionally use `kzg-rs`(Not audited) for a pure Rust implementation of KZG. +c-kzg = { version = "1.0.3", default-features = false, optional = true, features = [ + "ethereum_kzg_settings", +] } +kzg-rs = { version = "0.2.3", default-features = false, optional = true } +cfg-if = { version = "1", default-features = false, optional = true } +once_cell = { version = "1.19", default-features = false, optional = true, features = [ + "alloc", +] } + +[dev-dependencies] + +[features] +default = ["std", "portable"] +std = ["serde?/std"] +serde = ["dep:serde", "primitives/serde", "specification/serde", "state/serde"] +portable = ["c-kzg?/portable"] + +c-kzg = ["dep:c-kzg", "dep:cfg-if"] +# `kzg-rs` is not audited but useful for `no_std` environment. +# use it with causing and default to `c-kzg` if possible! +kzg-rs = ["dep:kzg-rs", "dep:cfg-if", "dep:once_cell"] + +# Enable additional features for development +dev = [ + "memory_limit", + "optional_balance_check", + "optional_block_gas_limit", + "optional_eip3607", + "optional_gas_refund", + "optional_no_base_fee", +] +memory_limit = [] +optional_balance_check = [] +optional_block_gas_limit = [] +optional_eip3607 = [] +optional_gas_refund = [] +optional_no_base_fee = [] diff --git a/crates/wiring/LICENSE b/crates/wiring/LICENSE new file mode 100644 index 0000000000..ad98ff22cc --- /dev/null +++ b/crates/wiring/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2024 draganrakita + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/primitives/src/block.rs b/crates/wiring/src/block.rs similarity index 85% rename from crates/primitives/src/block.rs rename to crates/wiring/src/block.rs index 38056c110b..b8d0d8f6f6 100644 --- a/crates/primitives/src/block.rs +++ b/crates/wiring/src/block.rs @@ -1,4 +1,8 @@ -use crate::{Address, BlobExcessGasAndPrice, B256, U256}; +pub mod blob; + +pub use blob::{calc_blob_gasprice, calc_excess_blob_gas, BlobExcessGasAndPrice}; + +use primitives::{Address, B256, U256}; /// Trait for retrieving block information required for execution. pub trait Block { @@ -36,17 +40,17 @@ pub trait Block { fn prevrandao(&self) -> Option<&B256>; /// Excess blob gas and blob gasprice. - /// See also [`crate::calc_excess_blob_gas`] - /// and [`crate::calc_blob_gasprice`]. + /// See also [`calc_excess_blob_gas`] + /// and [`calc_blob_gasprice`]. /// /// Incorporated as part of the Cancun upgrade via [EIP-4844]. /// /// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844 fn blob_excess_gas_and_price(&self) -> Option<&BlobExcessGasAndPrice>; - /// See [EIP-4844] and [`crate::calc_blob_gasprice`]. + /// See [EIP-4844] and [`calc_blob_gasprice`]. /// - /// Returns `None` if `Cancun` is not enabled. This is enforced in [`crate::Env::validate_block_env`]. + /// Returns `None` if `Cancun` is not enabled. This is enforced in [`crate::default::Env::validate_block_env`]. /// /// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844 fn get_blob_gasprice(&self) -> Option<&u128> { @@ -55,7 +59,7 @@ pub trait Block { /// Return `blob_excess_gas` header field. See [EIP-4844]. /// - /// Returns `None` if `Cancun` is not enabled. This is enforced in [`crate::Env::validate_block_env`]. + /// Returns `None` if `Cancun` is not enabled. This is enforced in [`crate::default::Env::validate_block_env`]. /// /// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844 fn get_blob_excess_gas(&self) -> Option { diff --git a/crates/primitives/src/utilities.rs b/crates/wiring/src/block/blob.rs similarity index 85% rename from crates/primitives/src/utilities.rs rename to crates/wiring/src/block/blob.rs index 07aa0457a3..646b95e9db 100644 --- a/crates/primitives/src/utilities.rs +++ b/crates/wiring/src/block/blob.rs @@ -1,11 +1,29 @@ -use crate::{ - b256, B256, BLOB_GASPRICE_UPDATE_FRACTION, MIN_BLOB_GASPRICE, TARGET_BLOB_GAS_PER_BLOCK, -}; -pub use alloy_primitives::keccak256; +use primitives::{BLOB_GASPRICE_UPDATE_FRACTION, MIN_BLOB_GASPRICE, TARGET_BLOB_GAS_PER_BLOCK}; -/// The Keccak-256 hash of the empty string `""`. -pub const KECCAK_EMPTY: B256 = - b256!("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"); +/// Structure holding block blob excess gas and it calculates blob fee. +/// +/// Incorporated as part of the Cancun upgrade via [EIP-4844]. +/// +/// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844 +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct BlobExcessGasAndPrice { + /// The excess blob gas of the block. + pub excess_blob_gas: u64, + /// The calculated blob gas price based on the `excess_blob_gas`, See [calc_blob_gasprice] + pub blob_gasprice: u128, +} + +impl BlobExcessGasAndPrice { + /// Creates a new instance by calculating the blob gas price with [`calc_blob_gasprice`]. + pub fn new(excess_blob_gas: u64) -> Self { + let blob_gasprice = calc_blob_gasprice(excess_blob_gas); + Self { + excess_blob_gas, + blob_gasprice, + } + } +} /// Calculates the `excess_blob_gas` from the parent header's `blob_gas_used` and `excess_blob_gas`. /// @@ -62,7 +80,7 @@ pub fn fake_exponential(factor: u64, numerator: u64, denominator: u64) -> u128 { #[cfg(test)] mod tests { use super::*; - use crate::GAS_PER_BLOB; + use primitives::GAS_PER_BLOB; // https://github.com/ethereum/go-ethereum/blob/28857080d732857030eda80c69b9ba2c8926f221/consensus/misc/eip4844/eip4844_test.go#L27 #[test] diff --git a/crates/primitives/src/env.rs b/crates/wiring/src/default.rs similarity index 84% rename from crates/primitives/src/env.rs rename to crates/wiring/src/default.rs index 7e48b175de..028b801bc9 100644 --- a/crates/primitives/src/env.rs +++ b/crates/wiring/src/default.rs @@ -1,13 +1,23 @@ -use crate::{ - calc_blob_gasprice, AccessListItem, Account, Address, AuthorizationList, Block, Bytes, - EvmWiring, InvalidHeader, InvalidTransaction, Spec, SpecId, Transaction, TransactionValidation, - B256, MAX_BLOB_NUMBER_PER_BLOCK, MAX_CODE_SIZE, MAX_INITCODE_SIZE, U256, - VERSIONED_HASH_VERSION_KZG, -}; -use alloy_primitives::TxKind; +pub mod block; +pub mod transaction; + +use crate::block::blob::calc_blob_gasprice; +use crate::result::InvalidHeader; +use crate::transaction::TransactionValidation; +use crate::{result::InvalidTransaction, Block, EvmWiring, Transaction}; use core::cmp::{min, Ordering}; use core::fmt::Debug; use core::hash::Hash; +use primitives::{ + Address, Bytes, TxKind, B256, MAX_BLOB_NUMBER_PER_BLOCK, MAX_CODE_SIZE, MAX_INITCODE_SIZE, + U256, VERSIONED_HASH_VERSION_KZG, +}; +use specification::{ + eip2930::AccessListItem, + eip7702::AuthorizationList, + hardfork::{Spec, SpecId}, +}; +use state::Account; use std::boxed::Box; use std::vec::Vec; @@ -308,8 +318,8 @@ pub struct CfgEnv { /// By default it is 0x6000 (~25kb). pub limit_contract_code_size: Option, /// Skips the nonce validation against the account's nonce: - /// [`crate::InvalidTransaction::NonceTooHigh`] and - /// [`crate::InvalidTransaction::NonceTooLow`] + /// [`crate::default::InvalidTransaction::NonceTooHigh`] and + /// [`crate::default::InvalidTransaction::NonceTooLow`] pub disable_nonce_check: bool, /// A hard memory limit in bytes beyond which [crate::result::OutOfGasError::Memory] cannot be resized. /// @@ -341,10 +351,6 @@ pub struct CfgEnv { /// By default, it is set to `false`. #[cfg(feature = "optional_no_base_fee")] pub disable_base_fee: bool, - /// Disables the payout of the reward to the beneficiary. - /// By default, it is set to `false`. - #[cfg(feature = "optional_beneficiary_reward")] - pub disable_beneficiary_reward: bool, } impl CfgEnv { @@ -409,16 +415,6 @@ impl CfgEnv { false } - #[cfg(feature = "optional_beneficiary_reward")] - pub fn is_beneficiary_reward_disabled(&self) -> bool { - self.disable_beneficiary_reward - } - - #[cfg(not(feature = "optional_beneficiary_reward"))] - pub fn is_beneficiary_reward_disabled(&self) -> bool { - false - } - pub const fn is_nonce_check_disabled(&self) -> bool { self.disable_nonce_check } @@ -445,114 +441,6 @@ impl Default for CfgEnv { disable_gas_refund: false, #[cfg(feature = "optional_no_base_fee")] disable_base_fee: false, - #[cfg(feature = "optional_beneficiary_reward")] - disable_beneficiary_reward: false, - } - } -} - -/// The block environment. -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BlockEnv { - /// The number of ancestor blocks of this block (block height). - pub number: U256, - /// Coinbase or miner or address that created and signed the block. - /// - /// This is the receiver address of all the gas spent in the block. - pub coinbase: Address, - - /// The timestamp of the block in seconds since the UNIX epoch. - pub timestamp: U256, - /// The gas limit of the block. - pub gas_limit: U256, - /// The base fee per gas, added in the London upgrade with [EIP-1559]. - /// - /// [EIP-1559]: https://eips.ethereum.org/EIPS/eip-1559 - pub basefee: U256, - /// The difficulty of the block. - /// - /// Unused after the Paris (AKA the merge) upgrade, and replaced by `prevrandao`. - pub difficulty: U256, - /// The output of the randomness beacon provided by the beacon chain. - /// - /// Replaces `difficulty` after the Paris (AKA the merge) upgrade with [EIP-4399]. - /// - /// NOTE: `prevrandao` can be found in a block in place of `mix_hash`. - /// - /// [EIP-4399]: https://eips.ethereum.org/EIPS/eip-4399 - pub prevrandao: Option, - /// Excess blob gas and blob gasprice. - /// See also [`crate::calc_excess_blob_gas`] - /// and [`calc_blob_gasprice`]. - /// - /// Incorporated as part of the Cancun upgrade via [EIP-4844]. - /// - /// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844 - pub blob_excess_gas_and_price: Option, -} - -impl BlockEnv { - /// Takes `blob_excess_gas` saves it inside env - /// and calculates `blob_fee` with [`BlobExcessGasAndPrice`]. - pub fn set_blob_excess_gas_and_price(&mut self, excess_blob_gas: u64) { - self.blob_excess_gas_and_price = Some(BlobExcessGasAndPrice::new(excess_blob_gas)); - } -} - -impl Block for BlockEnv { - #[inline] - fn number(&self) -> &U256 { - &self.number - } - - #[inline] - fn coinbase(&self) -> &Address { - &self.coinbase - } - - #[inline] - fn timestamp(&self) -> &U256 { - &self.timestamp - } - - #[inline] - fn gas_limit(&self) -> &U256 { - &self.gas_limit - } - - #[inline] - fn basefee(&self) -> &U256 { - &self.basefee - } - - #[inline] - fn difficulty(&self) -> &U256 { - &self.difficulty - } - - #[inline] - fn prevrandao(&self) -> Option<&B256> { - self.prevrandao.as_ref() - } - - #[inline] - fn blob_excess_gas_and_price(&self) -> Option<&BlobExcessGasAndPrice> { - self.blob_excess_gas_and_price.as_ref() - } -} - -impl Default for BlockEnv { - fn default() -> Self { - Self { - number: U256::ZERO, - coinbase: Address::ZERO, - timestamp: U256::from(1), - gas_limit: U256::MAX, - basefee: U256::ZERO, - difficulty: U256::ZERO, - prevrandao: Some(B256::ZERO), - blob_excess_gas_and_price: Some(BlobExcessGasAndPrice::new(0)), } } } @@ -775,6 +663,8 @@ pub enum AnalysisKind { #[cfg(test)] mod tests { use super::*; + use crate::default::block::BlockEnv; + use specification::hardfork::{FrontierSpec, LatestSpec}; #[test] fn test_validate_tx_chain_id() { @@ -782,7 +672,7 @@ mod tests { env.tx.chain_id = Some(1); env.cfg.chain_id = 2; assert_eq!( - env.validate_tx::(), + env.validate_tx::(), Err(InvalidTransaction::InvalidChainId) ); } @@ -795,7 +685,7 @@ mod tests { storage_keys: vec![], }]; assert_eq!( - env.validate_tx::(), + env.validate_tx::(), Err(InvalidTransaction::AccessListNotSupported) ); } diff --git a/crates/wiring/src/default/block.rs b/crates/wiring/src/default/block.rs new file mode 100644 index 0000000000..6c8765dd6c --- /dev/null +++ b/crates/wiring/src/default/block.rs @@ -0,0 +1,108 @@ +use crate::block::{BlobExcessGasAndPrice, Block}; +use primitives::{Address, B256, U256}; + +/// The block environment. +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct BlockEnv { + /// The number of ancestor blocks of this block (block height). + pub number: U256, + /// Coinbase or miner or address that created and signed the block. + /// + /// This is the receiver address of all the gas spent in the block. + pub coinbase: Address, + + /// The timestamp of the block in seconds since the UNIX epoch. + pub timestamp: U256, + /// The gas limit of the block. + pub gas_limit: U256, + /// The base fee per gas, added in the London upgrade with [EIP-1559]. + /// + /// [EIP-1559]: https://eips.ethereum.org/EIPS/eip-1559 + pub basefee: U256, + /// The difficulty of the block. + /// + /// Unused after the Paris (AKA the merge) upgrade, and replaced by `prevrandao`. + pub difficulty: U256, + /// The output of the randomness beacon provided by the beacon chain. + /// + /// Replaces `difficulty` after the Paris (AKA the merge) upgrade with [EIP-4399]. + /// + /// NOTE: `prevrandao` can be found in a block in place of `mix_hash`. + /// + /// [EIP-4399]: https://eips.ethereum.org/EIPS/eip-4399 + pub prevrandao: Option, + /// Excess blob gas and blob gasprice. + /// See also [`crate::block::calc_excess_blob_gas`] + /// and [`crate::block::blob::calc_blob_gasprice`]. + /// + /// Incorporated as part of the Cancun upgrade via [EIP-4844]. + /// + /// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844 + pub blob_excess_gas_and_price: Option, +} + +impl BlockEnv { + /// Takes `blob_excess_gas` saves it inside env + /// and calculates `blob_fee` with [`BlobExcessGasAndPrice`]. + pub fn set_blob_excess_gas_and_price(&mut self, excess_blob_gas: u64) { + self.blob_excess_gas_and_price = Some(BlobExcessGasAndPrice::new(excess_blob_gas)); + } +} + +impl Block for BlockEnv { + #[inline] + fn number(&self) -> &U256 { + &self.number + } + + #[inline] + fn coinbase(&self) -> &Address { + &self.coinbase + } + + #[inline] + fn timestamp(&self) -> &U256 { + &self.timestamp + } + + #[inline] + fn gas_limit(&self) -> &U256 { + &self.gas_limit + } + + #[inline] + fn basefee(&self) -> &U256 { + &self.basefee + } + + #[inline] + fn difficulty(&self) -> &U256 { + &self.difficulty + } + + #[inline] + fn prevrandao(&self) -> Option<&B256> { + self.prevrandao.as_ref() + } + + #[inline] + fn blob_excess_gas_and_price(&self) -> Option<&BlobExcessGasAndPrice> { + self.blob_excess_gas_and_price.as_ref() + } +} + +impl Default for BlockEnv { + fn default() -> Self { + Self { + number: U256::ZERO, + coinbase: Address::ZERO, + timestamp: U256::from(1), + gas_limit: U256::MAX, + basefee: U256::ZERO, + difficulty: U256::ZERO, + prevrandao: Some(B256::ZERO), + blob_excess_gas_and_price: Some(BlobExcessGasAndPrice::new(0)), + } + } +} diff --git a/crates/wiring/src/default/transaction.rs b/crates/wiring/src/default/transaction.rs new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/crates/wiring/src/default/transaction.rs @@ -0,0 +1 @@ + diff --git a/crates/primitives/src/evm_wiring.rs b/crates/wiring/src/evm_wiring.rs similarity index 73% rename from crates/primitives/src/evm_wiring.rs rename to crates/wiring/src/evm_wiring.rs index 12ae764301..78b78259dc 100644 --- a/crates/primitives/src/evm_wiring.rs +++ b/crates/wiring/src/evm_wiring.rs @@ -1,5 +1,11 @@ -use crate::{db::Database, Block, SpecId, Transaction}; +use crate::{ + result::HaltReason, + transaction::{Transaction, TransactionValidation}, + Block, +}; use core::{fmt::Debug, hash::Hash}; +use database_interface::{Database, EmptyDB}; +use specification::hardfork::SpecId; /// The type that enumerates the chain's hardforks. pub trait HardforkTrait: Clone + Copy + Default + PartialEq + Eq + Into {} @@ -9,18 +15,13 @@ impl HardforkTrait for HardforkT where { } -pub trait HaltReasonTrait: Clone + Debug + PartialEq + Eq + From {} +pub trait HaltReasonTrait: Clone + Debug + PartialEq + Eq + From {} impl HaltReasonTrait for HaltReasonT where - HaltReasonT: Clone + Debug + PartialEq + Eq + From + HaltReasonT: Clone + Debug + PartialEq + Eq + From { } -pub trait TransactionValidation { - /// An error that occurs when validating a transaction. - type ValidationError: Debug + core::error::Error; -} - pub trait EvmWiring: Sized { /// External context type type ExternalContext: Sized; @@ -53,10 +54,10 @@ impl EvmWiring for EthereumWiring { type Database = DB; type ExternalContext = EXT; type ChainContext = (); - type Block = crate::BlockEnv; - type Transaction = crate::TxEnv; + type Block = crate::default::block::BlockEnv; + type Transaction = crate::default::TxEnv; type Hardfork = SpecId; - type HaltReason = crate::HaltReason; + type HaltReason = crate::result::HaltReason; } -pub type DefaultEthereumWiring = EthereumWiring; +pub type DefaultEthereumWiring = EthereumWiring; diff --git a/crates/wiring/src/kzg.rs b/crates/wiring/src/kzg.rs new file mode 100644 index 0000000000..c058760033 --- /dev/null +++ b/crates/wiring/src/kzg.rs @@ -0,0 +1,47 @@ +cfg_if::cfg_if! { + if #[cfg(feature = "c-kzg")] { + pub use c_kzg::KzgSettings; + } else if #[cfg(feature = "kzg-rs")] { + pub use kzg_rs::KzgSettings; + } +} + +/// KZG Settings that allow us to specify a custom trusted setup. +/// or use hardcoded default settings. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub enum EnvKzgSettings { + /// Default mainnet trusted setup + #[default] + Default, + /// Custom trusted setup. + Custom(std::sync::Arc), +} + +impl EnvKzgSettings { + /// Return set KZG settings. + /// + /// In will initialize the default settings if it is not already loaded. + pub fn get(&self) -> &KzgSettings { + match self { + Self::Default => { + cfg_if::cfg_if! { + if #[cfg(feature = "c-kzg")] { + c_kzg::ethereum_kzg_settings() + } else if #[cfg(feature = "kzg-rs")] { + use once_cell::race::OnceBox; + use std::boxed::Box; + + static DEFAULT : OnceBox = OnceBox::new(); + &DEFAULT.get_or_init(|| { + Box::new(KzgSettings::load_trusted_setup_file() + .expect("failed to load default trusted setup")) + }) + } else { + unimplemented!() + } + } + } + Self::Custom(settings) => settings, + } + } +} diff --git a/crates/wiring/src/lib.rs b/crates/wiring/src/lib.rs new file mode 100644 index 0000000000..1808d524c6 --- /dev/null +++ b/crates/wiring/src/lib.rs @@ -0,0 +1,32 @@ +//! Optimism-specific constants, types, and helpers. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(not(feature = "std"))] +extern crate alloc as std; + +pub mod block; +pub mod default; +pub mod evm_wiring; +pub mod precompile; +pub mod result; +pub mod transaction; + +pub use block::Block; +pub use evm_wiring::{DefaultEthereumWiring, EthereumWiring, EvmWiring, HaltReasonTrait}; +pub use transaction::{Transaction, TransactionValidation}; + +// KZG + +#[cfg(any(feature = "c-kzg", feature = "kzg-rs"))] +pub mod kzg; + +#[cfg(any(feature = "c-kzg", feature = "kzg-rs"))] +pub use kzg::{EnvKzgSettings, KzgSettings}; + +// silence kzg-rs lint as c-kzg will be used as default if both are enabled. + +#[cfg(all(feature = "c-kzg", feature = "kzg-rs"))] +use kzg_rs as _; +#[cfg(all(feature = "c-kzg", feature = "kzg-rs"))] +use once_cell as _; diff --git a/crates/primitives/src/precompile.rs b/crates/wiring/src/precompile.rs similarity index 99% rename from crates/primitives/src/precompile.rs rename to crates/wiring/src/precompile.rs index 25938bb580..48f219344a 100644 --- a/crates/primitives/src/precompile.rs +++ b/crates/wiring/src/precompile.rs @@ -1,6 +1,7 @@ -use crate::{Bytes, CfgEnv}; +use crate::default::CfgEnv; use core::fmt; use dyn_clone::DynClone; +use primitives::Bytes; use std::{boxed::Box, string::String, sync::Arc}; /// A precompile operation result. diff --git a/crates/primitives/src/result.rs b/crates/wiring/src/result.rs similarity index 97% rename from crates/primitives/src/result.rs rename to crates/wiring/src/result.rs index 7dee33d49d..7e8dc3e7ea 100644 --- a/crates/primitives/src/result.rs +++ b/crates/wiring/src/result.rs @@ -1,8 +1,9 @@ -use crate::{ - db::Database, eip7702::authorization_list::InvalidAuthorization, Address, Bytes, EvmState, - EvmWiring, HaltReasonTrait, Log, TransactionValidation, U256, -}; +use crate::{evm_wiring::HaltReasonTrait, transaction::TransactionValidation, EvmWiring}; use core::fmt::{self, Debug}; +use database_interface::Database; +use primitives::{Address, Bytes, Log, U256}; +use specification::eip7702::InvalidAuthorization; +use state::EvmState; use std::{boxed::Box, string::String, vec::Vec}; /// Result of EVM execution. @@ -286,7 +287,7 @@ pub enum InvalidTransaction { /// Blob transaction can't be a create transaction. /// `to` must be present BlobCreateTransaction, - /// Transaction has more then [`crate::MAX_BLOB_NUMBER_PER_BLOCK`] blobs + /// Transaction has more then [`primitives::MAX_BLOB_NUMBER_PER_BLOCK`] blobs TooManyBlobs { max: usize, have: usize, @@ -377,7 +378,7 @@ impl fmt::Display for InvalidTransaction { } } -/// Errors related to misconfiguration of a [`crate::env::BlockEnv`]. +/// Errors related to misconfiguration of a [`crate::default::block::BlockEnv`]. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum InvalidHeader { diff --git a/crates/primitives/src/transaction.rs b/crates/wiring/src/transaction.rs similarity index 77% rename from crates/primitives/src/transaction.rs rename to crates/wiring/src/transaction.rs index f2a1577f70..4a99d59166 100644 --- a/crates/primitives/src/transaction.rs +++ b/crates/wiring/src/transaction.rs @@ -1,4 +1,7 @@ -use crate::{AccessListItem, Address, AuthorizationList, Bytes, TxKind, B256, GAS_PER_BLOB, U256}; +use core::fmt::Debug; +use primitives::{Address, Bytes, TxKind, B256, GAS_PER_BLOB, U256}; +use specification::{eip2930, eip7702}; +//{AccessListItem, Address, AuthorizationList, Bytes, TxKind, B256, GAS_PER_BLOB, U256}; /// Trait for retrieving transaction information required for execution. pub trait Transaction { @@ -27,7 +30,7 @@ pub trait Transaction { /// Added in [EIP-2930]. /// /// [EIP-2930]: https://eips.ethereum.org/EIPS/eip-2930 - fn access_list(&self) -> &[AccessListItem]; + fn access_list(&self) -> &[eip2930::AccessListItem]; /// The maximum priority fee per gas the sender is willing to pay. /// /// Incorporated as part of the London upgrade via [EIP-1559]. @@ -35,7 +38,7 @@ pub trait Transaction { /// [EIP-1559]: https://eips.ethereum.org/EIPS/eip-1559 fn max_priority_fee_per_gas(&self) -> Option<&U256>; /// The list of blob versioned hashes. Per EIP there should be at least - /// one blob present if [`Self::max_fee_per_blob_gas`] is `Some`. + /// one blob present if [`Transaction::max_fee_per_blob_gas`] is `Some`. /// /// Incorporated as part of the Cancun upgrade via [EIP-4844]. /// @@ -53,12 +56,17 @@ pub trait Transaction { /// Set EOA account code for one transaction /// /// [EIP-Set EOA account code for one transaction](https://eips.ethereum.org/EIPS/eip-7702) - fn authorization_list(&self) -> Option<&AuthorizationList>; + fn authorization_list(&self) -> Option<&eip7702::AuthorizationList>; - /// See [EIP-4844], [`crate::Env::calc_data_fee`], and [`crate::Env::calc_max_data_fee`]. + /// See [EIP-4844], [`crate::default::Env::calc_data_fee`], and [`crate::default::Env::calc_max_data_fee`]. /// /// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844 fn get_total_blob_gas(&self) -> u64 { GAS_PER_BLOB * self.blob_hashes().len() as u64 } } + +pub trait TransactionValidation { + /// An error that occurs when validating a transaction. + type ValidationError: Debug + core::error::Error; +} diff --git a/examples/db_by_ref.rs b/examples/db_by_ref.rs index 4801db5a1b..8be90b8dfe 100644 --- a/examples/db_by_ref.rs +++ b/examples/db_by_ref.rs @@ -1,11 +1,15 @@ use core::error::Error; use core::fmt::Debug; use revm::{ - db::{CacheDB, EmptyDB, WrapDatabaseRef}, + database_interface::{EmptyDB, WrapDatabaseRef}, + db::CacheDB, handler::register::HandleRegister, inspector_handle_register, inspectors::{NoOpInspector, TracerEip3155}, - primitives::{EthereumWiring, HaltReason, ResultAndState}, + wiring::{ + result::{HaltReason, ResultAndState}, + EthereumWiring, + }, DatabaseCommit, DatabaseRef, Evm, }; diff --git a/examples/deploy.rs b/examples/deploy.rs index 939cbbaab1..9431f32cf2 100644 --- a/examples/deploy.rs +++ b/examples/deploy.rs @@ -1,7 +1,11 @@ use anyhow::{anyhow, bail}; use revm::{ interpreter::opcode, - primitives::{bytes::Bytes, hex, EthereumWiring, ExecutionResult, Output, TxKind, U256}, + primitives::{hex, Bytes, TxKind, U256}, + wiring::{ + result::{ExecutionResult, Output}, + EthereumWiring, + }, Evm, InMemoryDB, }; @@ -46,7 +50,7 @@ fn main() -> anyhow::Result<()> { .with_default_ext_ctx() .modify_tx_env(|tx| { tx.transact_to = TxKind::Create; - *tx.data = bytecode.clone(); + tx.data = bytecode.clone(); }) .build(); @@ -65,7 +69,7 @@ fn main() -> anyhow::Result<()> { .modify() .modify_tx_env(|tx| { tx.transact_to = TxKind::Call(address); - *tx.data = Default::default(); + tx.data = Default::default(); tx.nonce += 1; }) .build(); diff --git a/examples/fork_ref_transact.rs b/examples/fork_ref_transact.rs index 99614267d8..a1467f29b1 100644 --- a/examples/fork_ref_transact.rs +++ b/examples/fork_ref_transact.rs @@ -1,21 +1,27 @@ +use alloy_eips::BlockId; +use alloy_provider::ProviderBuilder; use alloy_sol_types::sol; use alloy_sol_types::SolCall; -use ethers_providers::{Http, Provider}; -use revm::primitives::EthereumWiring; use revm::{ - db::{CacheDB, EmptyDB, EthersDB}, - primitives::{address, ExecutionResult, Output, TxKind, U256}, - Database, Evm, + database_interface::Database, + database_interface::EmptyDB, + db::{AlloyDB, CacheDB}, + primitives::{address, TxKind, U256}, + wiring::{ + result::{ExecutionResult, Output}, + EthereumWiring, + }, + Evm, }; -use std::sync::Arc; #[tokio::main] async fn main() -> anyhow::Result<()> { + // Set up the HTTP transport which is consumed by the RPC client. + let rpc_url = "https://mainnet.infura.io/v3/c60b0bb42f8a4c6481ecd229eddaca27".parse()?; + // create ethers client and wrap it in Arc - let client = Provider::::try_from( - "https://mainnet.infura.io/v3/c60b0bb42f8a4c6481ecd229eddaca27", - )?; - let client = Arc::new(client); + let client = ProviderBuilder::new().on_http(rpc_url); + let mut client = AlloyDB::new(client, BlockId::latest()).unwrap(); // ----------------------------------------------------------- // // Storage slots of UniV2Pair contract // @@ -43,14 +49,11 @@ async fn main() -> anyhow::Result<()> { // encode abi into Bytes let encoded = getReservesCall::new(()).abi_encode(); - // initialize new EthersDB - let mut ethersdb = EthersDB::new(client, None).unwrap(); - // query basic properties of an account incl bytecode - let acc_info = ethersdb.basic(pool_address).unwrap().unwrap(); + let acc_info = client.basic(pool_address).unwrap().unwrap(); // query value of storage slot at account address - let value = ethersdb.storage(pool_address, slot).unwrap(); + let value = client.storage(pool_address, slot).unwrap(); // initialise empty in-memory-db let mut cache_db = CacheDB::new(EmptyDB::default()); @@ -66,6 +69,7 @@ async fn main() -> anyhow::Result<()> { // initialise an empty (default) EVM let mut evm = Evm::, ()>>::builder() .with_db(cache_db) + .with_default_ext_ctx() .modify_tx_env(|tx| { // fill in missing bits of env struct // change that to whatever caller you want to be diff --git a/examples/generate_block_traces.rs b/examples/generate_block_traces.rs index 59cce05edf..371c4bdd34 100644 --- a/examples/generate_block_traces.rs +++ b/examples/generate_block_traces.rs @@ -1,13 +1,15 @@ -// Example Adapted From: https://github.com/bluealloy/revm/issues/672 - -use ethers_core::types::BlockId; -use ethers_providers::Middleware; -use ethers_providers::{Http, Provider}; +use alloy_eips::{BlockId, BlockNumberOrTag}; +use alloy_provider::{network::primitives::BlockTransactions, Provider, ProviderBuilder}; use indicatif::ProgressBar; -use revm::db::{CacheDB, EthersDB, StateBuilder}; -use revm::inspectors::TracerEip3155; -use revm::primitives::{AccessListItem, Address, EthereumWiring, TxKind, B256, U256}; -use revm::{inspector_handle_register, Evm}; +use revm::{ + db::{AlloyDB, CacheDB, StateBuilder}, + inspector_handle_register, + inspectors::TracerEip3155, + primitives::{TxKind, B256, U256}, + specification::eip2930::AccessListItem, + wiring::EthereumWiring, + Evm, +}; use std::fs::OpenOptions; use std::io::BufWriter; use std::io::Write; @@ -15,19 +17,6 @@ use std::sync::Arc; use std::sync::Mutex; use std::time::Instant; -macro_rules! local_fill { - ($left:expr, $right:expr, $fun:expr) => { - if let Some(right) = $right { - $left = $fun(right.0) - } - }; - ($left:expr, $right:expr) => { - if let Some(right) = $right { - $left = Address::from(right.as_fixed_bytes()) - } - }; -} - struct FlushWriter { writer: Arc>>, } @@ -50,46 +39,50 @@ impl Write for FlushWriter { #[tokio::main] async fn main() -> anyhow::Result<()> { - // Create ethers client and wrap it in Arc - let client = Provider::::try_from( - "https://mainnet.infura.io/v3/c60b0bb42f8a4c6481ecd229eddaca27", - )?; - let client = Arc::new(client); + // Set up the HTTP transport which is consumed by the RPC client. + let rpc_url = "https://mainnet.infura.io/v3/c60b0bb42f8a4c6481ecd229eddaca27".parse()?; + + // create ethers client and wrap it in Arc + let client = ProviderBuilder::new().on_http(rpc_url); // Params let chain_id: u64 = 1; let block_number = 10889447; // Fetch the transaction-rich block - let block = match client.get_block_with_txs(block_number).await { + let block = match client + .get_block_by_number(BlockNumberOrTag::Number(block_number), true) + .await + { Ok(Some(block)) => block, Ok(None) => anyhow::bail!("Block not found"), Err(error) => anyhow::bail!("Error: {:?}", error), }; - println!("Fetched block number: {}", block.number.unwrap().0[0]); + println!("Fetched block number: {}", block.header.number); let previous_block_number = block_number - 1; // Use the previous block state as the db with caching let prev_id: BlockId = previous_block_number.into(); // SAFETY: This cannot fail since this is in the top-level tokio runtime - let state_db = EthersDB::new(client, Some(prev_id)).expect("panic"); - let cache_db: CacheDB>> = CacheDB::new(state_db); + + let state_db = AlloyDB::new(client, prev_id).unwrap(); + let cache_db: CacheDB<_> = CacheDB::new(state_db); let mut state = StateBuilder::new_with_database(cache_db).build(); let mut evm = Evm::>::builder() .with_db(&mut state) .with_external_context(TracerEip3155::new(Box::new(std::io::stdout()))) .modify_block_env(|b| { - if let Some(number) = block.number { - let nn = number.0[0]; - b.number = U256::from(nn); - } - local_fill!(b.coinbase, block.author); - local_fill!(b.timestamp, Some(block.timestamp), U256::from_limbs); - local_fill!(b.difficulty, Some(block.difficulty), U256::from_limbs); - local_fill!(b.gas_limit, Some(block.gas_limit), U256::from_limbs); - if let Some(base_fee) = block.base_fee_per_gas { - local_fill!(b.basefee, Some(base_fee), U256::from_limbs); - } + b.number = U256::from(block.header.number); + b.coinbase = block.header.miner; + b.timestamp = U256::from(block.header.timestamp); + + b.difficulty = block.header.difficulty; + b.gas_limit = U256::from(block.header.gas_limit); + b.basefee = block + .header + .base_fee_per_gas + .map(U256::from) + .unwrap_or_default(); }) .modify_cfg_env(|c| { c.chain_id = chain_id; @@ -107,24 +100,25 @@ async fn main() -> anyhow::Result<()> { std::fs::create_dir_all("traces").expect("Failed to create traces directory"); // Fill in CfgEnv - for tx in block.transactions { + let BlockTransactions::Full(transactions) = block.transactions else { + panic!("Wrong transaction type") + }; + + for tx in transactions { evm = evm .modify() .modify_tx_env(|etx| { - etx.caller = Address::from(tx.from.as_fixed_bytes()); - etx.gas_limit = tx.gas.as_u64(); - local_fill!(etx.gas_price, tx.gas_price, U256::from_limbs); - local_fill!(etx.value, Some(tx.value), U256::from_limbs); - etx.data = tx.input.0.into(); - let mut gas_priority_fee = U256::ZERO; - local_fill!( - gas_priority_fee, - tx.max_priority_fee_per_gas, - U256::from_limbs + etx.caller = tx.from; + etx.gas_limit = tx.gas as u64; + etx.gas_price = U256::from( + tx.gas_price + .unwrap_or(tx.max_fee_per_gas.unwrap_or_default()), ); - etx.gas_priority_fee = Some(gas_priority_fee); + etx.value = tx.value; + etx.data = tx.input.0.into(); + etx.gas_priority_fee = tx.max_priority_fee_per_gas.map(U256::from); etx.chain_id = Some(chain_id); - etx.nonce = tx.nonce.as_u64(); + etx.nonce = tx.nonce; if let Some(access_list) = tx.access_list { etx.access_list = access_list .0 @@ -137,7 +131,7 @@ async fn main() -> anyhow::Result<()> { .collect(); AccessListItem { - address: Address::new(item.address.0), + address: item.address, storage_keys, } }) @@ -147,14 +141,14 @@ async fn main() -> anyhow::Result<()> { } etx.transact_to = match tx.to { - Some(to_address) => TxKind::Call(Address::from(to_address.as_fixed_bytes())), + Some(to_address) => TxKind::Call(to_address), None => TxKind::Create, }; }) .build(); // Construct the file writer to write the trace to - let tx_number = tx.transaction_index.unwrap().0[0]; + let tx_number = tx.transaction_index.unwrap_or_default(); let file_name = format!("traces/{}.json", tx_number); let write = OpenOptions::new() .write(true) diff --git a/examples/split_db_trait.rs b/examples/split_db_trait.rs new file mode 100644 index 0000000000..1382982ce6 --- /dev/null +++ b/examples/split_db_trait.rs @@ -0,0 +1,207 @@ + + +//! Database that is split on State and BlockHash traits. +pub mod block_hash; +pub mod state; + +pub use block_hash::{BlockHash, BlockHashRef}; +pub use state::{State, StateRef}; + +use crate::{ + db::{Database, DatabaseRef}, + Account, AccountInfo, Address, Bytecode, HashMap, B256, U256, +}; + +use super::DatabaseCommit; + +#[derive(Debug)] +pub struct DatabaseComponents { + pub state: S, + pub block_hash: BH, +} + +#[derive(Debug)] +pub enum DatabaseComponentError { + State(SE), + BlockHash(BHE), +} + +impl Database for DatabaseComponents { + type Error = DatabaseComponentError; + + fn basic(&mut self, address: Address) -> Result, Self::Error> { + self.state.basic(address).map_err(Self::Error::State) + } + + fn code_by_hash(&mut self, code_hash: B256) -> Result { + self.state + .code_by_hash(code_hash) + .map_err(Self::Error::State) + } + + fn storage(&mut self, address: Address, index: U256) -> Result { + self.state + .storage(address, index) + .map_err(Self::Error::State) + } + + fn block_hash(&mut self, number: u64) -> Result { + self.block_hash + .block_hash(number) + .map_err(Self::Error::BlockHash) + } +} + +impl DatabaseRef for DatabaseComponents { + type Error = DatabaseComponentError; + + fn basic_ref(&self, address: Address) -> Result, Self::Error> { + self.state.basic(address).map_err(Self::Error::State) + } + + fn code_by_hash_ref(&self, code_hash: B256) -> Result { + self.state + .code_by_hash(code_hash) + .map_err(Self::Error::State) + } + + fn storage_ref(&self, address: Address, index: U256) -> Result { + self.state + .storage(address, index) + .map_err(Self::Error::State) + } + + fn block_hash_ref(&self, number: u64) -> Result { + self.block_hash + .block_hash(number) + .map_err(Self::Error::BlockHash) + } +} + +impl DatabaseCommit for DatabaseComponents { + fn commit(&mut self, changes: HashMap) { + self.state.commit(changes); + } +} + + +//! BlockHash database component from [`crate::db::Database`] +//! it is used inside [`crate::db::DatabaseComponents`] + +use crate::B256; +use auto_impl::auto_impl; +use core::ops::Deref; +use std::sync::Arc; + +#[auto_impl(&mut, Box)] +pub trait BlockHash { + type Error; + + /// Get block hash by block number + fn block_hash(&mut self, number: u64) -> Result; +} + +#[auto_impl(&, &mut, Box, Rc, Arc)] +pub trait BlockHashRef { + type Error; + + /// Get block hash by block number + fn block_hash(&self, number: u64) -> Result; +} + +impl BlockHash for &T +where + T: BlockHashRef, +{ + type Error = ::Error; + + fn block_hash(&mut self, number: u64) -> Result { + BlockHashRef::block_hash(*self, number) + } +} + +impl BlockHash for Arc +where + T: BlockHashRef, +{ + type Error = ::Error; + + fn block_hash(&mut self, number: u64) -> Result { + self.deref().block_hash(number) + } +} + + +//! State database component from [`crate::db::Database`] +//! it is used inside [`crate::db::DatabaseComponents`] + +use crate::{AccountInfo, Address, Bytecode, B256, U256}; +use auto_impl::auto_impl; +use core::ops::Deref; +use std::sync::Arc; + +#[auto_impl(&mut, Box)] +pub trait State { + type Error; + + /// Get basic account information. + fn basic(&mut self, address: Address) -> Result, Self::Error>; + + /// Get account code by its hash + fn code_by_hash(&mut self, code_hash: B256) -> Result; + + /// Get storage value of address at index. + fn storage(&mut self, address: Address, index: U256) -> Result; +} + +#[auto_impl(&, &mut, Box, Rc, Arc)] +pub trait StateRef { + type Error; + + /// Get basic account information. + fn basic(&self, address: Address) -> Result, Self::Error>; + + /// Get account code by its hash + fn code_by_hash(&self, code_hash: B256) -> Result; + + /// Get storage value of address at index. + fn storage(&self, address: Address, index: U256) -> Result; +} + +impl State for &T +where + T: StateRef, +{ + type Error = ::Error; + + fn basic(&mut self, address: Address) -> Result, Self::Error> { + StateRef::basic(*self, address) + } + + fn code_by_hash(&mut self, code_hash: B256) -> Result { + StateRef::code_by_hash(*self, code_hash) + } + + fn storage(&mut self, address: Address, index: U256) -> Result { + StateRef::storage(*self, address, index) + } +} + +impl State for Arc +where + T: StateRef, +{ + type Error = ::Error; + + fn basic(&mut self, address: Address) -> Result, Self::Error> { + self.deref().basic(address) + } + + fn code_by_hash(&mut self, code_hash: B256) -> Result { + self.deref().code_by_hash(code_hash) + } + + fn storage(&mut self, address: Address, index: U256) -> Result { + self.deref().storage(address, index) + } +}