From f0103cc0eb9390e2b787b88603c8b6063bd9dd7f Mon Sep 17 00:00:00 2001 From: dnjscksdn98 Date: Wed, 13 Dec 2023 15:09:34 +0900 Subject: [PATCH 1/3] fix: sort vector on address modification --- pallets/bfc-staking/src/pallet/impls.rs | 9 ++++++--- pallets/bfc-staking/src/pallet/mod.rs | 10 +++++----- pallets/relay-manager/src/pallet/impls.rs | 1 + pallets/relay-manager/src/pallet/mod.rs | 8 ++++---- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pallets/bfc-staking/src/pallet/impls.rs b/pallets/bfc-staking/src/pallet/impls.rs index 2a7203b6..ca644d27 100644 --- a/pallets/bfc-staking/src/pallet/impls.rs +++ b/pallets/bfc-staking/src/pallet/impls.rs @@ -2,8 +2,8 @@ use super::pallet::*; use crate::{ inflation::Range, weights::WeightInfo, BalanceOf, Bond, DelayedCommissionSet, - DelayedControllerSet, DelayedPayout, ProductivityStatus, RewardDestination, RoundIndex, - TierType, TotalSnapshot, ValidatorSnapshot, ValidatorSnapshotOf, + DelayedControllerSet, DelayedPayout, ProductivityStatus, RewardDestination, RewardPoint, + RoundIndex, TierType, TotalSnapshot, ValidatorSnapshot, ValidatorSnapshotOf, }; use pallet_session::ShouldEndSession; @@ -182,6 +182,7 @@ impl Pallet { selected_candidates .try_push(candidate.clone()) .expect("SelectedCandidates out of bound"); + selected_candidates.sort(); >::put(selected_candidates); match tier { TierType::Full => { @@ -189,6 +190,7 @@ impl Pallet { selected_full_candidates .try_push(candidate.clone()) .expect("SelectedFullCandidates out of bound"); + selected_full_candidates.sort(); >::put(selected_full_candidates); }, _ => { @@ -196,6 +198,7 @@ impl Pallet { selected_basic_candidates .try_push(candidate.clone()) .expect("SelectedBasicCandidates out of bound"); + selected_basic_candidates.sort(); >::put(selected_basic_candidates); }, }; @@ -744,7 +747,7 @@ impl Pallet { let score_plus_5 = >::get(round_index, &author) + 5; >::insert(round_index, author, score_plus_5); - >::mutate(round_index, |x| *x += 5); + >::mutate(round_index, |x: &mut RewardPoint| *x += 5); } /// Reset every `per round` related parameters of every candidates diff --git a/pallets/bfc-staking/src/pallet/mod.rs b/pallets/bfc-staking/src/pallet/mod.rs index 9c9c15e9..03e2df02 100644 --- a/pallets/bfc-staking/src/pallet/mod.rs +++ b/pallets/bfc-staking/src/pallet/mod.rs @@ -552,26 +552,26 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn selected_candidates)] - /// The active validator set (full and basic) selected for the current round + /// The active validator set (full and basic) selected for the current round. This storage is sorted by address. pub type SelectedCandidates = StorageValue<_, BoundedVec>, ValueQuery>; #[pallet::storage] #[pallet::getter(fn selected_full_candidates)] - /// The active full validator set selected for the current round + /// The active full validator set selected for the current round. This storage is sorted by address. pub type SelectedFullCandidates = StorageValue<_, BoundedVec>, ValueQuery>; #[pallet::storage] #[pallet::getter(fn selected_basic_candidates)] - /// The active basic validator set selected for the current round + /// The active basic validator set selected for the current round. This storage is sorted by address. pub type SelectedBasicCandidates = StorageValue<_, BoundedVec>, ValueQuery>; #[pallet::storage] #[pallet::unbounded] #[pallet::getter(fn cached_selected_candidates)] - /// The cached active validator set selected from previous rounds + /// The cached active validator set selected from previous rounds. This storage is sorted by address. pub type CachedSelectedCandidates = StorageValue<_, Vec<(RoundIndex, Vec)>, ValueQuery>; @@ -593,7 +593,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn candidate_pool)] - /// The pool of validator candidates, each with their total voting power + /// The pool of validator candidates, each with their total voting power. This storage is sorted by amount. pub(crate) type CandidatePool = StorageValue< _, BoundedVec>, ConstU32>, diff --git a/pallets/relay-manager/src/pallet/impls.rs b/pallets/relay-manager/src/pallet/impls.rs index 8af28666..334094a3 100644 --- a/pallets/relay-manager/src/pallet/impls.rs +++ b/pallets/relay-manager/src/pallet/impls.rs @@ -263,6 +263,7 @@ impl Pallet { fn add_to_selected_relayers(relayer: T::AccountId) { let mut selected_relayers = >::get(); selected_relayers.try_push(relayer).expect("SelectedRelayers out of bound"); + selected_relayers.sort(); >::put(selected_relayers); } diff --git a/pallets/relay-manager/src/pallet/mod.rs b/pallets/relay-manager/src/pallet/mod.rs index c21636c8..f375be67 100644 --- a/pallets/relay-manager/src/pallet/mod.rs +++ b/pallets/relay-manager/src/pallet/mod.rs @@ -126,27 +126,27 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn selected_relayers)] - /// The active relayer set selected for the current round + /// The active relayer set selected for the current round. This storage is sorted by address. pub type SelectedRelayers = StorageValue<_, BoundedVec>, ValueQuery>; #[pallet::storage] #[pallet::getter(fn initial_selected_relayers)] - /// The active relayer set selected at the beginning of the current round + /// The active relayer set selected at the beginning of the current round. This storage is sorted by address. pub type InitialSelectedRelayers = StorageValue<_, BoundedVec>, ValueQuery>; #[pallet::storage] #[pallet::unbounded] #[pallet::getter(fn cached_selected_relayers)] - /// The cached active relayer set selected from previous rounds + /// The cached active relayer set selected from previous rounds. This storage is sorted by address. pub type CachedSelectedRelayers = StorageValue<_, Vec<(RoundIndex, Vec)>, ValueQuery>; #[pallet::storage] #[pallet::unbounded] #[pallet::getter(fn cached_initial_selected_relayers)] - /// The cached active relayer set selected from the beginning of each previous rounds + /// The cached active relayer set selected from the beginning of each previous rounds. This storage is sorted by address. pub type CachedInitialSelectedRelayers = StorageValue<_, Vec<(RoundIndex, Vec)>, ValueQuery>; From b73568e99a048fb0855174e787b43822c8e4e41f Mon Sep 17 00:00:00 2001 From: dnjscksdn98 Date: Wed, 13 Dec 2023 15:17:00 +0900 Subject: [PATCH 2/3] chore: increase testnet runtime version --- runtime/testnet/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/testnet/src/lib.rs b/runtime/testnet/src/lib.rs index be554b5d..ae8e501d 100644 --- a/runtime/testnet/src/lib.rs +++ b/runtime/testnet/src/lib.rs @@ -141,7 +141,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // The version of the authorship interface. authoring_version: 1, // The version of the runtime spec. - spec_version: 460, + spec_version: 461, // The version of the implementation of the spec. impl_version: 1, // A list of supported runtime APIs along with their versions. From bb6b22aaad9bbbdabc56b21c7a6d594db7abd09d Mon Sep 17 00:00:00 2001 From: dnjscksdn98 Date: Wed, 13 Dec 2023 15:18:00 +0900 Subject: [PATCH 3/3] test: update package.json version --- tests/package-lock.json | 4 ++-- tests/package.json | 2 +- tools/package-lock.json | 4 ++-- tools/package.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/package-lock.json b/tests/package-lock.json index fd93d438..639e90e5 100644 --- a/tests/package-lock.json +++ b/tests/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bifrost-platform/bifrost-node", - "version": "1.2.4", + "version": "1.2.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@bifrost-platform/bifrost-node", - "version": "1.2.4", + "version": "1.2.5", "dependencies": { "@polkadot/api": "10.9.1", "axios": "1.5.0", diff --git a/tests/package.json b/tests/package.json index 56e00538..e0de0754 100644 --- a/tests/package.json +++ b/tests/package.json @@ -1,6 +1,6 @@ { "name": "@bifrost-platform/bifrost-node", - "version": "1.2.4", + "version": "1.2.5", "author": "bifrost-platform", "scripts": { "test": "mocha -r ts-node/register tests/**/**/*.ts --exit", diff --git a/tools/package-lock.json b/tools/package-lock.json index 5d4690d0..f6826673 100644 --- a/tools/package-lock.json +++ b/tools/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bifrost-platform/bifrost-node", - "version": "1.2.4", + "version": "1.2.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@bifrost-platform/bifrost-node", - "version": "1.2.4", + "version": "1.2.5", "dependencies": { "@polkadot/api": "10.9.1", "axios": "1.5.0", diff --git a/tools/package.json b/tools/package.json index fa5af921..e30fefbd 100644 --- a/tools/package.json +++ b/tools/package.json @@ -1,6 +1,6 @@ { "name": "@bifrost-platform/bifrost-node", - "version": "1.2.4", + "version": "1.2.5", "author": "bifrost-platform", "scripts": { "set_session_keys": "ts-node src/set_session_keys.ts",