From a783c9fe157caf8dbd7aa92cfb25215628938886 Mon Sep 17 00:00:00 2001 From: lemunozm Date: Fri, 17 May 2024 09:52:32 +0200 Subject: [PATCH] upgraded runtime-common --- Cargo.lock | 643 +++++++++++++++++- Cargo.toml | 2 +- libs/types/src/locations.rs | 19 +- pallets/fees/src/mock.rs | 1 - .../routers/src/routers/axelar_evm.rs | 2 +- .../routers/src/routers/ethereum_xcm.rs | 2 +- pallets/oracle-feed/src/benchmarking.rs | 1 - runtime/altair/src/lib.rs | 2 +- runtime/centrifuge/src/lib.rs | 2 +- runtime/common/src/account_conversion.rs | 21 +- runtime/common/src/fees.rs | 10 + runtime/common/src/lib.rs | 142 ++-- runtime/common/src/transfer_filter.rs | 49 +- runtime/common/src/xcm.rs | 181 +++-- runtime/development/src/lib.rs | 2 +- 15 files changed, 822 insertions(+), 257 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ae83bef31..7f65c23cc9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -656,6 +656,17 @@ dependencies = [ "serde", ] +[[package]] +name = "bp-xcm-bridge-hub-router" +version = "0.6.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", +] + [[package]] name = "bs58" version = "0.5.1" @@ -1058,6 +1069,128 @@ dependencies = [ "subtle", ] +[[package]] +name = "cumulus-pallet-aura-ext" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "cumulus-pallet-parachain-system", + "frame-support", + "frame-system", + "pallet-aura", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-application-crypto", + "sp-consensus-aura", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + +[[package]] +name = "cumulus-pallet-dmp-queue" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "cumulus-primitives-core", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", + "staging-xcm", +] + +[[package]] +name = "cumulus-pallet-parachain-system" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "bytes", + "cumulus-pallet-parachain-system-proc-macro", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-primitives-proof-size-hostfunction", + "environmental", + "frame-benchmarking", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "pallet-message-queue", + "parity-scale-codec", + "polkadot-parachain-primitives", + "polkadot-runtime-parachains", + "scale-info", + "sp-core", + "sp-externalities 0.25.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-state-machine", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", + "sp-trie", + "sp-version", + "staging-xcm", + "trie-db", +] + +[[package]] +name = "cumulus-pallet-parachain-system-proc-macro" +version = "0.6.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.63", +] + +[[package]] +name = "cumulus-pallet-xcm" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", + "staging-xcm", +] + +[[package]] +name = "cumulus-pallet-xcmp-queue" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "bounded-collections", + "bp-xcm-bridge-hub-router", + "cumulus-primitives-core", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-message-queue", + "parity-scale-codec", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", + "staging-xcm", + "staging-xcm-executor", +] + [[package]] name = "cumulus-primitives-core" version = "0.7.0" @@ -1075,6 +1208,31 @@ dependencies = [ "staging-xcm", ] +[[package]] +name = "cumulus-primitives-parachain-inherent" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "async-trait", + "cumulus-primitives-core", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-inherents", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", + "sp-trie", +] + +[[package]] +name = "cumulus-primitives-proof-size-hostfunction" +version = "0.2.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "sp-externalities 0.25.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", + "sp-runtime-interface 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", + "sp-trie", +] + [[package]] name = "curve25519-dalek" version = "3.2.0" @@ -1529,6 +1687,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +[[package]] +name = "faster-hex" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51e2ce894d53b295cf97b05685aa077950ff3e8541af83217fc720a6437169f8" + [[package]] name = "ff" version = "0.13.0" @@ -2300,6 +2464,9 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] [[package]] name = "libc" @@ -2596,6 +2763,20 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.5" @@ -2634,12 +2815,24 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-rational" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ + "num-bigint", "num-integer", "num-traits", ] @@ -2811,6 +3004,20 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] +[[package]] +name = "orml-xcm" +version = "0.7.0" +source = "git+https://github.com/moonbeam-foundation/open-runtime-module-library?branch=moonbeam-polkadot-v1.7.2#f90f4de88986571e24ea3c027b9c09a4b732ee1f" +dependencies = [ + "frame-support", + "frame-system", + "pallet-xcm", + "parity-scale-codec", + "scale-info", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", + "staging-xcm", +] + [[package]] name = "orml-xcm-support" version = "0.7.0" @@ -2973,6 +3180,20 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] +[[package]] +name = "pallet-base-fee" +version = "1.0.0" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.7.2#91f1c7a447f987d732f87f86c3e02d506d426a99" +dependencies = [ + "fp-evm", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", +] + [[package]] name = "pallet-block-rewards" version = "0.1.0" @@ -3093,6 +3314,24 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] +[[package]] +name = "pallet-democracy" +version = "28.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "pallet-election-provider-multi-phase" version = "27.0.0" @@ -3130,6 +3369,25 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] +[[package]] +name = "pallet-elections-phragmen" +version = "29.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-npos-elections", + "sp-runtime", + "sp-staking", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "pallet-ethereum" version = "4.0.0-dev" @@ -3216,31 +3474,102 @@ dependencies = [ ] [[package]] -name = "pallet-evm-precompile-simple" -version = "2.0.0-dev" -source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.7.2#91f1c7a447f987d732f87f86c3e02d506d426a99" +name = "pallet-evm-precompile-balances-erc20" +version = "0.1.0" +source = "git+https://github.com/moonbeam-foundation/moonbeam?tag=v0.37.3#8081fdffb4d3d294dc5bbbb0ae8f02c348619499" dependencies = [ "fp-evm", - "ripemd", - "sp-io", -] - -[[package]] -name = "pallet-fast-unstake" -version = "27.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" -dependencies = [ - "docify", - "frame-benchmarking", - "frame-election-provider-support", "frame-support", "frame-system", "log", + "num_enum 0.5.11", + "pallet-balances", + "pallet-evm", + "pallet-timestamp", "parity-scale-codec", - "scale-info", + "paste", + "precompile-utils", + "slices", + "sp-core", "sp-io", "sp-runtime", - "sp-staking", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + +[[package]] +name = "pallet-evm-precompile-blake2" +version = "2.0.0-dev" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.7.2#91f1c7a447f987d732f87f86c3e02d506d426a99" +dependencies = [ + "fp-evm", +] + +[[package]] +name = "pallet-evm-precompile-bn128" +version = "2.0.0-dev" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.7.2#91f1c7a447f987d732f87f86c3e02d506d426a99" +dependencies = [ + "fp-evm", + "sp-core", + "substrate-bn", +] + +[[package]] +name = "pallet-evm-precompile-dispatch" +version = "2.0.0-dev" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.7.2#91f1c7a447f987d732f87f86c3e02d506d426a99" +dependencies = [ + "fp-evm", + "frame-support", + "pallet-evm", + "parity-scale-codec", + "sp-runtime", +] + +[[package]] +name = "pallet-evm-precompile-modexp" +version = "2.0.0-dev" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.7.2#91f1c7a447f987d732f87f86c3e02d506d426a99" +dependencies = [ + "fp-evm", + "num", +] + +[[package]] +name = "pallet-evm-precompile-sha3fips" +version = "2.0.0-dev" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.7.2#91f1c7a447f987d732f87f86c3e02d506d426a99" +dependencies = [ + "fp-evm", + "tiny-keccak", +] + +[[package]] +name = "pallet-evm-precompile-simple" +version = "2.0.0-dev" +source = "git+https://github.com/moonbeam-foundation/frontier?branch=moonbeam-polkadot-v1.7.2#91f1c7a447f987d732f87f86c3e02d506d426a99" +dependencies = [ + "fp-evm", + "ripemd", + "sp-io", +] + +[[package]] +name = "pallet-fast-unstake" +version = "27.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "docify", + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-staking", "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] @@ -3460,6 +3789,23 @@ dependencies = [ "strum", ] +[[package]] +name = "pallet-membership" +version = "28.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "pallet-message-queue" version = "31.0.0" @@ -3480,6 +3826,22 @@ dependencies = [ "sp-weights", ] +[[package]] +name = "pallet-multisig" +version = "28.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "pallet-oracle-collection" version = "1.0.0" @@ -3647,6 +4009,52 @@ dependencies = [ "strum", ] +[[package]] +name = "pallet-preimage" +version = "28.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + +[[package]] +name = "pallet-proxy" +version = "28.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + +[[package]] +name = "pallet-remarks" +version = "0.0.1" +source = "git+https://github.com/foss3/runtime-pallet-library?branch=polkadot-v1.7.2#e27ed4ebffc8800683773aac686938fbbe0a67ef" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "pallet-restricted-tokens" version = "0.1.0" @@ -3706,6 +4114,24 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] +[[package]] +name = "pallet-scheduler" +version = "29.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "docify", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", + "sp-weights", +] + [[package]] name = "pallet-session" version = "28.0.0" @@ -3760,6 +4186,22 @@ dependencies = [ "sp-arithmetic", ] +[[package]] +name = "pallet-sudo" +version = "28.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "docify", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "pallet-swaps" version = "1.0.0" @@ -3889,6 +4331,22 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] +[[package]] +name = "pallet-utility" +version = "28.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "pallet-vesting" version = "28.0.0" @@ -4600,6 +5058,112 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "runtime-common" +version = "1.0.0" +dependencies = [ + "axelar-gateway-precompile", + "cfg-mocks", + "cfg-primitives", + "cfg-traits", + "cfg-types", + "cfg-utils", + "chainbridge", + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "frame-benchmarking", + "frame-support", + "frame-system", + "hex-literal 0.3.4", + "log", + "num_enum 0.5.11", + "orml-asset-registry", + "orml-tokens", + "orml-traits", + "orml-xcm", + "orml-xtokens", + "pallet-anchors", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-base-fee", + "pallet-block-rewards", + "pallet-bridge", + "pallet-collator-allowlist", + "pallet-collator-selection", + "pallet-collective", + "pallet-democracy", + "pallet-elections-phragmen", + "pallet-ethereum", + "pallet-ethereum-transaction", + "pallet-evm", + "pallet-evm-chain-id", + "pallet-evm-precompile-balances-erc20", + "pallet-evm-precompile-blake2", + "pallet-evm-precompile-bn128", + "pallet-evm-precompile-dispatch", + "pallet-evm-precompile-modexp", + "pallet-evm-precompile-sha3fips", + "pallet-evm-precompile-simple", + "pallet-fees", + "pallet-foreign-investments", + "pallet-identity", + "pallet-interest-accrual", + "pallet-investments", + "pallet-keystore", + "pallet-liquidity-pools", + "pallet-liquidity-pools-gateway", + "pallet-liquidity-rewards", + "pallet-loans", + "pallet-membership", + "pallet-multisig", + "pallet-oracle-collection", + "pallet-oracle-feed", + "pallet-order-book", + "pallet-permissions", + "pallet-pool-fees", + "pallet-pool-registry", + "pallet-pool-system", + "pallet-preimage", + "pallet-proxy", + "pallet-remarks", + "pallet-restricted-tokens", + "pallet-restricted-xtokens", + "pallet-rewards", + "pallet-scheduler", + "pallet-session", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transfer-allowlist", + "pallet-treasury", + "pallet-uniques", + "pallet-utility", + "pallet-vesting", + "pallet-xcm", + "pallet-xcm-transactor", + "parity-scale-codec", + "polkadot-parachain-primitives", + "precompile-utils", + "scale-info", + "serde", + "smallvec", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", + "staging-parachain-info", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "xcm-primitives", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -4916,6 +5480,18 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slices" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2086e458a369cdca838e9f6ed04b4cc2e3ce636d99abb80c9e2eada107749cf" +dependencies = [ + "faster-hex", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "slot-range-helper" version = "7.0.0" @@ -5606,6 +6182,12 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "spki" version = "0.7.3" @@ -5637,6 +6219,20 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "staging-parachain-info" +version = "0.7.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "staging-xcm" version = "7.0.0" @@ -5739,6 +6335,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "substrate-bn" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b5bbfa79abbae15dd642ea8176a21a635ff3c00059961d1ea27ad04e5b441c" +dependencies = [ + "byteorder", + "crunchy", + "lazy_static", + "rand", + "rustc-hex", +] + [[package]] name = "substrate-wasm-builder-runner" version = "3.0.0" diff --git a/Cargo.toml b/Cargo.toml index 780daeb3ce..e02dd931d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ members = [ #"runtime/altair", #"runtime/centrifuge", #"runtime/development", - #"runtime/common", + "runtime/common", #"runtime/integration-tests", #"runtime/integration-tests/procedural", ] diff --git a/libs/types/src/locations.rs b/libs/types/src/locations.rs index 66f0afa432..08c9b31863 100644 --- a/libs/types/src/locations.rs +++ b/libs/types/src/locations.rs @@ -21,7 +21,7 @@ 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 CfgLocation { /// Local chain account sending destination. Local(AccountId), /// XCM MultiLocation sending destinations. @@ -33,21 +33,24 @@ pub enum Location { Address(DomainAddress), } -impl From for Location { +impl From for CfgLocation { fn from(value: AccountId32) -> Self { Self::Local(value) } } -impl From for Location { +impl From for CfgLocation { fn from(vml: VersionedLocation) -> 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())) + + // TODO-1.7: I'm afraid of locations translated from v3 to v4 will generate a different hash here. + // How this affect our current chain state? } } -impl From for Location { +impl From for CfgLocation { fn from(da: DomainAddress) -> Self { Self::Address(da) } @@ -65,10 +68,10 @@ mod test { fn from_xcm_versioned_address_works() { // TODO-1.7: Must be changed to V4? let xa = VersionedLocation::V3(MultiLocation::default()); - let l = Location::from(xa.clone()); + let l = CfgLocation::from(xa.clone()); assert_eq!( l, - Location::XCM(sp_core::H256( + CfgLocation::XCM(sp_core::H256( <[u8; 32]>::from_hex( "a943e30c855a123a9506e69e678dc65ae9f5b70149cb6b26eb2ed58a59b4bf77" ) @@ -83,8 +86,8 @@ mod test { 1284, <[u8; 20]>::from_hex("1231231231231231231231231231231231231231").unwrap(), ); - let l = Location::from(da.clone()); + let l = CfgLocation::from(da.clone()); - assert_eq!(l, Location::Address(da)) + assert_eq!(l, CfgLocation::Address(da)) } } diff --git a/pallets/fees/src/mock.rs b/pallets/fees/src/mock.rs index 2c51dbc66f..7b055573e8 100644 --- a/pallets/fees/src/mock.rs +++ b/pallets/fees/src/mock.rs @@ -57,7 +57,6 @@ impl pallet_authorship::Config for Runtime { parameter_types! { pub const TreasuryPalletId: PalletId = PalletId(*b"treasury"); pub TreasuryAccount: u64 = Treasury::account_id(); - pub TreasuryInstance1Account: u64 = Treasury::account_id(); } impl pallet_treasury::Config for Runtime { diff --git a/pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs b/pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs index 99d6b6c2cc..865557b848 100644 --- a/pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs +++ b/pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs @@ -115,7 +115,7 @@ pub(crate) fn get_axelar_encoded_msg( }, ], outputs: vec![], - constant: false, + constant: Some(false), state_mutability: Default::default(), }], )]), diff --git a/pallets/liquidity-pools-gateway/routers/src/routers/ethereum_xcm.rs b/pallets/liquidity-pools-gateway/routers/src/routers/ethereum_xcm.rs index 83f49cf796..a92569b277 100644 --- a/pallets/liquidity-pools-gateway/routers/src/routers/ethereum_xcm.rs +++ b/pallets/liquidity-pools-gateway/routers/src/routers/ethereum_xcm.rs @@ -84,7 +84,7 @@ pub(crate) fn get_xcm_router_contract() -> Contract { internal_type: None, }], outputs: vec![], - constant: false, + constant: Some(false), state_mutability: Default::default(), }], ); diff --git a/pallets/oracle-feed/src/benchmarking.rs b/pallets/oracle-feed/src/benchmarking.rs index 26b8563eb8..a4532f8b06 100644 --- a/pallets/oracle-feed/src/benchmarking.rs +++ b/pallets/oracle-feed/src/benchmarking.rs @@ -3,7 +3,6 @@ use frame_benchmarking::{v2::*, whitelisted_caller}; use frame_support::traits::OriginTrait; use frame_system::RawOrigin; use parity_scale_codec::Decode; -use sp_std::vec; // required for #[benchmarks] use crate::pallet::{Call, Config, Pallet}; diff --git a/runtime/altair/src/lib.rs b/runtime/altair/src/lib.rs index 1033814b80..36d17acd9d 100644 --- a/runtime/altair/src/lib.rs +++ b/runtime/altair/src/lib.rs @@ -2324,7 +2324,7 @@ impl_runtime_apis! { // Investment Runtime APIs impl runtime_common::apis::InvestmentsApi> for Runtime { fn investment_portfolio(account_id: AccountId) -> Vec<(TrancheCurrency, InvestmentPortfolio)> { - runtime_common::investment_portfolios::get_account_portfolio::(account_id) + runtime_common::investment_portfolios::get_account_portfolio::(account_id) } } diff --git a/runtime/centrifuge/src/lib.rs b/runtime/centrifuge/src/lib.rs index f6193db3e4..0fa0feb097 100644 --- a/runtime/centrifuge/src/lib.rs +++ b/runtime/centrifuge/src/lib.rs @@ -2371,7 +2371,7 @@ impl_runtime_apis! { // Investment Runtime APIs impl runtime_common::apis::InvestmentsApi> for Runtime { fn investment_portfolio(account_id: AccountId) -> Vec<(TrancheCurrency, InvestmentPortfolio)> { - runtime_common::investment_portfolios::get_account_portfolio::(account_id) + runtime_common::investment_portfolios::get_account_portfolio::(account_id) } } diff --git a/runtime/common/src/account_conversion.rs b/runtime/common/src/account_conversion.rs index 99061a6073..8234c1aabd 100644 --- a/runtime/common/src/account_conversion.rs +++ b/runtime/common/src/account_conversion.rs @@ -15,7 +15,7 @@ use cfg_types::domain_address::{Domain, DomainAddress}; use pallet_evm::AddressMapping; use sp_core::{Get, H160}; use sp_runtime::traits::Convert; -use staging_xcm::v3; +use staging_xcm::v4::{Junction::AccountKey20, Location, NetworkId::Ethereum}; use staging_xcm_executor::traits::ConvertLocation; /// Common converter code for translating accounts across different @@ -40,22 +40,21 @@ impl AccountConverter { } pub fn location_to_account>( - location: v3::MultiLocation, + location: Location, ) -> Option { // Try xcm logic first match XcmConverter::convert_location(&location) { Some(acc) => Some(acc), None => { // match EVM logic - match location { - v3::MultiLocation { - parents: 0, - interior: - v3::Junctions::X1(v3::Junction::AccountKey20 { - network: Some(v3::NetworkId::Ethereum { chain_id }), - key, - }), - } => Some(Self::convert_evm_address(chain_id, key)), + match location.unpack() { + ( + 0, + [AccountKey20 { + network: Some(Ethereum { chain_id }), + key, + }], + ) => Some(Self::convert_evm_address(*chain_id, *key)), _ => None, } } diff --git a/runtime/common/src/fees.rs b/runtime/common/src/fees.rs index 6a951a1087..a3baa3c99d 100644 --- a/runtime/common/src/fees.rs +++ b/runtime/common/src/fees.rs @@ -143,6 +143,7 @@ mod test { use cfg_types::ids::TREASURY_PALLET_ID; use frame_support::{ derive_impl, parameter_types, + traits::tokens::{PayFromAccount, UnityAssetBalanceConversion}, traits::{Currency, FindAuthor}, PalletId, }; @@ -185,6 +186,7 @@ mod test { parameter_types! { pub const TreasuryPalletId: PalletId = TREASURY_PALLET_ID; + pub TreasuryAccount: AccountId = Treasury::account_id(); pub const MaxApprovals: u32 = 100; } @@ -205,6 +207,14 @@ mod test { type SpendOrigin = frame_support::traits::NeverEnsureOrigin; type SpendPeriod = (); type WeightInfo = (); + 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 = (); } pub struct OneAuthor; diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 673b2bb54d..742991881f 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -85,13 +85,13 @@ pub struct CurrencyED(PhantomData); impl GetByKey for CurrencyED where T: pallet_balances::Config - + orml_asset_registry::Config, + + orml_asset_registry::module::Config, { fn get(currency_id: &CurrencyId) -> Balance { match currency_id { CurrencyId::Native => T::ExistentialDeposit::get(), CurrencyId::Staking(StakingCurrency::BlockRewards) => T::ExistentialDeposit::get(), - currency_id => orml_asset_registry::Pallet::::metadata(currency_id) + currency_id => orml_asset_registry::module::Pallet::::metadata(currency_id) .map(|metadata| metadata.existential_deposit) .unwrap_or_default(), } @@ -285,16 +285,20 @@ pub mod asset_registry { /// Module for investment portfolio common to all runtimes pub mod investment_portfolios { - use cfg_primitives::{Balance, PoolId, TrancheId}; + use cfg_primitives::{AccountId, Balance, PoolId}; use cfg_traits::{ - investments::{InvestmentCollector, TrancheCurrency}, - PoolInspect, Seconds, + investments::{InvestmentCollector, TrancheCurrency as _}, + PoolInspect, + }; + use cfg_types::{ + investments::InvestmentPortfolio, + tokens::{CurrencyId, TrancheCurrency}, }; - use cfg_types::{investments::InvestmentPortfolio, tokens::CurrencyId}; use frame_support::traits::{ fungibles, tokens::{Fortitude, Preservation}, }; + use fungibles::{Inspect, InspectHold}; use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; /// Get the PoolId, CurrencyId, InvestmentId, and Balance for all @@ -303,76 +307,51 @@ pub mod investment_portfolios { /// NOTE: Moving inner scope to any pallet would introduce tight(er) /// coupling due to requirement of iterating over storage maps which in turn /// require the pallet's Config trait. - pub fn get_account_portfolio( - investor: ::AccountId, - ) -> Vec<( - ::InvestmentId, - InvestmentPortfolio, - )> + pub fn get_account_portfolio( + investor: AccountId, + ) -> Vec<(TrancheCurrency, InvestmentPortfolio)> where - T: frame_system::Config - + pallet_investments::Config - + orml_tokens::Config - + pallet_restricted_tokens::Config, - ::InvestmentId: TrancheCurrency - + Into<::CurrencyId> - + Ord - + Into<::CurrencyId>, - CurrencyId: From<::CurrencyId> - + From<::CurrencyId>, - ::CurrencyId: - From<::CurrencyId>, - Balance: From<::Amount> - + From<::Balance>, - PoolInspector: PoolInspect< - ::AccountId, - ::CurrencyId, - PoolId = PoolId, - TrancheId = TrancheId, - Moment = Seconds, - >, + T: frame_system::Config + + pallet_investments::Config + + orml_tokens::Config + + pallet_pool_system::Config, { - let mut portfolio = BTreeMap::< - ::InvestmentId, - InvestmentPortfolio, - >::new(); + let mut portfolio = + BTreeMap::>::new(); // Denote current tranche token balances before dry running collecting orml_tokens::Accounts::::iter_key_prefix(&investor).for_each(|currency| { - if let CurrencyId::Tranche(pool_id, tranche_id) = CurrencyId::from(currency) { - let pool_currency = PoolInspector::currency_for(pool_id) - .expect("Pool must exist; qed") - .into(); - let free_balance = as fungibles::Inspect< - T::AccountId, - >>::reducible_balance( - currency.into(), + if let CurrencyId::Tranche(pool_id, tranche_id) = currency { + let pool_currency = pallet_pool_system::Pallet::::currency_for(pool_id) + .expect("Pool must exist; qed"); + + let free_balance = orml_tokens::Pallet::::reducible_balance( + currency, &investor, Preservation::Preserve, Fortitude::Polite, ); - let reserved_balance = as fungibles::InspectHold< - T::AccountId, - >>::balance_on_hold(currency.into(), &(), &investor); + let reserved_balance = + orml_tokens::Pallet::::balance_on_hold(currency, &(), &investor); portfolio .entry(TrancheCurrency::generate(pool_id, tranche_id)) .and_modify(|p| { - p.free_tranche_tokens = free_balance.into(); - p.reserved_tranche_tokens = reserved_balance.into(); + p.free_tranche_tokens = free_balance; + p.reserved_tranche_tokens = reserved_balance; }) .or_insert( InvestmentPortfolio::::new(pool_currency) - .with_free_tranche_tokens(free_balance.into()) - .with_reserved_tranche_tokens(reserved_balance.into()), + .with_free_tranche_tokens(free_balance) + .with_reserved_tranche_tokens(reserved_balance), ); } }); // Set pending invest currency and claimable tranche tokens pallet_investments::InvestOrders::::iter_key_prefix(&investor).for_each(|invest_id| { - let pool_currency = - PoolInspector::currency_for(invest_id.of_pool()).expect("Pool must exist; qed"); + let pool_currency = pallet_pool_system::Pallet::::currency_for(invest_id.of_pool()) + .expect("Pool must exist; qed"); // Collect such that we can determine claimable tranche tokens // NOTE: Does not modify storage since RtAPI is readonly @@ -381,44 +360,40 @@ pub mod investment_portfolios { let amount = pallet_investments::InvestOrders::::get(&investor, invest_id) .map(|order| order.amount()) .unwrap_or_default(); - let free_tranche_tokens_new: Balance = as fungibles::Inspect< - T::AccountId, - >>::reducible_balance( + let free_tranche_tokens_new = orml_tokens::Pallet::::reducible_balance( invest_id.into(), &investor, Preservation::Preserve, Fortitude::Polite, - ).into(); + ); portfolio .entry(invest_id) .and_modify(|p| { - p.pending_invest_currency = amount.into(); + p.pending_invest_currency = amount; if p.free_tranche_tokens < free_tranche_tokens_new { p.claimable_tranche_tokens = free_tranche_tokens_new.saturating_sub(p.free_tranche_tokens); } }) .or_insert( - InvestmentPortfolio::::new(pool_currency.into()) - .with_pending_invest_currency(amount.into()) + InvestmentPortfolio::::new(pool_currency) + .with_pending_invest_currency(amount) .with_claimable_tranche_tokens(free_tranche_tokens_new), ); }); // Set pending tranche tokens and claimable invest currency pallet_investments::RedeemOrders::::iter_key_prefix(&investor).for_each(|invest_id| { - let pool_currency = - PoolInspector::currency_for(invest_id.of_pool()).expect("Pool must exist; qed"); - let balance_before: Balance = - as fungibles::Inspect< - T::AccountId, - >>::reducible_balance( - pool_currency, - &investor, - Preservation::Preserve, - Fortitude::Polite, - ).into(); + let pool_currency = pallet_pool_system::Pallet::::currency_for(invest_id.of_pool()) + .expect("Pool must exist; qed"); + + let balance_before = orml_tokens::Pallet::::reducible_balance( + pool_currency, + &investor, + Preservation::Preserve, + Fortitude::Polite, + ); // Collect such that we can determine claimable invest currency // NOTE: Does not modify storage since RtAPI is readonly @@ -427,27 +402,24 @@ pub mod investment_portfolios { let amount = pallet_investments::RedeemOrders::::get(&investor, invest_id) .map(|order| order.amount()) .unwrap_or_default(); - let balance_after: Balance = - as fungibles::Inspect< - T::AccountId, - >>::reducible_balance( - pool_currency, - &investor, - Preservation::Preserve, - Fortitude::Polite, - ).into(); + let balance_after = orml_tokens::Pallet::::reducible_balance( + pool_currency, + &investor, + Preservation::Preserve, + Fortitude::Polite, + ); portfolio .entry(invest_id) .and_modify(|p| { - p.pending_redeem_tranche_tokens = amount.into(); + p.pending_redeem_tranche_tokens = amount; if balance_before < balance_after { p.claimable_currency = balance_after.saturating_sub(balance_before); } }) .or_insert( - InvestmentPortfolio::::new(pool_currency.into()) - .with_pending_redeem_tranche_tokens(amount.into()) + InvestmentPortfolio::::new(pool_currency) + .with_pending_redeem_tranche_tokens(amount) .with_claimable_currency(balance_after), ); }); @@ -474,7 +446,7 @@ pub mod xcm_transactor { } impl XcmTransact for NullTransactor { - fn destination(self) -> staging_xcm::latest::MultiLocation { + fn destination(self) -> staging_xcm::latest::Location { Default::default() } } diff --git a/runtime/common/src/transfer_filter.rs b/runtime/common/src/transfer_filter.rs index c8a634e867..445a4cc446 100644 --- a/runtime/common/src/transfer_filter.rs +++ b/runtime/common/src/transfer_filter.rs @@ -14,7 +14,7 @@ use cfg_primitives::{AccountId, Balance}; use cfg_traits::{PreConditions, TransferAllowance}; use cfg_types::{ domain_address::DomainAddress, - locations::Location, + locations::CfgLocation, tokens::{CurrencyId, FilterCurrency}, }; use frame_support::{traits::IsSubType, RuntimeDebugNoBound}; @@ -29,36 +29,36 @@ use sp_runtime::{ DispatchError, DispatchResult, TokenError, }; use sp_std::vec::Vec; -use staging_xcm::v3::{MultiAsset, MultiLocation}; +use staging_xcm::v4::{Asset, Location}; pub struct PreXcmTransfer(sp_std::marker::PhantomData<(T, C)>); impl< - T: TransferAllowance, - C: Convert>, + T: TransferAllowance, + C: Convert>, > PreConditions> for PreXcmTransfer { type Result = DispatchResult; fn check(t: TransferEffects) -> Self::Result { - let currency_based_check = |sender: AccountId, destination: MultiLocation, currency| { + let currency_based_check = |sender: AccountId, destination: Location, currency| { amalgamate_allowance( T::allowance( sender.clone(), - Location::XCM(BlakeTwo256::hash(&destination.encode())), + CfgLocation::XCM(BlakeTwo256::hash(&destination.encode())), FilterCurrency::Specific(currency), ), T::allowance( sender, - Location::XCM(BlakeTwo256::hash(&destination.encode())), + CfgLocation::XCM(BlakeTwo256::hash(&destination.encode())), FilterCurrency::All, ), ) }; - let asset_based_check = |sender, destination, asset| { + let asset_based_check = |sender, destination, asset: Asset| { let currency = - C::convert(asset).ok_or(DispatchError::Token(TokenError::UnknownAsset))?; + C::convert(asset.id.0).ok_or(DispatchError::Token(TokenError::UnknownAsset))?; currency_based_check(sender, destination, currency) }; @@ -87,7 +87,7 @@ impl< asset, fee_asset, } => { - asset_based_check(sender.clone(), destination, asset)?; + asset_based_check(sender.clone(), destination.clone(), asset)?; // NOTE: We do check the fee asset and assume that the destination // is the same as for the actual assets. This is a pure subjective @@ -102,7 +102,7 @@ impl< fee, } => { for (currency, ..) in currencies { - currency_based_check(sender.clone(), destination, currency)?; + currency_based_check(sender.clone(), destination.clone(), currency)?; } // NOTE: We do check the fee asset and assume that the destination @@ -121,7 +121,7 @@ impl< // but rather a burn of tokens. Furthermore, we do not know the // destination where those fees will go. for asset in assets.into_inner() { - asset_based_check(sender.clone(), destination, asset)?; + asset_based_check(sender.clone(), destination.clone().clone(), asset)?; } // NOTE: We do check the fee asset and assume that the destination @@ -136,7 +136,7 @@ impl< pub struct PreNativeTransfer(sp_std::marker::PhantomData); -impl> +impl> PreConditions> for PreNativeTransfer { type Result = bool; @@ -145,12 +145,12 @@ impl(sp_std::marker::PhantomData); -impl> +impl> PreConditions<(AccountId, DomainAddress, CurrencyId)> for PreLpTransfer { type Result = DispatchResult; @@ -170,10 +170,10 @@ impl Result, TransactionValidityError> { Self::recursive_search(caller.clone(), call, |who, balance_call, checks| { match balance_call { - pallet_balances::Call::transfer { dest, .. } - | pallet_balances::Call::transfer_all { dest, .. } + pallet_balances::Call::transfer_all { dest, .. } | pallet_balances::Call::transfer_allow_death { dest, .. } | pallet_balances::Call::transfer_keep_alive { dest, .. } => { let recv: T::AccountId = ::Lookup::lookup( @@ -298,7 +297,7 @@ where + pallet_utility::Config::RuntimeCall> + pallet_proxy::Config::RuntimeCall> + pallet_remarks::Config::RuntimeCall> - + pallet_transfer_allowlist::Config + + pallet_transfer_allowlist::Config + Sync + Send, ::RuntimeCall: IsSubType> @@ -330,12 +329,12 @@ where amalgamate_allowance( pallet_transfer_allowlist::pallet::Pallet::::allowance( who.clone(), - Location::Local(recv.clone()), + CfgLocation::Local(recv.clone()), FilterCurrency::All, ), pallet_transfer_allowlist::pallet::Pallet::::allowance( who.clone(), - Location::Local(recv.clone()), + CfgLocation::Local(recv.clone()), FilterCurrency::Specific(CurrencyId::Native), ), ) @@ -345,8 +344,8 @@ where } fn amalgamate_allowance( - first: Result, DispatchError>, - second: Result, DispatchError>, + first: Result, DispatchError>, + second: Result, DispatchError>, ) -> DispatchResult { match (first, second) { // There is an allowance set for `Specific(id)`, but NOT for the given recv diff --git a/runtime/common/src/xcm.rs b/runtime/common/src/xcm.rs index acddef4ff9..63ed8b87cf 100644 --- a/runtime/common/src/xcm.rs +++ b/runtime/common/src/xcm.rs @@ -19,14 +19,15 @@ use cfg_types::{ }; use frame_support::traits::{fungibles::Mutate, Everything, Get}; use frame_system::pallet_prelude::BlockNumberFor; +use orml_traits::asset_registry::Inspect; use polkadot_parachain_primitives::primitives::Sibling; use sp_runtime::traits::{AccountIdConversion, Convert, MaybeEquivalence, Zero}; use sp_std::marker::PhantomData; -use staging_xcm::v3::{ - prelude::*, +use staging_xcm::v4::{ + Asset, AssetId, + Fungibility::Fungible, Junction::{AccountId32, AccountKey20, GeneralKey, Parachain}, - Junctions::{X1, X2}, - MultiAsset, MultiLocation, NetworkId, OriginKind, + Location, NetworkId, OriginKind, }; use staging_xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, @@ -50,7 +51,7 @@ impl< >, > orml_traits::FixedConversionRateProvider for FixedConversionRateProvider { - fn get_fee_per_second(location: &MultiLocation) -> Option { + fn get_fee_per_second(location: &Location) -> Option { let metadata = OrmlAssetRegistry::metadata_by_location(location)?; match metadata.additional.transferability { CrossChainTransferability::Xcm(xcm_metadata) => xcm_metadata @@ -70,14 +71,14 @@ pub fn general_key(data: &[u8]) -> staging_xcm::latest::Junction { } } -/// How we convert an `[AccountId]` into an XCM MultiLocation +/// How we convert an `[AccountId]` into an XCM Location pub struct AccountIdToMultiLocation; -impl> Convert for AccountIdToMultiLocation { - fn convert(account: AccountId) -> MultiLocation { - X1(AccountId32 { +impl> Convert for AccountIdToMultiLocation { + fn convert(account: AccountId) -> Location { + AccountId32 { network: None, id: account.into(), - }) + } .into() } } @@ -93,35 +94,26 @@ where From, { fn convert_origin( - origin: impl Into, + origin: impl Into, kind: OriginKind, - ) -> Result<::RuntimeOrigin, MultiLocation> { - let location: MultiLocation = origin.into(); - match kind { - OriginKind::SovereignAccount => match location { - MultiLocation { - parents: 1, - interior: X2(Parachain(para), AccountKey20 { key, .. }), - } => { - let evm_id = ParaAsEvmChain::try_convert(para).map_err(|_| location)?; - let domain_address = DomainAddress::EVM(evm_id, key); - - if pallet_liquidity_pools_gateway::Pallet::::relayer( - Domain::EVM(evm_id), - &domain_address, - ) - .is_some() - { - Ok(pallet_liquidity_pools_gateway::GatewayOrigin::AxelarRelay( - domain_address, - ) - .into()) - } else { - Err(location) - } - } - _ => Err(location), - }, + ) -> Result<::RuntimeOrigin, Location> { + let location = origin.into(); + match (kind, location.clone().unpack()) { + (OriginKind::SovereignAccount, (1, [Parachain(para), AccountKey20 { key, .. }])) => { + let evm_id = ParaAsEvmChain::try_convert(*para).map_err(|_| location.clone())?; + let domain_address = DomainAddress::EVM(evm_id, *key); + + pallet_liquidity_pools_gateway::Pallet::::relayer( + Domain::EVM(evm_id), + &domain_address, + ) + .ok_or(location.clone())?; + + Ok( + pallet_liquidity_pools_gateway::GatewayOrigin::AxelarRelay(domain_address) + .into(), + ) + } _ => Err(location), } } @@ -149,97 +141,80 @@ where /// CurrencyIdConvert /// This type implements conversions from our `CurrencyId` type into -/// `MultiLocation` and vice-versa. A currency locally is identified with a +/// `Location` and vice-versa. A currency locally is identified with a /// `CurrencyId` variant but in the network it is identified in the form of a -/// `MultiLocation`. +/// `Location`. pub struct CurrencyIdConvert(PhantomData); -impl MaybeEquivalence for CurrencyIdConvert +impl MaybeEquivalence for CurrencyIdConvert where - T: orml_asset_registry::Config + T: orml_asset_registry::module::Config + staging_parachain_info::Config, { - fn convert(location: &MultiLocation) -> Option { + fn convert(location: &Location) -> Option { let para_id = staging_parachain_info::Pallet::::parachain_id(); let unanchored_location = match location { - MultiLocation { + Location { parents: 0, interior, - } => MultiLocation { + } => Location { parents: 1, interior: interior + .clone() .pushed_front_with(Parachain(u32::from(para_id))) .ok()?, }, - x => *x, + x => x.clone(), }; - orml_asset_registry::Pallet::::location_to_asset_id(unanchored_location) + orml_asset_registry::module::Pallet::::asset_id(&unanchored_location) } - fn convert_back(id: &CurrencyId) -> Option { - orml_asset_registry::Pallet::::metadata(id) + fn convert_back(id: &CurrencyId) -> Option { + orml_asset_registry::module::Pallet::::metadata(id) .filter(|m| m.additional.transferability.includes_xcm()) .and_then(|m| m.location) .and_then(|l| l.try_into().ok()) } } -/// Convert our `CurrencyId` type into its `MultiLocation` representation. -/// We use the `AssetRegistry` to lookup the associated `MultiLocation` for +/// Convert our `CurrencyId` type into its `Location` representation. +/// We use the `AssetRegistry` to lookup the associated `Location` for /// any given `CurrencyId`, while blocking tokens that are not Xcm-transferable. -impl Convert> for CurrencyIdConvert +impl Convert> for CurrencyIdConvert where - T: orml_asset_registry::Config + T: orml_asset_registry::module::Config + staging_parachain_info::Config, { - fn convert(id: CurrencyId) -> Option { + fn convert(id: CurrencyId) -> Option { >::convert_back(&id) } } -/// Convert an incoming `MultiLocation` into a `CurrencyId` through a +/// Convert an incoming `Location` into a `CurrencyId` through a /// reverse-lookup using the AssetRegistry. In the registry, we register CFG -/// using its absolute, non-anchored MultiLocation so we need to unanchor the +/// using its absolute, non-anchored Location so we need to unanchor the /// input location for Centrifuge-native assets for that to work. -impl Convert> for CurrencyIdConvert +impl Convert> for CurrencyIdConvert where - T: orml_asset_registry::Config + T: orml_asset_registry::module::Config + staging_parachain_info::Config, { - fn convert(location: MultiLocation) -> Option { + fn convert(location: Location) -> Option { >::convert(&location) } } -impl Convert> for CurrencyIdConvert -where - T: orml_asset_registry::Config - + staging_parachain_info::Config, -{ - fn convert(asset: MultiAsset) -> Option { - if let MultiAsset { - id: Concrete(location), - .. - } = asset - { - >::convert(&location) - } else { - None - } - } -} - pub struct ToTreasury(PhantomData); impl TakeRevenue for ToTreasury where - T: orml_asset_registry::Config + T: orml_asset_registry::module::Config + staging_parachain_info::Config + pallet_restricted_tokens::Config, { - fn take_revenue(revenue: MultiAsset) { - if let MultiAsset { - id: Concrete(location), + fn take_revenue(revenue: Asset) { + if let Asset { + id: AssetId(location), fun: Fungible(amount), } = revenue { @@ -268,7 +243,7 @@ pub type Barrier = ( AllowSubscriptionsFrom, ); -/// Type for specifying how a `MultiLocation` can be converted into an +/// Type for specifying how a `Location` can be converted into an /// `AccountId`. This is used when determining ownership of accounts for asset /// transacting and when attempting to use XCM `Transact` in order to determine /// the dispatch Origin. @@ -374,15 +349,15 @@ mod test { Ok(RELAYER_EVM_ID) }); - let location: MultiLocation = MultiLocation::new( + let location = Location::new( 1, - X2( + [ Parachain(RELAYER_PARA_ID), AccountKey20 { network: None, key: RELAYER_ADDRESS, }, - ), + ], ); let origin = LpInstanceRelayer::::convert_origin( @@ -413,11 +388,11 @@ mod test { Ok(RELAYER_EVM_ID) }); - let location: MultiLocation = MultiLocation::new(1, X1(Parachain(RELAYER_PARA_ID))); + let location = Location::new(1, Parachain(RELAYER_PARA_ID)); assert_eq!( LpInstanceRelayer::::convert_origin( - location, + location.clone(), OriginKind::SovereignAccount, ) .unwrap_err(), @@ -434,20 +409,20 @@ mod test { Ok(RELAYER_EVM_ID) }); - let location: MultiLocation = MultiLocation::new( + let location = Location::new( 1, - X2( + [ Parachain(RELAYER_PARA_ID), AccountKey20 { network: None, key: RELAYER_ADDRESS, }, - ), + ], ); assert_eq!( LpInstanceRelayer::::convert_origin( - location, + location.clone(), OriginKind::SovereignAccount, ) .unwrap_err(), @@ -471,20 +446,20 @@ mod test { Err(()) }); - let location: MultiLocation = MultiLocation::new( + let location = Location::new( 1, - X2( + [ Parachain(RELAYER_PARA_ID), AccountKey20 { network: None, key: RELAYER_ADDRESS, }, - ), + ], ); assert_eq!( LpInstanceRelayer::::convert_origin( - location, + location.clone(), OriginKind::SovereignAccount, ) .unwrap_err(), @@ -508,20 +483,20 @@ mod test { Err(()) }); - let location: MultiLocation = MultiLocation::new( + let location = Location::new( 1, - X2( + [ Parachain(1), AccountKey20 { network: None, key: RELAYER_ADDRESS, }, - ), + ], ); assert_eq!( LpInstanceRelayer::::convert_origin( - location, + location.clone(), OriginKind::SovereignAccount, ) .unwrap_err(), @@ -545,20 +520,20 @@ mod test { Ok(RELAYER_EVM_ID) }); - let location: MultiLocation = MultiLocation::new( + let location = Location::new( 1, - X2( + [ Parachain(RELAYER_PARA_ID), AccountKey20 { network: None, key: [0u8; 20], }, - ), + ], ); assert_eq!( LpInstanceRelayer::::convert_origin( - location, + location.clone(), OriginKind::SovereignAccount, ) .unwrap_err(), diff --git a/runtime/development/src/lib.rs b/runtime/development/src/lib.rs index 53e6886b76..d1f241999c 100644 --- a/runtime/development/src/lib.rs +++ b/runtime/development/src/lib.rs @@ -2410,7 +2410,7 @@ impl_runtime_apis! { // Investment Runtime APIs impl runtime_common::apis::InvestmentsApi> for Runtime { fn investment_portfolio(account_id: AccountId) -> Vec<(TrancheCurrency, InvestmentPortfolio)> { - runtime_common::investment_portfolios::get_account_portfolio::(account_id) + runtime_common::investment_portfolios::get_account_portfolio::(account_id) } }