Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

XCM v2: Scripting, Query responses, Exception handling and Error reporting #3629

Merged
merged 91 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
719efe0
Intoduce XCM v2
gavofyork Aug 10, 2021
b2dae98
Minor version cleanup
gavofyork Aug 10, 2021
5ab1b8b
Minor version cleanup
gavofyork Aug 10, 2021
c854e94
Introduce SendError for XcmSend trait to avoid cycles with having Out…
gavofyork Aug 10, 2021
1e287f3
comment
gavofyork Aug 10, 2021
c279e44
Corrent type
gavofyork Aug 10, 2021
632a992
Docs
gavofyork Aug 10, 2021
18ef569
Fix build
gavofyork Aug 10, 2021
ef3bc2e
Fixes
gavofyork Aug 10, 2021
eaea484
Build
gavofyork Aug 10, 2021
9820197
Introduce the basic impl
gavofyork Aug 10, 2021
82a67f7
Docs
gavofyork Aug 12, 2021
ace53dc
Add function
gavofyork Aug 12, 2021
49f1895
Merge remote-tracking branch 'origin/master' into gav-xcm-v2
gavofyork Aug 12, 2021
c6835ae
Basic implementation
gavofyork Aug 12, 2021
19617eb
Weighed responses and on_report
gavofyork Aug 12, 2021
0831192
Make XCM more script-like
gavofyork Aug 14, 2021
62d76b4
Remove BuyExecution::orders
gavofyork Aug 14, 2021
2bf963c
Fixes
gavofyork Aug 15, 2021
d58848f
Fixes
gavofyork Aug 15, 2021
e97f993
Fixes
gavofyork Aug 15, 2021
1a0e0ce
Formatting
gavofyork Aug 15, 2021
89debf5
Merge branch 'gav-rm-buy-orders' into gav-xcm-v2
gavofyork Aug 15, 2021
4516074
Initial draft and make pallet-xcm build
gavofyork Aug 16, 2021
329360f
fix XCM tests
gavofyork Aug 16, 2021
0ca87bd
Formatting
gavofyork Aug 16, 2021
15b9371
Merge remote-tracking branch 'origin/master' into gav-xcm-v2
gavofyork Aug 16, 2021
40efb2e
Fixes
gavofyork Aug 16, 2021
36f7a4e
Formatting
gavofyork Aug 16, 2021
33594b3
spelling
gavofyork Aug 16, 2021
8fd21f2
Fixes
gavofyork Aug 16, 2021
30c225d
Fixes
gavofyork Aug 17, 2021
b0f884e
spelling
gavofyork Aug 17, 2021
732ec50
tests for translation
gavofyork Aug 17, 2021
fbd84e4
extra fields to XCM pallet
gavofyork Aug 17, 2021
236f275
Formatting
gavofyork Aug 17, 2021
0188a9d
Fixes
gavofyork Aug 17, 2021
dcdf01d
spelling
gavofyork Aug 17, 2021
3d20770
first integration test
gavofyork Aug 17, 2021
0b27f43
Another integration test
gavofyork Aug 18, 2021
11b8a80
Formatting
gavofyork Aug 20, 2021
df76b24
Merge remote-tracking branch 'origin/master' into gav-xcm-v2
gavofyork Aug 20, 2021
170a20d
fix tests
gavofyork Aug 20, 2021
26330fa
all tests
gavofyork Aug 21, 2021
5d03978
Fixes
gavofyork Aug 21, 2021
7e7528d
Fixes
gavofyork Aug 22, 2021
b462eae
Formatting
gavofyork Aug 22, 2021
e1f36c4
Fixes
gavofyork Aug 22, 2021
a0db17a
Fixes
gavofyork Aug 22, 2021
653a2a2
Formatting
gavofyork Aug 22, 2021
f1ce4eb
Bump
gavofyork Aug 22, 2021
07ba2d0
Remove unneeded structuring
gavofyork Aug 22, 2021
48baab6
add instruction
gavofyork Aug 22, 2021
f317a64
Fixes
gavofyork Aug 22, 2021
dd80ebc
spelling
gavofyork Aug 22, 2021
de5e76c
Fixes
gavofyork Aug 22, 2021
e798658
Fixes
gavofyork Aug 22, 2021
df8f941
Formatting
gavofyork Aug 22, 2021
e39b1e6
Fixes
gavofyork Aug 22, 2021
bea12fb
Fixes
gavofyork Aug 23, 2021
2b47c3c
Formatting
gavofyork Aug 23, 2021
ca21160
Introduce and use VersionedResponse
gavofyork Aug 23, 2021
a062919
Introduce versioning to dispatchables' params
gavofyork Aug 23, 2021
26ca165
Fixes
gavofyork Aug 23, 2021
aeba4a8
Formatting
gavofyork Aug 23, 2021
1862f69
Merge branch 'gav-versioned-params' into gav-xcm-v2
gavofyork Aug 23, 2021
d92b7a7
Rest of merge
gavofyork Aug 23, 2021
c4c45d5
Merge branch 'gav-xcm-v2' into gav-xcm-trycatch
gavofyork Aug 23, 2021
7d7f2ac
more work
gavofyork Aug 23, 2021
604414c
Formatting
gavofyork Aug 23, 2021
8130a36
Basic logic
gavofyork Aug 23, 2021
fc58298
Fixes
gavofyork Aug 24, 2021
93dc645
Fixes
gavofyork Aug 24, 2021
6b5045f
Merge branch 'gav-xcm-v2' into gav-xcm-trycatch
gavofyork Aug 24, 2021
22fcbf2
Fixes
gavofyork Aug 24, 2021
7f5add7
Add test
gavofyork Aug 24, 2021
8c231a0
Fixes
gavofyork Aug 24, 2021
745835f
Formatting
gavofyork Aug 24, 2021
bb046cc
Fixes
gavofyork Aug 24, 2021
34dae85
Fixes
gavofyork Aug 24, 2021
ffe8513
Fixes
gavofyork Aug 24, 2021
c0f1875
Nits
gavofyork Aug 25, 2021
7b243cc
Simplify
gavofyork Aug 25, 2021
9f7e88c
Spelling
gavofyork Aug 25, 2021
8f07df6
Formatting
gavofyork Aug 25, 2021
41d8435
Return weight of unexecuted instructions in case of error as surplus
gavofyork Aug 25, 2021
53fc8dd
Formatting
gavofyork Aug 25, 2021
944b597
Fixes
gavofyork Aug 25, 2021
bcbacce
Test for instruction count limiting
gavofyork Aug 25, 2021
8c8d434
Formatting
gavofyork Aug 25, 2021
feb79ce
Docs
gavofyork Aug 25, 2021
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
12 changes: 6 additions & 6 deletions runtime/common/src/xcm_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@
use parity_scale_codec::Encode;
use runtime_parachains::{configuration, dmp};
use sp_std::marker::PhantomData;
use xcm::opaque::latest::*;
use xcm::latest::prelude::*;

