From 5cc3b3244a186643a11b68fd3b6142a2f5b42e0d Mon Sep 17 00:00:00 2001 From: Alexandru Gheorghe Date: Thu, 6 Nov 2025 14:59:02 +0200 Subject: [PATCH 1/4] make contracts create consider is_unlimited_contract_size_allowed Signed-off-by: Alexandru Gheorghe --- substrate/frame/revive/src/exec.rs | 11 +++++++++-- substrate/frame/revive/src/exec/mock_ext.rs | 4 ++++ .../frame/revive/src/vm/evm/instructions/contract.rs | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/substrate/frame/revive/src/exec.rs b/substrate/frame/revive/src/exec.rs index 4115cd5c6895b..a0fbd4db90ad4 100644 --- a/substrate/frame/revive/src/exec.rs +++ b/substrate/frame/revive/src/exec.rs @@ -31,8 +31,8 @@ use crate::{ tracing::if_tracing, transient_storage::TransientStorage, AccountInfo, BalanceOf, BalanceWithDust, Code, CodeInfo, CodeInfoOf, CodeRemoved, Config, - ContractInfo, Error, Event, ImmutableData, ImmutableDataOf, Pallet as Contracts, RuntimeCosts, - LOG_TARGET, + ContractInfo, DebugSettings, Error, Event, ImmutableData, ImmutableDataOf, Pallet as Contracts, + RuntimeCosts, LOG_TARGET, }; use alloc::{ collections::{BTreeMap, BTreeSet}, @@ -470,6 +470,9 @@ pub trait PrecompileExt: sealing::Sealed { /// Charges `diff` from the meter. fn charge_storage(&mut self, diff: &Diff); + + /// Check if unlimited contract size is allowed. + fn is_unlimited_contract_size_allowed(&self) -> bool; } /// Describes the different functions that can be exported by an [`Executable`]. @@ -2296,6 +2299,10 @@ where assert!(self.has_contract_info()); self.top_frame_mut().nested_storage.charge(diff) } + + fn is_unlimited_contract_size_allowed(&self) -> bool { + DebugSettings::is_unlimited_contract_size_allowed::() + } } /// Returns true if the address has a precompile contract, else false. diff --git a/substrate/frame/revive/src/exec/mock_ext.rs b/substrate/frame/revive/src/exec/mock_ext.rs index 8338b66825bb9..4b9e63711fa29 100644 --- a/substrate/frame/revive/src/exec/mock_ext.rs +++ b/substrate/frame/revive/src/exec/mock_ext.rs @@ -239,6 +239,10 @@ impl PrecompileExt for MockExt { } fn charge_storage(&mut self, _diff: &Diff) {} + + fn is_unlimited_contract_size_allowed(&self) -> bool { + false + } } impl PrecompileWithInfoExt for MockExt { diff --git a/substrate/frame/revive/src/vm/evm/instructions/contract.rs b/substrate/frame/revive/src/vm/evm/instructions/contract.rs index 421f592b8462f..c04ee876261ad 100644 --- a/substrate/frame/revive/src/vm/evm/instructions/contract.rs +++ b/substrate/frame/revive/src/vm/evm/instructions/contract.rs @@ -58,7 +58,9 @@ pub fn create( let mut code = Vec::new(); if len != 0 { // EIP-3860: Limit initcode - if len > revm::primitives::eip3860::MAX_INITCODE_SIZE { + if len > revm::primitives::eip3860::MAX_INITCODE_SIZE && + !interpreter.ext.is_unlimited_contract_size_allowed() + { return ControlFlow::Break(Error::::BlobTooLarge.into()); } From 957931684459a50087be17c768728eecd33f8e8d Mon Sep 17 00:00:00 2001 From: Alexandru Gheorghe Date: Mon, 10 Nov 2025 17:27:50 +0200 Subject: [PATCH 2/4] Revert "make contracts create consider is_unlimited_contract_size_allowed" This reverts commit 5cc3b3244a186643a11b68fd3b6142a2f5b42e0d. --- substrate/frame/revive/src/exec.rs | 11 ++--------- substrate/frame/revive/src/exec/mock_ext.rs | 4 ---- .../frame/revive/src/vm/evm/instructions/contract.rs | 4 +--- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/substrate/frame/revive/src/exec.rs b/substrate/frame/revive/src/exec.rs index a0fbd4db90ad4..4115cd5c6895b 100644 --- a/substrate/frame/revive/src/exec.rs +++ b/substrate/frame/revive/src/exec.rs @@ -31,8 +31,8 @@ use crate::{ tracing::if_tracing, transient_storage::TransientStorage, AccountInfo, BalanceOf, BalanceWithDust, Code, CodeInfo, CodeInfoOf, CodeRemoved, Config, - ContractInfo, DebugSettings, Error, Event, ImmutableData, ImmutableDataOf, Pallet as Contracts, - RuntimeCosts, LOG_TARGET, + ContractInfo, Error, Event, ImmutableData, ImmutableDataOf, Pallet as Contracts, RuntimeCosts, + LOG_TARGET, }; use alloc::{ collections::{BTreeMap, BTreeSet}, @@ -470,9 +470,6 @@ pub trait PrecompileExt: sealing::Sealed { /// Charges `diff` from the meter. fn charge_storage(&mut self, diff: &Diff); - - /// Check if unlimited contract size is allowed. - fn is_unlimited_contract_size_allowed(&self) -> bool; } /// Describes the different functions that can be exported by an [`Executable`]. @@ -2299,10 +2296,6 @@ where assert!(self.has_contract_info()); self.top_frame_mut().nested_storage.charge(diff) } - - fn is_unlimited_contract_size_allowed(&self) -> bool { - DebugSettings::is_unlimited_contract_size_allowed::() - } } /// Returns true if the address has a precompile contract, else false. diff --git a/substrate/frame/revive/src/exec/mock_ext.rs b/substrate/frame/revive/src/exec/mock_ext.rs index 4b9e63711fa29..8338b66825bb9 100644 --- a/substrate/frame/revive/src/exec/mock_ext.rs +++ b/substrate/frame/revive/src/exec/mock_ext.rs @@ -239,10 +239,6 @@ impl PrecompileExt for MockExt { } fn charge_storage(&mut self, _diff: &Diff) {} - - fn is_unlimited_contract_size_allowed(&self) -> bool { - false - } } impl PrecompileWithInfoExt for MockExt { diff --git a/substrate/frame/revive/src/vm/evm/instructions/contract.rs b/substrate/frame/revive/src/vm/evm/instructions/contract.rs index c04ee876261ad..421f592b8462f 100644 --- a/substrate/frame/revive/src/vm/evm/instructions/contract.rs +++ b/substrate/frame/revive/src/vm/evm/instructions/contract.rs @@ -58,9 +58,7 @@ pub fn create( let mut code = Vec::new(); if len != 0 { // EIP-3860: Limit initcode - if len > revm::primitives::eip3860::MAX_INITCODE_SIZE && - !interpreter.ext.is_unlimited_contract_size_allowed() - { + if len > revm::primitives::eip3860::MAX_INITCODE_SIZE { return ControlFlow::Break(Error::::BlobTooLarge.into()); } From 99645f4f182a3412ced7720bbcb06d5a7affdf90 Mon Sep 17 00:00:00 2001 From: Alexandru Gheorghe Date: Mon, 10 Nov 2025 17:29:28 +0200 Subject: [PATCH 3/4] address revive feedback Signed-off-by: Alexandru Gheorghe --- substrate/frame/revive/src/vm/evm/instructions/contract.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/substrate/frame/revive/src/vm/evm/instructions/contract.rs b/substrate/frame/revive/src/vm/evm/instructions/contract.rs index 421f592b8462f..732094ce6b71a 100644 --- a/substrate/frame/revive/src/vm/evm/instructions/contract.rs +++ b/substrate/frame/revive/src/vm/evm/instructions/contract.rs @@ -23,7 +23,7 @@ use crate::{ evm::{interpreter::Halt, util::as_usize_or_halt, Interpreter}, Ext, RuntimeCosts, }, - Code, Error, Pallet, Weight, H160, LOG_TARGET, U256, + Code, DebugSettings, Error, Pallet, Weight, H160, LOG_TARGET, U256, }; use alloc::{vec, vec::Vec}; pub use call_helpers::{calc_call_gas, get_memory_in_and_out_ranges}; @@ -58,7 +58,9 @@ pub fn create( let mut code = Vec::new(); if len != 0 { // EIP-3860: Limit initcode - if len > revm::primitives::eip3860::MAX_INITCODE_SIZE { + if len > revm::primitives::eip3860::MAX_INITCODE_SIZE && + !DebugSettings::is_unlimited_contract_size_allowed::() + { return ControlFlow::Break(Error::::BlobTooLarge.into()); } From 6e644f5f7016ea1ba458111741276f91655f4077 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 10 Nov 2025 16:45:07 +0000 Subject: [PATCH 4/4] Update from github-actions[bot] running command 'prdoc --audience runtime_dev --bump minor' --- prdoc/pr_10224.prdoc | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 prdoc/pr_10224.prdoc diff --git a/prdoc/pr_10224.prdoc b/prdoc/pr_10224.prdoc new file mode 100644 index 0000000000000..cf2068e6d6c46 --- /dev/null +++ b/prdoc/pr_10224.prdoc @@ -0,0 +1,10 @@ +title: make contracts create consider is_unlimited_contract_size_allowed +doc: +- audience: Runtime Dev + description: |- + While running foundry tests from https://github.com/balancer/balancer-v3-monorepo/tree/main/pkg/pool-weighted, found we hit this limit. + + Foundry environment is configured with unlimited code size, so we need to make sure pallet-revive respects those configurations everywhere. +crates: +- name: pallet-revive + bump: minor