Skip to content

Commit

Permalink
update to v0.9.11 (#15)
Browse files Browse the repository at this point in the history
* update to v0.9.11

* fmt

Co-authored-by: Shaun Wang <[email protected]>
  • Loading branch information
xlc and shaunxw authored Oct 17, 2021
1 parent 0c71745 commit 4d3bb9d
Show file tree
Hide file tree
Showing 10 changed files with 702 additions and 1,113 deletions.
1,551 changes: 568 additions & 983 deletions Cargo.lock

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions xcm-emulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ authors = ["Shaun Wang <[email protected]>"]
edition = "2018"

[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0" }
codec = { package = "parity-scale-codec", version = "2.3.1" }
paste = "1.0.5"

frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11" }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11" }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11" }

cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10" }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10" }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10" }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10" }
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10" }
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10" }
cumulus-test-relay-sproof-builder = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10" }
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11" }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11" }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11" }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11" }
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11" }
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11" }
cumulus-test-relay-sproof-builder = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11" }

xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10" }
xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11" }
30 changes: 15 additions & 15 deletions xcm-emulator/example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ edition = "2018"

[dependencies]
serde = { version = "1.0.124", optional = true }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
codec = { package = "parity-scale-codec", version = "2.3.1", default-features = false }

frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11" }

cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10" }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10" }
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10" }
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11" }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11" }
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11" }

xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10" }
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10" }
kusama-runtime = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10" }
pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10" }
xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11" }
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11" }
kusama-runtime = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11" }
pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11" }

xcm-emulator = { path = "../" }
yayoi = { path = "../yayoi" }
111 changes: 50 additions & 61 deletions xcm-emulator/example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,30 +153,32 @@ mod tests {
fn dmp() {
Network::reset();

let remark = yayoi::Call::System(frame_system::Call::<yayoi::Runtime>::remark_with_event(
"Hello from Kusama!".as_bytes().to_vec(),
));
let remark = yayoi::Call::System(frame_system::Call::<yayoi::Runtime>::remark_with_event {
remark: "Hello from Kusama!".as_bytes().to_vec(),
});
KusamaNet::execute_with(|| {
assert_ok!(kusama_runtime::XcmPallet::force_default_xcm_version(
kusama_runtime::Origin::root(),
Some(0)
));
assert_ok!(kusama_runtime::XcmPallet::send_xcm(
Here,
Parachain(1).into(),
Transact {
Parachain(1),
Xcm(vec![Transact {
origin_type: OriginKind::SovereignAccount,
require_weight_at_most: 10_000_000,
require_weight_at_most: INITIAL_BALANCE as u64,
call: remark.encode().into(),
}
}]),
));
});

YayoiPumpkin::execute_with(|| {
use yayoi::{Event, System};
System::events().iter().for_each(|r| println!(">>> {:?}", r.event));

// TODO: fix
// assert!(System::events()
// .iter()
// .any(|r| matches!(r.event,
// Event::System(frame_system::Event::Remarked(_, _)))));
assert!(System::events()
.iter()
.any(|r| matches!(r.event, Event::System(frame_system::Event::Remarked(_, _)))));
});
}

Expand All @@ -188,27 +190,18 @@ mod tests {
let _ = kusama_runtime::Balances::deposit_creating(&ParaId::from(1).into_account(), 1_000_000_000_000);
});

let remark = kusama_runtime::Call::System(frame_system::Call::<kusama_runtime::Runtime>::remark_with_event(
"Hello from Pumpkin!".as_bytes().to_vec(),
));
let remark = kusama_runtime::Call::System(frame_system::Call::<kusama_runtime::Runtime>::remark_with_event {
remark: "Hello from Pumpkin!".as_bytes().to_vec(),
});
YayoiPumpkin::execute_with(|| {
assert_ok!(yayoi::PolkadotXcm::send_xcm(
Here,
MultiLocation::parent(),
WithdrawAsset {
assets: (Here, 1_000_000_000_000).into(),
effects: vec![BuyExecution {
fees: (Here, 1_000_000_000_000).into(),
weight: 10_000_000,
debt: 10_000_000,
halt_on_error: true,
instructions: vec![Transact {
origin_type: OriginKind::SovereignAccount,
require_weight_at_most: 1_000_000_000,
call: remark.encode().into(),
}],
}]
}
Parent,
Xcm(vec![Transact {
origin_type: OriginKind::SovereignAccount,
require_weight_at_most: INITIAL_BALANCE as u64,
call: remark.encode().into(),
}]),
));
});

