Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ parameter_types! {
pub const DepositPerChildTrieItem: Balance = deposit(1, 0) / 100;
pub const DepositPerByte: Balance = deposit(0, 1);
pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(1,2);
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(9, 10);
}

impl pallet_revive::Config for Runtime {
Expand Down
2 changes: 1 addition & 1 deletion cumulus/parachains/runtimes/testing/penpal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ parameter_types! {
pub const DepositPerChildTrieItem: Balance = 0;
pub const DepositPerByte: Balance = 0;
pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(1,2);
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(9, 10);
}

impl pallet_revive::Config for Runtime {
Expand Down
16 changes: 16 additions & 0 deletions prdoc/pr_10089.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
title: 'pallet_revive: Raise the MaxEthExtrinsicWeight'
doc:
- audience: Runtime User
description: |-
Fixes https://github.com/paritytech/contract-issues/issues/194

Factory extrinsics do need more weight. It is fine to raise them to almost the full max extrinsic weight since this is still lower than the block weight.

Also improving the error reporting during the dry run in case an extrinsic hits this limit. No more `OutOfGas` but a more descriptive error of how much it is overweight.
crates:
- name: pallet-revive
bump: major
- name: asset-hub-westend-runtime
bump: major
- name: penpal-runtime
bump: major
2 changes: 1 addition & 1 deletion substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ parameter_types! {
pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024);
pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(1,2);
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(9, 10);
}

impl pallet_contracts::Config for Runtime {
Expand Down
4 changes: 3 additions & 1 deletion substrate/frame/revive/src/evm/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub struct CallInfo<T: Config> {
pub fn create_call<T>(
tx: GenericTransaction,
signed_transaction: Option<(u32, Vec<u8>)>,
apply_weight_cap: bool,
) -> Result<CallInfo<T>, InvalidTransaction>
where
T: Config,
Expand Down Expand Up @@ -176,7 +177,8 @@ where

call.set_weight_limit(weight_limit);
let info = <T as Config>::FeeInfo::dispatch_info(&call);
let max_weight = <Pallet<T>>::evm_max_extrinsic_weight();
let max_weight =
if apply_weight_cap { <Pallet<T>>::evm_max_extrinsic_weight() } else { Weight::MAX };
let overweight_by = info.total_weight().saturating_sub(max_weight);
let capped_weight = weight_limit.saturating_sub(overweight_by);
call.set_weight_limit(capped_weight);
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/src/evm/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ pub trait EthExtra {

log::debug!(target: LOG_TARGET, "Decoded Ethereum transaction with signer: {signer_addr:?} nonce: {nonce:?}");
let call_info =
create_call::<Self::Config>(tx, Some((encoded_len as u32, payload.to_vec())))?;
create_call::<Self::Config>(tx, Some((encoded_len as u32, payload.to_vec())), true)?;
let storage_credit = <Self::Config as Config>::Currency::withdraw(
&signer,
call_info.storage_deposit,
Expand Down
12 changes: 8 additions & 4 deletions substrate/frame/revive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ pub mod pallet {
pub const DepositPerChildTrieItem: Balance = deposit(1, 0) / 100;
pub const DepositPerByte: Balance = deposit(0, 1);
pub const CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(0);
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(1, 2);
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(9, 10);
}

/// A type providing default configurations for this pallet in testing environment.
Expand Down Expand Up @@ -1653,7 +1653,7 @@ impl<T: Config> Pallet<T> {

// we need to parse the weight from the transaction so that it is run
// using the exact weight limit passed by the eth wallet
let mut call_info = create_call::<T>(tx, None)
let mut call_info = create_call::<T>(tx, None, false)
.map_err(|err| EthTransactError::Message(format!("Invalid call: {err:?}")))?;

// the dry-run might leave out certain fields
Expand Down Expand Up @@ -1827,10 +1827,14 @@ impl<T: Config> Pallet<T> {

log::debug!(target: LOG_TARGET, "\
dry_run_eth_transact: \
weight_limit={:?}: \
eth_gas={eth_gas:?})\
weight_limit={} \
total_weight={total_weight} \
max_weight={max_weight} \
weight_left={} \
eth_gas={eth_gas})\
",
dry_run.gas_required,
max_weight.saturating_sub(total_weight),

);
dry_run.eth_gas = eth_gas;
Expand Down
Loading