Skip to content

Commit

Permalink
stable2409 (#1011)
Browse files Browse the repository at this point in the history
* stable2409

* remove old workaround

* fix

* fix

* do cargo update

* get tests passing

* fix
  • Loading branch information
xlc authored Dec 10, 2024
1 parent 7d60899 commit 9d09743
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 61 deletions.
1 change: 0 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ jobs:
tar -zxvf cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz -C $HOME/.cargo/bin
make Cargo.toml
cargo update
cargo update -p frame-support-procedural --precise 30.0.2
cargo tarpaulin --verbose --no-fail-fast --workspace --timeout 300 --out Xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ jobs:
- name: Install clippy
run: rustup component add clippy
- name: Update
run: |
cargo update
cargo update -p frame-support-procedural --precise 30.0.2
run: cargo update
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Check for Wasm
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/zepter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ jobs:
- name: Install Zepter
run: cargo install zepter --version 0.15.0 --locked -q -f --no-default-features && zepter --version
- run: make Cargo.toml
- run: |
cargo update
cargo update -p frame-support-procedural --precise 30.0.2
- run: cargo update
- name: Check Rust features
run: make dev-features-check
44 changes: 22 additions & 22 deletions Cargo.dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,35 @@ 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"] }

cumulus-pallet-xcm = { version = "0.16.0", default-features = false }
cumulus-primitives-core = { version = "0.15.0", default-features = false }
frame-benchmarking = { version = "37.0.0", default-features = false }
frame-support = { version = "37.0.0", default-features = false }
frame-system = { version = "37.0.0", default-features = false }
pallet-balances = { version = "38.0.0", default-features = false }
pallet-elections-phragmen = { version = "38.0.0", default-features = false }
pallet-message-queue = { version = "40.0.0", default-features = false }
pallet-preimage = { version = "37.0.0", default-features = false }
pallet-root-testing = { version = "13.0.0", default-features = false }
pallet-scheduler = { version = "38.0.0", default-features = false }
pallet-timestamp = { version = "36.0.0", default-features = false }
pallet-treasury = { version = "36.0.0", default-features = false }
pallet-xcm = { version = "16.0.0", default-features = false }
cumulus-pallet-xcm = { version = "0.17.0", default-features = false }
cumulus-primitives-core = { version = "0.16.0", default-features = false }
frame-benchmarking = { version = "38.0.0", default-features = false }
frame-support = { version = "38.0.0", default-features = false }
frame-system = { version = "38.0.0", default-features = false }
pallet-balances = { version = "39.0.0", default-features = false }
pallet-elections-phragmen = { version = "39.0.0", default-features = false }
pallet-message-queue = { version = "41.0.1", default-features = false }
pallet-preimage = { version = "38.0.0", default-features = false }
pallet-root-testing = { version = "14.0.0", default-features = false }
pallet-scheduler = { version = "39.0.0", default-features = false }
pallet-timestamp = { version = "37.0.0", default-features = false }
pallet-treasury = { version = "37.0.0", default-features = false }
pallet-xcm = { version = "17.0.0", default-features = false }
polkadot-parachain-primitives = { version = "14.0.0", default-features = false }
polkadot-runtime-common = { version = "16.0.0", default-features = false }
polkadot-runtime-parachains = { version = "16.0.0", default-features = false }
polkadot-runtime-common = { version = "17.0.0", default-features = false }
polkadot-runtime-parachains = { version = "17.0.1", default-features = false }
sp-api = { version = "34.0.0", default-features = false }
sp-application-crypto = { version = "38.0.0", default-features = false }
sp-arithmetic = { version = "26.0.0", default-features = false }
sp-core = { version = "34.0.0", default-features = false }
sp-io = { version = "38.0.0", default-features = false }
sp-runtime = { version = "39.0.0", default-features = false }
sp-runtime = { version = "39.0.1", default-features = false }
sp-runtime-interface = { version = "28.0.0", default-features = false }
sp-staking = { version = "34.0.0", default-features = false }
sp-staking = { version = "36.0.0", default-features = false }
sp-std = { version = "14.0.0", default-features = false }
sp-storage = { version = "21.0.0", default-features = false }
xcm = { version = "14.1.0", package = "staging-xcm", default-features = false }
xcm-builder = { version = "16.0.0", package = "staging-xcm-builder", default-features = false }
xcm-executor = { version = "16.0.0", package = "staging-xcm-executor", default-features = false }
xcm = { version = "14.2.0", package = "staging-xcm", default-features = false }
xcm-builder = { version = "17.0.1", package = "staging-xcm-builder", default-features = false }
xcm-executor = { version = "17.0.0", package = "staging-xcm-executor", default-features = false }

xcm-simulator = { version = "16.0.0" }
xcm-simulator = { version = "17.0.0" }
13 changes: 12 additions & 1 deletion tokens/src/imbalances.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// wrapping these imbalances in a private module is necessary to ensure absolute
// privacy of the inner member.
use crate::{Config, TotalIssuance};
use frame_support::traits::{Get, Imbalance, SameOrOther, TryDrop};
use frame_support::traits::{tokens::imbalance::TryMerge, Get, Imbalance, SameOrOther, TryDrop};
use sp_runtime::traits::{Saturating, Zero};
use sp_std::{marker, mem, result};

Expand Down Expand Up @@ -184,3 +184,14 @@ impl<T: Config, GetCurrencyId: Get<T::CurrencyId>> Drop for NegativeImbalance<T,
TotalIssuance::<T>::mutate(GetCurrencyId::get(), |v| *v = v.saturating_sub(self.0));
}
}

