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:
authored and GitHub committed 2024-03-27 08:31:01 +00:00
1 parent 66051adb61
commit feee773d15
36 files changed
+1133 -642

No files matched your search

@@ -23,7 +23,6 @@ use crate::{
};
use codec::{Decode, Encode};
use frame_support::{
assert_err,
pallet_prelude::Weight,
traits::{fungibles::Mutate, Currency},
};
@@ -102,7 +101,7 @@ fn test_xcm_execute() {
0,
Weight::MAX,
None,
VersionedXcm::V4(message).encode(),
VersionedXcm::V4(message).encode().encode(),
DebugInfo::UnsafeDebug,
CollectEvents::UnsafeCollect,
Determinism::Enforced,
@@ -146,7 +145,7 @@ fn test_xcm_execute_incomplete() {
0,
Weight::MAX,
None,
VersionedXcm::V4(message).encode(),
VersionedXcm::V4(message).encode().encode(),
DebugInfo::UnsafeDebug,
CollectEvents::UnsafeCollect,
Determinism::Enforced,
@@ -160,37 +159,6 @@ fn test_xcm_execute_incomplete() {
});
}
#[test]
fn test_xcm_execute_filtered_call() {
MockNet::reset();
let contract_addr = instantiate_test_contract("xcm_execute");
ParaA::execute_with(|| {
// `remark` should be rejected, as it is not allowed by our CallFilter.
let call = parachain::RuntimeCall::System(frame_system::Call::remark { remark: vec![] });
let message: Xcm<parachain::RuntimeCall> = Xcm(vec![Transact {
origin_kind: OriginKind::Native,
require_weight_at_most: Weight::MAX,
call: call.encode().into(),
}]);
let result = ParachainContracts::bare_call(
ALICE,
contract_addr.clone(),
0,
Weight::MAX,
None,
VersionedXcm::V4(message).encode(),
DebugInfo::UnsafeDebug,
CollectEvents::UnsafeCollect,
Determinism::Enforced,
);
assert_err!(result.result, frame_system::Error::<parachain::Runtime>::CallFiltered);
});
}
#[test]
fn test_xcm_execute_reentrant_call() {
MockNet::reset();
@@ -222,7 +190,7 @@ fn test_xcm_execute_reentrant_call() {
0,
Weight::MAX,
None,
VersionedXcm::V4(message).encode(),
VersionedXcm::V4(message).encode().encode(),
DebugInfo::UnsafeDebug,
CollectEvents::UnsafeCollect,
Determinism::Enforced,
@@ -258,7 +226,7 @@ fn test_xcm_send() {
0,
Weight::MAX,
None,
(dest, message).encode(),
(dest, message.encode()).encode(),
DebugInfo::UnsafeDebug,
CollectEvents::UnsafeCollect,
Determinism::Enforced,