Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update polkadot-sdk #975

Merged
merged 13 commits into from
Jan 29, 2024
Merged
Changes from 1 commit
Commits
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
fix tests
xlc committed Jan 28, 2024
commit 4b53b009afb57dcdfa62271942bbdecddc44e1e3
15 changes: 8 additions & 7 deletions Cargo.dev.toml
Original file line number Diff line number Diff line change
@@ -4,24 +4,25 @@ members = [
"auction",
"authority",
"benchmarking",
"build-script-utils",
"currencies",
"gradually-update",
"nft",
"oracle",
"oracle/runtime-api",
"parameters",
"payments",
"rewards",
"tokens",
"tokens/runtime-api",
"traits",
"unknown-tokens",
"utilities",
"vesting",
"rewards",
"nft",
"xcm-mock-message-queue",
"xcm-support",
"xcm",
"xtokens",
"xcm-support",
"unknown-tokens",
"build-script-utils",
"payments",
"parameters",
]

resolver = "2"
5 changes: 1 addition & 4 deletions asset-registry/Cargo.toml
Original file line number Diff line number Diff line change
@@ -41,11 +41,7 @@ pallet-message-queue = { workspace = true, features = ["std"] }

# cumulus
cumulus-primitives-core = { workspace = true, features = ["std"] }
cumulus-pallet-dmp-queue = { workspace = true, features = ["std"] }
cumulus-pallet-xcmp-queue = { workspace = true, features = ["std"] }
cumulus-pallet-xcm = { workspace = true, features = ["std"] }
cumulus-pallet-parachain-system = { workspace = true, features = ["std"] }
parachain-info = { workspace = true, features = ["std"] }

# polkadot
polkadot-parachain-primitives = { workspace = true, features = ["std"] }
@@ -58,6 +54,7 @@ orml-tokens = { path = "../tokens" }
orml-xcm = { path = "../xcm" }
orml-xcm-support = { path = "../xcm-support" }
orml-xtokens = { path = "../xtokens" }
orml-xcm-mock-message-queue = { path = "../xcm-mock-message-queue" }

[features]
default = [ "std" ]
29 changes: 13 additions & 16 deletions asset-registry/src/mock/mod.rs
Original file line number Diff line number Diff line change
@@ -162,35 +162,35 @@ pub type Amount = i128;
decl_test_parachain! {
pub struct ParaA {
Runtime = para::Runtime,
XcmpMessageHandler = para::XcmpQueue,
DmpMessageHandler = para::DmpQueue,
XcmpMessageHandler = para::MsgQueue,
DmpMessageHandler = para::MsgQueue,
new_ext = para_ext(1, None),
}
}

decl_test_parachain! {
pub struct ParaB {
Runtime = para::Runtime,
XcmpMessageHandler = para::XcmpQueue,
DmpMessageHandler = para::DmpQueue,
XcmpMessageHandler = para::MsgQueue,
DmpMessageHandler = para::MsgQueue,
new_ext = para_ext(2, None),
}
}

decl_test_parachain! {
pub struct ParaC {
Runtime = para::Runtime,
XcmpMessageHandler = para::XcmpQueue,
DmpMessageHandler = para::DmpQueue,
XcmpMessageHandler = para::MsgQueue,
DmpMessageHandler = para::MsgQueue,
new_ext = para_ext(3, None),
}
}

