Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions frame/ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ fp-evm = { workspace = true }
fp-rpc = { workspace = true }
fp-storage = { workspace = true }
pallet-evm = { workspace = true }
# Cumulus
cumulus-primitives-storage-weight-reclaim = { workspace = true, default-features = false }

[dev-dependencies]
hex = { workspace = true }
Expand Down Expand Up @@ -65,6 +67,7 @@ std = [
"fp-rpc/std",
"fp-storage/std",
"pallet-evm/std",
"cumulus-primitives-storage-weight-reclaim/std"
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
Expand Down
33 changes: 17 additions & 16 deletions frame/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ mod tests;
use alloc::{vec, vec::Vec};
pub use catch_exec_info::catch_exec_info;
use core::marker::PhantomData;
use cumulus_primitives_storage_weight_reclaim::get_proof_size;
pub use ethereum::{
AccessListItem, BlockV2 as Block, LegacyTransactionMessage, Log, ReceiptV3 as Receipt,
TransactionAction, TransactionV2 as Transaction,
Expand Down Expand Up @@ -393,16 +394,16 @@ pub mod pallet {
}

impl<T: Config> Pallet<T> {
pub fn transaction_weight(transaction_data: &TransactionData) -> (Option<Weight>, Option<u64>) {
match <T as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
pub fn transaction_pov(transaction_data: &TransactionData) -> (Option<Weight>, Option<u64>){
let weight_limit = <T as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
transaction_data.gas_limit.unique_saturated_into(),
true,
) {
weight_limit if weight_limit.proof_size() > 0 => (
Some(weight_limit),
Some(transaction_data.proof_size_base_cost()),
),
_ => (None, None),
);

if weight_limit.proof_size() > 0 {
(Some(weight_limit), get_proof_size())
} else {
(None, None)
}
}

Expand Down Expand Up @@ -528,7 +529,7 @@ impl<T: Config> Pallet<T> {
) -> TransactionValidity {
let transaction_data: TransactionData = transaction.into();
let transaction_nonce = transaction_data.nonce;
let (weight_limit, proof_size_base_cost) = Self::transaction_weight(&transaction_data);
let (weight_limit, proof_size_pre_execution) = Self::transaction_pov(&transaction_data);
let (base_fee, _) = T::FeeCalculator::min_gas_price();
let (who, _) = pallet_evm::Pallet::<T>::account_basic(&origin);

Expand All @@ -542,7 +543,7 @@ impl<T: Config> Pallet<T> {
},
transaction_data.clone().into(),
weight_limit,
proof_size_base_cost,
proof_size_pre_execution,
);
check_transaction
.validate_in_pool_for(&who)
Expand Down Expand Up @@ -769,7 +770,7 @@ impl<T: Config> Pallet<T> {
maybe_force_create_address: Option<H160>,
) -> Result<(Option<H160>, Option<H160>, CallOrCreateInfo), DispatchErrorWithPostInfo> {
let transaction_data: TransactionData = transaction.into();
let (weight_limit, proof_size_base_cost) = Self::transaction_weight(&transaction_data);
let (weight_limit, proof_size_pre_execution) = Self::transaction_pov(&transaction_data);
let is_transactional = true;
let validate = false;

Expand Down Expand Up @@ -848,7 +849,7 @@ impl<T: Config> Pallet<T> {
is_transactional,
validate,
weight_limit,
proof_size_base_cost,
proof_size_pre_execution,
config.as_ref().unwrap_or_else(|| T::config()),
) {
Ok(res) => res,
Expand Down Expand Up @@ -879,7 +880,7 @@ impl<T: Config> Pallet<T> {
is_transactional,
validate,
weight_limit,
proof_size_base_cost,
proof_size_pre_execution,
config.as_ref().unwrap_or_else(|| T::config()),
force_address,
) {
Expand Down Expand Up @@ -907,7 +908,7 @@ impl<T: Config> Pallet<T> {
is_transactional,
validate,
weight_limit,
proof_size_base_cost,
proof_size_pre_execution,
config.as_ref().unwrap_or_else(|| T::config()),
) {
Ok(res) => res,
Expand Down Expand Up @@ -937,7 +938,7 @@ impl<T: Config> Pallet<T> {
transaction: &Transaction,
) -> Result<(), TransactionValidityError> {
let transaction_data: TransactionData = transaction.into();
let (weight_limit, proof_size_base_cost) = Self::transaction_weight(&transaction_data);
let (weight_limit, proof_size_pre_execution) = Self::transaction_pov(&transaction_data);
let (base_fee, _) = T::FeeCalculator::min_gas_price();
let (who, _) = pallet_evm::Pallet::<T>::account_basic(&origin);

Expand All @@ -951,7 +952,7 @@ impl<T: Config> Pallet<T> {
},
transaction_data.into(),
weight_limit,
proof_size_base_cost,
proof_size_pre_execution,
);
check_transaction
.validate_in_block_for(&who)
Expand Down
2 changes: 1 addition & 1 deletion frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ pub mod pallet {
fn on_initialize(_: BlockNumberFor<T>) -> Weight {
let mut total_weight = Weight::zero();

// Do dummy read to populate the pov with the intermediates nodes,
// Populate the pov with the intermediates nodes,
// only when proof size recording is enabled.
if let Some(pov_before) = get_proof_size() {
const ZERO_ACCOUNT: H160 = H160::zero();
Expand Down
10 changes: 5 additions & 5 deletions frame/evm/src/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub trait Runner<T: Config> {
access_list: Vec<(H160, Vec<H256>)>,
is_transactional: bool,
weight_limit: Option<Weight>,
proof_size_base_cost: Option<u64>,
proof_size_pre_execution: Option<u64>,
evm_config: &evm::Config,
) -> Result<(), RunnerError<Self::Error>>;

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

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

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

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