diff --git a/Cargo.dev.toml b/Cargo.dev.toml index bdcd37adf..fd44629fe 100644 --- a/Cargo.dev.toml +++ b/Cargo.dev.toml @@ -37,71 +37,71 @@ resolver = "2" split-debuginfo = "unpacked" [patch.'https://github.com/paritytech/substrate'] -frame-benchmarking = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -frame-support = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -frame-system = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -pallet-authority-discovery = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -pallet-authorship = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -pallet-babe = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -pallet-balances = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -pallet-elections-phragmen = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -pallet-scheduler = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -pallet-session = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -pallet-staking = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -pallet-timestamp = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -pallet-treasury = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -pallet-vesting = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -pallet-transaction-payment = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sc-client-api = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sc-client-db = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sc-executor = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sc-executor-common = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sc-executor-wasmi = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sc-utils = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-api = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-application-crypto = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-arithmetic = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-authority-discovery = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-authorship = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-blockchain = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-consensus = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-consensus-slots = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-core = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-debug-derive = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-externalities = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-inherents = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-io = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-keystore = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-npos-elections = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-panic-handler = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-runtime = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-runtime-interface = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-session = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-staking = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-state-machine = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-std = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-storage = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-timestamp = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-trie = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-version = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-wasm-interface = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-tracing = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } -sp-maybe-compressed-blob = { git = "https://github.com/paritytech//substrate", rev = "946507ba9ef13e263534176b7b74e26fc56efbd4" } +frame-benchmarking = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +frame-support = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +frame-system = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +pallet-authority-discovery = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +pallet-authorship = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +pallet-babe = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +pallet-balances = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +pallet-elections-phragmen = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +pallet-scheduler = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +pallet-session = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +pallet-staking = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +pallet-timestamp = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +pallet-treasury = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +pallet-vesting = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +pallet-transaction-payment = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sc-client-api = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sc-client-db = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sc-executor = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sc-executor-common = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sc-executor-wasmi = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sc-utils = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-api = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-application-crypto = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-arithmetic = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-authority-discovery = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-blockchain = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-consensus = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-consensus-slots = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-core = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-debug-derive = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-externalities = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-inherents = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-io = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-keystore = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-npos-elections = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-panic-handler = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-runtime = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-runtime-interface = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-session = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-staking = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-state-machine = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-std = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-storage = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-timestamp = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-trie = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-version = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-wasm-interface = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-tracing = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-maybe-compressed-blob = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } +sp-weights = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" } [patch.'https://github.com/paritytech/cumulus'] -cumulus-primitives-core = { git = "https://github.com/paritytech//cumulus", rev = "09418fc04c2608b123f36ca80f16df3d2096753b" } -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech//cumulus", rev = "09418fc04c2608b123f36ca80f16df3d2096753b" } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech//cumulus", rev = "09418fc04c2608b123f36ca80f16df3d2096753b" } -cumulus-pallet-xcm = { git = "https://github.com/paritytech//cumulus", rev = "09418fc04c2608b123f36ca80f16df3d2096753b" } -parachain-info = { git = "https://github.com/paritytech//cumulus", rev = "09418fc04c2608b123f36ca80f16df3d2096753b" } +cumulus-primitives-core = { git = "https://github.com/paritytech//cumulus", rev = "1b2003d48f753be96471c5f96c4a2307592db49f" } +cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech//cumulus", rev = "1b2003d48f753be96471c5f96c4a2307592db49f" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech//cumulus", rev = "1b2003d48f753be96471c5f96c4a2307592db49f" } +cumulus-pallet-xcm = { git = "https://github.com/paritytech//cumulus", rev = "1b2003d48f753be96471c5f96c4a2307592db49f" } +parachain-info = { git = "https://github.com/paritytech//cumulus", rev = "1b2003d48f753be96471c5f96c4a2307592db49f" } [patch.'https://github.com/paritytech/polkadot'] -pallet-xcm = { git = "https://github.com/paritytech//polkadot", rev = "645723987cf9662244be8faf4e9b63e8b9a1b3a3" } -polkadot-core-primitives = { git = "https://github.com/paritytech//polkadot", rev = "645723987cf9662244be8faf4e9b63e8b9a1b3a3" } -polkadot-runtime-parachains = { git = "https://github.com/paritytech//polkadot", rev = "645723987cf9662244be8faf4e9b63e8b9a1b3a3" } -polkadot-parachain = { git = "https://github.com/paritytech//polkadot", rev = "645723987cf9662244be8faf4e9b63e8b9a1b3a3" } -polkadot-primitives = { git = "https://github.com/paritytech//polkadot", rev = "645723987cf9662244be8faf4e9b63e8b9a1b3a3" } -xcm = { git = "https://github.com/paritytech//polkadot", rev = "645723987cf9662244be8faf4e9b63e8b9a1b3a3" } -xcm-executor = { git = "https://github.com/paritytech//polkadot", rev = "645723987cf9662244be8faf4e9b63e8b9a1b3a3" } -xcm-builder = { git = "https://github.com/paritytech//polkadot", rev = "645723987cf9662244be8faf4e9b63e8b9a1b3a3" } -xcm-simulator = { git = "https://github.com/paritytech//polkadot", rev = "645723987cf9662244be8faf4e9b63e8b9a1b3a3" } +pallet-xcm = { git = "https://github.com/paritytech//polkadot", rev = "72309a2b2e68413305a56dce1097041309bd29c6" } +polkadot-core-primitives = { git = "https://github.com/paritytech//polkadot", rev = "72309a2b2e68413305a56dce1097041309bd29c6" } +polkadot-runtime-parachains = { git = "https://github.com/paritytech//polkadot", rev = "72309a2b2e68413305a56dce1097041309bd29c6" } +polkadot-parachain = { git = "https://github.com/paritytech//polkadot", rev = "72309a2b2e68413305a56dce1097041309bd29c6" } +polkadot-primitives = { git = "https://github.com/paritytech//polkadot", rev = "72309a2b2e68413305a56dce1097041309bd29c6" } +xcm = { git = "https://github.com/paritytech//polkadot", rev = "72309a2b2e68413305a56dce1097041309bd29c6" } +xcm-executor = { git = "https://github.com/paritytech//polkadot", rev = "72309a2b2e68413305a56dce1097041309bd29c6" } +xcm-builder = { git = "https://github.com/paritytech//polkadot", rev = "72309a2b2e68413305a56dce1097041309bd29c6" } +xcm-simulator = { git = "https://github.com/paritytech//polkadot", rev = "72309a2b2e68413305a56dce1097041309bd29c6" } diff --git a/asset-registry/Cargo.toml b/asset-registry/Cargo.toml index 48243c0af..77594e928 100644 --- a/asset-registry/Cargo.toml +++ b/asset-registry/Cargo.toml @@ -13,37 +13,37 @@ serde = { version = "1.0.136", optional = true } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["max-encoded-len"] } # substrate -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } # polkadot -pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.37" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.37" } -xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.37" } -xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.37" } +pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.38" } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.38" } +xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.38" } +xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.38" } # orml orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } [dev-dependencies] # substrate -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } # cumulus -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } +cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.38" } +cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.38" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.38" } +cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.38" } +parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.38" } # polkadot -polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } -polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } -xcm-simulator = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } +polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" } +polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" } +xcm-simulator = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" } # orml orml-tokens = { path = "../tokens" } diff --git a/asset-registry/src/impls.rs b/asset-registry/src/impls.rs index 9bb8e6678..c620784d9 100644 --- a/asset-registry/src/impls.rs +++ b/asset-registry/src/impls.rs @@ -104,7 +104,7 @@ impl WeightTrader for AssetRegistryTrad continue; } - if let Some(fee_increase) = W::convert_weight_to_fee(location, Weight::from_ref_time(weight)) { + if let Some(fee_increase) = W::convert_weight_to_fee(location, weight) { if fee_increase == 0 { // if the fee is set very low it could lead to zero fees, in which case // constructing the fee asset item to subtract from payment would fail. @@ -112,7 +112,7 @@ impl WeightTrader for AssetRegistryTrad return Ok(payment); } - if let Ok(unused) = payment.clone().checked_sub((asset.clone(), fee_increase).into()) { + if let Ok(unused) = payment.clone().checked_sub((*asset, fee_increase).into()) { let (existing_weight, existing_fee) = match self.bought_weight { Some(ref x) => (x.weight, x.amount), None => (Weight::zero(), 0), @@ -120,10 +120,8 @@ impl WeightTrader for AssetRegistryTrad self.bought_weight = Some(BoughtWeight { amount: existing_fee.checked_add(fee_increase).ok_or(XcmError::Overflow)?, - weight: existing_weight - .checked_add(&Weight::from_ref_time(weight)) - .ok_or(XcmError::Overflow)?, - asset_location: location.clone(), + weight: existing_weight.checked_add(&weight).ok_or(XcmError::Overflow)?, + asset_location: *location, }); return Ok(unused); } @@ -138,14 +136,14 @@ impl WeightTrader for AssetRegistryTrad match self.bought_weight { Some(ref mut bought) => { - let new_weight = bought.weight.saturating_sub(Weight::from_ref_time(weight)); + let new_weight = bought.weight.saturating_sub(weight); let new_amount = W::convert_weight_to_fee(&bought.asset_location, new_weight)?; let refunded_amount = bought.amount.saturating_sub(new_amount); bought.weight = new_weight; bought.amount = new_amount; - Some((AssetId::Concrete(bought.asset_location.clone()), refunded_amount).into()) + Some((AssetId::Concrete(bought.asset_location), refunded_amount).into()) } None => None, // nothing to refund } @@ -155,7 +153,7 @@ impl WeightTrader for AssetRegistryTrad impl Drop for AssetRegistryTrader { fn drop(&mut self) { if let Some(ref bought) = self.bought_weight { - R::take_revenue((AssetId::Concrete(bought.asset_location.clone()), bought.amount).into()); + R::take_revenue((AssetId::Concrete(bought.asset_location), bought.amount).into()); } } } diff --git a/asset-registry/src/lib.rs b/asset-registry/src/lib.rs index b9819566f..e2d5cea20 100644 --- a/asset-registry/src/lib.rs +++ b/asset-registry/src/lib.rs @@ -14,7 +14,7 @@ use sp_runtime::{ DispatchResult, }; use sp_std::prelude::*; -use xcm::{v2::prelude::*, VersionedMultiLocation}; +use xcm::{v3::prelude::*, VersionedMultiLocation}; pub use impls::*; pub use module::*; @@ -28,6 +28,9 @@ mod mock; #[cfg(test)] mod tests; +mod migrations; +pub use migrations::Migration; + #[frame_support::pallet] pub mod module { use super::*; @@ -130,8 +133,11 @@ pub mod module { } } + const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); + #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] + #[pallet::storage_version(STORAGE_VERSION)] #[pallet::without_storage_info] pub struct Pallet(_); diff --git a/asset-registry/src/migrations.rs b/asset-registry/src/migrations.rs new file mode 100644 index 000000000..1ce62e72b --- /dev/null +++ b/asset-registry/src/migrations.rs @@ -0,0 +1,43 @@ +use crate::{Config, LocationToAssetId, Pallet, Weight}; +use frame_support::pallet_prelude::*; +use frame_support::{migration::storage_key_iter, traits::OnRuntimeUpgrade, StoragePrefixedMap}; + +use xcm::v3::prelude::*; + +pub struct Migration(PhantomData); +impl OnRuntimeUpgrade for Migration { + fn on_runtime_upgrade() -> Weight { + let mut weight: Weight = Weight::zero(); + let onchain_version = Pallet::::on_chain_storage_version(); + if onchain_version < 2 { + let inner_weight = v2::migrate::(); + weight.saturating_accrue(inner_weight); + } + weight + } +} + +mod v2 { + use super::*; + + pub(crate) fn migrate() -> Weight { + let mut weight: Weight = Weight::zero(); + let module_prefix = LocationToAssetId::::module_prefix(); + let storage_prefix = LocationToAssetId::::storage_prefix(); + + weight.saturating_accrue(T::DbWeight::get().reads(1)); + let old_data = + storage_key_iter::(module_prefix, storage_prefix) + .drain(); + + for (old_key, value) in old_data { + weight.saturating_accrue(T::DbWeight::get().writes(1)); + let new_key: MultiLocation = old_key.try_into().expect("Stored xcm::v2::MultiLocation"); + LocationToAssetId::::insert(new_key, value); + } + + StorageVersion::new(2).put::>(); + weight.saturating_accrue(T::DbWeight::get().writes(1)); + weight + } +} diff --git a/asset-registry/src/mock/mod.rs b/asset-registry/src/mock/mod.rs index a9eecb939..9e347f54f 100644 --- a/asset-registry/src/mock/mod.rs +++ b/asset-registry/src/mock/mod.rs @@ -5,6 +5,7 @@ use super::*; use mock::para::AssetRegistry; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; +use sp_core::bounded::BoundedVec; use sp_io::TestExternalities; use sp_runtime::{traits::Convert, AccountId32}; use xcm_simulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain}; @@ -42,12 +43,54 @@ impl Convert> for CurrencyIdConvert { fn convert(id: CurrencyId) -> Option { match id { CurrencyId::R => Some(Parent.into()), - CurrencyId::A => Some((Parent, Parachain(1), GeneralKey(b"A".to_vec().try_into().unwrap())).into()), - CurrencyId::A1 => Some((Parent, Parachain(1), GeneralKey(b"A1".to_vec().try_into().unwrap())).into()), - CurrencyId::B => Some((Parent, Parachain(2), GeneralKey(b"B".to_vec().try_into().unwrap())).into()), - CurrencyId::B1 => Some((Parent, Parachain(2), GeneralKey(b"B1".to_vec().try_into().unwrap())).into()), - CurrencyId::B2 => Some((Parent, Parachain(2), GeneralKey(b"B2".to_vec().try_into().unwrap())).into()), - CurrencyId::D => Some((Parent, Parachain(4), GeneralKey(b"D".to_vec().try_into().unwrap())).into()), + CurrencyId::A => Some( + ( + Parent, + Parachain(1), + Junction::from(BoundedVec::try_from(b"A".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::A1 => Some( + ( + Parent, + Parachain(1), + Junction::from(BoundedVec::try_from(b"A1".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::B => Some( + ( + Parent, + Parachain(2), + Junction::from(BoundedVec::try_from(b"B".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::B1 => Some( + ( + Parent, + Parachain(2), + Junction::from(BoundedVec::try_from(b"B1".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::B2 => Some( + ( + Parent, + Parachain(2), + Junction::from(BoundedVec::try_from(b"B2".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::D => Some( + ( + Parent, + Parachain(4), + Junction::from(BoundedVec::try_from(b"D".to_vec()).unwrap()), + ) + .into(), + ), CurrencyId::RegisteredAsset(id) => AssetRegistry::multilocation(&id).unwrap_or_default(), } } @@ -65,21 +108,21 @@ impl Convert> for CurrencyIdConvert { } let currency_id = match l.clone() { MultiLocation { parents, interior } if parents == 1 => match interior { - X2(Parachain(1), GeneralKey(k)) if k == a => Some(CurrencyId::A), - X2(Parachain(1), GeneralKey(k)) if k == a1 => Some(CurrencyId::A1), - X2(Parachain(2), GeneralKey(k)) if k == b => Some(CurrencyId::B), - X2(Parachain(2), GeneralKey(k)) if k == b1 => Some(CurrencyId::B1), - X2(Parachain(2), GeneralKey(k)) if k == b2 => Some(CurrencyId::B2), - X2(Parachain(4), GeneralKey(k)) if k == d => Some(CurrencyId::D), + X2(Parachain(1), GeneralKey { data, .. }) if data.to_vec() == a => Some(CurrencyId::A), + X2(Parachain(1), GeneralKey { data, .. }) if data.to_vec() == a1 => Some(CurrencyId::A1), + X2(Parachain(2), GeneralKey { data, .. }) if data.to_vec() == b => Some(CurrencyId::B), + X2(Parachain(2), GeneralKey { data, .. }) if data.to_vec() == b1 => Some(CurrencyId::B1), + X2(Parachain(2), GeneralKey { data, .. }) if data.to_vec() == b2 => Some(CurrencyId::B2), + X2(Parachain(4), GeneralKey { data, .. }) if data.to_vec() == d => Some(CurrencyId::D), _ => None, }, MultiLocation { parents, interior } if parents == 0 => match interior { - X1(GeneralKey(k)) if k == a => Some(CurrencyId::A), - X1(GeneralKey(k)) if k == b => Some(CurrencyId::B), - X1(GeneralKey(k)) if k == a1 => Some(CurrencyId::A1), - X1(GeneralKey(k)) if k == b1 => Some(CurrencyId::B1), - X1(GeneralKey(k)) if k == b2 => Some(CurrencyId::B2), - X1(GeneralKey(k)) if k == d => Some(CurrencyId::D), + X1(GeneralKey { data, .. }) if data.to_vec() == a => Some(CurrencyId::A), + X1(GeneralKey { data, .. }) if data.to_vec() == b => Some(CurrencyId::B), + X1(GeneralKey { data, .. }) if data.to_vec() == a1 => Some(CurrencyId::A1), + X1(GeneralKey { data, .. }) if data.to_vec() == b1 => Some(CurrencyId::B1), + X1(GeneralKey { data, .. }) if data.to_vec() == b2 => Some(CurrencyId::B2), + X1(GeneralKey { data, .. }) if data.to_vec() == d => Some(CurrencyId::D), _ => None, }, _ => None, diff --git a/asset-registry/src/mock/para.rs b/asset-registry/src/mock/para.rs index 2e60a6350..489d709ec 100644 --- a/asset-registry/src/mock/para.rs +++ b/asset-registry/src/mock/para.rs @@ -28,9 +28,9 @@ use sp_runtime::{ }; use xcm::latest::{prelude::*, Weight}; use xcm_builder::{ - AccountId32Aliases, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, LocationInverter, - ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, + AccountId32Aliases, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset, + RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, }; use xcm_executor::{Config, XcmExecutor}; @@ -127,15 +127,17 @@ impl EnsureOriginWithArg> for AssetAuthority { } #[cfg(feature = "runtime-benchmarks")] - fn successful_origin(_asset_id: &Option) -> RuntimeOrigin { + fn try_successful_origin(_asset_id: &Option) -> Result { unimplemented!() } } +pub type ParaAssetId = u32; + impl orml_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Balance = Balance; - type AssetId = u32; + type AssetId = ParaAssetId; type AuthorityOrigin = AssetAuthority; type CustomMetadata = CustomMetadata; type AssetProcessor = orml_asset_registry::SequentialId; @@ -143,8 +145,8 @@ impl orml_asset_registry::Config for Runtime { } parameter_types! { - pub const ReservedXcmpWeight: Weight = WEIGHT_REF_TIME_PER_SECOND / 4; - pub const ReservedDmpWeight: Weight = WEIGHT_REF_TIME_PER_SECOND / 4; + pub const ReservedXcmpWeight: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4)); + pub const ReservedDmpWeight: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4)); } impl parachain_info::Config for Runtime {} @@ -153,7 +155,8 @@ parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Kusama; pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); + pub UniversalLocation: InteriorMultiLocation = + X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())); } pub type LocationToAccountId = ( @@ -214,6 +217,13 @@ impl FixedConversionRateProvider for MyFixedConversionRateProvider { } } +parameter_types! { + pub const UnitWeightCost: Weight = Weight::from_parts(10, 10); + pub const BaseXcmWeight: Weight = Weight::from_parts(100_000_000, 100_000_000); + pub const MaxInstructions: u32 = 100; + pub const MaxAssetsIntoHolding: u32 = 64; +} + pub struct XcmConfig; impl Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -222,14 +232,23 @@ impl Config for XcmConfig { type OriginConverter = XcmOriginToCallOrigin; type IsReserve = MultiNativeAsset; type IsTeleporter = (); - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; + type Weigher = FixedWeightBounds; type Trader = AssetRegistryWeightTrader; type ResponseHandler = (); type AssetTrap = PolkadotXcm; type AssetClaims = PolkadotXcm; type SubscriptionService = PolkadotXcm; + type AssetLocker = PolkadotXcm; + type AssetExchanger = (); + type PalletInstancesInfo = (); + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } pub struct ChannelInfo; @@ -251,6 +270,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToCallOrigin; type WeightInfo = (); + type PriceForSiblingDelivery = (); } impl cumulus_pallet_dmp_queue::Config for Runtime { @@ -266,6 +286,16 @@ impl cumulus_pallet_xcm::Config for Runtime { pub type LocalOriginToLocation = SignedToAccountId32; +parameter_types! { + pub SelfLocation: MultiLocation = MultiLocation::here(); + pub const MaxAssetsForTransfer: usize = 3; +} + +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parent.into()); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; @@ -275,30 +305,33 @@ impl pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; - type LocationInverter = LocationInverter; + type Weigher = FixedWeightBounds; + type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = (); + type MaxLockers = ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } pub struct AccountIdToMultiLocation; impl Convert for AccountIdToMultiLocation { fn convert(account: AccountId) -> MultiLocation { X1(Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: account.into(), }) .into() } } -parameter_types! { - pub SelfLocation: MultiLocation = MultiLocation::here(); - pub const MaxAssetsForTransfer: usize = 3; -} - match_types! { pub type ParentOrParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Junction::AccountId32 { .. }) } | @@ -331,9 +364,9 @@ impl orml_xtokens::Config for Runtime { type MultiLocationsFilter = ParentOrParachains; type MinXcmFee = ParachainMinFee; type XcmExecutor = XcmExecutor; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; - type BaseXcmWeight = ConstU64<100_000_000>; - type LocationInverter = LocationInverter; + type Weigher = FixedWeightBounds; + type BaseXcmWeight = BaseXcmWeight; + type UniversalLocation = UniversalLocation; type MaxAssetsForTransfer = MaxAssetsForTransfer; type ReserveProvider = RelativeReserveProvider; } diff --git a/asset-registry/src/mock/relay.rs b/asset-registry/src/mock/relay.rs index f6ec6f367..35e581f62 100644 --- a/asset-registry/src/mock/relay.rs +++ b/asset-registry/src/mock/relay.rs @@ -1,7 +1,8 @@ +use crate::Weight; use cumulus_primitives_core::ParaId; use frame_support::{ construct_runtime, parameter_types, - traits::{ConstU128, ConstU32, ConstU64, Everything}, + traits::{ConstU128, ConstU32, ConstU64, Everything, Nothing}, weights::IdentityFee, }; use frame_system::EnsureRoot; @@ -11,7 +12,7 @@ use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, - CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, LocationInverter, SignedAccountId32AsNative, + CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, }; use xcm_executor::{Config, XcmExecutor}; @@ -65,9 +66,9 @@ impl configuration::Config for Runtime { } parameter_types! { - pub const KsmLocation: MultiLocation = Here.into(); + pub KsmLocation: MultiLocation = Here.into(); pub const KusamaNetwork: NetworkId = NetworkId::Kusama; - pub Ancestry: MultiLocation = Here.into(); + pub UniversalLocation: InteriorMultiLocation = Here; } pub type SovereignAccountOf = ( @@ -87,6 +88,12 @@ type LocalOriginConverter = ( pub type XcmRouter = super::RelayChainXcmRouter; pub type Barrier = (TakeWeightCredit, AllowTopLevelPaidExecutionFrom); +parameter_types! { + pub const BaseXcmWeight: Weight = Weight::from_parts(10, 10); + pub const MaxInstructions: u32 = 100; + pub const MaxAssetsIntoHolding: u32 = 64; +} + pub struct XcmConfig; impl Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -95,18 +102,36 @@ impl Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = (); - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; + type Weigher = FixedWeightBounds; type Trader = UsingComponents, KsmLocation, AccountId, Balances, ()>; type ResponseHandler = (); type AssetTrap = (); type AssetClaims = (); type SubscriptionService = XcmPallet; + type AssetLocker = XcmPallet; + type AssetExchanger = (); + type PalletInstancesInfo = (); + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } pub type LocalOriginToLocation = SignedToAccountId32; +parameter_types! { + pub SelfLocation: MultiLocation = MultiLocation::here(); +} + +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(MultiLocation::here()); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; @@ -117,12 +142,20 @@ impl pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; - type LocationInverter = LocationInverter; + type Weigher = FixedWeightBounds; + type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = IsConcrete; + type TrustedLockers = (); + type SovereignAccountOf = (); + type MaxLockers = ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } impl ump::Config for Runtime { diff --git a/asset-registry/src/tests.rs b/asset-registry/src/tests.rs index f204c8c31..4a0f53169 100644 --- a/asset-registry/src/tests.rs +++ b/asset-registry/src/tests.rs @@ -3,7 +3,12 @@ use super::*; use crate as orml_asset_registry; use crate::tests::para::{AdminAssetTwo, AssetRegistry, CustomMetadata, RuntimeOrigin, Tokens, TreasuryAccount}; -use frame_support::{assert_noop, assert_ok}; +use frame_support::{ + assert_noop, assert_ok, + storage::migration::{get_storage_value, put_storage_value}, + traits::OnRuntimeUpgrade, + StorageHasher, +}; use mock::{para::RuntimeCall, *}; use orml_traits::MultiCurrency; use polkadot_parachain::primitives::Sibling; @@ -14,6 +19,10 @@ use sp_runtime::{ }; use xcm_simulator::TestExt; +type OldMultiLocation = xcm::v2::MultiLocation; +type OldJunctions = xcm::v2::Junctions; +type OldJunction = xcm::v2::Junction; + fn treasury_account() -> AccountId32 { TreasuryAccount::get() } @@ -46,7 +55,13 @@ fn dummy_metadata() -> AssetMetadata<>(), 0); + + // V2 storage key + let old_key = xcm::v2::MultiLocation::new( + 0, + xcm::v2::Junctions::X1(xcm::v2::Junction::GeneralKey(vec![0].try_into().unwrap())), + ) + .encode(); + + let asset_id: para::ParaAssetId = 5u32; + + // Store raw xcm::v2 data + put_storage_value( + module_prefix, + storage_prefix, + &Blake2_128Concat::hash(&old_key), + asset_id, + ); + + // V3 storage key + let new_key = MultiLocation::new(0, X1(Junction::from(BoundedVec::try_from(vec![0]).unwrap()))); + + // Assert new StorageKey still does not exist + assert_eq!(AssetRegistry::location_to_asset_id(new_key), None); + + // Run StorageKey migration + crate::Migration::::on_runtime_upgrade(); + + // StorageVersion is 2 after migration + assert_eq!(StorageVersion::get::>(), 2); + + // Assert the StorageKey exists and has been migrated to xcm::v3 + assert_eq!(AssetRegistry::location_to_asset_id(new_key), Some(asset_id)); + + // Assert the old key does not exist anymore + assert!(get_storage_value::( + module_prefix, + storage_prefix, + &Blake2_128Concat::hash(&old_key), + ) + .is_none()); + + // Assert further calls are no-op + assert_eq!(crate::Migration::::on_runtime_upgrade(), Weight::zero()); + }); +} diff --git a/auction/Cargo.toml b/auction/Cargo.toml index 5d3171089..c114847fb 100644 --- a/auction/Cargo.toml +++ b/auction/Cargo.toml @@ -12,16 +12,16 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } [dev-dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } [features] default = ["std"] diff --git a/authority/Cargo.toml b/authority/Cargo.toml index 5545ad373..46fef476d 100644 --- a/authority/Cargo.toml +++ b/authority/Cargo.toml @@ -12,18 +12,18 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } serde = { version = "1.0.145", optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } [dev-dependencies] -pallet-preimage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -pallet-root-testing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +pallet-preimage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +pallet-root-testing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } [features] default = ["std"] diff --git a/authority/src/lib.rs b/authority/src/lib.rs index 506f96578..ae9863c3a 100644 --- a/authority/src/lib.rs +++ b/authority/src/lib.rs @@ -146,7 +146,7 @@ impl< } #[cfg(feature = "runtime-benchmarks")] - fn successful_origin() -> O { + fn try_successful_origin() -> Result { unimplemented!() } } diff --git a/bencher/Cargo.toml b/bencher/Cargo.toml index d71a8a2ba..1a8973e64 100644 --- a/bencher/Cargo.toml +++ b/bencher/Cargo.toml @@ -26,18 +26,18 @@ hash-db = { version = "0.15.2", default-features = false, optional = true } bencher-procedural = { path = "bencher-procedural", default-features = false } codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime-interface = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-state-machine = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.37" } -sc-executor = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.37" } -sc-executor-common = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.37" } -sc-client-db = { git = "https://github.com/paritytech/substrate", default-features = false, features = ["rocksdb"], optional = true , branch = "polkadot-v0.9.37" } -sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.37" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-externalities = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-storage = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.37" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime-interface = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-state-machine = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.38" } +sc-executor = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.38" } +sc-executor-common = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.38" } +sc-client-db = { git = "https://github.com/paritytech/substrate", default-features = false, features = ["rocksdb"], optional = true , branch = "polkadot-v0.9.38" } +sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.38" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-externalities = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-storage = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.38" } [features] default = ["std"] diff --git a/bencher/test/Cargo.toml b/bencher/test/Cargo.toml index e40a5f424..9e9c69c0c 100644 --- a/bencher/test/Cargo.toml +++ b/bencher/test/Cargo.toml @@ -15,16 +15,16 @@ required-features = ["bench"] serde = { version = "1.0.136", optional = true } scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } orml-bencher = { path = "..", default-features = false } orml-weight-meter = { path = "../../weight-meter", default-features = false } [dev-dependencies] -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } [features] default = ["std"] diff --git a/benchmarking/Cargo.toml b/benchmarking/Cargo.toml index ce887694c..31f220b51 100644 --- a/benchmarking/Cargo.toml +++ b/benchmarking/Cargo.toml @@ -14,19 +14,19 @@ paste = "1.0.7" scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } -frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime-interface = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-storage = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime-interface = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-storage = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } [dev-dependencies] hex-literal = "0.3.4" -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } [features] default = [ "std" ] diff --git a/benchmarking/src/lib.rs b/benchmarking/src/lib.rs index f165cb682..20c42ec52 100644 --- a/benchmarking/src/lib.rs +++ b/benchmarking/src/lib.rs @@ -741,6 +741,9 @@ macro_rules! impl_benchmark { $crate::BenchmarkMetadata { name: benchmark.as_bytes().to_vec(), components, + // TODO: Not supported by V2 syntax as of yet. + // https://github.com/paritytech/substrate/issues/13132 + pov_modes: vec![], } }).collect::<$crate::Vec<_>>() } diff --git a/currencies/Cargo.toml b/currencies/Cargo.toml index 78c275980..05e60387b 100644 --- a/currencies/Cargo.toml +++ b/currencies/Cargo.toml @@ -12,18 +12,18 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } orml-utilities = { path = "../utilities", version = "0.4.1-dev", default-features = false } [dev-dependencies] -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } orml_tokens = { package = "orml-tokens", path = "../tokens", version = "0.4.1-dev" } diff --git a/gradually-update/Cargo.toml b/gradually-update/Cargo.toml index 74a8c0534..0ee697ed6 100644 --- a/gradually-update/Cargo.toml +++ b/gradually-update/Cargo.toml @@ -12,12 +12,12 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } [features] default = ["std"] diff --git a/nft/Cargo.toml b/nft/Cargo.toml index 52b785d74..d27bc2a27 100644 --- a/nft/Cargo.toml +++ b/nft/Cargo.toml @@ -12,14 +12,14 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } [dev-dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } [features] default = ["std"] diff --git a/oracle/Cargo.toml b/oracle/Cargo.toml index 2387dbe3f..9857f8700 100644 --- a/oracle/Cargo.toml +++ b/oracle/Cargo.toml @@ -12,18 +12,18 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } orml-utilities = { path = "../utilities", version = "0.4.1-dev", default-features = false } [dev-dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } [features] default = ["std"] diff --git a/oracle/rpc/Cargo.toml b/oracle/rpc/Cargo.toml index 1a3829205..4dfe9759b 100644 --- a/oracle/rpc/Cargo.toml +++ b/oracle/rpc/Cargo.toml @@ -12,8 +12,8 @@ jsonrpsee = { version = "0.16.2", features = ["client", "server", "macros"] } tracing = { version = "0.1.29" } tracing-core = { version = "0.1.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } orml-oracle-rpc-runtime-api = { path = "runtime-api", version = "0.4.1-dev" } diff --git a/oracle/rpc/runtime-api/Cargo.toml b/oracle/rpc/runtime-api/Cargo.toml index e631c46a2..3de1f5a6f 100644 --- a/oracle/rpc/runtime-api/Cargo.toml +++ b/oracle/rpc/runtime-api/Cargo.toml @@ -8,8 +8,8 @@ description = "Runtime API module for orml-oracle-rpc." [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } [features] default = ["std"] diff --git a/payments/Cargo.toml b/payments/Cargo.toml index 477221b65..42f2bc6d5 100644 --- a/payments/Cargo.toml +++ b/payments/Cargo.toml @@ -14,18 +14,18 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } orml-traits = {path = "../traits", version = "0.4.1-dev", default-features = false } [dev-dependencies] serde = { version = "1.0.136" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } orml-tokens = { path = "../tokens", version = "0.4.1-dev", default-features = false } diff --git a/rewards/Cargo.toml b/rewards/Cargo.toml index cb9e20b4c..000cb9ce2 100644 --- a/rewards/Cargo.toml +++ b/rewards/Cargo.toml @@ -12,17 +12,17 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } [dev-dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } [features] default = ["std"] diff --git a/tokens/Cargo.toml b/tokens/Cargo.toml index 4c849f7bc..53705810f 100644 --- a/tokens/Cargo.toml +++ b/tokens/Cargo.toml @@ -12,18 +12,18 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } [dev-dependencies] -pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } [features] default = ["std"] diff --git a/tokens/rpc/Cargo.toml b/tokens/rpc/Cargo.toml index 24cd93bc3..b27dffe96 100644 --- a/tokens/rpc/Cargo.toml +++ b/tokens/rpc/Cargo.toml @@ -12,11 +12,11 @@ jsonrpsee = { version = "0.16.2", features = ["client", "server", "macros"] } tracing = { version = "0.1.29" } tracing-core = { version = "0.1.28" } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } orml-tokens-rpc-runtime-api = { version = "0.4.1-dev", path = "./runtime-api" } diff --git a/tokens/rpc/runtime-api/Cargo.toml b/tokens/rpc/runtime-api/Cargo.toml index 0bc944de9..b5993eeb2 100644 --- a/tokens/rpc/runtime-api/Cargo.toml +++ b/tokens/rpc/runtime-api/Cargo.toml @@ -8,9 +8,9 @@ edition = "2021" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } orml-tokens = { default-features = false, path = "../../../tokens" } [features] diff --git a/traits/Cargo.toml b/traits/Cargo.toml index d498a2546..1eae41bb1 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -14,12 +14,13 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = num-traits = { version = "0.2.14", default-features = false } impl-trait-for-tuples = "0.2.2" -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.37" } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.38" } orml-utilities = { path = "../utilities", version = "0.4.1-dev", default-features = false } @@ -30,6 +31,7 @@ std = [ "codec/std", "scale-info/std", "sp-runtime/std", + "sp-core/std", "sp-io/std", "sp-std/std", "num-traits/std", diff --git a/traits/src/location.rs b/traits/src/location.rs index 14a3fe67f..2604b9bf2 100644 --- a/traits/src/location.rs +++ b/traits/src/location.rs @@ -1,5 +1,4 @@ -use sp_runtime::{traits::ConstU32, WeakBoundedVec}; -use sp_std::prelude::*; +use sp_core::{bounded::BoundedVec, ConstU32}; use xcm::latest::prelude::*; pub trait Parse { @@ -28,7 +27,7 @@ impl Parse for MultiLocation { } fn non_chain_part(&self) -> Option { - let mut junctions = self.interior().clone(); + let mut junctions = *self.interior(); while is_chain_junction(junctions.first()) { let _ = junctions.take_first(); } @@ -78,12 +77,12 @@ impl Reserve for RelativeReserveProvider { } pub trait RelativeLocations { - fn sibling_parachain_general_key(para_id: u32, general_key: WeakBoundedVec>) -> MultiLocation; + fn sibling_parachain_general_key(para_id: u32, general_key: BoundedVec>) -> MultiLocation; } impl RelativeLocations for MultiLocation { - fn sibling_parachain_general_key(para_id: u32, general_key: WeakBoundedVec>) -> MultiLocation { - MultiLocation::new(1, X2(Parachain(para_id), GeneralKey(general_key))) + fn sibling_parachain_general_key(para_id: u32, general_key: BoundedVec>) -> MultiLocation { + return MultiLocation::new(1, X2(Parachain(para_id), general_key.as_bounded_slice().into())); } } @@ -139,14 +138,14 @@ mod tests { assert_eq!( AbsoluteReserveProvider::reserve(&concrete_fungible(MultiLocation::new( 0, - X1(GeneralKey(b"DOT".to_vec().try_into().unwrap())) + X1(Junction::from(BoundedVec::try_from(b"DOT".to_vec()).unwrap())) ))), None ); assert_eq!( RelativeReserveProvider::reserve(&concrete_fungible(MultiLocation::new( 0, - X1(GeneralKey(b"DOT".to_vec().try_into().unwrap())) + X1(Junction::from(BoundedVec::try_from(b"DOT".to_vec()).unwrap())) ))), Some(MultiLocation::here()) ); diff --git a/traits/src/multi_asset.rs b/traits/src/multi_asset.rs index d7c7dd807..e95607386 100644 --- a/traits/src/multi_asset.rs +++ b/traits/src/multi_asset.rs @@ -1,20 +1,15 @@ -use sp_runtime::{traits::ConstU32, WeakBoundedVec}; +use sp_core::{bounded::BoundedVec, ConstU32}; use xcm::latest::prelude::*; use crate::location::RelativeLocations; pub trait ConcreteFungibleAsset { - fn sibling_parachain_asset(para_id: u32, general_key: WeakBoundedVec>, amount: u128) - -> MultiAsset; + fn sibling_parachain_asset(para_id: u32, general_key: BoundedVec>, amount: u128) -> MultiAsset; fn parent_asset(amount: u128) -> MultiAsset; } impl ConcreteFungibleAsset for MultiAsset { - fn sibling_parachain_asset( - para_id: u32, - general_key: WeakBoundedVec>, - amount: u128, - ) -> MultiAsset { + fn sibling_parachain_asset(para_id: u32, general_key: BoundedVec>, amount: u128) -> MultiAsset { ( MultiLocation::sibling_parachain_general_key(para_id, general_key), amount, diff --git a/unknown-tokens/Cargo.toml b/unknown-tokens/Cargo.toml index ba3921aad..263e21c13 100644 --- a/unknown-tokens/Cargo.toml +++ b/unknown-tokens/Cargo.toml @@ -12,18 +12,18 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.37" } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.38" } orml-xcm-support = { path = "../xcm-support", default-features = false } [dev-dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } [features] default = ["std"] diff --git a/unknown-tokens/src/lib.rs b/unknown-tokens/src/lib.rs index be7fee5d2..40ef68959 100644 --- a/unknown-tokens/src/lib.rs +++ b/unknown-tokens/src/lib.rs @@ -12,6 +12,9 @@ pub use module::*; mod mock; mod tests; +mod migrations; +pub use migrations::Migration; + #[frame_support::pallet] pub mod module { use super::*; @@ -40,8 +43,11 @@ pub mod module { UnhandledAsset, } + const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); + #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] + #[pallet::storage_version(STORAGE_VERSION)] #[pallet::without_storage_info] pub struct Pallet(_); @@ -83,7 +89,7 @@ impl UnknownAsset for Pallet { MultiAsset { fun: Fungible(amount), id: Abstract(key), - } => AbstractFungibleBalances::::try_mutate(to, key, |b| -> DispatchResult { + } => AbstractFungibleBalances::::try_mutate(to, key.to_vec(), |b| -> DispatchResult { *b = b.checked_add(*amount).ok_or(Error::::BalanceOverflow)?; Ok(()) }), @@ -92,7 +98,7 @@ impl UnknownAsset for Pallet { Self::deposit_event(Event::Deposited { asset: asset.clone(), - who: to.clone(), + who: *to, }); Ok(()) @@ -110,7 +116,7 @@ impl UnknownAsset for Pallet { MultiAsset { fun: Fungible(amount), id: Abstract(key), - } => AbstractFungibleBalances::::try_mutate(from, key, |b| -> DispatchResult { + } => AbstractFungibleBalances::::try_mutate(from, key.to_vec(), |b| -> DispatchResult { *b = b.checked_sub(*amount).ok_or(Error::::BalanceTooLow)?; Ok(()) }), @@ -119,7 +125,7 @@ impl UnknownAsset for Pallet { Self::deposit_event(Event::Withdrawn { asset: asset.clone(), - who: from.clone(), + who: *from, }); Ok(()) diff --git a/unknown-tokens/src/migrations.rs b/unknown-tokens/src/migrations.rs new file mode 100644 index 000000000..84a36584e --- /dev/null +++ b/unknown-tokens/src/migrations.rs @@ -0,0 +1,82 @@ +use crate::{AbstractFungibleBalances, ConcreteFungibleBalances, Config, Pallet, Weight}; +use frame_support::pallet_prelude::*; +use frame_support::{migration::storage_iter, traits::OnRuntimeUpgrade, ReversibleStorageHasher, StoragePrefixedMap}; + +use sp_std::vec::Vec; + +use xcm::v3::prelude::*; + +pub struct Migration(PhantomData); +impl OnRuntimeUpgrade for Migration { + fn on_runtime_upgrade() -> Weight { + let mut weight: Weight = Weight::zero(); + let onchain_version = Pallet::::on_chain_storage_version(); + if onchain_version < 2 { + let inner_weight = v2::migrate::(); + weight.saturating_accrue(inner_weight); + } + weight + } +} + +mod v2 { + use super::*; + + pub(crate) fn migrate() -> Weight { + let mut weight: Weight = Weight::zero(); + + // ConcreteFungibleBalances + let module_prefix = ConcreteFungibleBalances::::module_prefix(); + let storage_prefix = ConcreteFungibleBalances::::storage_prefix(); + + weight.saturating_accrue(T::DbWeight::get().reads(1)); + + let old_data = storage_iter::(module_prefix, storage_prefix).drain(); + + for (raw_k, value) in old_data { + let mut full_key = Vec::new(); + full_key.extend_from_slice(&raw_k); + + let mut k1_k2_material = Blake2_128Concat::reverse(&full_key); + let k1: xcm::v2::MultiLocation = + Decode::decode(&mut k1_k2_material).expect("Stored k1 xcm::v2::MultiLocation"); + + let mut k2_material = Blake2_128Concat::reverse(k1_k2_material); + let k2: xcm::v2::MultiLocation = + Decode::decode(&mut k2_material).expect("Stored k2 xcm::v2::MultiLocation"); + + weight.saturating_accrue(T::DbWeight::get().writes(1)); + let k1_new: MultiLocation = k1.try_into().expect("Stored k1 xcm::v2::MultiLocation"); + let k2_new: MultiLocation = k2.try_into().expect("Stored k2 xcm::v2::MultiLocation"); + ConcreteFungibleBalances::::insert(k1_new, k2_new, value); + } + + // AbstractFungibleBalances + let module_prefix = AbstractFungibleBalances::::module_prefix(); + let storage_prefix = AbstractFungibleBalances::::storage_prefix(); + + weight.saturating_accrue(T::DbWeight::get().reads(1)); + + let old_data = storage_iter::(module_prefix, storage_prefix).drain(); + + for (raw_k, value) in old_data { + let mut full_key = Vec::new(); + full_key.extend_from_slice(&raw_k); + + let mut k1_k2_material = Blake2_128Concat::reverse(&full_key); + let k1: xcm::v2::MultiLocation = + Decode::decode(&mut k1_k2_material).expect("Stored k1 xcm::v2::MultiLocation"); + + let mut k2_material = Blake2_128Concat::reverse(k1_k2_material); + let k2_new: Vec = Decode::decode(&mut k2_material).expect("Stored k1 xcm::v2::MultiLocation"); + + weight.saturating_accrue(T::DbWeight::get().writes(1)); + let k1_new: MultiLocation = k1.try_into().expect("Stored k1 xcm::v2::MultiLocation"); + AbstractFungibleBalances::::insert(k1_new, k2_new, value); + } + + StorageVersion::new(2).put::>(); + weight.saturating_accrue(T::DbWeight::get().writes(1)); + weight + } +} diff --git a/unknown-tokens/src/tests.rs b/unknown-tokens/src/tests.rs index 236d7f1fe..45d699ddb 100644 --- a/unknown-tokens/src/tests.rs +++ b/unknown-tokens/src/tests.rs @@ -5,13 +5,17 @@ use super::*; use mock::*; -use frame_support::{assert_err, assert_ok}; +use frame_support::{ + assert_err, assert_ok, + storage::migration::{get_storage_value, put_storage_value}, + traits::OnRuntimeUpgrade, +}; const MOCK_RECIPIENT: MultiLocation = MultiLocation::parent(); const MOCK_CONCRETE_FUNGIBLE_ID: MultiLocation = MultiLocation::parent(); -fn mock_abstract_fungible_id() -> Vec { - vec![1] +fn mock_abstract_fungible_id() -> [u8; 32] { + [1; 32] } fn concrete_fungible(amount: u128) -> MultiAsset { @@ -51,7 +55,7 @@ fn deposit_abstract_fungible_asset() { let asset = abstract_fungible(3); assert_ok!(UnknownTokens::deposit(&asset, &MOCK_RECIPIENT)); assert_eq!( - UnknownTokens::abstract_fungible_balances(&MOCK_RECIPIENT, &mock_abstract_fungible_id()), + UnknownTokens::abstract_fungible_balances(&MOCK_RECIPIENT, &mock_abstract_fungible_id().to_vec()), 3 ); System::assert_last_event(RuntimeEvent::UnknownTokens(crate::Event::Deposited { @@ -66,7 +70,7 @@ fn deposit_abstract_fungible_asset() { Error::::BalanceOverflow ); assert_eq!( - UnknownTokens::abstract_fungible_balances(&MOCK_RECIPIENT, &mock_abstract_fungible_id()), + UnknownTokens::abstract_fungible_balances(&MOCK_RECIPIENT, &mock_abstract_fungible_id().to_vec()), 3 ); }); @@ -115,12 +119,12 @@ fn withdraw_concrete_fungible_asset_works() { #[test] fn withdraw_abstract_fungible_asset_works() { ExtBuilder.build().execute_with(|| { - AbstractFungibleBalances::::insert(&MOCK_RECIPIENT, &mock_abstract_fungible_id(), 3); + AbstractFungibleBalances::::insert(&MOCK_RECIPIENT, &mock_abstract_fungible_id().to_vec(), 3); let asset = abstract_fungible(3); assert_ok!(UnknownTokens::withdraw(&asset, &MOCK_RECIPIENT)); assert_eq!( - UnknownTokens::abstract_fungible_balances(&MOCK_RECIPIENT, &mock_abstract_fungible_id()), + UnknownTokens::abstract_fungible_balances(&MOCK_RECIPIENT, &mock_abstract_fungible_id().to_vec()), 0 ); System::assert_last_event(RuntimeEvent::UnknownTokens(crate::Event::Withdrawn { @@ -151,3 +155,98 @@ fn withdraw_unhandled_asset_should_fail() { ); }); } + +#[test] +fn from_unversioned_to_v2_storage() { + ExtBuilder.build().execute_with(|| { + fn blake2_128_concat(d: &[u8]) -> Vec { + let mut v = sp_io::hashing::blake2_128(d).to_vec(); + v.extend_from_slice(d); + v + } + + // StorageVersion is 0 before migration + assert_eq!(StorageVersion::get::>(), 0); + + // V2 `ConcreteFungibleBalances` key + let mut old_concrete_key = Vec::new(); + old_concrete_key.extend_from_slice( + &xcm::v2::MultiLocation::new( + 0, + xcm::v2::Junctions::X1(xcm::v2::Junction::GeneralKey(vec![0].try_into().unwrap())), + ) + .using_encoded(blake2_128_concat), + ); + old_concrete_key.extend_from_slice(&xcm::v2::MultiLocation::here().using_encoded(blake2_128_concat)); + + let balance = 55u128; + + put_storage_value( + b"UnknownTokens", + b"ConcreteFungibleBalances", + &old_concrete_key, + balance, + ); + + // V2 `AbstractFungibleBalances` key + let mut old_abstract_key = Vec::new(); + old_abstract_key.extend_from_slice( + &xcm::v2::MultiLocation::new( + 0, + xcm::v2::Junctions::X1(xcm::v2::Junction::GeneralKey(vec![0].try_into().unwrap())), + ) + .using_encoded(blake2_128_concat), + ); + old_abstract_key.extend_from_slice(&vec![1].using_encoded(blake2_128_concat)); + + let balance = 77u128; + + put_storage_value( + b"UnknownTokens", + b"AbstractFungibleBalances", + &old_abstract_key, + balance, + ); + + // V3 storage keys + let new_concrete_k1 = MultiLocation::new(0, X1(Junction::from(BoundedVec::try_from(vec![0]).unwrap()))); + let new_concrete_k2 = MultiLocation::here(); + let new_abstract_k1 = MultiLocation::new(0, X1(Junction::from(BoundedVec::try_from(vec![0]).unwrap()))); + let new_abstract_k2 = vec![1]; + + // Assert new StorageKey still does not exist + assert_eq!( + UnknownTokens::concrete_fungible_balances(new_concrete_k1, new_concrete_k2), + 0 + ); + assert_eq!( + UnknownTokens::abstract_fungible_balances(new_abstract_k1, new_abstract_k2.clone()), + 0 + ); + + // Migrate + crate::Migration::::on_runtime_upgrade(); + + // StorageVersion is 2 after migration + assert_eq!(StorageVersion::get::>(), 2); + + // Assert the StorageKey exists and has been migrated to xcm::v3 + assert_eq!( + UnknownTokens::concrete_fungible_balances(new_concrete_k1, new_concrete_k2), + 55 + ); + assert_eq!( + UnknownTokens::abstract_fungible_balances(new_abstract_k1, new_abstract_k2), + 77 + ); + + // Assert the old concrete key does not exist anymore + assert!(get_storage_value::(b"UnknownTokens", b"ConcreteFungibleBalances", &old_concrete_key,).is_none()); + + // Assert the old abstract key does not exist anymore + assert!(get_storage_value::(b"UnknownTokens", b"AbstractFungibleBalances", &old_concrete_key,).is_none()); + + // Assert further calls are no-op + assert_eq!(crate::Migration::::on_runtime_upgrade(), Weight::zero()); + }); +} diff --git a/utilities/Cargo.toml b/utilities/Cargo.toml index eca6cbac3..19f93596f 100644 --- a/utilities/Cargo.toml +++ b/utilities/Cargo.toml @@ -12,15 +12,15 @@ scale-info = { version = "2.1.2", default-features = false, features = ["derive" serde = { version = "1.0.136", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } [dev-dependencies] serde_json = "1.0.64" -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } [features] default = ["std"] diff --git a/vesting/Cargo.toml b/vesting/Cargo.toml index e316d4102..ff1dec75d 100644 --- a/vesting/Cargo.toml +++ b/vesting/Cargo.toml @@ -12,15 +12,15 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } [dev-dependencies] -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } [features] default = ["std"] diff --git a/vesting/src/mock.rs b/vesting/src/mock.rs index 9a2a871fa..afbed77f6 100644 --- a/vesting/src/mock.rs +++ b/vesting/src/mock.rs @@ -68,10 +68,10 @@ impl EnsureOrigin for EnsureAliceOrBob { } #[cfg(feature = "runtime-benchmarks")] - fn successful_origin() -> RuntimeOrigin { + fn try_successful_origin() -> Result { let zero_account_id = AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()) .expect("infinite length input; no invalid inputs for type; qed"); - RuntimeOrigin::from(RawOrigin::Signed(zero_account_id)) + Ok(RuntimeOrigin::from(RawOrigin::Signed(zero_account_id))) } } diff --git a/weight-meter/Cargo.toml b/weight-meter/Cargo.toml index c3cf1e656..9d9cb46be 100644 --- a/weight-meter/Cargo.toml +++ b/weight-meter/Cargo.toml @@ -10,19 +10,19 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } weight-meter-procedural = { path = "weight-meter-procedural", default-features = false } [dev-dependencies] serde = { version = "1.0.136" } codec = { package = "parity-scale-codec", version = "3.0.0" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } orml-bencher = { path = "../bencher" } diff --git a/xcm-support/Cargo.toml b/xcm-support/Cargo.toml index 2b85249b0..6198a81f1 100644 --- a/xcm-support/Cargo.toml +++ b/xcm-support/Cargo.toml @@ -10,12 +10,12 @@ edition = "2021" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.37" } -xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.37" } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.38" } +xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.38" } orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } diff --git a/xcm-support/src/currency_adapter.rs b/xcm-support/src/currency_adapter.rs index d81594133..9d61e3984 100644 --- a/xcm-support/src/currency_adapter.rs +++ b/xcm-support/src/currency_adapter.rs @@ -12,7 +12,7 @@ use sp_std::{ result, }; -use xcm::latest::{Error as XcmError, MultiAsset, MultiLocation, Result}; +use xcm::latest::{prelude::*, Error as XcmError, MultiAsset, MultiLocation, Result}; use xcm_executor::{ traits::{Convert as MoreConvert, MatchesFungible, TransactAsset}, Assets, @@ -145,7 +145,7 @@ impl< DepositFailureHandler, > { - fn deposit_asset(asset: &MultiAsset, location: &MultiLocation) -> Result { + fn deposit_asset(asset: &MultiAsset, location: &MultiLocation, _context: &XcmContext) -> Result { match ( AccountIdConvert::convert_ref(location), CurrencyIdConvert::convert(asset.clone()), @@ -160,7 +160,11 @@ impl< } } - fn withdraw_asset(asset: &MultiAsset, location: &MultiLocation) -> result::Result { + fn withdraw_asset( + asset: &MultiAsset, + location: &MultiLocation, + _maybe_context: Option<&XcmContext>, + ) -> result::Result { UnknownAsset::withdraw(asset, location).or_else(|_| { let who = AccountIdConvert::convert_ref(location) .map_err(|_| XcmError::from(Error::AccountIdConversionFailed))?; @@ -179,6 +183,7 @@ impl< asset: &MultiAsset, from: &MultiLocation, to: &MultiLocation, + _context: &XcmContext, ) -> result::Result { let from_account = AccountIdConvert::convert_ref(from).map_err(|_| XcmError::from(Error::AccountIdConversionFailed))?; diff --git a/xcm-support/src/lib.rs b/xcm-support/src/lib.rs index ee98e4882..bbbe89826 100644 --- a/xcm-support/src/lib.rs +++ b/xcm-support/src/lib.rs @@ -9,12 +9,15 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::unused_unit)] -use frame_support::dispatch::{DispatchError, DispatchResult}; +use frame_support::{ + dispatch::{DispatchError, DispatchResult}, + traits::ContainsPair, +}; use sp_runtime::traits::{CheckedConversion, Convert}; -use sp_std::{marker::PhantomData, prelude::*}; +use sp_std::marker::PhantomData; use xcm::latest::prelude::*; -use xcm_executor::traits::{FilterAssetLocation, MatchesFungible}; +use xcm_executor::traits::MatchesFungible; use orml_traits::{location::Reserve, GetByKey}; @@ -34,7 +37,7 @@ where { fn matches_fungible(a: &MultiAsset) -> Option { if let (Fungible(ref amount), Concrete(ref location)) = (&a.fun, &a.id) { - if CurrencyIdConvert::convert(location.clone()).is_some() { + if CurrencyIdConvert::convert(*location).is_some() { return CheckedConversion::checked_from(*amount); } } @@ -42,14 +45,14 @@ where } } -/// A `FilterAssetLocation` implementation. Filters multi native assets whose +/// A `ContainsPair` implementation. Filters multi native assets whose /// reserve is same with `origin`. pub struct MultiNativeAsset(PhantomData); -impl FilterAssetLocation for MultiNativeAsset +impl ContainsPair for MultiNativeAsset where ReserveProvider: Reserve, { - fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { + fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { if let Some(ref reserve) = ReserveProvider::reserve(asset) { if reserve == origin { return true; diff --git a/xcm-support/src/tests.rs b/xcm-support/src/tests.rs index 5189ecd83..69f8dd159 100644 --- a/xcm-support/src/tests.rs +++ b/xcm-support/src/tests.rs @@ -82,7 +82,9 @@ fn is_native_concrete_does_not_matches_non_native_currencies() { fun: Fungible(100), id: Concrete(MultiLocation::new( 1, - X1(GeneralKey(b"TokenB".to_vec().try_into().unwrap())) + X1(Junction::from( + sp_runtime::BoundedVec::try_from(b"TokenB".to_vec()).unwrap() + )) )), }) .is_none() @@ -91,18 +93,18 @@ fn is_native_concrete_does_not_matches_non_native_currencies() { #[test] fn multi_native_asset() { - assert!(MultiNativeAsset::::filter_asset_location( + assert!(MultiNativeAsset::::contains( &MultiAsset { fun: Fungible(10), id: Concrete(MultiLocation::parent()) }, &Parent.into() )); - assert!(MultiNativeAsset::::filter_asset_location( + assert!(MultiNativeAsset::::contains( &MultiAsset::sibling_parachain_asset(1, b"TokenA".to_vec().try_into().unwrap(), 100), &MultiLocation::new(1, X1(Parachain(1))), )); - assert!(!MultiNativeAsset::::filter_asset_location( + assert!(!MultiNativeAsset::::contains( &MultiAsset::sibling_parachain_asset(1, b"TokenA".to_vec().try_into().unwrap(), 100), &MultiLocation::parent(), )); diff --git a/xcm/Cargo.toml b/xcm/Cargo.toml index 40f5a32d3..0b762903a 100644 --- a/xcm/Cargo.toml +++ b/xcm/Cargo.toml @@ -11,15 +11,15 @@ edition = "2021" codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } -pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.37" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.37" } +pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.38" } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.38" } [dev-dependencies] -xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } +xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" } [features] default = ["std"] diff --git a/xcm/src/lib.rs b/xcm/src/lib.rs index 40057f889..29916f0c1 100644 --- a/xcm/src/lib.rs +++ b/xcm/src/lib.rs @@ -61,8 +61,8 @@ pub mod module { let dest = MultiLocation::try_from(*dest).map_err(|()| Error::::BadVersion)?; let message: Xcm<()> = (*message).try_into().map_err(|()| Error::::BadVersion)?; - pallet_xcm::Pallet::::send_xcm(Here, dest.clone(), message.clone()).map_err(|e| match e { - SendError::CannotReachDestination(..) => Error::::Unreachable, + pallet_xcm::Pallet::::send_xcm(Here, dest, message.clone()).map_err(|e| match e { + SendError::Unroutable => Error::::Unreachable, _ => Error::::SendFailure, })?; Self::deposit_event(Event::Sent { to: dest, message }); diff --git a/xtokens/Cargo.toml b/xtokens/Cargo.toml index 236a726f8..80648c1da 100644 --- a/xtokens/Cargo.toml +++ b/xtokens/Cargo.toml @@ -13,19 +13,19 @@ scale-info = { version = "2.1.2", default-features = false, features = ["derive" serde = { version = "1.0.136", optional = true } # substrate -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.37" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.38" } # cumulus -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", default-features = false , branch = "polkadot-v0.9.37" } +cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", default-features = false , branch = "polkadot-v0.9.38" } # polkadot -pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.37" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.37" } -xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.37" } +pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.38" } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.38" } +xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.38" } # orml orml-traits = { path = "../traits", default-features = false} @@ -33,21 +33,21 @@ orml-xcm-support = { path = "../xcm-support", default-features = false } [dev-dependencies] # substrate -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } # cumulus -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } +cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.38" } +cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.38" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.38" } +cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.38" } +parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.38" } # polkadot -polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } -polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } -xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } -xcm-simulator = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } +polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" } +polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" } +xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" } +xcm-simulator = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" } # orml orml-tokens = { path = "../tokens" } diff --git a/xtokens/src/lib.rs b/xtokens/src/lib.rs index 0af581872..95599a8f0 100644 --- a/xtokens/src/lib.rs +++ b/xtokens/src/lib.rs @@ -41,13 +41,13 @@ use frame_support::{ }; use frame_system::{ensure_signed, pallet_prelude::*}; use sp_runtime::{ - traits::{AtLeast32BitUnsigned, Convert, MaybeSerializeDeserialize, Member, Zero}, + traits::{AtLeast32BitUnsigned, Bounded, Convert, MaybeSerializeDeserialize, Member, Zero}, DispatchError, }; use sp_std::{prelude::*, result::Result}; use xcm::{latest::Weight, prelude::*}; -use xcm_executor::traits::{InvertLocation, WeightBounds}; +use xcm_executor::traits::WeightBounds; pub use module::*; use orml_traits::{ @@ -117,8 +117,8 @@ pub mod module { #[pallet::constant] type BaseXcmWeight: Get; - /// Means of inverting a location. - type LocationInverter: InvertLocation; + /// This chain's Universal Location. + type UniversalLocation: Get; /// The maximum number of distinct assets allowed to be transferred in a /// single helper extrinsic. @@ -425,7 +425,7 @@ pub mod module { Error::::NotSupportedMultiLocation ); - let asset = (location.clone(), amount.into()).into(); + let asset = (location, amount.into()).into(); let fee_asset: MultiAsset = (location, fee.into()).into(); // Push contains saturated addition, so we should be able to use it safely @@ -548,11 +548,11 @@ pub mod module { // like `NonReserve` or `SelfReserve` with relay-chain fee is not support. ensure!(non_fee_reserve == dest.chain_part(), Error::::InvalidAsset); - let reserve_location = non_fee_reserve.clone().ok_or(Error::::AssetHasNoReserve)?; + let reserve_location = non_fee_reserve.ok_or(Error::::AssetHasNoReserve)?; let min_xcm_fee = T::MinXcmFee::get(&reserve_location).ok_or(Error::::MinXcmFeeNotDefined)?; // min xcm fee should less than user fee - let fee_to_dest: MultiAsset = (fee.id.clone(), min_xcm_fee).into(); + let fee_to_dest: MultiAsset = (fee.id, min_xcm_fee).into(); ensure!(fee_to_dest < fee, Error::::FeeNotEnough); let mut assets_to_dest = MultiAssets::new(); @@ -572,9 +572,9 @@ pub mod module { let mut override_recipient = T::SelfLocation::get(); if override_recipient == MultiLocation::here() { let dest_chain_part = dest.chain_part().ok_or(Error::::InvalidDest)?; - let ancestry = T::LocationInverter::ancestry(); + let ancestry = T::UniversalLocation::get(); let _ = override_recipient - .reanchor(&dest_chain_part, &ancestry) + .reanchor(&dest_chain_part, ancestry) .map_err(|_| Error::::CannotReanchor); } @@ -583,7 +583,7 @@ pub mod module { // teleport. But as current there's only one case which is Parachain send back // asset to Statemine/t, So we set `use_teleport` to always `true` in this case. Self::execute_and_send_reserve_kind_xcm( - origin_location.clone(), + origin_location, assets_to_fee_reserve, asset_to_fee_reserve, fee_reserve, @@ -644,7 +644,6 @@ pub mod module { Some(recipient) => recipient, None => recipient, }; - let mut msg = match transfer_kind { SelfReserveAsset => Self::transfer_self_reserve_asset(assets, fee, dest, recipient, dest_weight_limit)?, ToReserve => Self::transfer_to_reserve(assets, fee, dest, recipient, dest_weight_limit)?, @@ -658,9 +657,10 @@ pub mod module { use_teleport, )?, }; + let hash = msg.using_encoded(sp_io::hashing::blake2_256); let weight = T::Weigher::weight(&mut msg).map_err(|()| Error::::UnweighableMessage)?; - T::XcmExecutor::execute_xcm_in_credit(origin_location, msg, weight, weight) + T::XcmExecutor::execute_xcm_in_credit(origin_location, msg, hash, weight, weight) .ensure_complete() .map_err(|error| { log::error!("Failed execute transfer message with {:?}", error); @@ -679,7 +679,7 @@ pub mod module { ) -> Result, DispatchError> { Ok(Xcm(vec![TransferReserveAsset { assets: assets.clone(), - dest: dest.clone(), + dest, xcm: Xcm(vec![ Self::buy_execution(fee, &dest, dest_weight_limit)?, Self::deposit_asset(recipient, assets.len() as u32), @@ -698,7 +698,7 @@ pub mod module { WithdrawAsset(assets.clone()), InitiateReserveWithdraw { assets: All.into(), - reserve: reserve.clone(), + reserve, xcm: Xcm(vec![ Self::buy_execution(fee, &reserve, dest_weight_limit)?, Self::deposit_asset(recipient, assets.len() as u32), @@ -716,7 +716,7 @@ pub mod module { dest_weight_limit: WeightLimit, use_teleport: bool, ) -> Result, DispatchError> { - let mut reanchored_dest = dest.clone(); + let mut reanchored_dest = dest; if reserve == MultiLocation::parent() { match dest { MultiLocation { @@ -729,21 +729,21 @@ pub mod module { } } + let max_assets = assets.len() as u32; if !use_teleport { Ok(Xcm(vec![ - WithdrawAsset(assets.clone()), + WithdrawAsset(assets), InitiateReserveWithdraw { assets: All.into(), - reserve: reserve.clone(), + reserve, xcm: Xcm(vec![ Self::buy_execution(half(&fee), &reserve, dest_weight_limit.clone())?, DepositReserveAsset { - assets: All.into(), - max_assets: assets.len() as u32, + assets: AllCounted(max_assets).into(), dest: reanchored_dest, xcm: Xcm(vec![ Self::buy_execution(half(&fee), &dest, dest_weight_limit)?, - Self::deposit_asset(recipient, assets.len() as u32), + Self::deposit_asset(recipient, max_assets), ]), }, ]), @@ -751,10 +751,10 @@ pub mod module { ])) } else { Ok(Xcm(vec![ - WithdrawAsset(assets.clone()), + WithdrawAsset(assets), InitiateReserveWithdraw { assets: All.into(), - reserve: reserve.clone(), + reserve, xcm: Xcm(vec![ Self::buy_execution(half(&fee), &reserve, dest_weight_limit.clone())?, InitiateTeleport { @@ -762,7 +762,7 @@ pub mod module { dest: reanchored_dest, xcm: Xcm(vec![ Self::buy_execution(half(&fee), &dest, dest_weight_limit)?, - Self::deposit_asset(recipient, assets.len() as u32), + Self::deposit_asset(recipient, max_assets), ]), }, ]), @@ -773,8 +773,7 @@ pub mod module { fn deposit_asset(recipient: MultiLocation, max_assets: u32) -> Instruction<()> { DepositAsset { - assets: All.into(), - max_assets, + assets: AllCounted(max_assets).into(), beneficiary: recipient, } } @@ -784,10 +783,8 @@ pub mod module { at: &MultiLocation, weight_limit: WeightLimit, ) -> Result, DispatchError> { - let ancestry = T::LocationInverter::ancestry(); - let fees = asset - .reanchored(at, &ancestry) - .map_err(|_| Error::::CannotReanchor)?; + let ancestry = T::UniversalLocation::get(); + let fees = asset.reanchored(at, ancestry).map_err(|_| Error::::CannotReanchor)?; Ok(BuyExecution { fees, weight_limit }) } @@ -859,7 +856,7 @@ pub mod module { .map_or(Weight::max_value(), |w| T::BaseXcmWeight::get().saturating_add(w)); } } - 0 + Weight::zero() } /// Returns weight of `transfer` call. @@ -868,7 +865,7 @@ pub mod module { let asset = (location, amount.into()).into(); Self::weight_of_transfer_multiasset(&asset, dest) } else { - 0 + Weight::zero() } } @@ -881,10 +878,10 @@ pub mod module { let mut assets: Vec = Vec::new(); for (currency_id, amount) in currencies { if let Some(location) = T::CurrencyIdConvert::convert(currency_id.clone()) { - let asset: MultiAsset = (location.clone(), (*amount).into()).into(); + let asset: MultiAsset = (location, (*amount).into()).into(); assets.push(asset); } else { - return 0; + return Weight::zero(); } } @@ -922,7 +919,7 @@ pub mod module { .map_or(Weight::max_value(), |w| T::BaseXcmWeight::get().saturating_add(w)); } } - 0 + Weight::zero() } /// Get reserve location by `assets` and `fee_item`. the `assets` @@ -989,7 +986,7 @@ fn half(asset: &MultiAsset) -> MultiAsset { .expect("div 2 can't overflow; qed"); MultiAsset { fun: Fungible(half_amount), - id: asset.id.clone(), + id: asset.id, } } @@ -997,6 +994,6 @@ fn subtract_fee(asset: &MultiAsset, amount: u128) -> MultiAsset { let final_amount = fungible_amount(asset).checked_sub(amount).expect("fee too low; qed"); MultiAsset { fun: Fungible(final_amount), - id: asset.id.clone(), + id: asset.id, } } diff --git a/xtokens/src/mock/mod.rs b/xtokens/src/mock/mod.rs index 4a128ff11..bac4e881e 100644 --- a/xtokens/src/mock/mod.rs +++ b/xtokens/src/mock/mod.rs @@ -6,7 +6,7 @@ use crate as orml_xtokens; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; use sp_io::TestExternalities; -use sp_runtime::AccountId32; +use sp_runtime::{AccountId32, BoundedVec}; use xcm_executor::traits::WeightTrader; use xcm_executor::Assets; @@ -47,47 +47,103 @@ impl Convert> for CurrencyIdConvert { fn convert(id: CurrencyId) -> Option { match id { CurrencyId::R => Some(Parent.into()), - CurrencyId::A => Some((Parent, Parachain(1), GeneralKey(b"A".to_vec().try_into().unwrap())).into()), - CurrencyId::A1 => Some((Parent, Parachain(1), GeneralKey(b"A1".to_vec().try_into().unwrap())).into()), - CurrencyId::B => Some((Parent, Parachain(2), GeneralKey(b"B".to_vec().try_into().unwrap())).into()), - CurrencyId::B1 => Some((Parent, Parachain(2), GeneralKey(b"B1".to_vec().try_into().unwrap())).into()), - CurrencyId::B2 => Some((Parent, Parachain(2), GeneralKey(b"B2".to_vec().try_into().unwrap())).into()), - CurrencyId::C => Some((Parent, Parachain(3), GeneralKey(b"C".to_vec().try_into().unwrap())).into()), - CurrencyId::D => Some((Parent, Parachain(4), GeneralKey(b"D".to_vec().try_into().unwrap())).into()), + CurrencyId::A => Some( + ( + Parent, + Parachain(1), + Junction::from(BoundedVec::try_from(b"A".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::A1 => Some( + ( + Parent, + Parachain(1), + Junction::from(BoundedVec::try_from(b"A1".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::B => Some( + ( + Parent, + Parachain(2), + Junction::from(BoundedVec::try_from(b"B".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::B1 => Some( + ( + Parent, + Parachain(2), + Junction::from(BoundedVec::try_from(b"B1".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::B2 => Some( + ( + Parent, + Parachain(2), + Junction::from(BoundedVec::try_from(b"B2".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::C => Some( + ( + Parent, + Parachain(3), + Junction::from(BoundedVec::try_from(b"C".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::D => Some( + ( + Parent, + Parachain(4), + Junction::from(BoundedVec::try_from(b"D".to_vec()).unwrap()), + ) + .into(), + ), } } } impl Convert> for CurrencyIdConvert { fn convert(l: MultiLocation) -> Option { - let a: Vec = "A".into(); - let a1: Vec = "A1".into(); - let b: Vec = "B".into(); - let b1: Vec = "B1".into(); - let b2: Vec = "B2".into(); - let c: Vec = "C".into(); - let d: Vec = "D".into(); + let mut a: Vec = "A".into(); + a.resize(32, 0); + let mut a1: Vec = "A1".into(); + a1.resize(32, 0); + let mut b: Vec = "B".into(); + b.resize(32, 0); + let mut b1: Vec = "B1".into(); + b1.resize(32, 0); + let mut b2: Vec = "B2".into(); + b2.resize(32, 0); + let mut c: Vec = "C".into(); + c.resize(32, 0); + let mut d: Vec = "D".into(); + d.resize(32, 0); if l == MultiLocation::parent() { return Some(CurrencyId::R); } match l { MultiLocation { parents, interior } if parents == 1 => match interior { - X2(Parachain(1), GeneralKey(k)) if k == a => Some(CurrencyId::A), - X2(Parachain(1), GeneralKey(k)) if k == a1 => Some(CurrencyId::A1), - X2(Parachain(2), GeneralKey(k)) if k == b => Some(CurrencyId::B), - X2(Parachain(2), GeneralKey(k)) if k == b1 => Some(CurrencyId::B1), - X2(Parachain(2), GeneralKey(k)) if k == b2 => Some(CurrencyId::B2), - X2(Parachain(3), GeneralKey(k)) if k == c => Some(CurrencyId::C), - X2(Parachain(4), GeneralKey(k)) if k == d => Some(CurrencyId::D), + X2(Parachain(1), GeneralKey { data, .. }) if data.to_vec() == a => Some(CurrencyId::A), + X2(Parachain(1), GeneralKey { data, .. }) if data.to_vec() == a1 => Some(CurrencyId::A1), + X2(Parachain(2), GeneralKey { data, .. }) if data.to_vec() == b => Some(CurrencyId::B), + X2(Parachain(2), GeneralKey { data, .. }) if data.to_vec() == b1 => Some(CurrencyId::B1), + X2(Parachain(2), GeneralKey { data, .. }) if data.to_vec() == b2 => Some(CurrencyId::B2), + X2(Parachain(3), GeneralKey { data, .. }) if data.to_vec() == c => Some(CurrencyId::C), + X2(Parachain(4), GeneralKey { data, .. }) if data.to_vec() == d => Some(CurrencyId::D), _ => None, }, MultiLocation { parents, interior } if parents == 0 => match interior { - X1(GeneralKey(k)) if k == a => Some(CurrencyId::A), - X1(GeneralKey(k)) if k == b => Some(CurrencyId::B), - X1(GeneralKey(k)) if k == a1 => Some(CurrencyId::A1), - X1(GeneralKey(k)) if k == b1 => Some(CurrencyId::B1), - X1(GeneralKey(k)) if k == b2 => Some(CurrencyId::B2), - X1(GeneralKey(k)) if k == c => Some(CurrencyId::C), - X1(GeneralKey(k)) if k == d => Some(CurrencyId::D), + X1(GeneralKey { data, .. }) if data.to_vec() == a => Some(CurrencyId::A), + X1(GeneralKey { data, .. }) if data.to_vec() == b => Some(CurrencyId::B), + X1(GeneralKey { data, .. }) if data.to_vec() == a1 => Some(CurrencyId::A1), + X1(GeneralKey { data, .. }) if data.to_vec() == b1 => Some(CurrencyId::B1), + X1(GeneralKey { data, .. }) if data.to_vec() == b2 => Some(CurrencyId::B2), + X1(GeneralKey { data, .. }) if data.to_vec() == c => Some(CurrencyId::C), + X1(GeneralKey { data, .. }) if data.to_vec() == d => Some(CurrencyId::D), _ => None, }, _ => None, @@ -263,7 +319,7 @@ impl WeightTrader for AllTokensAreCreatedEqualToWeight { .0; let required = MultiAsset { id: asset_id.clone(), - fun: Fungible(weight as u128), + fun: Fungible(weight.ref_time() as u128), }; if let MultiAsset { @@ -282,7 +338,7 @@ impl WeightTrader for AllTokensAreCreatedEqualToWeight { if weight.is_zero() { None } else { - Some((self.0.clone(), weight as u128).into()) + Some((self.0.clone(), weight.ref_time() as u128).into()) } } } diff --git a/xtokens/src/mock/para.rs b/xtokens/src/mock/para.rs index 19f38d690..e779bdbfa 100644 --- a/xtokens/src/mock/para.rs +++ b/xtokens/src/mock/para.rs @@ -19,8 +19,8 @@ use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; use xcm::latest::{prelude::*, Weight}; use xcm_builder::{ - AccountId32Aliases, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, LocationInverter, - NativeAsset, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + AccountId32Aliases, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, NativeAsset, + ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, }; use xcm_executor::{Config, XcmExecutor}; @@ -91,8 +91,8 @@ impl orml_tokens::Config for Runtime { } parameter_types! { - pub const ReservedXcmpWeight: Weight = WEIGHT_REF_TIME_PER_SECOND / 4; - pub const ReservedDmpWeight: Weight = WEIGHT_REF_TIME_PER_SECOND / 4; + pub const ReservedXcmpWeight: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4)); + pub const ReservedDmpWeight: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4)); } impl parachain_info::Config for Runtime {} @@ -101,7 +101,8 @@ parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Kusama; pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); + pub UniversalLocation: InteriorMultiLocation = + X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())); } pub type LocationToAccountId = ( @@ -132,6 +133,13 @@ pub type LocalAssetTransactor = MultiCurrencyAdapter< pub type XcmRouter = ParachainXcmRouter; pub type Barrier = (TakeWeightCredit, AllowTopLevelPaidExecutionFrom); +parameter_types! { + pub const UnitWeightCost: Weight = Weight::from_parts(10, 10); + pub const BaseXcmWeight: Weight = Weight::from_parts(100_000_000, 100_000_000); + pub const MaxInstructions: u32 = 100; + pub const MaxAssetsIntoHolding: u32 = 64; +} + pub struct XcmConfig; impl Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -140,14 +148,23 @@ impl Config for XcmConfig { type OriginConverter = XcmOriginToCallOrigin; type IsReserve = MultiNativeAsset; type IsTeleporter = NativeAsset; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; + type Weigher = FixedWeightBounds; type Trader = AllTokensAreCreatedEqualToWeight; type ResponseHandler = (); type AssetTrap = PolkadotXcm; type AssetClaims = PolkadotXcm; type SubscriptionService = PolkadotXcm; + type AssetLocker = PolkadotXcm; + type AssetExchanger = (); + type PalletInstancesInfo = (); + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } pub struct ChannelInfo; @@ -169,6 +186,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToCallOrigin; type WeightInfo = (); + type PriceForSiblingDelivery = (); } impl cumulus_pallet_dmp_queue::Config for Runtime { @@ -184,6 +202,11 @@ impl cumulus_pallet_xcm::Config for Runtime { pub type LocalOriginToLocation = SignedToAccountId32; +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parent.into()); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; @@ -193,19 +216,27 @@ impl pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; - type LocationInverter = LocationInverter; + type Weigher = FixedWeightBounds; + type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = (); + type MaxLockers = ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } pub struct AccountIdToMultiLocation; impl Convert for AccountIdToMultiLocation { fn convert(account: AccountId) -> MultiLocation { X1(Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: account.into(), }) .into() @@ -249,9 +280,9 @@ impl orml_xtokens::Config for Runtime { type MultiLocationsFilter = ParentOrParachains; type MinXcmFee = ParachainMinFee; type XcmExecutor = XcmExecutor; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; - type BaseXcmWeight = ConstU64<100_000_000>; - type LocationInverter = LocationInverter; + type Weigher = FixedWeightBounds; + type BaseXcmWeight = BaseXcmWeight; + type UniversalLocation = UniversalLocation; type MaxAssetsForTransfer = MaxAssetsForTransfer; type ReserveProvider = AbsoluteReserveProvider; } diff --git a/xtokens/src/mock/para_relative_view.rs b/xtokens/src/mock/para_relative_view.rs index a44283438..34d47c4b8 100644 --- a/xtokens/src/mock/para_relative_view.rs +++ b/xtokens/src/mock/para_relative_view.rs @@ -11,7 +11,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{Convert, IdentityLookup}, - AccountId32, + AccountId32, BoundedVec, }; use cumulus_primitives_core::{ChannelStatus, GetChannelInfo, ParaId}; @@ -19,9 +19,9 @@ use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; use xcm::latest::{prelude::*, Weight}; use xcm_builder::{ - AccountId32Aliases, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, LocationInverter, - ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + AccountId32Aliases, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset, + RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, }; use xcm_executor::{Config, XcmExecutor}; @@ -94,8 +94,8 @@ impl orml_tokens::Config for Runtime { } parameter_types! { - pub const ReservedXcmpWeight: Weight = WEIGHT_REF_TIME_PER_SECOND / 4; - pub const ReservedDmpWeight: Weight = WEIGHT_REF_TIME_PER_SECOND / 4; + pub const ReservedXcmpWeight: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4)); + pub const ReservedDmpWeight: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4)); } impl parachain_info::Config for Runtime {} @@ -104,7 +104,8 @@ parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Kusama; pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); + pub UniversalLocation: InteriorMultiLocation = + X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())); } pub type LocationToAccountId = ( @@ -135,6 +136,13 @@ pub type LocalAssetTransactor = MultiCurrencyAdapter< pub type XcmRouter = ParachainXcmRouter; pub type Barrier = (TakeWeightCredit, AllowTopLevelPaidExecutionFrom); +parameter_types! { + pub const UnitWeightCost: Weight = Weight::from_parts(10, 10); + pub const BaseXcmWeight: Weight = Weight::from_parts(100_000_000, 100_000_000); + pub const MaxInstructions: u32 = 100; + pub const MaxAssetsIntoHolding: u32 = 64; +} + pub struct XcmConfig; impl Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -143,14 +151,23 @@ impl Config for XcmConfig { type OriginConverter = XcmOriginToCallOrigin; type IsReserve = MultiNativeAsset; type IsTeleporter = (); - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; + type Weigher = FixedWeightBounds; type Trader = AllTokensAreCreatedEqualToWeight; type ResponseHandler = (); type AssetTrap = PolkadotXcm; type AssetClaims = PolkadotXcm; type SubscriptionService = PolkadotXcm; + type AssetLocker = PolkadotXcm; + type AssetExchanger = (); + type PalletInstancesInfo = (); + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } pub struct ChannelInfo; @@ -172,6 +189,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToCallOrigin; type WeightInfo = (); + type PriceForSiblingDelivery = (); } impl cumulus_pallet_dmp_queue::Config for Runtime { @@ -187,6 +205,11 @@ impl cumulus_pallet_xcm::Config for Runtime { pub type LocalOriginToLocation = SignedToAccountId32; +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parent.into()); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; @@ -196,19 +219,27 @@ impl pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; - type LocationInverter = LocationInverter; + type Weigher = FixedWeightBounds; + type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = (); + type MaxLockers = ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } pub struct AccountIdToMultiLocation; impl Convert for AccountIdToMultiLocation { fn convert(account: AccountId) -> MultiLocation { X1(Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: account.into(), }) .into() @@ -220,25 +251,74 @@ impl Convert> for RelativeCurrencyIdConvert { fn convert(id: CurrencyId) -> Option { match id { CurrencyId::R => Some(Parent.into()), - CurrencyId::A => Some((Parent, Parachain(1), GeneralKey(b"A".to_vec().try_into().unwrap())).into()), - CurrencyId::A1 => Some((Parent, Parachain(1), GeneralKey(b"A1".to_vec().try_into().unwrap())).into()), - CurrencyId::B => Some((Parent, Parachain(2), GeneralKey(b"B".to_vec().try_into().unwrap())).into()), - CurrencyId::B1 => Some((Parent, Parachain(2), GeneralKey(b"B1".to_vec().try_into().unwrap())).into()), - CurrencyId::B2 => Some((Parent, Parachain(2), GeneralKey(b"B2".to_vec().try_into().unwrap())).into()), - CurrencyId::C => Some((Parent, Parachain(3), GeneralKey(b"C".to_vec().try_into().unwrap())).into()), - CurrencyId::D => Some(GeneralKey(b"D".to_vec().try_into().unwrap()).into()), + CurrencyId::A => Some( + ( + Parent, + Parachain(1), + Junction::from(BoundedVec::try_from(b"A".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::A1 => Some( + ( + Parent, + Parachain(1), + Junction::from(BoundedVec::try_from(b"A1".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::B => Some( + ( + Parent, + Parachain(2), + Junction::from(BoundedVec::try_from(b"B".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::B1 => Some( + ( + Parent, + Parachain(2), + Junction::from(BoundedVec::try_from(b"B1".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::B2 => Some( + ( + Parent, + Parachain(2), + Junction::from(BoundedVec::try_from(b"B2".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::C => Some( + ( + Parent, + Parachain(3), + Junction::from(BoundedVec::try_from(b"C".to_vec()).unwrap()), + ) + .into(), + ), + CurrencyId::D => Some(Junction::from(BoundedVec::try_from(b"D".to_vec()).unwrap()).into()), } } } impl Convert> for RelativeCurrencyIdConvert { fn convert(l: MultiLocation) -> Option { - let a: Vec = "A".into(); - let a1: Vec = "A1".into(); - let b: Vec = "B".into(); - let b1: Vec = "B1".into(); - let b2: Vec = "B2".into(); - let c: Vec = "C".into(); - let d: Vec = "D".into(); + let mut a: Vec = "A".into(); + a.resize(32, 0); + let mut a1: Vec = "A1".into(); + a1.resize(32, 0); + let mut b: Vec = "B".into(); + b.resize(32, 0); + let mut b1: Vec = "B1".into(); + b1.resize(32, 0); + let mut b2: Vec = "B2".into(); + b2.resize(32, 0); + let mut c: Vec = "C".into(); + c.resize(32, 0); + let mut d: Vec = "D".into(); + d.resize(32, 0); let self_para_id: u32 = ParachainInfo::parachain_id().into(); if l == MultiLocation::parent() { @@ -246,23 +326,25 @@ impl Convert> for RelativeCurrencyIdConvert { } match l { MultiLocation { parents, interior } if parents == 1 => match interior { - X2(Parachain(1), GeneralKey(k)) if k == a => Some(CurrencyId::A), - X2(Parachain(1), GeneralKey(k)) if k == a1 => Some(CurrencyId::A1), - X2(Parachain(2), GeneralKey(k)) if k == b => Some(CurrencyId::B), - X2(Parachain(2), GeneralKey(k)) if k == b1 => Some(CurrencyId::B1), - X2(Parachain(2), GeneralKey(k)) if k == b2 => Some(CurrencyId::B2), - X2(Parachain(3), GeneralKey(k)) if k == c => Some(CurrencyId::C), - X2(Parachain(para_id), GeneralKey(k)) if k == d && para_id == self_para_id => Some(CurrencyId::D), + X2(Parachain(1), GeneralKey { data, .. }) if data.to_vec() == a => Some(CurrencyId::A), + X2(Parachain(1), GeneralKey { data, .. }) if data.to_vec() == a1 => Some(CurrencyId::A1), + X2(Parachain(2), GeneralKey { data, .. }) if data.to_vec() == b => Some(CurrencyId::B), + X2(Parachain(2), GeneralKey { data, .. }) if data.to_vec() == b1 => Some(CurrencyId::B1), + X2(Parachain(2), GeneralKey { data, .. }) if data.to_vec() == b2 => Some(CurrencyId::B2), + X2(Parachain(3), GeneralKey { data, .. }) if data.to_vec() == c => Some(CurrencyId::C), + X2(Parachain(para_id), GeneralKey { data, .. }) if data.to_vec() == d && para_id == self_para_id => { + Some(CurrencyId::D) + } _ => None, }, MultiLocation { parents, interior } if parents == 0 => match interior { - X1(GeneralKey(k)) if k == a => Some(CurrencyId::A), - X1(GeneralKey(k)) if k == b => Some(CurrencyId::B), - X1(GeneralKey(k)) if k == a1 => Some(CurrencyId::A1), - X1(GeneralKey(k)) if k == b1 => Some(CurrencyId::B1), - X1(GeneralKey(k)) if k == b2 => Some(CurrencyId::B2), - X1(GeneralKey(k)) if k == c => Some(CurrencyId::C), - X1(GeneralKey(k)) if k == d => Some(CurrencyId::D), + X1(GeneralKey { data, .. }) if data.to_vec() == a => Some(CurrencyId::A), + X1(GeneralKey { data, .. }) if data.to_vec() == b => Some(CurrencyId::B), + X1(GeneralKey { data, .. }) if data.to_vec() == a1 => Some(CurrencyId::A1), + X1(GeneralKey { data, .. }) if data.to_vec() == b1 => Some(CurrencyId::B1), + X1(GeneralKey { data, .. }) if data.to_vec() == b2 => Some(CurrencyId::B2), + X1(GeneralKey { data, .. }) if data.to_vec() == c => Some(CurrencyId::C), + X1(GeneralKey { data, .. }) if data.to_vec() == d => Some(CurrencyId::D), _ => None, }, _ => None, @@ -321,9 +403,9 @@ impl orml_xtokens::Config for Runtime { type MultiLocationsFilter = ParentOrParachains; type MinXcmFee = ParachainMinFee; type XcmExecutor = XcmExecutor; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; - type BaseXcmWeight = ConstU64<100_000_000>; - type LocationInverter = LocationInverter; + type Weigher = FixedWeightBounds; + type BaseXcmWeight = BaseXcmWeight; + type UniversalLocation = UniversalLocation; type MaxAssetsForTransfer = MaxAssetsForTransfer; type ReserveProvider = RelativeReserveProvider; } diff --git a/xtokens/src/mock/para_teleport.rs b/xtokens/src/mock/para_teleport.rs index 75fbd509c..dcfedb606 100644 --- a/xtokens/src/mock/para_teleport.rs +++ b/xtokens/src/mock/para_teleport.rs @@ -19,8 +19,8 @@ use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; use xcm::latest::{prelude::*, Weight}; use xcm_builder::{ - AccountId32Aliases, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, LocationInverter, - NativeAsset, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + AccountId32Aliases, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, NativeAsset, + ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, }; use xcm_executor::{Config, XcmExecutor}; @@ -92,8 +92,8 @@ impl orml_tokens::Config for Runtime { } parameter_types! { - pub const ReservedXcmpWeight: Weight = WEIGHT_REF_TIME_PER_SECOND / 4; - pub const ReservedDmpWeight: Weight = WEIGHT_REF_TIME_PER_SECOND / 4; + pub const ReservedXcmpWeight: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4)); + pub const ReservedDmpWeight: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND.saturating_div(4)); } impl parachain_info::Config for Runtime {} @@ -102,7 +102,8 @@ parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Kusama; pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); + pub UniversalLocation: InteriorMultiLocation = + X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())); } pub type LocationToAccountId = ( @@ -133,6 +134,13 @@ pub type LocalAssetTransactor = MultiTeleportCurrencyAdapter< pub type XcmRouter = ParachainXcmRouter; pub type Barrier = (TakeWeightCredit, AllowTopLevelPaidExecutionFrom); +parameter_types! { + pub const UnitWeightCost: Weight = Weight::from_parts(10, 10); + pub const BaseXcmWeight: Weight = Weight::from_parts(100_000_000, 100_000_000); + pub const MaxInstructions: u32 = 100; + pub const MaxAssetsIntoHolding: u32 = 64; +} + pub struct XcmConfig; impl Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -141,14 +149,23 @@ impl Config for XcmConfig { type OriginConverter = XcmOriginToCallOrigin; type IsReserve = MultiNativeAsset; type IsTeleporter = NativeAsset; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; + type Weigher = FixedWeightBounds; type Trader = AllTokensAreCreatedEqualToWeight; type ResponseHandler = (); type AssetTrap = PolkadotXcm; type AssetClaims = PolkadotXcm; type SubscriptionService = PolkadotXcm; + type AssetLocker = PolkadotXcm; + type AssetExchanger = (); + type PalletInstancesInfo = (); + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } pub struct ChannelInfo; @@ -170,6 +187,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToCallOrigin; type WeightInfo = (); + type PriceForSiblingDelivery = (); } impl cumulus_pallet_dmp_queue::Config for Runtime { @@ -185,6 +203,11 @@ impl cumulus_pallet_xcm::Config for Runtime { pub type LocalOriginToLocation = SignedToAccountId32; +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parent.into()); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; @@ -194,19 +217,27 @@ impl pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; - type LocationInverter = LocationInverter; + type Weigher = FixedWeightBounds; + type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = (); + type MaxLockers = ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } pub struct AccountIdToMultiLocation; impl Convert for AccountIdToMultiLocation { fn convert(account: AccountId) -> MultiLocation { X1(Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: account.into(), }) .into() @@ -240,9 +271,9 @@ impl orml_xtokens::Config for Runtime { type MultiLocationsFilter = ParentOrParachains; type MinXcmFee = DisabledParachainFee; type XcmExecutor = XcmExecutor; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; - type BaseXcmWeight = ConstU64<100_000_000>; - type LocationInverter = LocationInverter; + type Weigher = FixedWeightBounds; + type BaseXcmWeight = BaseXcmWeight; + type UniversalLocation = UniversalLocation; type MaxAssetsForTransfer = MaxAssetsForTransfer; type ReserveProvider = AbsoluteReserveProvider; } diff --git a/xtokens/src/mock/relay.rs b/xtokens/src/mock/relay.rs index e0b1e9965..d608b564e 100644 --- a/xtokens/src/mock/relay.rs +++ b/xtokens/src/mock/relay.rs @@ -1,18 +1,19 @@ use frame_support::{ construct_runtime, parameter_types, - traits::{ConstU128, ConstU32, ConstU64, Everything}, + traits::{ConstU128, ConstU32, ConstU64, Everything, Nothing}, weights::IdentityFee, }; use frame_system::EnsureRoot; use sp_core::H256; use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; +use crate::Weight; use cumulus_primitives_core::ParaId; use polkadot_runtime_parachains::{configuration, origin, shared, ump}; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, - CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, LocationInverter, SignedAccountId32AsNative, + CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, }; use xcm_executor::{Config, XcmExecutor}; @@ -66,9 +67,9 @@ impl configuration::Config for Runtime { } parameter_types! { - pub const KsmLocation: MultiLocation = Here.into(); + pub KsmLocation: MultiLocation = Here.into(); pub const KusamaNetwork: NetworkId = NetworkId::Kusama; - pub Ancestry: MultiLocation = Here.into(); + pub UniversalLocation: InteriorMultiLocation = X1(GlobalConsensus(KusamaNetwork::get())); } pub type SovereignAccountOf = ( @@ -89,13 +90,20 @@ pub type XcmRouter = super::RelayChainXcmRouter; pub type Barrier = (TakeWeightCredit, AllowTopLevelPaidExecutionFrom); parameter_types! { - pub const Kusama: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(KsmLocation::get()) }); - pub const Statemine: MultiLocation = Parachain(3).into(); - pub const KusamaForStatemine: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Statemine::get()); + pub Kusama: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(KsmLocation::get()) }); + pub Statemine: MultiLocation = Parachain(3).into(); + pub KusamaForStatemine: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Statemine::get()); } pub type TrustedTeleporters = xcm_builder::Case; +parameter_types! { + pub const UnitWeightCost: Weight = Weight::from_parts(10, 10); + pub const BaseXcmWeight: Weight = Weight::from_parts(100_000_000, 100_000_000); + pub const MaxInstructions: u32 = 100; + pub const MaxAssetsIntoHolding: u32 = 64; +} + pub struct XcmConfig; impl Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -104,18 +112,32 @@ impl Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; + type Weigher = FixedWeightBounds; type Trader = UsingComponents, KsmLocation, AccountId, Balances, ()>; type ResponseHandler = (); type AssetTrap = (); type AssetClaims = (); type SubscriptionService = XcmPallet; + type AssetLocker = XcmPallet; + type AssetExchanger = (); + type PalletInstancesInfo = (); + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } pub type LocalOriginToLocation = SignedToAccountId32; +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parent.into()); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; @@ -126,12 +148,20 @@ impl pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds, RuntimeCall, ConstU32<100>>; - type LocationInverter = LocationInverter; + type Weigher = FixedWeightBounds; + type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = (); + type MaxLockers = ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } impl ump::Config for Runtime { diff --git a/xtokens/src/mock/teleport_currency_adapter.rs b/xtokens/src/mock/teleport_currency_adapter.rs index 2056b07cc..9ca6be636 100644 --- a/xtokens/src/mock/teleport_currency_adapter.rs +++ b/xtokens/src/mock/teleport_currency_adapter.rs @@ -9,7 +9,7 @@ use sp_std::{ }; use orml_xcm_support::{OnDepositFail, UnknownAsset as UnknownAssetT}; -use xcm::latest::{Error as XcmError, MultiAsset, MultiLocation, Result}; +use xcm::latest::{prelude::*, Error as XcmError, MultiAsset, MultiLocation, Result}; use xcm_executor::{ traits::{Convert as MoreConvert, MatchesFungible, TransactAsset}, Assets, @@ -87,13 +87,13 @@ impl< DepositFailureHandler, > { - fn can_check_in(_origin: &MultiLocation, _what: &MultiAsset) -> Result { + fn can_check_in(_origin: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) -> Result { Ok(()) } - fn check_in(_origin: &MultiLocation, _what: &MultiAsset) {} + fn check_in(_origin: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {} - fn deposit_asset(asset: &MultiAsset, location: &MultiLocation) -> Result { + fn deposit_asset(asset: &MultiAsset, location: &MultiLocation, _context: &XcmContext) -> Result { match ( AccountIdConvert::convert_ref(location), CurrencyIdConvert::convert(asset.clone()), @@ -108,7 +108,11 @@ impl< } } - fn withdraw_asset(asset: &MultiAsset, location: &MultiLocation) -> result::Result { + fn withdraw_asset( + asset: &MultiAsset, + location: &MultiLocation, + _maybe_context: Option<&XcmContext>, + ) -> result::Result { UnknownAsset::withdraw(asset, location).or_else(|_| { let who = AccountIdConvert::convert_ref(location) .map_err(|_| XcmError::from(Error::AccountIdConversionFailed))?; diff --git a/xtokens/src/tests.rs b/xtokens/src/tests.rs index 79ef3c0b7..7e494ec0a 100644 --- a/xtokens/src/tests.rs +++ b/xtokens/src/tests.rs @@ -65,7 +65,7 @@ fn send_relay_chain_asset_to_relay_chain() { MultiLocation::new( 1, X1(Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }) ) @@ -100,7 +100,7 @@ fn send_relay_chain_asset_to_relay_chain_with_fee() { MultiLocation::new( 1, X1(Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }) ) @@ -134,7 +134,7 @@ fn cannot_lost_fund_on_send_failed() { Parent, Parachain(100), Junction::AccountId32 { - network: NetworkId::Kusama, + network: None, id: BOB.into(), }, ) @@ -168,7 +168,7 @@ fn send_relay_chain_asset_to_sibling() { X2( Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) @@ -210,7 +210,7 @@ fn send_relay_chain_asset_to_sibling_with_fee() { X2( Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) @@ -258,7 +258,7 @@ fn send_sibling_asset_to_reserve_sibling() { Parent, Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -283,7 +283,7 @@ fn send_sibling_asset_to_reserve_sibling() { Parent, Parachain(1), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: ALICE.into(), }, ) @@ -323,7 +323,7 @@ fn send_sibling_asset_to_reserve_sibling_with_fee() { Parent, Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -366,7 +366,7 @@ fn send_sibling_asset_to_reserve_sibling_with_distinct_fee() { Parent, Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -412,7 +412,7 @@ fn send_sibling_asset_to_reserve_sibling_with_distinct_fee_index_works() { Parent, Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -457,7 +457,7 @@ fn send_sibling_asset_to_non_reserve_sibling() { X2( Parachain(3), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) @@ -504,7 +504,7 @@ fn send_sibling_asset_to_non_reserve_sibling_with_fee() { X2( Parachain(3), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) @@ -546,7 +546,7 @@ fn send_self_parachain_asset_to_sibling() { X2( Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) @@ -583,7 +583,7 @@ fn send_self_parachain_asset_to_sibling_with_fee() { X2( Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) @@ -621,7 +621,7 @@ fn send_self_parachain_asset_to_sibling_with_distinct_fee() { X2( Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) @@ -662,7 +662,9 @@ fn sending_sibling_asset_to_reserve_sibling_with_relay_fee_works() { }); let fee_amount: u128 = 200; - let weight: u128 = 50; + // TODO: set the weight limit to 40 until this issue is addressed: + // https://github.com/paritytech/polkadot/issues/6770 + let weight: u128 = 40; let dest_weight: u128 = 40; ParaA::execute_with(|| { @@ -675,13 +677,13 @@ fn sending_sibling_asset_to_reserve_sibling_with_relay_fee_works() { Parent, Parachain(3), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) .into() ), - WeightLimit::Limited(weight as u64), + WeightLimit::Limited((weight as u64).into()), )); assert_eq!(550, ParaTokens::free_balance(CurrencyId::C, &ALICE)); assert_eq!(1000 - fee_amount, ParaTokens::free_balance(CurrencyId::R, &ALICE)); @@ -722,7 +724,9 @@ fn sending_sibling_asset_to_reserve_sibling_with_relay_fee_works_with_relative_s }); let fee_amount: u128 = 200; - let weight: u128 = 50; + // TODO: set the weight limit to 40 until this issue is addressed: + // https://github.com/paritytech/polkadot/issues/6770 + let weight: u128 = 40; let dest_weight: u128 = 40; ParaD::execute_with(|| { @@ -735,13 +739,13 @@ fn sending_sibling_asset_to_reserve_sibling_with_relay_fee_works_with_relative_s Parent, Parachain(3), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) .into() ), - WeightLimit::Limited(weight as u64), + WeightLimit::Limited((weight as u64).into()), )); assert_eq!(550, ParaRelativeTokens::free_balance(CurrencyId::C, &ALICE)); assert_eq!( @@ -785,7 +789,9 @@ fn sending_sibling_asset_to_reserve_sibling_with_relay_fee_not_enough() { }); let fee_amount: u128 = 159; - let weight: u128 = 50; + // TODO: set the weight limit to 40 until this issue is addressed: + // https://github.com/paritytech/polkadot/issues/6770 + let weight: u128 = 40; let dest_weight: u128 = 40; ParaA::execute_with(|| { @@ -798,13 +804,13 @@ fn sending_sibling_asset_to_reserve_sibling_with_relay_fee_not_enough() { Parent, Parachain(3), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) .into() ), - WeightLimit::Limited(weight as u64), + WeightLimit::Limited((weight as u64).into()), )); assert_eq!(550, ParaTokens::free_balance(CurrencyId::C, &ALICE)); assert_eq!(1000 - fee_amount, ParaTokens::free_balance(CurrencyId::R, &ALICE)); @@ -844,7 +850,7 @@ fn transfer_asset_with_relay_fee_failed() { Parent, Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -868,7 +874,7 @@ fn transfer_asset_with_relay_fee_failed() { Parent, Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -893,7 +899,7 @@ fn transfer_asset_with_relay_fee_failed() { Parent, Parachain(3), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -917,7 +923,7 @@ fn transfer_asset_with_relay_fee_failed() { Parent, Parachain(1), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -935,16 +941,17 @@ fn transfer_no_reserve_assets_fails() { TestNet::reset(); ParaA::execute_with(|| { + let asset_id: AssetId = X1(Junction::from(BoundedVec::try_from(b"B".to_vec()).unwrap())).into(); assert_noop!( ParaXTokens::transfer_multiasset( Some(ALICE).into(), - Box::new((X1(GeneralKey(b"B".to_vec().try_into().unwrap())).into(), 100).into()), + Box::new((asset_id, 100).into()), Box::new( ( Parent, Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into() } ) @@ -972,7 +979,7 @@ fn transfer_to_self_chain_fails() { X2( Parachain(1), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into() } ) @@ -999,7 +1006,7 @@ fn transfer_to_invalid_dest_fails() { MultiLocation::new( 0, X1(Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into() }) ) @@ -1026,7 +1033,7 @@ fn send_as_sovereign() { let call = relay::RuntimeCall::System(frame_system::Call::::remark_with_event { remark: vec![1, 1, 1], }); - let assets: MultiAsset = (Here, 1_000_000_000_000).into(); + let assets: MultiAsset = (Here, 1_000_000_000_000u128).into(); assert_ok!(para::OrmlXcm::send_as_sovereign( para::RuntimeOrigin::root(), Box::new(Parent.into()), @@ -1034,11 +1041,11 @@ fn send_as_sovereign() { WithdrawAsset(assets.clone().into()), BuyExecution { fees: assets, - weight_limit: Limited(2_000_000_000) + weight_limit: Limited(2_000_000_000.into()) }, Instruction::Transact { - origin_type: SovereignAccount, - require_weight_at_most: 1_000_000_000, + origin_kind: SovereignAccount, + require_weight_at_most: 1_000_000_000.into(), call: call.encode().into(), } ]))) @@ -1069,7 +1076,7 @@ fn send_as_sovereign_fails_if_bad_origin() { let call = relay::RuntimeCall::System(frame_system::Call::::remark_with_event { remark: vec![1, 1, 1], }); - let assets: MultiAsset = (Here, 1_000_000_000_000).into(); + let assets: MultiAsset = (Here, 1_000_000_000_000u128).into(); assert_err!( para::OrmlXcm::send_as_sovereign( para::RuntimeOrigin::signed(ALICE), @@ -1078,11 +1085,11 @@ fn send_as_sovereign_fails_if_bad_origin() { WithdrawAsset(assets.clone().into()), BuyExecution { fees: assets, - weight_limit: Limited(10_000_000) + weight_limit: Limited(10_000_000.into()) }, Instruction::Transact { - origin_type: SovereignAccount, - require_weight_at_most: 1_000_000_000, + origin_kind: SovereignAccount, + require_weight_at_most: 1_000_000_000.into(), call: call.encode().into(), } ]))) @@ -1130,7 +1137,7 @@ fn send_with_zero_fee_should_yield_an_error() { X2( Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) @@ -1164,7 +1171,7 @@ fn send_with_insufficient_fee_traps_assets() { X2( Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) @@ -1207,7 +1214,7 @@ fn send_with_fee_should_handle_overflow() { X2( Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) @@ -1258,7 +1265,7 @@ fn specifying_more_than_assets_limit_should_error() { Parent, Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -1299,7 +1306,7 @@ fn sending_non_fee_assets_with_different_reserve_should_fail() { Parent, Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -1335,7 +1342,7 @@ fn specifying_a_non_existent_asset_index_should_fail() { Parent, Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -1363,7 +1370,7 @@ fn send_with_zero_amount() { Parent, Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -1384,7 +1391,7 @@ fn send_with_zero_amount() { Parent, Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -1416,7 +1423,7 @@ fn send_self_parachain_asset_to_sibling_relative_parachain() { X2( Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) @@ -1462,7 +1469,7 @@ fn send_sibling_asset_to_reserve_sibling_with_relative_view() { Parent, Parachain(4), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -1490,7 +1497,7 @@ fn send_sibling_asset_to_reserve_sibling_with_relative_view() { Parent, Parachain(1), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: ALICE.into(), }, ) @@ -1530,7 +1537,7 @@ fn send_relative_view_sibling_asset_to_non_reserve_sibling() { X2( Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) @@ -1578,7 +1585,7 @@ fn send_relay_chain_asset_to_relative_view_sibling() { X2( Parachain(4), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) @@ -1617,7 +1624,7 @@ fn unsupported_multilocation_should_be_filtered() { Parent, Parachain(5), // parachain 4 is not supported list. Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -1638,7 +1645,7 @@ fn unsupported_multilocation_should_be_filtered() { Parent, Parachain(5), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), }, ) @@ -1668,14 +1675,14 @@ fn send_with_sufficient_weight_limit() { X2( Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) ) .into() ), - WeightLimit::Limited(40), + WeightLimit::Limited(40.into()), )); assert_eq!(ParaTokens::free_balance(CurrencyId::A, &ALICE), 500); @@ -1704,14 +1711,14 @@ fn send_with_insufficient_weight_limit() { X2( Parachain(2), Junction::AccountId32 { - network: NetworkId::Any, + network: None, id: BOB.into(), } ) ) .into() ), - WeightLimit::Limited(1), + WeightLimit::Limited(1.into()), )); assert_eq!(ParaTokens::free_balance(CurrencyId::A, &ALICE), 500);