decl_test_parachain! {
pub struct ParaG {
Runtime = para::Runtime,
XcmpMessageHandler = para::XcmpQueue,
DmpMessageHandler = para::DmpQueue,
XcmpMessageHandler = para::MsgQueue,
DmpMessageHandler = para::MsgQueue,
new_ext = para_ext(4, Some((
vec![(
4,
@@ -248,18 +248,12 @@ pub type ParaTokens = orml_tokens::Pallet<para::Runtime>;
pub type ParaXTokens = orml_xtokens::Pallet<para::Runtime>;

pub fn para_ext(para_id: u32, asset_data: Option<(Vec<(u32, Vec<u8>)>, u32)>) -> TestExternalities {
use para::{Runtime, System};
use para::{MsgQueue, Runtime, System};

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

let parachain_info_config = parachain_info::GenesisConfig::<Runtime> {
_config: Default::default(),
parachain_id: para_id.into(),
};
parachain_info_config.assimilate_storage(&mut t).unwrap();

orml_tokens::GenesisConfig::<Runtime> {
balances: vec![(ALICE, CurrencyId::R, 1_000)],
}
@@ -273,7 +267,10 @@ pub fn para_ext(para_id: u32, asset_data: Option<(Vec<(u32, Vec<u8>)>, u32)>) ->
}

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

84 changes: 14 additions & 70 deletions asset-registry/src/mock/para.rs
Original file line number Diff line number Diff line change
@@ -2,13 +2,10 @@

use crate as orml_asset_registry;

use cumulus_pallet_parachain_system::AnyRelayNumber;
use cumulus_primitives_core::ParaId;
use frame_support::traits::{EnsureOrigin, EnsureOriginWithArg};
use cumulus_primitives_core::AggregateMessageOrigin;
use frame_support::{
construct_runtime, match_types, ord_parameter_types, parameter_types,
traits::{ConstU128, ConstU32, ConstU64, Everything, Nothing},
weights::constants::WEIGHT_REF_TIME_PER_SECOND,
construct_runtime, derive_impl, match_types, ord_parameter_types, parameter_types,
traits::{ConstU128, ConstU32, EnsureOrigin, EnsureOriginWithArg, Everything, Nothing},
PalletId,
};
use frame_system::{EnsureRoot, EnsureSignedBy};
@@ -21,8 +18,7 @@
use pallet_xcm::XcmPassthrough;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;
use sp_core::H256;
use sp_core::Get;
use sp_runtime::{
traits::{AccountIdConversion, Convert, IdentityLookup},
AccountId32,
@@ -37,30 +33,13 @@

pub type AccountId = AccountId32;

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type BlockWeights = ();
type BlockLength = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type DbWeight = ();
type BaseCallFilter = Everything;
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Runtime>;
type MaxConsumers = ConstU32<16>;
}

impl pallet_balances::Config for Runtime {
@@ -157,18 +136,10 @@
}

parameter_types! {
pub const ReservedXcmpWeight: Weight = Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4), 0);
pub const ReservedDmpWeight: Weight = Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4), 0);
}

impl parachain_info::Config for Runtime {}

parameter_types! {
pub const RelayLocation: MultiLocation = MultiLocation::parent();
pub const RelayNetwork: NetworkId = NetworkId::Kusama;
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub UniversalLocation: InteriorMultiLocation =
X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into()));
X2(GlobalConsensus(RelayNetwork::get()), Parachain(MsgQueue::get().into()));
}

pub type LocationToAccountId = (
@@ -196,7 +167,7 @@
(),
>;

pub type XcmRouter = ParachainXcmRouter<ParachainInfo>;
pub type XcmRouter = ParachainXcmRouter<MsgQueue>;
pub type Barrier = (TakeWeightCredit, AllowTopLevelPaidExecutionFrom<Everything>);

parameter_types! {
@@ -234,6 +205,7 @@
pub const BaseXcmWeight: Weight = Weight::from_parts(100_000_000, 100_000_000);
pub const MaxInstructions: u32 = 100;
pub const MaxAssetsIntoHolding: u32 = 64;
pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;

Check warning on line 208 in asset-registry/src/mock/para.rs

Codecov / codecov/patch

asset-registry/src/mock/para.rs#L208

Added line #L208 was not covered by tests
}

pub struct XcmConfig;
@@ -264,36 +236,6 @@
type Aliasers = Nothing;
}

impl cumulus_pallet_parachain_system::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnSystemEvent = ();
type SelfParaId = ();
type OutboundXcmpMessageSource = XcmpQueue;
type DmpMessageHandler = ();
type ReservedDmpWeight = ();
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ();
type CheckAssociatedRelayNumber = AnyRelayNumber;
}

impl cumulus_pallet_xcmp_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
type ControllerOrigin = EnsureRoot<AccountId>;
type ControllerOriginConverter = XcmOriginToCallOrigin;
type WeightInfo = ();
type PriceForSiblingDelivery = NoPriceForMessageDelivery<ParaId>;
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
}

impl cumulus_pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
@@ -394,17 +336,19 @@
type SovereignOrigin = EnsureRoot<AccountId>;
}

impl orml_xcm_mock_message_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
}

type Block = frame_system::mocking::MockBlock<Runtime>;

construct_runtime!(
pub enum Runtime {
System: frame_system,
Balances: pallet_balances,

ParachainInfo: parachain_info,
ParachainSystem: cumulus_pallet_parachain_system,
XcmpQueue: cumulus_pallet_xcmp_queue,
DmpQueue: cumulus_pallet_dmp_queue,
MsgQueue: orml_xcm_mock_message_queue,
CumulusXcm: cumulus_pallet_xcm,

Tokens: orml_tokens,
31 changes: 8 additions & 23 deletions asset-registry/src/mock/relay.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::Weight;
use cumulus_primitives_core::ParaId;
use frame_support::{
construct_runtime, parameter_types,
traits::{ConstU128, ConstU32, ConstU64, Everything, Nothing, ProcessMessage, ProcessMessageError},
construct_runtime, derive_impl, parameter_types,
traits::{ConstU128, ConstU32, Everything, Nothing, ProcessMessage, ProcessMessageError},
weights::{IdentityFee, WeightMeter},
};
use frame_system::EnsureRoot;
@@ -11,43 +11,27 @@ use polkadot_runtime_parachains::{
inclusion::{AggregateMessageOrigin, UmpQueueId},
origin, shared,
};
use sp_core::H256;
use sp_runtime::{traits::IdentityLookup, AccountId32};
use xcm::v3::prelude::*;
#[allow(deprecated)]
use xcm_builder::CurrencyAdapter as XcmCurrencyAdapter;
use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia,
CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
FixedWeightBounds, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
TakeWeightCredit, UsingComponents,
};
use xcm_executor::{Config, XcmExecutor};

pub type AccountId = AccountId32;
pub type Balance = u128;

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type BlockWeights = ();
type BlockLength = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type DbWeight = ();
type BaseCallFilter = Everything;
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
}

impl pallet_balances::Config for Runtime {
@@ -84,6 +68,7 @@ pub type SovereignAccountOf = (
AccountId32Aliases<KusamaNetwork, AccountId>,
);

#[allow(deprecated)]
pub type LocalAssetTransactor =
XcmCurrencyAdapter<Balances, IsConcrete<KsmLocation>, SovereignAccountOf, AccountId, ()>;

2 changes: 1 addition & 1 deletion asset-registry/src/tests.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
use super::*;
use crate as orml_asset_registry;
use crate::tests::para::{AdminAssetTwo, AssetRegistry, CustomMetadata, RuntimeOrigin, Tokens, TreasuryAccount};
use frame_support::{assert_noop, assert_ok, traits::OnRuntimeUpgrade, StorageHasher};
use frame_support::{assert_noop, assert_ok};
use mock::{para::RuntimeCall, *};
use orml_traits::MultiCurrency;
use polkadot_parachain_primitives::primitives::Sibling;
Loading