/// XCM sender for relay chain. It only sends downward message.
pub struct ChildParachainRouter<T, W>(PhantomData<(T, W)>);

impl<T: configuration::Config + dmp::Config, W: xcm::WrapVersion> SendXcm
for ChildParachainRouter<T, W>
{
fn send_xcm(dest: MultiLocation, msg: Xcm) -> Result {
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> SendResult {
match dest {
MultiLocation { parents: 0, interior: Junctions::X1(Junction::Parachain(id)) } => {
MultiLocation { parents: 0, interior: X1(Parachain(id)) } => {
// Downward message passing.
let versioned_xcm =
W::wrap_version(&dest, msg).map_err(|()| Error::DestinationUnsupported)?;
W::wrap_version(&dest, msg).map_err(|()| SendError::DestinationUnsupported)?;
let config = <configuration::Pallet<T>>::config();
<dmp::Pallet<T>>::queue_downward_message(
&config,
id.into(),
versioned_xcm.encode(),
)
.map_err(Into::<Error>::into)?;
.map_err(Into::<SendError>::into)?;
Ok(())
},
dest => Err(Error::CannotReachDestination(dest, msg)),
dest => Err(SendError::CannotReachDestination(dest, msg)),
}
}
}
2 changes: 2 additions & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,8 @@ impl pallet_xcm::Config for Runtime {
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
}

parameter_types! {
Expand Down
6 changes: 3 additions & 3 deletions runtime/parachains/src/dmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use frame_support::pallet_prelude::*;
use primitives::v1::{DownwardMessage, Hash, Id as ParaId, InboundDownwardMessage};
use sp_runtime::traits::{BlakeTwo256, Hash as HashT, SaturatedConversion};
use sp_std::{fmt, prelude::*};
use xcm::latest::Error as XcmError;
use xcm::latest::SendError;

pub use pallet::*;

Expand All @@ -33,10 +33,10 @@ pub enum QueueDownwardMessageError {
ExceedsMaxMessageSize,
}

impl From<QueueDownwardMessageError> for XcmError {
impl From<QueueDownwardMessageError> for SendError {
fn from(err: QueueDownwardMessageError) -> Self {
match err {
QueueDownwardMessageError::ExceedsMaxMessageSize => XcmError::ExceedsMaxMessageSize,
QueueDownwardMessageError::ExceedsMaxMessageSize => SendError::ExceedsMaxMessageSize,
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions runtime/parachains/src/hrmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,13 +1007,13 @@ impl<T: Config> Pallet<T> {

let notification_bytes = {
use parity_scale_codec::Encode as _;
use xcm::opaque::{v1::Xcm, VersionedXcm};
use xcm::opaque::{latest::prelude::*, VersionedXcm};

VersionedXcm::from(Xcm::HrmpNewChannelOpenRequest {
VersionedXcm::from(Xcm(vec![HrmpNewChannelOpenRequest {
sender: u32::from(origin),
max_capacity: proposed_max_capacity,
max_message_size: proposed_max_message_size,
})
}]))
.encode()
};
if let Err(dmp::QueueDownwardMessageError::ExceedsMaxMessageSize) =
Expand Down Expand Up @@ -1066,9 +1066,9 @@ impl<T: Config> Pallet<T> {

let notification_bytes = {
use parity_scale_codec::Encode as _;
use xcm::opaque::{v1::Xcm, VersionedXcm};

VersionedXcm::from(Xcm::HrmpChannelAccepted { recipient: u32::from(origin) }).encode()
use xcm::opaque::{latest::prelude::*, VersionedXcm};
let xcm = Xcm(vec![HrmpChannelAccepted { recipient: u32::from(origin) }]);
VersionedXcm::from(xcm).encode()
};
if let Err(dmp::QueueDownwardMessageError::ExceedsMaxMessageSize) =
<dmp::Pallet<T>>::queue_downward_message(&config, sender, notification_bytes)
Expand Down Expand Up @@ -1106,13 +1106,13 @@ impl<T: Config> Pallet<T> {
let config = <configuration::Pallet<T>>::config();
let notification_bytes = {
use parity_scale_codec::Encode as _;
use xcm::opaque::{v1::Xcm, VersionedXcm};
use xcm::opaque::{latest::prelude::*, VersionedXcm};

VersionedXcm::from(Xcm::HrmpChannelClosing {
VersionedXcm::from(Xcm(vec![HrmpChannelClosing {
initiator: u32::from(origin),
sender: u32::from(channel_id.sender),
recipient: u32::from(channel_id.recipient),
})
}]))
.encode()
};
let opposite_party =
Expand Down
2 changes: 2 additions & 0 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@ impl pallet_xcm::Config for Runtime {
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
}

impl parachains_session_info::Config for Runtime {}
Expand Down
2 changes: 2 additions & 0 deletions runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ impl pallet_xcm::Config for Runtime {
type XcmExecutor = xcm_executor::XcmExecutor<xcm_config::XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything;
type Origin = Origin;
type Call = Call;
}

impl parachains_hrmp::Config for Runtime {
Expand Down
7 changes: 2 additions & 5 deletions runtime/test-runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use frame_support::{parameter_types, traits::Everything, weights::Weight};
use xcm::latest::{
Error as XcmError, Junctions::Here, MultiAsset, MultiLocation, NetworkId, Parent,
Result as XcmResult, SendXcm, Xcm,
};
use xcm::latest::prelude::*;
use xcm_builder::{AllowUnpaidExecutionFrom, FixedWeightBounds, SignedToAccountId32};
use xcm_executor::{
traits::{InvertLocation, TransactAsset, WeightTrader},
Expand All @@ -38,7 +35,7 @@ pub type LocalOriginToLocation = (

pub struct DoNothingRouter;
impl SendXcm for DoNothingRouter {
fn send_xcm(_dest: MultiLocation, _msg: Xcm<()>) -> XcmResult {
fn send_xcm(_dest: MultiLocation, _msg: Xcm<()>) -> SendResult {
Ok(())
}
}
Expand Down
2 changes: 2 additions & 0 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,8 @@ impl pallet_xcm::Config for Runtime {
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
}

construct_runtime! {
Expand Down
4 changes: 4 additions & 0 deletions scripts/gitlab/lingua.dic
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ inverter/MS
io
IP/S
isn
isolatable
isolate/BG
iterable
jaeger/MS
Expand Down Expand Up @@ -200,6 +201,7 @@ responder/SM
retriability
reverify
roundtrip/MS
routable
rpc
RPC/MS
runtime/MS
Expand Down Expand Up @@ -231,6 +233,7 @@ taskmanager/MS
TCP
teleport/D
teleport/RG
teleports
teleportation/SM
teleporter/SM
teleporters
Expand All @@ -251,6 +254,7 @@ unordered
unreceived
unreserve
unreserving
unroutable
unservable/B
untrusted
untyped
Expand Down
Loading