diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml index 6ed8042224..ea33f1fb9c 100644 --- a/.github/workflows/book.yml +++ b/.github/workflows/book.yml @@ -81,7 +81,7 @@ jobs: run: mdbook build documentation - name: Build docs - run: RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo +nightly doc --all --no-deps + run: RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo doc --all --no-deps - name: Move docs to book folder run: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4d7e3ddde..10686799f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,8 +78,8 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@clippy - - run: cargo +nightly clippy --workspace --all-targets --all-features + - uses: dtolnay/rust-toolchain@stable + - run: cargo clippy --workspace --all-targets --all-features env: RUSTFLAGS: -Dwarnings @@ -89,7 +89,7 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@nightly + - uses: dtolnay/rust-toolchain@stable with: components: rust-docs - run: cargo doc --workspace --all-features --no-deps --document-private-items @@ -102,7 +102,7 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@nightly + - uses: dtolnay/rust-toolchain@stable with: components: rustfmt - - run: cargo +nightly fmt --all --check + - run: cargo fmt --all --check diff --git a/bins/revm-test/src/bin/analysis.rs b/bins/revm-test/src/bin/analysis.rs index b0f2b6404e..49fdbc57a7 100644 --- a/bins/revm-test/src/bin/analysis.rs +++ b/bins/revm-test/src/bin/analysis.rs @@ -1,12 +1,10 @@ -use std::time::Instant; - use revm::{ db::BenchmarkDB, interpreter::analysis::to_analysed, primitives::{address, bytes, Bytecode, Bytes, TransactTo}, Evm, }; -extern crate alloc; +use std::time::Instant; fn main() { let contract_data : Bytes = hex::decode( "6060604052341561000f57600080fd5b604051610dd1380380610dd18339810160405280805190602001909190805182019190602001805190602001909190805182019190505083600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508360008190555082600390805190602001906100a79291906100e3565b5081600460006101000a81548160ff021916908360ff16021790555080600590805190602001906100d99291906100e3565b5050505050610188565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061012457805160ff1916838001178555610152565b82800160010185558215610152579182015b82811115610151578251825591602001919060010190610136565b5b50905061015f9190610163565b5090565b61018591905b80821115610181576000816000905550600101610169565b5090565b90565b610c3a806101976000396000f3006060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b4578063095ea7b31461014257806318160ddd1461019c57806323b872dd146101c557806327e235e31461023e578063313ce5671461028b5780635c658165146102ba57806370a082311461032657806395d89b4114610373578063a9059cbb14610401578063dd62ed3e1461045b575b600080fd5b34156100bf57600080fd5b6100c76104c7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101075780820151818401526020810190506100ec565b50505050905090810190601f1680156101345780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014d57600080fd5b610182600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610565565b604051808215151515815260200191505060405180910390f35b34156101a757600080fd5b6101af610657565b6040518082815260200191505060405180910390f35b34156101d057600080fd5b610224600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061065d565b604051808215151515815260200191505060405180910390f35b341561024957600080fd5b610275600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108f7565b6040518082815260200191505060405180910390f35b341561029657600080fd5b61029e61090f565b604051808260ff1660ff16815260200191505060405180910390f35b34156102c557600080fd5b610310600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610922565b6040518082815260200191505060405180910390f35b341561033157600080fd5b61035d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610947565b6040518082815260200191505060405180910390f35b341561037e57600080fd5b610386610990565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103c65780820151818401526020810190506103ab565b50505050905090810190601f1680156103f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561040c57600080fd5b610441600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610a2e565b604051808215151515815260200191505060405180910390f35b341561046657600080fd5b6104b1600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610b87565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561055d5780601f106105325761010080835404028352916020019161055d565b820191906000526020600020905b81548152906001019060200180831161054057829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b600080600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015801561072e5750828110155b151561073957600080fd5b82600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555082600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110156108865782600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b60016020528060005260406000206000915090505481565b600460009054906101000a900460ff1681565b6002602052816000526040600020602052806000526040600020600091509150505481565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a265780601f106109fb57610100808354040283529160200191610a26565b820191906000526020600020905b815481529060010190602001808311610a0957829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610a7e57600080fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820df254047bc8f2904ad3e966b6db116d703bebd40efadadb5e738c836ffc8f58a0029" ).unwrap().into(); diff --git a/bins/revm-test/src/bin/transfer.rs b/bins/revm-test/src/bin/transfer.rs index 2af94b040d..8abd0910ef 100644 --- a/bins/revm-test/src/bin/transfer.rs +++ b/bins/revm-test/src/bin/transfer.rs @@ -3,8 +3,8 @@ use revm::{ primitives::{Bytecode, TransactTo, U256}, Evm, }; + use std::time::Duration; -extern crate alloc; fn main() { // BenchmarkDB is dummy state that implements Database trait. diff --git a/crates/interpreter/src/gas/calc.rs b/crates/interpreter/src/gas/calc.rs index 17c2a33c57..092fff7c85 100644 --- a/crates/interpreter/src/gas/calc.rs +++ b/crates/interpreter/src/gas/calc.rs @@ -1,7 +1,7 @@ use super::constants::*; use crate::inner_models::SelfDestructResult; use crate::primitives::{Address, Spec, SpecId::*, U256}; -use alloc::vec::Vec; +use std::vec::Vec; #[allow(clippy::collapsible_else_if)] pub fn sstore_refund(original: U256, current: U256, new: U256) -> i64 { diff --git a/crates/interpreter/src/host/dummy.rs b/crates/interpreter/src/host/dummy.rs index 96b208b189..ca8e2b4538 100644 --- a/crates/interpreter/src/host/dummy.rs +++ b/crates/interpreter/src/host/dummy.rs @@ -3,7 +3,7 @@ use crate::{ primitives::{Address, Env, Log, B256, KECCAK_EMPTY}, Host, SelfDestructResult, }; -use alloc::vec::Vec; +use std::vec::Vec; /// A dummy [Host] implementation. #[derive(Clone, Debug, Default, PartialEq, Eq)] diff --git a/crates/interpreter/src/inner_models.rs b/crates/interpreter/src/inner_models.rs index 754450ba59..550fab19c3 100644 --- a/crates/interpreter/src/inner_models.rs +++ b/crates/interpreter/src/inner_models.rs @@ -1,7 +1,7 @@ pub use crate::primitives::CreateScheme; use crate::primitives::{Address, Bytes, TransactTo, TxEnv, U256}; -use alloc::boxed::Box; use core::ops::Range; +use std::boxed::Box; /// Inputs for a call. #[derive(Clone, Debug, PartialEq, Eq, Hash)] diff --git a/crates/interpreter/src/instructions/host.rs b/crates/interpreter/src/instructions/host.rs index 4919b644a6..9a4a9e79ea 100644 --- a/crates/interpreter/src/instructions/host.rs +++ b/crates/interpreter/src/instructions/host.rs @@ -9,9 +9,9 @@ use crate::{ CallContext, CallInputs, CallScheme, CreateInputs, CreateScheme, Host, InstructionResult, Transfer, MAX_INITCODE_SIZE, }; -use alloc::{boxed::Box, vec::Vec}; use core::cmp::min; use revm_primitives::BLOCK_HASH_HISTORY; +use std::{boxed::Box, vec::Vec}; pub fn balance(interpreter: &mut Interpreter, host: &mut H) { pop_address!(interpreter, address); diff --git a/crates/interpreter/src/instructions/opcode.rs b/crates/interpreter/src/instructions/opcode.rs index 79a77ee829..ccc5ac76b4 100644 --- a/crates/interpreter/src/instructions/opcode.rs +++ b/crates/interpreter/src/instructions/opcode.rs @@ -6,8 +6,8 @@ use crate::{ primitives::{Spec, SpecId}, Host, Interpreter, }; -use alloc::boxed::Box; use core::fmt; +use std::boxed::Box; /// EVM opcode function signature. pub type Instruction = fn(&mut Interpreter, &mut H); diff --git a/crates/interpreter/src/interpreter.rs b/crates/interpreter/src/interpreter.rs index 4cddf3ca6d..23ff01e969 100644 --- a/crates/interpreter/src/interpreter.rs +++ b/crates/interpreter/src/interpreter.rs @@ -8,14 +8,14 @@ pub use contract::Contract; pub use shared_memory::{next_multiple_of_32, SharedMemory}; pub use stack::{Stack, STACK_LIMIT}; -use crate::alloc::borrow::ToOwned; use crate::{ primitives::Bytes, push, push_b256, return_ok, return_revert, CallInputs, CallOutcome, CreateInputs, CreateOutcome, Gas, Host, InstructionResult, }; -use alloc::boxed::Box; use core::cmp::min; use revm_primitives::U256; +use std::borrow::ToOwned; +use std::boxed::Box; pub use self::shared_memory::EMPTY_SHARED_MEMORY; diff --git a/crates/interpreter/src/interpreter/analysis.rs b/crates/interpreter/src/interpreter/analysis.rs index eda7216412..4b363a84bc 100644 --- a/crates/interpreter/src/interpreter/analysis.rs +++ b/crates/interpreter/src/interpreter/analysis.rs @@ -3,8 +3,8 @@ use crate::primitives::{ bitvec::prelude::{bitvec, BitVec, Lsb0}, keccak256, Bytecode, BytecodeState, Bytes, JumpMap, B256, KECCAK_EMPTY, }; -use alloc::sync::Arc; use core::fmt; +use std::sync::Arc; /// Perform bytecode analysis. /// diff --git a/crates/interpreter/src/interpreter/shared_memory.rs b/crates/interpreter/src/interpreter/shared_memory.rs index 77abbf2867..b330412418 100644 --- a/crates/interpreter/src/interpreter/shared_memory.rs +++ b/crates/interpreter/src/interpreter/shared_memory.rs @@ -1,11 +1,11 @@ use revm_primitives::{B256, U256}; -use crate::alloc::vec::Vec; use core::{ cmp::min, fmt, ops::{BitAnd, Not}, }; +use std::vec::Vec; /// A sequential memory shared between calls, which uses /// a `Vec` for internal representation. diff --git a/crates/interpreter/src/interpreter/stack.rs b/crates/interpreter/src/interpreter/stack.rs index 7a05ad0840..9692695cf2 100644 --- a/crates/interpreter/src/interpreter/stack.rs +++ b/crates/interpreter/src/interpreter/stack.rs @@ -2,8 +2,8 @@ use crate::{ primitives::{B256, U256}, InstructionResult, }; -use alloc::vec::Vec; use core::fmt; +use std::vec::Vec; /// EVM interpreter stack limit. pub const STACK_LIMIT: usize = 1024; @@ -318,7 +318,7 @@ impl<'de> serde::Deserialize<'de> for Stack { { let mut data = Vec::::deserialize(deserializer)?; if data.len() > STACK_LIMIT { - return Err(serde::de::Error::custom(alloc::format!( + return Err(serde::de::Error::custom(std::format!( "stack size exceeds limit: {} > {}", data.len(), STACK_LIMIT diff --git a/crates/interpreter/src/lib.rs b/crates/interpreter/src/lib.rs index 5ee07a3a52..cecef71120 100644 --- a/crates/interpreter/src/lib.rs +++ b/crates/interpreter/src/lib.rs @@ -5,9 +5,9 @@ #![warn(unreachable_pub, unused_crate_dependencies)] #![deny(unused_must_use, rust_2018_idioms)] #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -extern crate alloc; +#[cfg(not(feature = "std"))] +extern crate alloc as std; #[macro_use] mod macros; diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index 9a099f7885..b3d1c73a30 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -5,10 +5,10 @@ #![warn(unused_crate_dependencies)] #![deny(unused_must_use, rust_2018_idioms)] #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] -extern crate alloc; +#[cfg(not(feature = "std"))] +extern crate alloc as std; mod blake2; mod bn128; @@ -20,7 +20,6 @@ mod modexp; mod secp256k1; pub mod utilities; -use alloc::{boxed::Box, vec::Vec}; use core::{fmt, hash::Hash}; use once_cell::race::OnceBox; #[doc(hidden)] @@ -29,6 +28,7 @@ pub use revm_primitives::{ precompile::{PrecompileError as Error, *}, Address, Bytes, HashMap, Log, B256, }; +use std::{boxed::Box, vec::Vec}; pub fn calc_linear_cost_u32(len: usize, base: u64, word: u64) -> u64 { (len as u64 + 32 - 1) / 32 * word + base diff --git a/crates/precompile/src/modexp.rs b/crates/precompile/src/modexp.rs index 903832fbed..986347aa1f 100644 --- a/crates/precompile/src/modexp.rs +++ b/crates/precompile/src/modexp.rs @@ -160,8 +160,8 @@ fn berlin_gas_calc(base_length: u64, exp_length: u64, mod_length: u64, exp_highp #[cfg(test)] mod tests { use super::*; - use alloc::vec::Vec; use revm_primitives::hex; + use std::vec::Vec; struct Test { input: &'static str, diff --git a/crates/precompile/src/secp256k1.rs b/crates/precompile/src/secp256k1.rs index 352d7024c5..d7b3a00aad 100644 --- a/crates/precompile/src/secp256k1.rs +++ b/crates/precompile/src/secp256k1.rs @@ -19,7 +19,7 @@ mod secp256k1 { // normalize signature and flip recovery id if needed. if let Some(sig_normalized) = sig.normalize_s() { sig = sig_normalized; - recid = recid ^ 1; + recid ^= 1; } let recid = RecoveryId::from_byte(recid).expect("recovery ID is valid"); diff --git a/crates/precompile/src/utilities.rs b/crates/precompile/src/utilities.rs index 22ed7f7d0b..022da1dc4a 100644 --- a/crates/precompile/src/utilities.rs +++ b/crates/precompile/src/utilities.rs @@ -1,4 +1,4 @@ -use alloc::borrow::Cow; +use std::borrow::Cow; /// Right-pads the given slice at `offset` with zeroes until `LEN`. /// diff --git a/crates/primitives/src/bytecode.rs b/crates/primitives/src/bytecode.rs index bbf8791eef..e13040bd43 100644 --- a/crates/primitives/src/bytecode.rs +++ b/crates/primitives/src/bytecode.rs @@ -1,10 +1,10 @@ use crate::{hex, keccak256, Bytes, B256, KECCAK_EMPTY}; -use alloc::{sync::Arc, vec::Vec}; use bitvec::{ prelude::{bitvec, Lsb0}, vec::BitVec, }; use core::fmt::Debug; +use std::{sync::Arc, vec::Vec}; /// A map of valid `jump` destinations. #[derive(Clone, Default, PartialEq, Eq, Hash)] diff --git a/crates/primitives/src/db/components/block_hash.rs b/crates/primitives/src/db/components/block_hash.rs index be250ac0eb..a0a0fe21e6 100644 --- a/crates/primitives/src/db/components/block_hash.rs +++ b/crates/primitives/src/db/components/block_hash.rs @@ -2,9 +2,9 @@ //! it is used inside [`crate::db::DatabaseComponents`] use crate::{B256, U256}; -use alloc::sync::Arc; use auto_impl::auto_impl; use core::ops::Deref; +use std::sync::Arc; #[auto_impl(&mut, Box)] pub trait BlockHash { diff --git a/crates/primitives/src/db/components/state.rs b/crates/primitives/src/db/components/state.rs index 9121f0e28e..d3b948ddaa 100644 --- a/crates/primitives/src/db/components/state.rs +++ b/crates/primitives/src/db/components/state.rs @@ -2,9 +2,9 @@ //! it is used inside [`crate::db::DatabaseComponents`] use crate::{AccountInfo, Address, Bytecode, B256, U256}; -use alloc::sync::Arc; use auto_impl::auto_impl; use core::ops::Deref; +use std::sync::Arc; #[auto_impl(&mut, Box)] pub trait State { diff --git a/crates/primitives/src/env.rs b/crates/primitives/src/env.rs index f92b484248..aa2f3f4cc2 100644 --- a/crates/primitives/src/env.rs +++ b/crates/primitives/src/env.rs @@ -3,12 +3,13 @@ pub mod handler_cfg; pub use handler_cfg::{CfgEnvWithHandlerCfg, EnvWithHandlerCfg, HandlerCfg}; use crate::{ - alloc::vec::Vec, calc_blob_gasprice, Account, Address, Bytes, InvalidHeader, - InvalidTransaction, Spec, SpecId, B256, GAS_PER_BLOB, KECCAK_EMPTY, MAX_BLOB_NUMBER_PER_BLOCK, - MAX_INITCODE_SIZE, U256, VERSIONED_HASH_VERSION_KZG, + calc_blob_gasprice, Account, Address, Bytes, InvalidHeader, InvalidTransaction, Spec, SpecId, + B256, GAS_PER_BLOB, KECCAK_EMPTY, MAX_BLOB_NUMBER_PER_BLOCK, MAX_INITCODE_SIZE, U256, + VERSIONED_HASH_VERSION_KZG, }; -use alloc::boxed::Box; use core::cmp::{min, Ordering}; +use std::boxed::Box; +use std::vec::Vec; /// EVM environment configuration. #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] diff --git a/crates/primitives/src/env/handler_cfg.rs b/crates/primitives/src/env/handler_cfg.rs index 1c47e16536..e1766d02fe 100644 --- a/crates/primitives/src/env/handler_cfg.rs +++ b/crates/primitives/src/env/handler_cfg.rs @@ -1,6 +1,6 @@ use super::{BlockEnv, CfgEnv, Env, SpecId, TxEnv}; -use alloc::boxed::Box; use core::ops::{Deref, DerefMut}; +use std::boxed::Box; /// Handler configuration fields. It is used to configure the handler. /// It contains specification id and the Optimism related field if diff --git a/crates/primitives/src/kzg/env_settings.rs b/crates/primitives/src/kzg/env_settings.rs index 88b818566d..849ec3c463 100644 --- a/crates/primitives/src/kzg/env_settings.rs +++ b/crates/primitives/src/kzg/env_settings.rs @@ -2,9 +2,9 @@ use super::{ trusted_setup_points::{G1_POINTS, G2_POINTS}, KzgSettings, }; -use alloc::{boxed::Box, sync::Arc}; use core::hash::{Hash, Hasher}; use once_cell::race::OnceBox; +use std::{boxed::Box, sync::Arc}; /// KZG Settings that allow us to specify a custom trusted setup. /// or use hardcoded default settings. diff --git a/crates/primitives/src/kzg/trusted_setup_points.rs b/crates/primitives/src/kzg/trusted_setup_points.rs index 70b422c81e..182d6c17ee 100644 --- a/crates/primitives/src/kzg/trusted_setup_points.rs +++ b/crates/primitives/src/kzg/trusted_setup_points.rs @@ -1,7 +1,7 @@ -use alloc::boxed::Box; pub use c_kzg::{BYTES_PER_G1_POINT, BYTES_PER_G2_POINT}; use core::fmt::Display; use derive_more::{AsMut, AsRef, Deref, DerefMut}; +use std::boxed::Box; /// Number of G1 Points. pub const NUM_G1_POINTS: usize = 4096; diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 2d1da60808..7676e1d36c 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -5,9 +5,9 @@ #![warn(unreachable_pub, unused_crate_dependencies)] #![deny(unused_must_use, rust_2018_idioms)] #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -extern crate alloc; +#[cfg(not(feature = "std"))] +extern crate alloc as std; mod bytecode; mod constants; diff --git a/crates/primitives/src/result.rs b/crates/primitives/src/result.rs index b765dd7aef..2b7c37d401 100644 --- a/crates/primitives/src/result.rs +++ b/crates/primitives/src/result.rs @@ -1,6 +1,6 @@ use crate::{Address, Bytes, Log, State, U256}; -use alloc::{boxed::Box, string::String, vec::Vec}; use core::fmt; +use std::{boxed::Box, string::String, vec::Vec}; /// Result of EVM execution. pub type EVMResult = EVMResultGeneric; diff --git a/crates/revm/src/builder.rs b/crates/revm/src/builder.rs index a23c1d441c..20a8fd37a0 100644 --- a/crates/revm/src/builder.rs +++ b/crates/revm/src/builder.rs @@ -6,8 +6,8 @@ use crate::{ }, Context, ContextWithHandlerCfg, Evm, Handler, }; -use alloc::boxed::Box; use core::marker::PhantomData; +use std::boxed::Box; /// Evm Builder allows building or modifying EVM. /// Note that some of the methods that changes underlying structures diff --git a/crates/revm/src/context.rs b/crates/revm/src/context.rs index a84817e93f..ef91258729 100644 --- a/crates/revm/src/context.rs +++ b/crates/revm/src/context.rs @@ -12,7 +12,7 @@ use crate::{ }, FrameOrResult, JournalCheckpoint, CALL_STACK_LIMIT, }; -use alloc::boxed::Box; +use std::boxed::Box; /// Main Context structure that contains both EvmContext and External context. pub struct Context { @@ -173,7 +173,6 @@ impl EvmContext { /// /// Loading of accounts/storages is needed to make them warm. #[inline] - #[must_use] pub fn load_access_list(&mut self) -> Result<(), EVMError> { for (address, slots) in self.env.tx.access_list.iter() { self.journaled_state diff --git a/crates/revm/src/db/emptydb.rs b/crates/revm/src/db/emptydb.rs index 27d7641c92..6495ce1735 100644 --- a/crates/revm/src/db/emptydb.rs +++ b/crates/revm/src/db/emptydb.rs @@ -1,9 +1,9 @@ -use alloc::string::ToString; use core::{convert::Infallible, fmt, marker::PhantomData}; use revm_interpreter::primitives::{ db::{Database, DatabaseRef}, keccak256, AccountInfo, Address, Bytecode, B256, U256, }; +use std::string::ToString; /// An empty database that always returns default values when queried. pub type EmptyDB = EmptyDBTyped; diff --git a/crates/revm/src/db/in_memory_db.rs b/crates/revm/src/db/in_memory_db.rs index 2fef18b494..d7e435548f 100644 --- a/crates/revm/src/db/in_memory_db.rs +++ b/crates/revm/src/db/in_memory_db.rs @@ -4,8 +4,8 @@ use crate::primitives::{ U256, }; use crate::Database; -use alloc::vec::Vec; use core::convert::Infallible; +use std::vec::Vec; /// A [Database] implementation that stores all state changes in memory. pub type InMemoryDB = CacheDB; diff --git a/crates/revm/src/db/states/bundle_state.rs b/crates/revm/src/db/states/bundle_state.rs index f524b08ecb..0b5a6da573 100644 --- a/crates/revm/src/db/states/bundle_state.rs +++ b/crates/revm/src/db/states/bundle_state.rs @@ -3,15 +3,15 @@ use super::{ reverts::{AccountInfoRevert, Reverts}, AccountRevert, AccountStatus, BundleAccount, PlainStateReverts, RevertToSlot, TransitionState, }; -use alloc::{ - collections::{BTreeMap, BTreeSet}, - vec::Vec, -}; use core::{mem, ops::RangeInclusive}; use revm_interpreter::primitives::{ hash_map::{self, Entry}, AccountInfo, Address, Bytecode, HashMap, HashSet, StorageSlot, B256, KECCAK_EMPTY, U256, }; +use std::{ + collections::{BTreeMap, BTreeSet}, + vec::Vec, +}; /// This builder is used to help to facilitate the initialization of `BundleState` struct #[derive(Debug)] diff --git a/crates/revm/src/db/states/cache.rs b/crates/revm/src/db/states/cache.rs index a3232029ad..eb1c4577ae 100644 --- a/crates/revm/src/db/states/cache.rs +++ b/crates/revm/src/db/states/cache.rs @@ -1,10 +1,10 @@ use super::{ plain_account::PlainStorage, transition_account::TransitionAccount, CacheAccount, PlainAccount, }; -use alloc::vec::Vec; use revm_interpreter::primitives::{ Account, AccountInfo, Address, Bytecode, HashMap, State as EVMState, B256, }; +use std::vec::Vec; /// Cache state contains both modified and original values. /// diff --git a/crates/revm/src/db/states/changes.rs b/crates/revm/src/db/states/changes.rs index 4a559e699e..555ba1e015 100644 --- a/crates/revm/src/db/states/changes.rs +++ b/crates/revm/src/db/states/changes.rs @@ -1,6 +1,6 @@ use super::RevertToSlot; -use alloc::vec::Vec; use revm_interpreter::primitives::{AccountInfo, Address, Bytecode, B256, U256}; +use std::vec::Vec; /// accounts/storages/contracts for inclusion into database. /// Structure is made so it is easier to apply directly to database diff --git a/crates/revm/src/db/states/reverts.rs b/crates/revm/src/db/states/reverts.rs index 513101ded2..5be2c932fd 100644 --- a/crates/revm/src/db/states/reverts.rs +++ b/crates/revm/src/db/states/reverts.rs @@ -2,9 +2,9 @@ use super::{ changes::PlainStorageRevert, AccountStatus, BundleAccount, PlainStateReverts, StorageWithOriginalValues, }; -use alloc::vec::Vec; use core::ops::{Deref, DerefMut}; use revm_interpreter::primitives::{AccountInfo, Address, HashMap, U256}; +use std::vec::Vec; /// Contains reverts of multiple account in multiple transitions (Transitions as a block). #[derive(Clone, Debug, Default, PartialEq, Eq)] diff --git a/crates/revm/src/db/states/state.rs b/crates/revm/src/db/states/state.rs index ec82cb87ff..b7a4c38623 100644 --- a/crates/revm/src/db/states/state.rs +++ b/crates/revm/src/db/states/state.rs @@ -3,15 +3,15 @@ use super::{ CacheAccount, StateBuilder, TransitionAccount, TransitionState, }; use crate::db::EmptyDB; -use alloc::{ - boxed::Box, - collections::{btree_map, BTreeMap}, - vec::Vec, -}; use revm_interpreter::primitives::{ db::{Database, DatabaseCommit}, hash_map, Account, AccountInfo, Address, Bytecode, HashMap, B256, BLOCK_HASH_HISTORY, U256, }; +use std::{ + boxed::Box, + collections::{btree_map, BTreeMap}, + vec::Vec, +}; /// Database boxed with a lifetime and Send. pub type DBBox<'a, E> = Box + Send + 'a>; diff --git a/crates/revm/src/db/states/state_builder.rs b/crates/revm/src/db/states/state_builder.rs index b71293fb14..f029ae13d4 100644 --- a/crates/revm/src/db/states/state_builder.rs +++ b/crates/revm/src/db/states/state_builder.rs @@ -1,10 +1,10 @@ use super::{cache::CacheState, state::DBBox, BundleState, State, TransitionState}; use crate::db::EmptyDB; -use alloc::collections::BTreeMap; use revm_interpreter::primitives::{ db::{Database, DatabaseRef, WrapDatabaseRef}, B256, }; +use std::collections::BTreeMap; /// Allows building of State and initializing it with different options. #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/crates/revm/src/db/states/transition_state.rs b/crates/revm/src/db/states/transition_state.rs index 269492405e..1a65aefd28 100644 --- a/crates/revm/src/db/states/transition_state.rs +++ b/crates/revm/src/db/states/transition_state.rs @@ -1,6 +1,6 @@ use super::TransitionAccount; -use alloc::vec::Vec; use revm_interpreter::primitives::{hash_map::Entry, Address, HashMap}; +use std::vec::Vec; #[derive(Clone, Debug, PartialEq, Eq)] pub struct TransitionState { diff --git a/crates/revm/src/evm.rs b/crates/revm/src/evm.rs index 9db4c50854..8dfe358618 100644 --- a/crates/revm/src/evm.rs +++ b/crates/revm/src/evm.rs @@ -13,9 +13,9 @@ use crate::{ }, Context, ContextWithHandlerCfg, Frame, FrameOrResult, FrameResult, }; -use alloc::vec::Vec; use core::fmt; use revm_interpreter::{CallInputs, CreateInputs}; +use std::vec::Vec; /// EVM call stack limit. pub const CALL_STACK_LIMIT: u64 = 1024; diff --git a/crates/revm/src/frame.rs b/crates/revm/src/frame.rs index e519fdf2ba..ad5eada494 100644 --- a/crates/revm/src/frame.rs +++ b/crates/revm/src/frame.rs @@ -3,9 +3,9 @@ use crate::{ primitives::{Address, Output}, JournalCheckpoint, }; -use alloc::boxed::Box; use core::ops::Range; use revm_interpreter::{CallOutcome, CreateOutcome, Gas, InstructionResult, InterpreterResult}; +use std::boxed::Box; /// Call CallStackFrame. #[derive(Debug)] diff --git a/crates/revm/src/handler.rs b/crates/revm/src/handler.rs index 1d4654b3b7..bba5192543 100644 --- a/crates/revm/src/handler.rs +++ b/crates/revm/src/handler.rs @@ -15,8 +15,8 @@ use crate::{ primitives::{db::Database, spec_to_generic, HandlerCfg, Spec, SpecId}, Evm, }; -use alloc::vec::Vec; use register::{EvmHandler, HandleRegisters}; +use std::vec::Vec; use self::register::{HandleRegister, HandleRegisterBox}; @@ -205,7 +205,7 @@ mod test { use core::cell::RefCell; use crate::{db::EmptyDB, primitives::EVMError}; - use alloc::{rc::Rc, sync::Arc}; + use std::{rc::Rc, sync::Arc}; use super::*; diff --git a/crates/revm/src/handler/handle_types/execution.rs b/crates/revm/src/handler/handle_types/execution.rs index 7ed7aa5e8c..66831fb83c 100644 --- a/crates/revm/src/handler/handle_types/execution.rs +++ b/crates/revm/src/handler/handle_types/execution.rs @@ -4,7 +4,7 @@ use crate::{ primitives::{db::Database, Spec}, CallFrame, Context, CreateFrame, Frame, FrameOrResult, FrameResult, }; -use alloc::{boxed::Box, sync::Arc}; +use std::{boxed::Box, sync::Arc}; use revm_interpreter::{CallOutcome, CreateOutcome, InterpreterResult}; diff --git a/crates/revm/src/handler/handle_types/post_execution.rs b/crates/revm/src/handler/handle_types/post_execution.rs index 8155c28695..393b321aab 100644 --- a/crates/revm/src/handler/handle_types/post_execution.rs +++ b/crates/revm/src/handler/handle_types/post_execution.rs @@ -5,7 +5,7 @@ use crate::{ primitives::{db::Database, EVMError, EVMResultGeneric, ResultAndState, Spec}, Context, FrameResult, }; -use alloc::sync::Arc; +use std::sync::Arc; /// Reimburse the caller with ethereum it didn't spent. pub type ReimburseCallerHandle<'a, EXT, DB> = diff --git a/crates/revm/src/handler/handle_types/pre_execution.rs b/crates/revm/src/handler/handle_types/pre_execution.rs index 62df4a90ae..7bbdab0867 100644 --- a/crates/revm/src/handler/handle_types/pre_execution.rs +++ b/crates/revm/src/handler/handle_types/pre_execution.rs @@ -4,8 +4,8 @@ use crate::{ primitives::{db::Database, EVMError, EVMResultGeneric, Spec}, Context, }; -use alloc::sync::Arc; use revm_precompile::Precompiles; +use std::sync::Arc; /// Loads precompiles into Evm pub type LoadPrecompilesHandle<'a> = Arc Precompiles + 'a>; diff --git a/crates/revm/src/handler/handle_types/validation.rs b/crates/revm/src/handler/handle_types/validation.rs index 8516960d28..8aa55c28c2 100644 --- a/crates/revm/src/handler/handle_types/validation.rs +++ b/crates/revm/src/handler/handle_types/validation.rs @@ -3,7 +3,7 @@ use crate::{ primitives::{db::Database, EVMError, Env, Spec}, Context, }; -use alloc::sync::Arc; +use std::sync::Arc; /// Handle that validates env. pub type ValidateEnvHandle<'a, DB> = diff --git a/crates/revm/src/handler/mainnet/execution.rs b/crates/revm/src/handler/mainnet/execution.rs index d56d94e99a..92f00963ba 100644 --- a/crates/revm/src/handler/mainnet/execution.rs +++ b/crates/revm/src/handler/mainnet/execution.rs @@ -7,7 +7,7 @@ use crate::{ primitives::{Env, Spec}, CallFrame, Context, CreateFrame, Frame, FrameOrResult, FrameResult, }; -use alloc::boxed::Box; +use std::boxed::Box; use revm_interpreter::{CallOutcome, InterpreterResult}; diff --git a/crates/revm/src/handler/register.rs b/crates/revm/src/handler/register.rs index 2a5e9df89e..835b80e2c8 100644 --- a/crates/revm/src/handler/register.rs +++ b/crates/revm/src/handler/register.rs @@ -1,5 +1,5 @@ use crate::{db::Database, handler::Handler, interpreter::opcode::InstructionTables, Evm}; -use alloc::boxed::Box; +use std::boxed::Box; /// EVM Handler pub type EvmHandler<'a, EXT, DB> = Handler<'a, Evm<'a, EXT, DB>, EXT, DB>; diff --git a/crates/revm/src/inspector/eip3155.rs b/crates/revm/src/inspector/eip3155.rs index 6fd6449f2a..1da606af9d 100644 --- a/crates/revm/src/inspector/eip3155.rs +++ b/crates/revm/src/inspector/eip3155.rs @@ -148,7 +148,7 @@ impl Inspector for TracerEip3155 { gas: hex_number(self.gas), gas_cost: hex_number(self.gas_inspector.last_gas_cost()), stack: self.stack.iter().map(hex_number_u256).collect(), - depth: context.journaled_state.depth() as u64, + depth: context.journaled_state.depth(), return_data: "0x".to_string(), refund: "0x0".to_string(), mem_size: self.mem_size.to_string(), diff --git a/crates/revm/src/inspector/handler_register.rs b/crates/revm/src/inspector/handler_register.rs index a3b6d8fcd2..f588237fd3 100644 --- a/crates/revm/src/inspector/handler_register.rs +++ b/crates/revm/src/inspector/handler_register.rs @@ -6,7 +6,7 @@ use crate::{ interpreter::{opcode, opcode::BoxedInstruction, InstructionResult, Interpreter}, Evm, FrameOrResult, FrameResult, Inspector, JournalEntry, }; -use alloc::{boxed::Box, rc::Rc, sync::Arc, vec::Vec}; +use std::{boxed::Box, rc::Rc, sync::Arc, vec::Vec}; /// Provides access to an `Inspector` instance. pub trait GetInspector { diff --git a/crates/revm/src/journaled_state.rs b/crates/revm/src/journaled_state.rs index 27882a4f3b..2d04ae3c5c 100644 --- a/crates/revm/src/journaled_state.rs +++ b/crates/revm/src/journaled_state.rs @@ -3,9 +3,9 @@ use crate::primitives::{ db::Database, hash_map::Entry, Account, Address, Bytecode, HashMap, HashSet, Log, SpecId::*, State, StorageSlot, TransientStorage, KECCAK_EMPTY, PRECOMPILE3, U256, }; -use alloc::vec::Vec; use core::mem; use revm_interpreter::primitives::SpecId; +use std::vec::Vec; /// JournalState is internal EVM state that is used to contain state and track changes to that state. /// It contains journal of changes that happened to state so that they can be reverted. diff --git a/crates/revm/src/lib.rs b/crates/revm/src/lib.rs index 2b2b161174..3dfa14a197 100644 --- a/crates/revm/src/lib.rs +++ b/crates/revm/src/lib.rs @@ -2,12 +2,12 @@ #![warn(rustdoc::all, unreachable_pub)] #![allow(rustdoc::bare_urls)] #![cfg_attr(not(test), warn(unused_crate_dependencies))] -#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![deny(unused_must_use, rust_2018_idioms)] #![cfg_attr(not(feature = "std"), no_std)] #[macro_use] -extern crate alloc; +#[cfg(not(feature = "std"))] +extern crate alloc as std; // Define modules. diff --git a/crates/revm/src/optimism/handler_register.rs b/crates/revm/src/optimism/handler_register.rs index d13073c0d3..08c50f7a28 100644 --- a/crates/revm/src/optimism/handler_register.rs +++ b/crates/revm/src/optimism/handler_register.rs @@ -13,8 +13,8 @@ use crate::{ }, Context, FrameResult, }; -use alloc::sync::Arc; use core::ops::Mul; +use std::sync::Arc; pub fn optimism_handle_register(handler: &mut EvmHandler<'_, EXT, DB>) { spec_to_generic!(handler.cfg.spec_id, {