From 9cac16e0e60fcd13069489e16c7d6d0d3d4f1225 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Thu, 16 Oct 2025 16:40:11 +0300 Subject: [PATCH 1/4] tweaks --- substrate/frame/revive/src/exec.rs | 8 ++++++-- substrate/frame/revive/src/lib.rs | 6 +++--- substrate/frame/revive/src/primitives.rs | 25 +++++++++++++++++++++--- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/substrate/frame/revive/src/exec.rs b/substrate/frame/revive/src/exec.rs index 802266210a0fa..ec87b616a40bb 100644 --- a/substrate/frame/revive/src/exec.rs +++ b/substrate/frame/revive/src/exec.rs @@ -1288,8 +1288,12 @@ where // if we are dealing with EVM bytecode // We upload the new runtime code, and update the code if !is_pvm { - // Only keep return data for tracing - let data = if crate::tracing::if_tracing(|_| {}).is_none() { + // Only keep return data for tracing and for dry runs. + // When a dry-run simulates contract deployment, keep the execution result's + // data. + let data = if crate::tracing::if_tracing(|_| {}).is_none() && + !self.exec_config.is_dry_run + { core::mem::replace(&mut output.data, Default::default()) } else { output.data.clone() diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index 4d97ca194c86a..162d8219ab6d2 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -1476,7 +1476,7 @@ impl Pallet { effective_gas_price, call_info.encoded_len, base_info.total_weight(), - ) + ).dry_run() }; // emulate transaction behavior @@ -2335,7 +2335,7 @@ macro_rules! impl_runtime_apis_plus_revive_traits { gas_limit.unwrap_or(blockweights.max_block), storage_deposit_limit.unwrap_or(u128::MAX), input_data, - $crate::ExecConfig::new_substrate_tx(), + $crate::ExecConfig::new_substrate_tx().dry_run(), ) } @@ -2361,7 +2361,7 @@ macro_rules! impl_runtime_apis_plus_revive_traits { code, data, salt, - $crate::ExecConfig::new_substrate_tx(), + $crate::ExecConfig::new_substrate_tx().dry_run(), ) } diff --git a/substrate/frame/revive/src/primitives.rs b/substrate/frame/revive/src/primitives.rs index 48db56df0aca4..51f067cecc773 100644 --- a/substrate/frame/revive/src/primitives.rs +++ b/substrate/frame/revive/src/primitives.rs @@ -348,22 +348,41 @@ pub struct ExecConfig { /// /// It is determined when transforming `eth_transact` into a proper extrinsic. pub effective_gas_price: Option, + /// Whether this configuration was created for a dry-run execution. + /// Use to enable logic that should only run in dry-run mode. + pub is_dry_run: bool, } impl ExecConfig { - /// Create a default config appropriate when the call originated from a subtrate tx. + /// Create a default config appropriate when the call originated from a substrate tx. pub fn new_substrate_tx() -> Self { - Self { bump_nonce: true, collect_deposit_from_hold: None, effective_gas_price: None } + Self { + bump_nonce: true, + collect_deposit_from_hold: None, + effective_gas_price: None, + is_dry_run: false, + } } /// Create a default config appropriate when the call originated from a ethereum tx. - pub fn new_eth_tx(effective_gas_price: U256, encoded_len: u32, base_weight: Weight) -> Self { + pub fn new_eth_tx( + effective_gas_price: U256, + encoded_len: u32, + base_weight: Weight, + ) -> Self { Self { bump_nonce: false, collect_deposit_from_hold: Some((encoded_len, base_weight)), effective_gas_price: Some(effective_gas_price), + is_dry_run: false, } } + + /// Set this config to be a dry-run. + pub fn dry_run(self) -> Self { + self.is_dry_run = true + self + } } /// Indicates whether the code was removed after the last refcount was decremented. From f16aedc568fa731357c014d530a7a78a21785f6f Mon Sep 17 00:00:00 2001 From: Marian Radu Date: Thu, 16 Oct 2025 17:34:22 +0300 Subject: [PATCH 2/4] pallet_revive: Fix build and format code using rustfmt. --- substrate/frame/revive/src/lib.rs | 3 ++- substrate/frame/revive/src/primitives.rs | 10 +++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index 162d8219ab6d2..cb8f74be3ff01 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -1476,7 +1476,8 @@ impl Pallet { effective_gas_price, call_info.encoded_len, base_info.total_weight(), - ).dry_run() + ) + .dry_run() }; // emulate transaction behavior diff --git a/substrate/frame/revive/src/primitives.rs b/substrate/frame/revive/src/primitives.rs index 51f067cecc773..7e1a9cc745483 100644 --- a/substrate/frame/revive/src/primitives.rs +++ b/substrate/frame/revive/src/primitives.rs @@ -365,11 +365,7 @@ impl ExecConfig { } /// Create a default config appropriate when the call originated from a ethereum tx. - pub fn new_eth_tx( - effective_gas_price: U256, - encoded_len: u32, - base_weight: Weight, - ) -> Self { + pub fn new_eth_tx(effective_gas_price: U256, encoded_len: u32, base_weight: Weight) -> Self { Self { bump_nonce: false, collect_deposit_from_hold: Some((encoded_len, base_weight)), @@ -379,8 +375,8 @@ impl ExecConfig { } /// Set this config to be a dry-run. - pub fn dry_run(self) -> Self { - self.is_dry_run = true + pub fn dry_run(mut self) -> Self { + self.is_dry_run = true; self } } From d3411f2f04236d96ba7a8ce24b70903fc75f8103 Mon Sep 17 00:00:00 2001 From: Marian Radu Date: Sat, 18 Oct 2025 13:42:36 +0300 Subject: [PATCH 3/4] Rename dry_run method to with_dry_run --- substrate/frame/revive/src/lib.rs | 6 +++--- substrate/frame/revive/src/primitives.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index cb8f74be3ff01..dbd8c017a71a0 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -1477,7 +1477,7 @@ impl Pallet { call_info.encoded_len, base_info.total_weight(), ) - .dry_run() + .with_dry_run() }; // emulate transaction behavior @@ -2336,7 +2336,7 @@ macro_rules! impl_runtime_apis_plus_revive_traits { gas_limit.unwrap_or(blockweights.max_block), storage_deposit_limit.unwrap_or(u128::MAX), input_data, - $crate::ExecConfig::new_substrate_tx().dry_run(), + $crate::ExecConfig::new_substrate_tx().with_dry_run(), ) } @@ -2362,7 +2362,7 @@ macro_rules! impl_runtime_apis_plus_revive_traits { code, data, salt, - $crate::ExecConfig::new_substrate_tx().dry_run(), + $crate::ExecConfig::new_substrate_tx().with_dry_run(), ) } diff --git a/substrate/frame/revive/src/primitives.rs b/substrate/frame/revive/src/primitives.rs index 7e1a9cc745483..6cb015b06e6c5 100644 --- a/substrate/frame/revive/src/primitives.rs +++ b/substrate/frame/revive/src/primitives.rs @@ -375,7 +375,7 @@ impl ExecConfig { } /// Set this config to be a dry-run. - pub fn dry_run(mut self) -> Self { + pub fn with_dry_run(mut self) -> Self { self.is_dry_run = true; self } From c43c76e8ec32736215040f11b0812cad83091e9c Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 19 Oct 2025 07:57:46 +0000 Subject: [PATCH 4/4] Update from github-actions[bot] running command 'prdoc --audience runtime_dev --bump patch' --- prdoc/pr_10032.prdoc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 prdoc/pr_10032.prdoc diff --git a/prdoc/pr_10032.prdoc b/prdoc/pr_10032.prdoc new file mode 100644 index 0000000000000..085bd210e5d91 --- /dev/null +++ b/prdoc/pr_10032.prdoc @@ -0,0 +1,13 @@ +title: 'pallet_revive: when a dry run simulates contract deployment, return the execution + result data.' +doc: +- audience: Runtime Dev + description: |- + Fixes https://github.com/paritytech/contract-issues/issues/177 + + Expose the deployed contract's runtime bytecode in eth_call responses during simulated contract creation. + + The test from issue https://github.com/paritytech/contract-issues/issues/177 sends an eth_call request without a destination address, while providing contract bytecode in the data field. This simulates a contract creation transaction. The test expects the RPC response to return the result of executing the init code, which is the deployed contract's runtime bytecode. While this result is not returned in actual deployments, it is expected in dry-run simulations. +crates: +- name: pallet-revive + bump: patch