Expand All @@ -224,29 +217,28 @@ mod tests {
fn xcmp() {
Network::reset();

let remark = yayoi::Call::System(frame_system::Call::<yayoi::Runtime>::remark_with_event(
"Hello from Pumpkin!".as_bytes().to_vec(),
));
let remark = yayoi::Call::System(frame_system::Call::<yayoi::Runtime>::remark_with_event {
remark: "Hello from Pumpkin!".as_bytes().to_vec(),
});
YayoiPumpkin::execute_with(|| {
assert_ok!(yayoi::PolkadotXcm::send_xcm(
Here,
MultiLocation::new(1, X1(Parachain(2))),
Transact {
Xcm(vec![Transact {
origin_type: OriginKind::SovereignAccount,
require_weight_at_most: 10_000_000,
call: remark.encode().into(),
},
}]),
));
});

YayoiMushroom::execute_with(|| {
use yayoi::{Event, System};
System::events().iter().for_each(|r| println!(">>> {:?}", r.event));
// TODO: fix
// assert!(System::events()
// .iter()
// .any(|r| matches!(r.event,
// Event::System(frame_system::Event::Remarked(_, _)))));

assert!(System::events()
.iter()
.any(|r| matches!(r.event, Event::System(frame_system::Event::Remarked(_, _)))));
});
}

Expand All @@ -257,49 +249,46 @@ mod tests {
Network::reset();

// The message goes through: Pumpkin --> Mushroom --> Octopus
let remark = Call::System(frame_system::Call::<Runtime>::remark_with_event(
"Hello from Pumpkin!".as_bytes().to_vec(),
));
let send_xcm_to_octopus = Call::PolkadotXcm(pallet_xcm::Call::<Runtime>::send(
Box::new(VersionedMultiLocation::V1(MultiLocation::new(1, X1(Parachain(3))))),
Box::new(VersionedXcm::V1(Transact {
let remark = Call::System(frame_system::Call::<Runtime>::remark_with_event {
remark: "Hello from Pumpkin!".as_bytes().to_vec(),
});
let send_xcm_to_octopus = Call::PolkadotXcm(pallet_xcm::Call::<Runtime>::send {
dest: Box::new(VersionedMultiLocation::V1(MultiLocation::new(1, X1(Parachain(3))))),
message: Box::new(VersionedXcm::V2(Xcm(vec![Transact {
origin_type: OriginKind::SovereignAccount,
require_weight_at_most: 10_000_000,
call: remark.encode().into(),
})),
));
}]))),
});
YayoiPumpkin::execute_with(|| {
assert_ok!(PolkadotXcm::send_xcm(
Here,
MultiLocation::new(1, X1(Parachain(2))),
Transact {
Xcm(vec![Transact {
origin_type: OriginKind::SovereignAccount,
require_weight_at_most: 100_000_000,
call: send_xcm_to_octopus.encode().into(),
},
}]),
));
});

YayoiMushroom::execute_with(|| {
use yayoi::{Event, System};
System::events().iter().for_each(|r| println!(">>> {:?}", r.event));
// TODO: fix
// assert!(System::events()
// .iter()
// .any(|r| matches!(r.event,
// Event::PolkadotXcm(pallet_xcm::Event::Sent(_, _, _)))));

assert!(System::events()
.iter()
.any(|r| matches!(r.event, Event::PolkadotXcm(pallet_xcm::Event::Sent(_, _, _)))));
});

YayoiOctopus::execute_with(|| {
use yayoi::{Event, System};
// execution would fail, but good enough to check if the message is received
System::events().iter().for_each(|r| println!(">>> {:?}", r.event));
// TODO: fix
// assert!(System::events()
// .iter()
// .any(|r| matches!(r.event,
// Event::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail(_,
// _)))));

assert!(System::events()
.iter()
.any(|r| matches!(r.event, Event::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail(_, _)))));
});
}
}
48 changes: 25 additions & 23 deletions xcm-emulator/yayoi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,38 @@ edition = "2018"

[dependencies]
serde = { version = "1.0.124", optional = true }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }

sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10", default-features = false }

cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10", default-features = false }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10", default-features = false }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10", default-features = false }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10", default-features = false }
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10", default-features = false }
cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.10", default-features = false }

xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10", default-features = false }
xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10", default-features = false }
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10", default-features = false }
xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10", default-features = false }
pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10", default-features = false }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.10", default-features = false }
codec = { package = "parity-scale-codec", version = "2.3.1", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }

sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false }

cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11", default-features = false }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11", default-features = false }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11", default-features = false }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11", default-features = false }
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11", default-features = false }
cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.11", default-features = false }

xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11", default-features = false }
xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11", default-features = false }
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11", default-features = false }
xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11", default-features = false }
pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11", default-features = false }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.11", default-features = false }

[features]
default = ["std"]
no_std = []
std = [
"serde/std",
"codec/std",
"scale-info/std",

"sp-runtime/std",
"sp-io/std",
Expand Down
19 changes: 13 additions & 6 deletions xcm-emulator/yayoi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use frame_support::{
construct_runtime, parameter_types,
traits::Everything,
traits::{Everything, Nothing},
weights::{constants::WEIGHT_PER_SECOND, Weight},
};
use frame_system::EnsureRoot;
Expand Down Expand Up @@ -49,7 +49,7 @@ impl frame_system::Config for Runtime {
type OnNewAccount = ();
type OnKilledAccount = ();
type DbWeight = ();
type BaseCallFilter = ();
type BaseCallFilter = Everything;
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
Expand Down Expand Up @@ -98,6 +98,7 @@ pub type XcmOriginToCallOrigin = (

parameter_types! {
pub const UnitWeightCost: Weight = 10;
pub const MaxInstructions: u32 = 100;
}

pub type LocalAssetTransactor = ();
Expand All @@ -123,10 +124,12 @@ impl Config for XcmConfig {
type IsTeleporter = ();
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Trader = ();
type ResponseHandler = ();
type SubscriptionService = PolkadotXcm;
type AssetTrap = ();
type AssetClaims = ();
type SubscriptionService = ();
}

parameter_types! {
Expand Down Expand Up @@ -172,10 +175,14 @@ impl pallet_xcm::Config for Runtime {
type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type XcmExecuteFilter = Everything;
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = ();
type XcmTeleportFilter = Nothing;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
}

pub struct AccountIdToMultiLocation;
Expand Down
2 changes: 1 addition & 1 deletion xcm-simulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Shaun Wang <[email protected]>"]
edition = "2018"

[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0" }
codec = { package = "parity-scale-codec", version = "2.3.1" }
paste = "1.0.5"

frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9" }
Expand Down
Loading

0 comments on commit 4d3bb9d

Please sign in to comment.