Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3cc8d6d
add external transient_storage to pallet_revive::ExecConfig
pkhry Nov 30, 2025
fdba022
Update from github-actions[bot] running command 'prdoc'
github-actions[bot] Dec 1, 2025
093782d
prdoc
pkhry Dec 2, 2025
d9f4b93
merge fix
pkhry Dec 2, 2025
8becba6
Update from github-actions[bot] running command 'fmt'
github-actions[bot] Dec 4, 2025
12d6c8b
Merge branch 'master' into pkhry/external_transient_storage
pkhry Dec 4, 2025
d31790d
up
pkhry Dec 2, 2025
fc09d1d
Update substrate/frame/revive/src/primitives.rs
pkhry Dec 5, 2025
d37a69b
rm spurious commas
pkhry Dec 5, 2025
561cdef
Merge branch 'master' into pkhry/external_transient_storage
pkhry Dec 5, 2025
cc82a2b
Merge branch 'master' into pkhry/external_transient_storage
pkhry Dec 8, 2025
de4d819
address comments
pkhry Dec 9, 2025
840ad71
Update from github-actions[bot] running command 'fmt'
github-actions[bot] Dec 9, 2025
68b627c
Merge branch 'master' into pkhry/external_transient_storage
pkhry Dec 9, 2025
d70b9d0
Merge branch 'master' into pkhry/external_transient_storage
pkhry Dec 10, 2025
75f36cf
Merge branch 'master' into pkhry/external_transient_storage
pkhry Dec 13, 2025
a97d852
Merge remote-tracking branch 'origin/master' into pkhry/external_tran…
pkhry Jan 22, 2026
f5a7e42
review comments
pkhry Jan 22, 2026
e27ed4d
fix compilation
pkhry Jan 22, 2026
e00b2c1
cleanup builder change
pkhry Jan 22, 2026
3d87b31
fix erc20 transactor calls
pkhry Jan 23, 2026
8ca6e61
fixup tests
pkhry Jan 25, 2026
037c675
clippy
pkhry Jan 25, 2026
8e35cc9
bare_instantiate
pkhry Jan 25, 2026
28d5d53
Merge branch 'master' into pkhry/external_transient_storage
pkhry Jan 25, 2026
fc0394d
Merge branch 'master' into pkhry/external_transient_storage
pkhry Jan 26, 2026
eaae888
fix prdoc
pkhry Jan 27, 2026
2cdbab6
Merge branch 'master' into pkhry/external_transient_storage
pkhry Jan 29, 2026
6b2dea7
Merge branch 'master' into pkhry/external_transient_storage
pkhry Jan 30, 2026
8f0cbcc
Update from github-actions[bot] running command 'fmt'
github-actions[bot] Jan 30, 2026
469b6ba
revert breaking change
pkhry Jan 30, 2026
5f097b1
upd more
pkhry Jan 30, 2026
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 @@ -131,7 +131,7 @@ where
deposit_limit: StorageDepositLimit::get(),
},
data,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);
// We need to return this surplus for the executor to allow refunding it.
let surplus = weight_limit.saturating_sub(weight_consumed);
Expand Down Expand Up @@ -192,7 +192,7 @@ where
deposit_limit: StorageDepositLimit::get(),
},
data,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);
// We need to return this surplus for the executor to allow refunding it.
let surplus = weight_limit.saturating_sub(weight_consumed);
Expand Down
36 changes: 18 additions & 18 deletions polkadot/xcm/pallet-xcm/precompiles/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn test_xcm_send_precompile_works() {
deposit_limit: u128::MAX,
},
encoded_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);
assert!(result.result.is_ok());
let sent_message = Xcm(Some(DescendOrigin(sender.clone().try_into().unwrap()))
Expand Down Expand Up @@ -131,7 +131,7 @@ fn test_xcm_send_precompile_to_parachain() {
deposit_limit: u128::MAX,
},
encoded_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

assert!(result.result.is_ok());
Expand Down Expand Up @@ -182,7 +182,7 @@ fn test_xcm_send_precompile_fails() {
deposit_limit: u128::MAX,
},
encoded_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);
let return_value = match result.result {
Ok(value) => value,
Expand Down Expand Up @@ -234,7 +234,7 @@ fn send_fails_on_old_location_version() {
deposit_limit: u128::MAX,
},
encoded_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);
let return_value = match result.result {
Ok(value) => value,
Expand Down Expand Up @@ -263,7 +263,7 @@ fn send_fails_on_old_location_version() {
deposit_limit: u128::MAX,
},
encoded_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);
let return_value = match result.result {
Ok(value) => value,
Expand Down Expand Up @@ -315,7 +315,7 @@ fn send_fails_on_old_xcm_version() {
deposit_limit: u128::MAX,
},
encoded_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);
let return_value = match result.result {
Ok(value) => value,
Expand Down Expand Up @@ -345,7 +345,7 @@ fn send_fails_on_old_xcm_version() {
deposit_limit: u128::MAX,
},
encoded_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);
let return_value = match result.result {
Ok(value) => value,
Expand Down Expand Up @@ -390,7 +390,7 @@ fn test_xcm_execute_precompile_works() {
deposit_limit: u128::MAX,
},
encoded_weight_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

let weight_result = match xcm_weight_results.result {
Expand All @@ -414,7 +414,7 @@ fn test_xcm_execute_precompile_works() {
deposit_limit: u128::MAX,
},
encoded_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

assert!(result.result.is_ok());
Expand Down Expand Up @@ -455,7 +455,7 @@ fn test_xcm_execute_precompile_different_beneficiary() {
deposit_limit: u128::MAX,
},
encoded_weight_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

let weight_result = match xcm_weight_results.result {
Expand All @@ -479,7 +479,7 @@ fn test_xcm_execute_precompile_different_beneficiary() {
deposit_limit: u128::MAX,
},
encoded_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

let return_value = match result.result {
Expand Down Expand Up @@ -528,7 +528,7 @@ fn test_xcm_execute_precompile_fails() {
deposit_limit: u128::MAX,
},
encoded_weight_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

let weight_result = match xcm_weight_results.result {
Expand All @@ -552,7 +552,7 @@ fn test_xcm_execute_precompile_fails() {
deposit_limit: u128::MAX,
},
encoded_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);
let return_value = match result.result {
Ok(value) => value,
Expand Down Expand Up @@ -600,7 +600,7 @@ fn execute_fails_on_old_version() {
deposit_limit: u128::MAX,
},
encoded_weight_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

let weight_result = match xcm_weight_results.result {
Expand Down Expand Up @@ -631,7 +631,7 @@ fn execute_fails_on_old_version() {
deposit_limit: u128::MAX,
},
encoded_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

let return_value = match result.result {
Expand Down Expand Up @@ -660,7 +660,7 @@ fn execute_fails_on_old_version() {
deposit_limit: u128::MAX,
},
encoded_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

let return_value = match result.result {
Expand Down Expand Up @@ -711,7 +711,7 @@ fn weight_fails_on_old_version() {
deposit_limit: u128::MAX,
},
encoded_weight_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

let result = match xcm_weight_results.result {
Expand All @@ -737,7 +737,7 @@ fn weight_fails_on_old_version() {
deposit_limit: u128::MAX,
},
encoded_weight_call,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

let result = match xcm_weight_results.result {
Expand Down
18 changes: 18 additions & 0 deletions prdoc/pr_10493.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
title: add external transient_storage to pallet_revive::ExecConfig
doc:
- audience: Node Dev
description: |-
# Description

This PR adds the ability to supply external copy of `TransientStorage` to `pallet_revive::ExecConfig` to be used during execution.
This is required by testing in foundry as we only enter `pallet_revive` during a `CALL` or `CREATE` instruction and we need to carryover
the transient storage to other following calls as they happen within an external tx
crates:
- name: pallet-revive
bump: major
- name: pallet-xcm-precompiles
bump: minor
- name: pallet-assets-precompiles
bump: minor
- name: assets-common
bump: minor
12 changes: 6 additions & 6 deletions substrate/frame/assets/precompiles/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn precompile_transfer_works() {
deposit_limit: u64::MAX,
},
data,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

assert_contract_event(
Expand Down Expand Up @@ -122,7 +122,7 @@ fn total_supply_works() {
deposit_limit: u64::MAX,
},
data,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
)
.result
.unwrap()
Expand Down Expand Up @@ -157,7 +157,7 @@ fn balance_of_works() {
deposit_limit: u64::MAX,
},
data,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
)
.result
.unwrap()
Expand Down Expand Up @@ -205,7 +205,7 @@ fn approval_works() {
deposit_limit: u64::MAX,
},
data,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

assert_contract_event(
Expand All @@ -230,7 +230,7 @@ fn approval_works() {
deposit_limit: u64::MAX,
},
data,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
)
.result
.unwrap()
Expand All @@ -255,7 +255,7 @@ fn approval_works() {
deposit_limit: u64::MAX,
},
data,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);
assert_eq!(Assets::balance(asset_id, owner), 90);
assert_eq!(Assets::allowance(asset_id, &owner, &spender), 15);
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/src/call_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ where
Code::Upload(module.code),
data,
salt,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);

let address = outcome.result?.addr;
Expand Down
7 changes: 5 additions & 2 deletions substrate/frame/revive/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,21 @@ pub struct DebugSettings {
}

impl DebugSettings {
#[cfg(test)]
pub fn set_bypass_eip_3607(mut self, value: bool) -> Self {
self.bypass_eip_3607 = value;
self
}

#[cfg(test)]
pub fn set_allow_unlimited_contract_size(mut self, value: bool) -> Self {
self.allow_unlimited_contract_size = value;
self
}

pub fn set_enable_pvm_logs(mut self, value: bool) -> Self {
self.pvm_logs = value;
self
}

pub fn is_execution_tracing_enabled<T: Config>() -> bool {
T::DebugEnabled::get() && !DebugSettingsOf::<T>::get().disable_execution_tracing
}
Expand Down
49 changes: 37 additions & 12 deletions substrate/frame/revive/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,9 @@ where
*caller_frame = Default::default();
}

self.transient_storage.start_transaction();
self.with_transient_storage_mut(|transient_storage| {
transient_storage.start_transaction();
});
let is_first_frame = self.frames.is_empty();

let do_transaction = || -> ExecResult {
Expand Down Expand Up @@ -1499,12 +1501,13 @@ where
(false, Err(error.into()))
},
};

if success {
self.transient_storage.commit_transaction();
} else {
self.transient_storage.rollback_transaction();
}
self.with_transient_storage_mut(|transient_storage| {
if success {
transient_storage.commit_transaction();
} else {
transient_storage.rollback_transaction();
}
});
log::trace!(target: LOG_TARGET, "frame finished with: {output:?}");

self.pop_frame(success);
Expand Down Expand Up @@ -1844,6 +1847,24 @@ where
}
true
}

fn with_transient_storage_mut<R, F: FnOnce(&mut TransientStorage<T>) -> R>(
&mut self,
f: F,
) -> R {
if let Some(transient) = &self.exec_config.transient_storage {
f(&mut transient.borrow_mut())
} else {
f(&mut self.transient_storage)
}
}
fn with_transient_storage<R, F: FnOnce(&TransientStorage<T>) -> R>(&self, f: F) -> R {
if let Some(transient) = &self.exec_config.transient_storage {
f(&transient.borrow())
} else {
f(&self.transient_storage)
}
}
}

impl<'a, T, E> Ext for Stack<'a, T, E>
Expand Down Expand Up @@ -2142,13 +2163,15 @@ where
}

fn get_transient_storage(&self, key: &Key) -> Option<Vec<u8>> {
self.transient_storage.read(self.account_id(), key)
self.with_transient_storage(|transient_storage| {
transient_storage.read(self.account_id(), key)
})
}

fn get_transient_storage_size(&self, key: &Key) -> Option<u32> {
self.transient_storage
.read(self.account_id(), key)
.map(|value| value.len() as _)
self.with_transient_storage(|transient_storage| {
transient_storage.read(self.account_id(), key).map(|value| value.len() as _)
})
}

fn set_transient_storage(
Expand All @@ -2158,7 +2181,9 @@ where
take_old: bool,
) -> Result<WriteOutcome, DispatchError> {
let account_id = self.account_id().clone();
self.transient_storage.write(&account_id, key, value, take_old)
self.with_transient_storage_mut(|transient_storage| {
transient_storage.write(&account_id, key, value, take_old)
})
}

fn account_id(&self) -> &T::AccountId {
Expand Down
Loading
Loading