diff --git a/Cargo.dev.toml b/Cargo.dev.toml index 3433f8068..4f93f70dc 100644 --- a/Cargo.dev.toml +++ b/Cargo.dev.toml @@ -35,70 +35,72 @@ scale-info = { version = "2.10.0", default-features = false, features = ["derive serde = { version = "1.0.189" } parity-scale-codec = { version = "3.6.5", default-features = false, features = ["max-encoded-len"] } -frame-benchmarking = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -frame-support = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -frame-system = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-authority-discovery = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-authorship = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-babe = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-balances = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-elections-phragmen = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-message-queue = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-scheduler = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-session = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-staking = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-treasury = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-vesting = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-transaction-payment = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-preimage = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-root-testing = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-api = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-application-crypto = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-arithmetic = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-authority-discovery = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-blockchain = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-consensus = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-consensus-slots = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-core = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-debug-derive = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-externalities = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-inherents = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-io = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-keystore = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-npos-elections = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-panic-handler = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-runtime = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-runtime-interface = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-session = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-staking = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-state-machine = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-std = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-storage = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-timestamp = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-trie = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-version = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-wasm-interface = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-tracing = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-maybe-compressed-blob = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-weights = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -cumulus-primitives-core = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -cumulus-pallet-xcm = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -parachain-info = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-xcm = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -polkadot-core-primitives = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -polkadot-runtime-parachains = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -polkadot-parachain-primitives = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -polkadot-primitives = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -xcm = { package = "staging-xcm", git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } +cumulus-pallet-dmp-queue = { version = "0.4.0", default-features = false } +cumulus-pallet-parachain-system = { version = "0.4.0", default-features = false } +cumulus-pallet-xcm = { version = "0.4.0", default-features = false } +cumulus-pallet-xcmp-queue = { version = "0.4.0", default-features = false } +cumulus-primitives-core = { version = "0.4.0", default-features = false } +frame-benchmarking = { version = "25.0.0", default-features = false } +frame-support = { version = "25.0.0", default-features = false } +frame-system = { version = "25.0.0", default-features = false } +pallet-authority-discovery = { version = "25.0.0", default-features = false } +pallet-authorship = { version = "25.0.0", default-features = false } +pallet-babe = { version = "25.0.0", default-features = false } +pallet-balances = { version = "25.0.0", default-features = false } +pallet-elections-phragmen = { version = "26.0.0", default-features = false } +pallet-message-queue = { version = "28.0.0", default-features = false } +pallet-preimage = { version = "25.0.0", default-features = false } +pallet-root-testing = { version = "1.0.0", default-features = false } +pallet-scheduler = { version = "26.0.0", default-features = false } +pallet-session = { version = "25.0.0", default-features = false } +pallet-staking = { version = "25.0.0", default-features = false } +pallet-timestamp = { version = "24.0.0", default-features = false } +pallet-transaction-payment = { version = "25.0.0", default-features = false } +pallet-treasury = { version = "24.0.0", default-features = false } +pallet-vesting = { version = "25.0.0", default-features = false } +pallet-xcm = { version = "4.0.0", default-features = false } +parachain-info = { package = "staging-parachain-info", version = "0.4.0", default-features = false } +polkadot-core-primitives = { version = "4.0.0", default-features = false } +polkadot-parachain-primitives = { version = "3.0.0", default-features = false } +polkadot-primitives = { version = "4.0.0", default-features = false } +polkadot-runtime-common = { version = "4.0.0", default-features = false } +polkadot-runtime-parachains = { version = "4.0.0", default-features = false } +sp-api = { version = "23.0.0", default-features = false } +sp-application-crypto = { version = "27.0.0", default-features = false } +sp-arithmetic = { version = "20.0.0", default-features = false } +sp-authority-discovery = { version = "23.0.0", default-features = false } +sp-blockchain = { version = "25.0.0", default-features = false } +sp-consensus = { version = "0.29.0", default-features = false } +sp-consensus-slots = { version = "0.29.0", default-features = false } +sp-core = { version = "25.0.0", default-features = false } +sp-debug-derive = { version = "12.0.0", default-features = false } +sp-externalities = { version = "0.23.0", default-features = false } +sp-inherents = { version = "23.0.0", default-features = false } +sp-io = { version = "27.0.0", default-features = false } +sp-keystore = { version = "0.31.0", default-features = false } +sp-maybe-compressed-blob = { version = "9.0.0", default-features = false } +sp-npos-elections = { version = "23.0.0", default-features = false } +sp-panic-handler = { version = "12.0.0", default-features = false } +sp-runtime = { version = "28.0.0", default-features = false } +sp-runtime-interface = { version = "21.0.0", default-features = false } +sp-session = { version = "24.0.0", default-features = false } +sp-staking = { version = "23.0.0", default-features = false } +sp-state-machine = { version = "0.32.0", default-features = false } +sp-std = { version = "12.0.0", default-features = false } +sp-storage = { version = "17.0.0", default-features = false } +sp-timestamp = { version = "23.0.0", default-features = false } +sp-tracing = { version = "14.0.0", default-features = false } +sp-trie = { version = "26.0.0", default-features = false } +sp-version = { version = "26.0.0", default-features = false } +sp-wasm-interface = { version = "18.0.0", default-features = false } +sp-weights = { version = "24.0.0", default-features = false } +xcm = { package = "staging-xcm", version = "4.0.0", default-features = false } +xcm-builder = { package = "staging-xcm-builder", version = "4.0.0", default-features = false } +xcm-executor = { package = "staging-xcm-executor", version = "4.0.0", default-features = false } -xcm-simulator = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-client-api = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-client-db = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-executor = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-executor-common = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-utils = { git = "https://github.com/paritytech//polkadot-sdk", branch = "release-polkadot-v1.1.0" } +sc-client-api = { version = "25.0.0" } +sc-client-db = { version = "0.32.0" } +sc-executor = { version = "0.29.0" } +sc-executor-common = { version = "0.26.0" } +sc-utils = { version = "11.0.0" } +xcm-simulator = { version = "4.0.0" } diff --git a/asset-registry/Cargo.toml b/asset-registry/Cargo.toml index a499f2998..e4e09e1e9 100644 --- a/asset-registry/Cargo.toml +++ b/asset-registry/Cargo.toml @@ -41,11 +41,13 @@ 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"] } polkadot-runtime-parachains = { workspace = true, features = ["std"] } +polkadot-runtime-common = { workspace = true, features = ["std"] } xcm-simulator = { workspace = true } # orml @@ -78,6 +80,8 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", + "polkadot-runtime-parachains/runtime-benchmarks", + "polkadot-runtime-common/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", diff --git a/asset-registry/src/migrations.rs b/asset-registry/src/migrations.rs index 75320e289..eadf9dab1 100644 --- a/asset-registry/src/migrations.rs +++ b/asset-registry/src/migrations.rs @@ -22,7 +22,7 @@ mod v2 { pub(crate) fn migrate() -> Weight { let mut weight: Weight = Weight::zero(); - let module_prefix = LocationToAssetId::::module_prefix(); + let module_prefix = LocationToAssetId::::pallet_prefix(); let storage_prefix = LocationToAssetId::::storage_prefix(); weight.saturating_accrue(T::DbWeight::get().reads(1)); diff --git a/asset-registry/src/mock/para.rs b/asset-registry/src/mock/para.rs index d245955e6..2d17ccf30 100644 --- a/asset-registry/src/mock/para.rs +++ b/asset-registry/src/mock/para.rs @@ -2,7 +2,8 @@ use super::{Amount, Balance, CurrencyId, CurrencyIdConvert, ParachainXcmRouter}; use crate as orml_asset_registry; -use cumulus_primitives_core::{ChannelStatus, GetChannelInfo, ParaId}; +use cumulus_pallet_parachain_system::AnyRelayNumber; +use cumulus_primitives_core::ParaId; use frame_support::traits::{EnsureOrigin, EnsureOriginWithArg}; use frame_support::{ construct_runtime, match_types, ord_parameter_types, parameter_types, @@ -20,6 +21,7 @@ use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset} 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_runtime::{ traits::{AccountIdConversion, Convert, IdentityLookup}, @@ -57,7 +59,7 @@ impl frame_system::Config for Runtime { type BaseCallFilter = Everything; type SystemWeightInfo = (); type SS58Prefix = (); - type OnSetCode = (); + type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; type MaxConsumers = ConstU32<16>; } @@ -72,6 +74,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = [u8; 8]; type MaxHolds = (); type MaxFreezes = (); @@ -261,26 +264,28 @@ impl Config for XcmConfig { type Aliasers = Nothing; } -pub struct ChannelInfo; -impl GetChannelInfo for ChannelInfo { - fn get_channel_status(_id: ParaId) -> ChannelStatus { - ChannelStatus::Ready(10, 10) - } - fn get_channel_max(_id: ParaId) -> Option { - Some(usize::max_value()) - } +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; - type ChannelInfo = ChannelInfo; + type ChannelInfo = ParachainSystem; type VersionWrapper = (); type ExecuteOverweightOrigin = EnsureRoot; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToCallOrigin; type WeightInfo = (); - type PriceForSiblingDelivery = (); + type PriceForSiblingDelivery = NoPriceForMessageDelivery; } impl cumulus_pallet_dmp_queue::Config for Runtime { @@ -397,6 +402,7 @@ construct_runtime!( Balances: pallet_balances, ParachainInfo: parachain_info, + ParachainSystem: cumulus_pallet_parachain_system, XcmpQueue: cumulus_pallet_xcmp_queue, DmpQueue: cumulus_pallet_dmp_queue, CumulusXcm: cumulus_pallet_xcm, diff --git a/asset-registry/src/mock/relay.rs b/asset-registry/src/mock/relay.rs index 8b8ccab06..9e1404c15 100644 --- a/asset-registry/src/mock/relay.rs +++ b/asset-registry/src/mock/relay.rs @@ -61,6 +61,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = [u8; 8]; type MaxHolds = (); type MaxFreezes = (); diff --git a/authority/src/mock.rs b/authority/src/mock.rs index 00be4d249..14deac4ae 100644 --- a/authority/src/mock.rs +++ b/authority/src/mock.rs @@ -57,8 +57,7 @@ impl pallet_preimage::Config for Runtime { type WeightInfo = (); type Currency = (); type ManagerOrigin = EnsureRoot; - type BaseDeposit = (); - type ByteDeposit = (); + type Consideration = (); } parameter_types! { diff --git a/currencies/src/mock.rs b/currencies/src/mock.rs index 27ee649b9..64e417eab 100644 --- a/currencies/src/mock.rs +++ b/currencies/src/mock.rs @@ -60,6 +60,7 @@ impl pallet_balances::Config for Runtime { type ReserveIdentifier = ReserveIdentifier; type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = [u8; 8]; type MaxHolds = (); type MaxFreezes = (); diff --git a/tokens/src/imbalances.rs b/tokens/src/imbalances.rs index 6aef35cd5..7463d8c72 100644 --- a/tokens/src/imbalances.rs +++ b/tokens/src/imbalances.rs @@ -102,6 +102,12 @@ impl> Imbalance for Pos fn peek(&self) -> T::Balance { self.0 } + + fn extract(&mut self, amount: T::Balance) -> Self { + let new: T::Balance = self.0.min(amount); + self.0 -= new; + Self::new(new) + } } impl> TryDrop for NegativeImbalance { @@ -157,6 +163,12 @@ impl> Imbalance for Neg fn peek(&self) -> T::Balance { self.0 } + + fn extract(&mut self, amount: T::Balance) -> Self { + let new: T::Balance = self.0.min(amount); + self.0 -= new; + Self::new(new) + } } impl> Drop for PositiveImbalance { diff --git a/tokens/src/mock.rs b/tokens/src/mock.rs index cd8785d4c..a59180a64 100644 --- a/tokens/src/mock.rs +++ b/tokens/src/mock.rs @@ -5,7 +5,10 @@ use super::*; use frame_support::{ construct_runtime, parameter_types, - traits::{ChangeMembers, ConstU32, ConstU64, ContainsLengthBound, Everything, SortedMembers}, + traits::{ + tokens::{PayFromAccount, UnityAssetBalanceConversion}, + ChangeMembers, ConstU32, ConstU64, ContainsLengthBound, Everything, SortedMembers, + }, PalletId, }; use orml_traits::parameter_type_with_key; @@ -99,13 +102,10 @@ impl ContainsLengthBound for TenToFourteen { parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(5); - pub const ProposalBondMinimum: u64 = 1; - pub const ProposalBondMaximum: u64 = 5; - pub const SpendPeriod: u64 = 2; pub const Burn: Permill = Permill::from_percent(50); pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); pub const GetTokenId: CurrencyId = DOT; - pub const MaxApprovals: u32 = 100; + pub TreasuryAccount: AccountId = Treasury::account_id(); } pub type MockCurrencyAdapter = CurrencyAdapter; @@ -117,15 +117,23 @@ impl pallet_treasury::Config for Runtime { type RuntimeEvent = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; - type ProposalBondMinimum = ProposalBondMinimum; - type ProposalBondMaximum = ProposalBondMaximum; - type SpendPeriod = SpendPeriod; + type ProposalBondMinimum = ConstU64<1>; + type ProposalBondMaximum = (); + type SpendPeriod = ConstU64<2>; type Burn = Burn; - type BurnDestination = (); - type SpendFunds = (); + type BurnDestination = (); // Just gets burned. type WeightInfo = (); - type MaxApprovals = MaxApprovals; - type SpendOrigin = frame_support::traits::NeverEnsureOrigin; + type SpendFunds = (); + type MaxApprovals = ConstU32<100>; + type SpendOrigin = frame_support::traits::NeverEnsureOrigin; + type AssetKind = (); + type Beneficiary = Self::AccountId; + type BeneficiaryLookup = IdentityLookup; + type Paymaster = PayFromAccount; + type BalanceConverter = UnityAssetBalanceConversion; + type PayoutPeriod = ConstU64<10>; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); } thread_local! { diff --git a/tokens/src/tests_currency_adapter.rs b/tokens/src/tests_currency_adapter.rs index c0ced63a3..20929baf2 100644 --- a/tokens/src/tests_currency_adapter.rs +++ b/tokens/src/tests_currency_adapter.rs @@ -136,6 +136,40 @@ fn currency_adapter_ensure_currency_adapter_should_work() { }); } +#[test] +fn currency_adapter_imbalances_extract_works() { + ExtBuilder::default() + .balances(vec![(TREASURY_ACCOUNT, DOT, 100)]) + .build() + .execute_with(|| { + let init_total_issuance = TreasuryCurrencyAdapter::total_issuance(); + + let mut imbalance = TreasuryCurrencyAdapter::burn(10); + + let imbalance2 = imbalance.extract(3); + + drop(imbalance); + + assert_eq!(TreasuryCurrencyAdapter::total_issuance(), init_total_issuance - 3); + + drop(imbalance2); + + assert_eq!(TreasuryCurrencyAdapter::total_issuance(), init_total_issuance); + + let mut imbalance = TreasuryCurrencyAdapter::issue(10); + + let imbalance2 = imbalance.extract(3); + + drop(imbalance); + + assert_eq!(TreasuryCurrencyAdapter::total_issuance(), init_total_issuance + 3); + + drop(imbalance2); + + assert_eq!(TreasuryCurrencyAdapter::total_issuance(), init_total_issuance); + }); +} + #[test] fn currency_adapter_burn_must_work() { ExtBuilder::default() diff --git a/unknown-tokens/src/migrations.rs b/unknown-tokens/src/migrations.rs index 9c866d30c..05177dc5a 100644 --- a/unknown-tokens/src/migrations.rs +++ b/unknown-tokens/src/migrations.rs @@ -26,7 +26,7 @@ mod v2 { let mut weight: Weight = Weight::zero(); // ConcreteFungibleBalances - let module_prefix = ConcreteFungibleBalances::::module_prefix(); + let module_prefix = ConcreteFungibleBalances::::pallet_prefix(); let storage_prefix = ConcreteFungibleBalances::::storage_prefix(); weight.saturating_accrue(T::DbWeight::get().reads(1)); @@ -54,7 +54,7 @@ mod v2 { } // AbstractFungibleBalances - let module_prefix = AbstractFungibleBalances::::module_prefix(); + let module_prefix = AbstractFungibleBalances::::pallet_prefix(); let storage_prefix = AbstractFungibleBalances::::storage_prefix(); weight.saturating_accrue(T::DbWeight::get().reads(1)); diff --git a/vesting/src/mock.rs b/vesting/src/mock.rs index 48ffd32f6..71e09674d 100644 --- a/vesting/src/mock.rs +++ b/vesting/src/mock.rs @@ -53,6 +53,7 @@ impl pallet_balances::Config for Runtime { type ReserveIdentifier = [u8; 8]; type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = [u8; 8]; type MaxHolds = (); type MaxFreezes = (); diff --git a/vesting/src/tests.rs b/vesting/src/tests.rs index 3d982e7d4..d054161b0 100644 --- a/vesting/src/tests.rs +++ b/vesting/src/tests.rs @@ -276,19 +276,29 @@ fn claim_works() { MockBlockNumberProvider::set(11); // remain locked if not claimed - assert!(PalletBalances::transfer(RuntimeOrigin::signed(BOB), ALICE, 10).is_err()); + assert!(PalletBalances::transfer(&BOB, &ALICE, 10, ExistenceRequirement::AllowDeath).is_err()); // unlocked after claiming assert_ok!(Vesting::claim(RuntimeOrigin::signed(BOB))); assert!(VestingSchedules::::contains_key(BOB)); - assert_ok!(PalletBalances::transfer(RuntimeOrigin::signed(BOB), ALICE, 10)); + assert_ok!(PalletBalances::transfer( + &BOB, + &ALICE, + 10, + ExistenceRequirement::AllowDeath + )); // more are still locked - assert!(PalletBalances::transfer(RuntimeOrigin::signed(BOB), ALICE, 1).is_err()); + assert!(PalletBalances::transfer(&BOB, &ALICE, 1, ExistenceRequirement::AllowDeath).is_err()); MockBlockNumberProvider::set(21); // claim more assert_ok!(Vesting::claim(RuntimeOrigin::signed(BOB))); assert!(!VestingSchedules::::contains_key(BOB)); - assert_ok!(PalletBalances::transfer(RuntimeOrigin::signed(BOB), ALICE, 10)); + assert_ok!(PalletBalances::transfer( + &BOB, + &ALICE, + 10, + ExistenceRequirement::AllowDeath + )); // all used up assert_eq!(PalletBalances::free_balance(BOB), 0); @@ -355,11 +365,16 @@ fn update_vesting_schedules_works() { MockBlockNumberProvider::set(11); assert_ok!(Vesting::claim(RuntimeOrigin::signed(BOB))); - assert!(PalletBalances::transfer(RuntimeOrigin::signed(BOB), ALICE, 1).is_err()); + assert!(PalletBalances::transfer(&BOB, &ALICE, 1, ExistenceRequirement::AllowDeath).is_err()); MockBlockNumberProvider::set(21); assert_ok!(Vesting::claim(RuntimeOrigin::signed(BOB))); - assert_ok!(PalletBalances::transfer(RuntimeOrigin::signed(BOB), ALICE, 10)); + assert_ok!(PalletBalances::transfer( + &BOB, + &ALICE, + 10, + ExistenceRequirement::AllowDeath + )); // empty vesting schedules cleanup the storage and unlock the fund assert!(VestingSchedules::::contains_key(BOB)); @@ -380,7 +395,12 @@ fn update_vesting_schedules_works() { #[test] fn update_vesting_schedules_fails_if_unexpected_existing_locks() { ExtBuilder::build().execute_with(|| { - assert_ok!(PalletBalances::transfer(RuntimeOrigin::signed(ALICE), BOB, 1)); + assert_ok!(PalletBalances::transfer( + &ALICE, + &BOB, + 1, + ExistenceRequirement::AllowDeath + )); PalletBalances::set_lock(*b"prelocks", &BOB, 0u64, WithdrawReasons::all()); }); } @@ -518,7 +538,7 @@ fn cliff_vesting_works() { assert_eq!(PalletBalances::free_balance(BOB), VESTING_AMOUNT); assert_eq!(PalletBalances::locks(&BOB), vec![balance_lock.clone()]); assert_noop!( - PalletBalances::transfer(RuntimeOrigin::signed(BOB), CHARLIE, VESTING_AMOUNT), + PalletBalances::transfer(&BOB, &CHARLIE, VESTING_AMOUNT, ExistenceRequirement::AllowDeath), TokenError::Frozen, ); } @@ -527,9 +547,10 @@ fn cliff_vesting_works() { assert_ok!(Vesting::claim(RuntimeOrigin::signed(BOB))); assert!(PalletBalances::locks(&BOB).is_empty()); assert_ok!(PalletBalances::transfer( - RuntimeOrigin::signed(BOB), - CHARLIE, - VESTING_AMOUNT + &BOB, + &CHARLIE, + VESTING_AMOUNT, + ExistenceRequirement::AllowDeath, )); }); } diff --git a/xcm-support/src/currency_adapter.rs b/xcm-support/src/currency_adapter.rs index 63dcdca16..33189309f 100644 --- a/xcm-support/src/currency_adapter.rs +++ b/xcm-support/src/currency_adapter.rs @@ -145,7 +145,7 @@ impl< DepositFailureHandler, > { - fn deposit_asset(asset: &MultiAsset, location: &MultiLocation, _context: &XcmContext) -> Result { + fn deposit_asset(asset: &MultiAsset, location: &MultiLocation, _context: Option<&XcmContext>) -> Result { match ( AccountIdConvert::convert_location(location), CurrencyIdConvert::convert(asset.clone()), diff --git a/xtokens/Cargo.toml b/xtokens/Cargo.toml index ae307e9eb..2bd620a35 100644 --- a/xtokens/Cargo.toml +++ b/xtokens/Cargo.toml @@ -43,11 +43,13 @@ cumulus-pallet-dmp-queue = { workspace = true, features = ["std"] } cumulus-pallet-xcm = { workspace = true, features = ["std"] } cumulus-pallet-xcmp-queue = { workspace = true, features = ["std"] } cumulus-primitives-core = { 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"] } polkadot-runtime-parachains = { workspace = true, features = ["std"] } +polkadot-runtime-common = { workspace = true, features = ["std"] } xcm-builder = { workspace = true, features = ["std"] } xcm-simulator = { workspace = true } @@ -81,6 +83,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", + "polkadot-runtime-parachains/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", diff --git a/xtokens/src/mock/para.rs b/xtokens/src/mock/para.rs index 4e812c2da..f2947a4c6 100644 --- a/xtokens/src/mock/para.rs +++ b/xtokens/src/mock/para.rs @@ -1,21 +1,22 @@ use super::{AllowTopLevelPaidExecution, Amount, Balance, CurrencyId, CurrencyIdConvert, ParachainXcmRouter}; use crate as orml_xtokens; +use cumulus_pallet_parachain_system::AnyRelayNumber; +use cumulus_primitives_core::ParaId; use frame_support::{ construct_runtime, match_types, parameter_types, traits::{ConstU128, ConstU32, ConstU64, Everything, Get, Nothing}, weights::constants::WEIGHT_REF_TIME_PER_SECOND, }; use frame_system::EnsureRoot; +use pallet_xcm::XcmPassthrough; +use polkadot_parachain_primitives::primitives::Sibling; +use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; use sp_core::H256; use sp_runtime::{ traits::{Convert, IdentityLookup}, AccountId32, }; - -use cumulus_primitives_core::{ChannelStatus, GetChannelInfo, ParaId}; -use pallet_xcm::XcmPassthrough; -use polkadot_parachain_primitives::primitives::Sibling; use xcm::v3::{prelude::*, Weight}; use xcm_builder::{ AccountId32Aliases, EnsureXcmOrigin, FixedWeightBounds, NativeAsset, ParentIsPreset, RelayChainAsNative, @@ -52,7 +53,7 @@ impl frame_system::Config for Runtime { type BaseCallFilter = Everything; type SystemWeightInfo = (); type SS58Prefix = (); - type OnSetCode = (); + type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; type MaxConsumers = ConstU32<16>; } @@ -67,6 +68,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = [u8; 8]; type MaxHolds = (); type MaxFreezes = (); @@ -170,26 +172,28 @@ impl Config for XcmConfig { type Aliasers = (); } -pub struct ChannelInfo; -impl GetChannelInfo for ChannelInfo { - fn get_channel_status(_id: ParaId) -> ChannelStatus { - ChannelStatus::Ready(10, 10) - } - fn get_channel_max(_id: ParaId) -> Option { - Some(usize::max_value()) - } +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; - type ChannelInfo = ChannelInfo; + type ChannelInfo = ParachainSystem; type VersionWrapper = (); type ExecuteOverweightOrigin = EnsureRoot; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToCallOrigin; type WeightInfo = (); - type PriceForSiblingDelivery = (); + type PriceForSiblingDelivery = NoPriceForMessageDelivery; } impl cumulus_pallet_dmp_queue::Config for Runtime { @@ -306,6 +310,7 @@ construct_runtime!( Balances: pallet_balances, ParachainInfo: parachain_info, + ParachainSystem: cumulus_pallet_parachain_system, XcmpQueue: cumulus_pallet_xcmp_queue, DmpQueue: cumulus_pallet_dmp_queue, CumulusXcm: cumulus_pallet_xcm, diff --git a/xtokens/src/mock/para_relative_view.rs b/xtokens/src/mock/para_relative_view.rs index 721af1303..549ab4423 100644 --- a/xtokens/src/mock/para_relative_view.rs +++ b/xtokens/src/mock/para_relative_view.rs @@ -1,21 +1,22 @@ use super::{Amount, Balance, CurrencyId, CurrencyIdConvert, ParachainXcmRouter}; use crate as orml_xtokens; +use cumulus_pallet_parachain_system::AnyRelayNumber; +use cumulus_primitives_core::ParaId; use frame_support::{ construct_runtime, match_types, parameter_types, traits::{ConstU128, ConstU32, ConstU64, Everything, Nothing}, weights::constants::WEIGHT_REF_TIME_PER_SECOND, }; use frame_system::EnsureRoot; +use pallet_xcm::XcmPassthrough; +use polkadot_parachain_primitives::primitives::Sibling; +use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; use sp_core::H256; use sp_runtime::{ traits::{Convert, IdentityLookup}, AccountId32, BoundedVec, }; - -use cumulus_primitives_core::{ChannelStatus, GetChannelInfo, ParaId}; -use pallet_xcm::XcmPassthrough; -use polkadot_parachain_primitives::primitives::Sibling; use xcm::v3::{prelude::*, Weight}; use xcm_builder::{ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset, @@ -55,7 +56,7 @@ impl frame_system::Config for Runtime { type BaseCallFilter = Everything; type SystemWeightInfo = (); type SS58Prefix = (); - type OnSetCode = (); + type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; type MaxConsumers = ConstU32<16>; } @@ -70,6 +71,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = [u8; 8]; type MaxHolds = (); type MaxFreezes = (); @@ -173,26 +175,28 @@ impl Config for XcmConfig { type Aliasers = (); } -pub struct ChannelInfo; -impl GetChannelInfo for ChannelInfo { - fn get_channel_status(_id: ParaId) -> ChannelStatus { - ChannelStatus::Ready(10, 10) - } - fn get_channel_max(_id: ParaId) -> Option { - Some(usize::max_value()) - } +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; - type ChannelInfo = ChannelInfo; + type ChannelInfo = ParachainSystem; type VersionWrapper = (); type ExecuteOverweightOrigin = EnsureRoot; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToCallOrigin; type WeightInfo = (); - type PriceForSiblingDelivery = (); + type PriceForSiblingDelivery = NoPriceForMessageDelivery; } impl cumulus_pallet_dmp_queue::Config for Runtime { @@ -429,6 +433,7 @@ construct_runtime!( Balances: pallet_balances, ParachainInfo: parachain_info, + ParachainSystem: cumulus_pallet_parachain_system, XcmpQueue: cumulus_pallet_xcmp_queue, DmpQueue: cumulus_pallet_dmp_queue, CumulusXcm: cumulus_pallet_xcm, diff --git a/xtokens/src/mock/para_teleport.rs b/xtokens/src/mock/para_teleport.rs index 1a12c7998..dd63753f3 100644 --- a/xtokens/src/mock/para_teleport.rs +++ b/xtokens/src/mock/para_teleport.rs @@ -1,21 +1,22 @@ use super::{AllowTopLevelPaidExecution, Amount, Balance, CurrencyId, CurrencyIdConvert, ParachainXcmRouter}; use crate as orml_xtokens; +use cumulus_pallet_parachain_system::AnyRelayNumber; +use cumulus_primitives_core::ParaId; use frame_support::{ construct_runtime, match_types, parameter_types, traits::{ConstU128, ConstU32, ConstU64, Everything, Get, Nothing}, weights::constants::WEIGHT_REF_TIME_PER_SECOND, }; use frame_system::EnsureRoot; +use pallet_xcm::XcmPassthrough; +use polkadot_parachain_primitives::primitives::Sibling; +use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; use sp_core::H256; use sp_runtime::{ traits::{Convert, IdentityLookup}, AccountId32, }; - -use cumulus_primitives_core::{ChannelStatus, GetChannelInfo, ParaId}; -use pallet_xcm::XcmPassthrough; -use polkadot_parachain_primitives::primitives::Sibling; use xcm::v3::{prelude::*, Weight}; use xcm_builder::{ AccountId32Aliases, EnsureXcmOrigin, FixedWeightBounds, NativeAsset, ParentIsPreset, RelayChainAsNative, @@ -53,7 +54,7 @@ impl frame_system::Config for Runtime { type BaseCallFilter = Everything; type SystemWeightInfo = (); type SS58Prefix = (); - type OnSetCode = (); + type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; type MaxConsumers = ConstU32<16>; } @@ -68,6 +69,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = [u8; 8]; type MaxHolds = (); type MaxFreezes = (); @@ -171,26 +173,28 @@ impl Config for XcmConfig { type Aliasers = (); } -pub struct ChannelInfo; -impl GetChannelInfo for ChannelInfo { - fn get_channel_status(_id: ParaId) -> ChannelStatus { - ChannelStatus::Ready(10, 10) - } - fn get_channel_max(_id: ParaId) -> Option { - Some(usize::max_value()) - } +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; - type ChannelInfo = ChannelInfo; + type ChannelInfo = ParachainSystem; type VersionWrapper = (); type ExecuteOverweightOrigin = EnsureRoot; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToCallOrigin; type WeightInfo = (); - type PriceForSiblingDelivery = (); + type PriceForSiblingDelivery = NoPriceForMessageDelivery; } impl cumulus_pallet_dmp_queue::Config for Runtime { @@ -297,6 +301,7 @@ construct_runtime!( Balances: pallet_balances, ParachainInfo: parachain_info, + ParachainSystem: cumulus_pallet_parachain_system, XcmpQueue: cumulus_pallet_xcmp_queue, DmpQueue: cumulus_pallet_dmp_queue, CumulusXcm: cumulus_pallet_xcm, diff --git a/xtokens/src/mock/relay.rs b/xtokens/src/mock/relay.rs index 06309ffed..da78f8c76 100644 --- a/xtokens/src/mock/relay.rs +++ b/xtokens/src/mock/relay.rs @@ -62,6 +62,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = [u8; 8]; type MaxHolds = (); type MaxFreezes = (); diff --git a/xtokens/src/mock/teleport_currency_adapter.rs b/xtokens/src/mock/teleport_currency_adapter.rs index 6730243ee..b05356428 100644 --- a/xtokens/src/mock/teleport_currency_adapter.rs +++ b/xtokens/src/mock/teleport_currency_adapter.rs @@ -93,7 +93,7 @@ impl< fn check_in(_origin: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {} - fn deposit_asset(asset: &MultiAsset, location: &MultiLocation, _context: &XcmContext) -> Result { + fn deposit_asset(asset: &MultiAsset, location: &MultiLocation, _context: Option<&XcmContext>) -> Result { match ( AccountIdConvert::convert_location(location), CurrencyIdConvert::convert(asset.clone()),