pallet-xcm: ensure xcm outcome is always complete, revert effects otherwise (#2405)

On extrinsics/call, ensure local XCM execution is complete/successful.
Otherwise, fail the extrinsic so that state changes don't get committed
to the db.

Added regression tests that fail without the fix.

fixes #2237

---------

Co-authored-by: Adrian Catangiu <adrian@parity.io>
This commit is contained in:
Xiliang Chen
2023-11-24 22:13:57 +13:00
committed by GitHub
parent a00a767604
commit 4163152506
10 changed files with 210 additions and 35 deletions
@@ -152,7 +152,7 @@ pub fn teleports_for_native_asset_works<
hash,
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Parent),
);
assert_eq!(outcome.ensure_complete(), Ok(()));
assert_ok!(outcome.ensure_complete());
// check Balances after
assert_ne!(<pallet_balances::Pallet<Runtime>>::free_balance(&target_account), 0.into());
@@ -499,7 +499,7 @@ pub fn teleports_for_foreign_assets_works<
hash,
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
);
assert_eq!(outcome.ensure_complete(), Ok(()));
assert_ok!(outcome.ensure_complete());
// checks target_account after
assert_eq!(
@@ -1211,7 +1211,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
hash,
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
);
assert_eq!(outcome.ensure_complete(), Ok(()));
assert_ok!(outcome.ensure_complete());
// check events
let mut events = <frame_system::Pallet<Runtime>>::events()
@@ -1319,7 +1319,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
hash,
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
);
assert_eq!(outcome.ensure_complete(), Ok(()));
assert_ok!(outcome.ensure_complete());
additional_checks_after();
})