Skip to content

Commit

Permalink
Upgrade to Polkadot-v1.7.2 (#1833)
Browse files Browse the repository at this point in the history
* set dependency versions

* upgrade libs/*

* upgrade pallet-anchors

* upgrade pallet-fees

* upgrade pallet-bridge

* migrate simple pallets

* migrate pallet-order-book

* migrated collator-allowlist & swaps

* upgrade rewards

* upgraded pallet-mux

* upgrade transfer-allowlist

* fix hold reason in restricted tokens

* simplify set_balance removing the holding part

* upgrade restricted-xtokens

* upgrade some pallets

* upgrade pallet-ethereum-transaction

* upgrade pallet-loans

* upgrade pool-system

* upgrade pool-fees

* upgrade pool-registry

* upgrade liquidity-pools stuffs

* avoid duplicated polkadot-sdk repos

* minor fixes

* upgraded runtime-common

* CfgLocation to RestrictedTransferLocation

* restricted tokens with NativeIndex for native fungibles

* rename dependency

* upgraded development-runtime

* fix partially benchmarks

* fix benchmarks

* overpass xcmp-queue integrity tests

* minor coments

* upgrade altair & centrifuge

* remove some benchmarking pallets that are not needed

* fix runtime upgrades

* upgrade integration-test proc

* upgrade integration-tests framework

* upgraded all tests except liquidity pools

* 99% upgraded liquidity-pools tests

* fix lookup

* cargo fmt

* taplo fmt

* using nightly cargo in CI

* restore set_balance as it was

* allow nightly support in CI

* use restricted_tokens again to fetch from investement portfolio

* Install rust-src for docs

* fix tests

* remove unused restricted tokens

* fix block rewards

* fix WrongWitness for some tests in IT

* fix liquidity-pools

* minor fixes

* fix clippy

* remove unneeded tests

* feat: Update client to Polkadot v1.7.2 (#1844)

* wip: update client

* chore: update crate versions

* chore: update anchor rpc api

* chore: remove rewards, pools rpc

* chore: compile with development runtime

* fix: client for all runtimes

* fix: build spec

* feat: update relay docker images

* fix: apply deprecation of export genesis state to scripts

* fmt: taplo

* refactor: use xcm v4 sugar

* fix: revert tmp change in local para run

* refactor: simplify xcm v4 locations in chain spec

* cargo fmt

* fix clippy

* feat: Polkadot v1.7.2 migrations (#1849)

* feat: add hold reason migration

* feat: centrifuge migrations

* feat: altair migrations

* feat: dev + demo migrations

* fix: clippy

* fix: build

* fmt: fix using nightly

* last William iteration review

* increase passed blocks

* use rococo instead of polkadot-test-runtime

* fix tests

* remove line

* dirty fix to fix Hrmp test issue

* use default weights for treasury

---------

Co-authored-by: William Freudenberger <[email protected]>
  • Loading branch information
lemunozm and wischli authored Jun 7, 2024
1 parent 2b4f94f commit ccbe93d
Show file tree
Hide file tree
Showing 138 changed files with 6,532 additions and 6,472 deletions.
5,673 changes: 2,985 additions & 2,688 deletions Cargo.lock

Large diffs are not rendered by default.

502 changes: 241 additions & 261 deletions Cargo.toml

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion ci/run-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ case $TARGET in
;;

lint-fmt)
cargo fmt -- --check
# We need the `+nightly` as long as the used toolchain is the stable version
# in order to allow using the formatter unstable options
cargo +nightly fmt -- --check
;;

lint-taplo)
Expand Down
4 changes: 2 additions & 2 deletions docker/docker-compose-local-relay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: '3.4'
services:
node_alice:
container_name: alice
image: "parity/polkadot:v1.0.0"
image: "parity/polkadot:v1.7.2"
platform: "linux/x86_64"
ports:
- "30333:30333"
Expand All @@ -30,7 +30,7 @@ services:
node_bob:
container_name: bob
image: "parity/polkadot:v1.0.0"
image: "parity/polkadot:v1.7.2"
platform: "linux/x86_64"
ports:
- "30344:30333"
Expand Down
1 change: 0 additions & 1 deletion libs/mocks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ std = [
"sp-runtime/std",
"orml-traits/std",
"staging-xcm/std",
"mock-builder/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
Expand Down
18 changes: 9 additions & 9 deletions libs/mocks/src/asset_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod pallet {
use mock_builder::{execute_call, register_call};
use orml_traits::asset_registry::{AssetMetadata, Inspect, Mutate};
use sp_std::fmt::Debug;
use staging_xcm::{v3::prelude::MultiLocation, VersionedMultiLocation};
use staging_xcm::{v4::Location, VersionedLocation};

#[pallet::config]
pub trait Config: frame_system::Config {
Expand All @@ -21,7 +21,7 @@ pub mod pallet {
type CallIds<T: Config> = StorageMap<_, _, String, mock_builder::CallId>;

impl<T: Config> Pallet<T> {
pub fn mock_asset_id(f: impl Fn(&MultiLocation) -> Option<T::AssetId> + 'static) {
pub fn mock_asset_id(f: impl Fn(&Location) -> Option<T::AssetId> + 'static) {
register_call!(f);
}

Expand All @@ -36,15 +36,15 @@ pub mod pallet {

pub fn mock_metadata_by_location(
f: impl Fn(
&MultiLocation,
&Location,
) -> Option<AssetMetadata<T::Balance, T::CustomMetadata, T::StringLimit>>
+ 'static,
) {
register_call!(f);
}

pub fn mock_location(
f: impl Fn(&T::AssetId) -> Result<Option<MultiLocation>, DispatchError> + 'static,
f: impl Fn(&T::AssetId) -> Result<Option<Location>, DispatchError> + 'static,
) {
register_call!(f);
}
Expand All @@ -66,7 +66,7 @@ pub mod pallet {
Option<BoundedVec<u8, T::StringLimit>>,
Option<BoundedVec<u8, T::StringLimit>>,
Option<T::Balance>,
Option<Option<VersionedMultiLocation>>,
Option<Option<VersionedLocation>>,
Option<T::CustomMetadata>,
) -> DispatchResult
+ 'static,
Expand All @@ -81,7 +81,7 @@ pub mod pallet {
type CustomMetadata = T::CustomMetadata;
type StringLimit = T::StringLimit;

fn asset_id(a: &MultiLocation) -> Option<Self::AssetId> {
fn asset_id(a: &Location) -> Option<Self::AssetId> {
execute_call!(a)
}

Expand All @@ -92,12 +92,12 @@ pub mod pallet {
}

fn metadata_by_location(
a: &MultiLocation,
a: &Location,
) -> Option<AssetMetadata<Self::Balance, Self::CustomMetadata, Self::StringLimit>> {
execute_call!(a)
}

fn location(a: &Self::AssetId) -> Result<Option<MultiLocation>, DispatchError> {
fn location(a: &Self::AssetId) -> Result<Option<Location>, DispatchError> {
execute_call!(a)
}
}
Expand All @@ -116,7 +116,7 @@ pub mod pallet {
c: Option<BoundedVec<u8, Self::StringLimit>>,
d: Option<BoundedVec<u8, Self::StringLimit>>,
e: Option<Self::Balance>,
g: Option<Option<VersionedMultiLocation>>,
g: Option<Option<VersionedLocation>>,
h: Option<Self::CustomMetadata>,
) -> DispatchResult {
execute_call!((a, b, c, d, e, g, h))
Expand Down
33 changes: 5 additions & 28 deletions libs/mocks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ macro_rules! make_runtime_for_mock {
($runtime_name:ident, $mock_name:ident, $pallet:ident, $externalities:ident) => {
use $crate::reexport::{
frame_support,
frame_support::traits::{ConstU16, ConstU32, ConstU64, Everything},
frame_support::derive_impl,
frame_system,
sp_core::H256,
sp_io,
sp_runtime::traits::{BlakeTwo256, IdentityLookup},
};

frame_support::construct_runtime!(
Expand All @@ -71,31 +69,10 @@ macro_rules! make_runtime_for_mock {
}
);

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

pub fn $externalities() -> sp_io::TestExternalities {
sp_io::TestExternalities::default()
Expand Down
27 changes: 12 additions & 15 deletions libs/test-utils/src/mocks/orml_asset_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

pub mod reexport {
pub use staging_xcm::{
v3::prelude::MultiLocation as __private_MultiLocation,
VersionedMultiLocation as __private_VersionedMultiLocation,
v4::prelude::Location as __private_Location,
VersionedLocation as __private_VersionedLocation,
};
}

Expand All @@ -36,7 +36,7 @@ macro_rules! impl_mock_registry {
};
use sp_runtime::{BoundedVec, BuildStorage};
use $crate::mocks::orml_asset_registry::reexport::{
__private_MultiLocation, __private_VersionedMultiLocation,
__private_Location, __private_VersionedLocation,
};

use super::*;
Expand All @@ -49,7 +49,7 @@ macro_rules! impl_mock_registry {
type CustomMetadata = $custom_metadata;
type StringLimit = $string_limit;

fn asset_id(location: &__private_MultiLocation) -> Option<Self::AssetId> {
fn asset_id(location: &__private_Location) -> Option<Self::AssetId> {
__private::STATE.with(|s| s.borrow().get_asset_from_location(location))
}

Expand All @@ -62,7 +62,7 @@ macro_rules! impl_mock_registry {
}

fn metadata_by_location(
location: &__private_MultiLocation,
location: &__private_Location,
) -> Option<
__private_AssetMetadata<Self::Balance, Self::CustomMetadata, Self::StringLimit>,
> {
Expand All @@ -71,7 +71,7 @@ macro_rules! impl_mock_registry {

fn location(
asset_id: &Self::AssetId,
) -> Result<Option<__private_MultiLocation>, __private_DispatchError> {
) -> Result<Option<__private_Location>, __private_DispatchError> {
let maybe_location =
__private::STATE.with(|s| s.borrow().get_location(asset_id));

Expand Down Expand Up @@ -103,7 +103,7 @@ macro_rules! impl_mock_registry {
name: Option<BoundedVec<u8, Self::StringLimit>>,
symbol: Option<BoundedVec<u8, Self::StringLimit>>,
existential_deposit: Option<Self::Balance>,
location: Option<Option<__private_VersionedMultiLocation>>,
location: Option<Option<__private_VersionedLocation>>,
additional: Option<Self::CustomMetadata>,
) -> __private_DispatchResult {
__private::STATE.with(|s| {
Expand Down Expand Up @@ -192,7 +192,7 @@ macro_rules! impl_mock_registry {
use super::*;

pub struct RegistryState {
pub location_to_asset: Vec<(__private_MultiLocation, $asset_id)>,
pub location_to_asset: Vec<(__private_Location, $asset_id)>,
pub metadata: Vec<(
$asset_id,
__private_AssetMetadata<$balance, $custom_metadata, $string_limit>,
Expand Down Expand Up @@ -230,10 +230,7 @@ macro_rules! impl_mock_registry {
Ok(())
}

pub fn get_location(
&self,
asset_id: &$asset_id,
) -> Option<__private_MultiLocation> {
pub fn get_location(&self, asset_id: &$asset_id) -> Option<__private_Location> {
for (curr_id, meta) in &self.metadata {
if curr_id == asset_id {
return meta
Expand All @@ -249,7 +246,7 @@ macro_rules! impl_mock_registry {

pub fn get_asset_from_location(
&self,
location: &__private_MultiLocation,
location: &__private_Location,
) -> Option<$asset_id> {
for (curr_location, asset_id) in &self.location_to_asset {
if curr_location == location {
Expand All @@ -262,7 +259,7 @@ macro_rules! impl_mock_registry {

pub fn get_meta_from_location(
&self,
location: &__private_MultiLocation,
location: &__private_Location,
) -> Option<__private_AssetMetadata<$balance, $custom_metadata, $string_limit>>
{
let asset_id = self.get_asset_from_location(location)?;
Expand All @@ -276,7 +273,7 @@ macro_rules! impl_mock_registry {
name: Option<BoundedVec<u8, $string_limit>>,
symbol: Option<BoundedVec<u8, $string_limit>>,
existential_deposit: Option<$balance>,
location: Option<Option<__private_VersionedMultiLocation>>,
location: Option<Option<__private_VersionedLocation>>,
additional: Option<$custom_metadata>,
) -> __private_DispatchResult {
for (curr_id, curr_meta) in &mut self.metadata {
Expand Down
67 changes: 8 additions & 59 deletions libs/types/src/locations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,76 +14,25 @@ use cfg_primitives::AccountId;
use frame_support::RuntimeDebugNoBound;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_core::{crypto::AccountId32, H256};
use sp_runtime::traits::{BlakeTwo256, Hash};
use staging_xcm::VersionedMultiLocation;
use sp_core::crypto::AccountId32;
use sp_std::boxed::Box;
use staging_xcm::VersionedLocation;

use crate::domain_address::DomainAddress;

/// Location types for destinations that can receive restricted transfers
#[derive(Clone, RuntimeDebugNoBound, Encode, Decode, Eq, PartialEq, MaxEncodedLen, TypeInfo)]
pub enum Location {
pub enum RestrictedTransferLocation {
/// Local chain account sending destination.
Local(AccountId),
/// XCM MultiLocation sending destinations.
/// Using hash value here as Multilocation is large -- v1 is 512 bytes, but
/// next largest is only 40 bytes other values aren't hashed as we have
/// blake2 hashing on storage map keys, and we don't want the extra overhead
XCM(H256),
/// XCM Location sending destinations.
Xcm(Box<VersionedLocation>),
/// DomainAddress sending location from a liquidity pools' instance
Address(DomainAddress),
}

impl From<AccountId32> for Location {
impl From<AccountId32> for RestrictedTransferLocation {
fn from(value: AccountId32) -> Self {
Self::Local(value)
}
}

impl From<VersionedMultiLocation> for Location {
fn from(vml: VersionedMultiLocation) -> Self {
// using hash here as multilocation is significantly larger than any other enum
// type here -- 592 bytes, vs 40 bytes for domain address (next largest)
Self::XCM(BlakeTwo256::hash(&vml.encode()))
}
}

impl From<DomainAddress> for Location {
fn from(da: DomainAddress) -> Self {
Self::Address(da)
}
}

#[cfg(test)]
mod test {

use hex::FromHex;
use staging_xcm::v3::MultiLocation;

use super::*;

#[test]
fn from_xcm_versioned_address_works() {
let xa = VersionedMultiLocation::V3(MultiLocation::default());
let l = Location::from(xa.clone());
assert_eq!(
l,
Location::XCM(sp_core::H256(
<[u8; 32]>::from_hex(
"a943e30c855a123a9506e69e678dc65ae9f5b70149cb6b26eb2ed58a59b4bf77"
)
.unwrap()
))
);
}

#[test]
fn from_domain_address_works() {
let da = DomainAddress::EVM(
1284,
<[u8; 20]>::from_hex("1231231231231231231231231231231231231231").unwrap(),
);
let l = Location::from(da.clone());

assert_eq!(l, Location::Address(da))
}
}
2 changes: 1 addition & 1 deletion libs/types/src/portfolio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use sp_std::{cmp::Ordering, marker::PhantomData, vec::Vec};
/// The total NAV is based on the reserve, the assets under management (AUM) and
/// pool fees:
///
/// ```ignore
/// ```text
/// NAV = PoolReserve + AUM - PoolFees
/// ```
///
Expand Down
4 changes: 3 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ jsonrpsee = { workspace = true, default-features = true }
log = { workspace = true, default-features = true }
parity-scale-codec = { default-features = true, workspace = true }
serde = { workspace = true, default-features = true }
serde_json = { workspace = true, default-features = true }
url = { workspace = true, default-features = true }

# client dependencies
pallet-transaction-payment-rpc = { workspace = true, default-features = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true, default-features = true }
sc-basic-authorship = { workspace = true, default-features = true }
sc-chain-spec = { workspace = true, default-features = true }
sc-cli = { workspace = true, default-features = true, features = ["rocksdb"] }
Expand Down Expand Up @@ -106,6 +108,7 @@ pallet-pool-system = { workspace = true, default-features = true }
runtime-common = { workspace = true, default-features = true }

# frontier
fc-api = { workspace = true, default-features = true }
fc-consensus = { workspace = true, default-features = true }
fc-db = { workspace = true, default-features = true, features = ["rocksdb"] }
fc-mapping-sync = { workspace = true, default-features = true }
Expand All @@ -121,7 +124,6 @@ pallet-evm = { workspace = true, default-features = true }

[build-dependencies]
substrate-build-script-utils = { workspace = true, default-features = true }
vergen = { workspace = true, default-features = true }

[features]
default = []
Expand Down
Loading

0 comments on commit ccbe93d

Please sign in to comment.