Skip to content
Prev Previous commit
Next Next commit
fmt,clippy,sort
  • Loading branch information
rakita committed Feb 20, 2022
commit 990d76dbc6e0f8a9b96e8fb7bd7b8c1ab597410c
6 changes: 2 additions & 4 deletions crates/revm/src/evm_impl.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use crate::{
db::Database,
gas,
interpreter,
Gas,
gas, interpreter,
interpreter::{Contract, Interpreter},
models::SelfDestructResult,
return_ok,
subroutine::{Account, State, SubRoutine},
CallContext, CreateScheme, Env, Inspector, Log, Return, Spec,
CallContext, CreateScheme, Env, Gas, Inspector, Log, Return, Spec,
SpecId::*,
TransactOut, TransactTo, Transfer, KECCAK_EMPTY,
};
Expand Down
6 changes: 2 additions & 4 deletions crates/revm/src/gas/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pub fn create2_cost(len: usize) -> Option<u64> {
Some(gas)
}


fn log2floor(value: U256) -> u64 {
assert!(!value.is_zero());
let mut l: u64 = 256;
Expand Down Expand Up @@ -92,9 +91,8 @@ pub fn exp_cost<SPEC: Spec>(power: U256) -> Option<u64> {
} else {
10
}); // EIP-160: EXP cost increase
let gas = U256::from(EXP).checked_add(
gas_byte.checked_mul(U256::from(log2floor(power) / 8 + 1))?,
)?;
let gas = U256::from(EXP)
.checked_add(gas_byte.checked_mul(U256::from(log2floor(power) / 8 + 1))?)?;

if gas > U256::from(u64::MAX) {
return None;
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bytes::Bytes;
use primitive_types::{H160, U256};

use crate::{
evm_impl::EVMData, Gas, CallContext, CreateScheme, Database, Interpreter, Return, Transfer,
evm_impl::EVMData, CallContext, CreateScheme, Database, Gas, Interpreter, Return, Transfer,
};
use auto_impl::auto_impl;

Expand Down
6 changes: 1 addition & 5 deletions crates/revm/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ mod system;

pub use opcode::{OpCode, OPCODE_JUMPMAP};

use crate::{
interpreter::Interpreter,
Spec, SpecId::*,
CallScheme, Host,
};
use crate::{interpreter::Interpreter, CallScheme, Host, Spec, SpecId::*};
use core::ops::{BitAnd, BitOr, BitXor};
use primitive_types::U256;

Expand Down
4 changes: 2 additions & 2 deletions crates/revm/src/instructions/misc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{interpreter::Interpreter,gas, Return, Spec, SpecId::*};
use crate::{gas, interpreter::Interpreter, Return, Spec, SpecId::*};
use primitive_types::{H256, U256};

pub fn codesize(machine: &mut Interpreter) -> Return {
Expand Down Expand Up @@ -88,7 +88,7 @@ pub fn mload(machine: &mut Interpreter) -> Return {
memory_resize!(machine, index, 32);
push!(
machine,
U256::from_big_endian(machine.memory.get_slice(index, 32).as_ref())
U256::from_big_endian(machine.memory.get_slice(index, 32))
);
Return::Continue
}
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/instructions/system.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
interpreter::Interpreter,gas, return_ok, return_revert, CallContext, CallScheme, CreateScheme,
gas, interpreter::Interpreter, return_ok, return_revert, CallContext, CallScheme, CreateScheme,
Host, Return, Spec, Transfer,
};
// CallScheme, Capture, CallContext, CreateScheme, ,
Expand Down
8 changes: 4 additions & 4 deletions crates/revm/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ pub use memory::Memory;
pub use stack::Stack;

use crate::{
instructions::{eval, Return}, USE_GAS, Gas,
instructions::{eval, Return},
Gas, USE_GAS,
};
use crate::{Host, Spec};
use bytes::Bytes;
use core::ops::Range;
use crate::{Spec, Host};

pub const STACK_LIMIT: u64 = 1024;
pub const CALL_STACK_LIMIT: u64 = 1024;
Expand All @@ -35,7 +36,6 @@ pub struct Interpreter {
pub call_depth: u64,
}


impl Interpreter {
pub fn new<SPEC: Spec>(contract: Contract, gas_limit: u64, call_depth: u64) -> Self {
Self {
Expand Down Expand Up @@ -127,4 +127,4 @@ impl Interpreter {
))
}
}
}
}
4 changes: 2 additions & 2 deletions crates/revm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
pub mod db;
mod evm;
mod evm_impl;
pub(crate) mod gas;
mod inspector;
mod instructions;
mod interpreter;
mod models;
mod specification;
mod subroutine;
pub(crate) mod gas;

pub use evm_impl::{EVMData, Host};

pub type DummyStateDB = InMemoryDB;

pub use db::{Database, DatabaseCommit, InMemoryDB};
pub use evm::{new, EVM};
pub use gas::Gas;
pub use inspector::{Inspector, NoOpInspector, OverrideSpec};
pub use instructions::{
opcode::{self, spec_opcode_gas, OpCode, OPCODE_JUMPMAP},
Return,
};
pub use interpreter::Interpreter;
pub use gas::Gas;
pub use models::*;
pub use specification::*;
pub use subroutine::{Account, SubRoutine};
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub trait Spec: Sized {
}

mod spec_impl {
use super::{NotStaticSpec,Spec};
use super::{NotStaticSpec, Spec};

macro_rules! spec {
($spec_id:tt) => {
Expand Down