diff --git a/crates/primitives/src/precompile.rs b/crates/primitives/src/precompile.rs index 58f7cfe953..22a7839021 100644 --- a/crates/primitives/src/precompile.rs +++ b/crates/primitives/src/precompile.rs @@ -30,13 +30,13 @@ pub type EnvPrecompileFn = fn(&Bytes, u64, env: &Env) -> PrecompileResult; /// Stateful precompile trait. It is used to create /// a arc precompile Precompile::Stateful. pub trait StatefulPrecompile: Sync + Send { - fn call(&self, bytes: &Bytes, gas_price: u64, env: &Env) -> PrecompileResult; + fn call(&self, bytes: &Bytes, gas_limit: u64, env: &Env) -> PrecompileResult; } /// Mutable stateful precompile trait. It is used to create /// a boxed precompile in Precompile::StatefulMut. pub trait StatefulPrecompileMut: DynClone + Send + Sync { - fn call_mut(&mut self, bytes: &Bytes, gas_price: u64, env: &Env) -> PrecompileResult; + fn call_mut(&mut self, bytes: &Bytes, gas_limit: u64, env: &Env) -> PrecompileResult; } dyn_clone::clone_trait_object!(StatefulPrecompileMut); @@ -109,23 +109,23 @@ impl Precompile { } /// Call the precompile with the given input and gas limit and return the result. - pub fn call(&mut self, bytes: &Bytes, gas_price: u64, env: &Env) -> PrecompileResult { + pub fn call(&mut self, bytes: &Bytes, gas_limit: u64, env: &Env) -> PrecompileResult { match *self { - Precompile::Standard(p) => p(bytes, gas_price), - Precompile::Env(p) => p(bytes, gas_price, env), - Precompile::Stateful(ref p) => p.call(bytes, gas_price, env), - Precompile::StatefulMut(ref mut p) => p.call_mut(bytes, gas_price, env), + Precompile::Standard(p) => p(bytes, gas_limit), + Precompile::Env(p) => p(bytes, gas_limit, env), + Precompile::Stateful(ref p) => p.call(bytes, gas_limit, env), + Precompile::StatefulMut(ref mut p) => p.call_mut(bytes, gas_limit, env), } } /// Call the precompile with the given input and gas limit and return the result. /// /// Returns an error if the precompile is mutable. - pub fn call_ref(&self, bytes: &Bytes, gas_price: u64, env: &Env) -> PrecompileResult { + pub fn call_ref(&self, bytes: &Bytes, gas_limit: u64, env: &Env) -> PrecompileResult { match *self { - Precompile::Standard(p) => p(bytes, gas_price), - Precompile::Env(p) => p(bytes, gas_price, env), - Precompile::Stateful(ref p) => p.call(bytes, gas_price, env), + Precompile::Standard(p) => p(bytes, gas_limit), + Precompile::Env(p) => p(bytes, gas_limit, env), + Precompile::Stateful(ref p) => p.call(bytes, gas_limit, env), Precompile::StatefulMut(_) => Err(PrecompileErrors::Fatal { msg: "call_ref on mutable stateful precompile".into(), }), @@ -233,7 +233,7 @@ mod test { fn call_mut( &mut self, _bytes: &Bytes, - _gas_price: u64, + _gas_limit: u64, _env: &Env, ) -> PrecompileResult { Err(PrecompileError::OutOfGas.into()) diff --git a/crates/revm/src/builder.rs b/crates/revm/src/builder.rs index c66b61f556..9fc89ebe65 100644 --- a/crates/revm/src/builder.rs +++ b/crates/revm/src/builder.rs @@ -612,7 +612,7 @@ mod test { fn call( &self, _input: &Bytes, - _gas_price: u64, + _gas_limit: u64, _context: &mut InnerEvmContext, ) -> PrecompileResult { Ok(PrecompileOutput::new(10, Bytes::new())) diff --git a/crates/revm/src/context/context_precompiles.rs b/crates/revm/src/context/context_precompiles.rs index a47cef7132..f674093535 100644 --- a/crates/revm/src/context/context_precompiles.rs +++ b/crates/revm/src/context/context_precompiles.rs @@ -119,15 +119,15 @@ impl ContextPrecompiles { &mut self, address: &Address, bytes: &Bytes, - gas_price: u64, + gas_limit: u64, evmctx: &mut InnerEvmContext, ) -> Option { Some(match self.inner { - PrecompilesCow::StaticRef(p) => p.get(address)?.call_ref(bytes, gas_price, &evmctx.env), + PrecompilesCow::StaticRef(p) => p.get(address)?.call_ref(bytes, gas_limit, &evmctx.env), PrecompilesCow::Owned(ref mut owned) => match owned.get_mut(address)? { - ContextPrecompile::Ordinary(p) => p.call(bytes, gas_price, &evmctx.env), - ContextPrecompile::ContextStateful(p) => p.call(bytes, gas_price, evmctx), - ContextPrecompile::ContextStatefulMut(p) => p.call_mut(bytes, gas_price, evmctx), + ContextPrecompile::Ordinary(p) => p.call(bytes, gas_limit, &evmctx.env), + ContextPrecompile::ContextStateful(p) => p.call(bytes, gas_limit, evmctx), + ContextPrecompile::ContextStatefulMut(p) => p.call_mut(bytes, gas_limit, evmctx), }, }) } @@ -199,7 +199,7 @@ pub trait ContextStatefulPrecompile: Sync + Send { fn call( &self, bytes: &Bytes, - gas_price: u64, + gas_limit: u64, evmctx: &mut InnerEvmContext, ) -> PrecompileResult; } @@ -210,7 +210,7 @@ pub trait ContextStatefulPrecompileMut: DynClone + Send + Sync { fn call_mut( &mut self, bytes: &Bytes, - gas_price: u64, + gas_limit: u64, evmctx: &mut InnerEvmContext, ) -> PrecompileResult; } diff --git a/documentation/src/crates/revm/builder.md b/documentation/src/crates/revm/builder.md index 2414bb8964..c7ecefd211 100644 --- a/documentation/src/crates/revm/builder.md +++ b/documentation/src/crates/revm/builder.md @@ -125,7 +125,7 @@ impl ContextStatefulPrecompile, ()> for CustomPrecompile { fn call( &self, _input: &Bytes, - _gas_price: u64, + _gas_limit: u64, _context: &mut EvmContext, _extctx: &mut (), ) -> PrecompileResult {