impl<T: Config, GetCurrencyId: Get<T::CurrencyId>> TryMerge for PositiveImbalance<T, GetCurrencyId> {
fn try_merge(self, other: Self) -> Result<Self, (Self, Self)> {
Ok(self.merge(other))
}
}
impl<T: Config, GetCurrencyId: Get<T::CurrencyId>> TryMerge for NegativeImbalance<T, GetCurrencyId> {
fn try_merge(self, other: Self) -> Result<Self, (Self, Self)> {
Ok(self.merge(other))
}
}
24 changes: 0 additions & 24 deletions tokens/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,6 @@ thread_local! {
]);
}

pub struct TenToFourteen;
impl SortedMembers<AccountId> for TenToFourteen {
fn sorted_members() -> Vec<AccountId> {
TEN_TO_FOURTEEN.with(|v| v.borrow().clone())
}
#[cfg(feature = "runtime-benchmarks")]
fn add(new: &AccountId) {
TEN_TO_FOURTEEN.with(|v| {
let mut members = v.borrow_mut();
members.push(new.clone());
members.sort();
})
}
}

impl ContainsLengthBound for TenToFourteen {
fn max_len() -> usize {
TEN_TO_FOURTEEN.with(|v| v.borrow().len())
}
fn min_len() -> usize {
0
}
}

parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const Burn: Permill = Permill::from_percent(50);
Expand Down
30 changes: 26 additions & 4 deletions xtokens/src/mock/para.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate as orml_xtokens;

use frame_support::{
construct_runtime, derive_impl, ensure, parameter_types,
traits::{ConstU128, ConstU32, Contains, Everything, Get, Nothing},
traits::{ConstU128, ConstU32, Contains, ContainsPair, Everything, Get, Nothing},
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
Expand All @@ -16,7 +16,7 @@ use sp_runtime::{
traits::{Convert, IdentityLookup},
AccountId32,
};
use sp_std::cell::RefCell;
use sp_std::{cell::RefCell, marker::PhantomData};
use xcm::v4::{prelude::*, Weight};
use xcm_builder::{
AccountId32Aliases, EnsureXcmOrigin, FixedWeightBounds, NativeAsset, ParentIsPreset, RelayChainAsNative,
Expand All @@ -26,8 +26,11 @@ use xcm_builder::{
use xcm_executor::{Config, XcmExecutor};

use crate::mock::AllTokensAreCreatedEqualToWeight;
use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key, RateLimiterError};
use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset};
use orml_traits::{
location::{AbsoluteReserveProvider, Reserve},
parameter_type_with_key, RateLimiterError,
};
use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter};

pub type AccountId = AccountId32;

Expand Down Expand Up @@ -117,6 +120,25 @@ parameter_types! {
pub const MaxAssetsIntoHolding: u32 = 64;
}

pub struct MultiNativeAsset<ReserveProvider>(PhantomData<ReserveProvider>);
impl<ReserveProvider> ContainsPair<Asset, Location> for MultiNativeAsset<ReserveProvider>
where
ReserveProvider: Reserve,
{
fn contains(asset: &Asset, origin: &Location) -> bool {
if let Some(ref reserve) = ReserveProvider::reserve(asset) {
if reserve == origin {
return true;
}
}
// allow parachain to be reserved of relay to bypass https://github.com/paritytech/polkadot-sdk/pull/5660
if asset.id.0 == Location::parent() {
return true;
}
false
}
}

pub struct XcmConfig;
impl Config for XcmConfig {
type RuntimeCall = RuntimeCall;
Expand Down
26 changes: 23 additions & 3 deletions xtokens/src/mock/para_relative_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate as orml_xtokens;

use frame_support::{
construct_runtime, derive_impl, parameter_types,
traits::{ConstU128, ConstU32, Contains, Everything, Get, Nothing},
traits::{ConstU128, ConstU32, Contains, ContainsPair, Everything, Get, Nothing},
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
Expand All @@ -12,6 +12,7 @@ use sp_runtime::{
traits::{Convert, IdentityLookup},
AccountId32, BoundedVec,
};
use sp_std::marker::PhantomData;
use xcm::v4::{prelude::*, Weight};
use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset,
Expand All @@ -22,10 +23,10 @@ use xcm_executor::{Config, XcmExecutor};

use crate::mock::AllTokensAreCreatedEqualToWeight;
use orml_traits::{
location::{AbsoluteReserveProvider, RelativeReserveProvider},
location::{AbsoluteReserveProvider, RelativeReserveProvider, Reserve},
parameter_type_with_key,
};
use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset};
use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter};

pub type AccountId = AccountId32;

Expand Down Expand Up @@ -115,6 +116,25 @@ parameter_types! {
pub const MaxAssetsIntoHolding: u32 = 64;
}

pub struct MultiNativeAsset<ReserveProvider>(PhantomData<ReserveProvider>);
impl<ReserveProvider> ContainsPair<Asset, Location> for MultiNativeAsset<ReserveProvider>
where
ReserveProvider: Reserve,
{
fn contains(asset: &Asset, origin: &Location) -> bool {
if let Some(ref reserve) = ReserveProvider::reserve(asset) {
if reserve == origin {
return true;
}
}
// allow parachain to be reserved of relay to bypass https://github.com/paritytech/polkadot-sdk/pull/5660
if asset.id.0 == Location::parent() {
return true;
}
false
}
}

pub struct XcmConfig;
impl Config for XcmConfig {
type RuntimeCall = RuntimeCall;
Expand Down

0 comments on commit 9d09743

Please sign in to comment.