Skip to content

Commit

Permalink
Rename others transaction_len (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Jun 25, 2023
1 parent 406c6c7 commit 6102a1a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
30 changes: 17 additions & 13 deletions frame/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ pub mod pallet {
}

impl<T: Config> Pallet<T> {
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()
Expand Down Expand Up @@ -488,9 +489,10 @@ impl<T: Config> Pallet<T> {
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),
};

Expand Down Expand Up @@ -772,14 +774,15 @@ impl<T: Config> Pallet<T> {
let is_transactional = true;
let validate = false;

let (transaction_len, weight_limit) =
let (proof_size_base_cost, weight_limit) =
match <T as pallet_evm::Config>::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 {
Expand All @@ -797,7 +800,7 @@ impl<T: Config> Pallet<T> {
is_transactional,
validate,
weight_limit,
transaction_len,
proof_size_base_cost,
config.as_ref().unwrap_or_else(|| T::config()),
) {
Ok(res) => res,
Expand Down Expand Up @@ -827,7 +830,7 @@ impl<T: Config> Pallet<T> {
is_transactional,
validate,
weight_limit,
transaction_len,
proof_size_base_cost,
config.as_ref().unwrap_or_else(|| T::config()),
) {
Ok(res) => res,
Expand Down Expand Up @@ -865,9 +868,10 @@ impl<T: Config> Pallet<T> {
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),
};

Expand Down
8 changes: 4 additions & 4 deletions frame/evm/src/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub trait Runner<T: Config> {
access_list: Vec<(H160, Vec<H256>)>,
is_transactional: bool,
weight_limit: Option<Weight>,
transaction_len: Option<u64>,
proof_size_base_cost: Option<u64>,
evm_config: &evm::Config,
) -> Result<(), RunnerError<Self::Error>>;

Expand All @@ -60,7 +60,7 @@ pub trait Runner<T: Config> {
is_transactional: bool,
validate: bool,
weight_limit: Option<Weight>,
transaction_len: Option<u64>,
proof_size_base_cost: Option<u64>,
config: &evm::Config,
) -> Result<CallInfo, RunnerError<Self::Error>>;

Expand All @@ -76,7 +76,7 @@ pub trait Runner<T: Config> {
is_transactional: bool,
validate: bool,
weight_limit: Option<Weight>,
transaction_len: Option<u64>,
proof_size_base_cost: Option<u64>,
config: &evm::Config,
) -> Result<CreateInfo, RunnerError<Self::Error>>;

Expand All @@ -93,7 +93,7 @@ pub trait Runner<T: Config> {
is_transactional: bool,
validate: bool,
weight_limit: Option<Weight>,
transaction_len: Option<u64>,
proof_size_base_cost: Option<u64>,
config: &evm::Config,
) -> Result<CreateInfo, RunnerError<Self::Error>>;
}
10 changes: 5 additions & 5 deletions primitives/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ pub struct WeightInfo {
impl WeightInfo {
pub fn new_from_weight_limit(
weight_limit: Option<Weight>,
transaction_len: Option<u64>,
proof_size_base_cost: Option<u64>,
) -> Result<Option<Self>, &'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 {
Expand Down

0 comments on commit 6102a1a

Please sign in to comment.