Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1471572
feat(pallet-xcm): add an inner error to LocalExecutionIncomplete
franciscoaguirre Feb 26, 2025
95c3959
Merge branch 'master' into nest-inner-xcm-errors
raymondkfcheung May 13, 2025
abf74b1
Rename to LocalExecutionIncompleteWithError
raymondkfcheung May 13, 2025
68e14e6
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] May 13, 2025
dcd819f
Update PRDoc
raymondkfcheung May 13, 2025
28e1f95
Add tracing
raymondkfcheung May 13, 2025
08f1401
Update PRDoc
raymondkfcheung May 13, 2025
07d5ac5
Merge branch 'master' into nest-inner-xcm-errors
raymondkfcheung May 14, 2025
9cbc0b1
Merge branch 'master' into nest-inner-xcm-errors
franciscoaguirre May 14, 2025
318a102
feat(xcm-executor): add index to error
franciscoaguirre May 15, 2025
c2609f1
fix: Resolve compile errors with new nested error structure (#8561)
raymondkfcheung May 20, 2025
a573797
doc: update bumps
franciscoaguirre May 27, 2025
410f390
Update polkadot/xcm/src/v5/traits.rs
franciscoaguirre May 27, 2025
4375886
Update polkadot/xcm/src/v5/traits.rs
franciscoaguirre May 27, 2025
033dc98
Update polkadot/xcm/xcm-builder/src/process_xcm_message.rs
franciscoaguirre May 27, 2025
4144f05
chore: create OutcomeError
franciscoaguirre May 27, 2025
afcdfbb
Merge branch 'master' into nest-inner-xcm-errors
franciscoaguirre May 28, 2025
245de3e
Merge branch 'master' into nest-inner-xcm-errors
franciscoaguirre May 29, 2025
02bcb0b
fix: change OutcomeError in more places
franciscoaguirre May 29, 2025
0d2c5d6
fix(xcm-builder): tests
franciscoaguirre May 29, 2025
a5e5a44
fix(xcm-builder): more tests
franciscoaguirre May 29, 2025
11d82ba
fix: more tests
franciscoaguirre May 29, 2025
503ee01
Merge branch 'master' into nest-inner-xcm-errors
franciscoaguirre May 29, 2025
b572788
fix: more tests
franciscoaguirre May 30, 2025
fb57537
fix: tests
franciscoaguirre May 30, 2025
f97878a
chore: add InstructionIndex type alias
franciscoaguirre May 30, 2025
b7f65ff
fix: wrong taplo version fmts
franciscoaguirre May 30, 2025
5562c14
chore: rename OutcomeError to InstructionError
franciscoaguirre May 30, 2025
ba6ea6b
Merge branch 'master' into nest-inner-xcm-errors
x3c41a May 30, 2025
8ee25cd
feat(xcm-executor): return the correct index when weighing fails
franciscoaguirre May 30, 2025
f966995
Merge branch 'master' into nest-inner-xcm-errors
franciscoaguirre May 30, 2025
c7041b3
test(xcm-builder): add unit test for WeightLimitReached
franciscoaguirre May 30, 2025
e7bf2e4
fix(xcm-executor): add Weight::MAX in prepare calls
franciscoaguirre May 30, 2025
c68cafe
feat(xcm): return actual errors from Weigher
franciscoaguirre May 30, 2025
fc30bae
chore: use InstructionError directly in Outcome::Error
franciscoaguirre May 30, 2025
d12261c
fix: more tests
franciscoaguirre May 30, 2025
b3a1294
Merge branch 'master' into nest-inner-xcm-errors
franciscoaguirre May 30, 2025
bee5ab3
fix: tests
franciscoaguirre May 30, 2025
f12ec5b
fix: tests
franciscoaguirre May 30, 2025
241974e
fix(coretime-westend-runtime): test
franciscoaguirre May 30, 2025
b9cf32f
fix(xcm-executor-integration-tests): tests
franciscoaguirre May 30, 2025
d10e375
doc: update prdoc
franciscoaguirre May 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bridges/snowbridge/primitives/core/src/reward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ mod tests {
pub struct MockXcmExecutor;
impl<C> ExecuteXcm<C> for MockXcmExecutor {
type Prepared = Weightless;
fn prepare(message: Xcm<C>) -> Result<Self::Prepared, Xcm<C>> {
Err(message)
fn prepare(_: Xcm<C>, _: Weight) -> Result<Self::Prepared, InstructionError> {
Err(InstructionError { index: 0, error: XcmError::Unimplemented })
}
fn execute(
_: impl Into<Location>,
Expand Down Expand Up @@ -313,8 +313,8 @@ mod tests {
struct FailingXcmExecutor;
impl<C> ExecuteXcm<C> for FailingXcmExecutor {
type Prepared = Weightless;
fn prepare(message: Xcm<C>) -> Result<Self::Prepared, Xcm<C>> {
Err(message)
fn prepare(_: Xcm<C>, _: Weight) -> Result<Self::Prepared, InstructionError> {
Err(InstructionError { index: 0, error: XcmError::Unimplemented })
}
fn execute(
_: impl Into<Location>,
Expand Down
5 changes: 4 additions & 1 deletion bridges/snowbridge/runtime/test-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,10 @@ pub fn send_transfer_token_message_failure<Runtime, XcmConfig>(
destination_address,
fee_amount,
);
assert_err!(outcome.ensure_complete(), expected_error);
assert_err!(
outcome.ensure_complete(),
InstructionError { index: 0, error: expected_error }
);
});
}

Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/test-utils/src/mock_xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl PreparedMessage for Weightless {
pub struct MockXcmExecutor;
impl<C> ExecuteXcm<C> for MockXcmExecutor {
type Prepared = Weightless;
fn prepare(_: Xcm<C>) -> Result<Self::Prepared, Xcm<C>> {
fn prepare(_: Xcm<C>, _: Weight) -> Result<Self::Prepared, InstructionError> {
unreachable!()
}
fn execute(_: impl Into<Location>, _: Self::Prepared, _: &mut XcmHash, _: Weight) -> Outcome {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub use frame_support::{
pub use pallet_assets;
pub use pallet_message_queue;
pub use pallet_xcm;
pub use xcm;

// Polkadot
pub use polkadot_runtime_parachains::{
Expand Down Expand Up @@ -233,7 +234,7 @@ macro_rules! impl_assert_events_helpers_for_relay_chain {
vec![
// Dispatchable is properly executed and XCM message sent
[<$chain RuntimeEvent>]::<N>::XcmPallet(
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete { used: weight, error } }
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete { used: weight, error: $crate::impls::xcm::prelude::InstructionError { error, .. } } }
) => {
weight: $crate::impls::weight_within_threshold(
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
Expand Down Expand Up @@ -471,7 +472,7 @@ macro_rules! impl_assert_events_helpers_for_parachain {
vec![
// Dispatchable is properly executed and XCM message sent
[<$chain RuntimeEvent>]::<N>::PolkadotXcm(
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete { used: weight, error } }
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete { used: weight, error: $crate::impls::xcm::prelude::InstructionError { error, .. } } }
) => {
weight: $crate::impls::weight_within_threshold(
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
Expand All @@ -491,7 +492,7 @@ macro_rules! impl_assert_events_helpers_for_parachain {
vec![
// Execution fails in the origin with `Barrier`
[<$chain RuntimeEvent>]::<N>::PolkadotXcm(
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Error { error } }
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Error($crate::impls::xcm::prelude::InstructionError { error, .. }) }
) => {
error: *error == expected_error.unwrap_or((*error).into()).into(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,56 @@ use frame_support::{
use parachains_common::{AccountId, Balance};
use sp_tracing::capture_test_logs;
use std::convert::Into;
use xcm::latest::{Assets, Location, Xcm};
use xcm::latest::{Assets, Error as XcmError, Location, Xcm};

const UNITS: Balance = 1_000_000_000;

#[test]
fn exchange_asset_success() {
test_exchange_asset(true, 500 * UNITS, 665 * UNITS, true);
test_exchange_asset(true, 500 * UNITS, 665 * UNITS, None);
}

#[test]
fn exchange_asset_insufficient_liquidity() {
let log_capture = capture_test_logs!({
test_exchange_asset(true, 1_000 * UNITS, 2_000 * UNITS, false);
test_exchange_asset(
true,
1_000 * UNITS,
2_000 * UNITS,
Some(InstructionError { index: 1, error: XcmError::NoDeal }),
);
});
assert!(log_capture.contains("NoDeal"));
}

#[test]
fn exchange_asset_insufficient_balance() {
let log_capture = capture_test_logs!({
test_exchange_asset(true, 5_000 * UNITS, 1_665 * UNITS, false);
test_exchange_asset(
true,
5_000 * UNITS,
1_665 * UNITS,
Some(InstructionError { index: 0, error: XcmError::FailedToTransactAsset("") }),
);
});
assert!(log_capture.contains("Funds are unavailable"));
}

#[test]
fn exchange_asset_pool_not_created() {
test_exchange_asset(false, 500 * UNITS, 665 * UNITS, false);
test_exchange_asset(
false,
500 * UNITS,
665 * UNITS,
Some(InstructionError { index: 1, error: XcmError::NoDeal }),
);
}

fn test_exchange_asset(
create_pool: bool,
give_amount: Balance,
want_amount: Balance,
should_succeed: bool,
expected_error: Option<InstructionError>,
) {
let alice: AccountId = Westend::account_id_of(ALICE);
let native_asset_location = WestendLocation::get();
Expand Down Expand Up @@ -112,20 +127,13 @@ fn test_exchange_asset(
let foreign_balance_after = ForeignAssets::balance(asset_location, &alice);
let wnd_balance_after = Balances::total_balance(&alice);

if should_succeed {
assert_ok!(result);
assert!(
foreign_balance_after >= foreign_balance_before + want_amount,
"Expected foreign balance to increase by at least {want_amount} units, got {foreign_balance_after} from {foreign_balance_before}"
);
assert_eq!(
wnd_balance_after, wnd_balance_before - give_amount,
"Expected WND balance to decrease by {give_amount} units, got {wnd_balance_after} from {wnd_balance_before}"
);
} else {
if let Some(InstructionError { index, error }) = expected_error {
assert_err_ignore_postinfo!(
result,
pallet_xcm::Error::<Runtime>::LocalExecutionIncomplete
pallet_xcm::Error::<Runtime>::LocalExecutionIncompleteWithError {
index,
error: error.into()
}
);
assert_eq!(
foreign_balance_after, foreign_balance_before,
Expand All @@ -135,6 +143,16 @@ fn test_exchange_asset(
wnd_balance_after, wnd_balance_before,
"WND balance changed unexpectedly: got {wnd_balance_after}, expected {wnd_balance_before}"
);
} else {
assert_ok!(result);
assert!(
foreign_balance_after >= foreign_balance_before + want_amount,
"Expected foreign balance to increase by at least {want_amount} units, got {foreign_balance_after} from {foreign_balance_before}"
);
assert_eq!(
wnd_balance_after, wnd_balance_before - give_amount,
"Expected WND balance to decrease by {give_amount} units, got {wnd_balance_after} from {wnd_balance_before}"
);
}
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,10 @@ fn export_message_from_asset_hub_to_ethereum_is_banned_when_set_operating_mode()
bx!(xcm),
Weight::from(EXECUTION_WEIGHT),
),
pallet_xcm::Error::<Runtime>::LocalExecutionIncomplete
pallet_xcm::Error::<Runtime>::LocalExecutionIncompleteWithError {
error: XcmError::Unroutable.into(),
index: 2
}
);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -1417,23 +1417,23 @@ fn governance_authorize_upgrade_works() {
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(12334)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - AssetHub
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(ASSET_HUB_ID)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - Collectives
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(COLLECTIVES_ID)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - Collectives Voice of Fellows plurality
assert_err!(
Expand All @@ -1444,7 +1444,7 @@ fn governance_authorize_upgrade_works() {
Location::new(1, Parachain(COLLECTIVES_ID)),
Plurality { id: BodyId::Technical, part: BodyPart::Voice }.into()
)),
Either::Right(XcmError::BadOrigin)
Either::Right(InstructionError { index: 2, error: XcmError::BadOrigin })
);

// ok - relaychain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -781,23 +781,23 @@ fn governance_authorize_upgrade_works() {
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(12334)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - AssetHub
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(ASSET_HUB_ID)))),
Either::Right(XcmError::BadOrigin)
Either::Right(InstructionError { index: 1, error: XcmError::BadOrigin })
);
// no - Collectives
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(COLLECTIVES_ID)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - Collectives Voice of Fellows plurality
assert_err!(
Expand All @@ -808,7 +808,7 @@ fn governance_authorize_upgrade_works() {
Location::new(1, Parachain(COLLECTIVES_ID)),
Plurality { id: BodyId::Technical, part: BodyPart::Voice }.into()
)),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);

// ok - relaychain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ where
]);

// get weight
let weight = XcmConfig::Weigher::weight(&mut xcm);
let weight = XcmConfig::Weigher::weight(&mut xcm, Weight::MAX);
assert_ok!(weight);
let weight = weight.unwrap();
// check if sane
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,23 @@ fn governance_authorize_upgrade_works() {
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(12334)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - AssetHub
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(ASSET_HUB_ID)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - Collectives
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(COLLECTIVES_ID)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - Collectives Voice of Fellows plurality
assert_err!(
Expand All @@ -188,7 +188,7 @@ fn governance_authorize_upgrade_works() {
Location::new(1, Parachain(COLLECTIVES_ID)),
Plurality { id: BodyId::Technical, part: BodyPart::Voice }.into()
)),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);

// ok - relaychain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,23 @@ fn governance_authorize_upgrade_works() {
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(12334)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - AssetHub
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(ASSET_HUB_ID)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - Collectives
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(COLLECTIVES_ID)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - Collectives Voice of Fellows plurality
assert_err!(
Expand All @@ -188,7 +188,7 @@ fn governance_authorize_upgrade_works() {
Location::new(1, Parachain(COLLECTIVES_ID)),
Plurality { id: BodyId::Technical, part: BodyPart::Voice }.into()
)),
Either::Right(XcmError::BadOrigin)
Either::Right(InstructionError { index: 2, error: XcmError::BadOrigin })
);

// ok - relaychain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,23 @@ fn governance_authorize_upgrade_works() {
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(12334)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - AssetHub
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(ASSET_HUB_ID)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - Collectives
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(COLLECTIVES_ID)))),
Either::Right(XcmError::Barrier)
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
);
// no - Collectives Voice of Fellows plurality
assert_err!(
Expand All @@ -188,7 +188,7 @@ fn governance_authorize_upgrade_works() {
Location::new(1, Parachain(COLLECTIVES_ID)),
Plurality { id: BodyId::Technical, part: BodyPart::Voice }.into()
)),
Either::Right(XcmError::BadOrigin)
Either::Right(InstructionError { index: 2, error: XcmError::BadOrigin })
);

// ok - relaychain
Expand Down
2 changes: 1 addition & 1 deletion cumulus/parachains/runtimes/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ impl<
pub fn execute_as_governance_call<Call: Dispatchable + Encode>(
call: Call,
governance_origin: GovernanceOrigin<Call::RuntimeOrigin>,
) -> Result<(), Either<DispatchError, XcmError>> {
) -> Result<(), Either<DispatchError, InstructionError>> {
// execute xcm as governance would send
let execute_xcm = |call: Call, governance_location, descend_origin| {
// prepare xcm
Expand Down
Loading