pallet-xcm: Deprecate execute and send in favor of execute_blob and send_blob (#3749)

`execute` and `send` try to decode the xcm in the parameters before
reaching the filter line.
The new extrinsics decode only after the filter line.
These should be used instead of the old ones.

## TODO
- [x] Tests
- [x] Generate weights
- [x] Deprecation issue ->
https://github.com/paritytech/polkadot-sdk/issues/3771
- [x] PRDoc
- [x] Handle error in pallet-contracts

This would make writing XCMs in PJS Apps more difficult, but here's the
fix for that: https://github.com/polkadot-js/apps/pull/10350.
Already deployed! https://polkadot.js.org/apps/#/utilities/xcm

Supersedes https://github.com/paritytech/polkadot-sdk/pull/1798/

---------

Co-authored-by: PG Herveou <pgherveou@gmail.com>
Co-authored-by: command-bot <>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
This commit is contained in:
Francisco Aguirre
2024-03-27 09:31:01 +01:00
committed by GitHub
parent 66051adb61
commit feee773d15
36 changed files with 1133 additions and 642 deletions
@@ -14,6 +14,7 @@
// limitations under the License.
use crate::tests::*;
use codec::Encode;
#[test]
fn send_xcm_from_rococo_relay_to_westend_asset_hub_should_fail_on_not_applicable() {
@@ -26,7 +27,7 @@ fn send_xcm_from_rococo_relay_to_westend_asset_hub_should_fail_on_not_applicable
let remote_xcm = Xcm(vec![ClearOrigin]);
let xcm = VersionedXcm::from(Xcm(vec![
let xcm = VersionedXcm::from(Xcm::<()>(vec![
UnpaidExecution { weight_limit, check_origin },
ExportMessage {
network: WestendId.into(),
@@ -38,10 +39,10 @@ fn send_xcm_from_rococo_relay_to_westend_asset_hub_should_fail_on_not_applicable
// Rococo Global Consensus
// Send XCM message from Relay Chain to Bridge Hub source Parachain
Rococo::execute_with(|| {
assert_ok!(<Rococo as RococoPallet>::XcmPallet::send(
assert_ok!(<Rococo as RococoPallet>::XcmPallet::send_blob(
sudo_origin,
bx!(destination),
bx!(xcm),
xcm.encode().try_into().unwrap(),
));
type RuntimeEvent = <Rococo as Chain>::RuntimeEvent;
@@ -83,7 +83,7 @@ fn create_agent() {
let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {});
// Construct XCM to create an agent for para 1001
let remote_xcm = VersionedXcm::from(Xcm(vec![
let remote_xcm = VersionedXcm::from(Xcm::<()>(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
DescendOrigin(Parachain(origin_para).into()),
Transact {
@@ -96,10 +96,10 @@ fn create_agent() {
// Rococo Global Consensus
// Send XCM message from Relay Chain to Bridge Hub source Parachain
Rococo::execute_with(|| {
assert_ok!(<Rococo as RococoPallet>::XcmPallet::send(
assert_ok!(<Rococo as RococoPallet>::XcmPallet::send_blob(
sudo_origin,
bx!(destination),
bx!(remote_xcm),
remote_xcm.encode().try_into().unwrap(),
));
type RuntimeEvent = <Rococo as Chain>::RuntimeEvent;
@@ -141,7 +141,7 @@ fn create_channel() {
let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {});
// Construct XCM to create an agent for para 1001
let create_agent_xcm = VersionedXcm::from(Xcm(vec![
let create_agent_xcm = VersionedXcm::from(Xcm::<()>(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
DescendOrigin(Parachain(origin_para).into()),
Transact {
@@ -154,7 +154,7 @@ fn create_channel() {
let create_channel_call =
SnowbridgeControl::Control(ControlCall::CreateChannel { mode: OperatingMode::Normal });
// Construct XCM to create a channel for para 1001
let create_channel_xcm = VersionedXcm::from(Xcm(vec![
let create_channel_xcm = VersionedXcm::from(Xcm::<()>(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
DescendOrigin(Parachain(origin_para).into()),
Transact {
@@ -167,16 +167,16 @@ fn create_channel() {
// Rococo Global Consensus
// Send XCM message from Relay Chain to Bridge Hub source Parachain
Rococo::execute_with(|| {
assert_ok!(<Rococo as RococoPallet>::XcmPallet::send(
assert_ok!(<Rococo as RococoPallet>::XcmPallet::send_blob(
sudo_origin.clone(),
bx!(destination.clone()),
bx!(create_agent_xcm),
create_agent_xcm.encode().try_into().unwrap(),
));
assert_ok!(<Rococo as RococoPallet>::XcmPallet::send(
assert_ok!(<Rococo as RococoPallet>::XcmPallet::send_blob(
sudo_origin,
bx!(destination),
bx!(create_channel_xcm),
create_channel_xcm.encode().try_into().unwrap(),
));
type RuntimeEvent = <Rococo as Chain>::RuntimeEvent;