Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fmt and stable rust
  • Loading branch information
rakita committed Feb 21, 2024
commit e199a390f6ab31e24fa847c2638c322f15d3d52f
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@clippy
- uses: dtolnay/rust-toolchain@stable
- run: cargo clippy --workspace --all-targets --all-features
env:
RUSTFLAGS: -Dwarnings
Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/inner_models.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub use crate::primitives::CreateScheme;
use crate::primitives::{Address, Bytes, TransactTo, TxEnv, U256};
use std::boxed::Box;
use core::ops::Range;
use std::boxed::Box;

/// Inputs for a call.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/instructions/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use crate::{
CallContext, CallInputs, CallScheme, CreateInputs, CreateScheme, Host, InstructionResult,
Transfer, MAX_INITCODE_SIZE,
};
use std::{boxed::Box, vec::Vec};
use core::cmp::min;
use revm_primitives::BLOCK_HASH_HISTORY;
use std::{boxed::Box, vec::Vec};

pub fn balance<H: Host, SPEC: Spec>(interpreter: &mut Interpreter, host: &mut H) {
pop_address!(interpreter, address);
Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/instructions/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::{
primitives::{Spec, SpecId},
Host, Interpreter,
};
use std::boxed::Box;
use core::fmt;
use std::boxed::Box;

/// EVM opcode function signature.
pub type Instruction<H> = fn(&mut Interpreter, &mut H);
Expand Down
4 changes: 2 additions & 2 deletions crates/interpreter/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ pub use contract::Contract;
pub use shared_memory::{next_multiple_of_32, SharedMemory};
pub use stack::{Stack, STACK_LIMIT};

use std::borrow::ToOwned;
use crate::{
primitives::Bytes, push, push_b256, return_ok, return_revert, CallInputs, CallOutcome,
CreateInputs, CreateOutcome, Gas, Host, InstructionResult,
};
use std::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;

Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/interpreter/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::primitives::{
bitvec::prelude::{bitvec, BitVec, Lsb0},
keccak256, Bytecode, BytecodeState, Bytes, JumpMap, B256, KECCAK_EMPTY,
};
use std::sync::Arc;
use core::fmt;
use std::sync::Arc;

/// Perform bytecode analysis.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/interpreter/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::{
primitives::{B256, U256},
InstructionResult,
};
use std::vec::Vec;
use core::fmt;
use std::vec::Vec;

/// EVM interpreter stack limit.
pub const STACK_LIMIT: usize = 1024;
Expand Down
2 changes: 1 addition & 1 deletion crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ mod modexp;
mod secp256k1;
pub mod utilities;

use std::{boxed::Box, vec::Vec};
use core::{fmt, hash::Hash};
use once_cell::race::OnceBox;
#[doc(hidden)]
Expand All @@ -30,6 +29,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
Expand Down
2 changes: 1 addition & 1 deletion crates/precompile/src/modexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 std::vec::Vec;
use revm_primitives::hex;
use std::vec::Vec;

struct Test {
input: &'static str,
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/bytecode.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{hex, keccak256, Bytes, B256, KECCAK_EMPTY};
use std::{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)]
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/db/components/block_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
//! it is used inside [`crate::db::DatabaseComponents`]

use crate::{B256, U256};
use std::sync::Arc;
use auto_impl::auto_impl;
use core::ops::Deref;
use std::sync::Arc;

#[auto_impl(&mut, Box)]
pub trait BlockHash {
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/db/components/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
//! it is used inside [`crate::db::DatabaseComponents`]

use crate::{AccountInfo, Address, Bytecode, B256, U256};
use std::sync::Arc;
use auto_impl::auto_impl;
use core::ops::Deref;
use std::sync::Arc;

#[auto_impl(&mut, Box)]
pub trait State {
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/env/handler_cfg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{BlockEnv, CfgEnv, Env, SpecId, TxEnv};
use std::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
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/kzg/env_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use super::{
trusted_setup_points::{G1_POINTS, G2_POINTS},
KzgSettings,
};
use std::{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.
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/kzg/trusted_setup_points.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::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;
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/result.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{Address, Bytes, Log, State, U256};
use std::{boxed::Box, string::String, vec::Vec};
use core::fmt;
use std::{boxed::Box, string::String, vec::Vec};

/// Result of EVM execution.
pub type EVMResult<DBError> = EVMResultGeneric<ResultAndState, DBError>;
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::{
},
Context, ContextWithHandlerCfg, Evm, Handler,
};
use std::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
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db/emptydb.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::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<Infallible>;
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db/in_memory_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::primitives::{
U256,
};
use crate::Database;
use std::vec::Vec;
use core::convert::Infallible;
use std::vec::Vec;

/// A [Database] implementation that stores all state changes in memory.
pub type InMemoryDB = CacheDB<EmptyDB>;
Expand Down
8 changes: 4 additions & 4 deletions crates/revm/src/db/states/bundle_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ use super::{
reverts::{AccountInfoRevert, Reverts},
AccountRevert, AccountStatus, BundleAccount, PlainStateReverts, RevertToSlot, TransitionState,
};
use std::{
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)]
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db/states/cache.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::{
plain_account::PlainStorage, transition_account::TransitionAccount, CacheAccount, PlainAccount,
};
use std::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.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db/states/changes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::RevertToSlot;
use std::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
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db/states/reverts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use super::{
changes::PlainStorageRevert, AccountStatus, BundleAccount, PlainStateReverts,
StorageWithOriginalValues,
};
use std::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)]
Expand Down
8 changes: 4 additions & 4 deletions crates/revm/src/db/states/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ use super::{
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 std::{
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,
};

/// Database boxed with a lifetime and Send.
pub type DBBox<'a, E> = Box<dyn Database<Error = E> + Send + 'a>;
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db/states/state_builder.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::{cache::CacheState, state::DBBox, BundleState, State, TransitionState};
use crate::db::EmptyDB;
use std::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)]
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db/states/transition_state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::TransitionAccount;
use std::vec::Vec;
use revm_interpreter::primitives::{hash_map::Entry, Address, HashMap};
use std::vec::Vec;

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TransitionState {
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use crate::{
},
Context, ContextWithHandlerCfg, Frame, FrameOrResult, FrameResult,
};
use std::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;
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use crate::{
primitives::{Address, Output},
JournalCheckpoint,
};
use std::boxed::Box;
use core::ops::Range;
use revm_interpreter::{CallOutcome, CreateOutcome, Gas, InstructionResult, InterpreterResult};
use std::boxed::Box;

/// Call CallStackFrame.
#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use crate::{
primitives::{db::Database, spec_to_generic, HandlerCfg, Spec, SpecId},
Evm,
};
use std::vec::Vec;
use register::{EvmHandler, HandleRegisters};
use std::vec::Vec;

use self::register::{HandleRegister, HandleRegisterBox};

Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/handler/handle_types/pre_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
primitives::{db::Database, EVMError, EVMResultGeneric, Spec},
Context,
};
use std::sync::Arc;
use revm_precompile::Precompiles;
use std::sync::Arc;

/// Loads precompiles into Evm
pub type LoadPrecompilesHandle<'a> = Arc<dyn Fn() -> Precompiles + 'a>;
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/journaled_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 std::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.
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/optimism/handler_register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use crate::{
},
Context, FrameResult,
};
use std::sync::Arc;
use core::ops::Mul;
use std::sync::Arc;

pub fn optimism_handle_register<DB: Database, EXT>(handler: &mut EvmHandler<'_, EXT, DB>) {
spec_to_generic!(handler.cfg.spec_id, {
Expand Down