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

XCM v0 #1657

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
8f6ce0e
Rename XCMP -> Xcmp
gavofyork Aug 25, 2020
6ce0b56
Merge remote-tracking branch 'origin/rococo-branch' into gav-xcmp
gavofyork Aug 26, 2020
4ba8022
WiP: Xcm
gavofyork Aug 29, 2020
7492c3b
Finish up on draft
gavofyork Aug 31, 2020
9658a23
Remove old code, work on getting it all to build.
gavofyork Aug 31, 2020
84d1c55
XCM handler and parachains now build 🎉
gavofyork Aug 31, 2020
0c0796e
Various fixes
gavofyork Sep 4, 2020
a563c53
Fix compilation
bkchr Sep 7, 2020
38656a0
fix tests
shawntabrizi Sep 7, 2020
d8b67f1
Merge branch 'gav-xcmp' of https://github.com/paritytech/polkadot int…
shawntabrizi Sep 7, 2020
9c16e3d
bump parity-scale-codec 1.3.5, fix `dest_` -> `dest`
shawntabrizi Sep 7, 2020
f979fab
remove unused
shawntabrizi Sep 7, 2020
87e2090
Remove defunct code
gavofyork Sep 8, 2020
f672cc6
Merge branch 'gav-xcmp' of github.com:paritytech/polkadot into gav-xcmp
gavofyork Sep 8, 2020
4d2e8d1
Derive `RuntimeDebug` across XCM enums
shawntabrizi Sep 9, 2020
db7aa74
Working
gavofyork Sep 9, 2020
89b3695
More work
gavofyork Sep 9, 2020
3115e1d
Some fixes
bkchr Sep 10, 2020
0dfcd00
Merge branch 'gav-xcmp' into gav-xcmp-working
gavofyork Sep 10, 2020
9dd154b
More work
gavofyork Sep 10, 2020
4163db9
Merge branch 'gav-xcmp-working' of github.com:paritytech/polkadot int…
gavofyork Sep 10, 2020
0566de0
Move interpreter into polkadot, split & repot
gavofyork Sep 10, 2020
a5c0e95
Move interpreter into polkadot, split & repot
gavofyork Sep 10, 2020
fdfabe6
Remove 'static'
gavofyork Sep 10, 2020
fa116b0
Fix toml file
bkchr Sep 10, 2020
10f8641
imports
shawntabrizi Sep 10, 2020
3887848
fix filename
shawntabrizi Sep 10, 2020
b2384b9
some fixes
shawntabrizi Sep 10, 2020
7d158e8
Fix
gavofyork Sep 10, 2020
8743525
Merge branch 'gav-xcmp-working' of github.com:paritytech/polkadot int…
gavofyork Sep 10, 2020
060a337
Fixes
gavofyork Sep 10, 2020
9a4497a
Fixes
gavofyork Sep 10, 2020
ee07247
Fixes
gavofyork Sep 10, 2020
2d9550e
Fixes
gavofyork Sep 10, 2020
3ae493e
Fixes
gavofyork Sep 10, 2020
40a6fb0
Fixes
gavofyork Sep 10, 2020
534b731
Fixes
gavofyork Sep 10, 2020
953a581
Fixes
gavofyork Sep 10, 2020
91f3914
Fixes
gavofyork Sep 10, 2020
ba8bdaa
Fixes
gavofyork Sep 10, 2020
52affef
Fixes
gavofyork Sep 10, 2020
1b1e265
fixes
shawntabrizi Sep 10, 2020
c958d08
Fixes
gavofyork Sep 10, 2020
1a3dc55
remove `frame-system`
shawntabrizi Sep 10, 2020
721a3e9
Fixes
gavofyork Sep 10, 2020
c83ee04
Merge branch 'gav-xcmp-working' of github.com:paritytech/polkadot int…
gavofyork Sep 10, 2020
a6131ae
Fixes
gavofyork Sep 10, 2020
85dee1a
Fixes
gavofyork Sep 10, 2020
4c77f93
fixes for `parachains`
shawntabrizi Sep 10, 2020
22d5321
Merge branch 'gav-xcmp-working' of https://github.com/paritytech/polk…
shawntabrizi Sep 10, 2020
0d37c9b
Fixes
gavofyork Sep 10, 2020
9ccc139
Merge branch 'gav-xcmp-working' of github.com:paritytech/polkadot int…
gavofyork Sep 10, 2020
7a7c958
QueryHolding
gavofyork Sep 10, 2020
a213bd3
`From` instead of `UncheckedFrom`
shawntabrizi Sep 10, 2020
e609000
Initial effort at integrating xcm-executor into Rococo
gavofyork Sep 10, 2020
c25b4b7
Merge branch 'gav-xcmp-working' of github.com:paritytech/polkadot int…
gavofyork Sep 10, 2020
1aeb7c8
Fixes
gavofyork Sep 10, 2020
6080e7b
Fixes
gavofyork Sep 10, 2020
739eeb7
Fixes
gavofyork Sep 10, 2020
9334f62
Fixes
gavofyork Sep 10, 2020
bc01389
Fixes
gavofyork Sep 10, 2020
ec55f0b
Rococo builds! 🎉
gavofyork Sep 10, 2020
6e112c9
Implement Xcm for the unit type
shawntabrizi Sep 10, 2020
b092cd4
Fixes
gavofyork Sep 10, 2020
61a4090
Fixes
gavofyork Sep 10, 2020
7dea1b3
Fixes
gavofyork Sep 10, 2020
758d675
Fixes
gavofyork Sep 10, 2020
aa08941
Fixes
gavofyork Sep 10, 2020
2e8a923
Fixes
gavofyork Sep 10, 2020
3869118
Fixes
gavofyork Sep 11, 2020
eab83fe
Fixes
gavofyork Sep 11, 2020
6565989
Fixes
gavofyork Sep 11, 2020
a388c68
Refactor all the hard logic away.
gavofyork Sep 11, 2020
17a6a16
Fixes
gavofyork Sep 11, 2020
3121739
Fixes
gavofyork Sep 11, 2020
9b39a46
Fixes
gavofyork Sep 11, 2020
3b3ef7c
Broken.
gavofyork Sep 11, 2020
14b36e3
Add `RuntimeDebug` to Assets
shawntabrizi Sep 11, 2020
a6222b2
Fixes
gavofyork Sep 11, 2020
f5143f3
Merge branch 'gav-xcmp' of github.com:paritytech/polkadot into gav-xcmp
gavofyork Sep 11, 2020
87ab207
Fix DepositReserveAsset. Repotting, renaming and docs.
gavofyork Sep 12, 2020
7d572f6
fix networkid export
shawntabrizi Sep 12, 2020
7d1629d
Full docs.
gavofyork Sep 12, 2020
358673b
Merge remote-tracking branch 'origin/gav-xcmp' into gav-xcmp
gavofyork Sep 12, 2020
baa3e74
Polkadot JS Types
shawntabrizi Sep 12, 2020
2ef7c7e
Update types.json
shawntabrizi Sep 12, 2020
f712a36
Fix `RocLocation`
shawntabrizi Sep 12, 2020
b4bc868
Fixes
gavofyork Sep 12, 2020
ccb2c08
Merge branch 'gav-xcmp' of github.com:paritytech/polkadot into gav-xcmp
gavofyork Sep 12, 2020
573df3d
Generate tuples properly.
gavofyork Sep 12, 2020
e19549f
Improve docs
gavofyork Sep 13, 2020
94b96dd
Docs and API tidy
gavofyork Sep 13, 2020
cf02df9
Merge branch 'gav-xcmp' of github.com:paritytech/polkadot into gav-xcmp
gavofyork Sep 13, 2020
a4eeae0
Introduce some error handling (#1709)
shawntabrizi Sep 13, 2020
b60cf99
Fixes
gavofyork Sep 15, 2020
dfa3290
Merge branch 'gav-xcmp' of github.com:paritytech/polkadot into gav-xcmp
gavofyork Sep 15, 2020
3f22946
Fixes
gavofyork Sep 16, 2020
8c86f3f
Fixes
gavofyork Sep 17, 2020
17bacc8
Fixes
gavofyork Sep 17, 2020
e4c31ee
Add result events, logging
gavofyork Sep 17, 2020
33ecb02
Fixes
gavofyork Sep 18, 2020
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
Prev Previous commit
Next Next commit
Finish up on draft
  • Loading branch information
gavofyork committed Aug 31, 2020
commit 7492c3b6bbf35781c3595f6e39dd1d0af29620b0
27 changes: 21 additions & 6 deletions parachain/src/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,32 @@ pub mod v0 {
#[derive(Clone, Eq, PartialEq, Encode, Decode)]
pub enum MultiLocation {
Null,
X1(Junction),
X2(Junction, Junction),
X3(Junction, Junction, Junction),
X4(Junction, Junction, Junction, Junction),
}

#[derive(Clone, Eq, PartialEq, Encode, Decode)]
pub enum Junction {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't match spec?

Parent,
ChildOf { primary: Box<MultiLocation>, subordinate: Box<MultiLocation> },
SiblingOf(Box<MultiLocation>),
Reserved4,
Reserved5,
Reserved6,
Parachain { #[codec(compact)] id: u32 },
OpaqueRemark(Vec<u8>),
AccountId32 { network: MultiNetwork, id: [u8; 32] },
AccountIndex64 { network: MultiNetwork, #[codec(compact)] index: u64 },
Parachain { #[codec(compact)] id: u32 },
AccountKey20 { network: MultiNetwork, key: [u8; 20] },
/// An instanced Pallet on a Frame-based chain.
PalletInstance { id: u8 },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The is the pallet index right? The index in construct_runtime? Not the Instance number for Instantiable pallets?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the index from construct_runtime. Will see if I can rename it.

/// A nondescript index within the context location.
GeneralIndex { #[codec(compact)] id: u128 },
/// A nondescript datum acting as a key within the context location.
GeneralKey(Vec<u8>),
}

impl From<Junction> for MultiLocation {
fn from(x: Junction) -> Self {
MultiLocation::X1(x)
}
}

#[derive(Clone, Eq, PartialEq, Encode, Decode)]
Expand Down
35 changes: 29 additions & 6 deletions runtime/common/src/parachains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ use system::{
use crate::attestations::{self, IncludedBlocks};
use crate::registrar::Registrar;
use polkadot_parachain::xcm::{VersionedXcm, v0::Xcm};
use polkadot_parachain::xcm::v0::{MultiOrigin, MultiAsset, MultiLocation};
use polkadot_parachain::xcm::v0::{MultiOrigin, MultiAsset, MultiLocation, Junction, Ai};

// ranges for iteration of general block number don't work, so this
// is a utility to get around that.
Expand Down Expand Up @@ -953,7 +953,7 @@ impl<T: Trait> Module<T> {
Ok(Ok(Xcm::ForwardToParachain { id, inner })) => {
let downward_queue_count = DownwardMessageQueue::<T>::decode_len(id).unwrap_or(0);
ensure!(downward_queue_count < MAX_DOWNWARD_QUEUE_COUNT, Error::<T>::DownwardMessageQueueFull);
let msg = VersionedXcm::from(Xcm::ForwardedFromParachain({ id: from, inner }));
let msg = VersionedXcm::from(Xcm::ForwardedFromParachain{ id: from.into(), inner });
DownwardMessageQueue::<T>::append(id, msg.encode());
}
Ok(Ok(Xcm::Transact{ origin_type, call })) => {
Expand All @@ -977,7 +977,7 @@ impl<T: Trait> Module<T> {
}
Ok(Ok(Xcm::ReserveAssetTransfer { asset, dest_, effect })) => {
let amount = match asset {
MultiAsset::ConcreteFungible { id, amount} if id == MultiLocation::Null => amount,
MultiAsset::ConcreteFungible { id: MultiLocation::Null, amount} => amount,
_ => return, // Bail as we don't support being a reserve for this asset.
};
let (onward_asset, dest) = match dest_ {
Expand All @@ -986,15 +986,38 @@ impl<T: Trait> Module<T> {
if T::ParachainCurrency::transfer_out(from, &dest.into_account(), amount, ExistenceRequirement::AllowDeath).is_err() {
return
}
(MultiAsset::ConcreateFungible(MultiLocation::Parent, amount), id)
// The onward asset, since it's the Relay-chain's native currency, is identified as
// the chain itself (from our context, it's therefore `Null`). From the parachain's context,
// it is identified as `Parent`.
(MultiAsset::ConcreteFungible { id: Junction::Parent.into(), amount }, id)
},
_ => return,
};
let msg = VersionedXcm::from(Xcm::ReserveAssetCredit { asset: onward_asset, effect }).encode();
DownwardMessageQueue::<T>::append(dest, msg.encode());
}
// TODO: Support withdraw-deposit
Ok(Ok(_)) => (), // Unhandled XCM message.
Ok(Ok(Xcm::WithdrawAsset { asset, effect })) => {
let amount = match asset {
MultiAsset::ConcreteFungible { id: MultiLocation::Null, amount} => amount,
_ => return, // Bail as we don't support being a reserve for this asset.
};
match effect {
// Only effect we support for now is a straight wildcard deposit into an AccountId32.
// TODO: Consider caring about the `network`.
Ai::DepositAsset { asset: MultiAsset::Wild, dest_: MultiLocation::X1(Junction::AccountId32 { id, .. }) } => {
let dest = match T::AccountId::decode(&mut &id[..]) {
Ok(x) => x,
Err(_) => return,
};
if T::ParachainCurrency::transfer_out(from, dest, amount, ExistenceRequirement::AllowDeath).is_err() {
return
}
},
_ => return,
};
let msg = VersionedXcm::from(Xcm::ReserveAssetCredit { asset: onward_asset, effect }).encode();
}
Ok(Ok(_)) => (), // Unhandled XCM message type.
Ok(Err(_)) => (), // Unsupported XCM version.
Err(_) => (), // Bad format (can't decode).
}
Expand Down