From b8293cbc6d0fb65ae6067319d80db0ad4d2ef76f Mon Sep 17 00:00:00 2001 From: Daniel Moka Date: Sat, 6 Apr 2024 12:03:13 +0200 Subject: [PATCH 01/13] fix bug of reducible_balance so we return the balance minus ED in case of Preserve preservation (#987) --- tokens/Cargo.toml | 2 +- tokens/src/lib.rs | 4 +++- tokens/src/tests_fungibles.rs | 9 +++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tokens/Cargo.toml b/tokens/Cargo.toml index 7644e3635..ff8dec2dd 100644 --- a/tokens/Cargo.toml +++ b/tokens/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-tokens" description = "Fungible tokens module that implements `MultiCurrency` trait." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/tokens" license = "Apache-2.0" -version = "0.8.0" +version = "0.8.1" authors = ["Laminar Developers "] edition = "2021" diff --git a/tokens/src/lib.rs b/tokens/src/lib.rs index b5375561d..a00435e3a 100644 --- a/tokens/src/lib.rs +++ b/tokens/src/lib.rs @@ -1808,7 +1808,9 @@ impl fungibles::Inspect for Pallet { let a = Self::accounts(who, asset_id); // Liquid balance is what is neither reserved nor locked/frozen. let liquid = a.free.saturating_sub(a.frozen); - if frame_system::Pallet::::can_dec_provider(who) && !matches!(preservation, Preservation::Protect) { + if frame_system::Pallet::::can_dec_provider(who) + && !matches!(preservation, Preservation::Protect | Preservation::Preserve) + { liquid } else { // `must_remain_to_exist` is the part of liquid balance which must remain to diff --git a/tokens/src/tests_fungibles.rs b/tokens/src/tests_fungibles.rs index d7b6abf55..2d975c727 100644 --- a/tokens/src/tests_fungibles.rs +++ b/tokens/src/tests_fungibles.rs @@ -27,6 +27,15 @@ fn fungibles_inspect_trait_should_work() { ), 98 ); + assert_eq!( + >::reducible_balance( + DOT, + &ALICE, + Preservation::Preserve, + Fortitude::Polite + ), + 98 + ); assert_ok!( >::can_deposit(DOT, &ALICE, 1, Provenance::Extant).into_result() ); From d26afd5f420a26bdfaf31a30005068b96f626cca Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Sun, 7 Apr 2024 19:22:23 +1200 Subject: [PATCH 02/13] update to 1.9.0 (#988) --- Cargo.dev.toml | 58 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/Cargo.dev.toml b/Cargo.dev.toml index 728aec898..ed490f47e 100644 --- a/Cargo.dev.toml +++ b/Cargo.dev.toml @@ -37,35 +37,35 @@ scale-info = { version = "2.10.0", default-features = false, features = ["derive serde = { version = "1.0.189" } parity-scale-codec = { version = "3.6.5", default-features = false, features = ["max-encoded-len"] } -cumulus-pallet-xcm = { version = "0.8.0", default-features = false } -cumulus-primitives-core = { version = "0.8.0", default-features = false } -frame-benchmarking = { version = "29.0.0", default-features = false } -frame-support = { version = "29.0.0", default-features = false } -frame-system = { version = "29.0.0", default-features = false } -pallet-balances = { version = "29.0.0", default-features = false } -pallet-elections-phragmen = { version = "30.0.0", default-features = false } -pallet-message-queue = { version = "32.0.0", default-features = false } -pallet-preimage = { version = "29.0.0", default-features = false } -pallet-root-testing = { version = "5.0.0", default-features = false } -pallet-scheduler = { version = "30.0.0", default-features = false } -pallet-timestamp = { version = "28.0.0", default-features = false } -pallet-treasury = { version = "28.0.0", default-features = false } -pallet-xcm = { version = "8.0.0", default-features = false } -polkadot-parachain-primitives = { version = "7.0.0", default-features = false } -polkadot-runtime-common = { version = "8.0.0", default-features = false } -polkadot-runtime-parachains = { version = "8.0.0", default-features = false } -sp-api = { version = "27.0.0", default-features = false } -sp-application-crypto = { version = "31.0.0", default-features = false } -sp-arithmetic = { version = "24.0.0", default-features = false } -sp-core = { version = "29.0.0", default-features = false } -sp-io = { version = "31.0.0", default-features = false } -sp-runtime = { version = "32.0.0", default-features = false } -sp-runtime-interface = { version = "25.0.0", default-features = false } -sp-staking = { version = "27.0.0", default-features = false } +cumulus-pallet-xcm = { version = "0.10.0", default-features = false } +cumulus-primitives-core = { version = "0.10.0", default-features = false } +frame-benchmarking = { version = "31.0.0", default-features = false } +frame-support = { version = "31.0.0", default-features = false } +frame-system = { version = "31.0.0", default-features = false } +pallet-balances = { version = "31.0.0", default-features = false } +pallet-elections-phragmen = { version = "32.0.0", default-features = false } +pallet-message-queue = { version = "34.0.0", default-features = false } +pallet-preimage = { version = "31.0.0", default-features = false } +pallet-root-testing = { version = "7.0.0", default-features = false } +pallet-scheduler = { version = "32.0.0", default-features = false } +pallet-timestamp = { version = "30.0.0", default-features = false } +pallet-treasury = { version = "30.0.0", default-features = false } +pallet-xcm = { version = "10.0.0", default-features = false } +polkadot-parachain-primitives = { version = "9.0.0", default-features = false } +polkadot-runtime-common = { version = "10.0.0", default-features = false } +polkadot-runtime-parachains = { version = "10.0.0", default-features = false } +sp-api = { version = "29.0.0", default-features = false } +sp-application-crypto = { version = "33.0.0", default-features = false } +sp-arithmetic = { version = "25.0.0", default-features = false } +sp-core = { version = "31.0.0", default-features = false } +sp-io = { version = "33.0.0", default-features = false } +sp-runtime = { version = "34.0.0", default-features = false } +sp-runtime-interface = { version = "26.0.0", default-features = false } +sp-staking = { version = "29.0.0", default-features = false } sp-std = { version = "14.0.0", default-features = false } sp-storage = { version = "20.0.0", default-features = false } -xcm = { package = "staging-xcm", version = "8.0.0", default-features = false } -xcm-builder = { package = "staging-xcm-builder", version = "8.0.0", default-features = false } -xcm-executor = { package = "staging-xcm-executor", version = "8.0.0", default-features = false } +xcm = { version = "10.0.0", package = "staging-xcm", default-features = false } +xcm-builder = { version = "10.0.0", package = "staging-xcm-builder", default-features = false } +xcm-executor = { version = "10.0.0", package = "staging-xcm-executor", default-features = false } -xcm-simulator = { version = "8.0.0" } +xcm-simulator = { version = "10.0.0" } From 3151b86877ac2e8bfdecd2c8a73374bd5dcd0e5b Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Sun, 7 Apr 2024 19:43:30 +1200 Subject: [PATCH 03/13] chore: Release --- asset-registry/Cargo.toml | 4 ++-- auction/Cargo.toml | 4 ++-- authority/Cargo.toml | 2 +- benchmarking/Cargo.toml | 2 +- build-script-utils/Cargo.toml | 2 +- currencies/Cargo.toml | 6 +++--- gradually-update/Cargo.toml | 2 +- nft/Cargo.toml | 2 +- oracle/Cargo.toml | 6 +++--- oracle/runtime-api/Cargo.toml | 2 +- parameters/Cargo.toml | 4 ++-- payments/Cargo.toml | 4 ++-- rate-limit/Cargo.toml | 6 +++--- rewards/Cargo.toml | 4 ++-- tokens/Cargo.toml | 4 ++-- tokens/runtime-api/Cargo.toml | 2 +- traits/Cargo.toml | 4 ++-- unknown-tokens/Cargo.toml | 4 ++-- utilities/Cargo.toml | 2 +- vesting/Cargo.toml | 2 +- xcm-mock-message-queue/Cargo.toml | 2 +- xcm-support/Cargo.toml | 4 ++-- xcm/Cargo.toml | 2 +- xtokens/Cargo.toml | 6 +++--- 24 files changed, 41 insertions(+), 41 deletions(-) diff --git a/asset-registry/Cargo.toml b/asset-registry/Cargo.toml index 87f914642..5ed17a03d 100644 --- a/asset-registry/Cargo.toml +++ b/asset-registry/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-asset-registry" description = "Registry for (foreign) assets" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/asset-registry" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Interlay Ltd, etc"] edition = "2021" @@ -27,7 +27,7 @@ xcm-builder = { workspace = true } xcm-executor = { workspace = true } # orml -orml-traits = { path = "../traits", version = "0.8.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.0", default-features = false } # for runtime-benchmarks polkadot-runtime-common = { workspace = true, optional = true } diff --git a/auction/Cargo.toml b/auction/Cargo.toml index e6d5f429b..e78b40da8 100644 --- a/auction/Cargo.toml +++ b/auction/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-auction" description = "Auction module that implements `Auction` trait." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/auction" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Acala Developers"] edition = "2021" @@ -17,7 +17,7 @@ frame-system = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.8.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.0", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/authority/Cargo.toml b/authority/Cargo.toml index 0997a8319..4296957a2 100644 --- a/authority/Cargo.toml +++ b/authority/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-authority" description = "Utility pallet to perform ROOT calls in a PoA network" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/auction" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Acala Developers"] edition = "2021" diff --git a/benchmarking/Cargo.toml b/benchmarking/Cargo.toml index 06f4f49bc..bb704ade0 100644 --- a/benchmarking/Cargo.toml +++ b/benchmarking/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-benchmarking" description = "Provide macro to benchmark Substrate runtime." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/benchmarking" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Laminar Developers "] edition = "2021" diff --git a/build-script-utils/Cargo.toml b/build-script-utils/Cargo.toml index 01b8ceb06..cdbeeec05 100644 --- a/build-script-utils/Cargo.toml +++ b/build-script-utils/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-build-script-utils" description = "Crate with utility functions for `build.rs` scripts." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/build-script-utils" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Parity Technologies ", "Laminar Developers "] edition = "2021" diff --git a/currencies/Cargo.toml b/currencies/Cargo.toml index 600e81e37..ce2ec7962 100644 --- a/currencies/Cargo.toml +++ b/currencies/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-currencies" description = "Provide `MultiCurrency` implementation using `pallet-balances` and `orml-tokens` module." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/currencies" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Laminar Developers "] edition = "2021" @@ -18,8 +18,8 @@ sp-io = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.8.0", default-features = false } -orml-utilities = { path = "../utilities", version = "0.8.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.0", default-features = false } +orml-utilities = { path = "../utilities", version = "0.9.0", default-features = false } [dev-dependencies] pallet-balances = { workspace = true, features = ["std"] } diff --git a/gradually-update/Cargo.toml b/gradually-update/Cargo.toml index c54f78f19..4a799351c 100644 --- a/gradually-update/Cargo.toml +++ b/gradually-update/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-gradually-update" description = "Provides way to adjust numeric parameter gradually over a period of time." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/gradually-update" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Laminar Developers "] edition = "2021" diff --git a/nft/Cargo.toml b/nft/Cargo.toml index aadcb42f8..735fc9bec 100644 --- a/nft/Cargo.toml +++ b/nft/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-nft" description = "Non-fungible token pallet provides basic functions to create and manager NFT" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/nft" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Acala Developers"] edition = "2021" diff --git a/oracle/Cargo.toml b/oracle/Cargo.toml index 043fb29d8..05d60c23d 100644 --- a/oracle/Cargo.toml +++ b/oracle/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-oracle" description = "Oracle module that makes off-chain data available on-chain." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/oracle" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Laminar Developers "] edition = "2021" @@ -20,8 +20,8 @@ sp-runtime = { workspace = true } sp-std = { workspace = true } frame-benchmarking = { workspace = true, optional = true } -orml-traits = { path = "../traits", version = "0.8.0", default-features = false } -orml-utilities = { path = "../utilities", version = "0.8.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.0", default-features = false } +orml-utilities = { path = "../utilities", version = "0.9.0", default-features = false } [dev-dependencies] sp-core = { workspace = true } diff --git a/oracle/runtime-api/Cargo.toml b/oracle/runtime-api/Cargo.toml index 780422846..dc3602585 100644 --- a/oracle/runtime-api/Cargo.toml +++ b/oracle/runtime-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orml-oracle-runtime-api" -version = "0.8.0" +version = "0.9.0" authors = ["Laminar Developers "] edition = "2021" license = "Apache-2.0" diff --git a/parameters/Cargo.toml b/parameters/Cargo.toml index 277f89be8..ca993edc3 100644 --- a/parameters/Cargo.toml +++ b/parameters/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-parameters" description = "Offer a centra place to store and configure parameters." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/parameters" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Acala Developers"] edition = "2021" @@ -18,7 +18,7 @@ sp-runtime = { workspace = true } sp-core = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.8.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.0", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/payments/Cargo.toml b/payments/Cargo.toml index cfdf8a6c1..57c4b87be 100644 --- a/payments/Cargo.toml +++ b/payments/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Virto Network "] edition = '2021' name = "orml-payments" -version = "0.8.0" +version = "0.9.0" license = "Apache-2.0" homepage = "https://github.com/virto-network/virto-node" repository = "https://github.com/virto-network/virto-node" @@ -19,7 +19,7 @@ frame-system = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = {path = "../traits", version = "0.8.0", default-features = false } +orml-traits = {path = "../traits", version = "0.9.0", default-features = false } [dev-dependencies] serde = "1.0.136" diff --git a/rate-limit/Cargo.toml b/rate-limit/Cargo.toml index 7891cc92a..79fd48fa9 100644 --- a/rate-limit/Cargo.toml +++ b/rate-limit/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-rate-limit" description = "Provides way to config rate limiter for limit some operation." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/rate-limit" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Laminar Developers "] edition = "2021" @@ -19,8 +19,8 @@ sp-io = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.8.0", default-features = false } -orml-utilities = { path = "../utilities", version = "0.8.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.0", default-features = false } +orml-utilities = { path = "../utilities", version = "0.9.0", default-features = false } [dev-dependencies] pallet-timestamp = { workspace = true, features = ["std"] } diff --git a/rewards/Cargo.toml b/rewards/Cargo.toml index 8c2f7b56f..30a87ccc1 100644 --- a/rewards/Cargo.toml +++ b/rewards/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-rewards" description = "Store and manage shares and rewards" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/rewards" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Acala Developers"] edition = "2021" @@ -19,7 +19,7 @@ sp-io = { workspace = true } sp-runtime = { workspace = true, features = ["serde"] } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.8.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.0", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/tokens/Cargo.toml b/tokens/Cargo.toml index ff8dec2dd..86101a4a8 100644 --- a/tokens/Cargo.toml +++ b/tokens/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-tokens" description = "Fungible tokens module that implements `MultiCurrency` trait." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/tokens" license = "Apache-2.0" -version = "0.8.1" +version = "0.9.0" authors = ["Laminar Developers "] edition = "2021" @@ -19,7 +19,7 @@ sp-arithmetic = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.8.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.0", default-features = false } [dev-dependencies] pallet-elections-phragmen = { workspace = true, features = ["std"] } diff --git a/tokens/runtime-api/Cargo.toml b/tokens/runtime-api/Cargo.toml index 4b3a0e69f..316cc1b6c 100644 --- a/tokens/runtime-api/Cargo.toml +++ b/tokens/runtime-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orml-tokens-runtime-api" -version = "0.8.0" +version = "0.9.0" authors = ["Laminar Developers "] edition = "2021" license = "Apache-2.0" diff --git a/traits/Cargo.toml b/traits/Cargo.toml index 1951801fd..e82c1f36c 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-traits" description = "Shared traits including `BasicCurrency`, `MultiCurrency`, `Auction` and more." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/traits" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Laminar Developers "] edition = "2021" @@ -23,7 +23,7 @@ frame-support = { workspace = true } xcm = { workspace = true } -orml-utilities = { path = "../utilities", version = "0.8.0", default-features = false } +orml-utilities = { path = "../utilities", version = "0.9.0", default-features = false } [features] default = [ "std" ] diff --git a/unknown-tokens/Cargo.toml b/unknown-tokens/Cargo.toml index 765a328cf..2ce21249e 100644 --- a/unknown-tokens/Cargo.toml +++ b/unknown-tokens/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-unknown-tokens" description = "Unknown tokens module that implements `UnknownAsset` trait." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/unknown-tokens" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Acala Developers"] edition = "2021" @@ -18,7 +18,7 @@ sp-std = { workspace = true } xcm = { workspace = true } -orml-xcm-support = { path = "../xcm-support", version = "0.8.0", default-features = false } +orml-xcm-support = { path = "../xcm-support", version = "0.9.0", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/utilities/Cargo.toml b/utilities/Cargo.toml index b528bb3ba..db43b6838 100644 --- a/utilities/Cargo.toml +++ b/utilities/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-utilities" description = "Various utilities including `FixedU128` and `LinkedList`." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/utilities" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Laminar Developers "] edition = "2021" diff --git a/vesting/Cargo.toml b/vesting/Cargo.toml index e58ba5613..1fdfdc84c 100644 --- a/vesting/Cargo.toml +++ b/vesting/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-vesting" description = "Provides scheduled balance locking mechanism, in a *graded vesting* way." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/vesting" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Laminar Developers "] edition = "2021" diff --git a/xcm-mock-message-queue/Cargo.toml b/xcm-mock-message-queue/Cargo.toml index 403d2c7b4..d0168e420 100644 --- a/xcm-mock-message-queue/Cargo.toml +++ b/xcm-mock-message-queue/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xcm-mock-message-queue" description = "XCM Mock Message Qeueu for XCM Simulator tests" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xcm-mock-message-queue" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Acala Developers"] edition = "2021" diff --git a/xcm-support/Cargo.toml b/xcm-support/Cargo.toml index 34c002aa9..155245d64 100644 --- a/xcm-support/Cargo.toml +++ b/xcm-support/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xcm-support" description = "Supporting module for XCM integration." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xcm-support" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Acala Developers"] edition = "2021" @@ -17,7 +17,7 @@ sp-std = { workspace = true } xcm = { workspace = true } xcm-executor = { workspace = true } -orml-traits = { path = "../traits", version = "0.8.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.0", default-features = false } [features] default = [ "std" ] diff --git a/xcm/Cargo.toml b/xcm/Cargo.toml index 9510f22ae..c8ada5eef 100644 --- a/xcm/Cargo.toml +++ b/xcm/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xcm" description = "XCM message helpers." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xcm" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Acala Developers"] edition = "2021" diff --git a/xtokens/Cargo.toml b/xtokens/Cargo.toml index bcafc8196..d3b9a187a 100644 --- a/xtokens/Cargo.toml +++ b/xtokens/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xtokens" description = "Cross-chain token transfer." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xtokens" license = "Apache-2.0" -version = "0.8.0" +version = "0.9.0" authors = ["Acala Developers"] edition = "2021" @@ -26,8 +26,8 @@ xcm = { workspace = true } xcm-executor = { workspace = true } # orml -orml-traits = { path = "../traits", version = "0.8.0", default-features = false} -orml-xcm-support = { path = "../xcm-support", version = "0.8.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.0", default-features = false} +orml-xcm-support = { path = "../xcm-support", version = "0.9.0", default-features = false } [dev-dependencies] # substrate From bd4564bf1ee7291225f38eadb2019b64cc994643 Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Tue, 9 Apr 2024 16:44:34 +1200 Subject: [PATCH 04/13] chore: Release --- asset-registry/Cargo.toml | 4 ++-- auction/Cargo.toml | 4 ++-- authority/Cargo.toml | 2 +- benchmarking/Cargo.toml | 2 +- build-script-utils/Cargo.toml | 2 +- currencies/Cargo.toml | 6 +++--- gradually-update/Cargo.toml | 2 +- nft/Cargo.toml | 2 +- oracle/Cargo.toml | 6 +++--- oracle/runtime-api/Cargo.toml | 2 +- parameters/Cargo.toml | 4 ++-- payments/Cargo.toml | 4 ++-- rate-limit/Cargo.toml | 6 +++--- rewards/Cargo.toml | 4 ++-- tokens/Cargo.toml | 4 ++-- tokens/runtime-api/Cargo.toml | 2 +- traits/Cargo.toml | 4 ++-- unknown-tokens/Cargo.toml | 4 ++-- utilities/Cargo.toml | 2 +- vesting/Cargo.toml | 2 +- xcm-mock-message-queue/Cargo.toml | 2 +- xcm-support/Cargo.toml | 4 ++-- xcm/Cargo.toml | 2 +- xtokens/Cargo.toml | 6 +++--- 24 files changed, 41 insertions(+), 41 deletions(-) diff --git a/asset-registry/Cargo.toml b/asset-registry/Cargo.toml index 5ed17a03d..26dd887a2 100644 --- a/asset-registry/Cargo.toml +++ b/asset-registry/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-asset-registry" description = "Registry for (foreign) assets" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/asset-registry" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Interlay Ltd, etc"] edition = "2021" @@ -27,7 +27,7 @@ xcm-builder = { workspace = true } xcm-executor = { workspace = true } # orml -orml-traits = { path = "../traits", version = "0.9.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.1", default-features = false } # for runtime-benchmarks polkadot-runtime-common = { workspace = true, optional = true } diff --git a/auction/Cargo.toml b/auction/Cargo.toml index e78b40da8..adf914360 100644 --- a/auction/Cargo.toml +++ b/auction/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-auction" description = "Auction module that implements `Auction` trait." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/auction" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Acala Developers"] edition = "2021" @@ -17,7 +17,7 @@ frame-system = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.1", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/authority/Cargo.toml b/authority/Cargo.toml index 4296957a2..6c627f664 100644 --- a/authority/Cargo.toml +++ b/authority/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-authority" description = "Utility pallet to perform ROOT calls in a PoA network" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/auction" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Acala Developers"] edition = "2021" diff --git a/benchmarking/Cargo.toml b/benchmarking/Cargo.toml index bb704ade0..6bb578dfd 100644 --- a/benchmarking/Cargo.toml +++ b/benchmarking/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-benchmarking" description = "Provide macro to benchmark Substrate runtime." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/benchmarking" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Laminar Developers "] edition = "2021" diff --git a/build-script-utils/Cargo.toml b/build-script-utils/Cargo.toml index cdbeeec05..3a0c8de4a 100644 --- a/build-script-utils/Cargo.toml +++ b/build-script-utils/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-build-script-utils" description = "Crate with utility functions for `build.rs` scripts." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/build-script-utils" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Parity Technologies ", "Laminar Developers "] edition = "2021" diff --git a/currencies/Cargo.toml b/currencies/Cargo.toml index ce2ec7962..b52d083dc 100644 --- a/currencies/Cargo.toml +++ b/currencies/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-currencies" description = "Provide `MultiCurrency` implementation using `pallet-balances` and `orml-tokens` module." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/currencies" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Laminar Developers "] edition = "2021" @@ -18,8 +18,8 @@ sp-io = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.0", default-features = false } -orml-utilities = { path = "../utilities", version = "0.9.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.1", default-features = false } +orml-utilities = { path = "../utilities", version = "0.9.1", default-features = false } [dev-dependencies] pallet-balances = { workspace = true, features = ["std"] } diff --git a/gradually-update/Cargo.toml b/gradually-update/Cargo.toml index 4a799351c..d7cb1f51b 100644 --- a/gradually-update/Cargo.toml +++ b/gradually-update/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-gradually-update" description = "Provides way to adjust numeric parameter gradually over a period of time." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/gradually-update" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Laminar Developers "] edition = "2021" diff --git a/nft/Cargo.toml b/nft/Cargo.toml index 735fc9bec..66156c430 100644 --- a/nft/Cargo.toml +++ b/nft/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-nft" description = "Non-fungible token pallet provides basic functions to create and manager NFT" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/nft" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Acala Developers"] edition = "2021" diff --git a/oracle/Cargo.toml b/oracle/Cargo.toml index 05d60c23d..58f6f8dc5 100644 --- a/oracle/Cargo.toml +++ b/oracle/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-oracle" description = "Oracle module that makes off-chain data available on-chain." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/oracle" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Laminar Developers "] edition = "2021" @@ -20,8 +20,8 @@ sp-runtime = { workspace = true } sp-std = { workspace = true } frame-benchmarking = { workspace = true, optional = true } -orml-traits = { path = "../traits", version = "0.9.0", default-features = false } -orml-utilities = { path = "../utilities", version = "0.9.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.1", default-features = false } +orml-utilities = { path = "../utilities", version = "0.9.1", default-features = false } [dev-dependencies] sp-core = { workspace = true } diff --git a/oracle/runtime-api/Cargo.toml b/oracle/runtime-api/Cargo.toml index dc3602585..423550a9c 100644 --- a/oracle/runtime-api/Cargo.toml +++ b/oracle/runtime-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orml-oracle-runtime-api" -version = "0.9.0" +version = "0.9.1" authors = ["Laminar Developers "] edition = "2021" license = "Apache-2.0" diff --git a/parameters/Cargo.toml b/parameters/Cargo.toml index ca993edc3..92a3deb2b 100644 --- a/parameters/Cargo.toml +++ b/parameters/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-parameters" description = "Offer a centra place to store and configure parameters." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/parameters" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Acala Developers"] edition = "2021" @@ -18,7 +18,7 @@ sp-runtime = { workspace = true } sp-core = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.1", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/payments/Cargo.toml b/payments/Cargo.toml index 57c4b87be..8ed7c00fb 100644 --- a/payments/Cargo.toml +++ b/payments/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Virto Network "] edition = '2021' name = "orml-payments" -version = "0.9.0" +version = "0.9.1" license = "Apache-2.0" homepage = "https://github.com/virto-network/virto-node" repository = "https://github.com/virto-network/virto-node" @@ -19,7 +19,7 @@ frame-system = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = {path = "../traits", version = "0.9.0", default-features = false } +orml-traits = {path = "../traits", version = "0.9.1", default-features = false } [dev-dependencies] serde = "1.0.136" diff --git a/rate-limit/Cargo.toml b/rate-limit/Cargo.toml index 79fd48fa9..a46bc4547 100644 --- a/rate-limit/Cargo.toml +++ b/rate-limit/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-rate-limit" description = "Provides way to config rate limiter for limit some operation." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/rate-limit" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Laminar Developers "] edition = "2021" @@ -19,8 +19,8 @@ sp-io = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.0", default-features = false } -orml-utilities = { path = "../utilities", version = "0.9.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.1", default-features = false } +orml-utilities = { path = "../utilities", version = "0.9.1", default-features = false } [dev-dependencies] pallet-timestamp = { workspace = true, features = ["std"] } diff --git a/rewards/Cargo.toml b/rewards/Cargo.toml index 30a87ccc1..778f5cfa1 100644 --- a/rewards/Cargo.toml +++ b/rewards/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-rewards" description = "Store and manage shares and rewards" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/rewards" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Acala Developers"] edition = "2021" @@ -19,7 +19,7 @@ sp-io = { workspace = true } sp-runtime = { workspace = true, features = ["serde"] } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.1", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/tokens/Cargo.toml b/tokens/Cargo.toml index 86101a4a8..db0221c2a 100644 --- a/tokens/Cargo.toml +++ b/tokens/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-tokens" description = "Fungible tokens module that implements `MultiCurrency` trait." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/tokens" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Laminar Developers "] edition = "2021" @@ -19,7 +19,7 @@ sp-arithmetic = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.1", default-features = false } [dev-dependencies] pallet-elections-phragmen = { workspace = true, features = ["std"] } diff --git a/tokens/runtime-api/Cargo.toml b/tokens/runtime-api/Cargo.toml index 316cc1b6c..edd383c2a 100644 --- a/tokens/runtime-api/Cargo.toml +++ b/tokens/runtime-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orml-tokens-runtime-api" -version = "0.9.0" +version = "0.9.1" authors = ["Laminar Developers "] edition = "2021" license = "Apache-2.0" diff --git a/traits/Cargo.toml b/traits/Cargo.toml index e82c1f36c..1a21366e2 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-traits" description = "Shared traits including `BasicCurrency`, `MultiCurrency`, `Auction` and more." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/traits" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Laminar Developers "] edition = "2021" @@ -23,7 +23,7 @@ frame-support = { workspace = true } xcm = { workspace = true } -orml-utilities = { path = "../utilities", version = "0.9.0", default-features = false } +orml-utilities = { path = "../utilities", version = "0.9.1", default-features = false } [features] default = [ "std" ] diff --git a/unknown-tokens/Cargo.toml b/unknown-tokens/Cargo.toml index 2ce21249e..f6524e08f 100644 --- a/unknown-tokens/Cargo.toml +++ b/unknown-tokens/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-unknown-tokens" description = "Unknown tokens module that implements `UnknownAsset` trait." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/unknown-tokens" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Acala Developers"] edition = "2021" @@ -18,7 +18,7 @@ sp-std = { workspace = true } xcm = { workspace = true } -orml-xcm-support = { path = "../xcm-support", version = "0.9.0", default-features = false } +orml-xcm-support = { path = "../xcm-support", version = "0.9.1", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/utilities/Cargo.toml b/utilities/Cargo.toml index db43b6838..d9aea353f 100644 --- a/utilities/Cargo.toml +++ b/utilities/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-utilities" description = "Various utilities including `FixedU128` and `LinkedList`." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/utilities" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Laminar Developers "] edition = "2021" diff --git a/vesting/Cargo.toml b/vesting/Cargo.toml index 1fdfdc84c..55141caf6 100644 --- a/vesting/Cargo.toml +++ b/vesting/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-vesting" description = "Provides scheduled balance locking mechanism, in a *graded vesting* way." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/vesting" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Laminar Developers "] edition = "2021" diff --git a/xcm-mock-message-queue/Cargo.toml b/xcm-mock-message-queue/Cargo.toml index d0168e420..e4ad77912 100644 --- a/xcm-mock-message-queue/Cargo.toml +++ b/xcm-mock-message-queue/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xcm-mock-message-queue" description = "XCM Mock Message Qeueu for XCM Simulator tests" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xcm-mock-message-queue" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Acala Developers"] edition = "2021" diff --git a/xcm-support/Cargo.toml b/xcm-support/Cargo.toml index 155245d64..54156fb79 100644 --- a/xcm-support/Cargo.toml +++ b/xcm-support/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xcm-support" description = "Supporting module for XCM integration." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xcm-support" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Acala Developers"] edition = "2021" @@ -17,7 +17,7 @@ sp-std = { workspace = true } xcm = { workspace = true } xcm-executor = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.1", default-features = false } [features] default = [ "std" ] diff --git a/xcm/Cargo.toml b/xcm/Cargo.toml index c8ada5eef..44a819441 100644 --- a/xcm/Cargo.toml +++ b/xcm/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xcm" description = "XCM message helpers." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xcm" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Acala Developers"] edition = "2021" diff --git a/xtokens/Cargo.toml b/xtokens/Cargo.toml index d3b9a187a..5c5fcb8e0 100644 --- a/xtokens/Cargo.toml +++ b/xtokens/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xtokens" description = "Cross-chain token transfer." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xtokens" license = "Apache-2.0" -version = "0.9.0" +version = "0.9.1" authors = ["Acala Developers"] edition = "2021" @@ -26,8 +26,8 @@ xcm = { workspace = true } xcm-executor = { workspace = true } # orml -orml-traits = { path = "../traits", version = "0.9.0", default-features = false} -orml-xcm-support = { path = "../xcm-support", version = "0.9.0", default-features = false } +orml-traits = { path = "../traits", version = "0.9.1", default-features = false} +orml-xcm-support = { path = "../xcm-support", version = "0.9.1", default-features = false } [dev-dependencies] # substrate From 19f53ced5bb82db8a34d6b4ef218730ebbbb4ce5 Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Wed, 10 Apr 2024 21:49:41 +1200 Subject: [PATCH 05/13] improve self transfer handling (#990) --- rewards/src/lib.rs | 8 ++++++-- rewards/src/tests.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/rewards/src/lib.rs b/rewards/src/lib.rs index 59bd3567f..f1759221f 100644 --- a/rewards/src/lib.rs +++ b/rewards/src/lib.rs @@ -329,11 +329,15 @@ impl Pallet { move_share: T::Share, other: &T::AccountId, ) -> DispatchResult { - SharesAndWithdrawnRewards::::mutate(pool, other, |increased_share| { + SharesAndWithdrawnRewards::::try_mutate(pool, other, |increased_share| { let (increased_share, increased_rewards) = increased_share; - SharesAndWithdrawnRewards::::mutate_exists(pool, who, |share| { + SharesAndWithdrawnRewards::::try_mutate_exists(pool, who, |share| { let (share, rewards) = share.as_mut().ok_or(Error::::ShareDoesNotExist)?; ensure!(move_share < *share, Error::::CanSplitOnlyLessThanShare); + if who == other { + // self transfer is noop + return Ok(()); + } for (reward_currency, balance) in rewards { // u128 * u128 is always less than u256 // move_share / share always less then 1 and share > 0 diff --git a/rewards/src/tests.rs b/rewards/src/tests.rs index fb80a28bb..f558b184e 100644 --- a/rewards/src/tests.rs +++ b/rewards/src/tests.rs @@ -593,3 +593,35 @@ fn transfer_share_and_rewards() { ); }); } + +#[test] +fn transfer_share_and_rewards_self_transfer() { + ExtBuilder::default().build().execute_with(|| { + RewardsModule::add_share(&ALICE, &DOT_POOL, 100); + assert_ok!(RewardsModule::accumulate_reward(&DOT_POOL, NATIVE_COIN, 100)); + + assert_noop!( + RewardsModule::transfer_share_and_rewards(&BOB, &DOT_POOL, 50, &BOB), + Error::::ShareDoesNotExist + ); + assert_noop!( + RewardsModule::transfer_share_and_rewards(&ALICE, &DOT_POOL, 200, &ALICE), + Error::::CanSplitOnlyLessThanShare + ); + + let pool_info = RewardsModule::pool_infos(DOT_POOL); + assert_ok!(RewardsModule::transfer_share_and_rewards(&ALICE, &DOT_POOL, 33, &ALICE)); + + let new_pool_info = RewardsModule::pool_infos(DOT_POOL); + assert_eq!(pool_info, new_pool_info, "reward transfer does not affect the pool"); + + assert_eq!( + RewardsModule::shares_and_withdrawn_rewards(DOT_POOL, ALICE), + (100, Default::default()) + ); + assert_eq!( + RewardsModule::shares_and_withdrawn_rewards(DOT_POOL, BOB), + (0, Default::default()) + ); + }); +} From c572223629d95630cb800276fb5d0ed036b44637 Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Thu, 11 Apr 2024 14:35:30 +1200 Subject: [PATCH 06/13] Minimal share (#991) * require a minimal share * fix --- oracle/src/lib.rs | 6 ++- rewards/src/lib.rs | 82 ++++++++++++++++++++++++++---------- rewards/src/mock.rs | 11 +++++ rewards/src/tests.rs | 98 ++++++++++++++++++++++++++++++-------------- 4 files changed, 143 insertions(+), 54 deletions(-) diff --git a/oracle/src/lib.rs b/oracle/src/lib.rs index ede378a44..2a0bc3104 100644 --- a/oracle/src/lib.rs +++ b/oracle/src/lib.rs @@ -55,9 +55,11 @@ pub use weights::WeightInfo; #[cfg(feature = "runtime-benchmarks")] /// Helper trait for benchmarking. pub trait BenchmarkHelper> { - /// Returns a list of `(oracle_key, oracle_value)` pairs to be used for benchmarking. + /// Returns a list of `(oracle_key, oracle_value)` pairs to be used for + /// benchmarking. /// - /// NOTE: User should ensure to at least submit two values, otherwise the benchmark linear analysis might fail. + /// NOTE: User should ensure to at least submit two values, otherwise the + /// benchmark linear analysis might fail. fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L>; } diff --git a/rewards/src/lib.rs b/rewards/src/lib.rs index f1759221f..85e127d1b 100644 --- a/rewards/src/lib.rs +++ b/rewards/src/lib.rs @@ -6,7 +6,7 @@ mod mock; mod tests; use frame_support::pallet_prelude::*; -use orml_traits::RewardHandler; +use orml_traits::{GetByKey, RewardHandler}; use parity_scale_codec::{FullCodec, HasCompact}; use scale_info::TypeInfo; use sp_core::U256; @@ -73,6 +73,11 @@ pub mod module { type CurrencyId: Parameter + Member + Copy + MaybeSerializeDeserialize + Ord; + /// The minimal amount of shares an account can hold. + /// Transactions that would result in an account holding shares fewer + /// than this amount but non zero are invalid. + type MinimalShares: GetByKey; + /// The `RewardHandler` type Handler: RewardHandler; } @@ -83,8 +88,12 @@ pub mod module { pub enum Error { /// Pool does not exist PoolDoesNotExist, + /// Account does not have share ShareDoesNotExist, + /// Can split only less than share CanSplitOnlyLessThanShare, + /// Share amount below minimal + ShareBelowMinimal, } /// Record reward pool info. @@ -140,12 +149,12 @@ impl Pallet { }) } - pub fn add_share(who: &T::AccountId, pool: &T::PoolId, add_amount: T::Share) { + pub fn add_share(who: &T::AccountId, pool: &T::PoolId, add_amount: T::Share) -> DispatchResult { if add_amount.is_zero() { - return; + return Ok(()); } - PoolInfos::::mutate(pool, |pool_info| { + PoolInfos::::try_mutate(pool, |pool_info| { let initial_total_shares = pool_info.total_shares; pool_info.total_shares = pool_info.total_shares.saturating_add(add_amount); @@ -171,8 +180,11 @@ impl Pallet { withdrawn_inflation.push((*reward_currency, reward_inflation)); }); - SharesAndWithdrawnRewards::::mutate(pool, who, |(share, withdrawn_rewards)| { + SharesAndWithdrawnRewards::::try_mutate(pool, who, |(share, withdrawn_rewards)| { *share = share.saturating_add(add_amount); + + ensure!(*share >= T::MinimalShares::get(pool), Error::::ShareBelowMinimal); + // update withdrawn inflation for each reward currency withdrawn_inflation .into_iter() @@ -184,27 +196,36 @@ impl Pallet { }) .or_insert(reward_inflation); }); - }); - }); + + Ok(()) + }) + }) } - pub fn remove_share(who: &T::AccountId, pool: &T::PoolId, remove_amount: T::Share) { + pub fn remove_share(who: &T::AccountId, pool: &T::PoolId, remove_amount: T::Share) -> DispatchResult { if remove_amount.is_zero() { - return; + return Ok(()); } // claim rewards firstly Self::claim_rewards(who, pool); - SharesAndWithdrawnRewards::::mutate_exists(pool, who, |share_info| { + SharesAndWithdrawnRewards::::try_mutate_exists(pool, who, |share_info| { if let Some((mut share, mut withdrawn_rewards)) = share_info.take() { let remove_amount = remove_amount.min(share); if remove_amount.is_zero() { - return; + return Ok(()); } - PoolInfos::::mutate_exists(pool, |maybe_pool_info| { + let old_share = share; + + share = share.saturating_sub(remove_amount); + if !share.is_zero() { + ensure!(share >= T::MinimalShares::get(pool), Error::::ShareBelowMinimal); + } + + PoolInfos::::try_mutate_exists(pool, |maybe_pool_info| -> DispatchResult { if let Some(mut pool_info) = maybe_pool_info.take() { let removing_share = U256::from(remove_amount.saturated_into::()); @@ -216,7 +237,7 @@ impl Pallet { .for_each(|(reward_currency, withdrawn_reward)| { let withdrawn_reward_to_remove: T::Balance = removing_share .saturating_mul(withdrawn_reward.to_owned().saturated_into::().into()) - .checked_div(share.saturated_into::().into()) + .checked_div(old_share.saturated_into::().into()) .unwrap_or_default() .as_u128() .saturated_into(); @@ -240,23 +261,26 @@ impl Pallet { *maybe_pool_info = Some(pool_info); } } - }); - share = share.saturating_sub(remove_amount); - if !share.is_zero() { - *share_info = Some((share, withdrawn_rewards)); - } + if !share.is_zero() { + *share_info = Some((share, withdrawn_rewards)); + } + + Ok(()) + })?; } - }); + + Ok(()) + }) } - pub fn set_share(who: &T::AccountId, pool: &T::PoolId, new_share: T::Share) { + pub fn set_share(who: &T::AccountId, pool: &T::PoolId, new_share: T::Share) -> DispatchResult { let (share, _) = Self::shares_and_withdrawn_rewards(pool, who); if new_share > share { - Self::add_share(who, pool, new_share.saturating_sub(share)); + Self::add_share(who, pool, new_share.saturating_sub(share)) } else { - Self::remove_share(who, pool, share.saturating_sub(new_share)); + Self::remove_share(who, pool, share.saturating_sub(new_share)) } } @@ -329,6 +353,10 @@ impl Pallet { move_share: T::Share, other: &T::AccountId, ) -> DispatchResult { + if move_share.is_zero() { + return Ok(()); + } + SharesAndWithdrawnRewards::::try_mutate(pool, other, |increased_share| { let (increased_share, increased_rewards) = increased_share; SharesAndWithdrawnRewards::::try_mutate_exists(pool, who, |share| { @@ -359,6 +387,16 @@ impl Pallet { } *share = share.saturating_sub(move_share); *increased_share = increased_share.saturating_add(move_share); + + ensure!( + *share >= T::MinimalShares::get(pool) || share.is_zero(), + Error::::ShareBelowMinimal + ); + ensure!( + *increased_share >= T::MinimalShares::get(pool), + Error::::ShareBelowMinimal + ); + Ok(()) }) }) diff --git a/rewards/src/mock.rs b/rewards/src/mock.rs index c46c03b69..6fb3618e4 100644 --- a/rewards/src/mock.rs +++ b/rewards/src/mock.rs @@ -4,6 +4,7 @@ use super::*; use frame_support::{construct_runtime, derive_impl}; +use orml_traits::parameter_type_with_key; use sp_runtime::{traits::IdentityLookup, BuildStorage}; use sp_std::cell::RefCell; use std::collections::HashMap; @@ -53,12 +54,22 @@ impl RewardHandler for Handler { } } +parameter_type_with_key! { + pub MinimalShares: |pool_id: PoolId| -> Share { + match pool_id { + &DOT_POOL => 10, + _ => 0, + } + }; +} + impl Config for Runtime { type Share = Share; type Balance = Balance; type PoolId = PoolId; type CurrencyId = CurrencyId; type Handler = Handler; + type MinimalShares = MinimalShares; } type Block = frame_system::mocking::MockBlock; diff --git a/rewards/src/tests.rs b/rewards/src/tests.rs index f558b184e..3235d5c6e 100644 --- a/rewards/src/tests.rs +++ b/rewards/src/tests.rs @@ -15,14 +15,14 @@ fn add_share_should_work() { Default::default() ); - RewardsModule::add_share(&ALICE, &DOT_POOL, 0); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 0)); assert_eq!(RewardsModule::pool_infos(DOT_POOL), Default::default()); assert_eq!( RewardsModule::shares_and_withdrawn_rewards(DOT_POOL, ALICE), Default::default() ); - RewardsModule::add_share(&ALICE, &DOT_POOL, 100); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 100)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), @@ -52,7 +52,7 @@ fn add_share_should_work() { Default::default() ); - RewardsModule::add_share(&BOB, &DOT_POOL, 50); + assert_ok!(RewardsModule::add_share(&BOB, &DOT_POOL, 50)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), @@ -66,7 +66,7 @@ fn add_share_should_work() { (50, vec![(NATIVE_COIN, 2_500)].into_iter().collect()) ); - RewardsModule::add_share(&ALICE, &DOT_POOL, 100); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 100)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), @@ -76,7 +76,7 @@ fn add_share_should_work() { } ); - RewardsModule::add_share(&ALICE, &DOT_POOL, 50); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 50)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), @@ -91,7 +91,7 @@ fn add_share_should_work() { ); // overflow occurs when saturating calculation - RewardsModule::add_share(&ALICE, &DOT_POOL, u64::MAX); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, u64::MAX)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), @@ -125,7 +125,7 @@ fn claim_rewards_should_not_create_empty_records() { PoolInfos::::mutate(DOT_POOL, |pool_info| { pool_info.rewards.insert(NATIVE_COIN, (10_000, 0)); }); - RewardsModule::add_share(&ALICE, &DOT_POOL, 100); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 100)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), PoolInfo { @@ -153,12 +153,12 @@ fn claim_rewards_should_not_create_empty_records() { #[test] fn claim_rewards_should_work() { ExtBuilder::default().build().execute_with(|| { - RewardsModule::add_share(&ALICE, &DOT_POOL, 100); - RewardsModule::add_share(&BOB, &DOT_POOL, 100); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 100)); + assert_ok!(RewardsModule::add_share(&BOB, &DOT_POOL, 100)); PoolInfos::::mutate(DOT_POOL, |pool_info| { pool_info.rewards.insert(NATIVE_COIN, (5_000, 0)); }); - RewardsModule::add_share(&CAROL, &DOT_POOL, 200); + assert_ok!(RewardsModule::add_share(&CAROL, &DOT_POOL, 200)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), PoolInfo { @@ -248,8 +248,8 @@ fn claim_rewards_should_work() { #[test] fn remove_share_should_work() { ExtBuilder::default().build().execute_with(|| { - RewardsModule::add_share(&ALICE, &DOT_POOL, 100); - RewardsModule::add_share(&BOB, &DOT_POOL, 100); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 100)); + assert_ok!(RewardsModule::add_share(&BOB, &DOT_POOL, 100)); PoolInfos::::mutate(DOT_POOL, |pool_info| { pool_info.rewards.insert(NATIVE_COIN, (10_000, 0)); }); @@ -279,7 +279,7 @@ fn remove_share_should_work() { ); // remove amount is zero, do not claim interest - RewardsModule::remove_share(&ALICE, &DOT_POOL, 0); + assert_ok!(RewardsModule::remove_share(&ALICE, &DOT_POOL, 0)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), PoolInfo { @@ -296,7 +296,7 @@ fn remove_share_should_work() { 0 ); - RewardsModule::remove_share(&BOB, &DOT_POOL, 50); + assert_ok!(RewardsModule::remove_share(&BOB, &DOT_POOL, 50)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), PoolInfo { @@ -313,7 +313,7 @@ fn remove_share_should_work() { 5_000 ); - RewardsModule::remove_share(&ALICE, &DOT_POOL, 101); + assert_ok!(RewardsModule::remove_share(&ALICE, &DOT_POOL, 101)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), PoolInfo { @@ -336,7 +336,7 @@ fn remove_share_should_work() { ); // remove all shares will remove entries - RewardsModule::remove_share(&BOB, &DOT_POOL, 100); + assert_ok!(RewardsModule::remove_share(&BOB, &DOT_POOL, 100)); assert_eq!(RewardsModule::pool_infos(DOT_POOL), PoolInfo::default()); assert_eq!(PoolInfos::::contains_key(DOT_POOL), false); assert_eq!(PoolInfos::::iter().count(), 0); @@ -357,7 +357,7 @@ fn set_share_should_work() { Default::default() ); - RewardsModule::set_share(&ALICE, &DOT_POOL, 100); + assert_ok!(RewardsModule::set_share(&ALICE, &DOT_POOL, 100)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), @@ -382,7 +382,7 @@ fn set_share_should_work() { } ); - RewardsModule::set_share(&ALICE, &DOT_POOL, 500); + assert_ok!(RewardsModule::set_share(&ALICE, &DOT_POOL, 500)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), PoolInfo { @@ -404,7 +404,7 @@ fn set_share_should_work() { } ); - RewardsModule::set_share(&ALICE, &DOT_POOL, 600); + assert_ok!(RewardsModule::set_share(&ALICE, &DOT_POOL, 600)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), PoolInfo { @@ -430,7 +430,7 @@ fn set_share_should_work() { 0 ); - RewardsModule::set_share(&ALICE, &DOT_POOL, 100); + assert_ok!(RewardsModule::set_share(&ALICE, &DOT_POOL, 100)); assert_eq!( RewardsModule::pool_infos(DOT_POOL), PoolInfo { @@ -470,7 +470,7 @@ fn accumulate_reward_should_work() { ); assert_eq!(RewardsModule::pool_infos(DOT_POOL), PoolInfo::default()); - RewardsModule::add_share(&ALICE, &DOT_POOL, 100); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 100)); assert_ok!(RewardsModule::accumulate_reward(&DOT_POOL, NATIVE_COIN, 100)); assert_eq!( @@ -501,8 +501,8 @@ fn share_to_zero_removes_storage() { SharesAndWithdrawnRewards::::contains_key(DOT_POOL, ALICE), false ); - RewardsModule::add_share(&ALICE, &DOT_POOL, 100); - RewardsModule::add_share(&BOB, &DOT_POOL, 100); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 100)); + assert_ok!(RewardsModule::add_share(&BOB, &DOT_POOL, 100)); PoolInfos::::mutate(DOT_POOL, |pool_info| { pool_info.rewards.insert(NATIVE_COIN, (10000, 0)); }); @@ -520,16 +520,16 @@ fn share_to_zero_removes_storage() { SharesAndWithdrawnRewards::::contains_key(DOT_POOL, ALICE), true ); - RewardsModule::remove_share(&ALICE, &DOT_POOL, 100); + assert_ok!(RewardsModule::remove_share(&ALICE, &DOT_POOL, 100)); assert_eq!( SharesAndWithdrawnRewards::::contains_key(DOT_POOL, ALICE), false ); - RewardsModule::remove_share(&BOB, &DOT_POOL, 50); + assert_ok!(RewardsModule::remove_share(&BOB, &DOT_POOL, 50)); assert_eq!(SharesAndWithdrawnRewards::::contains_key(DOT_POOL, BOB), true); - RewardsModule::remove_share(&BOB, &DOT_POOL, 100); + assert_ok!(RewardsModule::remove_share(&BOB, &DOT_POOL, 100)); assert_eq!(SharesAndWithdrawnRewards::::contains_key(DOT_POOL, BOB), false); }); } @@ -539,7 +539,7 @@ fn claim_single_reward() { ExtBuilder::default().build().execute_with(|| { assert_eq!(RewardsModule::pool_infos(DOT_POOL), PoolInfo::default()); - RewardsModule::add_share(&ALICE, &DOT_POOL, 100); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 100)); assert_ok!(RewardsModule::accumulate_reward(&DOT_POOL, NATIVE_COIN, 100)); assert_ok!(RewardsModule::accumulate_reward(&DOT_POOL, STABLE_COIN, 200)); @@ -560,9 +560,9 @@ fn claim_single_reward() { #[test] fn transfer_share_and_rewards() { ExtBuilder::default().build().execute_with(|| { - RewardsModule::add_share(&ALICE, &DOT_POOL, 100); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 100)); assert_ok!(RewardsModule::accumulate_reward(&DOT_POOL, NATIVE_COIN, 100)); - RewardsModule::add_share(&BOB, &DOT_POOL, 100); + assert_ok!(RewardsModule::add_share(&BOB, &DOT_POOL, 100)); let pool_info = RewardsModule::pool_infos(DOT_POOL); assert_ok!(RewardsModule::transfer_share_and_rewards(&ALICE, &DOT_POOL, 33, &BOB)); assert_ok!(RewardsModule::transfer_share_and_rewards(&ALICE, &DOT_POOL, 33, &CAROL)); @@ -597,7 +597,7 @@ fn transfer_share_and_rewards() { #[test] fn transfer_share_and_rewards_self_transfer() { ExtBuilder::default().build().execute_with(|| { - RewardsModule::add_share(&ALICE, &DOT_POOL, 100); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 100)); assert_ok!(RewardsModule::accumulate_reward(&DOT_POOL, NATIVE_COIN, 100)); assert_noop!( @@ -625,3 +625,41 @@ fn transfer_share_and_rewards_self_transfer() { ); }); } + +#[test] +fn minimal_share_should_be_enforced() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + RewardsModule::add_share(&ALICE, &DOT_POOL, 1), + Error::::ShareBelowMinimal + ); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 10)); + assert_ok!(RewardsModule::add_share(&ALICE, &DOT_POOL, 1)); + + assert_noop!( + RewardsModule::remove_share(&ALICE, &DOT_POOL, 2), + Error::::ShareBelowMinimal + ); + assert_ok!(RewardsModule::remove_share(&ALICE, &DOT_POOL, 1)); + assert_ok!(RewardsModule::remove_share(&ALICE, &DOT_POOL, 10)); + + assert_noop!( + RewardsModule::set_share(&ALICE, &DOT_POOL, 1), + Error::::ShareBelowMinimal + ); + assert_ok!(RewardsModule::set_share(&ALICE, &DOT_POOL, 10)); + + assert_noop!( + RewardsModule::transfer_share_and_rewards(&ALICE, &DOT_POOL, 1, &BOB), + Error::::ShareBelowMinimal + ); + + assert_ok!(RewardsModule::set_share(&ALICE, &DOT_POOL, 15)); + assert_ok!(RewardsModule::set_share(&BOB, &DOT_POOL, 10)); + assert_noop!( + RewardsModule::transfer_share_and_rewards(&ALICE, &DOT_POOL, 6, &BOB), + Error::::ShareBelowMinimal + ); + assert_ok!(RewardsModule::transfer_share_and_rewards(&ALICE, &DOT_POOL, 5, &BOB)); + }); +} From 9af1fa501d2656b4d0ddf47023c40d437b276da1 Mon Sep 17 00:00:00 2001 From: deferdeter <166976362+deferdeter@users.noreply.github.com> Date: Tue, 16 Apr 2024 15:26:57 +0800 Subject: [PATCH 07/13] chore: fix some comments (#993) Signed-off-by: deferdeter --- oracle/src/tests.rs | 2 +- rate-limit/src/tests.rs | 4 ++-- tokens/src/tests.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/oracle/src/tests.rs b/oracle/src/tests.rs index b116c25c5..2fa02f31c 100644 --- a/oracle/src/tests.rs +++ b/oracle/src/tests.rs @@ -200,7 +200,7 @@ fn multiple_calls_should_fail() { vec![(50, 1300)].try_into().unwrap() )); - // Fails feeding by the the extrinsic + // Fails feeding by the extrinsic assert_noop!( ModuleOracle::feed_values(RuntimeOrigin::signed(1), vec![(50, 1300)].try_into().unwrap()), Error::::AlreadyFeeded, diff --git a/rate-limit/src/tests.rs b/rate-limit/src/tests.rs index 4a4817b55..52ecb3aa4 100644 --- a/rate-limit/src/tests.rs +++ b/rate-limit/src/tests.rs @@ -756,7 +756,7 @@ fn consume_work() { assert_eq!(RateLimit::rate_limit_quota(0, BTC.encode()), (0, 100)); assert_eq!(RateLimit::rate_limit_quota(0, ETH.encode()), (0, 1000)); - // consume when vaule > remainer_quota + // consume when value > remainer_quota RateLimit::consume(1, ETH, 1000); assert_eq!(RateLimit::rate_limit_quota(1, ETH.encode()), (0, 0)); }); @@ -834,7 +834,7 @@ fn can_consume_work() { assert_ok!(RateLimit::can_consume(1, BTC, 10000)); assert_ok!(RateLimit::can_consume(1, BTC, u128::MAX)); - // if dosen't config rule, always return true + // if doesn't config rule, always return true assert_eq!(RateLimitRules::::contains_key(0, ETH.encode()), false); assert_ok!(RateLimit::can_consume(0, ETH, 10000)); assert_ok!(RateLimit::can_consume(0, ETH, u128::MAX)); diff --git a/tokens/src/tests.rs b/tokens/src/tests.rs index 504ca06ab..458fe25e5 100644 --- a/tokens/src/tests.rs +++ b/tokens/src/tests.rs @@ -668,7 +668,7 @@ fn do_transfer_report_keep_alive_error_when_ed_is_not_zero() { ); // even if dave is in dust removal whitelist, but account drain will still cause - // account be be reaped. + // account be reaped. assert_noop!( Tokens::do_transfer(DOT, &DAVE, &BOB, 100, ExistenceRequirement::KeepAlive), Error::::KeepAlive From 26d89d3056b59d2d5ff2c0ffa152fd159a953d47 Mon Sep 17 00:00:00 2001 From: clangenb <37865735+clangenb@users.noreply.github.com> Date: Wed, 17 Apr 2024 15:34:28 +0800 Subject: [PATCH 08/13] update to polkadot-v1.10.0 (#994) * polkadot-v1.10.0 * Use scheduler v3::Named instead of v1 * allow deprecated schedule::v1 api --- Cargo.dev.toml | 60 +++++++++++++------------- asset-registry/src/mock/para.rs | 3 ++ asset-registry/src/mock/relay.rs | 4 ++ authority/src/lib.rs | 11 ++++- xtokens/src/mock/para.rs | 3 ++ xtokens/src/mock/para_relative_view.rs | 3 ++ xtokens/src/mock/para_teleport.rs | 3 ++ xtokens/src/mock/relay.rs | 4 ++ 8 files changed, 60 insertions(+), 31 deletions(-) diff --git a/Cargo.dev.toml b/Cargo.dev.toml index ed490f47e..42f7e0933 100644 --- a/Cargo.dev.toml +++ b/Cargo.dev.toml @@ -37,35 +37,35 @@ scale-info = { version = "2.10.0", default-features = false, features = ["derive serde = { version = "1.0.189" } parity-scale-codec = { version = "3.6.5", default-features = false, features = ["max-encoded-len"] } -cumulus-pallet-xcm = { version = "0.10.0", default-features = false } -cumulus-primitives-core = { version = "0.10.0", default-features = false } -frame-benchmarking = { version = "31.0.0", default-features = false } -frame-support = { version = "31.0.0", default-features = false } -frame-system = { version = "31.0.0", default-features = false } -pallet-balances = { version = "31.0.0", default-features = false } -pallet-elections-phragmen = { version = "32.0.0", default-features = false } -pallet-message-queue = { version = "34.0.0", default-features = false } -pallet-preimage = { version = "31.0.0", default-features = false } -pallet-root-testing = { version = "7.0.0", default-features = false } -pallet-scheduler = { version = "32.0.0", default-features = false } -pallet-timestamp = { version = "30.0.0", default-features = false } -pallet-treasury = { version = "30.0.0", default-features = false } -pallet-xcm = { version = "10.0.0", default-features = false } -polkadot-parachain-primitives = { version = "9.0.0", default-features = false } -polkadot-runtime-common = { version = "10.0.0", default-features = false } -polkadot-runtime-parachains = { version = "10.0.0", default-features = false } -sp-api = { version = "29.0.0", default-features = false } -sp-application-crypto = { version = "33.0.0", default-features = false } -sp-arithmetic = { version = "25.0.0", default-features = false } -sp-core = { version = "31.0.0", default-features = false } -sp-io = { version = "33.0.0", default-features = false } -sp-runtime = { version = "34.0.0", default-features = false } -sp-runtime-interface = { version = "26.0.0", default-features = false } -sp-staking = { version = "29.0.0", default-features = false } +cumulus-pallet-xcm = { version = "0.11.0", default-features = false } +cumulus-primitives-core = { version = "0.11.0", default-features = false } +frame-benchmarking = { version = "32.0.0", default-features = false } +frame-support = { version = "32.0.0", default-features = false } +frame-system = { version = "32.0.0", default-features = false } +pallet-balances = { version = "33.0.0", default-features = false } +pallet-elections-phragmen = { version = "33.0.0", default-features = false } +pallet-message-queue = { version = "35.0.0", default-features = false } +pallet-preimage = { version = "32.0.0", default-features = false } +pallet-root-testing = { version = "8.0.0", default-features = false } +pallet-scheduler = { version = "33.0.0", default-features = false } +pallet-timestamp = { version = "31.0.0", default-features = false } +pallet-treasury = { version = "31.0.0", default-features = false } +pallet-xcm = { version = "11.0.0", default-features = false } +polkadot-parachain-primitives = { version = "10.0.0", default-features = false } +polkadot-runtime-common = { version = "11.0.0", default-features = false } +polkadot-runtime-parachains = { version = "11.0.0", default-features = false } +sp-api = { version = "30.0.0", default-features = false } +sp-application-crypto = { version = "34.0.0", default-features = false } +sp-arithmetic = { version = "26.0.0", default-features = false } +sp-core = { version = "32.0.0", default-features = false } +sp-io = { version = "34.0.0", default-features = false } +sp-runtime = { version = "35.0.0", default-features = false } +sp-runtime-interface = { version = "27.0.0", default-features = false } +sp-staking = { version = "30.0.0", default-features = false } sp-std = { version = "14.0.0", default-features = false } -sp-storage = { version = "20.0.0", default-features = false } -xcm = { version = "10.0.0", package = "staging-xcm", default-features = false } -xcm-builder = { version = "10.0.0", package = "staging-xcm-builder", default-features = false } -xcm-executor = { version = "10.0.0", package = "staging-xcm-executor", default-features = false } +sp-storage = { version = "21.0.0", default-features = false } +xcm = { version = "11.0.0", package = "staging-xcm", default-features = false } +xcm-builder = { version = "11.0.0", package = "staging-xcm-builder", default-features = false } +xcm-executor = { version = "11.0.0", package = "staging-xcm-executor", default-features = false } -xcm-simulator = { version = "10.0.0" } +xcm-simulator = { version = "11.0.0" } diff --git a/asset-registry/src/mock/para.rs b/asset-registry/src/mock/para.rs index cd428225c..6829e4225 100644 --- a/asset-registry/src/mock/para.rs +++ b/asset-registry/src/mock/para.rs @@ -233,6 +233,9 @@ impl Config for XcmConfig { type SafeCallFilter = Everything; type Aliasers = Nothing; type TransactionalProcessor = (); + type HrmpNewChannelOpenRequestHandler = (); + type HrmpChannelAcceptedHandler = (); + type HrmpChannelClosingHandler = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/asset-registry/src/mock/relay.rs b/asset-registry/src/mock/relay.rs index 146d71b0e..05eedfd6b 100644 --- a/asset-registry/src/mock/relay.rs +++ b/asset-registry/src/mock/relay.rs @@ -110,6 +110,9 @@ impl Config for XcmConfig { type SafeCallFilter = Everything; type Aliasers = Nothing; type TransactionalProcessor = (); + type HrmpNewChannelOpenRequestHandler = (); + type HrmpChannelAcceptedHandler = (); + type HrmpChannelClosingHandler = (); } pub type LocalOriginToLocation = SignedToAccountId32; @@ -187,6 +190,7 @@ impl pallet_message_queue::Config for Runtime { type QueueChangeHandler = (); type QueuePausedQuery = (); type WeightInfo = (); + type IdleMaxServiceWeight = (); } construct_runtime!( diff --git a/authority/src/lib.rs b/authority/src/lib.rs index ff148b2dc..3fcb627e2 100644 --- a/authority/src/lib.rs +++ b/authority/src/lib.rs @@ -31,7 +31,7 @@ use frame_support::{ dispatch::{DispatchClass, GetDispatchInfo, Pays}, pallet_prelude::*, traits::{ - schedule::{v1::Named as ScheduleNamed, DispatchTime, Priority}, + schedule::{DispatchTime, Priority}, EitherOfDiverse, EnsureOrigin, Get, IsType, OriginTrait, }, }; @@ -45,6 +45,10 @@ use sp_runtime::{ }; use sp_std::prelude::*; +// Todo: Switch to current v3 api: https://github.com/open-web3-stack/open-runtime-module-library/issues/995 +#[allow(deprecated)] +use frame_support::traits::schedule::v1::Named as ScheduleNamed; + mod mock; mod tests; mod weights; @@ -215,6 +219,7 @@ pub mod module { + GetDispatchInfo; /// The Scheduler. + #[allow(deprecated)] type Scheduler: ScheduleNamed, ::RuntimeCall, Self::PalletsOrigin>; /// The type represent origin that can be dispatched by other origins. @@ -357,6 +362,7 @@ pub mod module { }; let pallets_origin = schedule_origin.caller().clone(); + #[allow(deprecated)] T::Scheduler::schedule_named( Encode::encode(&(&pallets_origin, id)), when, @@ -394,6 +400,7 @@ pub mod module { }; T::AuthorityConfig::check_fast_track_schedule(origin, &initial_origin, new_delay)?; + #[allow(deprecated)] T::Scheduler::reschedule_named((&initial_origin, task_id).encode(), when) .map_err(|_| Error::::FailedToFastTrack)?; @@ -416,6 +423,7 @@ pub mod module { ) -> DispatchResult { T::AuthorityConfig::check_delay_schedule(origin, &initial_origin)?; + #[allow(deprecated)] T::Scheduler::reschedule_named( (&initial_origin, task_id).encode(), DispatchTime::After(additional_delay), @@ -442,6 +450,7 @@ pub mod module { task_id: ScheduleTaskIndex, ) -> DispatchResult { T::AuthorityConfig::check_cancel_schedule(origin, &initial_origin)?; + #[allow(deprecated)] T::Scheduler::cancel_named((&initial_origin, task_id).encode()).map_err(|_| Error::::FailedToCancel)?; Self::deposit_event(Event::Cancelled { diff --git a/xtokens/src/mock/para.rs b/xtokens/src/mock/para.rs index 5ece9ab6a..159c8bf8c 100644 --- a/xtokens/src/mock/para.rs +++ b/xtokens/src/mock/para.rs @@ -144,6 +144,9 @@ impl Config for XcmConfig { type SafeCallFilter = Everything; type Aliasers = (); type TransactionalProcessor = (); + type HrmpNewChannelOpenRequestHandler = (); + type HrmpChannelAcceptedHandler = (); + type HrmpChannelClosingHandler = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/xtokens/src/mock/para_relative_view.rs b/xtokens/src/mock/para_relative_view.rs index 248cef833..8b3d79f0e 100644 --- a/xtokens/src/mock/para_relative_view.rs +++ b/xtokens/src/mock/para_relative_view.rs @@ -142,6 +142,9 @@ impl Config for XcmConfig { type SafeCallFilter = Everything; type Aliasers = (); type TransactionalProcessor = (); + type HrmpNewChannelOpenRequestHandler = (); + type HrmpChannelAcceptedHandler = (); + type HrmpChannelClosingHandler = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/xtokens/src/mock/para_teleport.rs b/xtokens/src/mock/para_teleport.rs index 6fcb6f7ef..ea882fdaa 100644 --- a/xtokens/src/mock/para_teleport.rs +++ b/xtokens/src/mock/para_teleport.rs @@ -140,6 +140,9 @@ impl Config for XcmConfig { type SafeCallFilter = Everything; type Aliasers = (); type TransactionalProcessor = (); + type HrmpNewChannelOpenRequestHandler = (); + type HrmpChannelAcceptedHandler = (); + type HrmpChannelClosingHandler = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/xtokens/src/mock/relay.rs b/xtokens/src/mock/relay.rs index c8c02c6bd..a9d1d2912 100644 --- a/xtokens/src/mock/relay.rs +++ b/xtokens/src/mock/relay.rs @@ -120,6 +120,9 @@ impl Config for XcmConfig { type SafeCallFilter = Everything; type Aliasers = (); type TransactionalProcessor = (); + type HrmpNewChannelOpenRequestHandler = (); + type HrmpChannelAcceptedHandler = (); + type HrmpChannelClosingHandler = (); } pub type LocalOriginToLocation = SignedToAccountId32; @@ -193,6 +196,7 @@ impl pallet_message_queue::Config for Runtime { type QueueChangeHandler = (); type QueuePausedQuery = (); type WeightInfo = (); + type IdleMaxServiceWeight = (); } construct_runtime!( From d7c5f8ddd7f1f225d8bf05625556c4a055141792 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 07:44:01 +0000 Subject: [PATCH 09/13] chore: Release (#996) Co-authored-by: github-actions --- asset-registry/Cargo.toml | 4 ++-- auction/Cargo.toml | 4 ++-- authority/Cargo.toml | 2 +- benchmarking/Cargo.toml | 2 +- build-script-utils/Cargo.toml | 2 +- currencies/Cargo.toml | 6 +++--- gradually-update/Cargo.toml | 2 +- nft/Cargo.toml | 2 +- oracle/Cargo.toml | 6 +++--- oracle/runtime-api/Cargo.toml | 2 +- parameters/Cargo.toml | 4 ++-- payments/Cargo.toml | 4 ++-- rate-limit/Cargo.toml | 6 +++--- rewards/Cargo.toml | 4 ++-- tokens/Cargo.toml | 4 ++-- tokens/runtime-api/Cargo.toml | 2 +- traits/Cargo.toml | 4 ++-- unknown-tokens/Cargo.toml | 4 ++-- utilities/Cargo.toml | 2 +- vesting/Cargo.toml | 2 +- xcm-mock-message-queue/Cargo.toml | 2 +- xcm-support/Cargo.toml | 4 ++-- xcm/Cargo.toml | 2 +- xtokens/Cargo.toml | 6 +++--- 24 files changed, 41 insertions(+), 41 deletions(-) diff --git a/asset-registry/Cargo.toml b/asset-registry/Cargo.toml index 26dd887a2..879312207 100644 --- a/asset-registry/Cargo.toml +++ b/asset-registry/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-asset-registry" description = "Registry for (foreign) assets" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/asset-registry" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Interlay Ltd, etc"] edition = "2021" @@ -27,7 +27,7 @@ xcm-builder = { workspace = true } xcm-executor = { workspace = true } # orml -orml-traits = { path = "../traits", version = "0.9.1", default-features = false } +orml-traits = { path = "../traits", version = "0.10.0", default-features = false } # for runtime-benchmarks polkadot-runtime-common = { workspace = true, optional = true } diff --git a/auction/Cargo.toml b/auction/Cargo.toml index adf914360..a57f40503 100644 --- a/auction/Cargo.toml +++ b/auction/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-auction" description = "Auction module that implements `Auction` trait." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/auction" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Acala Developers"] edition = "2021" @@ -17,7 +17,7 @@ frame-system = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.1", default-features = false } +orml-traits = { path = "../traits", version = "0.10.0", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/authority/Cargo.toml b/authority/Cargo.toml index 6c627f664..ce56ff6c3 100644 --- a/authority/Cargo.toml +++ b/authority/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-authority" description = "Utility pallet to perform ROOT calls in a PoA network" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/auction" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Acala Developers"] edition = "2021" diff --git a/benchmarking/Cargo.toml b/benchmarking/Cargo.toml index 6bb578dfd..799064dac 100644 --- a/benchmarking/Cargo.toml +++ b/benchmarking/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-benchmarking" description = "Provide macro to benchmark Substrate runtime." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/benchmarking" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Laminar Developers "] edition = "2021" diff --git a/build-script-utils/Cargo.toml b/build-script-utils/Cargo.toml index 3a0c8de4a..8a928b195 100644 --- a/build-script-utils/Cargo.toml +++ b/build-script-utils/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-build-script-utils" description = "Crate with utility functions for `build.rs` scripts." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/build-script-utils" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Parity Technologies ", "Laminar Developers "] edition = "2021" diff --git a/currencies/Cargo.toml b/currencies/Cargo.toml index b52d083dc..fd0aedc48 100644 --- a/currencies/Cargo.toml +++ b/currencies/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-currencies" description = "Provide `MultiCurrency` implementation using `pallet-balances` and `orml-tokens` module." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/currencies" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Laminar Developers "] edition = "2021" @@ -18,8 +18,8 @@ sp-io = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.1", default-features = false } -orml-utilities = { path = "../utilities", version = "0.9.1", default-features = false } +orml-traits = { path = "../traits", version = "0.10.0", default-features = false } +orml-utilities = { path = "../utilities", version = "0.10.0", default-features = false } [dev-dependencies] pallet-balances = { workspace = true, features = ["std"] } diff --git a/gradually-update/Cargo.toml b/gradually-update/Cargo.toml index d7cb1f51b..59cda60dd 100644 --- a/gradually-update/Cargo.toml +++ b/gradually-update/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-gradually-update" description = "Provides way to adjust numeric parameter gradually over a period of time." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/gradually-update" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Laminar Developers "] edition = "2021" diff --git a/nft/Cargo.toml b/nft/Cargo.toml index 66156c430..0777b3fd3 100644 --- a/nft/Cargo.toml +++ b/nft/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-nft" description = "Non-fungible token pallet provides basic functions to create and manager NFT" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/nft" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Acala Developers"] edition = "2021" diff --git a/oracle/Cargo.toml b/oracle/Cargo.toml index 58f6f8dc5..16ed64a66 100644 --- a/oracle/Cargo.toml +++ b/oracle/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-oracle" description = "Oracle module that makes off-chain data available on-chain." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/oracle" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Laminar Developers "] edition = "2021" @@ -20,8 +20,8 @@ sp-runtime = { workspace = true } sp-std = { workspace = true } frame-benchmarking = { workspace = true, optional = true } -orml-traits = { path = "../traits", version = "0.9.1", default-features = false } -orml-utilities = { path = "../utilities", version = "0.9.1", default-features = false } +orml-traits = { path = "../traits", version = "0.10.0", default-features = false } +orml-utilities = { path = "../utilities", version = "0.10.0", default-features = false } [dev-dependencies] sp-core = { workspace = true } diff --git a/oracle/runtime-api/Cargo.toml b/oracle/runtime-api/Cargo.toml index 423550a9c..f4eddac94 100644 --- a/oracle/runtime-api/Cargo.toml +++ b/oracle/runtime-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orml-oracle-runtime-api" -version = "0.9.1" +version = "0.10.0" authors = ["Laminar Developers "] edition = "2021" license = "Apache-2.0" diff --git a/parameters/Cargo.toml b/parameters/Cargo.toml index 92a3deb2b..9f5073eee 100644 --- a/parameters/Cargo.toml +++ b/parameters/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-parameters" description = "Offer a centra place to store and configure parameters." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/parameters" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Acala Developers"] edition = "2021" @@ -18,7 +18,7 @@ sp-runtime = { workspace = true } sp-core = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.1", default-features = false } +orml-traits = { path = "../traits", version = "0.10.0", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/payments/Cargo.toml b/payments/Cargo.toml index 8ed7c00fb..d2052753e 100644 --- a/payments/Cargo.toml +++ b/payments/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Virto Network "] edition = '2021' name = "orml-payments" -version = "0.9.1" +version = "0.10.0" license = "Apache-2.0" homepage = "https://github.com/virto-network/virto-node" repository = "https://github.com/virto-network/virto-node" @@ -19,7 +19,7 @@ frame-system = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = {path = "../traits", version = "0.9.1", default-features = false } +orml-traits = {path = "../traits", version = "0.10.0", default-features = false } [dev-dependencies] serde = "1.0.136" diff --git a/rate-limit/Cargo.toml b/rate-limit/Cargo.toml index a46bc4547..7f0cb85d9 100644 --- a/rate-limit/Cargo.toml +++ b/rate-limit/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-rate-limit" description = "Provides way to config rate limiter for limit some operation." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/rate-limit" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Laminar Developers "] edition = "2021" @@ -19,8 +19,8 @@ sp-io = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.1", default-features = false } -orml-utilities = { path = "../utilities", version = "0.9.1", default-features = false } +orml-traits = { path = "../traits", version = "0.10.0", default-features = false } +orml-utilities = { path = "../utilities", version = "0.10.0", default-features = false } [dev-dependencies] pallet-timestamp = { workspace = true, features = ["std"] } diff --git a/rewards/Cargo.toml b/rewards/Cargo.toml index 778f5cfa1..b8ba00e0e 100644 --- a/rewards/Cargo.toml +++ b/rewards/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-rewards" description = "Store and manage shares and rewards" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/rewards" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Acala Developers"] edition = "2021" @@ -19,7 +19,7 @@ sp-io = { workspace = true } sp-runtime = { workspace = true, features = ["serde"] } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.1", default-features = false } +orml-traits = { path = "../traits", version = "0.10.0", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/tokens/Cargo.toml b/tokens/Cargo.toml index db0221c2a..0025e21ae 100644 --- a/tokens/Cargo.toml +++ b/tokens/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-tokens" description = "Fungible tokens module that implements `MultiCurrency` trait." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/tokens" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Laminar Developers "] edition = "2021" @@ -19,7 +19,7 @@ sp-arithmetic = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.1", default-features = false } +orml-traits = { path = "../traits", version = "0.10.0", default-features = false } [dev-dependencies] pallet-elections-phragmen = { workspace = true, features = ["std"] } diff --git a/tokens/runtime-api/Cargo.toml b/tokens/runtime-api/Cargo.toml index edd383c2a..97c14cec8 100644 --- a/tokens/runtime-api/Cargo.toml +++ b/tokens/runtime-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orml-tokens-runtime-api" -version = "0.9.1" +version = "0.10.0" authors = ["Laminar Developers "] edition = "2021" license = "Apache-2.0" diff --git a/traits/Cargo.toml b/traits/Cargo.toml index 1a21366e2..f38ed80a4 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-traits" description = "Shared traits including `BasicCurrency`, `MultiCurrency`, `Auction` and more." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/traits" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Laminar Developers "] edition = "2021" @@ -23,7 +23,7 @@ frame-support = { workspace = true } xcm = { workspace = true } -orml-utilities = { path = "../utilities", version = "0.9.1", default-features = false } +orml-utilities = { path = "../utilities", version = "0.10.0", default-features = false } [features] default = [ "std" ] diff --git a/unknown-tokens/Cargo.toml b/unknown-tokens/Cargo.toml index f6524e08f..12553afd7 100644 --- a/unknown-tokens/Cargo.toml +++ b/unknown-tokens/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-unknown-tokens" description = "Unknown tokens module that implements `UnknownAsset` trait." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/unknown-tokens" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Acala Developers"] edition = "2021" @@ -18,7 +18,7 @@ sp-std = { workspace = true } xcm = { workspace = true } -orml-xcm-support = { path = "../xcm-support", version = "0.9.1", default-features = false } +orml-xcm-support = { path = "../xcm-support", version = "0.10.0", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/utilities/Cargo.toml b/utilities/Cargo.toml index d9aea353f..b719608d2 100644 --- a/utilities/Cargo.toml +++ b/utilities/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-utilities" description = "Various utilities including `FixedU128` and `LinkedList`." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/utilities" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Laminar Developers "] edition = "2021" diff --git a/vesting/Cargo.toml b/vesting/Cargo.toml index 55141caf6..b711d8898 100644 --- a/vesting/Cargo.toml +++ b/vesting/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-vesting" description = "Provides scheduled balance locking mechanism, in a *graded vesting* way." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/vesting" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Laminar Developers "] edition = "2021" diff --git a/xcm-mock-message-queue/Cargo.toml b/xcm-mock-message-queue/Cargo.toml index e4ad77912..133864ecd 100644 --- a/xcm-mock-message-queue/Cargo.toml +++ b/xcm-mock-message-queue/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xcm-mock-message-queue" description = "XCM Mock Message Qeueu for XCM Simulator tests" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xcm-mock-message-queue" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Acala Developers"] edition = "2021" diff --git a/xcm-support/Cargo.toml b/xcm-support/Cargo.toml index 54156fb79..4dd93b954 100644 --- a/xcm-support/Cargo.toml +++ b/xcm-support/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xcm-support" description = "Supporting module for XCM integration." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xcm-support" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Acala Developers"] edition = "2021" @@ -17,7 +17,7 @@ sp-std = { workspace = true } xcm = { workspace = true } xcm-executor = { workspace = true } -orml-traits = { path = "../traits", version = "0.9.1", default-features = false } +orml-traits = { path = "../traits", version = "0.10.0", default-features = false } [features] default = [ "std" ] diff --git a/xcm/Cargo.toml b/xcm/Cargo.toml index 44a819441..59e2641b5 100644 --- a/xcm/Cargo.toml +++ b/xcm/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xcm" description = "XCM message helpers." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xcm" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Acala Developers"] edition = "2021" diff --git a/xtokens/Cargo.toml b/xtokens/Cargo.toml index 5c5fcb8e0..7edbe23fd 100644 --- a/xtokens/Cargo.toml +++ b/xtokens/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xtokens" description = "Cross-chain token transfer." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xtokens" license = "Apache-2.0" -version = "0.9.1" +version = "0.10.0" authors = ["Acala Developers"] edition = "2021" @@ -26,8 +26,8 @@ xcm = { workspace = true } xcm-executor = { workspace = true } # orml -orml-traits = { path = "../traits", version = "0.9.1", default-features = false} -orml-xcm-support = { path = "../xcm-support", version = "0.9.1", default-features = false } +orml-traits = { path = "../traits", version = "0.10.0", default-features = false} +orml-xcm-support = { path = "../xcm-support", version = "0.10.0", default-features = false } [dev-dependencies] # substrate From e576f86cd4a4666729de6f47d675f02e020b7c7e Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Wed, 17 Apr 2024 19:49:55 +1200 Subject: [PATCH 10/13] add release target --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 5623d2165..25e463821 100644 --- a/Makefile +++ b/Makefile @@ -77,3 +77,6 @@ benchmark-all: cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_tokens --extrinsic="*" --wasm-execution=compiled --heap-pages=4096 --output=./tokens/src/weights.rs --template ../templates/orml-weight-template.hbs cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_vesting --extrinsic="*" --wasm-execution=compiled --heap-pages=4096 --output=./vesting/src/weights.rs --template ../templates/orml-weight-template.hbs + +release: Cargo.toml + cargo release --execute From 288218c3b1a5193575387c4c0eff83c5772062fd Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Thu, 25 Apr 2024 11:49:50 +0800 Subject: [PATCH 11/13] impl BenchmarkHelper for () (#997) --- oracle/src/benchmarking.rs | 3 +-- oracle/src/lib.rs | 7 +++++++ oracle/src/mock.rs | 11 +---------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/oracle/src/benchmarking.rs b/oracle/src/benchmarking.rs index 910bf229c..7c8cc8f25 100644 --- a/oracle/src/benchmarking.rs +++ b/oracle/src/benchmarking.rs @@ -5,14 +5,13 @@ use frame_benchmarking::v2::*; use frame_support::assert_ok; use frame_system::{Pallet as System, RawOrigin}; -use sp_std::vec; #[instance_benchmarks] mod benchmarks { use super::*; #[benchmark] - fn feed_values(x: Linear<1, { T::BenchmarkHelper::get_currency_id_value_pairs().len() as u32 }>) { + fn feed_values(x: Linear<0, { T::BenchmarkHelper::get_currency_id_value_pairs().len() as u32 }>) { // Register the caller let caller: T::AccountId = whitelisted_caller(); T::Members::add(&caller); diff --git a/oracle/src/lib.rs b/oracle/src/lib.rs index 2a0bc3104..ce7ac3074 100644 --- a/oracle/src/lib.rs +++ b/oracle/src/lib.rs @@ -63,6 +63,13 @@ pub trait BenchmarkHelper> { fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L>; } +#[cfg(feature = "runtime-benchmarks")] +impl> BenchmarkHelper for () { + fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L> { + BoundedVec::default() + } +} + #[frame_support::pallet] pub mod module { use super::*; diff --git a/oracle/src/mock.rs b/oracle/src/mock.rs index 4907aa0c0..d289439f3 100644 --- a/oracle/src/mock.rs +++ b/oracle/src/mock.rs @@ -63,15 +63,6 @@ impl SortedMembers for Members { } } -#[cfg(feature = "runtime-benchmarks")] -pub struct BenchmarkHelper; -#[cfg(feature = "runtime-benchmarks")] -impl crate::BenchmarkHelper for BenchmarkHelper { - fn get_currency_id_value_pairs() -> BoundedVec<(Key, Value), MaxFeedValues> { - vec![(1, 1), (2, 2), (3, 3)].try_into().unwrap() - } -} - impl Config for Test { type RuntimeEvent = RuntimeEvent; type OnNewData = (); @@ -85,7 +76,7 @@ impl Config for Test { type MaxHasDispatchedSize = ConstU32<100>; type MaxFeedValues = MaxFeedValues; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = BenchmarkHelper; + type BenchmarkHelper = (); } type Block = frame_system::mocking::MockBlock; From 764922f5f333acb1af96dec417bacf9cd6556a01 Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Wed, 8 May 2024 17:00:38 +1200 Subject: [PATCH 12/13] update toolchain (#999) * update toolchain * fix --- authority/src/lib.rs | 4 +++- rust-toolchain.toml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/authority/src/lib.rs b/authority/src/lib.rs index 3fcb627e2..63bb57ff7 100644 --- a/authority/src/lib.rs +++ b/authority/src/lib.rs @@ -76,7 +76,9 @@ mod helper { use std::cell::RefCell; thread_local! { - static NESTED_MAX_ENCODED_LEN: RefCell = RefCell::new(false); + static NESTED_MAX_ENCODED_LEN: RefCell = const { + RefCell::new(false) + }; } pub fn set_nested_max_encoded_len(val: bool) { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index a0f945fbb..b76bf618f 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.75.0" +channel = "1.77.0" components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] From f2fc5ee47a228bfe899904f88077f602bcfdca07 Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Tue, 14 May 2024 10:09:46 +0800 Subject: [PATCH 13/13] use schedule traits v3 instead of v1 (#1001) --- authority/src/lib.rs | 50 +++++++++++++++++++----------------------- authority/src/tests.rs | 30 ++++++++++++------------- 2 files changed, 37 insertions(+), 43 deletions(-) diff --git a/authority/src/lib.rs b/authority/src/lib.rs index 63bb57ff7..d2ca9bc28 100644 --- a/authority/src/lib.rs +++ b/authority/src/lib.rs @@ -32,22 +32,21 @@ use frame_support::{ pallet_prelude::*, traits::{ schedule::{DispatchTime, Priority}, - EitherOfDiverse, EnsureOrigin, Get, IsType, OriginTrait, + Bounded, EitherOfDiverse, EnsureOrigin, Get, IsType, OriginTrait, }, }; use frame_system::{pallet_prelude::*, EnsureRoot, EnsureSigned}; use parity_scale_codec::MaxEncodedLen; use scale_info::TypeInfo; use sp_core::defer; +use sp_io::hashing::blake2_256; use sp_runtime::{ traits::{CheckedSub, Dispatchable, Hash, Saturating}, ArithmeticError, DispatchError, DispatchResult, Either, RuntimeDebug, }; use sp_std::prelude::*; -// Todo: Switch to current v3 api: https://github.com/open-web3-stack/open-runtime-module-library/issues/995 -#[allow(deprecated)] -use frame_support::traits::schedule::v1::Named as ScheduleNamed; +use frame_support::traits::schedule::v3::Named as ScheduleNamed; mod mock; mod tests; @@ -201,6 +200,7 @@ pub mod module { #[pallet::origin] pub type Origin = DelayedOrigin, ::PalletsOrigin>; pub(crate) type CallOf = ::RuntimeCall; + pub(crate) type BoundedCallOf = Bounded, ::Hashing>; #[pallet::config] pub trait Config: frame_system::Config { @@ -221,8 +221,12 @@ pub mod module { + GetDispatchInfo; /// The Scheduler. - #[allow(deprecated)] - type Scheduler: ScheduleNamed, ::RuntimeCall, Self::PalletsOrigin>; + type Scheduler: ScheduleNamed< + BlockNumberFor, + ::RuntimeCall, + Self::PalletsOrigin, + Hasher = Self::Hashing, + >; /// The type represent origin that can be dispatched by other origins. type AsOriginId: Parameter + AsOriginId<::RuntimeOrigin, Self::PalletsOrigin>; @@ -337,7 +341,7 @@ pub mod module { when: DispatchTime>, priority: Priority, with_delayed_origin: bool, - call: Box>, + call: Box>, ) -> DispatchResult { T::AuthorityConfig::check_schedule_dispatch(origin.clone(), priority)?; @@ -364,16 +368,9 @@ pub mod module { }; let pallets_origin = schedule_origin.caller().clone(); - #[allow(deprecated)] - T::Scheduler::schedule_named( - Encode::encode(&(&pallets_origin, id)), - when, - None, - priority, - pallets_origin.clone(), - *call, - ) - .map_err(|_| Error::::FailedToSchedule)?; + let task_name = (&pallets_origin, id).using_encoded(blake2_256); + T::Scheduler::schedule_named(task_name, when, None, priority, pallets_origin.clone(), *call) + .map_err(|_| Error::::FailedToSchedule)?; Self::deposit_event(Event::Scheduled { origin: pallets_origin, @@ -402,9 +399,8 @@ pub mod module { }; T::AuthorityConfig::check_fast_track_schedule(origin, &initial_origin, new_delay)?; - #[allow(deprecated)] - T::Scheduler::reschedule_named((&initial_origin, task_id).encode(), when) - .map_err(|_| Error::::FailedToFastTrack)?; + let task_name = (&initial_origin, task_id).using_encoded(blake2_256); + T::Scheduler::reschedule_named(task_name, when).map_err(|_| Error::::FailedToFastTrack)?; Self::deposit_event(Event::FastTracked { origin: *initial_origin, @@ -425,12 +421,9 @@ pub mod module { ) -> DispatchResult { T::AuthorityConfig::check_delay_schedule(origin, &initial_origin)?; - #[allow(deprecated)] - T::Scheduler::reschedule_named( - (&initial_origin, task_id).encode(), - DispatchTime::After(additional_delay), - ) - .map_err(|_| Error::::FailedToDelay)?; + let task_name = (&initial_origin, task_id).using_encoded(blake2_256); + T::Scheduler::reschedule_named(task_name, DispatchTime::After(additional_delay)) + .map_err(|_| Error::::FailedToDelay)?; let now = frame_system::Pallet::::block_number(); let dispatch_at = now.saturating_add(additional_delay); @@ -452,8 +445,9 @@ pub mod module { task_id: ScheduleTaskIndex, ) -> DispatchResult { T::AuthorityConfig::check_cancel_schedule(origin, &initial_origin)?; - #[allow(deprecated)] - T::Scheduler::cancel_named((&initial_origin, task_id).encode()).map_err(|_| Error::::FailedToCancel)?; + + let task_name = (&initial_origin, task_id).using_encoded(blake2_256); + T::Scheduler::cancel_named(task_name).map_err(|_| Error::::FailedToCancel)?; Self::deposit_event(Event::Cancelled { origin: *initial_origin, diff --git a/authority/src/tests.rs b/authority/src/tests.rs index bcbd4dc80..c1366c096 100644 --- a/authority/src/tests.rs +++ b/authority/src/tests.rs @@ -6,12 +6,12 @@ use super::*; use frame_support::{ assert_noop, assert_ok, dispatch::DispatchErrorWithPostInfo, - traits::{schedule::DispatchTime, OriginTrait}, + traits::{schedule::DispatchTime, OriginTrait, StorePreimage}, }; use frame_system::RawOrigin; use mock::{ - authority, run_to_block, Authority, BlockNumber, ExtBuilder, MockAsOriginId, OriginCaller, Runtime, RuntimeCall, - RuntimeOrigin, System, + authority, run_to_block, Authority, BlockNumber, ExtBuilder, MockAsOriginId, OriginCaller, Preimage, Runtime, + RuntimeCall, RuntimeOrigin, System, }; use parity_scale_codec::MaxEncodedLen; use sp_io::hashing::blake2_256; @@ -74,7 +74,7 @@ fn schedule_dispatch_at_work() { DispatchTime::At(1), 0, true, - Box::new(call.clone()) + Box::new(Preimage::bound(call.clone()).unwrap()) ), Error::::FailedToSchedule ); @@ -84,7 +84,7 @@ fn schedule_dispatch_at_work() { DispatchTime::At(2), 0, true, - Box::new(call.clone()) + Box::new(Preimage::bound(call.clone()).unwrap()) )); System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled { origin: OriginCaller::Authority(DelayedOrigin { @@ -109,7 +109,7 @@ fn schedule_dispatch_at_work() { DispatchTime::At(3), 0, false, - Box::new(call) + Box::new(Preimage::bound(call).unwrap()) )); System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled { origin: OriginCaller::system(RawOrigin::Root), @@ -144,7 +144,7 @@ fn schedule_dispatch_after_work() { DispatchTime::At(0), 0, true, - Box::new(call.clone()) + Box::new(Preimage::bound(call.clone()).unwrap()) ), ArithmeticError::Overflow ); @@ -154,7 +154,7 @@ fn schedule_dispatch_after_work() { DispatchTime::After(0), 0, true, - Box::new(call.clone()) + Box::new(Preimage::bound(call.clone()).unwrap()) )); System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled { origin: OriginCaller::Authority(DelayedOrigin { @@ -179,7 +179,7 @@ fn schedule_dispatch_after_work() { DispatchTime::After(0), 0, false, - Box::new(call) + Box::new(Preimage::bound(call).unwrap()) )); System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled { origin: OriginCaller::system(RawOrigin::Root), @@ -214,7 +214,7 @@ fn fast_track_scheduled_dispatch_work() { DispatchTime::At(2), 0, true, - Box::new(call.clone()) + Box::new(Preimage::bound(call.clone()).unwrap()) )); System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled { origin: OriginCaller::Authority(DelayedOrigin { @@ -255,7 +255,7 @@ fn fast_track_scheduled_dispatch_work() { DispatchTime::At(2), 0, false, - Box::new(call) + Box::new(Preimage::bound(call.clone()).unwrap()) )); System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled { origin: OriginCaller::system(RawOrigin::Root), @@ -293,7 +293,7 @@ fn delay_scheduled_dispatch_work() { DispatchTime::At(2), 0, true, - Box::new(call.clone()) + Box::new(Preimage::bound(call.clone()).unwrap()) )); System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled { origin: OriginCaller::Authority(DelayedOrigin { @@ -334,7 +334,7 @@ fn delay_scheduled_dispatch_work() { DispatchTime::At(2), 0, false, - Box::new(call) + Box::new(Preimage::bound(call).unwrap()) )); System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled { origin: OriginCaller::system(RawOrigin::Root), @@ -371,7 +371,7 @@ fn cancel_scheduled_dispatch_work() { DispatchTime::At(2), 0, true, - Box::new(call.clone()) + Box::new(Preimage::bound(call.clone()).unwrap()) )); System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled { origin: OriginCaller::Authority(DelayedOrigin { @@ -410,7 +410,7 @@ fn cancel_scheduled_dispatch_work() { DispatchTime::At(2), 0, false, - Box::new(call) + Box::new(Preimage::bound(call).unwrap()) )); System::assert_last_event(mock::RuntimeEvent::Authority(Event::Scheduled { origin: OriginCaller::system(RawOrigin::Root),