Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
e170f4c
Add statemine like runtime for xcm tests
girazoki Jan 10, 2022
ef6ae21
Be able to receive both prefixes from statemine, while add an extrins…
girazoki Jan 10, 2022
32cdb42
Add statemine/statemint tests
girazoki Jan 10, 2022
a15613b
add statemine runtime test
girazoki Jan 10, 2022
9d44c8f
refactor
girazoki Jan 10, 2022
bf39e2e
More rust and typescript tests
girazoki Jan 11, 2022
aeef2b3
NPX
girazoki Jan 11, 2022
306bb0e
Document tests
girazoki Jan 11, 2022
6bc863c
editorconfig
girazoki Jan 11, 2022
01b0618
Merge remote-tracking branch 'upstream/master' into girazoki-avoid-st…
girazoki Jan 11, 2022
bdeaebf
Update benchmark
girazoki Jan 11, 2022
14c2599
Update weights
girazoki Jan 11, 2022
8b4dcbb
Update message
girazoki Jan 11, 2022
8aa9b70
Merge remote-tracking branch 'upstream/master' into girazoki-avoid-st…
girazoki Jan 12, 2022
c7112a7
Update estamite for assets transfer
girazoki Jan 13, 2022
1895e6c
Adapt test and package-lock to run all tests correctly
girazoki Jan 13, 2022
723dd97
Prettier
girazoki Jan 13, 2022
1b4e8e0
Merge remote-tracking branch 'upstream/master' into girazoki-avoid-st…
girazoki Jan 17, 2022
5ec2c1f
Update test with AssetDoesNotExist
girazoki Jan 17, 2022
2667fef
Update to 3 in alphanet
girazoki Jan 17, 2022
982b6ec
New storage item with mapping from assetType -> AssetId
girazoki Jan 18, 2022
fd2e0dc
Migration referencing units per second by assetType and not by assetId
girazoki Jan 18, 2022
34344aa
Add migrations
girazoki Jan 18, 2022
82f30eb
Add test for new migration
girazoki Jan 18, 2022
67b0aae
adapt traits to new storage item in pallet-asset-amanger
girazoki Jan 18, 2022
13852c4
Remove AsserId bound in FirstAssetTrader
girazoki Jan 18, 2022
5c82ee9
Update all tests to new design
girazoki Jan 18, 2022
c0fc100
Test third migration: migrate prefixes from previous statemine to new…
girazoki Jan 18, 2022
d2694d0
Integration tests change
girazoki Jan 18, 2022
e0cb77f
Update moonriver integration tests
girazoki Jan 18, 2022
e31d450
Merge remote-tracking branch 'upstream/master' into girazoki-avoid-st…
girazoki Jan 19, 2022
cdc8f42
Adapt moonbeam to migrations and statemint
girazoki Jan 19, 2022
42399ad
Make all migrations be independent from each other, and thus they can…
girazoki Jan 19, 2022
fff3b82
Define how we are going to pass statemine info to migration
girazoki Jan 19, 2022
94dbdfa
Update names of migrations
girazoki Jan 19, 2022
eccdb27
Include migration to all runtimes
girazoki Jan 19, 2022
555d0bf
Adapt tests to changes in set assets units per second plus statemint …
girazoki Jan 19, 2022
b23dcf7
Toml sort
girazoki Jan 19, 2022
437d089
Add statemine like to moonbeam
girazoki Jan 19, 2022
f7ef5c0
Prettier
girazoki Jan 19, 2022
a8e899c
EditorConfig
girazoki Jan 19, 2022
ee85d85
Fmt
girazoki Jan 19, 2022
c025e17
Editorconfig
girazoki Jan 19, 2022
c7cdf07
EditorCOnfig too
girazoki Jan 19, 2022
988eb26
Update benchmarks too
girazoki Jan 19, 2022
c7650bd
Editorconfig third try
girazoki Jan 19, 2022
90a2026
Update weights
girazoki Jan 19, 2022
8392853
Remove unused variable
girazoki Jan 19, 2022
9a97266
Remove silly comment
girazoki Jan 19, 2022
239964b
Tests for regular users cannot call root extrinsics
girazoki Jan 19, 2022
4b8faef
Add PR suggestions
girazoki Jan 20, 2022
08452c5
Documentation about migrations
girazoki Jan 20, 2022
5086d17
Merge remote-tracking branch 'upstream/master' into girazoki-avoid-st…
girazoki Jan 20, 2022
fc91d87
Comments in storage items
girazoki Jan 20, 2022
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
Adapt moonbeam to migrations and statemint
  • Loading branch information
