From 89abd2ad785b98669748dfdf2185d6d92bdcf229 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Wed, 14 Aug 2024 13:34:20 +0200 Subject: [PATCH 1/6] feat: domain routers migration --- Cargo.lock | 9 +- Cargo.toml | 96 ++-- runtime/altair/src/lib.rs | 4 +- runtime/altair/src/migrations.rs | 6 +- runtime/centrifuge/src/lib.rs | 4 +- runtime/centrifuge/src/migrations.rs | 6 +- runtime/common/Cargo.toml | 512 +++++++++--------- runtime/common/src/evm/mod.rs | 3 + .../src/migrations/liquidity_pools_gateway.rs | 294 +++++++--- runtime/development/src/lib.rs | 4 +- runtime/development/src/migrations.rs | 32 +- 11 files changed, 557 insertions(+), 413 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9bb0ef1336..06d4b2b2e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -121,7 +121,7 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "altair-runtime" -version = "0.14.0" +version = "0.14.2" dependencies = [ "axelar-gateway-precompile", "cfg-primitives", @@ -1376,7 +1376,7 @@ dependencies = [ [[package]] name = "centrifuge-chain" -version = "0.14.0" +version = "0.14.2" dependencies = [ "altair-runtime", "async-trait", @@ -1469,7 +1469,7 @@ dependencies = [ [[package]] name = "centrifuge-runtime" -version = "0.14.0" +version = "0.14.2" dependencies = [ "axelar-gateway-precompile", "cfg-primitives", @@ -3080,7 +3080,7 @@ dependencies = [ [[package]] name = "development-runtime" -version = "0.14.0" +version = "0.14.2" dependencies = [ "axelar-gateway-precompile", "cfg-primitives", @@ -11645,6 +11645,7 @@ dependencies = [ "frame-system", "hex", "hex-literal", + "liquidity-pools-gateway-routers", "log", "num_enum 0.5.11", "orml-asset-registry", diff --git a/Cargo.toml b/Cargo.toml index 42d8008e8e..188474908f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,49 +1,49 @@ [workspace] resolver = "2" members = [ - "node", - "libs/mocks", - "libs/primitives", - "libs/test-utils", - "libs/traits", - "libs/types", - "libs/utils", - "pallets/anchors", - "pallets/anchors-v2", - "pallets/bridge", - "pallets/block-rewards", - "pallets/collator-allowlist", - "pallets/ethereum-transaction", - "pallets/fees", - "pallets/foreign-investments", - "pallets/interest-accrual", - "pallets/investments", - "pallets/keystore", - "pallets/liquidity-pools", - "pallets/liquidity-pools-gateway", - "pallets/liquidity-pools-gateway/axelar-gateway-precompile", - "pallets/liquidity-pools-gateway/routers", - "pallets/liquidity-pools-gateway/queue", - "pallets/liquidity-rewards", - "pallets/loans", - "pallets/oracle-feed", - "pallets/oracle-collection", - "pallets/order-book", - "pallets/permissions", - "pallets/pool-fees", - "pallets/pool-system", - "pallets/pool-registry", - "pallets/restricted-tokens", - "pallets/restricted-xtokens", - "pallets/rewards", - "pallets/token-mux", - "pallets/transfer-allowlist", - "runtime/altair", - "runtime/centrifuge", - "runtime/development", - "runtime/common", - "runtime/integration-tests", - "runtime/integration-tests/procedural", + "node", + "libs/mocks", + "libs/primitives", + "libs/test-utils", + "libs/traits", + "libs/types", + "libs/utils", + "pallets/anchors", + "pallets/anchors-v2", + "pallets/bridge", + "pallets/block-rewards", + "pallets/collator-allowlist", + "pallets/ethereum-transaction", + "pallets/fees", + "pallets/foreign-investments", + "pallets/interest-accrual", + "pallets/investments", + "pallets/keystore", + "pallets/liquidity-pools", + "pallets/liquidity-pools-gateway", + "pallets/liquidity-pools-gateway/axelar-gateway-precompile", + "pallets/liquidity-pools-gateway/routers", + "pallets/liquidity-pools-gateway/queue", + "pallets/liquidity-rewards", + "pallets/loans", + "pallets/oracle-feed", + "pallets/oracle-collection", + "pallets/order-book", + "pallets/permissions", + "pallets/pool-fees", + "pallets/pool-system", + "pallets/pool-registry", + "pallets/restricted-tokens", + "pallets/restricted-xtokens", + "pallets/rewards", + "pallets/token-mux", + "pallets/transfer-allowlist", + "runtime/altair", + "runtime/centrifuge", + "runtime/development", + "runtime/common", + "runtime/integration-tests", + "runtime/integration-tests/procedural", ] [workspace.package] @@ -53,7 +53,7 @@ license = "LGPL-3.0" homepage = "https://centrifuge.io/" repository = "https://github.com/centrifuge/centrifuge-chain" documentation = "https://reference.centrifuge.io/centrifuge_chain/index.html" -version = "0.14.0" +version = "0.14.2" [workspace.dependencies] hex-literal = { version = "0.4.1" } @@ -175,7 +175,7 @@ frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", defau frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, features = [ - "tuples-96", + "tuples-96", ], branch = "release-polkadot-v1.7.2" } # Check when tuples-96 can be removed frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } @@ -287,14 +287,14 @@ pallet-remarks = { git = "https://github.com/foss3/runtime-pallet-library", bran # Moonbeam fork of polkadot-evm/frontier fp-rpc = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } fp-self-contained = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2", features = [ - "serde", + "serde", ] } pallet-base-fee = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } pallet-ethereum = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2", features = [ - "forbid-evm-reentrancy", + "forbid-evm-reentrancy", ] } pallet-evm = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2", features = [ - "forbid-evm-reentrancy", + "forbid-evm-reentrancy", ] } pallet-evm-chain-id = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } pallet-evm-precompile-blake2 = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } diff --git a/runtime/altair/src/lib.rs b/runtime/altair/src/lib.rs index fe0d5dd8f8..62d6ac27e2 100644 --- a/runtime/altair/src/lib.rs +++ b/runtime/altair/src/lib.rs @@ -164,7 +164,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("altair"), impl_name: create_runtime_str!("altair"), authoring_version: 1, - spec_version: 1401, + spec_version: 1402, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -2009,7 +2009,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - migrations::UpgradeAltair1401, + migrations::UpgradeAltair1402, >; // Frame Order in this block dictates the index of each one in the metadata diff --git a/runtime/altair/src/migrations.rs b/runtime/altair/src/migrations.rs index c405dda164..d1cef70c2a 100644 --- a/runtime/altair/src/migrations.rs +++ b/runtime/altair/src/migrations.rs @@ -14,12 +14,14 @@ use crate::Runtime; /// The migration set for Altair @ Kusama. /// It includes all the migrations that have to be applied on that chain. -pub type UpgradeAltair1401 = ( +pub type UpgradeAltair1402 = ( + // Remove deprecated DomainRouters entries + runtime_common::migrations::liquidity_pools_gateway::clear_deprecated_domain_router_entries::Migration, // Clear OutboundMessageNonceStore frame_support::migrations::VersionedMigration< 0, 1, - runtime_common::migrations::liquidity_pools_gateway::Migration, + runtime_common::migrations::liquidity_pools_gateway::clear_outbound_nonce::Migration, pallet_liquidity_pools_gateway::Pallet, ::DbWeight, >, diff --git a/runtime/centrifuge/src/lib.rs b/runtime/centrifuge/src/lib.rs index 0d97bad678..cf6b00b7b0 100644 --- a/runtime/centrifuge/src/lib.rs +++ b/runtime/centrifuge/src/lib.rs @@ -162,7 +162,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("centrifuge"), impl_name: create_runtime_str!("centrifuge"), authoring_version: 1, - spec_version: 1401, + spec_version: 1402, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -2023,7 +2023,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - migrations::UpgradeCentrifuge1401, + migrations::UpgradeCentrifuge1402, >; // Frame Order in this block dictates the index of each one in the metadata diff --git a/runtime/centrifuge/src/migrations.rs b/runtime/centrifuge/src/migrations.rs index d8a378e7e4..3bd55bb315 100644 --- a/runtime/centrifuge/src/migrations.rs +++ b/runtime/centrifuge/src/migrations.rs @@ -14,12 +14,14 @@ use crate::Runtime; /// The migration set for Centrifuge @ Polkadot. /// It includes all the migrations that have to be applied on that chain. -pub type UpgradeCentrifuge1401 = ( +pub type UpgradeCentrifuge1402 = ( + // Remove deprecated DomainRouters entries + runtime_common::migrations::liquidity_pools_gateway::clear_deprecated_domain_router_entries::Migration, // Clear OutboundMessageNonceStore frame_support::migrations::VersionedMigration< 0, 1, - runtime_common::migrations::liquidity_pools_gateway::Migration, + runtime_common::migrations::liquidity_pools_gateway::clear_outbound_nonce::Migration, pallet_liquidity_pools_gateway::Pallet, ::DbWeight, >, diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 823acb7caa..6c7fe27622 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -90,6 +90,7 @@ pallet-investments = { workspace = true } pallet-keystore = { workspace = true } pallet-liquidity-pools = { workspace = true } pallet-liquidity-pools-gateway = { workspace = true } +liquidity-pools-gateway-routers = { workspace = true } pallet-liquidity-rewards = { workspace = true } pallet-loans = { workspace = true } pallet-membership = { workspace = true } @@ -131,264 +132,267 @@ cfg-mocks = { workspace = true, default-features = true } [features] default = ["std"] std = [ - "parity-scale-codec/std", - "log/std", - # Substrate related - "frame-support/std", - "frame-system/std", - "frame-benchmarking?/std", - "orml-traits/std", - "orml-tokens/std", - "pallet-anchors/std", - "pallet-authorship/std", - "pallet-balances/std", - "pallet-base-fee/std", - "pallet-ethereum/std", - "pallet-evm-chain-id/std", - "pallet-evm-precompile-balances-erc20/std", - "pallet-evm-precompile-blake2/std", - "pallet-evm-precompile-bn128/std", - "pallet-evm-precompile-dispatch/std", - "pallet-evm-precompile-modexp/std", - "pallet-evm-precompile-sha3fips/std", - "pallet-evm-precompile-simple/std", - "precompile-utils/std", - "polkadot-parachain-primitives/std", - "cumulus-primitives-core/std", - "scale-info/std", - "serde/std", - "sp-api/std", - "sp-arithmetic/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", - "staging-xcm-executor/std", - "xcm-primitives/std", - "staging-xcm-builder/std", - "staging-xcm/std", - # Locals - "cfg-primitives/std", - "cfg-traits/std", - "cfg-types/std", - "cfg-utils/std", - # Pallet exporting list - "axelar-gateway-precompile/std", - "chainbridge/std", - "cumulus-pallet-aura-ext/std", - "cumulus-pallet-parachain-system/std", - "cumulus-pallet-xcm/std", - "cumulus-pallet-xcmp-queue/std", - "orml-asset-registry/std", - "orml-tokens/std", - "orml-xcm/std", - "orml-xtokens/std", - "pallet-anchors/std", - "pallet-aura/std", - "pallet-authorship/std", - "pallet-balances/std", - "pallet-base-fee/std", - "pallet-block-rewards/std", - "pallet-bridge/std", - "pallet-collator-allowlist/std", - "pallet-collator-selection/std", - "pallet-collective/std", - "pallet-democracy/std", - "pallet-elections-phragmen/std", - "pallet-ethereum/std", - "pallet-ethereum-transaction/std", - "pallet-evm/std", - "pallet-evm-chain-id/std", - "pallet-fees/std", - "pallet-foreign-investments/std", - "pallet-identity/std", - "pallet-interest-accrual/std", - "pallet-investments/std", - "pallet-keystore/std", - "pallet-liquidity-pools/std", - "pallet-liquidity-pools-gateway/std", - "pallet-liquidity-rewards/std", - "pallet-loans/std", - "pallet-membership/std", - "pallet-multisig/std", - "pallet-oracle-collection/std", - "pallet-oracle-feed/std", - "pallet-order-book/std", - "pallet-permissions/std", - "pallet-pool-fees/std", - "pallet-pool-registry/std", - "pallet-pool-system/std", - "pallet-preimage/std", - "pallet-proxy/std", - "pallet-restricted-tokens/std", - "pallet-restricted-xtokens/std", - "pallet-rewards/std", - "pallet-remarks/std", - "pallet-scheduler/std", - "pallet-session/std", - "pallet-sudo/std", - "pallet-timestamp/std", - "pallet-transaction-payment/std", - "pallet-transfer-allowlist/std", - "pallet-treasury/std", - "pallet-uniques/std", - "pallet-utility/std", - "pallet-vesting/std", - "pallet-xcm/std", - "pallet-xcm-transactor/std", - "pallet-message-queue/std", - "staging-parachain-info/std", + "parity-scale-codec/std", + "log/std", + # Substrate related + "frame-support/std", + "frame-system/std", + "frame-benchmarking?/std", + "orml-traits/std", + "orml-tokens/std", + "pallet-anchors/std", + "pallet-authorship/std", + "pallet-balances/std", + "pallet-base-fee/std", + "pallet-ethereum/std", + "pallet-evm-chain-id/std", + "pallet-evm-precompile-balances-erc20/std", + "pallet-evm-precompile-blake2/std", + "pallet-evm-precompile-bn128/std", + "pallet-evm-precompile-dispatch/std", + "pallet-evm-precompile-modexp/std", + "pallet-evm-precompile-sha3fips/std", + "pallet-evm-precompile-simple/std", + "precompile-utils/std", + "polkadot-parachain-primitives/std", + "cumulus-primitives-core/std", + "scale-info/std", + "serde/std", + "sp-api/std", + "sp-arithmetic/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "staging-xcm-executor/std", + "xcm-primitives/std", + "staging-xcm-builder/std", + "staging-xcm/std", + # Locals + "cfg-primitives/std", + "cfg-traits/std", + "cfg-types/std", + "cfg-utils/std", + # Pallet exporting list + "axelar-gateway-precompile/std", + "chainbridge/std", + "cumulus-pallet-aura-ext/std", + "cumulus-pallet-parachain-system/std", + "cumulus-pallet-xcm/std", + "cumulus-pallet-xcmp-queue/std", + "orml-asset-registry/std", + "orml-tokens/std", + "orml-xcm/std", + "orml-xtokens/std", + "pallet-anchors/std", + "pallet-aura/std", + "pallet-authorship/std", + "pallet-balances/std", + "pallet-base-fee/std", + "pallet-block-rewards/std", + "pallet-bridge/std", + "pallet-collator-allowlist/std", + "pallet-collator-selection/std", + "pallet-collective/std", + "pallet-democracy/std", + "pallet-elections-phragmen/std", + "pallet-ethereum/std", + "pallet-ethereum-transaction/std", + "pallet-evm/std", + "pallet-evm-chain-id/std", + "pallet-fees/std", + "pallet-foreign-investments/std", + "pallet-identity/std", + "pallet-interest-accrual/std", + "pallet-investments/std", + "pallet-keystore/std", + "pallet-liquidity-pools/std", + "pallet-liquidity-pools-gateway/std", + "liquidity-pools-gateway-routers/std", + "pallet-liquidity-rewards/std", + "pallet-loans/std", + "pallet-membership/std", + "pallet-multisig/std", + "pallet-oracle-collection/std", + "pallet-oracle-feed/std", + "pallet-order-book/std", + "pallet-permissions/std", + "pallet-pool-fees/std", + "pallet-pool-registry/std", + "pallet-pool-system/std", + "pallet-preimage/std", + "pallet-proxy/std", + "pallet-restricted-tokens/std", + "pallet-restricted-xtokens/std", + "pallet-rewards/std", + "pallet-remarks/std", + "pallet-scheduler/std", + "pallet-session/std", + "pallet-sudo/std", + "pallet-timestamp/std", + "pallet-transaction-payment/std", + "pallet-transfer-allowlist/std", + "pallet-treasury/std", + "pallet-uniques/std", + "pallet-utility/std", + "pallet-vesting/std", + "pallet-xcm/std", + "pallet-xcm-transactor/std", + "pallet-message-queue/std", + "staging-parachain-info/std", ] runtime-benchmarks = [ - # Substrate related - "sp-runtime/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "frame-benchmarking/runtime-benchmarks", # Optional enabled - "staging-xcm-executor/runtime-benchmarks", - "xcm-primitives/runtime-benchmarks", - "staging-xcm-builder/runtime-benchmarks", - "polkadot-parachain-primitives/runtime-benchmarks", - "cumulus-primitives-core/runtime-benchmarks", - # Locals - "cfg-primitives/runtime-benchmarks", - "cfg-traits/runtime-benchmarks", - "cfg-types/runtime-benchmarks", - "cfg-utils/runtime-benchmarks", - "cfg-mocks/runtime-benchmarks", - # Pallet exporting list - "axelar-gateway-precompile/runtime-benchmarks", - "chainbridge/runtime-benchmarks", - "cumulus-pallet-parachain-system/runtime-benchmarks", - "cumulus-pallet-xcmp-queue/runtime-benchmarks", - "orml-asset-registry/runtime-benchmarks", - "orml-tokens/runtime-benchmarks", - "orml-xtokens/runtime-benchmarks", - "pallet-anchors/runtime-benchmarks", - "pallet-balances/runtime-benchmarks", - "pallet-block-rewards/runtime-benchmarks", - "pallet-bridge/runtime-benchmarks", - "pallet-collator-allowlist/runtime-benchmarks", - "pallet-collator-selection/runtime-benchmarks", - "pallet-collective/runtime-benchmarks", - "pallet-democracy/runtime-benchmarks", - "pallet-elections-phragmen/runtime-benchmarks", - "pallet-ethereum/runtime-benchmarks", - "pallet-ethereum-transaction/runtime-benchmarks", - "pallet-evm/runtime-benchmarks", - "pallet-fees/runtime-benchmarks", - "pallet-foreign-investments/runtime-benchmarks", - "pallet-identity/runtime-benchmarks", - "pallet-interest-accrual/runtime-benchmarks", - "pallet-investments/runtime-benchmarks", - "pallet-keystore/runtime-benchmarks", - "pallet-liquidity-pools/runtime-benchmarks", - "pallet-liquidity-pools-gateway/runtime-benchmarks", - "pallet-liquidity-rewards/runtime-benchmarks", - "pallet-loans/runtime-benchmarks", - "pallet-membership/runtime-benchmarks", - "pallet-multisig/runtime-benchmarks", - "pallet-oracle-collection/runtime-benchmarks", - "pallet-oracle-feed/runtime-benchmarks", - "pallet-order-book/runtime-benchmarks", - "pallet-permissions/runtime-benchmarks", - "pallet-pool-fees/runtime-benchmarks", - "pallet-pool-registry/runtime-benchmarks", - "pallet-pool-system/runtime-benchmarks", - "pallet-preimage/runtime-benchmarks", - "pallet-proxy/runtime-benchmarks", - "pallet-restricted-tokens/runtime-benchmarks", - "pallet-restricted-xtokens/runtime-benchmarks", - "pallet-rewards/runtime-benchmarks", - "pallet-remarks/runtime-benchmarks", - "pallet-scheduler/runtime-benchmarks", - "pallet-sudo/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", - "pallet-transfer-allowlist/runtime-benchmarks", - "pallet-treasury/runtime-benchmarks", - "pallet-uniques/runtime-benchmarks", - "pallet-utility/runtime-benchmarks", - "pallet-vesting/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", - "pallet-xcm-transactor/runtime-benchmarks", - "pallet-message-queue/runtime-benchmarks", + # Substrate related + "sp-runtime/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", # Optional enabled + "staging-xcm-executor/runtime-benchmarks", + "xcm-primitives/runtime-benchmarks", + "staging-xcm-builder/runtime-benchmarks", + "polkadot-parachain-primitives/runtime-benchmarks", + "cumulus-primitives-core/runtime-benchmarks", + # Locals + "cfg-primitives/runtime-benchmarks", + "cfg-traits/runtime-benchmarks", + "cfg-types/runtime-benchmarks", + "cfg-utils/runtime-benchmarks", + "cfg-mocks/runtime-benchmarks", + # Pallet exporting list + "axelar-gateway-precompile/runtime-benchmarks", + "chainbridge/runtime-benchmarks", + "cumulus-pallet-parachain-system/runtime-benchmarks", + "cumulus-pallet-xcmp-queue/runtime-benchmarks", + "orml-asset-registry/runtime-benchmarks", + "orml-tokens/runtime-benchmarks", + "orml-xtokens/runtime-benchmarks", + "pallet-anchors/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-block-rewards/runtime-benchmarks", + "pallet-bridge/runtime-benchmarks", + "pallet-collator-allowlist/runtime-benchmarks", + "pallet-collator-selection/runtime-benchmarks", + "pallet-collective/runtime-benchmarks", + "pallet-democracy/runtime-benchmarks", + "pallet-elections-phragmen/runtime-benchmarks", + "pallet-ethereum/runtime-benchmarks", + "pallet-ethereum-transaction/runtime-benchmarks", + "pallet-evm/runtime-benchmarks", + "pallet-fees/runtime-benchmarks", + "pallet-foreign-investments/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", + "pallet-interest-accrual/runtime-benchmarks", + "pallet-investments/runtime-benchmarks", + "pallet-keystore/runtime-benchmarks", + "pallet-liquidity-pools/runtime-benchmarks", + "pallet-liquidity-pools-gateway/runtime-benchmarks", + "liquidity-pools-gateway-routers/runtime-benchmarks", + "pallet-liquidity-rewards/runtime-benchmarks", + "pallet-loans/runtime-benchmarks", + "pallet-membership/runtime-benchmarks", + "pallet-multisig/runtime-benchmarks", + "pallet-oracle-collection/runtime-benchmarks", + "pallet-oracle-feed/runtime-benchmarks", + "pallet-order-book/runtime-benchmarks", + "pallet-permissions/runtime-benchmarks", + "pallet-pool-fees/runtime-benchmarks", + "pallet-pool-registry/runtime-benchmarks", + "pallet-pool-system/runtime-benchmarks", + "pallet-preimage/runtime-benchmarks", + "pallet-proxy/runtime-benchmarks", + "pallet-restricted-tokens/runtime-benchmarks", + "pallet-restricted-xtokens/runtime-benchmarks", + "pallet-rewards/runtime-benchmarks", + "pallet-remarks/runtime-benchmarks", + "pallet-scheduler/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "pallet-transfer-allowlist/runtime-benchmarks", + "pallet-treasury/runtime-benchmarks", + "pallet-uniques/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", + "pallet-vesting/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "pallet-xcm-transactor/runtime-benchmarks", + "pallet-message-queue/runtime-benchmarks", ] try-runtime = [ - "sp-runtime/try-runtime", - "cfg-primitives/try-runtime", - "cfg-traits/try-runtime", - "cfg-types/try-runtime", - "cfg-utils/try-runtime", - "cfg-mocks/try-runtime", - "frame-support/try-runtime", - "frame-system/try-runtime", - # Pallet exporting list - "axelar-gateway-precompile/try-runtime", - "chainbridge/try-runtime", - "cumulus-pallet-aura-ext/try-runtime", - "cumulus-pallet-parachain-system/try-runtime", - "cumulus-pallet-xcm/try-runtime", - "cumulus-pallet-xcmp-queue/try-runtime", - "orml-asset-registry/try-runtime", - "orml-tokens/try-runtime", - "orml-xcm/try-runtime", - "orml-xtokens/try-runtime", - "pallet-anchors/try-runtime", - "pallet-aura/try-runtime", - "pallet-authorship/try-runtime", - "pallet-balances/try-runtime", - "pallet-base-fee/try-runtime", - "pallet-block-rewards/try-runtime", - "pallet-bridge/try-runtime", - "pallet-collator-allowlist/try-runtime", - "pallet-collator-selection/try-runtime", - "pallet-collective/try-runtime", - "pallet-democracy/try-runtime", - "pallet-elections-phragmen/try-runtime", - "pallet-ethereum/try-runtime", - "pallet-ethereum-transaction/try-runtime", - "pallet-evm/try-runtime", - "pallet-evm-chain-id/try-runtime", - "pallet-fees/try-runtime", - "pallet-foreign-investments/try-runtime", - "pallet-identity/try-runtime", - "pallet-interest-accrual/try-runtime", - "pallet-investments/try-runtime", - "pallet-keystore/try-runtime", - "pallet-liquidity-pools/try-runtime", - "pallet-liquidity-pools-gateway/try-runtime", - "pallet-liquidity-rewards/try-runtime", - "pallet-loans/try-runtime", - "pallet-membership/try-runtime", - "pallet-multisig/try-runtime", - "pallet-oracle-collection/try-runtime", - "pallet-oracle-feed/try-runtime", - "pallet-order-book/try-runtime", - "pallet-permissions/try-runtime", - "pallet-pool-fees/try-runtime", - "pallet-pool-registry/try-runtime", - "pallet-pool-system/try-runtime", - "pallet-preimage/try-runtime", - "pallet-proxy/try-runtime", - "pallet-restricted-tokens/try-runtime", - "pallet-restricted-xtokens/try-runtime", - "pallet-rewards/try-runtime", - "pallet-remarks/try-runtime", - "pallet-scheduler/try-runtime", - "pallet-session/try-runtime", - "pallet-sudo/try-runtime", - "pallet-timestamp/try-runtime", - "pallet-transaction-payment/try-runtime", - "pallet-transfer-allowlist/try-runtime", - "pallet-treasury/try-runtime", - "pallet-uniques/try-runtime", - "pallet-utility/try-runtime", - "pallet-vesting/try-runtime", - "pallet-xcm/try-runtime", - "pallet-xcm-transactor/try-runtime", - "pallet-message-queue/try-runtime", - "staging-parachain-info/try-runtime", + "sp-runtime/try-runtime", + "cfg-primitives/try-runtime", + "cfg-traits/try-runtime", + "cfg-types/try-runtime", + "cfg-utils/try-runtime", + "cfg-mocks/try-runtime", + "frame-support/try-runtime", + "frame-system/try-runtime", + # Pallet exporting list + "axelar-gateway-precompile/try-runtime", + "chainbridge/try-runtime", + "cumulus-pallet-aura-ext/try-runtime", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", + "orml-asset-registry/try-runtime", + "orml-tokens/try-runtime", + "orml-xcm/try-runtime", + "orml-xtokens/try-runtime", + "pallet-anchors/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", + "pallet-balances/try-runtime", + "pallet-base-fee/try-runtime", + "pallet-block-rewards/try-runtime", + "pallet-bridge/try-runtime", + "pallet-collator-allowlist/try-runtime", + "pallet-collator-selection/try-runtime", + "pallet-collective/try-runtime", + "pallet-democracy/try-runtime", + "pallet-elections-phragmen/try-runtime", + "pallet-ethereum/try-runtime", + "pallet-ethereum-transaction/try-runtime", + "pallet-evm/try-runtime", + "pallet-evm-chain-id/try-runtime", + "pallet-fees/try-runtime", + "pallet-foreign-investments/try-runtime", + "pallet-identity/try-runtime", + "pallet-interest-accrual/try-runtime", + "pallet-investments/try-runtime", + "pallet-keystore/try-runtime", + "pallet-liquidity-pools/try-runtime", + "pallet-liquidity-pools-gateway/try-runtime", + "liquidity-pools-gateway-routers/try-runtime", + "pallet-liquidity-rewards/try-runtime", + "pallet-loans/try-runtime", + "pallet-membership/try-runtime", + "pallet-multisig/try-runtime", + "pallet-oracle-collection/try-runtime", + "pallet-oracle-feed/try-runtime", + "pallet-order-book/try-runtime", + "pallet-permissions/try-runtime", + "pallet-pool-fees/try-runtime", + "pallet-pool-registry/try-runtime", + "pallet-pool-system/try-runtime", + "pallet-preimage/try-runtime", + "pallet-proxy/try-runtime", + "pallet-restricted-tokens/try-runtime", + "pallet-restricted-xtokens/try-runtime", + "pallet-rewards/try-runtime", + "pallet-remarks/try-runtime", + "pallet-scheduler/try-runtime", + "pallet-session/try-runtime", + "pallet-sudo/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-transaction-payment/try-runtime", + "pallet-transfer-allowlist/try-runtime", + "pallet-treasury/try-runtime", + "pallet-uniques/try-runtime", + "pallet-utility/try-runtime", + "pallet-vesting/try-runtime", + "pallet-xcm/try-runtime", + "pallet-xcm-transactor/try-runtime", + "pallet-message-queue/try-runtime", + "staging-parachain-info/try-runtime", ] on-chain-release-build = [ - "sp-api/disable-logging", + "sp-api/disable-logging", ] diff --git a/runtime/common/src/evm/mod.rs b/runtime/common/src/evm/mod.rs index 477b66371c..b95b59e9db 100644 --- a/runtime/common/src/evm/mod.rs +++ b/runtime/common/src/evm/mod.rs @@ -181,9 +181,12 @@ mod tests { } pub mod utils { + #[cfg(feature = "std")] use sp_core::H160; + #[cfg(feature = "std")] use sp_std::collections::btree_map::BTreeMap; + #[cfg(feature = "std")] use crate::evm::precompile::H160Addresses; #[cfg(feature = "std")] diff --git a/runtime/common/src/migrations/liquidity_pools_gateway.rs b/runtime/common/src/migrations/liquidity_pools_gateway.rs index 6677c2fc3d..6c11647590 100644 --- a/runtime/common/src/migrations/liquidity_pools_gateway.rs +++ b/runtime/common/src/migrations/liquidity_pools_gateway.rs @@ -1,22 +1,37 @@ +// Copyright 2024 Centrifuge Foundation (centrifuge.io). +// +// This file is part of the Centrifuge chain project. +// Centrifuge is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version (see http://www.gnu.org/licenses). +// Centrifuge is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + use cfg_types::domain_address::Domain; use frame_support::{ - pallet_prelude::ValueQuery, + pallet_prelude::{Decode, Encode, ValueQuery}, storage_alias, traits::{Get, OnRuntimeUpgrade}, + weights::Weight, Blake2_128Concat, }; -use pallet_order_book::weights::Weight; use sp_runtime::DispatchError; +use sp_std::marker::PhantomData; #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; -#[storage_alias] -pub type OutboundMessageNonceStore = - StorageValue, u64, ValueQuery>; +pub mod clear_outbound_nonce { + use super::*; + + #[storage_alias] + pub type OutboundMessageNonceStore = + StorageValue, u64, ValueQuery>; -#[storage_alias] -pub type OutboundMessageQueue = - StorageMap< + #[storage_alias] + pub type OutboundMessageQueue = StorageMap< pallet_liquidity_pools_gateway::Pallet, Blake2_128Concat, u64, @@ -27,9 +42,8 @@ pub type OutboundMessageQueue; -#[storage_alias] -pub type FailedOutboundMessages = - StorageMap< + #[storage_alias] + pub type FailedOutboundMessages = StorageMap< pallet_liquidity_pools_gateway::Pallet, Blake2_128Concat, u64, @@ -41,77 +55,223 @@ pub type FailedOutboundMessages; -const LOG_PREFIX: &str = "LiquidityPoolsGatewayV1"; + const LOG_PREFIX: &str = "LPGatewayClearNonce"; + + pub struct Migration(PhantomData); -pub struct Migration(sp_std::marker::PhantomData); + impl OnRuntimeUpgrade for Migration + where + T: pallet_liquidity_pools_gateway::Config + frame_system::Config, + { + fn on_runtime_upgrade() -> Weight { + let mut weight = Weight::zero(); + OutboundMessageNonceStore::::kill(); -impl OnRuntimeUpgrade for Migration -where - T: pallet_liquidity_pools_gateway::Config + frame_system::Config, -{ - fn on_runtime_upgrade() -> Weight { - let mut weight = Weight::zero(); - OutboundMessageNonceStore::::kill(); + for (nonce, entry) in OutboundMessageQueue::::iter() { + log::warn!("{LOG_PREFIX}: Found outbound message:\nnonce:{nonce}\nentry:{entry:?}"); + weight.saturating_accrue(T::DbWeight::get().reads(1)); + } - for (nonce, entry) in OutboundMessageQueue::::iter() { - log::warn!("{LOG_PREFIX}: Found outbound message:\nnonce:{nonce}\nentry:{entry:?}"); - weight.saturating_accrue(T::DbWeight::get().reads(1)); + for (nonce, entry) in FailedOutboundMessages::::iter() { + log::warn!( + "{LOG_PREFIX}: Found failed outbound message:\nnonce:{nonce}\nentry:{entry:?}" + ); + weight.saturating_accrue(T::DbWeight::get().reads(1)); + } + + log::info!("{LOG_PREFIX}: Migration done!"); + + weight } - for (nonce, entry) in FailedOutboundMessages::::iter() { - log::warn!( - "{LOG_PREFIX}: Found failed outbound message:\nnonce:{nonce}\nentry:{entry:?}" + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + // Extra check to confirm that the storage alias is correct. + assert_eq!( + OutboundMessageQueue::::iter_keys().count(), + 0, + "{LOG_PREFIX}: OutboundMessageQueue should be empty!" ); - weight.saturating_accrue(T::DbWeight::get().reads(1)); + + assert_eq!( + FailedOutboundMessages::::iter_keys().count(), + 0, + "{LOG_PREFIX}: FailedOutboundMessages should be empty!" + ); + + log::info!("{LOG_PREFIX}: Pre checks done!"); + + Ok(Vec::new()) } - log::info!("{LOG_PREFIX}: Migration done!"); + #[cfg(feature = "try-runtime")] + fn post_upgrade(_: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + assert_eq!( + OutboundMessageNonceStore::::get(), + 0, + "{LOG_PREFIX}: OutboundMessageNonceStore should be 0!" + ); - weight + assert_eq!( + OutboundMessageQueue::::iter_keys().count(), + 0, + "{LOG_PREFIX}: OutboundMessageQueue should be empty!" + ); + + assert_eq!( + FailedOutboundMessages::::iter_keys().count(), + 0, + "{LOG_PREFIX}: FailedOutboundMessages should be empty!" + ); + + log::info!("{LOG_PREFIX}: Post checks done!"); + + Ok(()) + } } +} + +pub mod clear_deprecated_domain_router_entries { + use frame_system::pallet_prelude::OriginFor; + use sp_arithmetic::traits::SaturatedConversion; + + use super::*; + pub struct Migration(PhantomData); + + const LOG_PREFIX: &str = "LPGatewayClearDomainRouters"; + + impl OnRuntimeUpgrade for Migration + where + T: pallet_liquidity_pools_gateway::Config + + pallet_xcm_transactor::Config + + pallet_ethereum_transaction::Config + + pallet_evm::Config + + frame_system::Config, + T::AccountId: AsRef<[u8; 32]>, + OriginFor: + From + Into>>, + v0::DomainRouter: sp_std::fmt::Debug, + ::Router: + From>, + { + fn on_runtime_upgrade() -> Weight { + let items = v0::DomainRouters::::iter_keys().count().saturated_into(); - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { - // Extra check to confirm that the storage alias is correct. - assert_eq!( - OutboundMessageQueue::::iter_keys().count(), - 0, - "{LOG_PREFIX}: OutboundMessageQueue should be empty!" - ); + pallet_liquidity_pools_gateway::DomainRouters::::translate_values::< + v0::DomainRouter, + _, + >(|old| match old { + v0::DomainRouter::AxelarEVM(router) => Some( + liquidity_pools_gateway_routers::DomainRouter::::AxelarEVM(router).into(), + ), + // Remove other entries + router => { + log::info!("{LOG_PREFIX}: Removing entry {router:?}!"); + None + } + }); - assert_eq!( - FailedOutboundMessages::::iter_keys().count(), - 0, - "{LOG_PREFIX}: FailedOutboundMessages should be empty!" - ); + log::info!("{LOG_PREFIX}: Migration done with {items:?} items in total!"); - log::info!("{LOG_PREFIX}: Pre checks done!"); + T::DbWeight::get().reads_writes(items, items) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + let count_total = v0::DomainRouters::::iter_keys().count(); + let count_axelar_evm_router: u64 = v0::DomainRouters::::iter_values() + .filter(|v| matches!(v, v0::DomainRouter::AxelarEVM(_))) + .count() + .saturated_into(); + log::info!("{LOG_PREFIX}: Found {count_axelar_evm_router:?} values of total {count_total:?} to migrate!"); + log::info!("{LOG_PREFIX}: Pre checks done!"); + Ok(count_axelar_evm_router.encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(pre_state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + let pre_count: u64 = Decode::decode(&mut pre_state.as_slice()) + .expect("pre_upgrade provides a valid state; qed"); + let post_count: u64 = pallet_liquidity_pools_gateway::DomainRouters::::iter_keys() + .count() + .saturated_into(); + assert_eq!( + pre_count, post_count, + "{LOG_PREFIX}: Mismatching number of domain routers after migration!" + ); + + log::info!("{LOG_PREFIX}: Post checks done!"); - Ok(Vec::new()) + Ok(()) + } } - #[cfg(feature = "try-runtime")] - fn post_upgrade(_: Vec) -> Result<(), sp_runtime::TryRuntimeError> { - assert_eq!( - OutboundMessageNonceStore::::get(), - 0, - "{LOG_PREFIX}: OutboundMessageNonceStore should be 0!" - ); - - assert_eq!( - OutboundMessageQueue::::iter_keys().count(), - 0, - "{LOG_PREFIX}: OutboundMessageQueue should be empty!" - ); - - assert_eq!( - FailedOutboundMessages::::iter_keys().count(), - 0, - "{LOG_PREFIX}: FailedOutboundMessages should be empty!" - ); - - log::info!("{LOG_PREFIX}: Post checks done!"); - - Ok(()) + mod v0 { + use frame_support::{ + pallet_prelude::{Decode, Encode, MaxEncodedLen, OptionQuery, TypeInfo}, + traits::ConstU32, + BoundedVec, + }; + use liquidity_pools_gateway_routers::AxelarEVMRouter; + use sp_core::H160; + use staging_xcm::VersionedLocation; + + use super::*; + + pub const MAX_AXELAR_EVM_CHAIN_SIZE: u32 = 16; + + #[storage_alias] + pub type DomainRouters = StorageMap< + pallet_liquidity_pools_gateway::Pallet, + Blake2_128Concat, + Domain, + DomainRouter, + OptionQuery, + >; + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub enum DomainRouter + where + T: pallet_xcm_transactor::Config + + pallet_ethereum_transaction::Config + + pallet_evm::Config, + T::AccountId: AsRef<[u8; 32]>, + OriginFor: + From + Into>>, + { + EthereumXCM(EthereumXCMRouter), + AxelarEVM(AxelarEVMRouter), + AxelarXCM(AxelarXCMRouter), + } + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub struct AxelarXCMRouter { + pub router: XCMRouter, + pub axelar_target_chain: BoundedVec>, + pub axelar_target_contract: H160, + } + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub struct EthereumXCMRouter { + pub router: XCMRouter, + } + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub struct XCMRouter { + pub xcm_domain: XcmDomain, + } + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub struct XcmDomain { + pub location: sp_std::boxed::Box, + pub ethereum_xcm_transact_call_index: + BoundedVec>, + pub contract_address: H160, + pub max_gas_limit: u64, + pub transact_required_weight_at_most: Weight, + pub overall_weight: Weight, + pub fee_currency: CurrencyId, + pub fee_amount: u128, + } } } diff --git a/runtime/development/src/lib.rs b/runtime/development/src/lib.rs index 67bf57c52c..af7272944d 100644 --- a/runtime/development/src/lib.rs +++ b/runtime/development/src/lib.rs @@ -171,7 +171,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("centrifuge-devel"), impl_name: create_runtime_str!("centrifuge-devel"), authoring_version: 1, - spec_version: 1401, + spec_version: 1402, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -2114,7 +2114,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - crate::migrations::UpgradeDevelopment1401, + crate::migrations::UpgradeDevelopment1402, >; // Frame Order in this block dictates the index of each one in the metadata diff --git a/runtime/development/src/migrations.rs b/runtime/development/src/migrations.rs index 257c6e8915..ab9d396ea9 100644 --- a/runtime/development/src/migrations.rs +++ b/runtime/development/src/migrations.rs @@ -12,33 +12,5 @@ use crate::Runtime; -pub type UpgradeDevelopment1401 = ( - // Clear OutboundMessageNonceStore - frame_support::migrations::VersionedMigration< - 0, - 1, - runtime_common::migrations::liquidity_pools_gateway::Migration, - pallet_liquidity_pools_gateway::Pallet, - ::DbWeight, - >, - // Remove undecodable ForeignInvestmentInfo v0 entries - runtime_common::migrations::foreign_investments_v2::Migration, - // Bump to v1 - runtime_common::migrations::increase_storage_version::Migration< - pallet_foreign_investments::Pallet, - 1, - 2, - >, - // Migrate TrancheInvestor permission role and storage version from v0 to v1 - frame_support::migrations::VersionedMigration< - 0, - 1, - runtime_common::migrations::permissions_v1::Migration< - Runtime, - crate::MinDelay, - crate::MaxTranches, - >, - pallet_permissions::Pallet, - ::DbWeight, - >, -); +pub type UpgradeDevelopment1402 = + (runtime_common::migrations::liquidity_pools_gateway::clear_deprecated_domain_router_entries::Migration,); From 25ebf613303a57552a53c353120782edfd68a716 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Wed, 14 Aug 2024 13:41:53 +0200 Subject: [PATCH 2/6] taplo: fmt --- Cargo.toml | 94 +++---- runtime/common/Cargo.toml | 516 +++++++++++++++++++------------------- 2 files changed, 305 insertions(+), 305 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 188474908f..ae2be64715 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,49 +1,49 @@ [workspace] resolver = "2" members = [ - "node", - "libs/mocks", - "libs/primitives", - "libs/test-utils", - "libs/traits", - "libs/types", - "libs/utils", - "pallets/anchors", - "pallets/anchors-v2", - "pallets/bridge", - "pallets/block-rewards", - "pallets/collator-allowlist", - "pallets/ethereum-transaction", - "pallets/fees", - "pallets/foreign-investments", - "pallets/interest-accrual", - "pallets/investments", - "pallets/keystore", - "pallets/liquidity-pools", - "pallets/liquidity-pools-gateway", - "pallets/liquidity-pools-gateway/axelar-gateway-precompile", - "pallets/liquidity-pools-gateway/routers", - "pallets/liquidity-pools-gateway/queue", - "pallets/liquidity-rewards", - "pallets/loans", - "pallets/oracle-feed", - "pallets/oracle-collection", - "pallets/order-book", - "pallets/permissions", - "pallets/pool-fees", - "pallets/pool-system", - "pallets/pool-registry", - "pallets/restricted-tokens", - "pallets/restricted-xtokens", - "pallets/rewards", - "pallets/token-mux", - "pallets/transfer-allowlist", - "runtime/altair", - "runtime/centrifuge", - "runtime/development", - "runtime/common", - "runtime/integration-tests", - "runtime/integration-tests/procedural", + "node", + "libs/mocks", + "libs/primitives", + "libs/test-utils", + "libs/traits", + "libs/types", + "libs/utils", + "pallets/anchors", + "pallets/anchors-v2", + "pallets/bridge", + "pallets/block-rewards", + "pallets/collator-allowlist", + "pallets/ethereum-transaction", + "pallets/fees", + "pallets/foreign-investments", + "pallets/interest-accrual", + "pallets/investments", + "pallets/keystore", + "pallets/liquidity-pools", + "pallets/liquidity-pools-gateway", + "pallets/liquidity-pools-gateway/axelar-gateway-precompile", + "pallets/liquidity-pools-gateway/routers", + "pallets/liquidity-pools-gateway/queue", + "pallets/liquidity-rewards", + "pallets/loans", + "pallets/oracle-feed", + "pallets/oracle-collection", + "pallets/order-book", + "pallets/permissions", + "pallets/pool-fees", + "pallets/pool-system", + "pallets/pool-registry", + "pallets/restricted-tokens", + "pallets/restricted-xtokens", + "pallets/rewards", + "pallets/token-mux", + "pallets/transfer-allowlist", + "runtime/altair", + "runtime/centrifuge", + "runtime/development", + "runtime/common", + "runtime/integration-tests", + "runtime/integration-tests/procedural", ] [workspace.package] @@ -175,7 +175,7 @@ frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", defau frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, features = [ - "tuples-96", + "tuples-96", ], branch = "release-polkadot-v1.7.2" } # Check when tuples-96 can be removed frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } @@ -287,14 +287,14 @@ pallet-remarks = { git = "https://github.com/foss3/runtime-pallet-library", bran # Moonbeam fork of polkadot-evm/frontier fp-rpc = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } fp-self-contained = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2", features = [ - "serde", + "serde", ] } pallet-base-fee = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } pallet-ethereum = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2", features = [ - "forbid-evm-reentrancy", + "forbid-evm-reentrancy", ] } pallet-evm = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2", features = [ - "forbid-evm-reentrancy", + "forbid-evm-reentrancy", ] } pallet-evm-chain-id = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } pallet-evm-precompile-blake2 = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 6c7fe27622..b4b4cdad74 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -62,6 +62,7 @@ cumulus-pallet-aura-ext = { workspace = true } cumulus-pallet-parachain-system = { workspace = true } cumulus-pallet-xcm = { workspace = true } cumulus-pallet-xcmp-queue = { workspace = true } +liquidity-pools-gateway-routers = { workspace = true } orml-asset-registry = { workspace = true } orml-tokens = { workspace = true } orml-xcm = { workspace = true } @@ -90,7 +91,6 @@ pallet-investments = { workspace = true } pallet-keystore = { workspace = true } pallet-liquidity-pools = { workspace = true } pallet-liquidity-pools-gateway = { workspace = true } -liquidity-pools-gateway-routers = { workspace = true } pallet-liquidity-rewards = { workspace = true } pallet-loans = { workspace = true } pallet-membership = { workspace = true } @@ -132,267 +132,267 @@ cfg-mocks = { workspace = true, default-features = true } [features] default = ["std"] std = [ - "parity-scale-codec/std", - "log/std", - # Substrate related - "frame-support/std", - "frame-system/std", - "frame-benchmarking?/std", - "orml-traits/std", - "orml-tokens/std", - "pallet-anchors/std", - "pallet-authorship/std", - "pallet-balances/std", - "pallet-base-fee/std", - "pallet-ethereum/std", - "pallet-evm-chain-id/std", - "pallet-evm-precompile-balances-erc20/std", - "pallet-evm-precompile-blake2/std", - "pallet-evm-precompile-bn128/std", - "pallet-evm-precompile-dispatch/std", - "pallet-evm-precompile-modexp/std", - "pallet-evm-precompile-sha3fips/std", - "pallet-evm-precompile-simple/std", - "precompile-utils/std", - "polkadot-parachain-primitives/std", - "cumulus-primitives-core/std", - "scale-info/std", - "serde/std", - "sp-api/std", - "sp-arithmetic/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", - "staging-xcm-executor/std", - "xcm-primitives/std", - "staging-xcm-builder/std", - "staging-xcm/std", - # Locals - "cfg-primitives/std", - "cfg-traits/std", - "cfg-types/std", - "cfg-utils/std", - # Pallet exporting list - "axelar-gateway-precompile/std", - "chainbridge/std", - "cumulus-pallet-aura-ext/std", - "cumulus-pallet-parachain-system/std", - "cumulus-pallet-xcm/std", - "cumulus-pallet-xcmp-queue/std", - "orml-asset-registry/std", - "orml-tokens/std", - "orml-xcm/std", - "orml-xtokens/std", - "pallet-anchors/std", - "pallet-aura/std", - "pallet-authorship/std", - "pallet-balances/std", - "pallet-base-fee/std", - "pallet-block-rewards/std", - "pallet-bridge/std", - "pallet-collator-allowlist/std", - "pallet-collator-selection/std", - "pallet-collective/std", - "pallet-democracy/std", - "pallet-elections-phragmen/std", - "pallet-ethereum/std", - "pallet-ethereum-transaction/std", - "pallet-evm/std", - "pallet-evm-chain-id/std", - "pallet-fees/std", - "pallet-foreign-investments/std", - "pallet-identity/std", - "pallet-interest-accrual/std", - "pallet-investments/std", - "pallet-keystore/std", - "pallet-liquidity-pools/std", - "pallet-liquidity-pools-gateway/std", - "liquidity-pools-gateway-routers/std", - "pallet-liquidity-rewards/std", - "pallet-loans/std", - "pallet-membership/std", - "pallet-multisig/std", - "pallet-oracle-collection/std", - "pallet-oracle-feed/std", - "pallet-order-book/std", - "pallet-permissions/std", - "pallet-pool-fees/std", - "pallet-pool-registry/std", - "pallet-pool-system/std", - "pallet-preimage/std", - "pallet-proxy/std", - "pallet-restricted-tokens/std", - "pallet-restricted-xtokens/std", - "pallet-rewards/std", - "pallet-remarks/std", - "pallet-scheduler/std", - "pallet-session/std", - "pallet-sudo/std", - "pallet-timestamp/std", - "pallet-transaction-payment/std", - "pallet-transfer-allowlist/std", - "pallet-treasury/std", - "pallet-uniques/std", - "pallet-utility/std", - "pallet-vesting/std", - "pallet-xcm/std", - "pallet-xcm-transactor/std", - "pallet-message-queue/std", - "staging-parachain-info/std", + "parity-scale-codec/std", + "log/std", + # Substrate related + "frame-support/std", + "frame-system/std", + "frame-benchmarking?/std", + "orml-traits/std", + "orml-tokens/std", + "pallet-anchors/std", + "pallet-authorship/std", + "pallet-balances/std", + "pallet-base-fee/std", + "pallet-ethereum/std", + "pallet-evm-chain-id/std", + "pallet-evm-precompile-balances-erc20/std", + "pallet-evm-precompile-blake2/std", + "pallet-evm-precompile-bn128/std", + "pallet-evm-precompile-dispatch/std", + "pallet-evm-precompile-modexp/std", + "pallet-evm-precompile-sha3fips/std", + "pallet-evm-precompile-simple/std", + "precompile-utils/std", + "polkadot-parachain-primitives/std", + "cumulus-primitives-core/std", + "scale-info/std", + "serde/std", + "sp-api/std", + "sp-arithmetic/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "staging-xcm-executor/std", + "xcm-primitives/std", + "staging-xcm-builder/std", + "staging-xcm/std", + # Locals + "cfg-primitives/std", + "cfg-traits/std", + "cfg-types/std", + "cfg-utils/std", + # Pallet exporting list + "axelar-gateway-precompile/std", + "chainbridge/std", + "cumulus-pallet-aura-ext/std", + "cumulus-pallet-parachain-system/std", + "cumulus-pallet-xcm/std", + "cumulus-pallet-xcmp-queue/std", + "orml-asset-registry/std", + "orml-tokens/std", + "orml-xcm/std", + "orml-xtokens/std", + "pallet-anchors/std", + "pallet-aura/std", + "pallet-authorship/std", + "pallet-balances/std", + "pallet-base-fee/std", + "pallet-block-rewards/std", + "pallet-bridge/std", + "pallet-collator-allowlist/std", + "pallet-collator-selection/std", + "pallet-collective/std", + "pallet-democracy/std", + "pallet-elections-phragmen/std", + "pallet-ethereum/std", + "pallet-ethereum-transaction/std", + "pallet-evm/std", + "pallet-evm-chain-id/std", + "pallet-fees/std", + "pallet-foreign-investments/std", + "pallet-identity/std", + "pallet-interest-accrual/std", + "pallet-investments/std", + "pallet-keystore/std", + "pallet-liquidity-pools/std", + "pallet-liquidity-pools-gateway/std", + "liquidity-pools-gateway-routers/std", + "pallet-liquidity-rewards/std", + "pallet-loans/std", + "pallet-membership/std", + "pallet-multisig/std", + "pallet-oracle-collection/std", + "pallet-oracle-feed/std", + "pallet-order-book/std", + "pallet-permissions/std", + "pallet-pool-fees/std", + "pallet-pool-registry/std", + "pallet-pool-system/std", + "pallet-preimage/std", + "pallet-proxy/std", + "pallet-restricted-tokens/std", + "pallet-restricted-xtokens/std", + "pallet-rewards/std", + "pallet-remarks/std", + "pallet-scheduler/std", + "pallet-session/std", + "pallet-sudo/std", + "pallet-timestamp/std", + "pallet-transaction-payment/std", + "pallet-transfer-allowlist/std", + "pallet-treasury/std", + "pallet-uniques/std", + "pallet-utility/std", + "pallet-vesting/std", + "pallet-xcm/std", + "pallet-xcm-transactor/std", + "pallet-message-queue/std", + "staging-parachain-info/std", ] runtime-benchmarks = [ - # Substrate related - "sp-runtime/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "frame-benchmarking/runtime-benchmarks", # Optional enabled - "staging-xcm-executor/runtime-benchmarks", - "xcm-primitives/runtime-benchmarks", - "staging-xcm-builder/runtime-benchmarks", - "polkadot-parachain-primitives/runtime-benchmarks", - "cumulus-primitives-core/runtime-benchmarks", - # Locals - "cfg-primitives/runtime-benchmarks", - "cfg-traits/runtime-benchmarks", - "cfg-types/runtime-benchmarks", - "cfg-utils/runtime-benchmarks", - "cfg-mocks/runtime-benchmarks", - # Pallet exporting list - "axelar-gateway-precompile/runtime-benchmarks", - "chainbridge/runtime-benchmarks", - "cumulus-pallet-parachain-system/runtime-benchmarks", - "cumulus-pallet-xcmp-queue/runtime-benchmarks", - "orml-asset-registry/runtime-benchmarks", - "orml-tokens/runtime-benchmarks", - "orml-xtokens/runtime-benchmarks", - "pallet-anchors/runtime-benchmarks", - "pallet-balances/runtime-benchmarks", - "pallet-block-rewards/runtime-benchmarks", - "pallet-bridge/runtime-benchmarks", - "pallet-collator-allowlist/runtime-benchmarks", - "pallet-collator-selection/runtime-benchmarks", - "pallet-collective/runtime-benchmarks", - "pallet-democracy/runtime-benchmarks", - "pallet-elections-phragmen/runtime-benchmarks", - "pallet-ethereum/runtime-benchmarks", - "pallet-ethereum-transaction/runtime-benchmarks", - "pallet-evm/runtime-benchmarks", - "pallet-fees/runtime-benchmarks", - "pallet-foreign-investments/runtime-benchmarks", - "pallet-identity/runtime-benchmarks", - "pallet-interest-accrual/runtime-benchmarks", - "pallet-investments/runtime-benchmarks", - "pallet-keystore/runtime-benchmarks", - "pallet-liquidity-pools/runtime-benchmarks", - "pallet-liquidity-pools-gateway/runtime-benchmarks", - "liquidity-pools-gateway-routers/runtime-benchmarks", - "pallet-liquidity-rewards/runtime-benchmarks", - "pallet-loans/runtime-benchmarks", - "pallet-membership/runtime-benchmarks", - "pallet-multisig/runtime-benchmarks", - "pallet-oracle-collection/runtime-benchmarks", - "pallet-oracle-feed/runtime-benchmarks", - "pallet-order-book/runtime-benchmarks", - "pallet-permissions/runtime-benchmarks", - "pallet-pool-fees/runtime-benchmarks", - "pallet-pool-registry/runtime-benchmarks", - "pallet-pool-system/runtime-benchmarks", - "pallet-preimage/runtime-benchmarks", - "pallet-proxy/runtime-benchmarks", - "pallet-restricted-tokens/runtime-benchmarks", - "pallet-restricted-xtokens/runtime-benchmarks", - "pallet-rewards/runtime-benchmarks", - "pallet-remarks/runtime-benchmarks", - "pallet-scheduler/runtime-benchmarks", - "pallet-sudo/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", - "pallet-transfer-allowlist/runtime-benchmarks", - "pallet-treasury/runtime-benchmarks", - "pallet-uniques/runtime-benchmarks", - "pallet-utility/runtime-benchmarks", - "pallet-vesting/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", - "pallet-xcm-transactor/runtime-benchmarks", - "pallet-message-queue/runtime-benchmarks", + # Substrate related + "sp-runtime/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", # Optional enabled + "staging-xcm-executor/runtime-benchmarks", + "xcm-primitives/runtime-benchmarks", + "staging-xcm-builder/runtime-benchmarks", + "polkadot-parachain-primitives/runtime-benchmarks", + "cumulus-primitives-core/runtime-benchmarks", + # Locals + "cfg-primitives/runtime-benchmarks", + "cfg-traits/runtime-benchmarks", + "cfg-types/runtime-benchmarks", + "cfg-utils/runtime-benchmarks", + "cfg-mocks/runtime-benchmarks", + # Pallet exporting list + "axelar-gateway-precompile/runtime-benchmarks", + "chainbridge/runtime-benchmarks", + "cumulus-pallet-parachain-system/runtime-benchmarks", + "cumulus-pallet-xcmp-queue/runtime-benchmarks", + "orml-asset-registry/runtime-benchmarks", + "orml-tokens/runtime-benchmarks", + "orml-xtokens/runtime-benchmarks", + "pallet-anchors/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-block-rewards/runtime-benchmarks", + "pallet-bridge/runtime-benchmarks", + "pallet-collator-allowlist/runtime-benchmarks", + "pallet-collator-selection/runtime-benchmarks", + "pallet-collective/runtime-benchmarks", + "pallet-democracy/runtime-benchmarks", + "pallet-elections-phragmen/runtime-benchmarks", + "pallet-ethereum/runtime-benchmarks", + "pallet-ethereum-transaction/runtime-benchmarks", + "pallet-evm/runtime-benchmarks", + "pallet-fees/runtime-benchmarks", + "pallet-foreign-investments/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", + "pallet-interest-accrual/runtime-benchmarks", + "pallet-investments/runtime-benchmarks", + "pallet-keystore/runtime-benchmarks", + "pallet-liquidity-pools/runtime-benchmarks", + "pallet-liquidity-pools-gateway/runtime-benchmarks", + "liquidity-pools-gateway-routers/runtime-benchmarks", + "pallet-liquidity-rewards/runtime-benchmarks", + "pallet-loans/runtime-benchmarks", + "pallet-membership/runtime-benchmarks", + "pallet-multisig/runtime-benchmarks", + "pallet-oracle-collection/runtime-benchmarks", + "pallet-oracle-feed/runtime-benchmarks", + "pallet-order-book/runtime-benchmarks", + "pallet-permissions/runtime-benchmarks", + "pallet-pool-fees/runtime-benchmarks", + "pallet-pool-registry/runtime-benchmarks", + "pallet-pool-system/runtime-benchmarks", + "pallet-preimage/runtime-benchmarks", + "pallet-proxy/runtime-benchmarks", + "pallet-restricted-tokens/runtime-benchmarks", + "pallet-restricted-xtokens/runtime-benchmarks", + "pallet-rewards/runtime-benchmarks", + "pallet-remarks/runtime-benchmarks", + "pallet-scheduler/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "pallet-transfer-allowlist/runtime-benchmarks", + "pallet-treasury/runtime-benchmarks", + "pallet-uniques/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", + "pallet-vesting/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "pallet-xcm-transactor/runtime-benchmarks", + "pallet-message-queue/runtime-benchmarks", ] try-runtime = [ - "sp-runtime/try-runtime", - "cfg-primitives/try-runtime", - "cfg-traits/try-runtime", - "cfg-types/try-runtime", - "cfg-utils/try-runtime", - "cfg-mocks/try-runtime", - "frame-support/try-runtime", - "frame-system/try-runtime", - # Pallet exporting list - "axelar-gateway-precompile/try-runtime", - "chainbridge/try-runtime", - "cumulus-pallet-aura-ext/try-runtime", - "cumulus-pallet-parachain-system/try-runtime", - "cumulus-pallet-xcm/try-runtime", - "cumulus-pallet-xcmp-queue/try-runtime", - "orml-asset-registry/try-runtime", - "orml-tokens/try-runtime", - "orml-xcm/try-runtime", - "orml-xtokens/try-runtime", - "pallet-anchors/try-runtime", - "pallet-aura/try-runtime", - "pallet-authorship/try-runtime", - "pallet-balances/try-runtime", - "pallet-base-fee/try-runtime", - "pallet-block-rewards/try-runtime", - "pallet-bridge/try-runtime", - "pallet-collator-allowlist/try-runtime", - "pallet-collator-selection/try-runtime", - "pallet-collective/try-runtime", - "pallet-democracy/try-runtime", - "pallet-elections-phragmen/try-runtime", - "pallet-ethereum/try-runtime", - "pallet-ethereum-transaction/try-runtime", - "pallet-evm/try-runtime", - "pallet-evm-chain-id/try-runtime", - "pallet-fees/try-runtime", - "pallet-foreign-investments/try-runtime", - "pallet-identity/try-runtime", - "pallet-interest-accrual/try-runtime", - "pallet-investments/try-runtime", - "pallet-keystore/try-runtime", - "pallet-liquidity-pools/try-runtime", - "pallet-liquidity-pools-gateway/try-runtime", - "liquidity-pools-gateway-routers/try-runtime", - "pallet-liquidity-rewards/try-runtime", - "pallet-loans/try-runtime", - "pallet-membership/try-runtime", - "pallet-multisig/try-runtime", - "pallet-oracle-collection/try-runtime", - "pallet-oracle-feed/try-runtime", - "pallet-order-book/try-runtime", - "pallet-permissions/try-runtime", - "pallet-pool-fees/try-runtime", - "pallet-pool-registry/try-runtime", - "pallet-pool-system/try-runtime", - "pallet-preimage/try-runtime", - "pallet-proxy/try-runtime", - "pallet-restricted-tokens/try-runtime", - "pallet-restricted-xtokens/try-runtime", - "pallet-rewards/try-runtime", - "pallet-remarks/try-runtime", - "pallet-scheduler/try-runtime", - "pallet-session/try-runtime", - "pallet-sudo/try-runtime", - "pallet-timestamp/try-runtime", - "pallet-transaction-payment/try-runtime", - "pallet-transfer-allowlist/try-runtime", - "pallet-treasury/try-runtime", - "pallet-uniques/try-runtime", - "pallet-utility/try-runtime", - "pallet-vesting/try-runtime", - "pallet-xcm/try-runtime", - "pallet-xcm-transactor/try-runtime", - "pallet-message-queue/try-runtime", - "staging-parachain-info/try-runtime", + "sp-runtime/try-runtime", + "cfg-primitives/try-runtime", + "cfg-traits/try-runtime", + "cfg-types/try-runtime", + "cfg-utils/try-runtime", + "cfg-mocks/try-runtime", + "frame-support/try-runtime", + "frame-system/try-runtime", + # Pallet exporting list + "axelar-gateway-precompile/try-runtime", + "chainbridge/try-runtime", + "cumulus-pallet-aura-ext/try-runtime", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", + "orml-asset-registry/try-runtime", + "orml-tokens/try-runtime", + "orml-xcm/try-runtime", + "orml-xtokens/try-runtime", + "pallet-anchors/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", + "pallet-balances/try-runtime", + "pallet-base-fee/try-runtime", + "pallet-block-rewards/try-runtime", + "pallet-bridge/try-runtime", + "pallet-collator-allowlist/try-runtime", + "pallet-collator-selection/try-runtime", + "pallet-collective/try-runtime", + "pallet-democracy/try-runtime", + "pallet-elections-phragmen/try-runtime", + "pallet-ethereum/try-runtime", + "pallet-ethereum-transaction/try-runtime", + "pallet-evm/try-runtime", + "pallet-evm-chain-id/try-runtime", + "pallet-fees/try-runtime", + "pallet-foreign-investments/try-runtime", + "pallet-identity/try-runtime", + "pallet-interest-accrual/try-runtime", + "pallet-investments/try-runtime", + "pallet-keystore/try-runtime", + "pallet-liquidity-pools/try-runtime", + "pallet-liquidity-pools-gateway/try-runtime", + "liquidity-pools-gateway-routers/try-runtime", + "pallet-liquidity-rewards/try-runtime", + "pallet-loans/try-runtime", + "pallet-membership/try-runtime", + "pallet-multisig/try-runtime", + "pallet-oracle-collection/try-runtime", + "pallet-oracle-feed/try-runtime", + "pallet-order-book/try-runtime", + "pallet-permissions/try-runtime", + "pallet-pool-fees/try-runtime", + "pallet-pool-registry/try-runtime", + "pallet-pool-system/try-runtime", + "pallet-preimage/try-runtime", + "pallet-proxy/try-runtime", + "pallet-restricted-tokens/try-runtime", + "pallet-restricted-xtokens/try-runtime", + "pallet-rewards/try-runtime", + "pallet-remarks/try-runtime", + "pallet-scheduler/try-runtime", + "pallet-session/try-runtime", + "pallet-sudo/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-transaction-payment/try-runtime", + "pallet-transfer-allowlist/try-runtime", + "pallet-treasury/try-runtime", + "pallet-uniques/try-runtime", + "pallet-utility/try-runtime", + "pallet-vesting/try-runtime", + "pallet-xcm/try-runtime", + "pallet-xcm-transactor/try-runtime", + "pallet-message-queue/try-runtime", + "staging-parachain-info/try-runtime", ] on-chain-release-build = [ - "sp-api/disable-logging", + "sp-api/disable-logging", ] From 8ec41e92a8b0bd31fef1c90e6a47cbcd48e771e6 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Wed, 14 Aug 2024 19:21:14 +0200 Subject: [PATCH 3/6] fix: migration --- pallets/liquidity-pools-gateway/src/lib.rs | 2 +- runtime/altair/src/migrations.rs | 14 ++++- runtime/centrifuge/src/migrations.rs | 14 ++++- .../src/migrations/liquidity_pools_gateway.rs | 62 ++++++++++++------- runtime/development/src/migrations.rs | 5 +- 5 files changed, 66 insertions(+), 31 deletions(-) diff --git a/pallets/liquidity-pools-gateway/src/lib.rs b/pallets/liquidity-pools-gateway/src/lib.rs index 2dfc01b85e..409a3cbfd7 100644 --- a/pallets/liquidity-pools-gateway/src/lib.rs +++ b/pallets/liquidity-pools-gateway/src/lib.rs @@ -61,7 +61,7 @@ mod tests; pub mod pallet { use super::*; - const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] diff --git a/runtime/altair/src/migrations.rs b/runtime/altair/src/migrations.rs index d1cef70c2a..f5bfce2023 100644 --- a/runtime/altair/src/migrations.rs +++ b/runtime/altair/src/migrations.rs @@ -15,13 +15,21 @@ use crate::Runtime; /// The migration set for Altair @ Kusama. /// It includes all the migrations that have to be applied on that chain. pub type UpgradeAltair1402 = ( - // Remove deprecated DomainRouters entries - runtime_common::migrations::liquidity_pools_gateway::clear_deprecated_domain_router_entries::Migration, // Clear OutboundMessageNonceStore frame_support::migrations::VersionedMigration< 0, 1, - runtime_common::migrations::liquidity_pools_gateway::clear_outbound_nonce::Migration, + runtime_common::migrations::liquidity_pools_gateway::clear_outbound_nonce::Migration< + Runtime, + >, + pallet_liquidity_pools_gateway::Pallet, + ::DbWeight, + >, + // Remove deprecated DomainRouters entries + frame_support::migrations::VersionedMigration< + 1, + 2, + runtime_common::migrations::liquidity_pools_gateway::clear_deprecated_domain_router_entries::Migration, pallet_liquidity_pools_gateway::Pallet, ::DbWeight, >, diff --git a/runtime/centrifuge/src/migrations.rs b/runtime/centrifuge/src/migrations.rs index 3bd55bb315..9143e228b3 100644 --- a/runtime/centrifuge/src/migrations.rs +++ b/runtime/centrifuge/src/migrations.rs @@ -15,13 +15,21 @@ use crate::Runtime; /// The migration set for Centrifuge @ Polkadot. /// It includes all the migrations that have to be applied on that chain. pub type UpgradeCentrifuge1402 = ( - // Remove deprecated DomainRouters entries - runtime_common::migrations::liquidity_pools_gateway::clear_deprecated_domain_router_entries::Migration, // Clear OutboundMessageNonceStore frame_support::migrations::VersionedMigration< 0, 1, - runtime_common::migrations::liquidity_pools_gateway::clear_outbound_nonce::Migration, + runtime_common::migrations::liquidity_pools_gateway::clear_outbound_nonce::Migration< + Runtime, + >, + pallet_liquidity_pools_gateway::Pallet, + ::DbWeight, + >, + // Remove deprecated DomainRouters entries + frame_support::migrations::VersionedMigration< + 1, + 2, + runtime_common::migrations::liquidity_pools_gateway::clear_deprecated_domain_router_entries::Migration, pallet_liquidity_pools_gateway::Pallet, ::DbWeight, >, diff --git a/runtime/common/src/migrations/liquidity_pools_gateway.rs b/runtime/common/src/migrations/liquidity_pools_gateway.rs index 6c11647590..493996a00b 100644 --- a/runtime/common/src/migrations/liquidity_pools_gateway.rs +++ b/runtime/common/src/migrations/liquidity_pools_gateway.rs @@ -11,8 +11,10 @@ // GNU General Public License for more details. use cfg_types::domain_address::Domain; +#[cfg(feature = "try-runtime")] +use frame_support::pallet_prelude::{Decode, Encode}; use frame_support::{ - pallet_prelude::{Decode, Encode, ValueQuery}, + pallet_prelude::ValueQuery, storage_alias, traits::{Get, OnRuntimeUpgrade}, weights::Weight, @@ -157,21 +159,26 @@ pub mod clear_deprecated_domain_router_entries { fn on_runtime_upgrade() -> Weight { let items = v0::DomainRouters::::iter_keys().count().saturated_into(); - pallet_liquidity_pools_gateway::DomainRouters::::translate_values::< - v0::DomainRouter, - _, - >(|old| match old { - v0::DomainRouter::AxelarEVM(router) => Some( - liquidity_pools_gateway_routers::DomainRouter::::AxelarEVM(router).into(), - ), - // Remove other entries - router => { - log::info!("{LOG_PREFIX}: Removing entry {router:?}!"); - None - } - }); - - log::info!("{LOG_PREFIX}: Migration done with {items:?} items in total!"); + pallet_liquidity_pools_gateway::DomainRouters::::translate::, _>( + |key, old| { + log::debug!("{LOG_PREFIX}: Inspecting key {key:?} with value\n{old:?}"); + match old { + v0::DomainRouter::AxelarEVM(router) => Some( + liquidity_pools_gateway_routers::DomainRouter::::AxelarEVM(router) + .into(), + ), + // Remove other entries + router => { + log::info!("{LOG_PREFIX} : Removing entry {router:?}!"); + None + } + } + }, + ); + + log::info!( + "{LOG_PREFIX} ON_RUNTIME_UPGRADE: Migration done with {items:?} items in total!" + ); T::DbWeight::get().reads_writes(items, items) } @@ -179,12 +186,23 @@ pub mod clear_deprecated_domain_router_entries { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { let count_total = v0::DomainRouters::::iter_keys().count(); - let count_axelar_evm_router: u64 = v0::DomainRouters::::iter_values() - .filter(|v| matches!(v, v0::DomainRouter::AxelarEVM(_))) + let count_axelar_evm_router: u64 = v0::DomainRouters::::iter() + .filter(|(domain, router)| { + log::debug!( + "{LOG_PREFIX} PRE: Inspecting key {domain:?} with value\n{router:?}" + ); + matches!(router, v0::DomainRouter::AxelarEVM(_)) + }) .count() .saturated_into(); - log::info!("{LOG_PREFIX}: Found {count_axelar_evm_router:?} values of total {count_total:?} to migrate!"); - log::info!("{LOG_PREFIX}: Pre checks done!"); + log::info!( + "{LOG_PREFIX} PRE: Found {count_axelar_evm_router:?} values of + total {count_total:?} to migrate!" + ); + log::info!( + "{LOG_PREFIX} PRE: Checks + done!" + ); Ok(count_axelar_evm_router.encode()) } @@ -197,10 +215,10 @@ pub mod clear_deprecated_domain_router_entries { .saturated_into(); assert_eq!( pre_count, post_count, - "{LOG_PREFIX}: Mismatching number of domain routers after migration!" + "{LOG_PREFIX} POST: Mismatching number of domain routers after migration!" ); - log::info!("{LOG_PREFIX}: Post checks done!"); + log::info!("{LOG_PREFIX} POST: Checks done!"); Ok(()) } diff --git a/runtime/development/src/migrations.rs b/runtime/development/src/migrations.rs index ab9d396ea9..f154e76666 100644 --- a/runtime/development/src/migrations.rs +++ b/runtime/development/src/migrations.rs @@ -10,7 +10,8 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. +use frame_support::migrations::VersionedMigration; + use crate::Runtime; -pub type UpgradeDevelopment1402 = - (runtime_common::migrations::liquidity_pools_gateway::clear_deprecated_domain_router_entries::Migration,); +pub type UpgradeDevelopment1402 = VersionedMigration<1, 2, runtime_common::migrations::liquidity_pools_gateway::clear_deprecated_domain_router_entries::Migration, pallet_liquidity_pools_gateway::Pallet, ::DbWeight>; From 86fe33fa4a665fd58c5a3894fdf902a9f2b64bc9 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Thu, 29 Aug 2024 14:28:32 +0200 Subject: [PATCH 4/6] feat: lp v2 migrations --- Cargo.lock | 10 +- Cargo.toml | 96 +- pallets/liquidity-pools-gateway/src/lib.rs | 2 +- runtime/altair/src/lib.rs | 4 +- runtime/altair/src/migrations.rs | 26 +- runtime/centrifuge/src/lib.rs | 4 +- runtime/centrifuge/src/migrations.rs | 28 +- runtime/common/Cargo.toml | 519 +++++------ .../src/migrations/foreign_investments_v2.rs | 2 +- .../src/migrations/liquidity_pools_gateway.rs | 295 ------ .../src/migrations/liquidity_pools_v2.rs | 846 ++++++++++++++++++ runtime/common/src/migrations/mod.rs | 2 +- runtime/common/src/migrations/nuke.rs | 35 +- runtime/development/src/lib.rs | 42 +- runtime/development/src/migrations.rs | 12 +- 15 files changed, 1242 insertions(+), 681 deletions(-) delete mode 100644 runtime/common/src/migrations/liquidity_pools_gateway.rs create mode 100644 runtime/common/src/migrations/liquidity_pools_v2.rs diff --git a/Cargo.lock b/Cargo.lock index f0a5a4a06c..52eaad985a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -121,7 +121,7 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "altair-runtime" -version = "0.14.2" +version = "0.14.3" dependencies = [ "cfg-primitives", "cfg-traits", @@ -1353,7 +1353,7 @@ dependencies = [ [[package]] name = "centrifuge-chain" -version = "0.14.2" +version = "0.14.3" dependencies = [ "altair-runtime", "async-trait", @@ -1446,7 +1446,7 @@ dependencies = [ [[package]] name = "centrifuge-runtime" -version = "0.14.2" +version = "0.14.3" dependencies = [ "cfg-primitives", "cfg-traits", @@ -3057,7 +3057,7 @@ dependencies = [ [[package]] name = "development-runtime" -version = "0.14.2" +version = "0.14.3" dependencies = [ "cfg-primitives", "cfg-traits", @@ -11645,7 +11645,6 @@ dependencies = [ "frame-system", "hex", "hex-literal", - "liquidity-pools-gateway-routers", "log", "num_enum 0.5.11", "orml-asset-registry", @@ -11685,6 +11684,7 @@ dependencies = [ "pallet-keystore", "pallet-liquidity-pools", "pallet-liquidity-pools-gateway", + "pallet-liquidity-pools-gateway-queue", "pallet-liquidity-rewards", "pallet-loans", "pallet-membership", diff --git a/Cargo.toml b/Cargo.toml index 6ff577f191..8075bfd741 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,49 +1,49 @@ [workspace] resolver = "2" members = [ - "node", - "libs/mocks", - "libs/primitives", - "libs/test-utils", - "libs/traits", - "libs/types", - "libs/utils", - "pallets/anchors", - "pallets/anchors-v2", - "pallets/axelar-router", - "pallets/bridge", - "pallets/block-rewards", - "pallets/collator-allowlist", - "pallets/ethereum-transaction", - "pallets/fees", - "pallets/foreign-investments", - "pallets/interest-accrual", - "pallets/investments", - "pallets/keystore", - "pallets/liquidity-pools", - "pallets/liquidity-pools-gateway", - "pallets/liquidity-pools-gateway-queue", - "pallets/liquidity-pools-forwarder", - "pallets/liquidity-rewards", - "pallets/loans", - "pallets/oracle-feed", - "pallets/oracle-collection", - "pallets/order-book", - "pallets/permissions", - "pallets/pool-fees", - "pallets/pool-system", - "pallets/pool-registry", - "pallets/restricted-tokens", - "pallets/restricted-xtokens", - "pallets/rewards", - "pallets/token-mux", - "pallets/transfer-allowlist", - "runtime/altair", - "runtime/centrifuge", - "runtime/development", - "runtime/common", - "runtime/integration-tests", - "runtime/integration-tests/procedural", + "node", + "libs/mocks", + "libs/primitives", + "libs/test-utils", + "libs/traits", + "libs/types", + "libs/utils", + "pallets/anchors", + "pallets/anchors-v2", + "pallets/axelar-router", + "pallets/bridge", + "pallets/block-rewards", + "pallets/collator-allowlist", + "pallets/ethereum-transaction", + "pallets/fees", + "pallets/foreign-investments", + "pallets/interest-accrual", + "pallets/investments", + "pallets/keystore", + "pallets/liquidity-pools", + "pallets/liquidity-pools-gateway", + "pallets/liquidity-pools-gateway-queue", + "pallets/liquidity-pools-forwarder", + "pallets/liquidity-rewards", + "pallets/loans", + "pallets/oracle-feed", + "pallets/oracle-collection", + "pallets/order-book", + "pallets/permissions", + "pallets/pool-fees", + "pallets/pool-system", + "pallets/pool-registry", + "pallets/restricted-tokens", + "pallets/restricted-xtokens", + "pallets/rewards", + "pallets/token-mux", + "pallets/transfer-allowlist", + "runtime/altair", + "runtime/centrifuge", + "runtime/development", + "runtime/common", + "runtime/integration-tests", + "runtime/integration-tests/procedural", ] [workspace.package] @@ -53,7 +53,7 @@ license = "LGPL-3.0" homepage = "https://centrifuge.io/" repository = "https://github.com/centrifuge/centrifuge-chain" documentation = "https://reference.centrifuge.io/centrifuge_chain/index.html" -version = "0.14.2" +version = "0.14.3" [workspace.dependencies] hex-literal = { version = "0.4.1" } @@ -176,7 +176,7 @@ frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", defau frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, features = [ - "tuples-96", + "tuples-96", ], branch = "release-polkadot-v1.7.2" } # Check when tuples-96 can be removed frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } @@ -288,14 +288,14 @@ pallet-remarks = { git = "https://github.com/foss3/runtime-pallet-library", bran # Moonbeam fork of polkadot-evm/frontier fp-rpc = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } fp-self-contained = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2", features = [ - "serde", + "serde", ] } pallet-base-fee = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } pallet-ethereum = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2", features = [ - "forbid-evm-reentrancy", + "forbid-evm-reentrancy", ] } pallet-evm = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2", features = [ - "forbid-evm-reentrancy", + "forbid-evm-reentrancy", ] } pallet-evm-chain-id = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } pallet-evm-precompile-blake2 = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } diff --git a/pallets/liquidity-pools-gateway/src/lib.rs b/pallets/liquidity-pools-gateway/src/lib.rs index 460850ef94..acd59b023e 100644 --- a/pallets/liquidity-pools-gateway/src/lib.rs +++ b/pallets/liquidity-pools-gateway/src/lib.rs @@ -66,7 +66,7 @@ mod tests; pub mod pallet { use super::*; - const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(3); #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] diff --git a/runtime/altair/src/lib.rs b/runtime/altair/src/lib.rs index 6335e4fe8a..7a4ccc9a15 100644 --- a/runtime/altair/src/lib.rs +++ b/runtime/altair/src/lib.rs @@ -169,7 +169,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("altair"), impl_name: create_runtime_str!("altair"), authoring_version: 1, - spec_version: 1402, + spec_version: 1403, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -2027,7 +2027,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - migrations::UpgradeAltair1402, + migrations::UpgradeAltair1403, >; // Frame Order in this block dictates the index of each one in the metadata diff --git a/runtime/altair/src/migrations.rs b/runtime/altair/src/migrations.rs index f5bfce2023..2b08b593c2 100644 --- a/runtime/altair/src/migrations.rs +++ b/runtime/altair/src/migrations.rs @@ -10,26 +10,22 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. +use frame_support::migrations::VersionedMigration; + use crate::Runtime; /// The migration set for Altair @ Kusama. /// It includes all the migrations that have to be applied on that chain. -pub type UpgradeAltair1402 = ( - // Clear OutboundMessageNonceStore - frame_support::migrations::VersionedMigration< +pub type UpgradeAltair1403 = ( + // Clear v0 RelayerList storage + runtime_common::migrations::liquidity_pools_v2::kill_relayer_list::Migration, + // Clear OutboundMessageNonceStore and migrate outbound storage to LP queue + runtime_common::migrations::liquidity_pools_v2::v0_init_message_queue::Migration, + // Remove deprecated DomainRouters entries and migrate relevant ones to Axelar Router Config + VersionedMigration< 0, - 1, - runtime_common::migrations::liquidity_pools_gateway::clear_outbound_nonce::Migration< - Runtime, - >, - pallet_liquidity_pools_gateway::Pallet, - ::DbWeight, - >, - // Remove deprecated DomainRouters entries - frame_support::migrations::VersionedMigration< - 1, - 2, - runtime_common::migrations::liquidity_pools_gateway::clear_deprecated_domain_router_entries::Migration, + 3, + runtime_common::migrations::liquidity_pools_v2::init_axelar_router::Migration, pallet_liquidity_pools_gateway::Pallet, ::DbWeight, >, diff --git a/runtime/centrifuge/src/lib.rs b/runtime/centrifuge/src/lib.rs index 0b6e5d2d7d..4d112de248 100644 --- a/runtime/centrifuge/src/lib.rs +++ b/runtime/centrifuge/src/lib.rs @@ -167,7 +167,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("centrifuge"), impl_name: create_runtime_str!("centrifuge"), authoring_version: 1, - spec_version: 1402, + spec_version: 1403, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -2041,7 +2041,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - migrations::UpgradeCentrifuge1402, + migrations::UpgradeCentrifuge1403, >; // Frame Order in this block dictates the index of each one in the metadata diff --git a/runtime/centrifuge/src/migrations.rs b/runtime/centrifuge/src/migrations.rs index 9143e228b3..36f6728690 100644 --- a/runtime/centrifuge/src/migrations.rs +++ b/runtime/centrifuge/src/migrations.rs @@ -10,29 +10,27 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. +use frame_support::migrations::VersionedMigration; + use crate::Runtime; /// The migration set for Centrifuge @ Polkadot. /// It includes all the migrations that have to be applied on that chain. -pub type UpgradeCentrifuge1402 = ( - // Clear OutboundMessageNonceStore - frame_support::migrations::VersionedMigration< +pub type UpgradeCentrifuge1403 = ( + // Clear v0 RelayerList storage + runtime_common::migrations::liquidity_pools_v2::kill_relayer_list::Migration, + // Clear OutboundMessageNonceStore and migrate outbound storage to LP queue + runtime_common::migrations::liquidity_pools_v2::v0_init_message_queue::Migration, + // Remove deprecated DomainRouters entries and migrate relevant ones to Axelar Router Config + VersionedMigration< 0, - 1, - runtime_common::migrations::liquidity_pools_gateway::clear_outbound_nonce::Migration< - Runtime, - >, - pallet_liquidity_pools_gateway::Pallet, - ::DbWeight, - >, - // Remove deprecated DomainRouters entries - frame_support::migrations::VersionedMigration< - 1, - 2, - runtime_common::migrations::liquidity_pools_gateway::clear_deprecated_domain_router_entries::Migration, + 3, + runtime_common::migrations::liquidity_pools_v2::init_axelar_router::Migration, pallet_liquidity_pools_gateway::Pallet, ::DbWeight, >, + // Remove deprecated RelayerList storage + runtime_common::migrations::liquidity_pools_v2::kill_relayer_list::Migration, // Remove undecodable ForeignInvestmentInfo v0 entries runtime_common::migrations::foreign_investments_v2::Migration, // Bump to v1 diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index d566344efb..a3f7f1d261 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -61,7 +61,6 @@ cumulus-pallet-aura-ext = { workspace = true } cumulus-pallet-parachain-system = { workspace = true } cumulus-pallet-xcm = { workspace = true } cumulus-pallet-xcmp-queue = { workspace = true } -liquidity-pools-gateway-routers = { workspace = true } orml-asset-registry = { workspace = true } orml-tokens = { workspace = true } orml-xcm = { workspace = true } @@ -91,6 +90,7 @@ pallet-investments = { workspace = true } pallet-keystore = { workspace = true } pallet-liquidity-pools = { workspace = true } pallet-liquidity-pools-gateway = { workspace = true } +pallet-liquidity-pools-gateway-queue = { workspace = true } pallet-liquidity-rewards = { workspace = true } pallet-loans = { workspace = true } pallet-membership = { workspace = true } @@ -132,267 +132,270 @@ cfg-mocks = { workspace = true, default-features = true } [features] default = ["std"] std = [ - "parity-scale-codec/std", - "log/std", - # Substrate related - "frame-support/std", - "frame-system/std", - "frame-benchmarking?/std", - "orml-traits/std", - "orml-tokens/std", - "pallet-anchors/std", - "pallet-authorship/std", - "pallet-balances/std", - "pallet-base-fee/std", - "pallet-ethereum/std", - "pallet-evm-chain-id/std", - "pallet-evm-precompile-balances-erc20/std", - "pallet-evm-precompile-blake2/std", - "pallet-evm-precompile-bn128/std", - "pallet-evm-precompile-dispatch/std", - "pallet-evm-precompile-modexp/std", - "pallet-evm-precompile-sha3fips/std", - "pallet-evm-precompile-simple/std", - "precompile-utils/std", - "polkadot-parachain-primitives/std", - "cumulus-primitives-core/std", - "scale-info/std", - "serde/std", - "sp-api/std", - "sp-arithmetic/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", - "staging-xcm-executor/std", - "xcm-primitives/std", - "staging-xcm-builder/std", - "staging-xcm/std", - # Locals - "cfg-primitives/std", - "cfg-traits/std", - "cfg-types/std", - "cfg-utils/std", - # Pallet exporting list - "chainbridge/std", - "cumulus-pallet-aura-ext/std", - "cumulus-pallet-parachain-system/std", - "cumulus-pallet-xcm/std", - "cumulus-pallet-xcmp-queue/std", - "orml-asset-registry/std", - "orml-tokens/std", - "orml-xcm/std", - "orml-xtokens/std", - "pallet-anchors/std", - "pallet-aura/std", - "pallet-authorship/std", - "pallet-axelar-router/std", - "pallet-balances/std", - "pallet-base-fee/std", - "pallet-block-rewards/std", - "pallet-bridge/std", - "pallet-collator-allowlist/std", - "pallet-collator-selection/std", - "pallet-collective/std", - "pallet-democracy/std", - "pallet-elections-phragmen/std", - "pallet-ethereum/std", - "pallet-ethereum-transaction/std", - "pallet-evm/std", - "pallet-evm-chain-id/std", - "pallet-fees/std", - "pallet-foreign-investments/std", - "pallet-identity/std", - "pallet-interest-accrual/std", - "pallet-investments/std", - "pallet-keystore/std", - "pallet-liquidity-pools/std", - "pallet-liquidity-pools-gateway/std", - "liquidity-pools-gateway-routers/std", - "pallet-liquidity-rewards/std", - "pallet-loans/std", - "pallet-membership/std", - "pallet-multisig/std", - "pallet-oracle-collection/std", - "pallet-oracle-feed/std", - "pallet-order-book/std", - "pallet-permissions/std", - "pallet-pool-fees/std", - "pallet-pool-registry/std", - "pallet-pool-system/std", - "pallet-preimage/std", - "pallet-proxy/std", - "pallet-restricted-tokens/std", - "pallet-restricted-xtokens/std", - "pallet-rewards/std", - "pallet-remarks/std", - "pallet-scheduler/std", - "pallet-session/std", - "pallet-sudo/std", - "pallet-timestamp/std", - "pallet-transaction-payment/std", - "pallet-transfer-allowlist/std", - "pallet-treasury/std", - "pallet-uniques/std", - "pallet-utility/std", - "pallet-vesting/std", - "pallet-xcm/std", - "pallet-xcm-transactor/std", - "pallet-message-queue/std", - "staging-parachain-info/std", + "parity-scale-codec/std", + "log/std", + # Substrate related + "frame-support/std", + "frame-system/std", + "frame-benchmarking?/std", + "orml-traits/std", + "orml-tokens/std", + "pallet-anchors/std", + "pallet-authorship/std", + "pallet-balances/std", + "pallet-base-fee/std", + "pallet-ethereum/std", + "pallet-evm-chain-id/std", + "pallet-evm-precompile-balances-erc20/std", + "pallet-evm-precompile-blake2/std", + "pallet-evm-precompile-bn128/std", + "pallet-evm-precompile-dispatch/std", + "pallet-evm-precompile-modexp/std", + "pallet-evm-precompile-sha3fips/std", + "pallet-evm-precompile-simple/std", + "precompile-utils/std", + "polkadot-parachain-primitives/std", + "cumulus-primitives-core/std", + "scale-info/std", + "serde/std", + "sp-api/std", + "sp-arithmetic/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "staging-xcm-executor/std", + "xcm-primitives/std", + "staging-xcm-builder/std", + "staging-xcm/std", + # Locals + "cfg-primitives/std", + "cfg-traits/std", + "cfg-types/std", + "cfg-utils/std", + # Pallet exporting list + "chainbridge/std", + "cumulus-pallet-aura-ext/std", + "cumulus-pallet-parachain-system/std", + "cumulus-pallet-xcm/std", + "cumulus-pallet-xcmp-queue/std", + "orml-asset-registry/std", + "orml-tokens/std", + "orml-xcm/std", + "orml-xtokens/std", + "pallet-anchors/std", + "pallet-aura/std", + "pallet-authorship/std", + "pallet-axelar-router/std", + "pallet-balances/std", + "pallet-base-fee/std", + "pallet-block-rewards/std", + "pallet-bridge/std", + "pallet-collator-allowlist/std", + "pallet-collator-selection/std", + "pallet-collective/std", + "pallet-democracy/std", + "pallet-elections-phragmen/std", + "pallet-ethereum/std", + "pallet-ethereum-transaction/std", + "pallet-evm/std", + "pallet-evm-chain-id/std", + "pallet-fees/std", + "pallet-foreign-investments/std", + "pallet-identity/std", + "pallet-interest-accrual/std", + "pallet-investments/std", + "pallet-keystore/std", + "pallet-liquidity-pools/std", + "pallet-liquidity-pools-gateway/std", + "pallet-liquidity-pools-gateway-queue/std", + "pallet-axelar-router/std", + "pallet-liquidity-rewards/std", + "pallet-loans/std", + "pallet-membership/std", + "pallet-multisig/std", + "pallet-oracle-collection/std", + "pallet-oracle-feed/std", + "pallet-order-book/std", + "pallet-permissions/std", + "pallet-pool-fees/std", + "pallet-pool-registry/std", + "pallet-pool-system/std", + "pallet-preimage/std", + "pallet-proxy/std", + "pallet-restricted-tokens/std", + "pallet-restricted-xtokens/std", + "pallet-rewards/std", + "pallet-remarks/std", + "pallet-scheduler/std", + "pallet-session/std", + "pallet-sudo/std", + "pallet-timestamp/std", + "pallet-transaction-payment/std", + "pallet-transfer-allowlist/std", + "pallet-treasury/std", + "pallet-uniques/std", + "pallet-utility/std", + "pallet-vesting/std", + "pallet-xcm/std", + "pallet-xcm-transactor/std", + "pallet-message-queue/std", + "staging-parachain-info/std", ] runtime-benchmarks = [ - # Substrate related - "sp-runtime/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "frame-benchmarking/runtime-benchmarks", # Optional enabled - "staging-xcm-executor/runtime-benchmarks", - "xcm-primitives/runtime-benchmarks", - "staging-xcm-builder/runtime-benchmarks", - "polkadot-parachain-primitives/runtime-benchmarks", - "cumulus-primitives-core/runtime-benchmarks", - # Locals - "cfg-primitives/runtime-benchmarks", - "cfg-traits/runtime-benchmarks", - "cfg-types/runtime-benchmarks", - "cfg-utils/runtime-benchmarks", - "cfg-mocks/runtime-benchmarks", - # Pallet exporting list - "chainbridge/runtime-benchmarks", - "cumulus-pallet-parachain-system/runtime-benchmarks", - "cumulus-pallet-xcmp-queue/runtime-benchmarks", - "orml-asset-registry/runtime-benchmarks", - "orml-tokens/runtime-benchmarks", - "orml-xtokens/runtime-benchmarks", - "pallet-anchors/runtime-benchmarks", - "pallet-axelar-router/runtime-benchmarks", - "pallet-balances/runtime-benchmarks", - "pallet-block-rewards/runtime-benchmarks", - "pallet-bridge/runtime-benchmarks", - "pallet-collator-allowlist/runtime-benchmarks", - "pallet-collator-selection/runtime-benchmarks", - "pallet-collective/runtime-benchmarks", - "pallet-democracy/runtime-benchmarks", - "pallet-elections-phragmen/runtime-benchmarks", - "pallet-ethereum/runtime-benchmarks", - "pallet-ethereum-transaction/runtime-benchmarks", - "pallet-evm/runtime-benchmarks", - "pallet-fees/runtime-benchmarks", - "pallet-foreign-investments/runtime-benchmarks", - "pallet-identity/runtime-benchmarks", - "pallet-interest-accrual/runtime-benchmarks", - "pallet-investments/runtime-benchmarks", - "pallet-keystore/runtime-benchmarks", - "pallet-liquidity-pools/runtime-benchmarks", - "pallet-liquidity-pools-gateway/runtime-benchmarks", - "liquidity-pools-gateway-routers/runtime-benchmarks", - "pallet-liquidity-rewards/runtime-benchmarks", - "pallet-loans/runtime-benchmarks", - "pallet-membership/runtime-benchmarks", - "pallet-multisig/runtime-benchmarks", - "pallet-oracle-collection/runtime-benchmarks", - "pallet-oracle-feed/runtime-benchmarks", - "pallet-order-book/runtime-benchmarks", - "pallet-permissions/runtime-benchmarks", - "pallet-pool-fees/runtime-benchmarks", - "pallet-pool-registry/runtime-benchmarks", - "pallet-pool-system/runtime-benchmarks", - "pallet-preimage/runtime-benchmarks", - "pallet-proxy/runtime-benchmarks", - "pallet-restricted-tokens/runtime-benchmarks", - "pallet-restricted-xtokens/runtime-benchmarks", - "pallet-rewards/runtime-benchmarks", - "pallet-remarks/runtime-benchmarks", - "pallet-scheduler/runtime-benchmarks", - "pallet-sudo/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", - "pallet-transfer-allowlist/runtime-benchmarks", - "pallet-treasury/runtime-benchmarks", - "pallet-uniques/runtime-benchmarks", - "pallet-utility/runtime-benchmarks", - "pallet-vesting/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", - "pallet-xcm-transactor/runtime-benchmarks", - "pallet-message-queue/runtime-benchmarks", + # Substrate related + "sp-runtime/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", # Optional enabled + "staging-xcm-executor/runtime-benchmarks", + "xcm-primitives/runtime-benchmarks", + "staging-xcm-builder/runtime-benchmarks", + "polkadot-parachain-primitives/runtime-benchmarks", + "cumulus-primitives-core/runtime-benchmarks", + # Locals + "cfg-primitives/runtime-benchmarks", + "cfg-traits/runtime-benchmarks", + "cfg-types/runtime-benchmarks", + "cfg-utils/runtime-benchmarks", + "cfg-mocks/runtime-benchmarks", + # Pallet exporting list + "chainbridge/runtime-benchmarks", + "cumulus-pallet-parachain-system/runtime-benchmarks", + "cumulus-pallet-xcmp-queue/runtime-benchmarks", + "orml-asset-registry/runtime-benchmarks", + "orml-tokens/runtime-benchmarks", + "orml-xtokens/runtime-benchmarks", + "pallet-anchors/runtime-benchmarks", + "pallet-axelar-router/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-block-rewards/runtime-benchmarks", + "pallet-bridge/runtime-benchmarks", + "pallet-collator-allowlist/runtime-benchmarks", + "pallet-collator-selection/runtime-benchmarks", + "pallet-collective/runtime-benchmarks", + "pallet-democracy/runtime-benchmarks", + "pallet-elections-phragmen/runtime-benchmarks", + "pallet-ethereum/runtime-benchmarks", + "pallet-ethereum-transaction/runtime-benchmarks", + "pallet-evm/runtime-benchmarks", + "pallet-fees/runtime-benchmarks", + "pallet-foreign-investments/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", + "pallet-interest-accrual/runtime-benchmarks", + "pallet-investments/runtime-benchmarks", + "pallet-keystore/runtime-benchmarks", + "pallet-liquidity-pools/runtime-benchmarks", + "pallet-liquidity-pools-gateway/runtime-benchmarks", + "pallet-liquidity-pools-gateway-queue/runtime-benchmarks", + "pallet-axelar-router/runtime-benchmarks", + "pallet-liquidity-rewards/runtime-benchmarks", + "pallet-loans/runtime-benchmarks", + "pallet-membership/runtime-benchmarks", + "pallet-multisig/runtime-benchmarks", + "pallet-oracle-collection/runtime-benchmarks", + "pallet-oracle-feed/runtime-benchmarks", + "pallet-order-book/runtime-benchmarks", + "pallet-permissions/runtime-benchmarks", + "pallet-pool-fees/runtime-benchmarks", + "pallet-pool-registry/runtime-benchmarks", + "pallet-pool-system/runtime-benchmarks", + "pallet-preimage/runtime-benchmarks", + "pallet-proxy/runtime-benchmarks", + "pallet-restricted-tokens/runtime-benchmarks", + "pallet-restricted-xtokens/runtime-benchmarks", + "pallet-rewards/runtime-benchmarks", + "pallet-remarks/runtime-benchmarks", + "pallet-scheduler/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "pallet-transfer-allowlist/runtime-benchmarks", + "pallet-treasury/runtime-benchmarks", + "pallet-uniques/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", + "pallet-vesting/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "pallet-xcm-transactor/runtime-benchmarks", + "pallet-message-queue/runtime-benchmarks", ] try-runtime = [ - "sp-runtime/try-runtime", - "cfg-primitives/try-runtime", - "cfg-traits/try-runtime", - "cfg-types/try-runtime", - "cfg-utils/try-runtime", - "cfg-mocks/try-runtime", - "frame-support/try-runtime", - "frame-system/try-runtime", - # Pallet exporting list - "chainbridge/try-runtime", - "cumulus-pallet-aura-ext/try-runtime", - "cumulus-pallet-parachain-system/try-runtime", - "cumulus-pallet-xcm/try-runtime", - "cumulus-pallet-xcmp-queue/try-runtime", - "orml-asset-registry/try-runtime", - "orml-tokens/try-runtime", - "orml-xcm/try-runtime", - "orml-xtokens/try-runtime", - "pallet-anchors/try-runtime", - "pallet-aura/try-runtime", - "pallet-authorship/try-runtime", - "pallet-axelar-router/try-runtime", - "pallet-balances/try-runtime", - "pallet-base-fee/try-runtime", - "pallet-block-rewards/try-runtime", - "pallet-bridge/try-runtime", - "pallet-collator-allowlist/try-runtime", - "pallet-collator-selection/try-runtime", - "pallet-collective/try-runtime", - "pallet-democracy/try-runtime", - "pallet-elections-phragmen/try-runtime", - "pallet-ethereum/try-runtime", - "pallet-ethereum-transaction/try-runtime", - "pallet-evm/try-runtime", - "pallet-evm-chain-id/try-runtime", - "pallet-fees/try-runtime", - "pallet-foreign-investments/try-runtime", - "pallet-identity/try-runtime", - "pallet-interest-accrual/try-runtime", - "pallet-investments/try-runtime", - "pallet-keystore/try-runtime", - "pallet-liquidity-pools/try-runtime", - "pallet-liquidity-pools-gateway/try-runtime", - "liquidity-pools-gateway-routers/try-runtime", - "pallet-liquidity-rewards/try-runtime", - "pallet-loans/try-runtime", - "pallet-membership/try-runtime", - "pallet-multisig/try-runtime", - "pallet-oracle-collection/try-runtime", - "pallet-oracle-feed/try-runtime", - "pallet-order-book/try-runtime", - "pallet-permissions/try-runtime", - "pallet-pool-fees/try-runtime", - "pallet-pool-registry/try-runtime", - "pallet-pool-system/try-runtime", - "pallet-preimage/try-runtime", - "pallet-proxy/try-runtime", - "pallet-restricted-tokens/try-runtime", - "pallet-restricted-xtokens/try-runtime", - "pallet-rewards/try-runtime", - "pallet-remarks/try-runtime", - "pallet-scheduler/try-runtime", - "pallet-session/try-runtime", - "pallet-sudo/try-runtime", - "pallet-timestamp/try-runtime", - "pallet-transaction-payment/try-runtime", - "pallet-transfer-allowlist/try-runtime", - "pallet-treasury/try-runtime", - "pallet-uniques/try-runtime", - "pallet-utility/try-runtime", - "pallet-vesting/try-runtime", - "pallet-xcm/try-runtime", - "pallet-xcm-transactor/try-runtime", - "pallet-message-queue/try-runtime", - "staging-parachain-info/try-runtime", + "sp-runtime/try-runtime", + "cfg-primitives/try-runtime", + "cfg-traits/try-runtime", + "cfg-types/try-runtime", + "cfg-utils/try-runtime", + "cfg-mocks/try-runtime", + "frame-support/try-runtime", + "frame-system/try-runtime", + # Pallet exporting list + "chainbridge/try-runtime", + "cumulus-pallet-aura-ext/try-runtime", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", + "orml-asset-registry/try-runtime", + "orml-tokens/try-runtime", + "orml-xcm/try-runtime", + "orml-xtokens/try-runtime", + "pallet-anchors/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", + "pallet-axelar-router/try-runtime", + "pallet-balances/try-runtime", + "pallet-base-fee/try-runtime", + "pallet-block-rewards/try-runtime", + "pallet-bridge/try-runtime", + "pallet-collator-allowlist/try-runtime", + "pallet-collator-selection/try-runtime", + "pallet-collective/try-runtime", + "pallet-democracy/try-runtime", + "pallet-elections-phragmen/try-runtime", + "pallet-ethereum/try-runtime", + "pallet-ethereum-transaction/try-runtime", + "pallet-evm/try-runtime", + "pallet-evm-chain-id/try-runtime", + "pallet-fees/try-runtime", + "pallet-foreign-investments/try-runtime", + "pallet-identity/try-runtime", + "pallet-interest-accrual/try-runtime", + "pallet-investments/try-runtime", + "pallet-keystore/try-runtime", + "pallet-liquidity-pools/try-runtime", + "pallet-liquidity-pools-gateway/try-runtime", + "pallet-liquidity-pools-gateway-queue/try-runtime", + "pallet-axelar-router/try-runtime", + "pallet-liquidity-rewards/try-runtime", + "pallet-loans/try-runtime", + "pallet-membership/try-runtime", + "pallet-multisig/try-runtime", + "pallet-oracle-collection/try-runtime", + "pallet-oracle-feed/try-runtime", + "pallet-order-book/try-runtime", + "pallet-permissions/try-runtime", + "pallet-pool-fees/try-runtime", + "pallet-pool-registry/try-runtime", + "pallet-pool-system/try-runtime", + "pallet-preimage/try-runtime", + "pallet-proxy/try-runtime", + "pallet-restricted-tokens/try-runtime", + "pallet-restricted-xtokens/try-runtime", + "pallet-rewards/try-runtime", + "pallet-remarks/try-runtime", + "pallet-scheduler/try-runtime", + "pallet-session/try-runtime", + "pallet-sudo/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-transaction-payment/try-runtime", + "pallet-transfer-allowlist/try-runtime", + "pallet-treasury/try-runtime", + "pallet-uniques/try-runtime", + "pallet-utility/try-runtime", + "pallet-vesting/try-runtime", + "pallet-xcm/try-runtime", + "pallet-xcm-transactor/try-runtime", + "pallet-message-queue/try-runtime", + "staging-parachain-info/try-runtime", ] on-chain-release-build = [ - "sp-api/disable-logging", + "sp-api/disable-logging", ] diff --git a/runtime/common/src/migrations/foreign_investments_v2.rs b/runtime/common/src/migrations/foreign_investments_v2.rs index 5bb65e1428..45fd2cc06f 100644 --- a/runtime/common/src/migrations/foreign_investments_v2.rs +++ b/runtime/common/src/migrations/foreign_investments_v2.rs @@ -18,7 +18,7 @@ use sp_std::vec::Vec; pub struct Migration(sp_std::marker::PhantomData); const REMOVAL_LIMIT: u32 = 10u32; -const LOG_PREFIX: &str = "LiquidityPoolsGatewayV1"; +const LOG_PREFIX: &str = "ForeignInvestmentsV2"; impl OnRuntimeUpgrade for Migration where diff --git a/runtime/common/src/migrations/liquidity_pools_gateway.rs b/runtime/common/src/migrations/liquidity_pools_gateway.rs deleted file mode 100644 index 493996a00b..0000000000 --- a/runtime/common/src/migrations/liquidity_pools_gateway.rs +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright 2024 Centrifuge Foundation (centrifuge.io). -// -// This file is part of the Centrifuge chain project. -// Centrifuge is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version (see http://www.gnu.org/licenses). -// Centrifuge is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -use cfg_types::domain_address::Domain; -#[cfg(feature = "try-runtime")] -use frame_support::pallet_prelude::{Decode, Encode}; -use frame_support::{ - pallet_prelude::ValueQuery, - storage_alias, - traits::{Get, OnRuntimeUpgrade}, - weights::Weight, - Blake2_128Concat, -}; -use sp_runtime::DispatchError; -use sp_std::marker::PhantomData; -#[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; - -pub mod clear_outbound_nonce { - use super::*; - - #[storage_alias] - pub type OutboundMessageNonceStore = - StorageValue, u64, ValueQuery>; - - #[storage_alias] - pub type OutboundMessageQueue = StorageMap< - pallet_liquidity_pools_gateway::Pallet, - Blake2_128Concat, - u64, - ( - Domain, - ::AccountId, - pallet_liquidity_pools::Message, - ), - >; - - #[storage_alias] - pub type FailedOutboundMessages = StorageMap< - pallet_liquidity_pools_gateway::Pallet, - Blake2_128Concat, - u64, - ( - Domain, - ::AccountId, - pallet_liquidity_pools::Message, - DispatchError, - ), - >; - - const LOG_PREFIX: &str = "LPGatewayClearNonce"; - - pub struct Migration(PhantomData); - - impl OnRuntimeUpgrade for Migration - where - T: pallet_liquidity_pools_gateway::Config + frame_system::Config, - { - fn on_runtime_upgrade() -> Weight { - let mut weight = Weight::zero(); - OutboundMessageNonceStore::::kill(); - - for (nonce, entry) in OutboundMessageQueue::::iter() { - log::warn!("{LOG_PREFIX}: Found outbound message:\nnonce:{nonce}\nentry:{entry:?}"); - weight.saturating_accrue(T::DbWeight::get().reads(1)); - } - - for (nonce, entry) in FailedOutboundMessages::::iter() { - log::warn!( - "{LOG_PREFIX}: Found failed outbound message:\nnonce:{nonce}\nentry:{entry:?}" - ); - weight.saturating_accrue(T::DbWeight::get().reads(1)); - } - - log::info!("{LOG_PREFIX}: Migration done!"); - - weight - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { - // Extra check to confirm that the storage alias is correct. - assert_eq!( - OutboundMessageQueue::::iter_keys().count(), - 0, - "{LOG_PREFIX}: OutboundMessageQueue should be empty!" - ); - - assert_eq!( - FailedOutboundMessages::::iter_keys().count(), - 0, - "{LOG_PREFIX}: FailedOutboundMessages should be empty!" - ); - - log::info!("{LOG_PREFIX}: Pre checks done!"); - - Ok(Vec::new()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(_: Vec) -> Result<(), sp_runtime::TryRuntimeError> { - assert_eq!( - OutboundMessageNonceStore::::get(), - 0, - "{LOG_PREFIX}: OutboundMessageNonceStore should be 0!" - ); - - assert_eq!( - OutboundMessageQueue::::iter_keys().count(), - 0, - "{LOG_PREFIX}: OutboundMessageQueue should be empty!" - ); - - assert_eq!( - FailedOutboundMessages::::iter_keys().count(), - 0, - "{LOG_PREFIX}: FailedOutboundMessages should be empty!" - ); - - log::info!("{LOG_PREFIX}: Post checks done!"); - - Ok(()) - } - } -} - -pub mod clear_deprecated_domain_router_entries { - use frame_system::pallet_prelude::OriginFor; - use sp_arithmetic::traits::SaturatedConversion; - - use super::*; - pub struct Migration(PhantomData); - - const LOG_PREFIX: &str = "LPGatewayClearDomainRouters"; - - impl OnRuntimeUpgrade for Migration - where - T: pallet_liquidity_pools_gateway::Config - + pallet_xcm_transactor::Config - + pallet_ethereum_transaction::Config - + pallet_evm::Config - + frame_system::Config, - T::AccountId: AsRef<[u8; 32]>, - OriginFor: - From + Into>>, - v0::DomainRouter: sp_std::fmt::Debug, - ::Router: - From>, - { - fn on_runtime_upgrade() -> Weight { - let items = v0::DomainRouters::::iter_keys().count().saturated_into(); - - pallet_liquidity_pools_gateway::DomainRouters::::translate::, _>( - |key, old| { - log::debug!("{LOG_PREFIX}: Inspecting key {key:?} with value\n{old:?}"); - match old { - v0::DomainRouter::AxelarEVM(router) => Some( - liquidity_pools_gateway_routers::DomainRouter::::AxelarEVM(router) - .into(), - ), - // Remove other entries - router => { - log::info!("{LOG_PREFIX} : Removing entry {router:?}!"); - None - } - } - }, - ); - - log::info!( - "{LOG_PREFIX} ON_RUNTIME_UPGRADE: Migration done with {items:?} items in total!" - ); - - T::DbWeight::get().reads_writes(items, items) - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { - let count_total = v0::DomainRouters::::iter_keys().count(); - let count_axelar_evm_router: u64 = v0::DomainRouters::::iter() - .filter(|(domain, router)| { - log::debug!( - "{LOG_PREFIX} PRE: Inspecting key {domain:?} with value\n{router:?}" - ); - matches!(router, v0::DomainRouter::AxelarEVM(_)) - }) - .count() - .saturated_into(); - log::info!( - "{LOG_PREFIX} PRE: Found {count_axelar_evm_router:?} values of - total {count_total:?} to migrate!" - ); - log::info!( - "{LOG_PREFIX} PRE: Checks - done!" - ); - Ok(count_axelar_evm_router.encode()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(pre_state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { - let pre_count: u64 = Decode::decode(&mut pre_state.as_slice()) - .expect("pre_upgrade provides a valid state; qed"); - let post_count: u64 = pallet_liquidity_pools_gateway::DomainRouters::::iter_keys() - .count() - .saturated_into(); - assert_eq!( - pre_count, post_count, - "{LOG_PREFIX} POST: Mismatching number of domain routers after migration!" - ); - - log::info!("{LOG_PREFIX} POST: Checks done!"); - - Ok(()) - } - } - - mod v0 { - use frame_support::{ - pallet_prelude::{Decode, Encode, MaxEncodedLen, OptionQuery, TypeInfo}, - traits::ConstU32, - BoundedVec, - }; - use liquidity_pools_gateway_routers::AxelarEVMRouter; - use sp_core::H160; - use staging_xcm::VersionedLocation; - - use super::*; - - pub const MAX_AXELAR_EVM_CHAIN_SIZE: u32 = 16; - - #[storage_alias] - pub type DomainRouters = StorageMap< - pallet_liquidity_pools_gateway::Pallet, - Blake2_128Concat, - Domain, - DomainRouter, - OptionQuery, - >; - - #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] - pub enum DomainRouter - where - T: pallet_xcm_transactor::Config - + pallet_ethereum_transaction::Config - + pallet_evm::Config, - T::AccountId: AsRef<[u8; 32]>, - OriginFor: - From + Into>>, - { - EthereumXCM(EthereumXCMRouter), - AxelarEVM(AxelarEVMRouter), - AxelarXCM(AxelarXCMRouter), - } - - #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] - pub struct AxelarXCMRouter { - pub router: XCMRouter, - pub axelar_target_chain: BoundedVec>, - pub axelar_target_contract: H160, - } - - #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] - pub struct EthereumXCMRouter { - pub router: XCMRouter, - } - - #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] - pub struct XCMRouter { - pub xcm_domain: XcmDomain, - } - - #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] - pub struct XcmDomain { - pub location: sp_std::boxed::Box, - pub ethereum_xcm_transact_call_index: - BoundedVec>, - pub contract_address: H160, - pub max_gas_limit: u64, - pub transact_required_weight_at_most: Weight, - pub overall_weight: Weight, - pub fee_currency: CurrencyId, - pub fee_amount: u128, - } - } -} diff --git a/runtime/common/src/migrations/liquidity_pools_v2.rs b/runtime/common/src/migrations/liquidity_pools_v2.rs new file mode 100644 index 0000000000..095e39cd57 --- /dev/null +++ b/runtime/common/src/migrations/liquidity_pools_v2.rs @@ -0,0 +1,846 @@ +// Copyright 2024 Centrifuge Foundation (centrifuge.io). +// +// This file is part of the Centrifuge chain project. +// Centrifuge is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version (see http://www.gnu.org/licenses). +// Centrifuge is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +use cfg_types::domain_address::Domain; +#[cfg(feature = "try-runtime")] +use frame_support::pallet_prelude::{Decode, Encode}; +use frame_support::{ + pallet_prelude::ValueQuery, + storage_alias, + traits::{Get, OnRuntimeUpgrade}, + weights::Weight, + Blake2_128Concat, +}; +use pallet_axelar_router::AxelarId; +use sp_runtime::DispatchError; +use sp_std::marker::PhantomData; +#[cfg(feature = "try-runtime")] +use sp_std::vec::Vec; + +use crate::routing::RouterId; + +const LOG_PREFIX: &str = "LpV2"; + +fn maybe_router_id(domain: Domain) -> Option { + match domain.get_evm_chain_id() { + None => { + log::error!( + "{LOG_PREFIX}: Failed derive chain_id from domain {domain:?} because it's not EVM" + ); + None + } + Some(id) => Some(RouterId::Axelar(AxelarId::Evm(id))), + } +} + +pub mod kill_relayer_list { + use frame_support::traits::OnRuntimeUpgrade; + #[cfg(feature = "try-runtime")] + use frame_support::{dispatch::DispatchResult, storage::with_storage_layer}; + #[cfg(feature = "try-runtime")] + use sp_arithmetic::traits::Zero; + #[cfg(feature = "try-runtime")] + use sp_std::vec; + + use super::{types::v0, *}; + use crate::migrations::nuke::storage_clean_res_log; + + const LOG_PREFIX: &str = "ClearRelayerList"; + + pub struct Migration(PhantomData); + + impl OnRuntimeUpgrade for Migration + where + T: pallet_liquidity_pools_gateway::Config, + { + fn on_runtime_upgrade() -> Weight { + let res = v0::RelayerList::::clear(20, None); + storage_clean_res_log(&res, "RelayerList", LOG_PREFIX); + + log::info!("{LOG_PREFIX}: Migration done!"); + + T::DbWeight::get().reads_writes(res.loops.into(), res.unique.into()) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + let mut cleared: bool = false; + + // Need to rollback in order to be NOOP + let _ = with_storage_layer(|| -> DispatchResult { + cleared = v0::RelayerList::::clear(20, None).maybe_cursor.is_none(); + Err(DispatchError::Other("Reverting on purpose")) + }); + assert!(cleared); + + log::info!("{LOG_PREFIX}: Pre checks done!"); + + Ok(vec![]) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + assert!(v0::RelayerList::::iter_keys().count().is_zero()); + log::info!("{LOG_PREFIX}: Post checks done!"); + + Ok(()) + } + } +} + +pub mod v2_update_message_queue { + use pallet_liquidity_pools::Message; + use pallet_liquidity_pools_gateway::message::GatewayMessage; + use sp_arithmetic::traits::SaturatedConversion; + + use super::{types::v2, *}; + + const LOG_PREFIX: &str = "InitMessageQueue"; + + pub struct Migration(PhantomData); + + impl OnRuntimeUpgrade for v2_update_message_queue::Migration + where + T: pallet_liquidity_pools_gateway::Config + + frame_system::Config + + pallet_liquidity_pools_gateway_queue::Config< + MessageNonce = u64, + Message = GatewayMessage, + >, + { + fn on_runtime_upgrade() -> Weight { + let items: u64 = v2::MessageQueue::::iter_keys() + .count() + .saturating_add(v2::FailedMessageQueue::::iter_keys().count()) + .saturated_into(); + + pallet_liquidity_pools_gateway_queue::MessageQueue::::translate_values::< + v2::GatewayMessage, + _, + >(|message| message.migrate()); + + pallet_liquidity_pools_gateway_queue::FailedMessageQueue::::translate_values::< + (v2::GatewayMessage, DispatchError), + _, + >(|(message, error)| message.migrate().map(|m| (m, error))); + + log::info!("{LOG_PREFIX}: Migration done with {items} in total!"); + + T::DbWeight::get().reads_writes(items, items) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + assert!( + v2::MessageQueue::::iter_values().all(|message| match message { + v2::GatewayMessage::::Inbound { + domain_address, .. + } => maybe_router_id(domain_address.domain()).is_some(), + v2::GatewayMessage::::Outbound { + destination, .. + } => maybe_router_id(destination).is_some(), + }) + ); + assert!(v2::FailedMessageQueue::::iter_values() + .into_iter() + .all(|(message, _)| match message { + v2::GatewayMessage::::Inbound { + domain_address, .. + } => maybe_router_id(domain_address.domain()).is_some(), + v2::GatewayMessage::::Outbound { + destination, .. + } => maybe_router_id(destination).is_some(), + })); + + let pending_v2: u64 = v2::MessageQueue::::iter_keys().count().saturated_into(); + let failed_v2: u64 = v2::FailedMessageQueue::::iter_keys() + .count() + .saturated_into(); + + let pending_v3: u64 = + pallet_liquidity_pools_gateway_queue::MessageQueue::::iter_keys() + .count() + .saturated_into(); + let failed_v3: u64 = + pallet_liquidity_pools_gateway_queue::FailedMessageQueue::::iter_keys() + .count() + .saturated_into(); + + log::info!( + "{LOG_PREFIX}: Pre checks done with {pending_v2} items in v2::MessageQueue, {pending_v3} in v3::MessageQueue and {failed_v2} items in FailedMessageQueue and {failed_v3} in v3::FailedMessageQueue!" + ); + + Ok(( + pending_v2.saturating_add(pending_v3), + failed_v2.saturating_add(failed_v3), + ) + .encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(pre_state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + let (pre_pending, pre_failed): (u64, u64) = Decode::decode(&mut pre_state.as_slice()) + .expect("pre_upgrade provides a valid state; qed"); + + let pending: u64 = pallet_liquidity_pools_gateway_queue::MessageQueue::::iter_keys() + .count() + .saturated_into(); + let failed: u64 = + pallet_liquidity_pools_gateway_queue::FailedMessageQueue::::iter_keys() + .count() + .saturated_into(); + + assert_eq!( + pre_pending, pending, + "{LOG_PREFIX} POST: Mismatching number of pending messages in queue after migration!" + ); + assert_eq!( + pre_failed, failed, + "{LOG_PREFIX} POST: Mismatching number of failed messages in queue after migration!" + ); + + log::info!("{LOG_PREFIX}: Post checks done!"); + + Ok(()) + } + } +} + +pub mod v0_init_message_queue { + use pallet_liquidity_pools::Message; + use pallet_liquidity_pools_gateway::message::GatewayMessage; + use sp_arithmetic::traits::{SaturatedConversion, Saturating}; + + use super::{ + types::v0::{FailedOutboundMessages, OutboundMessageNonceStore, OutboundMessageQueue}, + *, + }; + + const LOG_PREFIX: &str = "InitMessageQueue"; + + pub struct Migration(PhantomData); + + impl OnRuntimeUpgrade for Migration + where + T: pallet_liquidity_pools_gateway::Config + + frame_system::Config + + pallet_liquidity_pools_gateway_queue::Config< + MessageNonce = u64, + Message = GatewayMessage, + >, + { + fn on_runtime_upgrade() -> Weight { + let reads = 0u64; + let writes = 0u64; + OutboundMessageNonceStore::::kill(); + + pallet_liquidity_pools_gateway_queue::MessageNonceStore::::put(0u64); + Self::migrate_message_queue(reads, writes); + Self::migrate_failed_message_queue(reads, writes); + log::info!("{LOG_PREFIX}: Migration done!"); + + // Add weight from killing and setting nonce store + T::DbWeight::get().reads_writes(reads.saturating_add(1), writes.saturating_add(2)) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + assert!(OutboundMessageQueue::::iter_values() + .into_iter() + .all(|(domain, _, _)| maybe_router_id(domain).is_some())); + assert!(FailedOutboundMessages::::iter_values() + .into_iter() + .all(|(domain, _, _, _)| maybe_router_id(domain).is_some())); + + let pending: u64 = OutboundMessageQueue::::iter_keys() + .count() + .saturated_into(); + let failed: u64 = FailedOutboundMessages::::iter_keys() + .count() + .saturated_into(); + + log::info!("{LOG_PREFIX}: Pre checks done with {pending} items in OutboundMessageQueue and {failed} items in FailedOutboundMessages!"); + + Ok((pending, failed).encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(pre_state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + let (pre_pending, pre_failed): (u64, u64) = Decode::decode(&mut pre_state.as_slice()) + .expect("pre_upgrade provides a valid state; qed"); + + let pending: u64 = pallet_liquidity_pools_gateway_queue::MessageQueue::::iter_keys() + .count() + .saturated_into(); + let failed: u64 = + pallet_liquidity_pools_gateway_queue::FailedMessageQueue::::iter_keys() + .count() + .saturated_into(); + + assert_eq!( + pre_pending, pending, + "{LOG_PREFIX} POST: Mismatching number of pending messages in queue after migration!" + ); + assert_eq!( + pre_failed, failed, + "{LOG_PREFIX} POST: Mismatching number of failed messages in queue after migration!" + ); + + log::info!("{LOG_PREFIX}: Post checks done!"); + + Ok(()) + } + } + + impl Migration + where + T: pallet_liquidity_pools_gateway::Config + + frame_system::Config + + pallet_liquidity_pools_gateway_queue::Config< + MessageNonce = u64, + Message = GatewayMessage, + >, + { + fn migrate_message_queue(mut reads: u64, mut writes: u64) { + let n: u64 = FailedOutboundMessages::::iter_keys() + .count() + .saturated_into(); + log::info!("{LOG_PREFIX}: Initiating migration of {n} outbound messages"); + reads.saturating_accrue(n); + + for (nonce, (domain, _, message)) in OutboundMessageQueue::::iter().drain() { + // Should never be none since target are outbound messages + if let Some(router_id) = maybe_router_id(domain) { + log::info!( + "{LOG_PREFIX}: Migrating outbound domain {domain:?} message {message:?}" + ); + + pallet_liquidity_pools_gateway_queue::MessageQueue::::insert( + nonce, + GatewayMessage::Outbound { message, router_id }, + ); + + writes.saturating_accrue(2); + } else { + writes.saturating_accrue(1); + continue; + } + } + } + + fn migrate_failed_message_queue(mut reads: u64, mut writes: u64) { + let n: u64 = FailedOutboundMessages::::iter_keys() + .count() + .saturated_into(); + log::info!("{LOG_PREFIX}: Initiating migration of {n} failed outbound messages"); + reads.saturating_accrue(n); + + for (nonce, (domain, _, message, err)) in FailedOutboundMessages::::iter().drain() { + if let Some(router_id) = maybe_router_id(domain) { + log::info!( + "{LOG_PREFIX}: Migrating failed outbound domain {domain:?} message {message:?}" + ); + + // Should never be none since target are outbound messages + pallet_liquidity_pools_gateway_queue::FailedMessageQueue::::insert( + nonce, + (GatewayMessage::Outbound { message, router_id }, err), + ); + writes.saturating_accrue(2); + } else { + writes.saturating_accrue(1); + continue; + } + } + } + } +} + +pub mod init_axelar_router { + use cfg_types::EVMChainId; + #[cfg(feature = "try-runtime")] + use frame_support::storage::transactional; + use frame_support::{ + dispatch::DispatchResult, + traits::{GetStorageVersion, OriginTrait, StorageVersion}, + }; + use frame_system::pallet_prelude::OriginFor; + #[cfg(feature = "try-runtime")] + use sp_arithmetic::traits::SaturatedConversion; + use sp_arithmetic::traits::Saturating; + use sp_std::boxed::Box; + + use super::{ + types::{v0, v2}, + *, + }; + pub struct Migration(PhantomData); + + const LOG_PREFIX: &str = "DomainRoutersToAxelarConfig"; + + impl OnRuntimeUpgrade for Migration + where + T: pallet_liquidity_pools_gateway::Config + + pallet_liquidity_pools_gateway_queue::Config + + pallet_xcm_transactor::Config + + pallet_ethereum_transaction::Config + + pallet_axelar_router::Config + + pallet_evm::Config + + frame_system::Config, + T::AccountId: AsRef<[u8; 32]>, + OriginFor: + From + Into>>, + v0::DomainRouter: sp_std::fmt::Debug, + v2::DomainRouter: sp_std::fmt::Debug, + { + fn on_runtime_upgrade() -> Weight { + let (reads, writes) = Self::migrate_domain_routers().unwrap_or_default(); + log::info!( + "{LOG_PREFIX} ON_RUNTIME_UPGRADE: Migration done with {writes:?} updated domains!" + ); + + T::DbWeight::get().reads_writes(reads, writes.saturating_add(1)) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + let mut writes = 0u64; + + // Need to rollback in order to be NOOP + let _ = transactional::with_storage_layer(|| -> DispatchResult { + let (r, w) = Self::migrate_domain_routers()?; + log::info!("{LOG_PREFIX} PRE Migration counts {w:?} updated domains and {} removed domains", r.saturating_sub(w)); + writes = w; + Err(DispatchError::Other("Reverting on purpose")) + }); + + log::info!("{LOG_PREFIX} PRE: Checks done with {writes} domains!"); + + Ok(writes.encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(pre_state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + let pre_count: u64 = Decode::decode(&mut pre_state.as_slice()) + .expect("pre_upgrade provides a valid state; qed"); + let post_count: u64 = pallet_axelar_router::Configuration::::iter_keys() + .count() + .saturated_into(); + assert_eq!( + pre_count, post_count, + "{LOG_PREFIX} POST: Mismatching number of configured domains in axelar router after migration!" + ); + assert_eq!( + pallet_axelar_router::Configuration::::iter_keys().count(), + pallet_axelar_router::ChainNameById::::iter_keys().count(), + ); + + log::info!("{LOG_PREFIX} POST: Checks done!"); + + Ok(()) + } + } + + impl Migration + where + T: pallet_liquidity_pools_gateway::Config + + pallet_liquidity_pools_gateway_queue::Config + + pallet_xcm_transactor::Config + + pallet_ethereum_transaction::Config + + pallet_axelar_router::Config + + pallet_evm::Config + + frame_system::Config, + T::AccountId: AsRef<[u8; 32]>, + OriginFor: + From + Into>>, + v0::DomainRouter: sp_std::fmt::Debug, + v2::DomainRouter: sp_std::fmt::Debug, + { + fn migrate_domain_routers() -> Result<(u64, u64), DispatchError> { + match pallet_liquidity_pools_gateway::Pallet::::on_chain_storage_version() { + // Altair + Centrifuge chains + zero if zero == StorageVersion::new(0) => Self::v0_migrate_domain_routers(), + // Dev + Demo chains + two if two == StorageVersion::new(2) => Self::v2_migrate_domain_routers(), + z => { + log::error!("Unexpected storage version {z:?}, must be either 0 or 2. Skipping domain router migration"); + Err(DispatchError::Other("Unexpected storage version")) + } + } + } + + fn v0_migrate_domain_routers() -> Result<(u64, u64), DispatchError> { + let mut reads: u64 = 0; + let mut writes: u64 = 0; + for (domain, val) in v0::DomainRouters::::iter() { + log::debug!("{LOG_PREFIX}: Inspecting key {domain:?} with value\n{val:?}"); + reads.saturating_accrue(1); + + let chain_id = match domain.get_evm_chain_id() { + None => { + log::info!("{LOG_PREFIX}: Skipping domain {domain:?} because it's not EVM"); + continue; + } + Some(id) => id, + }; + + match val { + v0::DomainRouter::AxelarEVM(axelar) => { + Self::migrate_axelar_evm(axelar, chain_id, &domain)?; + writes.saturating_accrue(1); + } + v0::DomainRouter::EthereumXCM(_) => { + log::info!( + "{LOG_PREFIX} Removing v0::EthereumXCM router for domain {domain:?}" + ); + } + v0::DomainRouter::AxelarXCM(_) => { + log::info!( + "{LOG_PREFIX} Removing v0::AxelarXCM router for domain {domain:?}" + ); + } + } + } + + Ok((reads, writes)) + } + + fn v2_migrate_domain_routers() -> Result<(u64, u64), DispatchError> { + let mut reads: u64 = 0; + let mut writes: u64 = 0; + for (domain, domain_router) in v2::DomainRouters::::iter() { + log::debug!( + "{LOG_PREFIX}: Inspecting key {domain:?} with domain router\n{domain_router:?}" + ); + reads.saturating_accrue(1); + + let chain_id = match domain.get_evm_chain_id() { + None => { + log::info!("{LOG_PREFIX}: Skipping domain {domain:?} because it's not EVM"); + continue; + } + Some(id) => id, + }; + Self::migrate_axelar_evm(domain_router.into(), chain_id, &domain)?; + writes.saturating_accrue(1); + } + + Ok((reads, writes)) + } + + fn migrate_axelar_evm( + router: v0::AxelarEVMRouter, + chain_id: EVMChainId, + domain: &Domain, + ) -> DispatchResult { + pallet_axelar_router::Pallet::::set_config( + T::RuntimeOrigin::root(), + router.evm_chain.clone(), + Box::new(router.migrate_to_domain_config(chain_id)), + ) + .map_err(|e| { + log::error!( + "{LOG_PREFIX}: Failed to set axelar config for {domain:?} due to error \n{e:?}" + ); + e + })?; + + Ok(()) + } + } +} + +mod types { + use super::*; + + pub(crate) mod v2 { + use cfg_types::domain_address::{Domain, DomainAddress}; + use frame_support::{ + pallet_prelude::{Decode, Encode, MaxEncodedLen, OptionQuery, TypeInfo}, + storage_alias, Blake2_128Concat, + }; + use frame_system::pallet_prelude::OriginFor; + use pallet_liquidity_pools::Message; + use sp_runtime::DispatchError; + + use super::v0::AxelarEVMRouter; + use crate::{migrations::liquidity_pools_v2::maybe_router_id, routing::RouterId}; + + #[storage_alias] + pub type MessageQueue = StorageMap< + pallet_liquidity_pools_gateway::Pallet, + Blake2_128Concat, + u64, + GatewayMessage<::AccountId, Message>, + OptionQuery, + >; + + #[storage_alias] + pub type FailedMessageQueue = StorageMap< + pallet_liquidity_pools_gateway::Pallet, + Blake2_128Concat, + u64, + ( + GatewayMessage<::AccountId, Message>, + DispatchError, + ), + OptionQuery, + >; + + #[storage_alias] + pub type DomainRouters = StorageMap< + pallet_liquidity_pools_gateway::Pallet, + Blake2_128Concat, + Domain, + DomainRouter, + OptionQuery, + >; + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub enum DomainRouter + where + T: pallet_ethereum_transaction::Config + pallet_evm::Config, + T::AccountId: AsRef<[u8; 32]>, + OriginFor: + From + Into>>, + { + AxelarEVM(AxelarEVMRouter), + } + + impl From> for AxelarEVMRouter + where + T: pallet_ethereum_transaction::Config + pallet_evm::Config, + T::AccountId: AsRef<[u8; 32]>, + OriginFor: + From + Into>>, + { + fn from(value: DomainRouter) -> Self { + match value { + DomainRouter::AxelarEVM(t) => t, + } + } + } + + #[derive(Debug, Encode, Decode, Clone, Eq, MaxEncodedLen, PartialEq, TypeInfo)] + pub enum GatewayMessage { + Inbound { + domain_address: DomainAddress, + message: Message, + }, + Outbound { + sender: AccountId, + destination: Domain, + message: Message, + }, + } + + impl GatewayMessage { + pub(crate) fn migrate( + self, + ) -> Option> + { + match self { + GatewayMessage::Inbound { + domain_address, + message, + } => maybe_router_id(domain_address.domain()).map(|router_id| { + pallet_liquidity_pools_gateway::message::GatewayMessage::< + Message, + RouterId, + >::Inbound { + domain_address, + message, + router_id, + } + }), + GatewayMessage::Outbound { + message, + destination, + .. + } => maybe_router_id(destination).map(|router_id| { + pallet_liquidity_pools_gateway::message::GatewayMessage::< + Message, + RouterId, + >::Outbound { + message, + router_id, + } + }), + } + } + } + } + + pub(crate) mod v0 { + use cfg_types::{domain_address::DomainAddress, EVMChainId}; + use frame_support::{ + pallet_prelude::{Decode, Encode, MaxEncodedLen, OptionQuery, TypeInfo}, + traits::ConstU32, + BoundedVec, + }; + use frame_system::pallet_prelude::OriginFor; + use pallet_axelar_router::{AxelarConfig, DomainConfig, EvmConfig, FeeValues}; + use pallet_liquidity_pools::Message; + use sp_core::{H160, H256}; + use staging_xcm::VersionedLocation; + + use super::*; + + pub const MAX_AXELAR_EVM_CHAIN_SIZE: u32 = 16; + + #[storage_alias] + pub type OutboundMessageNonceStore = + StorageValue, u64, ValueQuery>; + + #[storage_alias] + pub type OutboundMessageQueue = StorageMap< + pallet_liquidity_pools_gateway::Pallet, + Blake2_128Concat, + u64, + (Domain, ::AccountId, Message), + >; + + #[storage_alias] + pub type FailedOutboundMessages = StorageMap< + pallet_liquidity_pools_gateway::Pallet, + Blake2_128Concat, + u64, + ( + Domain, + ::AccountId, + Message, + DispatchError, + ), + >; + + #[storage_alias] + pub type RelayerList = StorageDoubleMap< + pallet_liquidity_pools_gateway::Pallet, + Blake2_128Concat, + Domain, + Blake2_128Concat, + DomainAddress, + (), + >; + + #[storage_alias] + pub type DomainRouters = StorageMap< + pallet_liquidity_pools_gateway::Pallet, + Blake2_128Concat, + Domain, + DomainRouter, + OptionQuery, + >; + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub enum DomainRouter + where + T: pallet_xcm_transactor::Config + + pallet_ethereum_transaction::Config + + pallet_evm::Config, + T::AccountId: AsRef<[u8; 32]>, + OriginFor: + From + Into>>, + { + EthereumXCM(EthereumXCMRouter), + AxelarEVM(AxelarEVMRouter), + AxelarXCM(AxelarXCMRouter), + } + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub struct AxelarEVMRouter + where + T: pallet_ethereum_transaction::Config + pallet_evm::Config, + OriginFor: + From + Into>>, + { + pub router: EVMRouter, + pub evm_chain: BoundedVec>, + pub liquidity_pools_contract_address: H160, + } + + impl AxelarEVMRouter + where + T: pallet_ethereum_transaction::Config + pallet_evm::Config, + OriginFor: + From + Into>>, + { + pub(crate) fn migrate_to_domain_config(&self, chain_id: EVMChainId) -> AxelarConfig { + AxelarConfig { + liquidity_pools_contract_address: self.liquidity_pools_contract_address, + domain: DomainConfig::Evm(EvmConfig { + chain_id, + target_contract_address: self.router.evm_domain.target_contract_address, + target_contract_hash: self.router.evm_domain.target_contract_hash, + fee_values: self.router.evm_domain.fee_values.clone(), + }), + } + } + } + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub struct EVMRouter + where + T: pallet_ethereum_transaction::Config + pallet_evm::Config, + OriginFor: + From + Into>>, + { + pub evm_domain: EVMDomain, + pub _marker: PhantomData, + } + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub struct EVMDomain { + /// The address of the contract deployed in our EVM. + pub target_contract_address: H160, + + /// The `BlakeTwo256` hash of the target contract code. + /// + /// This is used during router initialization to ensure that the + /// correct contract code is used. + pub target_contract_hash: H256, + + /// The values used when executing the EVM call. + pub fee_values: FeeValues, + } + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub struct AxelarXCMRouter { + pub router: XCMRouter, + pub axelar_target_chain: BoundedVec>, + pub axelar_target_contract: H160, + } + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub struct EthereumXCMRouter { + pub router: XCMRouter, + } + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub struct XCMRouter { + pub xcm_domain: XcmDomain, + } + + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + pub struct XcmDomain { + pub location: sp_std::boxed::Box, + pub ethereum_xcm_transact_call_index: + BoundedVec>, + pub contract_address: H160, + pub max_gas_limit: u64, + pub transact_required_weight_at_most: Weight, + pub overall_weight: Weight, + pub fee_currency: CurrencyId, + pub fee_amount: u128, + } + } +} diff --git a/runtime/common/src/migrations/mod.rs b/runtime/common/src/migrations/mod.rs index 8a2dbcc331..d83ca8eba6 100644 --- a/runtime/common/src/migrations/mod.rs +++ b/runtime/common/src/migrations/mod.rs @@ -14,7 +14,7 @@ pub mod foreign_investments_v2; pub mod increase_storage_version; -pub mod liquidity_pools_gateway; +pub mod liquidity_pools_v2; pub mod nuke; pub mod permissions_v1; pub mod precompile_account_codes; diff --git a/runtime/common/src/migrations/nuke.rs b/runtime/common/src/migrations/nuke.rs index c781e2cc89..a83bac7603 100644 --- a/runtime/common/src/migrations/nuke.rs +++ b/runtime/common/src/migrations/nuke.rs @@ -19,6 +19,8 @@ use frame_support::{ traits::{Get, OnRuntimeUpgrade, PalletInfoAccess, StorageVersion}, weights::{RuntimeDbWeight, Weight}, }; +use scale_info::prelude::format; +use sp_io::MultiRemovalResults; #[cfg(feature = "try-runtime")] use sp_runtime::DispatchError; #[cfg(feature = "try-runtime")] @@ -151,22 +153,7 @@ where log::info!("Nuke-{}: nuking pallet...", Pallet::name()); let result = unhashed::clear_prefix(&pallet_prefix::(), None, None); - match result.maybe_cursor { - None => log::info!("Nuke-{}: storage cleared successful", Pallet::name()), - Some(_) => { - // TODO: Should we loop over maybe_cursor as a new prefix? - // By now, returning error. - log::error!("Nuke-{}: storage not totally cleared", Pallet::name()) - } - } - - log::info!( - "Nuke-{}: iteration result. backend: {} unique: {} loops: {}", - Pallet::name(), - result.backend, - result.unique, - result.loops, - ); + storage_clean_res_log(&result, "", &format!("Nuke-{}", Pallet::name())); Pallet::current_storage_version().put::(); @@ -219,3 +206,19 @@ pub fn contains_prefixed_key_skip_storage_version(pref } } } + +pub fn storage_clean_res_log(res: &MultiRemovalResults, storage_prefix: &str, log_prefix: &str) { + match res.maybe_cursor { + None => log::info!("{log_prefix}: Cleared all {storage_prefix} storage entries"), + Some(_) => { + log::error!("{log_prefix}: {storage_prefix} storage not totally cleared",) + } + } + + log::info!( + "{log_prefix} Clear result of {storage_prefix}: backend: {} unique: {} loops: {}", + res.backend, + res.unique, + res.loops, + ); +} diff --git a/runtime/development/src/lib.rs b/runtime/development/src/lib.rs index 99064f2f83..fce23c90bf 100644 --- a/runtime/development/src/lib.rs +++ b/runtime/development/src/lib.rs @@ -176,7 +176,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("centrifuge-devel"), impl_name: create_runtime_str!("centrifuge-devel"), authoring_version: 1, - spec_version: 1402, + spec_version: 1403, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -272,25 +272,25 @@ impl Contains for BaseCallFilter { fn contains(c: &RuntimeCall) -> bool { match c { RuntimeCall::PolkadotXcm(method) => match method { - // Block these calls when called by a signed extrinsic. - // Root will still be able to execute these. - pallet_xcm::Call::execute { .. } - | pallet_xcm::Call::transfer_assets { .. } - | pallet_xcm::Call::teleport_assets { .. } // deprecated - | pallet_xcm::Call::reserve_transfer_assets { .. } // deprecated - | pallet_xcm::Call::limited_reserve_transfer_assets { .. } - | pallet_xcm::Call::limited_teleport_assets { .. } => false, - pallet_xcm::Call::__Ignore { .. } => { - unimplemented!() - } - // Allow all these calls. Only send(..) is callable by signed the rest needs root. - pallet_xcm::Call::send { .. } - | pallet_xcm::Call::force_xcm_version { .. } - | pallet_xcm::Call::force_suspension { .. } - | pallet_xcm::Call::force_default_xcm_version { .. } - | pallet_xcm::Call::force_subscribe_version_notify { .. } - | pallet_xcm::Call::force_unsubscribe_version_notify { .. } => true, - }, + // Block these calls when called by a signed extrinsic. + // Root will still be able to execute these. + pallet_xcm::Call::execute { .. } + | pallet_xcm::Call::transfer_assets { .. } + | pallet_xcm::Call::teleport_assets { .. } // deprecated + | pallet_xcm::Call::reserve_transfer_assets { .. } // deprecated + | pallet_xcm::Call::limited_reserve_transfer_assets { .. } + | pallet_xcm::Call::limited_teleport_assets { .. } => false, + pallet_xcm::Call::__Ignore { .. } => { + unimplemented!() + } + // Allow all these calls. Only send(..) is callable by signed the rest needs root. + pallet_xcm::Call::send { .. } + | pallet_xcm::Call::force_xcm_version { .. } + | pallet_xcm::Call::force_suspension { .. } + | pallet_xcm::Call::force_default_xcm_version { .. } + | pallet_xcm::Call::force_subscribe_version_notify { .. } + | pallet_xcm::Call::force_unsubscribe_version_notify { .. } => true, + }, // We block this call since it includes Moonbeam trait implementations such // as UtilityEncodeCall and XcmTransact that we don't implement and don't want // arbitrary users calling it. @@ -2132,7 +2132,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - crate::migrations::UpgradeDevelopment1402, + crate::migrations::UpgradeDevelopment1403, >; // Frame Order in this block dictates the index of each one in the metadata diff --git a/runtime/development/src/migrations.rs b/runtime/development/src/migrations.rs index f154e76666..19ec695e22 100644 --- a/runtime/development/src/migrations.rs +++ b/runtime/development/src/migrations.rs @@ -14,4 +14,14 @@ use frame_support::migrations::VersionedMigration; use crate::Runtime; -pub type UpgradeDevelopment1402 = VersionedMigration<1, 2, runtime_common::migrations::liquidity_pools_gateway::clear_deprecated_domain_router_entries::Migration, pallet_liquidity_pools_gateway::Pallet, ::DbWeight>; +pub type UpgradeDevelopment1403 = ( + runtime_common::migrations::liquidity_pools_v2::kill_relayer_list::Migration, + runtime_common::migrations::liquidity_pools_v2::v2_update_message_queue::Migration, + VersionedMigration< + 2, + 3, + runtime_common::migrations::liquidity_pools_v2::init_axelar_router::Migration, + pallet_liquidity_pools_gateway::Pallet, + ::DbWeight, + >, +); From 0b8a1a6d341fbe2d6840b598b8f35de59412b220 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Tue, 3 Sep 2024 08:59:56 +0200 Subject: [PATCH 5/6] fmt: taplo --- Cargo.toml | 94 +++---- runtime/common/Cargo.toml | 520 +++++++++++++++++++------------------- 2 files changed, 307 insertions(+), 307 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8075bfd741..c88e5c2c7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,49 +1,49 @@ [workspace] resolver = "2" members = [ - "node", - "libs/mocks", - "libs/primitives", - "libs/test-utils", - "libs/traits", - "libs/types", - "libs/utils", - "pallets/anchors", - "pallets/anchors-v2", - "pallets/axelar-router", - "pallets/bridge", - "pallets/block-rewards", - "pallets/collator-allowlist", - "pallets/ethereum-transaction", - "pallets/fees", - "pallets/foreign-investments", - "pallets/interest-accrual", - "pallets/investments", - "pallets/keystore", - "pallets/liquidity-pools", - "pallets/liquidity-pools-gateway", - "pallets/liquidity-pools-gateway-queue", - "pallets/liquidity-pools-forwarder", - "pallets/liquidity-rewards", - "pallets/loans", - "pallets/oracle-feed", - "pallets/oracle-collection", - "pallets/order-book", - "pallets/permissions", - "pallets/pool-fees", - "pallets/pool-system", - "pallets/pool-registry", - "pallets/restricted-tokens", - "pallets/restricted-xtokens", - "pallets/rewards", - "pallets/token-mux", - "pallets/transfer-allowlist", - "runtime/altair", - "runtime/centrifuge", - "runtime/development", - "runtime/common", - "runtime/integration-tests", - "runtime/integration-tests/procedural", + "node", + "libs/mocks", + "libs/primitives", + "libs/test-utils", + "libs/traits", + "libs/types", + "libs/utils", + "pallets/anchors", + "pallets/anchors-v2", + "pallets/axelar-router", + "pallets/bridge", + "pallets/block-rewards", + "pallets/collator-allowlist", + "pallets/ethereum-transaction", + "pallets/fees", + "pallets/foreign-investments", + "pallets/interest-accrual", + "pallets/investments", + "pallets/keystore", + "pallets/liquidity-pools", + "pallets/liquidity-pools-gateway", + "pallets/liquidity-pools-gateway-queue", + "pallets/liquidity-pools-forwarder", + "pallets/liquidity-rewards", + "pallets/loans", + "pallets/oracle-feed", + "pallets/oracle-collection", + "pallets/order-book", + "pallets/permissions", + "pallets/pool-fees", + "pallets/pool-system", + "pallets/pool-registry", + "pallets/restricted-tokens", + "pallets/restricted-xtokens", + "pallets/rewards", + "pallets/token-mux", + "pallets/transfer-allowlist", + "runtime/altair", + "runtime/centrifuge", + "runtime/development", + "runtime/common", + "runtime/integration-tests", + "runtime/integration-tests/procedural", ] [workspace.package] @@ -176,7 +176,7 @@ frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", defau frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, features = [ - "tuples-96", + "tuples-96", ], branch = "release-polkadot-v1.7.2" } # Check when tuples-96 can be removed frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" } @@ -288,14 +288,14 @@ pallet-remarks = { git = "https://github.com/foss3/runtime-pallet-library", bran # Moonbeam fork of polkadot-evm/frontier fp-rpc = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } fp-self-contained = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2", features = [ - "serde", + "serde", ] } pallet-base-fee = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } pallet-ethereum = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2", features = [ - "forbid-evm-reentrancy", + "forbid-evm-reentrancy", ] } pallet-evm = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2", features = [ - "forbid-evm-reentrancy", + "forbid-evm-reentrancy", ] } pallet-evm-chain-id = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } pallet-evm-precompile-blake2 = { git = "https://github.com/moonbeam-foundation/frontier", default-features = false, branch = "moonbeam-polkadot-v1.7.2" } diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index a3f7f1d261..90348cb518 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -132,270 +132,270 @@ cfg-mocks = { workspace = true, default-features = true } [features] default = ["std"] std = [ - "parity-scale-codec/std", - "log/std", - # Substrate related - "frame-support/std", - "frame-system/std", - "frame-benchmarking?/std", - "orml-traits/std", - "orml-tokens/std", - "pallet-anchors/std", - "pallet-authorship/std", - "pallet-balances/std", - "pallet-base-fee/std", - "pallet-ethereum/std", - "pallet-evm-chain-id/std", - "pallet-evm-precompile-balances-erc20/std", - "pallet-evm-precompile-blake2/std", - "pallet-evm-precompile-bn128/std", - "pallet-evm-precompile-dispatch/std", - "pallet-evm-precompile-modexp/std", - "pallet-evm-precompile-sha3fips/std", - "pallet-evm-precompile-simple/std", - "precompile-utils/std", - "polkadot-parachain-primitives/std", - "cumulus-primitives-core/std", - "scale-info/std", - "serde/std", - "sp-api/std", - "sp-arithmetic/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", - "staging-xcm-executor/std", - "xcm-primitives/std", - "staging-xcm-builder/std", - "staging-xcm/std", - # Locals - "cfg-primitives/std", - "cfg-traits/std", - "cfg-types/std", - "cfg-utils/std", - # Pallet exporting list - "chainbridge/std", - "cumulus-pallet-aura-ext/std", - "cumulus-pallet-parachain-system/std", - "cumulus-pallet-xcm/std", - "cumulus-pallet-xcmp-queue/std", - "orml-asset-registry/std", - "orml-tokens/std", - "orml-xcm/std", - "orml-xtokens/std", - "pallet-anchors/std", - "pallet-aura/std", - "pallet-authorship/std", - "pallet-axelar-router/std", - "pallet-balances/std", - "pallet-base-fee/std", - "pallet-block-rewards/std", - "pallet-bridge/std", - "pallet-collator-allowlist/std", - "pallet-collator-selection/std", - "pallet-collective/std", - "pallet-democracy/std", - "pallet-elections-phragmen/std", - "pallet-ethereum/std", - "pallet-ethereum-transaction/std", - "pallet-evm/std", - "pallet-evm-chain-id/std", - "pallet-fees/std", - "pallet-foreign-investments/std", - "pallet-identity/std", - "pallet-interest-accrual/std", - "pallet-investments/std", - "pallet-keystore/std", - "pallet-liquidity-pools/std", - "pallet-liquidity-pools-gateway/std", - "pallet-liquidity-pools-gateway-queue/std", - "pallet-axelar-router/std", - "pallet-liquidity-rewards/std", - "pallet-loans/std", - "pallet-membership/std", - "pallet-multisig/std", - "pallet-oracle-collection/std", - "pallet-oracle-feed/std", - "pallet-order-book/std", - "pallet-permissions/std", - "pallet-pool-fees/std", - "pallet-pool-registry/std", - "pallet-pool-system/std", - "pallet-preimage/std", - "pallet-proxy/std", - "pallet-restricted-tokens/std", - "pallet-restricted-xtokens/std", - "pallet-rewards/std", - "pallet-remarks/std", - "pallet-scheduler/std", - "pallet-session/std", - "pallet-sudo/std", - "pallet-timestamp/std", - "pallet-transaction-payment/std", - "pallet-transfer-allowlist/std", - "pallet-treasury/std", - "pallet-uniques/std", - "pallet-utility/std", - "pallet-vesting/std", - "pallet-xcm/std", - "pallet-xcm-transactor/std", - "pallet-message-queue/std", - "staging-parachain-info/std", + "parity-scale-codec/std", + "log/std", + # Substrate related + "frame-support/std", + "frame-system/std", + "frame-benchmarking?/std", + "orml-traits/std", + "orml-tokens/std", + "pallet-anchors/std", + "pallet-authorship/std", + "pallet-balances/std", + "pallet-base-fee/std", + "pallet-ethereum/std", + "pallet-evm-chain-id/std", + "pallet-evm-precompile-balances-erc20/std", + "pallet-evm-precompile-blake2/std", + "pallet-evm-precompile-bn128/std", + "pallet-evm-precompile-dispatch/std", + "pallet-evm-precompile-modexp/std", + "pallet-evm-precompile-sha3fips/std", + "pallet-evm-precompile-simple/std", + "precompile-utils/std", + "polkadot-parachain-primitives/std", + "cumulus-primitives-core/std", + "scale-info/std", + "serde/std", + "sp-api/std", + "sp-arithmetic/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "staging-xcm-executor/std", + "xcm-primitives/std", + "staging-xcm-builder/std", + "staging-xcm/std", + # Locals + "cfg-primitives/std", + "cfg-traits/std", + "cfg-types/std", + "cfg-utils/std", + # Pallet exporting list + "chainbridge/std", + "cumulus-pallet-aura-ext/std", + "cumulus-pallet-parachain-system/std", + "cumulus-pallet-xcm/std", + "cumulus-pallet-xcmp-queue/std", + "orml-asset-registry/std", + "orml-tokens/std", + "orml-xcm/std", + "orml-xtokens/std", + "pallet-anchors/std", + "pallet-aura/std", + "pallet-authorship/std", + "pallet-axelar-router/std", + "pallet-balances/std", + "pallet-base-fee/std", + "pallet-block-rewards/std", + "pallet-bridge/std", + "pallet-collator-allowlist/std", + "pallet-collator-selection/std", + "pallet-collective/std", + "pallet-democracy/std", + "pallet-elections-phragmen/std", + "pallet-ethereum/std", + "pallet-ethereum-transaction/std", + "pallet-evm/std", + "pallet-evm-chain-id/std", + "pallet-fees/std", + "pallet-foreign-investments/std", + "pallet-identity/std", + "pallet-interest-accrual/std", + "pallet-investments/std", + "pallet-keystore/std", + "pallet-liquidity-pools/std", + "pallet-liquidity-pools-gateway/std", + "pallet-liquidity-pools-gateway-queue/std", + "pallet-axelar-router/std", + "pallet-liquidity-rewards/std", + "pallet-loans/std", + "pallet-membership/std", + "pallet-multisig/std", + "pallet-oracle-collection/std", + "pallet-oracle-feed/std", + "pallet-order-book/std", + "pallet-permissions/std", + "pallet-pool-fees/std", + "pallet-pool-registry/std", + "pallet-pool-system/std", + "pallet-preimage/std", + "pallet-proxy/std", + "pallet-restricted-tokens/std", + "pallet-restricted-xtokens/std", + "pallet-rewards/std", + "pallet-remarks/std", + "pallet-scheduler/std", + "pallet-session/std", + "pallet-sudo/std", + "pallet-timestamp/std", + "pallet-transaction-payment/std", + "pallet-transfer-allowlist/std", + "pallet-treasury/std", + "pallet-uniques/std", + "pallet-utility/std", + "pallet-vesting/std", + "pallet-xcm/std", + "pallet-xcm-transactor/std", + "pallet-message-queue/std", + "staging-parachain-info/std", ] runtime-benchmarks = [ - # Substrate related - "sp-runtime/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "frame-benchmarking/runtime-benchmarks", # Optional enabled - "staging-xcm-executor/runtime-benchmarks", - "xcm-primitives/runtime-benchmarks", - "staging-xcm-builder/runtime-benchmarks", - "polkadot-parachain-primitives/runtime-benchmarks", - "cumulus-primitives-core/runtime-benchmarks", - # Locals - "cfg-primitives/runtime-benchmarks", - "cfg-traits/runtime-benchmarks", - "cfg-types/runtime-benchmarks", - "cfg-utils/runtime-benchmarks", - "cfg-mocks/runtime-benchmarks", - # Pallet exporting list - "chainbridge/runtime-benchmarks", - "cumulus-pallet-parachain-system/runtime-benchmarks", - "cumulus-pallet-xcmp-queue/runtime-benchmarks", - "orml-asset-registry/runtime-benchmarks", - "orml-tokens/runtime-benchmarks", - "orml-xtokens/runtime-benchmarks", - "pallet-anchors/runtime-benchmarks", - "pallet-axelar-router/runtime-benchmarks", - "pallet-balances/runtime-benchmarks", - "pallet-block-rewards/runtime-benchmarks", - "pallet-bridge/runtime-benchmarks", - "pallet-collator-allowlist/runtime-benchmarks", - "pallet-collator-selection/runtime-benchmarks", - "pallet-collective/runtime-benchmarks", - "pallet-democracy/runtime-benchmarks", - "pallet-elections-phragmen/runtime-benchmarks", - "pallet-ethereum/runtime-benchmarks", - "pallet-ethereum-transaction/runtime-benchmarks", - "pallet-evm/runtime-benchmarks", - "pallet-fees/runtime-benchmarks", - "pallet-foreign-investments/runtime-benchmarks", - "pallet-identity/runtime-benchmarks", - "pallet-interest-accrual/runtime-benchmarks", - "pallet-investments/runtime-benchmarks", - "pallet-keystore/runtime-benchmarks", - "pallet-liquidity-pools/runtime-benchmarks", - "pallet-liquidity-pools-gateway/runtime-benchmarks", - "pallet-liquidity-pools-gateway-queue/runtime-benchmarks", - "pallet-axelar-router/runtime-benchmarks", - "pallet-liquidity-rewards/runtime-benchmarks", - "pallet-loans/runtime-benchmarks", - "pallet-membership/runtime-benchmarks", - "pallet-multisig/runtime-benchmarks", - "pallet-oracle-collection/runtime-benchmarks", - "pallet-oracle-feed/runtime-benchmarks", - "pallet-order-book/runtime-benchmarks", - "pallet-permissions/runtime-benchmarks", - "pallet-pool-fees/runtime-benchmarks", - "pallet-pool-registry/runtime-benchmarks", - "pallet-pool-system/runtime-benchmarks", - "pallet-preimage/runtime-benchmarks", - "pallet-proxy/runtime-benchmarks", - "pallet-restricted-tokens/runtime-benchmarks", - "pallet-restricted-xtokens/runtime-benchmarks", - "pallet-rewards/runtime-benchmarks", - "pallet-remarks/runtime-benchmarks", - "pallet-scheduler/runtime-benchmarks", - "pallet-sudo/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", - "pallet-transfer-allowlist/runtime-benchmarks", - "pallet-treasury/runtime-benchmarks", - "pallet-uniques/runtime-benchmarks", - "pallet-utility/runtime-benchmarks", - "pallet-vesting/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", - "pallet-xcm-transactor/runtime-benchmarks", - "pallet-message-queue/runtime-benchmarks", + # Substrate related + "sp-runtime/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", # Optional enabled + "staging-xcm-executor/runtime-benchmarks", + "xcm-primitives/runtime-benchmarks", + "staging-xcm-builder/runtime-benchmarks", + "polkadot-parachain-primitives/runtime-benchmarks", + "cumulus-primitives-core/runtime-benchmarks", + # Locals + "cfg-primitives/runtime-benchmarks", + "cfg-traits/runtime-benchmarks", + "cfg-types/runtime-benchmarks", + "cfg-utils/runtime-benchmarks", + "cfg-mocks/runtime-benchmarks", + # Pallet exporting list + "chainbridge/runtime-benchmarks", + "cumulus-pallet-parachain-system/runtime-benchmarks", + "cumulus-pallet-xcmp-queue/runtime-benchmarks", + "orml-asset-registry/runtime-benchmarks", + "orml-tokens/runtime-benchmarks", + "orml-xtokens/runtime-benchmarks", + "pallet-anchors/runtime-benchmarks", + "pallet-axelar-router/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-block-rewards/runtime-benchmarks", + "pallet-bridge/runtime-benchmarks", + "pallet-collator-allowlist/runtime-benchmarks", + "pallet-collator-selection/runtime-benchmarks", + "pallet-collective/runtime-benchmarks", + "pallet-democracy/runtime-benchmarks", + "pallet-elections-phragmen/runtime-benchmarks", + "pallet-ethereum/runtime-benchmarks", + "pallet-ethereum-transaction/runtime-benchmarks", + "pallet-evm/runtime-benchmarks", + "pallet-fees/runtime-benchmarks", + "pallet-foreign-investments/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", + "pallet-interest-accrual/runtime-benchmarks", + "pallet-investments/runtime-benchmarks", + "pallet-keystore/runtime-benchmarks", + "pallet-liquidity-pools/runtime-benchmarks", + "pallet-liquidity-pools-gateway/runtime-benchmarks", + "pallet-liquidity-pools-gateway-queue/runtime-benchmarks", + "pallet-axelar-router/runtime-benchmarks", + "pallet-liquidity-rewards/runtime-benchmarks", + "pallet-loans/runtime-benchmarks", + "pallet-membership/runtime-benchmarks", + "pallet-multisig/runtime-benchmarks", + "pallet-oracle-collection/runtime-benchmarks", + "pallet-oracle-feed/runtime-benchmarks", + "pallet-order-book/runtime-benchmarks", + "pallet-permissions/runtime-benchmarks", + "pallet-pool-fees/runtime-benchmarks", + "pallet-pool-registry/runtime-benchmarks", + "pallet-pool-system/runtime-benchmarks", + "pallet-preimage/runtime-benchmarks", + "pallet-proxy/runtime-benchmarks", + "pallet-restricted-tokens/runtime-benchmarks", + "pallet-restricted-xtokens/runtime-benchmarks", + "pallet-rewards/runtime-benchmarks", + "pallet-remarks/runtime-benchmarks", + "pallet-scheduler/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "pallet-transfer-allowlist/runtime-benchmarks", + "pallet-treasury/runtime-benchmarks", + "pallet-uniques/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", + "pallet-vesting/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "pallet-xcm-transactor/runtime-benchmarks", + "pallet-message-queue/runtime-benchmarks", ] try-runtime = [ - "sp-runtime/try-runtime", - "cfg-primitives/try-runtime", - "cfg-traits/try-runtime", - "cfg-types/try-runtime", - "cfg-utils/try-runtime", - "cfg-mocks/try-runtime", - "frame-support/try-runtime", - "frame-system/try-runtime", - # Pallet exporting list - "chainbridge/try-runtime", - "cumulus-pallet-aura-ext/try-runtime", - "cumulus-pallet-parachain-system/try-runtime", - "cumulus-pallet-xcm/try-runtime", - "cumulus-pallet-xcmp-queue/try-runtime", - "orml-asset-registry/try-runtime", - "orml-tokens/try-runtime", - "orml-xcm/try-runtime", - "orml-xtokens/try-runtime", - "pallet-anchors/try-runtime", - "pallet-aura/try-runtime", - "pallet-authorship/try-runtime", - "pallet-axelar-router/try-runtime", - "pallet-balances/try-runtime", - "pallet-base-fee/try-runtime", - "pallet-block-rewards/try-runtime", - "pallet-bridge/try-runtime", - "pallet-collator-allowlist/try-runtime", - "pallet-collator-selection/try-runtime", - "pallet-collective/try-runtime", - "pallet-democracy/try-runtime", - "pallet-elections-phragmen/try-runtime", - "pallet-ethereum/try-runtime", - "pallet-ethereum-transaction/try-runtime", - "pallet-evm/try-runtime", - "pallet-evm-chain-id/try-runtime", - "pallet-fees/try-runtime", - "pallet-foreign-investments/try-runtime", - "pallet-identity/try-runtime", - "pallet-interest-accrual/try-runtime", - "pallet-investments/try-runtime", - "pallet-keystore/try-runtime", - "pallet-liquidity-pools/try-runtime", - "pallet-liquidity-pools-gateway/try-runtime", - "pallet-liquidity-pools-gateway-queue/try-runtime", - "pallet-axelar-router/try-runtime", - "pallet-liquidity-rewards/try-runtime", - "pallet-loans/try-runtime", - "pallet-membership/try-runtime", - "pallet-multisig/try-runtime", - "pallet-oracle-collection/try-runtime", - "pallet-oracle-feed/try-runtime", - "pallet-order-book/try-runtime", - "pallet-permissions/try-runtime", - "pallet-pool-fees/try-runtime", - "pallet-pool-registry/try-runtime", - "pallet-pool-system/try-runtime", - "pallet-preimage/try-runtime", - "pallet-proxy/try-runtime", - "pallet-restricted-tokens/try-runtime", - "pallet-restricted-xtokens/try-runtime", - "pallet-rewards/try-runtime", - "pallet-remarks/try-runtime", - "pallet-scheduler/try-runtime", - "pallet-session/try-runtime", - "pallet-sudo/try-runtime", - "pallet-timestamp/try-runtime", - "pallet-transaction-payment/try-runtime", - "pallet-transfer-allowlist/try-runtime", - "pallet-treasury/try-runtime", - "pallet-uniques/try-runtime", - "pallet-utility/try-runtime", - "pallet-vesting/try-runtime", - "pallet-xcm/try-runtime", - "pallet-xcm-transactor/try-runtime", - "pallet-message-queue/try-runtime", - "staging-parachain-info/try-runtime", + "sp-runtime/try-runtime", + "cfg-primitives/try-runtime", + "cfg-traits/try-runtime", + "cfg-types/try-runtime", + "cfg-utils/try-runtime", + "cfg-mocks/try-runtime", + "frame-support/try-runtime", + "frame-system/try-runtime", + # Pallet exporting list + "chainbridge/try-runtime", + "cumulus-pallet-aura-ext/try-runtime", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", + "orml-asset-registry/try-runtime", + "orml-tokens/try-runtime", + "orml-xcm/try-runtime", + "orml-xtokens/try-runtime", + "pallet-anchors/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", + "pallet-axelar-router/try-runtime", + "pallet-balances/try-runtime", + "pallet-base-fee/try-runtime", + "pallet-block-rewards/try-runtime", + "pallet-bridge/try-runtime", + "pallet-collator-allowlist/try-runtime", + "pallet-collator-selection/try-runtime", + "pallet-collective/try-runtime", + "pallet-democracy/try-runtime", + "pallet-elections-phragmen/try-runtime", + "pallet-ethereum/try-runtime", + "pallet-ethereum-transaction/try-runtime", + "pallet-evm/try-runtime", + "pallet-evm-chain-id/try-runtime", + "pallet-fees/try-runtime", + "pallet-foreign-investments/try-runtime", + "pallet-identity/try-runtime", + "pallet-interest-accrual/try-runtime", + "pallet-investments/try-runtime", + "pallet-keystore/try-runtime", + "pallet-liquidity-pools/try-runtime", + "pallet-liquidity-pools-gateway/try-runtime", + "pallet-liquidity-pools-gateway-queue/try-runtime", + "pallet-axelar-router/try-runtime", + "pallet-liquidity-rewards/try-runtime", + "pallet-loans/try-runtime", + "pallet-membership/try-runtime", + "pallet-multisig/try-runtime", + "pallet-oracle-collection/try-runtime", + "pallet-oracle-feed/try-runtime", + "pallet-order-book/try-runtime", + "pallet-permissions/try-runtime", + "pallet-pool-fees/try-runtime", + "pallet-pool-registry/try-runtime", + "pallet-pool-system/try-runtime", + "pallet-preimage/try-runtime", + "pallet-proxy/try-runtime", + "pallet-restricted-tokens/try-runtime", + "pallet-restricted-xtokens/try-runtime", + "pallet-rewards/try-runtime", + "pallet-remarks/try-runtime", + "pallet-scheduler/try-runtime", + "pallet-session/try-runtime", + "pallet-sudo/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-transaction-payment/try-runtime", + "pallet-transfer-allowlist/try-runtime", + "pallet-treasury/try-runtime", + "pallet-uniques/try-runtime", + "pallet-utility/try-runtime", + "pallet-vesting/try-runtime", + "pallet-xcm/try-runtime", + "pallet-xcm-transactor/try-runtime", + "pallet-message-queue/try-runtime", + "staging-parachain-info/try-runtime", ] on-chain-release-build = [ - "sp-api/disable-logging", + "sp-api/disable-logging", ] From bf97ee805ed145ed527fe03dd076b427e4e05234 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Thu, 5 Sep 2024 15:51:02 +0200 Subject: [PATCH 6/6] fix: mut --- .../common/src/migrations/liquidity_pools_v2.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/runtime/common/src/migrations/liquidity_pools_v2.rs b/runtime/common/src/migrations/liquidity_pools_v2.rs index 095e39cd57..4d52c57158 100644 --- a/runtime/common/src/migrations/liquidity_pools_v2.rs +++ b/runtime/common/src/migrations/liquidity_pools_v2.rs @@ -239,14 +239,14 @@ pub mod v0_init_message_queue { >, { fn on_runtime_upgrade() -> Weight { - let reads = 0u64; - let writes = 0u64; + let mut reads = 0u64; + let mut writes = 0u64; OutboundMessageNonceStore::::kill(); pallet_liquidity_pools_gateway_queue::MessageNonceStore::::put(0u64); - Self::migrate_message_queue(reads, writes); - Self::migrate_failed_message_queue(reads, writes); - log::info!("{LOG_PREFIX}: Migration done!"); + Self::migrate_message_queue(&mut reads, &mut writes); + Self::migrate_failed_message_queue(&mut reads, &mut writes); + log::info!("{LOG_PREFIX}: Migration done with {reads} reads and {writes} writes!"); // Add weight from killing and setting nonce store T::DbWeight::get().reads_writes(reads.saturating_add(1), writes.saturating_add(2)) @@ -310,7 +310,7 @@ pub mod v0_init_message_queue { Message = GatewayMessage, >, { - fn migrate_message_queue(mut reads: u64, mut writes: u64) { + fn migrate_message_queue(reads: &mut u64, writes: &mut u64) { let n: u64 = FailedOutboundMessages::::iter_keys() .count() .saturated_into(); @@ -337,7 +337,7 @@ pub mod v0_init_message_queue { } } - fn migrate_failed_message_queue(mut reads: u64, mut writes: u64) { + fn migrate_failed_message_queue(reads: &mut u64, writes: &mut u64) { let n: u64 = FailedOutboundMessages::::iter_keys() .count() .saturated_into();