From 77b079a6b1b9212fb8085811195efa4b9354e732 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Sat, 30 Aug 2025 11:59:28 +0800 Subject: [PATCH 01/50] Add barrier_check --- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index d7471b02368fa..b52f52ad78ce0 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -97,6 +97,14 @@ pub mod pallet { /// If set to `Err`, benchmarks which rely on a universal alias will be skipped. fn alias_origin() -> Result<(Location, Location), BenchmarkError>; + /// A `RuntimeCall` that is checked by the XCM executor's barrier logic. + /// + /// This represents a call used to benchmark the cost of barrier evaluation in both + /// acceptance and rejection cases. + /// + /// If set to `Err`, benchmarks which rely on a `barrier_check` will be skipped. + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError>; + /// Returns a valid pallet info for `ExpectPallet` or `QueryPallet` benchmark. /// /// By default returns `frame_system::Pallet` info with expected pallet index `0`. From e1769d34702f0e37d2de14fee0a928c48cf45f29 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Sat, 30 Aug 2025 12:24:03 +0800 Subject: [PATCH 02/50] Add dummy barrier_check impls --- .../parachains/runtimes/assets/asset-hub-rococo/src/lib.rs | 4 ++++ .../parachains/runtimes/assets/asset-hub-westend/src/lib.rs | 5 +++++ .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 4 ++++ .../runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs | 4 ++++ .../runtimes/collectives/collectives-westend/src/lib.rs | 4 ++++ .../parachains/runtimes/coretime/coretime-rococo/src/lib.rs | 4 ++++ .../parachains/runtimes/coretime/coretime-westend/src/lib.rs | 4 ++++ cumulus/parachains/runtimes/people/people-rococo/src/lib.rs | 4 ++++ cumulus/parachains/runtimes/people/people-westend/src/lib.rs | 4 ++++ polkadot/runtime/rococo/src/lib.rs | 4 ++++ polkadot/runtime/westend/src/lib.rs | 4 ++++ polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 4 ++++ substrate/frame/staking-async/runtimes/parachain/src/lib.rs | 4 ++++ substrate/frame/staking-async/runtimes/rc/src/lib.rs | 4 ++++ 14 files changed, 57 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 209f11d8173a5..544436a6239a8 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -2022,6 +2022,10 @@ impl_runtime_apis! { Location::new(1, [Parachain(1001), AccountId32 { id: [111u8; 32], network: None }]), )) } + + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 13fb11e8cf61d..47dc03d8436d6 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2563,6 +2563,11 @@ pallet_revive::impl_runtime_apis_plus_revive!( Location::new(1, [Parachain(1001), AccountId32 { id: [111u8; 32], network: None }]), )) } + + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + // TODO: implement a benchmark for barrier check + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index d91dd0adcdfb6..295e1a89713d2 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -1331,6 +1331,10 @@ impl_runtime_apis! { fn alias_origin() -> Result<(Location, Location), BenchmarkError> { Err(BenchmarkError::Skip) } + + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index eaa58ac1b62ed..bda6add4d03dc 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -1277,6 +1277,10 @@ impl_runtime_apis! { let target = Location::new(1, [Parachain(1000), AccountId32 { id: [128u8; 32], network: None }]); Ok((origin, target)) } + + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index cd89e9151c635..3e55cb70b589f 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -1318,6 +1318,10 @@ impl_runtime_apis! { let target = Location::new(1, [Parachain(1000), AccountId32 { id: [128u8; 32], network: None }]); Ok((origin, target)) } + + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs index dfefc339e6a76..24dafbfc2b73c 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs @@ -1150,6 +1150,10 @@ impl_runtime_apis! { fn alias_origin() -> Result<(Location, Location), BenchmarkError> { Err(BenchmarkError::Skip) } + + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index 0a60b6660e46b..7d236c6a9df41 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -1176,6 +1176,10 @@ impl_runtime_apis! { let target = Location::new(1, [Parachain(1000), AccountId32 { id: [128u8; 32], network: None }]); Ok((origin, target)) } + + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs index 9e20bf64f91cf..8332ae0760f39 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs @@ -1082,6 +1082,10 @@ impl_runtime_apis! { fn alias_origin() -> Result<(Location, Location), BenchmarkError> { Err(BenchmarkError::Skip) } + + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs index cbdca464f860b..55a96bcc9350a 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs @@ -1109,6 +1109,10 @@ impl_runtime_apis! { let target = Location::new(1, [Parachain(1000), AccountId32 { id: [128u8; 32], network: None }]); Ok((origin, target)) } + + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 7f5a615444763..cf7a621996361 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -2686,6 +2686,10 @@ sp_api::impl_runtime_apis! { // The XCM executor of Rococo doesn't have a configured `Aliasers` Err(BenchmarkError::Skip) } + + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + Err(BenchmarkError::Skip) + } } let mut whitelist: Vec = AllPalletsWithSystem::whitelisted_storage_keys(); diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 7b1b9031762b4..6cec847b9ae13 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -3052,6 +3052,10 @@ sp_api::impl_runtime_apis! { let target = Location::new(0, [Parachain(1000), AccountId32 { id: [128u8; 32], network: None }]); Ok((origin, target)) } + + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 6368ca0e9c3f5..3987e309afe00 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -193,6 +193,10 @@ impl generic::Config for Test { let target: Location = AccountId32 { network: None, id: [0; 32] }.into(); Ok((origin, target)) } + + fn barrier_check() -> Result<::RuntimeCall, BenchmarkError> { + Ok(frame_system::Call::remark_with_event { remark: vec![] }.into()) + } } #[cfg(feature = "runtime-benchmarks")] diff --git a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs index df0996a66f210..7c7d1f7f2244d 100644 --- a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs @@ -2136,6 +2136,10 @@ impl_runtime_apis! { Location::new(1, [Parachain(1001), AccountId32 { id: [111u8; 32], network: None }]), )) } + + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/substrate/frame/staking-async/runtimes/rc/src/lib.rs b/substrate/frame/staking-async/runtimes/rc/src/lib.rs index 9837448fe3827..7f2eb1e2fca9a 100644 --- a/substrate/frame/staking-async/runtimes/rc/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/rc/src/lib.rs @@ -2897,6 +2897,10 @@ sp_api::impl_runtime_apis! { let target = Location::new(0, [Parachain(1000), AccountId32 { id: [128u8; 32], network: None }]); Ok((origin, target)) } + + fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; From c86a29aab3c052a2ff35abfe036e259a4ee46874 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Mon, 22 Sep 2025 09:51:36 +0100 Subject: [PATCH 03/50] Add TODO placeholder --- .../assets/asset-hub-westend/src/lib.rs | 2 +- .../src/generic/benchmarking.rs | 17 +++++++++++++++++ .../pallet-xcm-benchmarks/src/generic/mock.rs | 3 ++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 2295c11924aa4..30dfb19a8c40a 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2121,7 +2121,7 @@ pallet_revive::impl_runtime_apis_plus_revive!( fn nominations_quota(balance: Balance) -> u32 { Staking::api_nominations_quota(balance) } - + fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page { Staking::api_eras_stakers_page_count(era, account) } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index aefbada7429dd..ffd695d3c5ecd 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -961,6 +961,23 @@ mod benchmarks { Ok(()) } + #[benchmark] + fn barrier_check() -> Result<(), BenchmarkError> { + // TODO: implement a benchmark for barrier check + let (origin, target) = T::alias_origin().map_err(|_| BenchmarkError::Skip)?; + + let mut executor = new_executor::(origin); + + let instruction = Instruction::AliasOrigin(target.clone()); + let xcm = Xcm(vec![instruction]); + #[block] + { + executor.bench_process(xcm)?; + } + assert_eq!(executor.origin(), &Some(target)); + Ok(()) + } + impl_benchmark_test_suite!( Pallet, crate::generic::mock::new_test_ext(), diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 3987e309afe00..4484e0d0e1845 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -195,7 +195,8 @@ impl generic::Config for Test { } fn barrier_check() -> Result<::RuntimeCall, BenchmarkError> { - Ok(frame_system::Call::remark_with_event { remark: vec![] }.into()) + // TODO: implement a benchmark for barrier check + Err(BenchmarkError::Skip) } } From 7b6a77f5a801e99654154b1a82378a8c72fc162e Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Mon, 22 Sep 2025 10:22:39 +0100 Subject: [PATCH 04/50] Update barrier_check signature --- .../runtimes/assets/asset-hub-rococo/src/lib.rs | 2 +- .../runtimes/assets/asset-hub-westend/src/lib.rs | 2 +- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 2 +- .../runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs | 2 +- .../runtimes/collectives/collectives-westend/src/lib.rs | 2 +- .../runtimes/coretime/coretime-rococo/src/lib.rs | 2 +- .../runtimes/coretime/coretime-westend/src/lib.rs | 2 +- .../parachains/runtimes/people/people-rococo/src/lib.rs | 2 +- .../parachains/runtimes/people/people-westend/src/lib.rs | 2 +- polkadot/runtime/rococo/src/lib.rs | 2 +- polkadot/runtime/westend/src/lib.rs | 2 +- .../pallet-xcm-benchmarks/src/generic/benchmarking.rs | 9 ++++----- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 5 ++--- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 7 ++++--- .../frame/staking-async/runtimes/parachain/src/lib.rs | 2 +- substrate/frame/staking-async/runtimes/rc/src/lib.rs | 2 +- 16 files changed, 23 insertions(+), 24 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 1ca2bda1c5e40..1e3b59a01c55a 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -2016,7 +2016,7 @@ impl_runtime_apis! { )) } - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + fn barrier_check() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 30dfb19a8c40a..4907a945d7913 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2562,7 +2562,7 @@ pallet_revive::impl_runtime_apis_plus_revive!( )) } - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + fn barrier_check() -> Result>, BenchmarkError> { // TODO: implement a benchmark for barrier check Err(BenchmarkError::Skip) } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index ce45fccf2288f..247427c8d22d1 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -1325,7 +1325,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + fn barrier_check() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index dd65a2d21cd1d..68e08e159828d 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -1271,7 +1271,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + fn barrier_check() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index d6cca3f83d755..9b7dcf69b8f91 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -1312,7 +1312,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + fn barrier_check() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs index 96557d977a1d1..1cdad5991b94e 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs @@ -1144,7 +1144,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + fn barrier_check() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index 34d50a827d449..c21243b215d02 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -1170,7 +1170,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + fn barrier_check() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs index d2626c59ee29b..ba09eb19894a3 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs @@ -1076,7 +1076,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + fn barrier_check() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs index 7676b8116cb23..130341b807189 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs @@ -1103,7 +1103,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + fn barrier_check() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index ad37666e0e28b..61c0c5d263cfe 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -2684,7 +2684,7 @@ sp_api::impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + fn barrier_check() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 9e15d308ad3f6..b8e902f43e470 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -3062,7 +3062,7 @@ sp_api::impl_runtime_apis! { Ok((origin, target)) } - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + fn barrier_check() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index ffd695d3c5ecd..a4d5102e6f2ce 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -964,17 +964,16 @@ mod benchmarks { #[benchmark] fn barrier_check() -> Result<(), BenchmarkError> { // TODO: implement a benchmark for barrier check - let (origin, target) = T::alias_origin().map_err(|_| BenchmarkError::Skip)?; + let instructions = T::barrier_check().map_err(|_| BenchmarkError::Skip)?; - let mut executor = new_executor::(origin); + let mut executor = new_executor::(Default::default()); - let instruction = Instruction::AliasOrigin(target.clone()); - let xcm = Xcm(vec![instruction]); + let xcm = Xcm(instructions); #[block] { executor.bench_process(xcm)?; } - assert_eq!(executor.origin(), &Some(target)); + // TODO: add verification that barrier check was done Ok(()) } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 4484e0d0e1845..38bcc4a4697e5 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -194,9 +194,8 @@ impl generic::Config for Test { Ok((origin, target)) } - fn barrier_check() -> Result<::RuntimeCall, BenchmarkError> { - // TODO: implement a benchmark for barrier check - Err(BenchmarkError::Skip) + fn barrier_check() -> Result>, BenchmarkError> { + Ok(Xcm(vec![])) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index b52f52ad78ce0..10bb657fe9ceb 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -28,6 +28,7 @@ pub mod pallet { use sp_runtime::traits::Dispatchable; use xcm::latest::{ Asset, Assets, InteriorLocation, Junction, Location, NetworkId, Response, WeightLimit, + Instruction, Xcm }; #[pallet::config] @@ -97,13 +98,13 @@ pub mod pallet { /// If set to `Err`, benchmarks which rely on a universal alias will be skipped. fn alias_origin() -> Result<(Location, Location), BenchmarkError>; - /// A `RuntimeCall` that is checked by the XCM executor's barrier logic. + /// An XCM used to exercise the barrier logic in benchmarks. /// - /// This represents a call used to benchmark the cost of barrier evaluation in both + /// This represents a call used to benchmark the cost of barrier evaluation in both+ /// acceptance and rejection cases. /// /// If set to `Err`, benchmarks which rely on a `barrier_check` will be skipped. - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError>; + fn barrier_check() -> Result>, BenchmarkError>; /// Returns a valid pallet info for `ExpectPallet` or `QueryPallet` benchmark. /// diff --git a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs index 819bedd5c8d6f..f686a46a3bb48 100644 --- a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs @@ -2133,7 +2133,7 @@ impl_runtime_apis! { )) } - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + fn barrier_check() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/substrate/frame/staking-async/runtimes/rc/src/lib.rs b/substrate/frame/staking-async/runtimes/rc/src/lib.rs index 1f11771c88bdf..2b6e69dbd894a 100644 --- a/substrate/frame/staking-async/runtimes/rc/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/rc/src/lib.rs @@ -2957,7 +2957,7 @@ sp_api::impl_runtime_apis! { Ok((origin, target)) } - fn barrier_check() -> Result<>::RuntimeCall, BenchmarkError> { + fn barrier_check() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } From 76fdb0bf44e44b4863d183430a6931841631927a Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Mon, 22 Sep 2025 10:36:12 +0100 Subject: [PATCH 05/50] Update barrier_check() --- .../xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index a4d5102e6f2ce..510ca354fced9 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -963,17 +963,16 @@ mod benchmarks { #[benchmark] fn barrier_check() -> Result<(), BenchmarkError> { - // TODO: implement a benchmark for barrier check - let instructions = T::barrier_check().map_err(|_| BenchmarkError::Skip)?; + let xmc = T::barrier_check().map_err(|_| BenchmarkError::Skip)?; let mut executor = new_executor::(Default::default()); - let xcm = Xcm(instructions); #[block] { executor.bench_process(xcm)?; } - // TODO: add verification that barrier check was done + let err = executor.error().expect("Error should exist after barrier rejection"); + assert_eq!(err, xcm::latest::Error::Barrier); Ok(()) } From 8e8842eea4c49e6cf36f42fd7f506115743ec337 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Mon, 22 Sep 2025 12:54:54 +0100 Subject: [PATCH 06/50] Fix fmt --- .../parachains/runtimes/assets/asset-hub-westend/src/lib.rs | 2 +- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 4907a945d7913..dd54dcc63b7f2 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2121,7 +2121,7 @@ pallet_revive::impl_runtime_apis_plus_revive!( fn nominations_quota(balance: Balance) -> u32 { Staking::api_nominations_quota(balance) } - + fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page { Staking::api_eras_stakers_page_count(era, account) } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index 10bb657fe9ceb..15e5e8cf472b7 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -27,8 +27,8 @@ pub mod pallet { use frame_support::{dispatch::GetDispatchInfo, pallet_prelude::Encode}; use sp_runtime::traits::Dispatchable; use xcm::latest::{ - Asset, Assets, InteriorLocation, Junction, Location, NetworkId, Response, WeightLimit, - Instruction, Xcm + Asset, Assets, Instruction, InteriorLocation, Junction, Location, NetworkId, Response, + WeightLimit, Xcm, }; #[pallet::config] From d4e690cd672833cf8bd699029eedd38a8733280e Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Mon, 22 Sep 2025 13:48:41 +0100 Subject: [PATCH 07/50] Add XCM instructions --- .../runtimes/assets/asset-hub-westend/src/lib.rs | 14 ++++++++++++-- .../src/generic/benchmarking.rs | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index dd54dcc63b7f2..556cd088fd780 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2563,8 +2563,18 @@ pallet_revive::impl_runtime_apis_plus_revive!( } fn barrier_check() -> Result>, BenchmarkError> { - // TODO: implement a benchmark for barrier check - Err(BenchmarkError::Skip) + let xcm = + Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( + Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( + Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![ + SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( + Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))]), + )]))])), + ]))]))]), + )]))]))]), + )]))]))]); + + Ok(xcm) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 510ca354fced9..b8dce88a3e35b 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -969,7 +969,7 @@ mod benchmarks { #[block] { - executor.bench_process(xcm)?; + let _ = executor.bench_process(xcm); } let err = executor.error().expect("Error should exist after barrier rejection"); assert_eq!(err, xcm::latest::Error::Barrier); From 6fe0cd9d50530e0afb31b876d1456f5a9f588773 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 13:09:48 +0000 Subject: [PATCH 08/50] Update from github-actions[bot] running command 'prdoc --audience runtime_dev --bump patch' --- prdoc/pr_9808.prdoc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 prdoc/pr_9808.prdoc diff --git a/prdoc/pr_9808.prdoc b/prdoc/pr_9808.prdoc new file mode 100644 index 0000000000000..63d021c90fca6 --- /dev/null +++ b/prdoc/pr_9808.prdoc @@ -0,0 +1,29 @@ +title: Add Barrier Benchmark for Accurate XCM Weight Accounting in Early Rejections +doc: +- audience: Runtime Dev + description: This PR improves weight accounting for barrier rejections. +crates: +- name: pallet-xcm-benchmarks + bump: patch +- name: asset-hub-rococo-runtime + bump: patch +- name: asset-hub-westend-runtime + bump: patch +- name: bridge-hub-rococo-runtime + bump: patch +- name: bridge-hub-westend-runtime + bump: patch +- name: collectives-westend-runtime + bump: patch +- name: coretime-rococo-runtime + bump: patch +- name: coretime-westend-runtime + bump: patch +- name: people-rococo-runtime + bump: patch +- name: people-westend-runtime + bump: patch +- name: rococo-runtime + bump: patch +- name: westend-runtime + bump: patch From 7037781ef3c0215af04a7f05553850b7d1c8115f Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Mon, 22 Sep 2025 14:49:47 +0100 Subject: [PATCH 09/50] Fix tests --- polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index b8dce88a3e35b..244e86233ae16 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -972,7 +972,7 @@ mod benchmarks { let _ = executor.bench_process(xcm); } let err = executor.error().expect("Error should exist after barrier rejection"); - assert_eq!(err, xcm::latest::Error::Barrier); + assert_eq!(err.1, xcm::latest::Error::Barrier); Ok(()) } From 8e5975fe17f32d2382d3e4f3079a13c3f3d81a8a Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Mon, 22 Sep 2025 16:03:13 +0200 Subject: [PATCH 10/50] Update polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs --- polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 244e86233ae16..a14dc56afb165 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -963,7 +963,7 @@ mod benchmarks { #[benchmark] fn barrier_check() -> Result<(), BenchmarkError> { - let xmc = T::barrier_check().map_err(|_| BenchmarkError::Skip)?; + let xcm = T::barrier_check().map_err(|_| BenchmarkError::Skip)?; let mut executor = new_executor::(Default::default()); From 23cb0ce643e0cd4ba0f71d84eb0a8ab31aa21914 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Mon, 22 Sep 2025 16:08:10 +0100 Subject: [PATCH 11/50] Address the comments --- .../parachains/runtimes/assets/asset-hub-rococo/src/lib.rs | 2 +- .../parachains/runtimes/assets/asset-hub-westend/src/lib.rs | 2 +- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 2 +- .../runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs | 2 +- .../runtimes/collectives/collectives-westend/src/lib.rs | 2 +- .../parachains/runtimes/coretime/coretime-rococo/src/lib.rs | 2 +- .../parachains/runtimes/coretime/coretime-westend/src/lib.rs | 2 +- cumulus/parachains/runtimes/people/people-rococo/src/lib.rs | 2 +- cumulus/parachains/runtimes/people/people-westend/src/lib.rs | 2 +- polkadot/runtime/rococo/src/lib.rs | 2 +- polkadot/runtime/westend/src/lib.rs | 2 +- .../xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 2 +- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 2 +- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 4 ++-- substrate/frame/staking-async/runtimes/parachain/src/lib.rs | 2 +- substrate/frame/staking-async/runtimes/rc/src/lib.rs | 2 +- 16 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 1e3b59a01c55a..088d1447cefa0 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -2016,7 +2016,7 @@ impl_runtime_apis! { )) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 556cd088fd780..8950d3c4f8076 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2562,7 +2562,7 @@ pallet_revive::impl_runtime_apis_plus_revive!( )) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { let xcm = Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 247427c8d22d1..f0421baf4a928 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -1325,7 +1325,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index 68e08e159828d..756835730bfdd 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -1271,7 +1271,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index 9b7dcf69b8f91..698333318fcbf 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -1312,7 +1312,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs index 1cdad5991b94e..454bf19328aa3 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs @@ -1144,7 +1144,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index c21243b215d02..c6f2e3a429754 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -1170,7 +1170,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs index ba09eb19894a3..12ee4d132a0c2 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs @@ -1076,7 +1076,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs index 130341b807189..a529ec48b6dc8 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs @@ -1103,7 +1103,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 61c0c5d263cfe..bd751157d74f0 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -2684,7 +2684,7 @@ sp_api::impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 77511f237437c..a93a22c7791db 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -3072,7 +3072,7 @@ sp_api::impl_runtime_apis! { Ok((origin, target)) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 244e86233ae16..58b4d260d15ae 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -963,7 +963,7 @@ mod benchmarks { #[benchmark] fn barrier_check() -> Result<(), BenchmarkError> { - let xmc = T::barrier_check().map_err(|_| BenchmarkError::Skip)?; + let xcm = T::worst_case_for_not_passing_barrier().map_err(|_| BenchmarkError::Skip)?; let mut executor = new_executor::(Default::default()); diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 38bcc4a4697e5..e70f500fc8c92 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -194,7 +194,7 @@ impl generic::Config for Test { Ok((origin, target)) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Ok(Xcm(vec![])) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index 15e5e8cf472b7..70609f6387917 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -100,11 +100,11 @@ pub mod pallet { /// An XCM used to exercise the barrier logic in benchmarks. /// - /// This represents a call used to benchmark the cost of barrier evaluation in both+ + /// This represents a call used to benchmark the cost of barrier evaluation in both /// acceptance and rejection cases. /// /// If set to `Err`, benchmarks which rely on a `barrier_check` will be skipped. - fn barrier_check() -> Result>, BenchmarkError>; + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError>; /// Returns a valid pallet info for `ExpectPallet` or `QueryPallet` benchmark. /// diff --git a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs index f686a46a3bb48..8e70d4890766b 100644 --- a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs @@ -2133,7 +2133,7 @@ impl_runtime_apis! { )) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/substrate/frame/staking-async/runtimes/rc/src/lib.rs b/substrate/frame/staking-async/runtimes/rc/src/lib.rs index 2b6e69dbd894a..bf93e02fbe187 100644 --- a/substrate/frame/staking-async/runtimes/rc/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/rc/src/lib.rs @@ -2957,7 +2957,7 @@ sp_api::impl_runtime_apis! { Ok((origin, target)) } - fn barrier_check() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } From d7083351b64b34474ac32ba2177482c0e1e5615c Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Mon, 22 Sep 2025 16:40:48 +0100 Subject: [PATCH 12/50] Change to RuntimeCall --- .../runtimes/assets/asset-hub-rococo/src/lib.rs | 2 +- .../runtimes/assets/asset-hub-westend/src/lib.rs | 9 ++++----- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 2 +- .../runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs | 2 +- .../runtimes/collectives/collectives-westend/src/lib.rs | 2 +- .../runtimes/coretime/coretime-rococo/src/lib.rs | 2 +- .../runtimes/coretime/coretime-westend/src/lib.rs | 2 +- .../parachains/runtimes/people/people-rococo/src/lib.rs | 2 +- .../parachains/runtimes/people/people-westend/src/lib.rs | 2 +- polkadot/runtime/rococo/src/lib.rs | 2 +- polkadot/runtime/westend/src/lib.rs | 2 +- .../pallet-xcm-benchmarks/src/generic/benchmarking.rs | 5 +++-- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 4 ++-- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 5 ++--- .../frame/staking-async/runtimes/parachain/src/lib.rs | 2 +- substrate/frame/staking-async/runtimes/rc/src/lib.rs | 2 +- 16 files changed, 23 insertions(+), 24 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 088d1447cefa0..38d7e3a129003 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -2016,7 +2016,7 @@ impl_runtime_apis! { )) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 8950d3c4f8076..8cca1b4e2223e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2562,9 +2562,8 @@ pallet_revive::impl_runtime_apis_plus_revive!( )) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { - let xcm = - Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( + fn worst_case_for_not_passing_barrier() -> Result { + let instructions = vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![ SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( @@ -2572,9 +2571,9 @@ pallet_revive::impl_runtime_apis_plus_revive!( )]))])), ]))]))]), )]))]))]), - )]))]))]); + )]))]))]; - Ok(xcm) + Ok(instructions) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index f0421baf4a928..37548327deba6 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -1325,7 +1325,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index 756835730bfdd..730967a27c269 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -1271,7 +1271,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index 698333318fcbf..b5e37bbc860e9 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -1312,7 +1312,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs index 454bf19328aa3..df451a8b8c0f4 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs @@ -1144,7 +1144,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index c6f2e3a429754..f278bb26eb858 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -1170,7 +1170,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs index 12ee4d132a0c2..228043affa759 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs @@ -1076,7 +1076,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs index a529ec48b6dc8..b303c4af51e75 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs @@ -1103,7 +1103,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result { Err(BenchmarkError::Skip) } } diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index bd751157d74f0..916e06ae6178a 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -2684,7 +2684,7 @@ sp_api::impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result { Err(BenchmarkError::Skip) } } diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index a93a22c7791db..e7a4aa9a1e554 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -3072,7 +3072,7 @@ sp_api::impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result { Err(BenchmarkError::Skip) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 58b4d260d15ae..85badda93ef15 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -963,13 +963,14 @@ mod benchmarks { #[benchmark] fn barrier_check() -> Result<(), BenchmarkError> { - let xcm = T::worst_case_for_not_passing_barrier().map_err(|_| BenchmarkError::Skip)?; + let instruments = + T::worst_case_for_not_passing_barrier().map_err(|_| BenchmarkError::Skip)?; let mut executor = new_executor::(Default::default()); #[block] { - let _ = executor.bench_process(xcm); + let _ = executor.bench_process(Xcm(instruments.into())); } let err = executor.error().expect("Error should exist after barrier rejection"); assert_eq!(err.1, xcm::latest::Error::Barrier); diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index e70f500fc8c92..ff916be1881c6 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -194,8 +194,8 @@ impl generic::Config for Test { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { - Ok(Xcm(vec![])) + fn worst_case_for_not_passing_barrier() -> Result<::RuntimeCall, BenchmarkError> { + Ok(vec![].into()) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index 70609f6387917..d8754a9bc8ac7 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -27,8 +27,7 @@ pub mod pallet { use frame_support::{dispatch::GetDispatchInfo, pallet_prelude::Encode}; use sp_runtime::traits::Dispatchable; use xcm::latest::{ - Asset, Assets, Instruction, InteriorLocation, Junction, Location, NetworkId, Response, - WeightLimit, Xcm, + Asset, Assets, InteriorLocation, Junction, Location, NetworkId, Response, WeightLimit, }; #[pallet::config] @@ -104,7 +103,7 @@ pub mod pallet { /// acceptance and rejection cases. /// /// If set to `Err`, benchmarks which rely on a `barrier_check` will be skipped. - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError>; + fn worst_case_for_not_passing_barrier() -> Result<>::RuntimeCall, BenchmarkError>; /// Returns a valid pallet info for `ExpectPallet` or `QueryPallet` benchmark. /// diff --git a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs index 8e70d4890766b..6e99660e0609d 100644 --- a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs @@ -2133,7 +2133,7 @@ impl_runtime_apis! { )) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result { Err(BenchmarkError::Skip) } } diff --git a/substrate/frame/staking-async/runtimes/rc/src/lib.rs b/substrate/frame/staking-async/runtimes/rc/src/lib.rs index bf93e02fbe187..3a19ad7fd0c8c 100644 --- a/substrate/frame/staking-async/runtimes/rc/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/rc/src/lib.rs @@ -2957,7 +2957,7 @@ sp_api::impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + fn worst_case_for_not_passing_barrier() -> Result { Err(BenchmarkError::Skip) } } From bbd27894b550b4bf08c91a545a9aee0f7378be6e Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Mon, 22 Sep 2025 16:42:27 +0100 Subject: [PATCH 13/50] Fix fmt --- .../xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 5 ++--- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 3 ++- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 85badda93ef15..58b4d260d15ae 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -963,14 +963,13 @@ mod benchmarks { #[benchmark] fn barrier_check() -> Result<(), BenchmarkError> { - let instruments = - T::worst_case_for_not_passing_barrier().map_err(|_| BenchmarkError::Skip)?; + let xcm = T::worst_case_for_not_passing_barrier().map_err(|_| BenchmarkError::Skip)?; let mut executor = new_executor::(Default::default()); #[block] { - let _ = executor.bench_process(Xcm(instruments.into())); + let _ = executor.bench_process(xcm); } let err = executor.error().expect("Error should exist after barrier rejection"); assert_eq!(err.1, xcm::latest::Error::Barrier); diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index ff916be1881c6..b8cfdbdd735aa 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -194,7 +194,8 @@ impl generic::Config for Test { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result<::RuntimeCall, BenchmarkError> { + fn worst_case_for_not_passing_barrier( + ) -> Result<::RuntimeCall, BenchmarkError> { Ok(vec![].into()) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index d8754a9bc8ac7..2685409650e8c 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -103,7 +103,8 @@ pub mod pallet { /// acceptance and rejection cases. /// /// If set to `Err`, benchmarks which rely on a `barrier_check` will be skipped. - fn worst_case_for_not_passing_barrier() -> Result<>::RuntimeCall, BenchmarkError>; + fn worst_case_for_not_passing_barrier( + ) -> Result<>::RuntimeCall, BenchmarkError>; /// Returns a valid pallet info for `ExpectPallet` or `QueryPallet` benchmark. /// From f8fcd399d85a36126a2ea1760d742a7264e037ff Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Mon, 22 Sep 2025 16:52:31 +0100 Subject: [PATCH 14/50] Revert to Xcm> --- .../runtimes/assets/asset-hub-rococo/src/lib.rs | 2 +- .../runtimes/assets/asset-hub-westend/src/lib.rs | 9 +++++---- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 2 +- .../runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs | 2 +- .../runtimes/collectives/collectives-westend/src/lib.rs | 2 +- .../runtimes/coretime/coretime-rococo/src/lib.rs | 2 +- .../runtimes/coretime/coretime-westend/src/lib.rs | 2 +- .../parachains/runtimes/people/people-rococo/src/lib.rs | 2 +- .../parachains/runtimes/people/people-westend/src/lib.rs | 2 +- polkadot/runtime/rococo/src/lib.rs | 2 +- polkadot/runtime/westend/src/lib.rs | 2 +- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 5 ++--- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 5 ++--- .../frame/staking-async/runtimes/parachain/src/lib.rs | 2 +- substrate/frame/staking-async/runtimes/rc/src/lib.rs | 2 +- 15 files changed, 21 insertions(+), 22 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 38d7e3a129003..aca9c5fc11c4b 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -2016,7 +2016,7 @@ impl_runtime_apis! { )) } - fn worst_case_for_not_passing_barrier() -> Result { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 8cca1b4e2223e..8950d3c4f8076 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2562,8 +2562,9 @@ pallet_revive::impl_runtime_apis_plus_revive!( )) } - fn worst_case_for_not_passing_barrier() -> Result { - let instructions = vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + let xcm = + Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![ SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( @@ -2571,9 +2572,9 @@ pallet_revive::impl_runtime_apis_plus_revive!( )]))])), ]))]))]), )]))]))]), - )]))]))]; + )]))]))]); - Ok(instructions) + Ok(xcm) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 37548327deba6..c7b33769aa7e3 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -1325,7 +1325,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn worst_case_for_not_passing_barrier() -> Result { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index 730967a27c269..ab109266889c9 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -1271,7 +1271,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index b5e37bbc860e9..50ec161fac078 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -1312,7 +1312,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs index df451a8b8c0f4..a0e3e1ac52f59 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs @@ -1144,7 +1144,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn worst_case_for_not_passing_barrier() -> Result { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index f278bb26eb858..235c3a6be7891 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -1170,7 +1170,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs index 228043affa759..c47d34b397069 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs @@ -1076,7 +1076,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn worst_case_for_not_passing_barrier() -> Result { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs index b303c4af51e75..e016ba2f8c098 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs @@ -1103,7 +1103,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { Err(BenchmarkError::Skip) } } diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 916e06ae6178a..529f73c3a8b60 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -2684,7 +2684,7 @@ sp_api::impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn worst_case_for_not_passing_barrier() -> Result { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { Err(BenchmarkError::Skip) } } diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index e7a4aa9a1e554..96d0e6542e798 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -3072,7 +3072,7 @@ sp_api::impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { Err(BenchmarkError::Skip) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index b8cfdbdd735aa..e70f500fc8c92 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -194,9 +194,8 @@ impl generic::Config for Test { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier( - ) -> Result<::RuntimeCall, BenchmarkError> { - Ok(vec![].into()) + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + Ok(Xcm(vec![])) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index 2685409650e8c..3d4659d0d8c7e 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -27,7 +27,7 @@ pub mod pallet { use frame_support::{dispatch::GetDispatchInfo, pallet_prelude::Encode}; use sp_runtime::traits::Dispatchable; use xcm::latest::{ - Asset, Assets, InteriorLocation, Junction, Location, NetworkId, Response, WeightLimit, + Asset, Assets, InteriorLocation, Junction, Location, NetworkId, Response, WeightLimit, Instruction, Xcm }; #[pallet::config] @@ -103,8 +103,7 @@ pub mod pallet { /// acceptance and rejection cases. /// /// If set to `Err`, benchmarks which rely on a `barrier_check` will be skipped. - fn worst_case_for_not_passing_barrier( - ) -> Result<>::RuntimeCall, BenchmarkError>; + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError>; /// Returns a valid pallet info for `ExpectPallet` or `QueryPallet` benchmark. /// diff --git a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs index 6e99660e0609d..b4981168ddcf9 100644 --- a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs @@ -2133,7 +2133,7 @@ impl_runtime_apis! { )) } - fn worst_case_for_not_passing_barrier() -> Result { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { Err(BenchmarkError::Skip) } } diff --git a/substrate/frame/staking-async/runtimes/rc/src/lib.rs b/substrate/frame/staking-async/runtimes/rc/src/lib.rs index 3a19ad7fd0c8c..41ac4df5c9256 100644 --- a/substrate/frame/staking-async/runtimes/rc/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/rc/src/lib.rs @@ -2957,7 +2957,7 @@ sp_api::impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { Err(BenchmarkError::Skip) } } From a976cdbd7504cf2ae30f64bd5a308820dedf7b58 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Tue, 23 Sep 2025 09:19:32 +0100 Subject: [PATCH 15/50] Fix bugs --- cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs | 2 +- .../parachains/runtimes/assets/asset-hub-westend/src/lib.rs | 2 ++ .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 2 +- .../runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs | 2 +- .../runtimes/collectives/collectives-westend/src/lib.rs | 2 +- .../parachains/runtimes/coretime/coretime-rococo/src/lib.rs | 2 +- .../parachains/runtimes/coretime/coretime-westend/src/lib.rs | 2 +- cumulus/parachains/runtimes/people/people-rococo/src/lib.rs | 2 +- cumulus/parachains/runtimes/people/people-westend/src/lib.rs | 2 +- polkadot/runtime/rococo/src/lib.rs | 2 +- polkadot/runtime/westend/src/lib.rs | 2 +- polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 2 +- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 3 ++- substrate/frame/staking-async/runtimes/parachain/src/lib.rs | 2 +- substrate/frame/staking-async/runtimes/rc/src/lib.rs | 2 +- 15 files changed, 17 insertions(+), 14 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index aca9c5fc11c4b..088d1447cefa0 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -2016,7 +2016,7 @@ impl_runtime_apis! { )) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 8950d3c4f8076..93a3d85f914af 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2563,6 +2563,8 @@ pallet_revive::impl_runtime_apis_plus_revive!( } fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + use xcm::latest::prelude::ClearOrigin; + let xcm = Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index c7b33769aa7e3..f0421baf4a928 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -1325,7 +1325,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index ab109266889c9..756835730bfdd 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -1271,7 +1271,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index 50ec161fac078..698333318fcbf 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -1312,7 +1312,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs index a0e3e1ac52f59..454bf19328aa3 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs @@ -1144,7 +1144,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index 235c3a6be7891..c6f2e3a429754 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -1170,7 +1170,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs index c47d34b397069..12ee4d132a0c2 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs @@ -1076,7 +1076,7 @@ impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs index e016ba2f8c098..a529ec48b6dc8 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs @@ -1103,7 +1103,7 @@ impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 529f73c3a8b60..bd751157d74f0 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -2684,7 +2684,7 @@ sp_api::impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 96d0e6542e798..a93a22c7791db 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -3072,7 +3072,7 @@ sp_api::impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 58b4d260d15ae..f7b7c2d1c7b72 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -969,7 +969,7 @@ mod benchmarks { #[block] { - let _ = executor.bench_process(xcm); + let _ = executor.bench_process(xcm.into()); } let err = executor.error().expect("Error should exist after barrier rejection"); assert_eq!(err.1, xcm::latest::Error::Barrier); diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index 3d4659d0d8c7e..70609f6387917 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -27,7 +27,8 @@ pub mod pallet { use frame_support::{dispatch::GetDispatchInfo, pallet_prelude::Encode}; use sp_runtime::traits::Dispatchable; use xcm::latest::{ - Asset, Assets, InteriorLocation, Junction, Location, NetworkId, Response, WeightLimit, Instruction, Xcm + Asset, Assets, Instruction, InteriorLocation, Junction, Location, NetworkId, Response, + WeightLimit, Xcm, }; #[pallet::config] diff --git a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs index b4981168ddcf9..8e70d4890766b 100644 --- a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs @@ -2133,7 +2133,7 @@ impl_runtime_apis! { )) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } diff --git a/substrate/frame/staking-async/runtimes/rc/src/lib.rs b/substrate/frame/staking-async/runtimes/rc/src/lib.rs index 41ac4df5c9256..bf93e02fbe187 100644 --- a/substrate/frame/staking-async/runtimes/rc/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/rc/src/lib.rs @@ -2957,7 +2957,7 @@ sp_api::impl_runtime_apis! { Ok((origin, target)) } - fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { { + fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { Err(BenchmarkError::Skip) } } From 0dca870a4afdf3d00d9b5ec47b8a027d7821d66e Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Tue, 23 Sep 2025 16:39:57 +0100 Subject: [PATCH 16/50] Fix tests --- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index e70f500fc8c92..63c922be30efe 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -195,7 +195,8 @@ impl generic::Config for Test { } fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { - Ok(Xcm(vec![])) + // No barrier test + Err(BenchmarkError::Skip) } } From 6780bfaf54d1154e66a71e83b97b04d08a028050 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Tue, 23 Sep 2025 16:49:12 +0100 Subject: [PATCH 17/50] Fix tests --- .../parachains/runtimes/assets/asset-hub-rococo/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 088d1447cefa0..ffc804bd4297a 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -100,8 +100,9 @@ use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; #[cfg(feature = "runtime-benchmarks")] use xcm::latest::prelude::{ - Asset, Assets as XcmAssets, Fungible, Here, InteriorLocation, Junction, Junction::*, Location, - NetworkId, NonFungible, ParentThen, Response, WeightLimit, XCM_VERSION, + Asset, Assets as XcmAssets, Fungible, Here, Instruction, InteriorLocation, Junction, + Junction::*, Location, NetworkId, NonFungible, ParentThen, Response, WeightLimit, Xcm, + XCM_VERSION, }; use xcm::{ latest::prelude::{AssetId, BodyId}, From 635d6bb72f20494c87bd07f63ffb910811d3d124 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Wed, 24 Sep 2025 10:12:43 +0100 Subject: [PATCH 18/50] Fix tests --- cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 93a3d85f914af..337dc6f711ac1 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -121,7 +121,7 @@ use frame_support::traits::PalletInfoAccess; #[cfg(feature = "runtime-benchmarks")] use xcm::latest::prelude::{ Asset, Assets as XcmAssets, Fungible, Here, InteriorLocation, Junction, Junction::*, Location, - NetworkId, NonFungible, ParentThen, Response, WeightLimit, XCM_VERSION, + NetworkId, NonFungible, ParentThen, Response, WeightLimit, XCM_VERSION, Xcm, Instruction, SetTopic, ClearOrigin }; use xcm_runtime_apis::{ From 98739eb95959280e7579faf84fec429e5b7d1320 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Wed, 24 Sep 2025 10:47:32 +0100 Subject: [PATCH 19/50] Fix tests --- cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 337dc6f711ac1..6d71044fa4ad0 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -121,7 +121,7 @@ use frame_support::traits::PalletInfoAccess; #[cfg(feature = "runtime-benchmarks")] use xcm::latest::prelude::{ Asset, Assets as XcmAssets, Fungible, Here, InteriorLocation, Junction, Junction::*, Location, - NetworkId, NonFungible, ParentThen, Response, WeightLimit, XCM_VERSION, Xcm, Instruction, SetTopic, ClearOrigin + NetworkId, NonFungible, ParentThen, Response, WeightLimit, XCM_VERSION, Xcm, Instruction, ClearOrigin, SetAppendix }; use xcm_runtime_apis::{ From 1311d5493371447513bba920e2e5f9174fc4ab86 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Wed, 24 Sep 2025 11:00:34 +0100 Subject: [PATCH 20/50] Update PRDoc --- .../runtimes/assets/asset-hub-westend/src/lib.rs | 5 +++-- prdoc/pr_9808.prdoc | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 6d71044fa4ad0..6ce9002750708 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -120,8 +120,9 @@ use frame_support::traits::PalletInfoAccess; #[cfg(feature = "runtime-benchmarks")] use xcm::latest::prelude::{ - Asset, Assets as XcmAssets, Fungible, Here, InteriorLocation, Junction, Junction::*, Location, - NetworkId, NonFungible, ParentThen, Response, WeightLimit, XCM_VERSION, Xcm, Instruction, ClearOrigin, SetAppendix + Asset, Assets as XcmAssets, ClearOrigin, Fungible, Here, Instruction, InteriorLocation, + Junction, Junction::*, Location, NetworkId, NonFungible, ParentThen, Response, SetAppendix, + WeightLimit, Xcm, XCM_VERSION, }; use xcm_runtime_apis::{ diff --git a/prdoc/pr_9808.prdoc b/prdoc/pr_9808.prdoc index 63d021c90fca6..b8106a1acefe0 100644 --- a/prdoc/pr_9808.prdoc +++ b/prdoc/pr_9808.prdoc @@ -3,8 +3,6 @@ doc: - audience: Runtime Dev description: This PR improves weight accounting for barrier rejections. crates: -- name: pallet-xcm-benchmarks - bump: patch - name: asset-hub-rococo-runtime bump: patch - name: asset-hub-westend-runtime @@ -25,5 +23,11 @@ crates: bump: patch - name: rococo-runtime bump: patch -- name: westend-runtime +- name: pallet-staking-async-parachain-runtime + bump: none +- name: pallet-staking-async-rc-runtime + bump: none +- name: pallet-xcm-benchmarks bump: patch +- name: westend-runtime + bump: patch \ No newline at end of file From 7b9a69c78c36e066c2f820fd7506d0891c6febdd Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Wed, 24 Sep 2025 11:05:17 +0100 Subject: [PATCH 21/50] Fix tests --- substrate/frame/staking-async/runtimes/parachain/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs index 8e70d4890766b..5b256ecd67776 100644 --- a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs @@ -95,7 +95,7 @@ use testnet_parachains_constants::westend::{ }; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use xcm::{ - latest::prelude::AssetId, + latest::prelude::{AssetId, Instruction, Xcm}, prelude::{VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm}, }; use xcm_config::{ From 742531a33cc2d2965748a7eca063f4edf798110c Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Wed, 24 Sep 2025 12:02:29 +0100 Subject: [PATCH 22/50] Fix tests --- cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 6ce9002750708..38561b29c87f6 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2564,8 +2564,6 @@ pallet_revive::impl_runtime_apis_plus_revive!( } fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { - use xcm::latest::prelude::ClearOrigin; - let xcm = Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( From c9dc6556117657308ff079da764a3044bbf49921 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Wed, 24 Sep 2025 13:45:55 +0100 Subject: [PATCH 23/50] Fix comments --- .../runtimes/assets/asset-hub-westend/src/lib.rs | 8 +++++--- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 38561b29c87f6..e394fbc085add 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -120,9 +120,9 @@ use frame_support::traits::PalletInfoAccess; #[cfg(feature = "runtime-benchmarks")] use xcm::latest::prelude::{ - Asset, Assets as XcmAssets, ClearOrigin, Fungible, Here, Instruction, InteriorLocation, - Junction, Junction::*, Location, NetworkId, NonFungible, ParentThen, Response, SetAppendix, - WeightLimit, Xcm, XCM_VERSION, + Asset, Assets as XcmAssets, Fungible, Here, Instruction, InteriorLocation, Junction, + Junction::*, Location, NetworkId, NonFungible, ParentThen, Response, WeightLimit, Xcm, + XCM_VERSION, }; use xcm_runtime_apis::{ @@ -2564,6 +2564,8 @@ pallet_revive::impl_runtime_apis_plus_revive!( } fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { + use xcm::latest::prelude::{ClearOrigin, SetAppendix}; + let xcm = Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index 70609f6387917..854efa537c4f8 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -100,10 +100,10 @@ pub mod pallet { /// An XCM used to exercise the barrier logic in benchmarks. /// - /// This represents a call used to benchmark the cost of barrier evaluation in both - /// acceptance and rejection cases. + /// This represents a call used to benchmark the cost of barrier evaluation in rejection + /// cases. /// - /// If set to `Err`, benchmarks which rely on a `barrier_check` will be skipped. + /// If set to `Err`, benchmarks which rely on a barrier check will be skipped. fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError>; /// Returns a valid pallet info for `ExpectPallet` or `QueryPallet` benchmark. From b58152aedd5b24dbcc44c06ad0c8390477fd77cc Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Wed, 24 Sep 2025 14:01:37 +0100 Subject: [PATCH 24/50] Fix imports --- substrate/frame/staking-async/runtimes/parachain/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs index 5b256ecd67776..88aa94995ff78 100644 --- a/substrate/frame/staking-async/runtimes/parachain/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/parachain/src/lib.rs @@ -95,7 +95,7 @@ use testnet_parachains_constants::westend::{ }; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use xcm::{ - latest::prelude::{AssetId, Instruction, Xcm}, + latest::prelude::AssetId, prelude::{VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm}, }; use xcm_config::{ @@ -109,8 +109,8 @@ use frame_support::traits::PalletInfoAccess; #[cfg(feature = "runtime-benchmarks")] use xcm::latest::prelude::{ - Asset, Assets as XcmAssets, Fungible, Here, InteriorLocation, Junction, Junction::*, Location, - NetworkId, NonFungible, Parent, ParentThen, Response, XCM_VERSION, + Asset, Assets as XcmAssets, Fungible, Here, Instruction, InteriorLocation, Junction, + Junction::*, Location, NetworkId, NonFungible, Parent, ParentThen, Response, Xcm, XCM_VERSION, }; use xcm_runtime_apis::{ From 6ba21f927b1935e1c7e331bf45102e3e4002a866 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Wed, 24 Sep 2025 16:42:03 +0100 Subject: [PATCH 25/50] Add tracing --- .../assets/asset-hub-westend/src/lib.rs | 21 ++++++++----------- polkadot/xcm/xcm-builder/src/barriers.rs | 1 + 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index e394fbc085add..8ce8c71d9ece6 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2565,19 +2565,16 @@ pallet_revive::impl_runtime_apis_plus_revive!( fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { use xcm::latest::prelude::{ClearOrigin, SetAppendix}; + use xcm_executor::RECURSION_LIMIT; - let xcm = - Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( - Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( - Xcm(vec![SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![ - SetAppendix(Xcm(vec![SetAppendix(Xcm(vec![SetAppendix( - Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))]), - )]))])), - ]))]))]), - )]))]))]), - )]))]))]); - - Ok(xcm) + let mut nested = Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))]); + for _ in 0..(RECURSION_LIMIT + 1) { + nested = Xcm(vec![SetAppendix(nested)]); + } + + tracing::info!(target: "frame::benchmark::pallet", ?nested, "TESTING"); + + Ok(nested) } } diff --git a/polkadot/xcm/xcm-builder/src/barriers.rs b/polkadot/xcm/xcm-builder/src/barriers.rs index 6152e54d08b02..e1e53e5232dd9 100644 --- a/polkadot/xcm/xcm-builder/src/barriers.rs +++ b/polkadot/xcm/xcm-builder/src/barriers.rs @@ -611,6 +611,7 @@ impl DenyRecursively { properties: &mut Properties, ) -> Result, ProcessMessageError> { // Initialise recursion counter for this execution context. + tracing::info!(target: "frame::benchmark::pallet", ?origin, ?xcm, ?max_weight, ?properties, "TESTING"); recursion_count::using_once(&mut 1, || { // Prevent stack overflow by enforcing a recursion depth limit. recursion_count::with(|count| { From 62c3b03b9ee3f37431763b5bfe8b6590d76806b9 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Wed, 24 Sep 2025 16:58:33 +0100 Subject: [PATCH 26/50] Try to add DenyClearOrigin --- .../assets/asset-hub-westend/src/lib.rs | 7 ++- .../pallet-xcm-benchmarks/src/generic/mock.rs | 48 ++++++++++++++----- polkadot/xcm/xcm-executor/src/lib.rs | 1 + 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 8ce8c71d9ece6..b8dc222109204 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2565,12 +2565,11 @@ pallet_revive::impl_runtime_apis_plus_revive!( fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { use xcm::latest::prelude::{ClearOrigin, SetAppendix}; - use xcm_executor::RECURSION_LIMIT; let mut nested = Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))]); - for _ in 0..(RECURSION_LIMIT + 1) { - nested = Xcm(vec![SetAppendix(nested)]); - } + for _ in 0..=(xcm_executor::RECURSION_LIMIT + 1) { + nested = Xcm(vec![SetAppendix(nested)]); + } tracing::info!(target: "frame::benchmark::pallet", ?nested, "TESTING"); diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 63c922be30efe..c03d7a5d3342a 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -16,22 +16,20 @@ //! A mock runtime for XCM benchmarking. +use std::ops::ControlFlow; use crate::{generic, mock::*, *}; use codec::Decode; use frame_support::{ derive_impl, parameter_types, traits::{Contains, Everything, OriginTrait}, }; +use frame_support::traits::ProcessMessageError; use sp_runtime::traits::TrailingZeroInput; -use xcm_builder::{ - test_utils::{ - AssetsInHolding, TestAssetExchanger, TestAssetLocker, TestAssetTrap, - TestSubscriptionService, TestUniversalAliases, - }, - AliasForeignAccountId32, AllowUnpaidExecutionFrom, EnsureDecodableXcm, - FrameTransactionalProcessor, -}; -use xcm_executor::traits::ConvertOrigin; +use xcm_builder::{test_utils::{ + AssetsInHolding, TestAssetExchanger, TestAssetLocker, TestAssetTrap, + TestSubscriptionService, TestUniversalAliases, +}, AliasForeignAccountId32, AllowUnpaidExecutionFrom, CreateMatcher, DenyRecursively, DenyThenTry, EnsureDecodableXcm, FrameTransactionalProcessor, MatchXcm}; +use xcm_executor::traits::{ConvertOrigin, DenyExecution, Properties}; type Block = frame_system::mocking::MockBlock; @@ -78,6 +76,26 @@ impl Contains for OnlyParachains { } } +pub struct DenyClearOrigin; +impl DenyExecution for DenyClearOrigin { + fn deny_execution( + _origin: &Location, + instructions: &mut [Instruction], + _max_weight: Weight, + _properties: &mut Properties, + ) -> Result<(), ProcessMessageError> { + instructions.matcher().match_next_inst_while( + |_| true, + |inst| match inst { + ClearOrigin => Err(ProcessMessageError::Unsupported), + _ => Ok(ControlFlow::Continue(())), + }, + )?; + Ok(()) + } +} + + type Aliasers = AliasForeignAccountId32; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { @@ -89,7 +107,7 @@ impl xcm_executor::Config for XcmConfig { type IsReserve = AllAssetLocationsPass; type IsTeleporter = (); type UniversalLocation = UniversalLocation; - type Barrier = AllowUnpaidExecutionFrom; + type Barrier = DenyThenTry, AllowUnpaidExecutionFrom>; type Weigher = xcm_builder::FixedWeightBounds; type Trader = xcm_builder::FixedRateOfFungible; type ResponseHandler = DevNull; @@ -195,8 +213,14 @@ impl generic::Config for Test { } fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { - // No barrier test - Err(BenchmarkError::Skip) + use xcm::latest::prelude::{ClearOrigin, SetAppendix}; + + let mut nested = Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))]); + for _ in 0..=(xcm_executor::RECURSION_LIMIT + 1) { + nested = Xcm(vec![SetAppendix(nested)]); + } + + Ok(nested) } } diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index b4efab9349a4b..64ca84041dba7 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -260,6 +260,7 @@ impl ExecuteXcm for XcmExecutor Date: Wed, 24 Sep 2025 17:01:22 +0100 Subject: [PATCH 27/50] Fix fmt --- .../pallet-xcm-benchmarks/src/generic/mock.rs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index c03d7a5d3342a..10739891e46c2 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -16,19 +16,22 @@ //! A mock runtime for XCM benchmarking. -use std::ops::ControlFlow; use crate::{generic, mock::*, *}; use codec::Decode; use frame_support::{ derive_impl, parameter_types, - traits::{Contains, Everything, OriginTrait}, + traits::{Contains, Everything, OriginTrait, ProcessMessageError}, }; -use frame_support::traits::ProcessMessageError; use sp_runtime::traits::TrailingZeroInput; -use xcm_builder::{test_utils::{ - AssetsInHolding, TestAssetExchanger, TestAssetLocker, TestAssetTrap, - TestSubscriptionService, TestUniversalAliases, -}, AliasForeignAccountId32, AllowUnpaidExecutionFrom, CreateMatcher, DenyRecursively, DenyThenTry, EnsureDecodableXcm, FrameTransactionalProcessor, MatchXcm}; +use std::ops::ControlFlow; +use xcm_builder::{ + test_utils::{ + AssetsInHolding, TestAssetExchanger, TestAssetLocker, TestAssetTrap, + TestSubscriptionService, TestUniversalAliases, + }, + AliasForeignAccountId32, AllowUnpaidExecutionFrom, CreateMatcher, DenyRecursively, DenyThenTry, + EnsureDecodableXcm, FrameTransactionalProcessor, MatchXcm, +}; use xcm_executor::traits::{ConvertOrigin, DenyExecution, Properties}; type Block = frame_system::mocking::MockBlock; @@ -95,7 +98,6 @@ impl DenyExecution for DenyClearOrigin { } } - type Aliasers = AliasForeignAccountId32; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { @@ -107,7 +109,8 @@ impl xcm_executor::Config for XcmConfig { type IsReserve = AllAssetLocationsPass; type IsTeleporter = (); type UniversalLocation = UniversalLocation; - type Barrier = DenyThenTry, AllowUnpaidExecutionFrom>; + type Barrier = + DenyThenTry, AllowUnpaidExecutionFrom>; type Weigher = xcm_builder::FixedWeightBounds; type Trader = xcm_builder::FixedRateOfFungible; type ResponseHandler = DevNull; From 8b3990b9dcb004f21083e53c4cb3ff3f5ad2439a Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Wed, 24 Sep 2025 17:54:39 +0100 Subject: [PATCH 28/50] Add execute_xcm --- .../pallet-xcm-benchmarks/src/generic/benchmarking.rs | 2 +- polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index f7b7c2d1c7b72..38b55c45d52ba 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -969,7 +969,7 @@ mod benchmarks { #[block] { - let _ = executor.bench_process(xcm.into()); + let _ = executor.execute_xcm(xcm.into()); } let err = executor.error().expect("Error should exist after barrier rejection"); assert_eq!(err.1, xcm::latest::Error::Barrier); diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs index 5f8482bdcb8cf..28da80bfe28f0 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -25,7 +25,7 @@ use codec::Encode; use frame_benchmarking::{account, BenchmarkError}; use xcm::latest::prelude::*; use xcm_builder::EnsureDelivery; -use xcm_executor::{traits::ConvertLocation, Config as XcmConfig}; +use xcm_executor::{traits::ConvertLocation, Config as XcmConfig, WeighedMessage}; pub mod fungible; pub mod generic; @@ -99,6 +99,13 @@ pub fn asset_instance_from(x: u32) -> AssetInstance { AssetInstance::Array4(instance) } +pub fn execute_xcm(executor: ExecutorOf, xcm: Xcm>) -> Outcome { + let message = executor.prepare(xcm, Weight::MAX).unwrap(); + let origin = executor.origin().clone().unwrap_or_default(); + let mut hash = executor.topic().clone().unwrap_or_default(); + executor.execute(origin, message, &mut hash, Weight::MAX) +} + pub fn new_executor(origin: Location) -> ExecutorOf { ExecutorOf::::new(origin, [0; 32]) } From 2afdacb04db7e8e6f7df084da5f6fd2b52baaa3b Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Wed, 24 Sep 2025 18:07:08 +0100 Subject: [PATCH 29/50] Update execute_xcm --- .../src/generic/benchmarking.rs | 18 +++++++++++++----- polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs | 12 +++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 38b55c45d52ba..6364d83846180 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -16,7 +16,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use crate::{account_and_location, new_executor, EnsureDelivery, XcmCallOf}; +use crate::{account_and_location, execute_xcm, new_executor, EnsureDelivery, XcmCallOf}; use alloc::{vec, vec::Vec}; use codec::Encode; use frame_benchmarking::v2::*; @@ -963,16 +963,24 @@ mod benchmarks { #[benchmark] fn barrier_check() -> Result<(), BenchmarkError> { + use xcm::latest::{prelude::Outcome, Error::Barrier}; + let xcm = T::worst_case_for_not_passing_barrier().map_err(|_| BenchmarkError::Skip)?; - let mut executor = new_executor::(Default::default()); + let mut outcome: Option = None; #[block] { - let _ = executor.execute_xcm(xcm.into()); + outcome = Some(execute_xcm(xcm.into())); } - let err = executor.error().expect("Error should exist after barrier rejection"); - assert_eq!(err.1, xcm::latest::Error::Barrier); + let err = outcome.expect("Error should exist after barrier rejection"); + assert!(matches!( + err, + Outcome::Incomplete { + used: _, + error: InstructionError { index: 0, error: Barrier } + } + )); Ok(()) } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs index 28da80bfe28f0..41b36c086b018 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -99,11 +99,13 @@ pub fn asset_instance_from(x: u32) -> AssetInstance { AssetInstance::Array4(instance) } -pub fn execute_xcm(executor: ExecutorOf, xcm: Xcm>) -> Outcome { - let message = executor.prepare(xcm, Weight::MAX).unwrap(); - let origin = executor.origin().clone().unwrap_or_default(); - let mut hash = executor.topic().clone().unwrap_or_default(); - executor.execute(origin, message, &mut hash, Weight::MAX) +pub fn execute_xcm( + origin: Location, + xcm: Xcm<::RuntimeCall> +) -> Outcome { + let mut hash = [0; 32]; + let message = ExecutorOf::::prepare(xcm, Weight::MAX).unwrap(); + ExecutorOf::::execute(origin, message, &mut hash, Weight::MAX) } pub fn new_executor(origin: Location) -> ExecutorOf { From 1bebab9d4356406673fcb1bb816f887f3f31a179 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Wed, 24 Sep 2025 18:14:51 +0100 Subject: [PATCH 30/50] Update execute_xcm --- .../parachains/runtimes/assets/asset-hub-westend/src/lib.rs | 2 -- .../xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 4 ++-- polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs | 5 ++--- polkadot/xcm/xcm-builder/src/barriers.rs | 1 - polkadot/xcm/xcm-executor/src/lib.rs | 1 - 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index b8dc222109204..73b30f63c3db9 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2571,8 +2571,6 @@ pallet_revive::impl_runtime_apis_plus_revive!( nested = Xcm(vec![SetAppendix(nested)]); } - tracing::info!(target: "frame::benchmark::pallet", ?nested, "TESTING"); - Ok(nested) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 6364d83846180..3f495d1bd91ea 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -966,13 +966,13 @@ mod benchmarks { use xcm::latest::{prelude::Outcome, Error::Barrier}; let xcm = T::worst_case_for_not_passing_barrier().map_err(|_| BenchmarkError::Skip)?; - let mut outcome: Option = None; #[block] { - outcome = Some(execute_xcm(xcm.into())); + outcome = Some(execute_xcm::(xcm.into())); } + let err = outcome.expect("Error should exist after barrier rejection"); assert!(matches!( err, diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs index 41b36c086b018..c73a2fc62606d 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -25,7 +25,7 @@ use codec::Encode; use frame_benchmarking::{account, BenchmarkError}; use xcm::latest::prelude::*; use xcm_builder::EnsureDelivery; -use xcm_executor::{traits::ConvertLocation, Config as XcmConfig, WeighedMessage}; +use xcm_executor::{traits::ConvertLocation, Config as XcmConfig}; pub mod fungible; pub mod generic; @@ -100,12 +100,11 @@ pub fn asset_instance_from(x: u32) -> AssetInstance { } pub fn execute_xcm( - origin: Location, xcm: Xcm<::RuntimeCall> ) -> Outcome { let mut hash = [0; 32]; let message = ExecutorOf::::prepare(xcm, Weight::MAX).unwrap(); - ExecutorOf::::execute(origin, message, &mut hash, Weight::MAX) + ExecutorOf::::execute(Location::default(), message, &mut hash, Weight::MAX) } pub fn new_executor(origin: Location) -> ExecutorOf { diff --git a/polkadot/xcm/xcm-builder/src/barriers.rs b/polkadot/xcm/xcm-builder/src/barriers.rs index e1e53e5232dd9..6152e54d08b02 100644 --- a/polkadot/xcm/xcm-builder/src/barriers.rs +++ b/polkadot/xcm/xcm-builder/src/barriers.rs @@ -611,7 +611,6 @@ impl DenyRecursively { properties: &mut Properties, ) -> Result, ProcessMessageError> { // Initialise recursion counter for this execution context. - tracing::info!(target: "frame::benchmark::pallet", ?origin, ?xcm, ?max_weight, ?properties, "TESTING"); recursion_count::using_once(&mut 1, || { // Prevent stack overflow by enforcing a recursion depth limit. recursion_count::with(|count| { diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 64ca84041dba7..b4efab9349a4b 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -260,7 +260,6 @@ impl ExecuteXcm for XcmExecutor Date: Wed, 24 Sep 2025 18:32:18 +0100 Subject: [PATCH 31/50] Fix fmt --- .../pallet-xcm-benchmarks/src/generic/benchmarking.rs | 9 +++------ polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs | 4 +--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 3f495d1bd91ea..d0153e110fccf 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -975,12 +975,9 @@ mod benchmarks { let err = outcome.expect("Error should exist after barrier rejection"); assert!(matches!( - err, - Outcome::Incomplete { - used: _, - error: InstructionError { index: 0, error: Barrier } - } - )); + err, + Outcome::Incomplete { used: _, error: InstructionError { index: 0, error: Barrier } } + )); Ok(()) } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs index c73a2fc62606d..92d73e2dd8887 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -99,9 +99,7 @@ pub fn asset_instance_from(x: u32) -> AssetInstance { AssetInstance::Array4(instance) } -pub fn execute_xcm( - xcm: Xcm<::RuntimeCall> -) -> Outcome { +pub fn execute_xcm(xcm: Xcm<::RuntimeCall>) -> Outcome { let mut hash = [0; 32]; let message = ExecutorOf::::prepare(xcm, Weight::MAX).unwrap(); ExecutorOf::::execute(Location::default(), message, &mut hash, Weight::MAX) From 3a9ce4127ff35833350e50cf846096fb2973cec6 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Thu, 25 Sep 2025 09:32:17 +0100 Subject: [PATCH 32/50] Add ExecuteXcmOf --- .../src/generic/benchmarking.rs | 11 ++++--- polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs | 31 +++++++++++++++---- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index d0153e110fccf..f37620c7f0111 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -16,7 +16,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use crate::{account_and_location, execute_xcm, new_executor, EnsureDelivery, XcmCallOf}; +use crate::{account_and_location, new_executor, EnsureDelivery, ExecuteXcmOf, XcmCallOf}; use alloc::{vec, vec::Vec}; use codec::Encode; use frame_benchmarking::v2::*; @@ -966,16 +966,17 @@ mod benchmarks { use xcm::latest::{prelude::Outcome, Error::Barrier}; let xcm = T::worst_case_for_not_passing_barrier().map_err(|_| BenchmarkError::Skip)?; - let mut outcome: Option = None; + let mut executor = ExecuteXcmOf::::new(Location::default(), XcmHash::default()); #[block] { - outcome = Some(execute_xcm::(xcm.into())); + let _ = executor.execute(xcm.into()); } - let err = outcome.expect("Error should exist after barrier rejection"); + let outcome = + executor.outcome().clone().expect("Error should exist after barrier rejection"); assert!(matches!( - err, + outcome, Outcome::Incomplete { used: _, error: InstructionError { index: 0, error: Barrier } } )); Ok(()) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs index 92d73e2dd8887..9c835777fde35 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -68,6 +68,31 @@ pub type AssetTransactorOf = <::XcmConfig as XcmConfig>::AssetTr /// The call type of executor's config. Should eventually resolve to the same overarching call type. pub type XcmCallOf = <::XcmConfig as XcmConfig>::RuntimeCall; +/// The wrapper for executing XCMs in benchmarks, storing the execution outcome. +pub struct ExecuteXcmOf { + _config: core::marker::PhantomData, + origin: Location, + id: XcmHash, + outcome: Option, +} + +impl ExecuteXcmOf { + pub fn new(origin: impl Into, id: XcmHash) -> Self { + Self { _config: core::marker::PhantomData, origin: origin.into(), id, outcome: None } + } + + pub fn execute(&mut self, xcm: Xcm>) -> Result<(), BenchmarkError> { + let message = ExecutorOf::::prepare(xcm, Weight::MAX).unwrap(); + self.outcome = + Some(ExecutorOf::::execute(self.origin.clone(), message, &mut self.id, Weight::MAX)); + Ok(()) + } + + pub fn outcome(&self) -> &Option { + &self.outcome + } +} + pub fn generate_holding_assets(max_assets: u32) -> Assets { let fungibles_amount: u128 = 100; let holding_fungibles = max_assets / 2; @@ -99,12 +124,6 @@ pub fn asset_instance_from(x: u32) -> AssetInstance { AssetInstance::Array4(instance) } -pub fn execute_xcm(xcm: Xcm<::RuntimeCall>) -> Outcome { - let mut hash = [0; 32]; - let message = ExecutorOf::::prepare(xcm, Weight::MAX).unwrap(); - ExecutorOf::::execute(Location::default(), message, &mut hash, Weight::MAX) -} - pub fn new_executor(origin: Location) -> ExecutorOf { ExecutorOf::::new(origin, [0; 32]) } From d76901c9a6ad5063486a4f17e8c5ef207356fe9f Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Thu, 25 Sep 2025 09:34:19 +0100 Subject: [PATCH 33/50] Fix fmt --- polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs index 9c835777fde35..6811e19b886fd 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -82,7 +82,8 @@ impl ExecuteXcmOf { } pub fn execute(&mut self, xcm: Xcm>) -> Result<(), BenchmarkError> { - let message = ExecutorOf::::prepare(xcm, Weight::MAX).unwrap(); + let message = + ExecutorOf::::prepare(xcm, Weight::MAX).map_err(|_| BenchmarkError::Skip)?; self.outcome = Some(ExecutorOf::::execute(self.origin.clone(), message, &mut self.id, Weight::MAX)); Ok(()) From 956822c35c876adfa5f0141399f4832c4b974474 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Thu, 25 Sep 2025 10:51:34 +0100 Subject: [PATCH 34/50] Update PRDoc --- prdoc/pr_9808.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_9808.prdoc b/prdoc/pr_9808.prdoc index b8106a1acefe0..905b1de064245 100644 --- a/prdoc/pr_9808.prdoc +++ b/prdoc/pr_9808.prdoc @@ -28,6 +28,6 @@ crates: - name: pallet-staking-async-rc-runtime bump: none - name: pallet-xcm-benchmarks - bump: patch + bump: major - name: westend-runtime bump: patch \ No newline at end of file From 1356f63b6942026b470b6a2a8ae5583baa228ac4 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Thu, 25 Sep 2025 12:21:22 +0100 Subject: [PATCH 35/50] Fix fmt --- .../pallet-xcm-benchmarks/src/generic/benchmarking.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index f37620c7f0111..07d3eb5362d13 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -970,14 +970,15 @@ mod benchmarks { #[block] { - let _ = executor.execute(xcm.into()); + executor.execute(xcm.into())?; } - let outcome = - executor.outcome().clone().expect("Error should exist after barrier rejection"); assert!(matches!( - outcome, - Outcome::Incomplete { used: _, error: InstructionError { index: 0, error: Barrier } } + executor.outcome(), + Some(Outcome::Incomplete { + used: _, + error: InstructionError { index: 0, error: XcmError::Barrier } + }) )); Ok(()) } From aa73c5c8f98ad90a18a3366e9c7edde252cd4501 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 25 Sep 2025 11:28:20 +0000 Subject: [PATCH 36/50] Update from github-actions[bot] running command 'bench --pallet pallet_xcm_benchmarks::generic --runtime asset-hub-westend' --- .../xcm/pallet_xcm_benchmarks_generic.rs | 146 ++++++++++-------- 1 file changed, 78 insertions(+), 68 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 04ed54ad8f48b..ae6c1e93ddc54 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -16,9 +16,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2025-07-30, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-09-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `601cc0634d73`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `8eae651c965f`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -68,8 +68,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `2632` // Estimated: `6196` - // Minimum execution time: 128_179_000 picoseconds. - Weight::from_parts(132_827_000, 6196) + // Minimum execution time: 139_700_000 picoseconds. + Weight::from_parts(142_196_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -79,8 +79,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 6_735_000 picoseconds. - Weight::from_parts(7_064_000, 3593) + // Minimum execution time: 7_189_000 picoseconds. + Weight::from_parts(7_676_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -90,8 +90,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 6_580_000 picoseconds. - Weight::from_parts(7_050_000, 3593) + // Minimum execution time: 7_042_000 picoseconds. + Weight::from_parts(7_638_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -99,8 +99,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 773_000 picoseconds. - Weight::from_parts(829_000, 0) + // Minimum execution time: 883_000 picoseconds. + Weight::from_parts(937_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -108,51 +108,51 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3465` - // Minimum execution time: 6_112_000 picoseconds. - Weight::from_parts(6_358_000, 3465) + // Minimum execution time: 6_323_000 picoseconds. + Weight::from_parts(6_819_000, 3465) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_002_000 picoseconds. - Weight::from_parts(8_377_000, 0) + // Minimum execution time: 8_121_000 picoseconds. + Weight::from_parts(8_738_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_344_000 picoseconds. - Weight::from_parts(1_497_000, 0) + // Minimum execution time: 1_549_000 picoseconds. + Weight::from_parts(1_629_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 786_000 picoseconds. - Weight::from_parts(840_000, 0) + // Minimum execution time: 853_000 picoseconds. + Weight::from_parts(922_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 737_000 picoseconds. - Weight::from_parts(805_000, 0) + // Minimum execution time: 868_000 picoseconds. + Weight::from_parts(922_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 745_000 picoseconds. - Weight::from_parts(810_000, 0) + // Minimum execution time: 816_000 picoseconds. + Weight::from_parts(860_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 774_000 picoseconds. - Weight::from_parts(828_000, 0) + // Minimum execution time: 854_000 picoseconds. + Weight::from_parts(930_000, 0) } // Storage: `Benchmark::Override` (r:0 w:0) // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -167,8 +167,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 739_000 picoseconds. - Weight::from_parts(822_000, 0) + // Minimum execution time: 843_000 picoseconds. + Weight::from_parts(909_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -188,8 +188,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `2632` // Estimated: `6196` - // Minimum execution time: 91_221_000 picoseconds. - Weight::from_parts(93_944_000, 6196) + // Minimum execution time: 99_054_000 picoseconds. + Weight::from_parts(101_257_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -199,8 +199,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `23` // Estimated: `3488` - // Minimum execution time: 9_795_000 picoseconds. - Weight::from_parts(10_091_000, 3488) + // Minimum execution time: 10_196_000 picoseconds. + Weight::from_parts(10_920_000, 3488) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -208,8 +208,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_599_000 picoseconds. - Weight::from_parts(3_920_000, 0) + // Minimum execution time: 3_752_000 picoseconds. + Weight::from_parts(3_996_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -227,8 +227,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `378` // Estimated: `3843` - // Minimum execution time: 36_969_000 picoseconds. - Weight::from_parts(37_920_000, 3843) + // Minimum execution time: 39_220_000 picoseconds. + Weight::from_parts(40_603_000, 3843) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -238,44 +238,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_401_000 picoseconds. - Weight::from_parts(3_642_000, 0) + // Minimum execution time: 3_683_000 picoseconds. + Weight::from_parts(3_893_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 23_275_000 picoseconds. - Weight::from_parts(23_612_000, 0) + // Minimum execution time: 23_585_000 picoseconds. + Weight::from_parts(24_057_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_950_000 picoseconds. - Weight::from_parts(6_129_000, 0) + // Minimum execution time: 6_080_000 picoseconds. + Weight::from_parts(6_209_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_589_000 picoseconds. - Weight::from_parts(3_806_000, 0) + // Minimum execution time: 3_705_000 picoseconds. + Weight::from_parts(3_948_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_648_000 picoseconds. - Weight::from_parts(3_844_000, 0) + // Minimum execution time: 3_847_000 picoseconds. + Weight::from_parts(4_054_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 917_000 picoseconds. - Weight::from_parts(975_000, 0) + // Minimum execution time: 1_004_000 picoseconds. + Weight::from_parts(1_070_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -295,8 +295,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `2632` // Estimated: `6196` - // Minimum execution time: 100_417_000 picoseconds. - Weight::from_parts(102_884_000, 6196) + // Minimum execution time: 108_631_000 picoseconds. + Weight::from_parts(111_473_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -304,8 +304,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_030_000 picoseconds. - Weight::from_parts(8_265_000, 0) + // Minimum execution time: 9_425_000 picoseconds. + Weight::from_parts(9_824_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -325,8 +325,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `2632` // Estimated: `6196` - // Minimum execution time: 91_164_000 picoseconds. - Weight::from_parts(93_992_000, 6196) + // Minimum execution time: 99_485_000 picoseconds. + Weight::from_parts(103_115_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -334,22 +334,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 780_000 picoseconds. - Weight::from_parts(842_000, 0) + // Minimum execution time: 834_000 picoseconds. + Weight::from_parts(934_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 707_000 picoseconds. - Weight::from_parts(768_000, 0) + // Minimum execution time: 819_000 picoseconds. + Weight::from_parts(858_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 711_000 picoseconds. - Weight::from_parts(775_000, 0) + // Minimum execution time: 820_000 picoseconds. + Weight::from_parts(902_000, 0) } // Storage: `System::Account` (r:1 w:1) // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) @@ -363,8 +363,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `1244` // Estimated: `4273` - // Minimum execution time: 93_724_000 picoseconds. - Weight::from_parts(96_332_000, 4273) + // Minimum execution time: 97_627_000 picoseconds. + Weight::from_parts(101_613_000, 4273) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -374,29 +374,39 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `136` // Estimated: `1489` - // Minimum execution time: 5_567_000 picoseconds. - Weight::from_parts(5_841_000, 1489) + // Minimum execution time: 5_820_000 picoseconds. + Weight::from_parts(6_180_000, 1489) .saturating_add(T::DbWeight::get().reads(1)) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 713_000 picoseconds. - Weight::from_parts(779_000, 0) + // Minimum execution time: 782_000 picoseconds. + Weight::from_parts(846_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 728_000 picoseconds. - Weight::from_parts(783_000, 0) + // Minimum execution time: 814_000 picoseconds. + Weight::from_parts(898_000, 0) } pub fn alias_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 777_000 picoseconds. - Weight::from_parts(859_000, 0) + // Minimum execution time: 842_000 picoseconds. + Weight::from_parts(889_000, 0) + } + // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) + // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn barrier_check() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1485` + // Minimum execution time: 5_452_000 picoseconds. + Weight::from_parts(5_653_000, 1485) + .saturating_add(T::DbWeight::get().reads(1)) } } From 560da7700929f6c51d9bc153e85f6c0da2fcc88d Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Thu, 25 Sep 2025 14:17:54 +0100 Subject: [PATCH 37/50] Add WeightInfo --- polkadot/xcm/xcm-executor/src/lib.rs | 4 ++- polkadot/xcm/xcm-executor/src/weights.rs | 34 ++++++++++++++++++++++++ prdoc/pr_9808.prdoc | 2 ++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 polkadot/xcm/xcm-executor/src/weights.rs diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index b4efab9349a4b..a7df934d8aec6 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -46,6 +46,8 @@ mod assets; pub use assets::AssetsInHolding; mod config; pub use config::Config; +mod weights; +use weights::WeightInfo; #[cfg(test)] mod tests; @@ -284,7 +286,7 @@ impl ExecuteXcm for XcmExecutor::barrier_check(), // Weight consumed before the error error: InstructionError { index: 0, error: XcmError::Barrier }, // The error that occurred }; } diff --git a/polkadot/xcm/xcm-executor/src/weights.rs b/polkadot/xcm/xcm-executor/src/weights.rs new file mode 100644 index 0000000000000..ed0bccf710635 --- /dev/null +++ b/polkadot/xcm/xcm-executor/src/weights.rs @@ -0,0 +1,34 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +use core::marker::PhantomData; +use frame_support::weights::{constants, Weight}; + +pub struct WeightInfo(PhantomData); +impl WeightInfo { + // Copy from `pallet_xcm_benchmarks_generic::WeightInfo::barrier_check` + // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) + // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: + // `Measured`) + pub fn barrier_check() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1485` + // Minimum execution time: 5_452_000 picoseconds. + Weight::from_parts(5_653_000, 1485) + .saturating_add(Weight::from_parts(13_036 * constants::WEIGHT_REF_TIME_PER_NANOS, 0)) // Copy from `inmemorydb_weights::constants::InMemoryDbWeight` + } +} diff --git a/prdoc/pr_9808.prdoc b/prdoc/pr_9808.prdoc index 905b1de064245..2911b2fa81cfc 100644 --- a/prdoc/pr_9808.prdoc +++ b/prdoc/pr_9808.prdoc @@ -29,5 +29,7 @@ crates: bump: none - name: pallet-xcm-benchmarks bump: major +- name: staging-xcm-executor + bump: major - name: westend-runtime bump: patch \ No newline at end of file From 8d111a8cefb88276b008a7e0bc7ce180c76b7614 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Thu, 25 Sep 2025 15:05:57 +0100 Subject: [PATCH 38/50] Add barrier_check --- .../assets/asset-hub-westend/src/weights/xcm/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 27532ac431e7a..ea6e0b633c3b5 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -89,6 +89,12 @@ impl WeighAssets for Assets { } pub struct AssetHubWestendXcmWeight(core::marker::PhantomData); +impl AssetHubWestendXcmWeight { + #[allow(unused)] + fn barrier_check() -> Weight { + XcmGeneric::::barrier_check() + } +} impl XcmWeightInfo for AssetHubWestendXcmWeight { fn withdraw_asset(assets: &Assets) -> Weight { assets.weigh_assets(XcmFungibleWeight::::withdraw_asset()) From 014382b25f2a59c35c806f86fdacf5c9f7a35a29 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Thu, 25 Sep 2025 15:20:42 +0100 Subject: [PATCH 39/50] Fix tests --- polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 07d3eb5362d13..c6ca06cd8720c 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -977,7 +977,7 @@ mod benchmarks { executor.outcome(), Some(Outcome::Incomplete { used: _, - error: InstructionError { index: 0, error: XcmError::Barrier } + error: InstructionError { index: 0, error: Barrier } }) )); Ok(()) From 350798ec05e84c690e5a2626ab4f42217e9f8e2f Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Fri, 26 Sep 2025 11:46:53 +0100 Subject: [PATCH 40/50] Make more complicated XCM --- .../assets/asset-hub-westend/src/lib.rs | 17 +++++++++++++---- .../pallet-xcm-benchmarks/src/generic/mock.rs | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 73b30f63c3db9..8ca3305b05cd9 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2564,13 +2564,22 @@ pallet_revive::impl_runtime_apis_plus_revive!( } fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { - use xcm::latest::prelude::{ClearOrigin, SetAppendix}; + use xcm::latest::prelude::{ClearOrigin, SetAppendix, SetTopic}; - let mut nested = Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))]); - for _ in 0..=(xcm_executor::RECURSION_LIMIT + 1) { - nested = Xcm(vec![SetAppendix(nested)]); + // Within the recursion limit, this is fine. + let mut set_topic = Xcm(vec![SetTopic([42; 32])]); + for _ in 0..(xcm_executor::RECURSION_LIMIT - 1) { + set_topic = Xcm(vec![SetAppendix(set_topic)]); } + // Exceed the recursion limit, this will be rejected. + let mut clear_origin = Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))]); + for _ in 0..=xcm_executor::RECURSION_LIMIT { + clear_origin = Xcm(vec![SetAppendix(clear_origin)]); + } + + let nested = Xcm(vec![SetAppendix(set_topic), SetAppendix(clear_origin)]); + Ok(nested) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 10739891e46c2..32e7bdb719ca4 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -216,13 +216,22 @@ impl generic::Config for Test { } fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { - use xcm::latest::prelude::{ClearOrigin, SetAppendix}; + use xcm::latest::prelude::{ClearOrigin, SetAppendix, SetTopic}; - let mut nested = Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))]); - for _ in 0..=(xcm_executor::RECURSION_LIMIT + 1) { - nested = Xcm(vec![SetAppendix(nested)]); + // Within the recursion limit, this is fine. + let mut set_topic = Xcm(vec![SetTopic([42; 32])]); + for _ in 0..(xcm_executor::RECURSION_LIMIT - 1) { + set_topic = Xcm(vec![SetAppendix(set_topic)]); } + // Exceed the recursion limit, this will be rejected. + let mut clear_origin = Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))]); + for _ in 0..=xcm_executor::RECURSION_LIMIT { + clear_origin = Xcm(vec![SetAppendix(clear_origin)]); + } + + let nested = Xcm(vec![SetAppendix(set_topic), SetAppendix(clear_origin)]); + Ok(nested) } } From 6f76a1b9afa3873f0d52c9f03eefda1ec82d11a6 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Fri, 26 Sep 2025 11:57:31 +0100 Subject: [PATCH 41/50] Add barrier_check_weight --- polkadot/xcm/xcm-executor/src/lib.rs | 10 ++++++---- polkadot/xcm/xcm-executor/src/traits/weight.rs | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index a7df934d8aec6..12792798ee8db 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -285,10 +285,12 @@ impl ExecuteXcm for XcmExecutor::barrier_check(), // Weight consumed before the error - error: InstructionError { index: 0, error: XcmError::Barrier }, // The error that occurred - }; + // Weight consumed before the error + let used = Config::Weigher::barrier_check_weight().unwrap_or(xcm_weight); + // The error that occurred + let error = InstructionError { index: 0, error: XcmError::Barrier }; + + return Outcome::Incomplete { used, error }; } *id = properties.message_id.unwrap_or(*id); diff --git a/polkadot/xcm/xcm-executor/src/traits/weight.rs b/polkadot/xcm/xcm-executor/src/traits/weight.rs index b938c346ea0bf..f3cd5d447ee35 100644 --- a/polkadot/xcm/xcm-executor/src/traits/weight.rs +++ b/polkadot/xcm/xcm-executor/src/traits/weight.rs @@ -30,6 +30,11 @@ pub trait WeightBounds { /// Return the maximum amount of weight that an attempted execution of this instruction could /// consume. fn instr_weight(instruction: &mut Instruction) -> Result; + + /// Return the weight consumed by a barrier check for an XCM, or None if not applicable. + fn barrier_check_weight() -> Option { + None + } } /// Charge for weight in order to execute XCM. From 19934131c033b7a6facf3451b45c7e51457f6a88 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Fri, 26 Sep 2025 11:59:27 +0100 Subject: [PATCH 42/50] Remove weights::WeightInfo --- polkadot/xcm/xcm-executor/src/lib.rs | 2 -- polkadot/xcm/xcm-executor/src/weights.rs | 34 ------------------------ 2 files changed, 36 deletions(-) delete mode 100644 polkadot/xcm/xcm-executor/src/weights.rs diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 12792798ee8db..2369a82a1e735 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -46,8 +46,6 @@ mod assets; pub use assets::AssetsInHolding; mod config; pub use config::Config; -mod weights; -use weights::WeightInfo; #[cfg(test)] mod tests; diff --git a/polkadot/xcm/xcm-executor/src/weights.rs b/polkadot/xcm/xcm-executor/src/weights.rs deleted file mode 100644 index ed0bccf710635..0000000000000 --- a/polkadot/xcm/xcm-executor/src/weights.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Polkadot. - -// Polkadot is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Polkadot is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Polkadot. If not, see . - -use core::marker::PhantomData; -use frame_support::weights::{constants, Weight}; - -pub struct WeightInfo(PhantomData); -impl WeightInfo { - // Copy from `pallet_xcm_benchmarks_generic::WeightInfo::barrier_check` - // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) - // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: - // `Measured`) - pub fn barrier_check() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `1485` - // Minimum execution time: 5_452_000 picoseconds. - Weight::from_parts(5_653_000, 1485) - .saturating_add(Weight::from_parts(13_036 * constants::WEIGHT_REF_TIME_PER_NANOS, 0)) // Copy from `inmemorydb_weights::constants::InMemoryDbWeight` - } -} From 32bfb356431cb2ef7ff2f711ab4cabf278c6e805 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Fri, 26 Sep 2025 12:56:24 +0100 Subject: [PATCH 43/50] Add AssetHubWestendXcmWeightInfoBounds --- Cargo.lock | 32 +++++++++---------- .../asset-hub-westend/src/weights/xcm/mod.rs | 31 ++++++++++++------ .../asset-hub-westend/src/xcm_config.rs | 6 +--- 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e213136785be5..f35a85b3971a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -378,9 +378,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" [[package]] name = "anstyle-parse" @@ -3260,9 +3260,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.13" +version = "4.5.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" +checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae" dependencies = [ "clap_builder", "clap_derive", @@ -3270,9 +3270,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.13" +version = "4.5.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" +checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9" dependencies = [ "anstream", "anstyle", @@ -3292,9 +3292,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c" dependencies = [ "heck 0.5.0", "proc-macro2 1.0.95", @@ -3304,9 +3304,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" [[package]] name = "cmd_lib" @@ -7462,9 +7462,9 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "glob-match" @@ -25331,12 +25331,12 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.3.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +checksum = "60b8cb979cb11c32ce1603f8137b22262a9d131aaa5c37b5678025f22b8becd0" dependencies = [ - "rustix 0.38.42", - "windows-sys 0.48.0", + "rustix 1.0.8", + "windows-sys 0.60.2", ] [[package]] diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index ea6e0b633c3b5..521c39019fd4f 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -16,10 +16,7 @@ mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; -use crate::{ - xcm_config::{ERC20TransferGasLimit, MaxAssetsIntoHolding}, - Runtime, -}; +use crate::{xcm_config::{ERC20TransferGasLimit, MaxAssetsIntoHolding, MaxInstructions}, Runtime, RuntimeCall}; use alloc::vec::Vec; use assets_common::IsLocalAccountKey20; use frame_support::{traits::Contains, weights::Weight}; @@ -30,6 +27,8 @@ use xcm::{ latest::{prelude::*, AssetTransferFilter}, DoubleEncoded, }; +use xcm_builder::WeightInfoBounds; +use xcm_executor::traits::WeightBounds; trait WeighAssets { fn weigh_assets(&self, weight: Weight) -> Weight; @@ -88,13 +87,27 @@ impl WeighAssets for Assets { } } -pub struct AssetHubWestendXcmWeight(core::marker::PhantomData); -impl AssetHubWestendXcmWeight { - #[allow(unused)] - fn barrier_check() -> Weight { - XcmGeneric::::barrier_check() +pub struct AssetHubWestendXcmWeightInfoBounds; +impl WeightBounds for AssetHubWestendXcmWeightInfoBounds { + fn weight(message: &mut Xcm, weight_limit: Weight) -> Result { + WeightInfoBounds::, RuntimeCall, MaxInstructions>::weight( + message, + weight_limit, + ) + } + + fn instr_weight(instruction: &mut Instruction) -> Result { + WeightInfoBounds::, RuntimeCall, MaxInstructions>::instr_weight( + instruction, + ) + } + + fn barrier_check_weight() -> Option { + Some(XcmGeneric::::barrier_check()) } } + +pub struct AssetHubWestendXcmWeight(core::marker::PhantomData); impl XcmWeightInfo for AssetHubWestendXcmWeight { fn withdraw_asset(assets: &Assets) -> Weight { assets.weigh_assets(XcmFungibleWeight::::withdraw_asset()) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 84f7dcdf9c054..22715e81fb47b 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -559,11 +559,7 @@ impl pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; - type Weigher = WeightInfoBounds< - crate::weights::xcm::AssetHubWestendXcmWeight, - RuntimeCall, - MaxInstructions, - >; + type Weigher = crate::weights::xcm::AssetHubWestendXcmWeightInfoBounds; type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; From 16a0fd7e21cf656324e53a9d5e0b0d2923a7053c Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Fri, 26 Sep 2025 14:26:19 +0100 Subject: [PATCH 44/50] Fix fmt --- .../assets/asset-hub-westend/src/weights/xcm/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 521c39019fd4f..33dc9aeca4a95 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -16,7 +16,10 @@ mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; -use crate::{xcm_config::{ERC20TransferGasLimit, MaxAssetsIntoHolding, MaxInstructions}, Runtime, RuntimeCall}; +use crate::{ + xcm_config::{ERC20TransferGasLimit, MaxAssetsIntoHolding, MaxInstructions}, + Runtime, RuntimeCall, +}; use alloc::vec::Vec; use assets_common::IsLocalAccountKey20; use frame_support::{traits::Contains, weights::Weight}; @@ -89,7 +92,10 @@ impl WeighAssets for Assets { pub struct AssetHubWestendXcmWeightInfoBounds; impl WeightBounds for AssetHubWestendXcmWeightInfoBounds { - fn weight(message: &mut Xcm, weight_limit: Weight) -> Result { + fn weight( + message: &mut Xcm, + weight_limit: Weight, + ) -> Result { WeightInfoBounds::, RuntimeCall, MaxInstructions>::weight( message, weight_limit, From fce82c1b7301adde5a45aeb993165b0dfe25c565 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 26 Sep 2025 14:07:09 +0000 Subject: [PATCH 45/50] Update from github-actions[bot] running command 'bench --pallet pallet_xcm_benchmarks::generic --runtime asset-hub-westend' --- .../xcm/pallet_xcm_benchmarks_generic.rs | 140 +++++++++--------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index ae6c1e93ddc54..4883ef5bdae1b 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -16,9 +16,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2025-09-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-09-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `8eae651c965f`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `bfea0ca505ba`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -68,8 +68,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `2632` // Estimated: `6196` - // Minimum execution time: 139_700_000 picoseconds. - Weight::from_parts(142_196_000, 6196) + // Minimum execution time: 136_485_000 picoseconds. + Weight::from_parts(141_802_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -79,8 +79,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 7_189_000 picoseconds. - Weight::from_parts(7_676_000, 3593) + // Minimum execution time: 6_939_000 picoseconds. + Weight::from_parts(7_349_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -90,8 +90,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 7_042_000 picoseconds. - Weight::from_parts(7_638_000, 3593) + // Minimum execution time: 6_940_000 picoseconds. + Weight::from_parts(7_364_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -99,8 +99,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 883_000 picoseconds. - Weight::from_parts(937_000, 0) + // Minimum execution time: 818_000 picoseconds. + Weight::from_parts(875_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -108,51 +108,51 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3465` - // Minimum execution time: 6_323_000 picoseconds. - Weight::from_parts(6_819_000, 3465) + // Minimum execution time: 6_239_000 picoseconds. + Weight::from_parts(6_460_000, 3465) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_121_000 picoseconds. - Weight::from_parts(8_738_000, 0) + // Minimum execution time: 8_096_000 picoseconds. + Weight::from_parts(8_560_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_549_000 picoseconds. - Weight::from_parts(1_629_000, 0) + // Minimum execution time: 1_475_000 picoseconds. + Weight::from_parts(1_558_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 853_000 picoseconds. - Weight::from_parts(922_000, 0) + // Minimum execution time: 822_000 picoseconds. + Weight::from_parts(864_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 868_000 picoseconds. - Weight::from_parts(922_000, 0) + // Minimum execution time: 795_000 picoseconds. + Weight::from_parts(840_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 816_000 picoseconds. - Weight::from_parts(860_000, 0) + // Minimum execution time: 774_000 picoseconds. + Weight::from_parts(826_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 854_000 picoseconds. - Weight::from_parts(930_000, 0) + // Minimum execution time: 785_000 picoseconds. + Weight::from_parts(860_000, 0) } // Storage: `Benchmark::Override` (r:0 w:0) // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -167,8 +167,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 843_000 picoseconds. - Weight::from_parts(909_000, 0) + // Minimum execution time: 792_000 picoseconds. + Weight::from_parts(866_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -188,8 +188,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `2632` // Estimated: `6196` - // Minimum execution time: 99_054_000 picoseconds. - Weight::from_parts(101_257_000, 6196) + // Minimum execution time: 96_961_000 picoseconds. + Weight::from_parts(100_455_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -199,8 +199,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `23` // Estimated: `3488` - // Minimum execution time: 10_196_000 picoseconds. - Weight::from_parts(10_920_000, 3488) + // Minimum execution time: 10_146_000 picoseconds. + Weight::from_parts(10_426_000, 3488) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -208,8 +208,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_752_000 picoseconds. - Weight::from_parts(3_996_000, 0) + // Minimum execution time: 3_703_000 picoseconds. + Weight::from_parts(3_883_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -227,8 +227,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `378` // Estimated: `3843` - // Minimum execution time: 39_220_000 picoseconds. - Weight::from_parts(40_603_000, 3843) + // Minimum execution time: 38_606_000 picoseconds. + Weight::from_parts(40_674_000, 3843) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -238,44 +238,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_683_000 picoseconds. - Weight::from_parts(3_893_000, 0) + // Minimum execution time: 3_446_000 picoseconds. + Weight::from_parts(3_916_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 23_585_000 picoseconds. - Weight::from_parts(24_057_000, 0) + // Minimum execution time: 23_263_000 picoseconds. + Weight::from_parts(23_690_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_080_000 picoseconds. - Weight::from_parts(6_209_000, 0) + // Minimum execution time: 6_117_000 picoseconds. + Weight::from_parts(6_232_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_705_000 picoseconds. - Weight::from_parts(3_948_000, 0) + // Minimum execution time: 3_626_000 picoseconds. + Weight::from_parts(3_835_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_847_000 picoseconds. - Weight::from_parts(4_054_000, 0) + // Minimum execution time: 3_701_000 picoseconds. + Weight::from_parts(3_863_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_004_000 picoseconds. - Weight::from_parts(1_070_000, 0) + // Minimum execution time: 957_000 picoseconds. + Weight::from_parts(1_012_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -295,8 +295,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `2632` // Estimated: `6196` - // Minimum execution time: 108_631_000 picoseconds. - Weight::from_parts(111_473_000, 6196) + // Minimum execution time: 109_001_000 picoseconds. + Weight::from_parts(110_922_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -304,8 +304,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_425_000 picoseconds. - Weight::from_parts(9_824_000, 0) + // Minimum execution time: 9_504_000 picoseconds. + Weight::from_parts(9_863_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -325,8 +325,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `2632` // Estimated: `6196` - // Minimum execution time: 99_485_000 picoseconds. - Weight::from_parts(103_115_000, 6196) + // Minimum execution time: 95_948_000 picoseconds. + Weight::from_parts(98_770_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -334,22 +334,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 834_000 picoseconds. - Weight::from_parts(934_000, 0) + // Minimum execution time: 866_000 picoseconds. + Weight::from_parts(912_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 819_000 picoseconds. - Weight::from_parts(858_000, 0) + // Minimum execution time: 763_000 picoseconds. + Weight::from_parts(815_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 820_000 picoseconds. - Weight::from_parts(902_000, 0) + // Minimum execution time: 791_000 picoseconds. + Weight::from_parts(827_000, 0) } // Storage: `System::Account` (r:1 w:1) // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) @@ -363,8 +363,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `1244` // Estimated: `4273` - // Minimum execution time: 97_627_000 picoseconds. - Weight::from_parts(101_613_000, 4273) + // Minimum execution time: 100_038_000 picoseconds. + Weight::from_parts(107_470_000, 4273) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -374,30 +374,30 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `136` // Estimated: `1489` - // Minimum execution time: 5_820_000 picoseconds. - Weight::from_parts(6_180_000, 1489) + // Minimum execution time: 5_703_000 picoseconds. + Weight::from_parts(6_065_000, 1489) .saturating_add(T::DbWeight::get().reads(1)) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 782_000 picoseconds. - Weight::from_parts(846_000, 0) + // Minimum execution time: 764_000 picoseconds. + Weight::from_parts(823_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 814_000 picoseconds. - Weight::from_parts(898_000, 0) + // Minimum execution time: 780_000 picoseconds. + Weight::from_parts(834_000, 0) } pub fn alias_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 842_000 picoseconds. - Weight::from_parts(889_000, 0) + // Minimum execution time: 807_000 picoseconds. + Weight::from_parts(872_000, 0) } // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -405,8 +405,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 5_452_000 picoseconds. - Weight::from_parts(5_653_000, 1485) + // Minimum execution time: 8_399_000 picoseconds. + Weight::from_parts(8_708_000, 1485) .saturating_add(T::DbWeight::get().reads(1)) } } From 7c2fd36703265bfbbfebd4ae30f51c327e5a4a7e Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Fri, 26 Sep 2025 15:08:53 +0100 Subject: [PATCH 46/50] Fix fmt --- .../assets/asset-hub-westend/src/lib.rs | 4 +- .../asset-hub-westend/src/weights/xcm/mod.rs | 46 +++++++++---------- .../pallet-xcm-benchmarks/src/generic/mock.rs | 4 +- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 8ca3305b05cd9..e4d7b4395bdc0 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2578,9 +2578,9 @@ pallet_revive::impl_runtime_apis_plus_revive!( clear_origin = Xcm(vec![SetAppendix(clear_origin)]); } - let nested = Xcm(vec![SetAppendix(set_topic), SetAppendix(clear_origin)]); + let xcm = Xcm(vec![SetAppendix(set_topic), SetAppendix(clear_origin)]); - Ok(nested) + Ok(xcm) } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 33dc9aeca4a95..d2cbf1f43a0cf 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -90,29 +90,6 @@ impl WeighAssets for Assets { } } -pub struct AssetHubWestendXcmWeightInfoBounds; -impl WeightBounds for AssetHubWestendXcmWeightInfoBounds { - fn weight( - message: &mut Xcm, - weight_limit: Weight, - ) -> Result { - WeightInfoBounds::, RuntimeCall, MaxInstructions>::weight( - message, - weight_limit, - ) - } - - fn instr_weight(instruction: &mut Instruction) -> Result { - WeightInfoBounds::, RuntimeCall, MaxInstructions>::instr_weight( - instruction, - ) - } - - fn barrier_check_weight() -> Option { - Some(XcmGeneric::::barrier_check()) - } -} - pub struct AssetHubWestendXcmWeight(core::marker::PhantomData); impl XcmWeightInfo for AssetHubWestendXcmWeight { fn withdraw_asset(assets: &Assets) -> Weight { @@ -328,3 +305,26 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { XcmGeneric::::execute_with_origin() } } + +pub struct AssetHubWestendXcmWeightInfoBounds; +impl WeightBounds for AssetHubWestendXcmWeightInfoBounds { + fn weight( + message: &mut Xcm, + weight_limit: Weight, + ) -> Result { + WeightInfoBounds::, RuntimeCall, MaxInstructions>::weight( + message, + weight_limit, + ) + } + + fn instr_weight(instruction: &mut Instruction) -> Result { + WeightInfoBounds::, RuntimeCall, MaxInstructions>::instr_weight( + instruction, + ) + } + + fn barrier_check_weight() -> Option { + Some(XcmGeneric::::barrier_check()) + } +} diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 32e7bdb719ca4..fe5ec06038de0 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -230,9 +230,9 @@ impl generic::Config for Test { clear_origin = Xcm(vec![SetAppendix(clear_origin)]); } - let nested = Xcm(vec![SetAppendix(set_topic), SetAppendix(clear_origin)]); + let xcm = Xcm(vec![SetAppendix(set_topic), SetAppendix(clear_origin)]); - Ok(nested) + Ok(xcm) } } From 5f179967718d390ac6a8fada8b002037c07b2a82 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Mon, 29 Sep 2025 10:16:19 +0100 Subject: [PATCH 47/50] Use more complicated instructions --- .../runtimes/assets/asset-hub-westend/src/lib.rs | 9 ++++++--- polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index e4d7b4395bdc0..9ee999044cce4 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2566,19 +2566,22 @@ pallet_revive::impl_runtime_apis_plus_revive!( fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { use xcm::latest::prelude::{ClearOrigin, SetAppendix, SetTopic}; + let recursion_limit = xcm_executor::RECURSION_LIMIT as usize; + // Within the recursion limit, this is fine. let mut set_topic = Xcm(vec![SetTopic([42; 32])]); - for _ in 0..(xcm_executor::RECURSION_LIMIT - 1) { + for _ in 0..(recursion_limit - 2) { set_topic = Xcm(vec![SetAppendix(set_topic)]); } + let set_topics = Xcm(vec![SetAppendix(set_topic); recursion_limit - 2]); // Exceed the recursion limit, this will be rejected. let mut clear_origin = Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))]); - for _ in 0..=xcm_executor::RECURSION_LIMIT { + for _ in 0..=recursion_limit { clear_origin = Xcm(vec![SetAppendix(clear_origin)]); } - let xcm = Xcm(vec![SetAppendix(set_topic), SetAppendix(clear_origin)]); + let xcm = Xcm(vec![SetAppendix(set_topics), SetAppendix(clear_origin)]); Ok(xcm) } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index fe5ec06038de0..df736d385d8d6 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -218,19 +218,22 @@ impl generic::Config for Test { fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { use xcm::latest::prelude::{ClearOrigin, SetAppendix, SetTopic}; + let recursion_limit = xcm_executor::RECURSION_LIMIT as usize; + // Within the recursion limit, this is fine. let mut set_topic = Xcm(vec![SetTopic([42; 32])]); - for _ in 0..(xcm_executor::RECURSION_LIMIT - 1) { + for _ in 0..(recursion_limit - 2) { set_topic = Xcm(vec![SetAppendix(set_topic)]); } + let set_topics = Xcm(vec![SetAppendix(set_topic); recursion_limit - 2]); // Exceed the recursion limit, this will be rejected. let mut clear_origin = Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))]); - for _ in 0..=xcm_executor::RECURSION_LIMIT { + for _ in 0..=recursion_limit { clear_origin = Xcm(vec![SetAppendix(clear_origin)]); } - let xcm = Xcm(vec![SetAppendix(set_topic), SetAppendix(clear_origin)]); + let xcm = Xcm(vec![SetAppendix(set_topics), SetAppendix(clear_origin)]); Ok(xcm) } From 82a6efb813880d42e560b9b93907c6753a440b10 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Mon, 29 Sep 2025 11:13:09 +0100 Subject: [PATCH 48/50] Simplify the Deny --- .../assets/asset-hub-westend/src/lib.rs | 8 ++--- .../pallet-xcm-benchmarks/src/generic/mock.rs | 29 +++++++------------ 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 9ee999044cce4..8341cb57a3549 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2566,18 +2566,18 @@ pallet_revive::impl_runtime_apis_plus_revive!( fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { use xcm::latest::prelude::{ClearOrigin, SetAppendix, SetTopic}; - let recursion_limit = xcm_executor::RECURSION_LIMIT as usize; + let nested_limit = xcm_executor::RECURSION_LIMIT as usize - 2; // Within the recursion limit, this is fine. let mut set_topic = Xcm(vec![SetTopic([42; 32])]); - for _ in 0..(recursion_limit - 2) { + for _ in 0..nested_limit { set_topic = Xcm(vec![SetAppendix(set_topic)]); } - let set_topics = Xcm(vec![SetAppendix(set_topic); recursion_limit - 2]); + let set_topics = Xcm(vec![SetAppendix(set_topic); nested_limit]); // Exceed the recursion limit, this will be rejected. let mut clear_origin = Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))]); - for _ in 0..=recursion_limit { + for _ in 0..=nested_limit { clear_origin = Xcm(vec![SetAppendix(clear_origin)]); } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index df736d385d8d6..f51a384d362ad 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -23,14 +23,13 @@ use frame_support::{ traits::{Contains, Everything, OriginTrait, ProcessMessageError}, }; use sp_runtime::traits::TrailingZeroInput; -use std::ops::ControlFlow; use xcm_builder::{ test_utils::{ AssetsInHolding, TestAssetExchanger, TestAssetLocker, TestAssetTrap, TestSubscriptionService, TestUniversalAliases, }, - AliasForeignAccountId32, AllowUnpaidExecutionFrom, CreateMatcher, DenyRecursively, DenyThenTry, - EnsureDecodableXcm, FrameTransactionalProcessor, MatchXcm, + AliasForeignAccountId32, AllowUnpaidExecutionFrom, DenyRecursively, DenyThenTry, + EnsureDecodableXcm, FrameTransactionalProcessor, }; use xcm_executor::traits::{ConvertOrigin, DenyExecution, Properties}; @@ -79,21 +78,14 @@ impl Contains for OnlyParachains { } } -pub struct DenyClearOrigin; -impl DenyExecution for DenyClearOrigin { +pub struct DenyNothing; +impl DenyExecution for DenyNothing { fn deny_execution( _origin: &Location, - instructions: &mut [Instruction], + _instructions: &mut [Instruction], _max_weight: Weight, _properties: &mut Properties, ) -> Result<(), ProcessMessageError> { - instructions.matcher().match_next_inst_while( - |_| true, - |inst| match inst { - ClearOrigin => Err(ProcessMessageError::Unsupported), - _ => Ok(ControlFlow::Continue(())), - }, - )?; Ok(()) } } @@ -109,8 +101,7 @@ impl xcm_executor::Config for XcmConfig { type IsReserve = AllAssetLocationsPass; type IsTeleporter = (); type UniversalLocation = UniversalLocation; - type Barrier = - DenyThenTry, AllowUnpaidExecutionFrom>; + type Barrier = DenyThenTry, AllowUnpaidExecutionFrom>; type Weigher = xcm_builder::FixedWeightBounds; type Trader = xcm_builder::FixedRateOfFungible; type ResponseHandler = DevNull; @@ -218,18 +209,18 @@ impl generic::Config for Test { fn worst_case_for_not_passing_barrier() -> Result>, BenchmarkError> { use xcm::latest::prelude::{ClearOrigin, SetAppendix, SetTopic}; - let recursion_limit = xcm_executor::RECURSION_LIMIT as usize; + let nested_limit = xcm_executor::RECURSION_LIMIT as usize - 2; // Within the recursion limit, this is fine. let mut set_topic = Xcm(vec![SetTopic([42; 32])]); - for _ in 0..(recursion_limit - 2) { + for _ in 0..nested_limit { set_topic = Xcm(vec![SetAppendix(set_topic)]); } - let set_topics = Xcm(vec![SetAppendix(set_topic); recursion_limit - 2]); + let set_topics = Xcm(vec![SetAppendix(set_topic); nested_limit]); // Exceed the recursion limit, this will be rejected. let mut clear_origin = Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))]); - for _ in 0..=recursion_limit { + for _ in 0..=nested_limit { clear_origin = Xcm(vec![SetAppendix(clear_origin)]); } From 001d9dba5c5f54e809291754f87d623451f6e5ac Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 15:29:15 +0000 Subject: [PATCH 49/50] Update from github-actions[bot] running command 'bench --pallet pallet_xcm_benchmarks::generic --runtime asset-hub-westend' --- .../xcm/pallet_xcm_benchmarks_generic.rs | 140 +++++++++--------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 4883ef5bdae1b..94dd7836d46d8 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -16,9 +16,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2025-09-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-09-29, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bfea0ca505ba`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `919088bef400`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -68,8 +68,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `2632` // Estimated: `6196` - // Minimum execution time: 136_485_000 picoseconds. - Weight::from_parts(141_802_000, 6196) + // Minimum execution time: 142_020_000 picoseconds. + Weight::from_parts(146_016_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -79,8 +79,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 6_939_000 picoseconds. - Weight::from_parts(7_349_000, 3593) + // Minimum execution time: 7_378_000 picoseconds. + Weight::from_parts(7_747_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -90,8 +90,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 6_940_000 picoseconds. - Weight::from_parts(7_364_000, 3593) + // Minimum execution time: 7_249_000 picoseconds. + Weight::from_parts(7_695_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -99,8 +99,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 818_000 picoseconds. - Weight::from_parts(875_000, 0) + // Minimum execution time: 874_000 picoseconds. + Weight::from_parts(950_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -108,51 +108,51 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3465` - // Minimum execution time: 6_239_000 picoseconds. - Weight::from_parts(6_460_000, 3465) + // Minimum execution time: 6_185_000 picoseconds. + Weight::from_parts(6_600_000, 3465) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_096_000 picoseconds. - Weight::from_parts(8_560_000, 0) + // Minimum execution time: 8_070_000 picoseconds. + Weight::from_parts(8_583_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_475_000 picoseconds. - Weight::from_parts(1_558_000, 0) + // Minimum execution time: 1_506_000 picoseconds. + Weight::from_parts(1_617_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 822_000 picoseconds. - Weight::from_parts(864_000, 0) + // Minimum execution time: 768_000 picoseconds. + Weight::from_parts(859_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 795_000 picoseconds. - Weight::from_parts(840_000, 0) + // Minimum execution time: 851_000 picoseconds. + Weight::from_parts(899_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 774_000 picoseconds. - Weight::from_parts(826_000, 0) + // Minimum execution time: 818_000 picoseconds. + Weight::from_parts(880_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 785_000 picoseconds. - Weight::from_parts(860_000, 0) + // Minimum execution time: 868_000 picoseconds. + Weight::from_parts(934_000, 0) } // Storage: `Benchmark::Override` (r:0 w:0) // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -167,8 +167,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 792_000 picoseconds. - Weight::from_parts(866_000, 0) + // Minimum execution time: 803_000 picoseconds. + Weight::from_parts(906_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -188,8 +188,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `2632` // Estimated: `6196` - // Minimum execution time: 96_961_000 picoseconds. - Weight::from_parts(100_455_000, 6196) + // Minimum execution time: 99_920_000 picoseconds. + Weight::from_parts(103_610_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -199,8 +199,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `23` // Estimated: `3488` - // Minimum execution time: 10_146_000 picoseconds. - Weight::from_parts(10_426_000, 3488) + // Minimum execution time: 10_347_000 picoseconds. + Weight::from_parts(10_840_000, 3488) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -208,8 +208,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_703_000 picoseconds. - Weight::from_parts(3_883_000, 0) + // Minimum execution time: 3_932_000 picoseconds. + Weight::from_parts(4_112_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -227,8 +227,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `378` // Estimated: `3843` - // Minimum execution time: 38_606_000 picoseconds. - Weight::from_parts(40_674_000, 3843) + // Minimum execution time: 38_093_000 picoseconds. + Weight::from_parts(39_724_000, 3843) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -238,44 +238,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_446_000 picoseconds. - Weight::from_parts(3_916_000, 0) + // Minimum execution time: 3_635_000 picoseconds. + Weight::from_parts(4_004_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 23_263_000 picoseconds. - Weight::from_parts(23_690_000, 0) + // Minimum execution time: 24_147_000 picoseconds. + Weight::from_parts(24_428_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_117_000 picoseconds. - Weight::from_parts(6_232_000, 0) + // Minimum execution time: 6_252_000 picoseconds. + Weight::from_parts(6_425_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_626_000 picoseconds. - Weight::from_parts(3_835_000, 0) + // Minimum execution time: 3_807_000 picoseconds. + Weight::from_parts(4_064_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_701_000 picoseconds. - Weight::from_parts(3_863_000, 0) + // Minimum execution time: 3_948_000 picoseconds. + Weight::from_parts(4_104_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 957_000 picoseconds. - Weight::from_parts(1_012_000, 0) + // Minimum execution time: 971_000 picoseconds. + Weight::from_parts(1_042_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -295,8 +295,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `2632` // Estimated: `6196` - // Minimum execution time: 109_001_000 picoseconds. - Weight::from_parts(110_922_000, 6196) + // Minimum execution time: 109_118_000 picoseconds. + Weight::from_parts(113_440_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -304,8 +304,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_504_000 picoseconds. - Weight::from_parts(9_863_000, 0) + // Minimum execution time: 9_429_000 picoseconds. + Weight::from_parts(9_765_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -325,8 +325,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `2632` // Estimated: `6196` - // Minimum execution time: 95_948_000 picoseconds. - Weight::from_parts(98_770_000, 6196) + // Minimum execution time: 98_366_000 picoseconds. + Weight::from_parts(102_857_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -334,22 +334,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 866_000 picoseconds. - Weight::from_parts(912_000, 0) + // Minimum execution time: 839_000 picoseconds. + Weight::from_parts(902_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 763_000 picoseconds. - Weight::from_parts(815_000, 0) + // Minimum execution time: 847_000 picoseconds. + Weight::from_parts(919_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 791_000 picoseconds. - Weight::from_parts(827_000, 0) + // Minimum execution time: 819_000 picoseconds. + Weight::from_parts(876_000, 0) } // Storage: `System::Account` (r:1 w:1) // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) @@ -363,8 +363,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `1244` // Estimated: `4273` - // Minimum execution time: 100_038_000 picoseconds. - Weight::from_parts(107_470_000, 4273) + // Minimum execution time: 101_215_000 picoseconds. + Weight::from_parts(105_533_000, 4273) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -374,30 +374,30 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `136` // Estimated: `1489` - // Minimum execution time: 5_703_000 picoseconds. - Weight::from_parts(6_065_000, 1489) + // Minimum execution time: 5_677_000 picoseconds. + Weight::from_parts(6_009_000, 1489) .saturating_add(T::DbWeight::get().reads(1)) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 764_000 picoseconds. - Weight::from_parts(823_000, 0) + // Minimum execution time: 820_000 picoseconds. + Weight::from_parts(888_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 780_000 picoseconds. - Weight::from_parts(834_000, 0) + // Minimum execution time: 863_000 picoseconds. + Weight::from_parts(923_000, 0) } pub fn alias_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 807_000 picoseconds. - Weight::from_parts(872_000, 0) + // Minimum execution time: 863_000 picoseconds. + Weight::from_parts(930_000, 0) } // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) @@ -405,8 +405,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 8_399_000 picoseconds. - Weight::from_parts(8_708_000, 1485) + // Minimum execution time: 25_422_000 picoseconds. + Weight::from_parts(25_803_000, 1485) .saturating_add(T::DbWeight::get().reads(1)) } } From 459f361384f64d1c64c9e118e9a31ae21e504210 Mon Sep 17 00:00:00 2001 From: Raymond Cheung <178801527+raymondkfcheung@users.noreply.github.com> Date: Mon, 29 Sep 2025 16:52:32 +0100 Subject: [PATCH 50/50] Update PRDoc --- prdoc/pr_9808.prdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prdoc/pr_9808.prdoc b/prdoc/pr_9808.prdoc index 2911b2fa81cfc..2c822819b0c7c 100644 --- a/prdoc/pr_9808.prdoc +++ b/prdoc/pr_9808.prdoc @@ -1,7 +1,7 @@ -title: Add Barrier Benchmark for Accurate XCM Weight Accounting in Early Rejections +title: Benchmark Barrier for Accurate Weighting on Early Rejection doc: - audience: Runtime Dev - description: This PR improves weight accounting for barrier rejections. + description: This PR improves the weight accounting for XCMs that are rejected early by `Barrier`. crates: - name: asset-hub-rococo-runtime bump: patch