Skip to content

Commit 8426299

Browse files
[stable2409] Backport #7843 (#7967)
Backport #7843 into `stable2409` from raymondkfcheung. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> --------- Co-authored-by: Raymond Cheung <[email protected]>
1 parent de5b874 commit 8426299

5 files changed

Lines changed: 42 additions & 8 deletions

File tree

polkadot/xcm/xcm-builder/src/tests/origins.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ fn unpaid_execution_should_work() {
139139
Weight::from_parts(50, 50),
140140
Weight::zero(),
141141
);
142-
assert_eq!(r, Outcome::Error { error: XcmError::Barrier });
142+
assert_eq!(
143+
r,
144+
Outcome::Incomplete { used: Weight::from_parts(10, 10), error: XcmError::Barrier }
145+
);
143146

144147
let message = Xcm(vec![UnpaidExecution {
145148
weight_limit: Limited(Weight::from_parts(10, 10)),

polkadot/xcm/xcm-builder/src/tests/querying.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,8 @@ fn prepaid_result_of_query_should_get_free_execution() {
130130
weight_limit,
131131
Weight::zero(),
132132
);
133-
assert_eq!(r, Outcome::Error { error: XcmError::Barrier });
133+
assert_eq!(
134+
r,
135+
Outcome::Incomplete { used: Weight::from_parts(10, 10), error: XcmError::Barrier }
136+
);
134137
}

polkadot/xcm/xcm-builder/src/tests/version_subscriptions.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn simple_version_subscriptions_should_work() {
3737
weight_limit,
3838
Weight::zero(),
3939
),
40-
Outcome::Error { error: XcmError::Barrier }
40+
Outcome::Incomplete { used: Weight::from_parts(20, 20), error: XcmError::Barrier }
4141
);
4242

4343
// this case fails because the additional `SetAppendix` instruction is not allowed in the
@@ -50,7 +50,7 @@ fn simple_version_subscriptions_should_work() {
5050
weight_limit,
5151
Weight::zero(),
5252
),
53-
Outcome::Error { error: XcmError::Barrier }
53+
Outcome::Incomplete { used: Weight::from_parts(20, 20), error: XcmError::Barrier }
5454
);
5555

5656
let message = Xcm::<TestCall>(vec![SubscribeVersion {
@@ -66,7 +66,10 @@ fn simple_version_subscriptions_should_work() {
6666
weight_limit,
6767
Weight::zero(),
6868
);
69-
assert_eq!(r, Outcome::Error { error: XcmError::Barrier });
69+
assert_eq!(
70+
r,
71+
Outcome::Incomplete { used: Weight::from_parts(10, 10), error: XcmError::Barrier }
72+
);
7073

7174
let r = XcmExecutor::<TestConfig>::prepare_and_execute(
7275
Parent,
@@ -139,7 +142,10 @@ fn simple_version_unsubscriptions_should_work() {
139142
weight_limit,
140143
Weight::zero(),
141144
);
142-
assert_eq!(r, Outcome::Error { error: XcmError::Barrier });
145+
assert_eq!(
146+
r,
147+
Outcome::Incomplete { used: Weight::from_parts(20, 20), error: XcmError::Barrier }
148+
);
143149

144150
let origin = Parachain(1000);
145151
let message = Xcm::<TestCall>(vec![UnsubscribeVersion]);
@@ -152,7 +158,10 @@ fn simple_version_unsubscriptions_should_work() {
152158
weight_limit,
153159
Weight::zero(),
154160
);
155-
assert_eq!(r, Outcome::Error { error: XcmError::Barrier });
161+
assert_eq!(
162+
r,
163+
Outcome::Incomplete { used: Weight::from_parts(10, 10), error: XcmError::Barrier }
164+
);
156165

157166
let r = XcmExecutor::<TestConfig>::prepare_and_execute(
158167
Parent,

polkadot/xcm/xcm-executor/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,11 @@ impl<Config: config::Config> ExecuteXcm<Config::RuntimeCall> for XcmExecutor<Con
243243
error = ?e,
244244
"Barrier blocked execution",
245245
);
246-
return Outcome::Error { error: XcmError::Barrier }
246+
247+
return Outcome::Incomplete {
248+
used: xcm_weight, // Weight consumed before the error
249+
error: XcmError::Barrier, // The error that occurred
250+
};
247251
}
248252

249253
*id = properties.message_id.unwrap_or(*id);

prdoc/pr_7967.prdoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
title: Fix XCM Barrier Rejection Handling to Return Incomplete with Weight
2+
doc:
3+
- audience: Runtime Dev
4+
description: "This PR addresses an issue with the handling of message execution\
5+
\ when blocked by the barrier. Instead of returning an `Outcome::Error`, we modify\
6+
\ the behaviour to return `Outcome::Incomplete`, which includes the weight consumed\
7+
\ up to the point of rejection and the error that caused the blockage.\n\nThis\
8+
\ change ensures more accurate weight tracking during message execution, even\
9+
\ when interrupted. It improves resource management and aligns the XCM executor\u2019\
10+
s behaviour with better error handling practices."
11+
crates:
12+
- name: staging-xcm-executor
13+
bump: patch
14+
- name: staging-xcm-builder
15+
bump: patch

0 commit comments

Comments
 (0)