From f8f1b30658d1520c29475e9a903b729a4512c1b5 Mon Sep 17 00:00:00 2001 From: rakita Date: Tue, 17 Sep 2024 19:35:19 +0200 Subject: [PATCH] revert until wiring --- Cargo.lock | 256 +++++++++++------- bins/revme/Cargo.toml | 2 +- bins/revme/src/cmd.rs | 16 +- bins/revme/src/cmd/bytecode.rs | 12 +- bins/revme/src/cmd/eofvalidation.rs | 14 +- bins/revme/src/cmd/evmrunner.rs | 34 +-- bins/revme/src/cmd/statetest.rs | 25 +- bins/revme/src/cmd/statetest/runner.rs | 2 - bins/revme/src/main.rs | 11 +- crates/interpreter/src/instruction_result.rs | 16 +- crates/optimism/Cargo.toml | 2 +- crates/precompile/Cargo.toml | 2 +- crates/revm/Cargo.toml | 2 +- .../src/handler/mainnet/post_execution.rs | 2 +- 14 files changed, 224 insertions(+), 172 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 22f292c117..0d750b7378 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -126,9 +126,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 +184,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 +210,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", @@ -332,9 +332,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,13 +346,13 @@ 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", - "heck", + "heck 0.5.0", "indexmap", "proc-macro-error2", "proc-macro2", @@ -364,13 +364,13 @@ 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", - "heck", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.70", @@ -379,9 +379,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 +389,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", @@ -441,18 +441,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] -name = "anstream" -version = "0.6.15" +name = "ansi_term" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", + "winapi", ] [[package]] @@ -461,39 +455,11 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" -[[package]] -name = "anstyle-parse" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" -dependencies = [ - "windows-sys 0.52.0", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" -dependencies = [ - "anstyle", - "windows-sys 0.52.0", -] - [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" [[package]] name = "arbitrary" @@ -684,6 +650,17 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + [[package]] name = "aurora-engine-modexp" version = "1.1.0" @@ -926,6 +903,21 @@ dependencies = [ "half", ] +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags 1.3.2", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + [[package]] name = "clap" version = "4.5.9" @@ -933,7 +925,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", - "clap_derive", ] [[package]] @@ -942,22 +933,8 @@ version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ - "anstream", "anstyle", "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.70", ] [[package]] @@ -966,12 +943,6 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" -[[package]] -name = "colorchoice" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" - [[package]] name = "console" version = "0.15.8" @@ -1038,7 +1009,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap", + "clap 4.5.9", "criterion-plot", "is-terminal", "itertools 0.10.5", @@ -1831,12 +1802,30 @@ dependencies = [ "fxhash", ] +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.3.9" @@ -2144,17 +2133,11 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "windows-sys 0.52.0", ] -[[package]] -name = "is_terminal_polyfill" -version = "1.70.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" - [[package]] name = "itertools" version = "0.10.5" @@ -2333,7 +2316,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "wasi", "windows-sys 0.52.0", @@ -2453,7 +2436,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", ] @@ -2495,9 +2478,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" @@ -2853,6 +2836,30 @@ dependencies = [ "toml_edit", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro-error-attr2" version = "2.0.0" @@ -3242,7 +3249,6 @@ name = "revme" version = "0.10.1" dependencies = [ "alloy-rlp", - "clap", "hash-db", "hashbrown", "hex", @@ -3253,6 +3259,7 @@ dependencies = [ "revm", "serde", "serde_json", + "structopt", "thiserror", "triehash", "walkdir", @@ -3602,9 +3609,9 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.29.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" +checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" dependencies = [ "rand", "secp256k1-sys", @@ -3887,9 +3894,33 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strsim" -version = "0.11.1" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "structopt" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" +dependencies = [ + "clap 2.34.0", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" +dependencies = [ + "heck 0.3.3", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] [[package]] name = "strum" @@ -3906,7 +3937,7 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", @@ -3956,9 +3987,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", @@ -4041,6 +4072,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + [[package]] name = "thiserror" version = "1.0.63" @@ -4407,6 +4447,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + [[package]] name = "unicode-width" version = "0.1.13" @@ -4448,12 +4494,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" -[[package]] -name = "utf8parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" - [[package]] name = "valuable" version = "0.1.0" @@ -4466,6 +4506,12 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + [[package]] name = "version_check" version = "0.9.4" diff --git a/bins/revme/Cargo.toml b/bins/revme/Cargo.toml index b8f02f90d2..798673b830 100644 --- a/bins/revme/Cargo.toml +++ b/bins/revme/Cargo.toml @@ -28,7 +28,7 @@ alloy-rlp = { version = "0.3", default-features = false, features = [ ] } serde = { version = "1.0", features = ["derive", "rc"] } serde_json = { version = "1.0", features = ["preserve_order"] } -clap = { version = "4", features = ["derive"] } +structopt = "0.3" thiserror = "1.0" triehash = "0.8" walkdir = "2.5" diff --git a/bins/revme/src/cmd.rs b/bins/revme/src/cmd.rs index a36a637a6e..97ea618aee 100644 --- a/bins/revme/src/cmd.rs +++ b/bins/revme/src/cmd.rs @@ -3,19 +3,21 @@ pub mod eofvalidation; pub mod evmrunner; pub mod statetest; -use clap::Parser; +use structopt::{clap::AppSettings, StructOpt}; -#[derive(Parser, Debug)] -#[command(infer_subcommands = true)] +#[derive(StructOpt, Debug)] +#[structopt(setting = AppSettings::InferSubcommands)] #[allow(clippy::large_enum_variant)] pub enum MainCmd { - /// Execute Ethereum state tests. + #[structopt(about = "Execute Ethereum state tests")] Statetest(statetest::Cmd), - /// Execute eof validation tests. + #[structopt(about = "Execute eof validation tests")] EofValidation(eofvalidation::Cmd), - /// Run arbitrary EVM bytecode. + #[structopt( + about = "Evm runner command allows running arbitrary evm bytecode.\nBytecode can be provided from cli or from file with --path option." + )] Evm(evmrunner::Cmd), - /// Print the structure of an EVM bytecode. + #[structopt(alias = "bc", about = "Prints the opcodes of an hex Bytecodes.")] Bytecode(bytecode::Cmd), } diff --git a/bins/revme/src/cmd/bytecode.rs b/bins/revme/src/cmd/bytecode.rs index a0843a9492..f46ebc264c 100644 --- a/bins/revme/src/cmd/bytecode.rs +++ b/bins/revme/src/cmd/bytecode.rs @@ -1,4 +1,3 @@ -use clap::Parser; use revm::{ interpreter::{ analysis::{validate_eof_inner, CodeType, EofError}, @@ -7,20 +6,21 @@ use revm::{ primitives::{Bytes, Eof, MAX_INITCODE_SIZE}, }; use std::io; +use structopt::StructOpt; -/// `bytecode` subcommand. -#[derive(Parser, Debug)] +/// Statetest command +#[derive(StructOpt, Debug)] pub struct Cmd { /// Is EOF code in INITCODE mode. - #[arg(long)] + #[structopt(long)] eof_initcode: bool, /// Is EOF code in RUNTIME mode. - #[arg(long)] + #[structopt(long)] eof_runtime: bool, /// Bytecode in hex format. If bytes start with 0xFE it will be interpreted as a EOF. /// Otherwise, it will be interpreted as a EOF bytecode. /// If not provided, it will operate in interactive EOF validation mode. - #[arg()] + #[structopt()] bytes: Option, } diff --git a/bins/revme/src/cmd/eofvalidation.rs b/bins/revme/src/cmd/eofvalidation.rs index 1badad7e77..6d1d39fd4f 100644 --- a/bins/revme/src/cmd/eofvalidation.rs +++ b/bins/revme/src/cmd/eofvalidation.rs @@ -3,24 +3,24 @@ mod test_suite; pub use test_suite::{PragueTestResult, TestResult, TestSuite, TestUnit, TestVector}; use crate::{cmd::Error, dir_utils::find_all_json_tests}; -use clap::Parser; use revm::interpreter::analysis::{validate_raw_eof_inner, CodeType, EofError}; use std::collections::BTreeMap; use std::path::{Path, PathBuf}; +use structopt::StructOpt; -/// `eof-validation` subcommand. -#[derive(Parser, Debug)] +/// Eof validation command. +#[derive(StructOpt, Debug)] pub struct Cmd { - /// Input paths to EOF validation tests. - #[arg(required = true, num_args = 1..)] - paths: Vec, + /// Input path to eof validation test + #[structopt(required = true)] + path: Vec, } impl Cmd { /// Run statetest command. pub fn run(&self) -> Result<(), Error> { // check if path exists. - for path in &self.paths { + for path in &self.path { if !path.exists() { return Err(Error::Custom("The specified path does not exist")); } diff --git a/bins/revme/src/cmd/evmrunner.rs b/bins/revme/src/cmd/evmrunner.rs index 381b153de4..3065280213 100644 --- a/bins/revme/src/cmd/evmrunner.rs +++ b/bins/revme/src/cmd/evmrunner.rs @@ -1,4 +1,3 @@ -use clap::Parser; use revm::{ db::BenchmarkDB, inspector_handle_register, @@ -10,6 +9,9 @@ use std::io::Error as IoError; use std::path::PathBuf; use std::time::Duration; use std::{borrow::Cow, fs}; +use structopt::StructOpt; + +extern crate alloc; #[derive(Debug, thiserror::Error)] pub enum Errors { @@ -29,26 +31,26 @@ pub enum Errors { /// Evm runner command allows running arbitrary evm bytecode. /// Bytecode can be provided from cli or from file with --path option. -#[derive(Parser, Debug)] +#[derive(StructOpt, Debug)] pub struct Cmd { - /// Hex-encoded EVM bytecode to be executed. - #[arg(required_unless_present = "path")] - bytecode: Option, - /// Path to a file containing the hex-encoded EVM bytecode to be executed. - /// Overrides the positional `bytecode` argument. - #[arg(long)] + /// Bytecode to be executed. + #[structopt(default_value = "")] + bytecode: String, + /// Path to file containing the evm bytecode. + /// Overrides the bytecode option. + #[structopt(long)] path: Option, /// Run in benchmarking mode. - #[arg(long)] + #[structopt(long)] bench: bool, - /// Hex-encoded input/calldata bytes. - #[arg(long, default_value = "")] + /// Input bytes. + #[structopt(long, default_value = "")] input: String, /// Print the state. - #[arg(long)] + #[structopt(long)] state: bool, /// Print the trace. - #[arg(long)] + #[structopt(long)] trace: bool, } @@ -62,11 +64,9 @@ impl Cmd { if !path.exists() { return Err(Errors::PathNotExists); } - fs::read_to_string(path)?.into() - } else if let Some(bytecode) = &self.bytecode { - bytecode.as_str().into() + fs::read_to_string(path)?.to_owned().into() } else { - unreachable!() + self.bytecode.as_str().into() }; let bytecode = hex::decode(bytecode_str.trim()).map_err(|_| Errors::InvalidBytecode)?; diff --git a/bins/revme/src/cmd/statetest.rs b/bins/revme/src/cmd/statetest.rs index 2b62a43430..cc082cb0d4 100644 --- a/bins/revme/src/cmd/statetest.rs +++ b/bins/revme/src/cmd/statetest.rs @@ -5,39 +5,38 @@ pub mod utils; pub use runner::TestError as Error; -use clap::Parser; use runner::{find_all_json_tests, run, TestError}; use std::path::PathBuf; +use structopt::StructOpt; -/// `statetest` subcommand. -#[derive(Parser, Debug)] +/// Statetest command +#[derive(StructOpt, Debug)] pub struct Cmd { /// Path to folder or file containing the tests. If multiple paths are specified /// they will be run in sequence. /// /// Folders will be searched recursively for files with the extension `.json`. - #[clap(required = true, num_args = 1..)] - paths: Vec, + #[structopt(required = true)] + path: Vec, /// Run tests in a single thread. - #[clap(short = 's', long)] + #[structopt(short = "s", long)] single_thread: bool, /// Output results in JSON format. /// It will stop second run of evm on failure. - #[clap(long)] + #[structopt(long)] json: bool, - /// Output outcome in JSON format. If `--json` is true, this is implied. - /// It will stop second run of EVM on failure. - #[clap(short = 'o', long)] + /// Output outcome in JSON format. If json is true, this is implied. + /// It will stop second run of evm on failure. + #[structopt(short = "o", long)] json_outcome: bool, - /// Keep going after a test failure. - #[clap(long, alias = "no-fail-fast")] + #[structopt(long, alias = "no-fail-fast")] keep_going: bool, } impl Cmd { /// Run statetest command. pub fn run(&self) -> Result<(), TestError> { - for path in &self.paths { + for path in &self.path { println!("\nRunning tests in {}...", path.display()); let test_files = find_all_json_tests(path); run( diff --git a/bins/revme/src/cmd/statetest/runner.rs b/bins/revme/src/cmd/statetest/runner.rs index 78a909f70a..b3e01f3392 100644 --- a/bins/revme/src/cmd/statetest/runner.rs +++ b/bins/revme/src/cmd/statetest/runner.rs @@ -404,7 +404,6 @@ pub fn execute_test_suite( .with_external_context( TracerEip3155::new(Box::new(stderr())).without_summary(), ) - .with_spec_id(spec_id) .append_handler_register(inspector_handle_register) .build(); @@ -467,7 +466,6 @@ pub fn execute_test_suite( .with_env(env.clone()) .reset_handler_with_external_context::>() .with_external_context(TracerEip3155::new(Box::new(stdout())).without_summary()) - .with_spec_id(spec_id) .append_handler_register(inspector_handle_register) .build(); let _ = evm.transact_commit(); diff --git a/bins/revme/src/main.rs b/bins/revme/src/main.rs index 992e9d248e..4662057476 100644 --- a/bins/revme/src/main.rs +++ b/bins/revme/src/main.rs @@ -1,6 +1,11 @@ -use clap::Parser; use revme::cmd::{Error, MainCmd}; +use structopt::StructOpt; -fn main() -> Result<(), Error> { - MainCmd::parse().run().inspect_err(|e| eprintln!("{e:?}")) +pub fn main() -> Result<(), Error> { + let cmd = MainCmd::from_args(); + if let Err(e) = cmd.run() { + println!("{:?}", e); + return Err(e); + } + Ok(()) } diff --git a/crates/interpreter/src/instruction_result.rs b/crates/interpreter/src/instruction_result.rs index e73ce1abc8..46f82a335e 100644 --- a/crates/interpreter/src/instruction_result.rs +++ b/crates/interpreter/src/instruction_result.rs @@ -1,6 +1,7 @@ use core::fmt::Debug; -use revm_primitives::HaltReasonTrait; +use derive_where::derive_where; +use revm_primitives::EvmWiring; use crate::primitives::{HaltReason, OutOfGasError, SuccessReason}; @@ -235,16 +236,17 @@ pub enum InternalResult { InvalidExtDelegateCallTarget, } -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] -pub enum SuccessOrHalt { +#[derive(Copy, Clone, PartialEq, Eq, Hash)] +#[derive_where(Debug; EvmWiringT::HaltReason)] +pub enum SuccessOrHalt { Success(SuccessReason), Revert, - Halt(HaltReasonT), + Halt(EvmWiringT::HaltReason), FatalExternalError, Internal(InternalResult), } -impl SuccessOrHalt { +impl SuccessOrHalt { /// Returns true if the transaction returned successfully without halts. #[inline] pub fn is_success(self) -> bool { @@ -274,7 +276,7 @@ impl SuccessOrHalt { /// Returns the [HaltReason] value the EVM has experienced an exceptional halt #[inline] - pub fn to_halt(self) -> Option { + pub fn to_halt(self) -> Option { match self { SuccessOrHalt::Halt(reason) => Some(reason), _ => None, @@ -282,7 +284,7 @@ impl SuccessOrHalt { } } -impl From for SuccessOrHalt { +impl From for SuccessOrHalt { fn from(result: InstructionResult) -> Self { match result { InstructionResult::Continue => Self::Internal(InternalResult::InternalContinue), // used only in interpreter loop diff --git a/crates/optimism/Cargo.toml b/crates/optimism/Cargo.toml index 65a979b9f4..01fe061821 100644 --- a/crates/optimism/Cargo.toml +++ b/crates/optimism/Cargo.toml @@ -39,7 +39,7 @@ serde = { version = "1.0", default-features = false, features = [ [dev-dependencies] -anyhow = "1.0.89" +anyhow = "1.0.83" criterion = "0.5" indicatif = "0.17" rstest = "0.22.0" diff --git a/crates/precompile/Cargo.toml b/crates/precompile/Cargo.toml index b29bac7aeb..04cb1104eb 100644 --- a/crates/precompile/Cargo.toml +++ b/crates/precompile/Cargo.toml @@ -23,7 +23,7 @@ all = "warn" [dependencies] revm-primitives = { path = "../primitives", version = "9.0.1", default-features = false } -once_cell = { version = "1.20", default-features = false, features = ["alloc"] } +once_cell = { version = "1.19", default-features = false, features = ["alloc"] } # ecRecover k256 = { version = "0.13.3", default-features = false, features = ["ecdsa"] } diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index de12bf468c..f5ddad0c4e 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -58,7 +58,7 @@ alloy-sol-types = { version = "0.8.2", default-features = false, features = [ "std", ] } ethers-contract = { version = "2.0.14", default-features = false } -anyhow = "1.0.89" +anyhow = "1.0.87" criterion = "0.5" indicatif = "0.17" reqwest = { version = "0.12" } diff --git a/crates/revm/src/handler/mainnet/post_execution.rs b/crates/revm/src/handler/mainnet/post_execution.rs index c010b7a0bb..784ab53540 100644 --- a/crates/revm/src/handler/mainnet/post_execution.rs +++ b/crates/revm/src/handler/mainnet/post_execution.rs @@ -112,7 +112,7 @@ pub fn output( // reset journal and return present state. let (state, logs) = context.evm.journaled_state.finalize(); - let result = match SuccessOrHalt::::from(instruction_result.result) { + let result = match SuccessOrHalt::::from(instruction_result.result) { SuccessOrHalt::Success(reason) => ExecutionResult::Success { reason, gas_used: final_gas_used,