Skip to content

Commit 6c74e3f

Browse files
pallet_revive: Raise the MaxEthExtrinsicWeight (#10089)
Fixes paritytech/contract-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. --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 1f5cad2 commit 6c74e3f

File tree

7 files changed

+31
-9
lines changed

7 files changed

+31
-9
lines changed

cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ parameter_types! {
11751175
pub const DepositPerChildTrieItem: Balance = deposit(1, 0) / 100;
11761176
pub const DepositPerByte: Balance = deposit(0, 1);
11771177
pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
1178-
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(1,2);
1178+
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(9, 10);
11791179
}
11801180

11811181
impl pallet_revive::Config for Runtime {

cumulus/parachains/runtimes/testing/penpal/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ parameter_types! {
809809
pub const DepositPerChildTrieItem: Balance = 0;
810810
pub const DepositPerByte: Balance = 0;
811811
pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
812-
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(1,2);
812+
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(9, 10);
813813
}
814814

815815
impl pallet_revive::Config for Runtime {

prdoc/pr_10089.prdoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
title: 'pallet_revive: Raise the MaxEthExtrinsicWeight'
2+
doc:
3+
- audience: Runtime User
4+
description: |-
5+
Fixes https://github.com/paritytech/contract-issues/issues/194
6+
7+
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.
8+
9+
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.
10+
crates:
11+
- name: pallet-revive
12+
bump: major
13+
- name: asset-hub-westend-runtime
14+
bump: major
15+
- name: penpal-runtime
16+
bump: major

substrate/bin/node/runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ parameter_types! {
14661466
pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024);
14671467
pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
14681468
pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
1469-
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(1,2);
1469+
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(9, 10);
14701470
}
14711471

14721472
impl pallet_contracts::Config for Runtime {

substrate/frame/revive/src/evm/call.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub struct CallInfo<T: Config> {
4848
pub fn create_call<T>(
4949
tx: GenericTransaction,
5050
signed_transaction: Option<(u32, Vec<u8>)>,
51+
apply_weight_cap: bool,
5152
) -> Result<CallInfo<T>, InvalidTransaction>
5253
where
5354
T: Config,
@@ -176,7 +177,8 @@ where
176177

177178
call.set_weight_limit(weight_limit);
178179
let info = <T as Config>::FeeInfo::dispatch_info(&call);
179-
let max_weight = <Pallet<T>>::evm_max_extrinsic_weight();
180+
let max_weight =
181+
if apply_weight_cap { <Pallet<T>>::evm_max_extrinsic_weight() } else { Weight::MAX };
180182
let overweight_by = info.total_weight().saturating_sub(max_weight);
181183
let capped_weight = weight_limit.saturating_sub(overweight_by);
182184
call.set_weight_limit(capped_weight);

substrate/frame/revive/src/evm/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ pub trait EthExtra {
315315

316316
log::debug!(target: LOG_TARGET, "Decoded Ethereum transaction with signer: {signer_addr:?} nonce: {nonce:?}");
317317
let call_info =
318-
create_call::<Self::Config>(tx, Some((encoded_len as u32, payload.to_vec())))?;
318+
create_call::<Self::Config>(tx, Some((encoded_len as u32, payload.to_vec())), true)?;
319319
let storage_credit = <Self::Config as Config>::Currency::withdraw(
320320
&signer,
321321
call_info.storage_deposit,

substrate/frame/revive/src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ pub mod pallet {
359359
pub const DepositPerChildTrieItem: Balance = deposit(1, 0) / 100;
360360
pub const DepositPerByte: Balance = deposit(0, 1);
361361
pub const CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(0);
362-
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(1, 2);
362+
pub const MaxEthExtrinsicWeight: FixedU128 = FixedU128::from_rational(9, 10);
363363
}
364364

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

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

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

18281828
log::debug!(target: LOG_TARGET, "\
18291829
dry_run_eth_transact: \
1830-
weight_limit={:?}: \
1831-
eth_gas={eth_gas:?})\
1830+
weight_limit={} \
1831+
total_weight={total_weight} \
1832+
max_weight={max_weight} \
1833+
weight_left={} \
1834+
eth_gas={eth_gas})\
18321835
",
18331836
dry_run.gas_required,
1837+
max_weight.saturating_sub(total_weight),
18341838

18351839
);
18361840
dry_run.eth_gas = eth_gas;

0 commit comments

Comments
 (0)