girazoki committed Jan 19, 2022
commit cdc8f4278895df62749335e534c6a56dd34dcbc2
32 changes: 13 additions & 19 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ impl xcm_executor::Config for XcmExecutorConfig {
type Weigher = XcmWeigher;
// When we receive a non-reserve asset, we use AssetManager to fetch how many
// units per second we should charge
type Trader = FirstAssetTrader<AssetId, AssetType, AssetManager, XcmFeesToAccount>;
type Trader = FirstAssetTrader<AssetType, AssetManager, XcmFeesToAccount>;
type ResponseHandler = PolkadotXcm;
type SubscriptionService = PolkadotXcm;
type AssetTrap = PolkadotXcm;
Expand Down Expand Up @@ -1163,13 +1163,10 @@ impl pallet_assets::Config for Runtime {
}

parameter_types! {
// Statemine ParaId in Alphanet
// Statemint ParaId in Polkadot
pub StatemineParaId: u32 = 1000;
// Assets Pallet instance in Statemine alphanet
// Assets Pallet instance in Statemint
pub StatemineAssetPalletInstance: u8 = 50;
// AssetIds from Statemine already registered, these will retain
// the previous prefix assetId and we will map new one to previous ones
pub StatemineAssetIdExceptions: Vec<u128> = [8].to_vec();
}

// Our AssetType. For now we only handle Xcm Assets
Expand All @@ -1188,21 +1185,18 @@ impl From<MultiLocation> for AssetType {
match location {
// Change https://github.com/paritytech/cumulus/pull/831
// This avoids interrumption once they upgrade
// We map to the previous location so that the assetId is well calculated
// TODO: we might want to do a migration after statemine has upgraded
// as this is quite hacky, but the change itself is quite painful to cover
// We map the previous location to the new one so that the assetId is well retrieved
MultiLocation {
parents: 1,
interior: X3(Parachain(id), PalletInstance(instance), GeneralIndex(index)),
} if id == StatemineParaId::get()
&& instance == StatemineAssetPalletInstance::get()
&& StatemineAssetIdExceptions::get().contains(&index) =>
{
Self::Xcm(MultiLocation {
parents: 1,
interior: X2(Parachain(id), GeneralIndex(index)),
})
}
interior: X2(Parachain(id), GeneralIndex(index)),
} if id == StatemineParaId::get() => Self::Xcm(MultiLocation {
parents: 1,
interior: X3(
Parachain(id),
PalletInstance(StatemineAssetPalletInstance::get()),
GeneralIndex(index),
),
}),
_ => Self::Xcm(location),
}
}
Expand Down
37 changes: 37 additions & 0 deletions runtime/moonbeam/tests/xcm_mock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

pub mod parachain;
pub mod relay_chain;
pub mod statemint_like;

use cumulus_primitives_core::ParaId;
use polkadot_parachain::primitives::AccountIdConversion;
Expand Down Expand Up @@ -63,6 +64,15 @@ decl_test_parachain! {
}
}

decl_test_parachain! {
pub struct Statemint {
Runtime = statemint_like::Runtime,
XcmpMessageHandler = statemint_like::MsgQueue,
DmpMessageHandler = statemint_like::MsgQueue,
new_ext = statemint_ext(4),
}
}

decl_test_relay_chain! {
pub struct Relay {
Runtime = relay_chain::Runtime,
Expand All @@ -78,6 +88,7 @@ decl_test_network! {
(1, ParaA),
(2, ParaB),
(3, ParaC),
(4, Statemint),
],
}
}
Expand Down Expand Up @@ -130,6 +141,27 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities {
ext
}

pub fn statemint_ext(para_id: u32) -> sp_io::TestExternalities {
use statemint_like::{MsgQueue, Runtime, System};

let mut t = frame_system::GenesisConfig::default()
.build_storage::<Runtime>()
.unwrap();

pallet_balances::GenesisConfig::<Runtime> {
balances: vec![(RELAYALICE.into(), INITIAL_BALANCE)],
}
.assimilate_storage(&mut t)
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| {
System::set_block_number(1);
MsgQueue::set_para_id(para_id.into());
});
ext
}

pub fn relay_ext() -> sp_io::TestExternalities {
use relay_chain::{Runtime, System};

Expand All @@ -149,6 +181,11 @@ pub fn relay_ext() -> sp_io::TestExternalities {
}

pub type RelayChainPalletXcm = pallet_xcm::Pallet<relay_chain::Runtime>;

pub type StatemintBalances = pallet_balances::Pallet<statemint_like::Runtime>;
pub type StatemintChainPalletXcm = pallet_xcm::Pallet<statemint_like::Runtime>;
pub type StatemintAssets = pallet_assets::Pallet<statemint_like::Runtime>;

pub type Assets = pallet_assets::Pallet<parachain::Runtime>;
pub type Treasury = pallet_treasury::Pallet<parachain::Runtime>;
pub type AssetManager = pallet_asset_manager::Pallet<parachain::Runtime>;
Expand Down
26 changes: 23 additions & 3 deletions runtime/moonbeam/tests/xcm_mock/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ impl Config for XcmConfig {
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Trader =
(xcm_primitives::FirstAssetTrader<AssetId, AssetType, AssetManager, XcmFeesToAccount_>,);
type Trader = (xcm_primitives::FirstAssetTrader<AssetType, AssetManager, XcmFeesToAccount_>,);

type ResponseHandler = PolkadotXcm;
type SubscriptionService = PolkadotXcm;
Expand Down Expand Up @@ -556,6 +555,11 @@ impl pallet_xcm::Config for Runtime {
type AdvertisedXcmVersion = XcmVersioner;
}

parameter_types! {
pub StatemintParaId: u32 = 4;
pub StatemintAssetPalletInstance: u8 = 5;
}

// Our AssetType. For now we only handle Xcm Assets
#[derive(Clone, Eq, Debug, PartialEq, Ord, PartialOrd, Encode, Decode, TypeInfo)]
pub enum AssetType {
Expand All @@ -569,7 +573,23 @@ impl Default for AssetType {

impl From<MultiLocation> for AssetType {
fn from(location: MultiLocation) -> Self {
Self::Xcm(location)
match location {
// Change https://github.com/paritytech/cumulus/pull/831
// This avoids interrumption once they upgrade
// We map the previous location to the new one so that the assetId is well retrieved
MultiLocation {
parents: 1,
interior: X2(Parachain(id), GeneralIndex(index)),
} if id == StatemintParaId::get() => Self::Xcm(MultiLocation {
parents: 1,
interior: X3(
Parachain(id),
PalletInstance(StatemintAssetPalletInstance::get()),
GeneralIndex(index),
),
}),
_ => Self::Xcm(location),
}
}
}

Expand Down
Loading