diff --git a/precompiles/src/evm/handle.rs b/precompiles/src/evm/handle.rs index d3d26bbe57..74254025f6 100644 --- a/precompiles/src/evm/handle.rs +++ b/precompiles/src/evm/handle.rs @@ -60,7 +60,7 @@ impl PrecompileHandleExt for T { ) -> Result<(), evm::ExitError> { self.record_cost(crate::prelude::RuntimeHelper::::db_read_gas_cost())?; // TODO: record ref time when precompile will be benchmarked - self.record_external_cost(None, Some(data_max_encoded_len as u64)) + self.record_external_cost(None, Some(data_max_encoded_len as u64), None) } /// Record cost of a log manualy. @@ -190,6 +190,7 @@ mod tests { &mut self, _ref_time: Option, _proof_size: Option, + _storage_growth: Option, ) -> Result<(), fp_evm::ExitError> { Ok(()) } diff --git a/precompiles/src/precompile_set.rs b/precompiles/src/precompile_set.rs index 2f9bb0816a..ebe2d11cfd 100644 --- a/precompiles/src/precompile_set.rs +++ b/precompiles/src/precompile_set.rs @@ -477,8 +477,10 @@ impl<'a, H: PrecompileHandle> PrecompileHandle for RestrictiveHandle<'a, H> { &mut self, ref_time: Option, proof_size: Option, + storage_growth: Option, ) -> Result<(), ExitError> { - self.handle.record_external_cost(ref_time, proof_size) + self.handle + .record_external_cost(ref_time, proof_size, storage_growth) } fn refund_external_cost(&mut self, ref_time: Option, proof_size: Option) { diff --git a/precompiles/src/substrate.rs b/precompiles/src/substrate.rs index a5c91447b7..7db249661d 100644 --- a/precompiles/src/substrate.rs +++ b/precompiles/src/substrate.rs @@ -59,9 +59,10 @@ where Runtime::RuntimeCall: Dispatchable + GetDispatchInfo, { #[inline(always)] - pub fn record_weight_v2_cost( + pub fn record_external_cost( handle: &mut impl PrecompileHandle, weight: Weight, + storage_growth: u64, ) -> Result<(), ExitError> { // Make sure there is enough gas. let remaining_gas = handle.remaining_gas(); @@ -72,7 +73,7 @@ where // Make sure there is enough remaining weight // TODO: record ref time when precompile will be benchmarked - handle.record_external_cost(None, Some(weight.proof_size())) + handle.record_external_cost(None, Some(weight.proof_size()), Some(storage_growth)) } #[inline(always)] @@ -102,6 +103,7 @@ where handle: &mut impl PrecompileHandle, origin: ::RuntimeOrigin, call: Call, + storage_growth: u64, ) -> Result where Runtime::RuntimeCall: From, @@ -109,7 +111,8 @@ where let call = Runtime::RuntimeCall::from(call); let dispatch_info = call.get_dispatch_info(); - Self::record_weight_v2_cost(handle, dispatch_info.weight).map_err(TryDispatchError::Evm)?; + Self::record_external_cost(handle, dispatch_info.weight, storage_growth) + .map_err(TryDispatchError::Evm)?; // Dispatch call. // It may be possible to not record gas cost if the call returns Pays::No. diff --git a/precompiles/src/testing/handle.rs b/precompiles/src/testing/handle.rs index f521954034..0e869700f2 100644 --- a/precompiles/src/testing/handle.rs +++ b/precompiles/src/testing/handle.rs @@ -208,6 +208,7 @@ impl PrecompileHandle for MockHandle { &mut self, _ref_time: Option, _proof_size: Option, + _storage_growth: Option, ) -> Result<(), ExitError> { Ok(()) } diff --git a/precompiles/tests-external/lib.rs b/precompiles/tests-external/lib.rs index bdf46e2932..994bc32de7 100644 --- a/precompiles/tests-external/lib.rs +++ b/precompiles/tests-external/lib.rs @@ -162,6 +162,7 @@ impl PrecompileHandle for MockPrecompileHandle { &mut self, _ref_time: Option, _proof_size: Option, + _storage_growth: Option, ) -> Result<(), fp_evm::ExitError> { Ok(()) } @@ -240,6 +241,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type FindAuthor = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + type GasLimitStorageGrowthRatio = (); type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; }