diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f38feb1f2..4767419bf 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,22 +13,32 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Rustfmt run: cargo fmt --all -- --check + - name: clippy + run: cargo clippy --workspace -- -D warnings + - name: clippy no-std + run: cargo clippy --workspace --no-default-features --all-targets -- -D warnings + - name: clippy with features + run: cargo clippy --workspace --all-features --all-targets -- -D warnings build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Build run: cargo build --verbose + - name: Build no-std + run: cargo build --no-default-features + - name: Build all-features + run: cargo build --all-features - name: Run tests run: cargo test --verbose jsontests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: path: jsontests/res/ethtests repository: ethereum/tests diff --git a/interpreter/src/call_create.rs b/interpreter/src/call_create.rs index 3c6825bc1..784bc8bfa 100644 --- a/interpreter/src/call_create.rs +++ b/interpreter/src/call_create.rs @@ -5,6 +5,7 @@ use crate::{ Context, ExitError, ExitException, ExitResult, Machine, Memory, Opcode, RuntimeBackend, RuntimeState, Transfer, }; +use alloc::vec::Vec; use core::cmp::{max, min}; use primitive_types::{H160, H256, U256}; use sha3::{Digest, Keccak256}; @@ -31,7 +32,7 @@ pub enum CreateScheme { impl CreateScheme { pub fn address(&self, handler: &H) -> H160 { match self { - CreateScheme::Create2 { + Self::Create2 { caller, code_hash, salt, @@ -43,7 +44,7 @@ impl CreateScheme { hasher.update(&code_hash[..]); H256::from_slice(hasher.finalize().as_slice()).into() } - CreateScheme::Legacy { caller } => { + Self::Legacy { caller } => { let nonce = handler.nonce(*caller); let mut stream = rlp::RlpStream::new_list(2); stream.append(caller); @@ -53,7 +54,7 @@ impl CreateScheme { } } - pub fn caller(&self) -> H160 { + pub const fn caller(&self) -> H160 { match self { Self::Create2 { caller, .. } => *caller, Self::Legacy { caller } => *caller, @@ -83,7 +84,7 @@ pub enum CallCreateTrapData { } impl CallCreateTrapData { - pub fn target_gas(&self) -> Option { + pub const fn target_gas(&self) -> Option { match self { Self::Call(CallTrapData { gas, .. }) => Some(*gas), Self::Create(_) => None, @@ -137,6 +138,7 @@ pub struct CallTrapData { } impl CallTrapData { + #[allow(clippy::too_many_arguments)] fn new_from_params + AsMut>( scheme: CallScheme, memory: &mut Memory, diff --git a/interpreter/src/error.rs b/interpreter/src/error.rs index bd5d6342f..4f45855fe 100644 --- a/interpreter/src/error.rs +++ b/interpreter/src/error.rs @@ -168,7 +168,7 @@ impl From for ExitResult { impl From for ExitError { fn from(s: ExitException) -> Self { - ExitError::Exception(s) + Self::Exception(s) } } @@ -203,6 +203,6 @@ impl From for ExitResult { impl From for ExitError { fn from(s: ExitFatal) -> Self { - ExitError::Fatal(s) + Self::Fatal(s) } } diff --git a/interpreter/src/eval/mod.rs b/interpreter/src/eval/mod.rs index 57ebbcd22..fcbc5272c 100644 --- a/interpreter/src/eval/mod.rs +++ b/interpreter/src/eval/mod.rs @@ -51,7 +51,7 @@ where self.0.map(|f| { let fr = wrapper(f, current_opcode); if current_opcode != Opcode(255) { - current_opcode.0 = current_opcode.0 + 1; + current_opcode.0 += 1; } fr }), @@ -62,7 +62,7 @@ where impl Etable { /// Default core value for Etable. - pub const fn core() -> Etable { + pub const fn core() -> Self { let mut table = [eval_unknown as _; 256]; table[Opcode::STOP.as_usize()] = eval_stop as _; @@ -186,7 +186,7 @@ impl, H: RuntimeEnvironment + RuntimeBackend, Tr: CallCre Etable { /// Runtime Etable. - pub const fn runtime() -> Etable { + pub const fn runtime() -> Self { let mut table = Self::core(); table.0[Opcode::SHA3.as_usize()] = eval_sha3 as _; diff --git a/interpreter/src/lib.rs b/interpreter/src/lib.rs index 09cd00dc5..a032885c1 100644 --- a/interpreter/src/lib.rs +++ b/interpreter/src/lib.rs @@ -54,7 +54,7 @@ pub struct Machine { impl Machine { /// Return a reference of the program counter. - pub fn position(&self) -> usize { + pub const fn position(&self) -> usize { self.position } diff --git a/interpreter/src/memory.rs b/interpreter/src/memory.rs index c363a37ed..d5824563e 100644 --- a/interpreter/src/memory.rs +++ b/interpreter/src/memory.rs @@ -1,4 +1,5 @@ use crate::{ExitException, ExitFatal}; +use alloc::vec; use alloc::vec::Vec; use core::ops::{BitAnd, Not, Range}; use core::{cmp::min, mem}; @@ -24,7 +25,7 @@ impl Memory { } /// Memory limit. - pub fn limit(&self) -> usize { + pub const fn limit(&self) -> usize { self.limit } @@ -34,7 +35,7 @@ impl Memory { } /// Get the effective length. - pub fn effective_len(&self) -> U256 { + pub const fn effective_len(&self) -> U256 { self.effective_len } @@ -44,7 +45,7 @@ impl Memory { } /// Return the full memory. - pub fn data(&self) -> &Vec { + pub const fn data(&self) -> &Vec { &self.data } @@ -82,9 +83,7 @@ impl Memory { /// Resize to range. Used for return value. pub fn resize_to_range(&mut self, return_range: Range) { let ret = if return_range.start > U256::from(usize::MAX) { - let mut ret = Vec::new(); - ret.resize((return_range.end - return_range.start).as_usize(), 0); - ret + vec![0; (return_range.end - return_range.start).as_usize()] } else if return_range.end > U256::from(usize::MAX) { let mut ret = self.get( return_range.start.as_usize(), @@ -111,8 +110,7 @@ impl Memory { /// Value of `size` is considered trusted. If they're too large, /// the program can run out of memory, or it can overflow. pub fn get(&self, offset: usize, size: usize) -> Vec { - let mut ret = Vec::new(); - ret.resize(size, 0); + let mut ret = vec![0; size]; #[allow(clippy::needless_range_loop)] for index in 0..size { diff --git a/interpreter/src/runtime.rs b/interpreter/src/runtime.rs index a5cfbb3aa..e0d390436 100644 --- a/interpreter/src/runtime.rs +++ b/interpreter/src/runtime.rs @@ -1,5 +1,6 @@ use crate::{ExitError, Opcode}; use alloc::rc::Rc; +use alloc::vec::Vec; use primitive_types::{H160, H256, U256}; use sha3::{Digest, Keccak256}; @@ -15,13 +16,13 @@ pub struct RuntimeState { pub gas: U256, } -impl AsRef for RuntimeState { +impl AsRef for RuntimeState { fn as_ref(&self) -> &Self { self } } -impl AsMut for RuntimeState { +impl AsMut for RuntimeState { fn as_mut(&mut self) -> &mut Self { self } diff --git a/interpreter/src/stack.rs b/interpreter/src/stack.rs index 672cc42a2..d6921530a 100644 --- a/interpreter/src/stack.rs +++ b/interpreter/src/stack.rs @@ -48,7 +48,7 @@ macro_rules! impl_perform_popn_pushn { impl Stack { /// Create a new stack with given limit. - pub fn new(limit: usize) -> Self { + pub const fn new(limit: usize) -> Self { Self { data: Vec::new(), limit, @@ -57,7 +57,7 @@ impl Stack { #[inline] /// Stack limit. - pub fn limit(&self) -> usize { + pub const fn limit(&self) -> usize { self.limit } @@ -75,7 +75,7 @@ impl Stack { #[inline] /// Stack data. - pub fn data(&self) -> &Vec { + pub const fn data(&self) -> &Vec { &self.data } diff --git a/interpreter/src/utils.rs b/interpreter/src/utils.rs index 7b2320c9e..ce1716fa2 100644 --- a/interpreter/src/utils.rs +++ b/interpreter/src/utils.rs @@ -46,7 +46,7 @@ pub struct I256(pub Sign, pub U256); impl I256 { /// Zero value of I256. - pub fn zero() -> I256 { + pub const fn zero() -> I256 { I256(Sign::Zero, U256::zero()) } /// Minimum value of I256. diff --git a/interpreter/tests/usability.rs b/interpreter/tests/usability.rs index 181bd2044..0ac85d1b7 100644 --- a/interpreter/tests/usability.rs +++ b/interpreter/tests/usability.rs @@ -11,8 +11,8 @@ const RET1: &str = "000000000000000000000000000000000000000000000000000000000000 #[test] fn etable_wrap() { - let code = hex::decode(&CODE1).unwrap(); - let data = hex::decode(&DATA1).unwrap(); + let code = hex::decode(CODE1).unwrap(); + let data = hex::decode(DATA1).unwrap(); let wrapped_etable = Etable::<_, _, Opcode>::core().wrap(|f, opcode_t| { move |machine, handle, opcode, position| { @@ -24,14 +24,15 @@ fn etable_wrap() { let mut vm = Machine::new(Rc::new(code), Rc::new(data), 1024, 10000, ()); let result = vm.run(&mut (), &wrapped_etable); - assert_eq!(result, Capture::Exit(Ok(ExitSucceed::Returned.into()))); - assert_eq!(vm.retval, hex::decode(&RET1).unwrap()); + assert_eq!(result, Capture::Exit(Ok(ExitSucceed::Returned))); + assert_eq!(vm.retval, hex::decode(RET1).unwrap()); } #[test] +#[allow(clippy::type_complexity)] fn etable_wrap2() { - let code = hex::decode(&CODE1).unwrap(); - let data = hex::decode(&DATA1).unwrap(); + let code = hex::decode(CODE1).unwrap(); + let data = hex::decode(DATA1).unwrap(); let wrapped_etable = Etable::core().wrap( |f, opcode_t| -> Box, &mut (), Opcode, usize) -> Control> { @@ -87,7 +88,7 @@ impl RuntimeEnvironment for UnimplementedHandler { } } -impl<'a> RuntimeBaseBackend for UnimplementedHandler { +impl RuntimeBaseBackend for UnimplementedHandler { fn balance(&self, _address: H160) -> U256 { unimplemented!() } @@ -113,7 +114,7 @@ impl<'a> RuntimeBaseBackend for UnimplementedHandler { } } -impl<'a> RuntimeBackend for UnimplementedHandler { +impl RuntimeBackend for UnimplementedHandler { fn original_storage(&self, _address: H160, _index: H256) -> H256 { unimplemented!() } @@ -167,8 +168,8 @@ static RUNTIME_ETABLE: Etable = Etab #[test] fn etable_runtime() { - let code = hex::decode(&CODE1).unwrap(); - let data = hex::decode(&DATA1).unwrap(); + let code = hex::decode(CODE1).unwrap(); + let data = hex::decode(DATA1).unwrap(); let mut handler = UnimplementedHandler; let mut vm = Machine::new( @@ -193,6 +194,6 @@ fn etable_runtime() { ); let res = vm.run(&mut handler, &RUNTIME_ETABLE).exit().unwrap(); - assert_eq!(res, Ok(ExitSucceed::Returned.into())); - assert_eq!(vm.retval, hex::decode(&RET1).unwrap()); + assert_eq!(res, Ok(ExitSucceed::Returned)); + assert_eq!(vm.retval, hex::decode(RET1).unwrap()); } diff --git a/jsontests/src/error.rs b/jsontests/src/error.rs index e10e31b33..125f07d26 100644 --- a/jsontests/src/error.rs +++ b/jsontests/src/error.rs @@ -1,3 +1,4 @@ +#![allow(clippy::upper_case_acronyms)] use thiserror::Error; #[derive(Error, Debug)] diff --git a/jsontests/src/main.rs b/jsontests/src/main.rs index 88cd5228a..d733c6908 100644 --- a/jsontests/src/main.rs +++ b/jsontests/src/main.rs @@ -48,7 +48,7 @@ fn run_file(filename: &str, debug: bool) -> Result<(), Error> { } } if debug { - println!(""); + println!(); } } } @@ -57,14 +57,14 @@ fn run_file(filename: &str, debug: bool) -> Result<(), Error> { } fn run_single(filename: &str, debug: bool) -> Result<(), Error> { - if fs::metadata(&filename)?.is_dir() { - for filename in fs::read_dir(&filename)? { + if fs::metadata(filename)?.is_dir() { + for filename in fs::read_dir(filename)? { let filepath = filename?.path(); let filename = filepath.to_str().ok_or(Error::NonUtf8Filename)?; run_file(filename, debug)?; } } else { - run_file(&filename, debug)?; + run_file(filename, debug)?; } Ok(()) diff --git a/jsontests/src/types.rs b/jsontests/src/types.rs index 0d3d317dc..bdeda8cf5 100644 --- a/jsontests/src/types.rs +++ b/jsontests/src/types.rs @@ -26,7 +26,7 @@ impl TestMulti { tests.push(Test { info: self.info.clone(), env: self.env.clone(), - fork: fork.clone(), + fork: *fork, index, post: post_state.clone(), pre: self.pre.clone(), diff --git a/precompile/src/modexp.rs b/precompile/src/modexp.rs index d002da153..d1d1f6fc9 100644 --- a/precompile/src/modexp.rs +++ b/precompile/src/modexp.rs @@ -179,6 +179,7 @@ impl PurePrecompile for Modexp { // always true except in the case of zero-length modulus, which leads to // output of length and value 1. + #[allow(clippy::comparison_chain)] if bytes.len() == mod_len { (ExitSucceed::Returned.into(), bytes.to_vec()) } else if bytes.len() < mod_len { diff --git a/precompile/src/simple.rs b/precompile/src/simple.rs index 114edfc4c..d2efae35f 100644 --- a/precompile/src/simple.rs +++ b/precompile/src/simple.rs @@ -65,7 +65,7 @@ impl PurePrecompile for Sha256 { ))))); let mut ret = [0u8; 32]; - let hash = ripemd::Ripemd160::digest(&input[..]); + let hash = ripemd::Ripemd160::digest(input); ret[12..32].copy_from_slice(&hash); (ExitSucceed::Returned.into(), ret.to_vec()) @@ -89,7 +89,7 @@ impl PurePrecompile for Ripemd160 { COST_WORD ))))); - let hash = sha2::Sha256::digest(&input[..]); + let hash = sha2::Sha256::digest(input); (ExitSucceed::Returned.into(), hash.to_vec()) } diff --git a/src/call_stack.rs b/src/call_stack.rs index 00a1c8d73..72a23a9fb 100644 --- a/src/call_stack.rs +++ b/src/call_stack.rs @@ -1,4 +1,5 @@ use crate::{Capture, ExitError, ExitFatal, ExitResult, Invoker, InvokerControl, InvokerMachine}; +use alloc::vec::Vec; use core::convert::Infallible; struct Substack { @@ -37,7 +38,7 @@ where backend: &'backend mut H, invoker: &'invoker I, ) -> Self { - let call_stack = Self { + Self { stack: Vec::new(), last: Some(LastSubstack { machine, @@ -46,11 +47,10 @@ where initial_depth, backend, invoker, - }; - - call_stack + } } + #[allow(clippy::type_complexity)] pub fn run(&mut self) -> Capture, I::Interrupt> { loop { let step_ret = self.step_run(); @@ -61,6 +61,7 @@ where } } + #[allow(clippy::type_complexity)] pub fn step( &mut self, ) -> Result<(), Capture, I::Interrupt>> { @@ -73,6 +74,7 @@ where }) } + #[allow(clippy::type_complexity)] pub fn step_run( &mut self, ) -> Result<(), Capture, I::Interrupt>> { @@ -82,6 +84,7 @@ where }) } + #[allow(clippy::type_complexity)] fn step_with( &mut self, fs: FS, @@ -93,7 +96,7 @@ where self.last = match self.last.take() { None => { - step_ret = Some(Capture::Exit(Err(ExitFatal::AlreadyExited.into()))); + step_ret = Some(Capture::Exit(Err(ExitFatal::AlreadyExited))); None } Some(LastSubstack { @@ -317,6 +320,7 @@ where }))) } + #[allow(clippy::type_complexity)] fn step_with( &mut self, fs: FS, @@ -390,6 +394,7 @@ where } /// Step the call stack, but run the interpreter inside. + #[allow(clippy::type_complexity)] pub fn step_run( &mut self, ) -> Result<(), Capture, I::Interrupt>> { @@ -397,6 +402,7 @@ where } /// Step the call stack, and step the interpreter inside. + #[allow(clippy::type_complexity)] pub fn step( &mut self, ) -> Result<(), Capture, I::Interrupt>> { @@ -432,45 +438,37 @@ where I: Invoker, { fn drop(&mut self) { - if let Some(state) = self.0.take() { - match state { - HeapTransactState::Running { - mut call_stack, - transact_invoke, - } => { - if let Some(mut last) = call_stack.last.take() { - loop { - if let Some(mut parent) = call_stack.stack.pop() { - let last_machine = last.machine.deconstruct(); - let _ = call_stack.invoker.exit_substack( - ExitFatal::Unfinished.into(), - last_machine, - parent.invoke, - &mut parent.machine, - call_stack.backend, - ); - - last = LastSubstack { - machine: parent.machine, - status: LastSubstackStatus::Exited(Capture::Exit( - ExitFatal::Unfinished.into(), - )), - }; - } else { - break; - } - } + if let Some(HeapTransactState::Running { + mut call_stack, + transact_invoke, + }) = self.0.take() + { + if let Some(mut last) = call_stack.last.take() { + while let Some(mut parent) = call_stack.stack.pop() { + let last_machine = last.machine.deconstruct(); + let _ = call_stack.invoker.exit_substack( + ExitFatal::Unfinished.into(), + last_machine, + parent.invoke, + &mut parent.machine, + call_stack.backend, + ); - let last_machine = last.machine.deconstruct(); - let _ = call_stack.invoker.finalize_transact( - &transact_invoke, + last = LastSubstack { + machine: parent.machine, + status: LastSubstackStatus::Exited(Capture::Exit( ExitFatal::Unfinished.into(), - last_machine, - call_stack.backend, - ); - } + )), + }; } - _ => (), + + let last_machine = last.machine.deconstruct(); + let _ = call_stack.invoker.finalize_transact( + &transact_invoke, + ExitFatal::Unfinished.into(), + last_machine, + call_stack.backend, + ); } } } diff --git a/src/color.rs b/src/color.rs index 9721ef492..d5e0fb153 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,6 +1,7 @@ use crate::{ Capture, Control, Etable, ExitResult, Gasometer, InvokerMachine, Machine, Opcode, RuntimeState, }; +use alloc::vec::Vec; /// # Colored machine. /// @@ -93,12 +94,12 @@ where is_static: bool, handler: &mut H, ) -> Result<(), Capture> { - match gasometer.record_step(&machine, is_static, handler) { + match gasometer.record_step(machine, is_static, handler) { Ok(()) => { - machine.state.as_mut().gas = gasometer.gas().into(); + machine.state.as_mut().gas = gasometer.gas(); machine.step(handler, self) } - Err(e) => return Err(Capture::Exit(Err(e))), + Err(e) => Err(Capture::Exit(Err(e))), } } @@ -110,9 +111,9 @@ where handler: &mut H, ) -> Capture { loop { - match gasometer.record_stepn(&machine, is_static, handler) { + match gasometer.record_stepn(machine, is_static, handler) { Ok(stepn) => { - machine.state.as_mut().gas = gasometer.gas().into(); + machine.state.as_mut().gas = gasometer.gas(); match machine.stepn(stepn, handler, self) { Ok(()) => (), Err(c) => return c, diff --git a/src/invoker.rs b/src/invoker.rs index d3d5d7587..9ae829bef 100644 --- a/src/invoker.rs +++ b/src/invoker.rs @@ -45,6 +45,7 @@ pub trait Invoker { type SubstackInvoke; /// Create a new transaction with the given transaction arguments. + #[allow(clippy::type_complexity)] fn new_transact( &self, args: Self::TransactArgs, @@ -73,6 +74,7 @@ pub trait Invoker { ) -> Result; /// Enter a sub-layer call stack. + #[allow(clippy::type_complexity)] fn enter_substack( &self, trap: Tr, diff --git a/src/standard/gasometer/mod.rs b/src/standard/gasometer/mod.rs index 47c3d9512..d3ac5eb13 100644 --- a/src/standard/gasometer/mod.rs +++ b/src/standard/gasometer/mod.rs @@ -7,6 +7,7 @@ use crate::{ ExitError, ExitException, ExitFatal, Gasometer as GasometerT, Machine, MergeStrategy, Opcode, RuntimeBackend, RuntimeState, Stack, StaticGasometer, }; +use alloc::vec::Vec; use core::cmp::{max, min}; use primitive_types::{H160, H256, U256}; @@ -16,7 +17,7 @@ pub trait TransactGasometer<'config, S: AsRef>: Sized { fn new_transact_call( gas_limit: U256, data: &[u8], - access_list: &Vec<(H160, Vec)>, + access_list: &[(H160, Vec)], config: &'config Config, ) -> Result; @@ -24,7 +25,7 @@ pub trait TransactGasometer<'config, S: AsRef>: Sized { fn new_transact_create( gas_limit: U256, code: &[u8], - access_list: &Vec<(H160, Vec)>, + access_list: &[(H160, Vec)], config: &'config Config, ) -> Result; @@ -131,7 +132,7 @@ impl<'config, S: AsRef> TransactGasometer<'config, S> for Gasomete fn new_transact_call( gas_limit: U256, data: &[u8], - access_list: &Vec<(H160, Vec)>, + access_list: &[(H160, Vec)], config: &'config Config, ) -> Result { let gas_limit = if gas_limit > U256::from(u64::MAX) { @@ -150,7 +151,7 @@ impl<'config, S: AsRef> TransactGasometer<'config, S> for Gasomete fn new_transact_create( gas_limit: U256, code: &[u8], - access_list: &Vec<(H160, Vec)>, + access_list: &[(H160, Vec)], config: &'config Config, ) -> Result { let gas_limit = if gas_limit > U256::from(u64::MAX) { @@ -878,7 +879,7 @@ impl TransactionCost { } pub fn cost(&self, config: &Config) -> u64 { - let gas_cost = match self { + match self { TransactionCost::Call { zero_data_len, non_zero_data_len, @@ -912,9 +913,7 @@ impl TransactionCost { cost } - }; - - gas_cost + } } } diff --git a/src/standard/invoker/mod.rs b/src/standard/invoker/mod.rs index b0e8d5637..f677abfed 100644 --- a/src/standard/invoker/mod.rs +++ b/src/standard/invoker/mod.rs @@ -1,6 +1,7 @@ mod resolver; mod routines; +use alloc::vec::Vec; pub use resolver::{EtableResolver, PrecompileSet, Resolver}; use super::{Config, MergeableRuntimeState, TransactGasometer}; @@ -204,7 +205,7 @@ where Some(salt) => { let scheme = CreateScheme::Create2 { caller: *caller, - code_hash: H256::from_slice(Keccak256::digest(&init_code).as_slice()), + code_hash: H256::from_slice(Keccak256::digest(init_code).as_slice()), salt: *salt, }; scheme.address(handler) @@ -275,7 +276,7 @@ where context, transaction_context: Rc::new(transaction_context), retbuf: Vec::new(), - gas: U256::from(gas_limit), + gas: gas_limit, }), gasometer, handler, @@ -313,7 +314,7 @@ where context, transaction_context: Rc::new(transaction_context), retbuf: Vec::new(), - gas: U256::from(gas_limit), + gas: gas_limit, }), gasometer, handler, @@ -426,10 +427,8 @@ where let target_gas = trap_data.target_gas().unwrap_or(after_gas); let gas_limit = min(after_gas, target_gas); - let call_has_value = match &trap_data { - CallCreateTrapData::Call(call) if call.has_value() => true, - _ => false, - }; + let call_has_value = + matches!(&trap_data, CallCreateTrapData::Call(call) if call.has_value()); let is_static = if machine.is_static { true @@ -454,9 +453,9 @@ where context: call_trap_data.context.clone(), transaction_context, retbuf: Vec::new(), - gas: U256::from(gas_limit), + gas: gas_limit, }, - &machine, + machine, ); let target = call_trap_data.target; @@ -490,9 +489,9 @@ where }, transaction_context, retbuf: Vec::new(), - gas: U256::from(gas_limit), + gas: gas_limit, }, - &machine, + machine, ); Capture::Exit(routines::enter_create_substack( diff --git a/src/standard/invoker/resolver.rs b/src/standard/invoker/resolver.rs index ec738faab..93d4b4e22 100644 --- a/src/standard/invoker/resolver.rs +++ b/src/standard/invoker/resolver.rs @@ -5,6 +5,7 @@ use crate::{ Machine, Opcode, RuntimeBackend, RuntimeState, }; use alloc::rc::Rc; +use alloc::vec::Vec; use primitive_types::H160; /// A code resolver. @@ -18,6 +19,7 @@ pub trait Resolver { type Color: Color; /// Resolve a call (with the target code address). + #[allow(clippy::type_complexity)] fn resolve_call( &self, code_address: H160, @@ -32,6 +34,7 @@ pub trait Resolver { >; /// Resolve a create (with the init code). + #[allow(clippy::type_complexity)] fn resolve_create( &self, init_code: Vec, diff --git a/src/standard/invoker/routines.rs b/src/standard/invoker/routines.rs index 432c1beeb..c3b7763d5 100644 --- a/src/standard/invoker/routines.rs +++ b/src/standard/invoker/routines.rs @@ -5,19 +5,22 @@ use crate::{ MergeStrategy, Opcode, RuntimeBackend, RuntimeEnvironment, RuntimeState, StaticGasometer, TransactionalBackend, Transfer, }; +use alloc::vec::Vec; use primitive_types::{H160, U256}; +#[allow(clippy::type_complexity)] pub fn maybe_analyse_code<'config, S: AsRef, G: TransactGasometer<'config, S>, C>( result: &mut InvokerControl, (ExitResult, (S, G, Vec))>, ) { if let InvokerControl::Enter(machine) = result { - machine.gasometer.analyse_code(&machine.machine.code()) + machine.gasometer.analyse_code(machine.machine.code()) } } -pub fn make_enter_call_machine<'config, 'resolver, S, G, H, R, Tr>( - _config: &'config Config, - resolver: &'resolver R, +#[allow(clippy::too_many_arguments, clippy::type_complexity)] +pub fn make_enter_call_machine( + _config: &Config, + resolver: &R, code_address: H160, input: Vec, is_static: bool, @@ -41,9 +44,10 @@ where resolver.resolve_call(code_address, input, is_static, state, gasometer, handler) } -pub fn make_enter_create_machine<'config, 'resolver, S, G, H, R, Tr>( - config: &'config Config, - resolver: &'resolver R, +#[allow(clippy::type_complexity, clippy::too_many_arguments)] +pub fn make_enter_create_machine( + config: &Config, + resolver: &R, caller: H160, init_code: Vec, is_static: bool, @@ -84,9 +88,10 @@ where resolver.resolve_create(init_code, is_static, state, gasometer, handler) } -pub fn enter_call_substack<'config, 'resolver, S, G, H, R, Tr>( +#[allow(clippy::type_complexity, clippy::too_many_arguments)] +pub fn enter_call_substack<'config, S, G, H, R, Tr>( config: &'config Config, - resolver: &'resolver R, + resolver: &R, trap_data: CallTrapData, code_address: H160, is_static: bool, @@ -133,9 +138,10 @@ where } } -pub fn enter_create_substack<'config, 'resolver, S, G, H, R, Tr>( +#[allow(clippy::type_complexity, clippy::too_many_arguments)] +pub fn enter_create_substack<'config, S, G, H, R, Tr>( config: &'config Config, - resolver: &'resolver R, + resolver: &R, code: Vec, trap_data: CreateTrapData, is_static: bool, @@ -202,8 +208,8 @@ fn check_first_byte(config: &Config, code: &[u8]) -> Result<(), ExitError> { Ok(()) } -pub fn deploy_create_code<'config, S, G, H>( - config: &'config Config, +pub fn deploy_create_code( + config: &Config, address: H160, retbuf: &Vec, gasometer: &mut G,