Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Create thread_local in XCM executor to limit recursion depth #6304

Merged
merged 14 commits into from
Dec 1, 2022
Prev Previous commit
Next Next commit
Fix statefulness in tests
  • Loading branch information
KiChjang committed Nov 26, 2022
commit 395a0997e2eafee75b501bcb3d0a9ce4b4d4ef91
7 changes: 4 additions & 3 deletions xcm/xcm-executor/integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ fn transact_recursion_limit_works() {
.build();

let mut msg = Xcm(vec![ClearOrigin]);
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
let mut max_weight = <XcmConfig as xcm_executor::Config>::Weigher::weight(&mut msg).unwrap();
let max_weight = <XcmConfig as xcm_executor::Config>::Weigher::weight(&mut msg).unwrap();
let mut call = polkadot_test_runtime::RuntimeCall::Xcm(
pallet_xcm::Call::execute { message: Box::new(VersionedXcm::from(msg)), max_weight },
);

for _ in 0..10 {
msg = Xcm(vec![
let mut msg = Xcm(vec![
WithdrawAsset((Parent, 1_000_000_000).into()),
BuyExecution { fees: (Parent, 1_000_000_000).into(), weight_limit: Unlimited },
Transact {
Expand All @@ -95,7 +95,7 @@ fn transact_recursion_limit_works() {
call: call.encode().into(),
},
]);
max_weight = <XcmConfig as xcm_executor::Config>::Weigher::weight(&mut msg).unwrap();
let max_weight = <XcmConfig as xcm_executor::Config>::Weigher::weight(&mut msg).unwrap();
call = polkadot_test_runtime::RuntimeCall::Xcm(
pallet_xcm::Call::execute { message: Box::new(VersionedXcm::from(msg)), max_weight }
);
Expand All @@ -119,6 +119,7 @@ fn transact_recursion_limit_works() {
.expect("imports the block");

client.state_at(block_hash).expect("state should exist").inspect_state(|| {
panic!("{:?}", polkadot_test_runtime::System::events());
assert!(polkadot_test_runtime::System::events().iter().any(|r| matches!(
r.event,
polkadot_test_runtime::RuntimeEvent::Xcm(pallet_xcm::Event::Attempted(
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
Expand Down