diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index d9f1131db8..e667341c92 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -353,7 +353,8 @@ pub mod pallet { } impl Pallet { - fn transaction_len(transaction: &Transaction) -> u64 { + /// The call wrapped in the extrinsic is part of the PoV, record this as a base cost for the size of the proof. + fn proof_size_base_cost(transaction: &Transaction) -> u64 { transaction .encode() .len() @@ -488,9 +489,10 @@ impl Pallet { transaction_data.gas_limit.unique_saturated_into(), true, ) { - weight_limit if weight_limit.proof_size() > 0 => { - (Some(weight_limit), Some(Self::transaction_len(transaction))) - } + weight_limit if weight_limit.proof_size() > 0 => ( + Some(weight_limit), + Some(Self::proof_size_base_cost(transaction)), + ), _ => (None, None), }; @@ -772,14 +774,15 @@ impl Pallet { let is_transactional = true; let validate = false; - let (transaction_len, weight_limit) = + let (proof_size_base_cost, weight_limit) = match ::GasWeightMapping::gas_to_weight( gas_limit.unique_saturated_into(), true, ) { - weight_limit if weight_limit.proof_size() > 0 => { - (Some(Self::transaction_len(transaction)), Some(weight_limit)) - } + weight_limit if weight_limit.proof_size() > 0 => ( + Some(Self::proof_size_base_cost(transaction)), + Some(weight_limit), + ), _ => (None, None), }; match action { @@ -797,7 +800,7 @@ impl Pallet { is_transactional, validate, weight_limit, - transaction_len, + proof_size_base_cost, config.as_ref().unwrap_or_else(|| T::config()), ) { Ok(res) => res, @@ -827,7 +830,7 @@ impl Pallet { is_transactional, validate, weight_limit, - transaction_len, + proof_size_base_cost, config.as_ref().unwrap_or_else(|| T::config()), ) { Ok(res) => res, @@ -865,9 +868,10 @@ impl Pallet { transaction_data.gas_limit.unique_saturated_into(), true, ) { - weight_limit if weight_limit.proof_size() > 0 => { - (Some(weight_limit), Some(Self::transaction_len(transaction))) - } + weight_limit if weight_limit.proof_size() > 0 => ( + Some(weight_limit), + Some(Self::proof_size_base_cost(transaction)), + ), _ => (None, None), }; diff --git a/frame/evm/src/runner/mod.rs b/frame/evm/src/runner/mod.rs index b23379690b..bda922d39c 100644 --- a/frame/evm/src/runner/mod.rs +++ b/frame/evm/src/runner/mod.rs @@ -43,7 +43,7 @@ pub trait Runner { access_list: Vec<(H160, Vec)>, is_transactional: bool, weight_limit: Option, - transaction_len: Option, + proof_size_base_cost: Option, evm_config: &evm::Config, ) -> Result<(), RunnerError>; @@ -60,7 +60,7 @@ pub trait Runner { is_transactional: bool, validate: bool, weight_limit: Option, - transaction_len: Option, + proof_size_base_cost: Option, config: &evm::Config, ) -> Result>; @@ -76,7 +76,7 @@ pub trait Runner { is_transactional: bool, validate: bool, weight_limit: Option, - transaction_len: Option, + proof_size_base_cost: Option, config: &evm::Config, ) -> Result>; @@ -93,7 +93,7 @@ pub trait Runner { is_transactional: bool, validate: bool, weight_limit: Option, - transaction_len: Option, + proof_size_base_cost: Option, config: &evm::Config, ) -> Result>; } diff --git a/primitives/evm/src/lib.rs b/primitives/evm/src/lib.rs index 8f618c4b20..0ac7d81559 100644 --- a/primitives/evm/src/lib.rs +++ b/primitives/evm/src/lib.rs @@ -84,18 +84,18 @@ pub struct WeightInfo { impl WeightInfo { pub fn new_from_weight_limit( weight_limit: Option, - transaction_len: Option, + proof_size_base_cost: Option, ) -> Result, &'static str> { - Ok(match (weight_limit, transaction_len) { + Ok(match (weight_limit, proof_size_base_cost) { (None, _) => None, - (Some(weight_limit), Some(transaction_len)) - if weight_limit.proof_size() >= transaction_len => + (Some(weight_limit), Some(proof_size_base_cost)) + if weight_limit.proof_size() >= proof_size_base_cost => { Some(WeightInfo { ref_time_limit: Some(weight_limit.ref_time()), proof_size_limit: Some(weight_limit.proof_size()), ref_time_usage: Some(0u64), - proof_size_usage: Some(transaction_len), + proof_size_usage: Some(proof_size_base_cost), }) } (Some(weight_limit), None) => Some(WeightInfo {