Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 088a7fc

Browse files
author
Ross Bulat
authored
Nomination Pools: Rename state-toggler to bouncer (#13421)
* rename state-toggler to bouncer * add migration * fmt * bump storage version * rm migration * revert version * ".git/.scripts/commands/fmt/fmt.sh" --------- Co-authored-by: command-bot <>
1 parent 425bf6b commit 088a7fc

File tree

5 files changed

+60
-90
lines changed

5 files changed

+60
-90
lines changed

frame/nomination-pools/benchmarking/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ frame_benchmarking::benchmarks! {
518518
depositor: depositor.clone(),
519519
root: Some(depositor.clone()),
520520
nominator: Some(depositor.clone()),
521-
state_toggler: Some(depositor.clone()),
521+
bouncer: Some(depositor.clone()),
522522
},
523523
}
524524
);
@@ -557,7 +557,7 @@ frame_benchmarking::benchmarks! {
557557
depositor: depositor.clone(),
558558
root: Some(depositor.clone()),
559559
nominator: Some(depositor.clone()),
560-
state_toggler: Some(depositor.clone()),
560+
bouncer: Some(depositor.clone()),
561561
}
562562
}
563563
);
@@ -630,7 +630,7 @@ frame_benchmarking::benchmarks! {
630630
pallet_nomination_pools::PoolRoles {
631631
depositor: root,
632632
nominator: Some(random.clone()),
633-
state_toggler: Some(random.clone()),
633+
bouncer: Some(random.clone()),
634634
root: Some(random),
635635
},
636636
)

frame/nomination-pools/fuzzer/src/call.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ fn random_call<R: Rng>(mut rng: &mut R) -> (pools::Call<T>, RuntimeOrigin) {
143143
let amount = random_ed_multiple(&mut rng);
144144
fund_account(&mut rng, &who);
145145
let root = who;
146-
let state_toggler = who;
146+
let bouncer = who;
147147
let nominator = who;
148-
(PoolsCall::<T>::create { amount, root, state_toggler, nominator }, origin)
148+
(PoolsCall::<T>::create { amount, root, bouncer, nominator }, origin)
149149
},
150150
7 => {
151151
// nominate

frame/nomination-pools/src/lib.rs

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@
120120
//! * Depositor: creates the pool and is the initial member. They can only leave the pool once all
121121
//! other members have left. Once they fully withdraw their funds, the pool is destroyed.
122122
//! * Nominator: can select which validators the pool nominates.
123-
//! * State-Toggler: can change the pools state and kick members if the pool is blocked.
124-
//! * Root: can change the nominator, state-toggler, or itself and can perform any of the actions
125-
//! the nominator or state-toggler can.
123+
//! * Bouncer: can change the pools state and kick members if the pool is blocked.
124+
//! * Root: can change the nominator, bouncer, or itself and can perform any of the actions the
125+
//! nominator or bouncer can.
126126
//!
127127
//! ### Dismantling
128128
//!
@@ -573,13 +573,13 @@ pub struct PoolRoles<AccountId> {
573573
/// Creates the pool and is the initial member. They can only leave the pool once all other
574574
/// members have left. Once they fully leave, the pool is destroyed.
575575
pub depositor: AccountId,
576-
/// Can change the nominator, state-toggler, or itself and can perform any of the actions the
577-
/// nominator or state-toggler can.
576+
/// Can change the nominator, bouncer, or itself and can perform any of the actions the
577+
/// nominator or bouncer can.
578578
pub root: Option<AccountId>,
579579
/// Can select which validators the pool nominates.
580580
pub nominator: Option<AccountId>,
581581
/// Can change the pools state and kick members if the pool is blocked.
582-
pub state_toggler: Option<AccountId>,
582+
pub bouncer: Option<AccountId>,
583583
}
584584

585585
/// Pool permissions and state
@@ -734,11 +734,8 @@ impl<T: Config> BondedPool<T> {
734734
self.roles.root.as_ref().map_or(false, |root| root == who)
735735
}
736736

737-
fn is_state_toggler(&self, who: &T::AccountId) -> bool {
738-
self.roles
739-
.state_toggler
740-
.as_ref()
741-
.map_or(false, |state_toggler| state_toggler == who)
737+
fn is_bouncer(&self, who: &T::AccountId) -> bool {
738+
self.roles.bouncer.as_ref().map_or(false, |bouncer| bouncer == who)
742739
}
743740

744741
fn can_update_roles(&self, who: &T::AccountId) -> bool {
@@ -751,15 +748,15 @@ impl<T: Config> BondedPool<T> {
751748
}
752749

753750
fn can_kick(&self, who: &T::AccountId) -> bool {
754-
self.state == PoolState::Blocked && (self.is_root(who) || self.is_state_toggler(who))
751+
self.state == PoolState::Blocked && (self.is_root(who) || self.is_bouncer(who))
755752
}
756753

757754
fn can_toggle_state(&self, who: &T::AccountId) -> bool {
758-
(self.is_root(who) || self.is_state_toggler(who)) && !self.is_destroying()
755+
(self.is_root(who) || self.is_bouncer(who)) && !self.is_destroying()
759756
}
760757

761758
fn can_set_metadata(&self, who: &T::AccountId) -> bool {
762-
self.is_root(who) || self.is_state_toggler(who)
759+
self.is_root(who) || self.is_bouncer(who)
763760
}
764761

765762
fn is_destroying(&self) -> bool {
@@ -1407,7 +1404,7 @@ pub mod pallet {
14071404
/// can never change.
14081405
RolesUpdated {
14091406
root: Option<T::AccountId>,
1410-
state_toggler: Option<T::AccountId>,
1407+
bouncer: Option<T::AccountId>,
14111408
nominator: Option<T::AccountId>,
14121409
},
14131410
/// The active balance of pool `pool_id` has been slashed to `balance`.
@@ -1630,8 +1627,8 @@ pub mod pallet {
16301627
///
16311628
/// # Conditions for a permissionless dispatch.
16321629
///
1633-
/// * The pool is blocked and the caller is either the root or state-toggler. This is
1634-
/// refereed to as a kick.
1630+
/// * The pool is blocked and the caller is either the root or bouncer. This is refereed to
1631+
/// as a kick.
16351632
/// * The pool is destroying and the member is not the depositor.
16361633
/// * The pool is destroying, the member is the depositor and no other members are in the
16371634
/// pool.
@@ -1754,7 +1751,7 @@ pub mod pallet {
17541751
///
17551752
/// * The pool is in destroy mode and the target is not the depositor.
17561753
/// * The target is the depositor and they are the only member in the sub pools.
1757-
/// * The pool is blocked and the caller is either the root or state-toggler.
1754+
/// * The pool is blocked and the caller is either the root or bouncer.
17581755
///
17591756
/// # Conditions for permissioned dispatch
17601757
///
@@ -1879,7 +1876,7 @@ pub mod pallet {
18791876
/// creating multiple pools in the same extrinsic.
18801877
/// * `root` - The account to set as [`PoolRoles::root`].
18811878
/// * `nominator` - The account to set as the [`PoolRoles::nominator`].
1882-
/// * `state_toggler` - The account to set as the [`PoolRoles::state_toggler`].
1879+
/// * `bouncer` - The account to set as the [`PoolRoles::bouncer`].
18831880
///
18841881
/// # Note
18851882
///
@@ -1892,7 +1889,7 @@ pub mod pallet {
18921889
#[pallet::compact] amount: BalanceOf<T>,
18931890
root: AccountIdLookupOf<T>,
18941891
nominator: AccountIdLookupOf<T>,
1895-
state_toggler: AccountIdLookupOf<T>,
1892+
bouncer: AccountIdLookupOf<T>,
18961893
) -> DispatchResult {
18971894
let depositor = ensure_signed(origin)?;
18981895

@@ -1901,7 +1898,7 @@ pub mod pallet {
19011898
Ok(*id)
19021899
})?;
19031900

1904-
Self::do_create(depositor, amount, root, nominator, state_toggler, pool_id)
1901+
Self::do_create(depositor, amount, root, nominator, bouncer, pool_id)
19051902
}
19061903

19071904
/// Create a new delegation pool with a previously used pool id
@@ -1917,15 +1914,15 @@ pub mod pallet {
19171914
#[pallet::compact] amount: BalanceOf<T>,
19181915
root: AccountIdLookupOf<T>,
19191916
nominator: AccountIdLookupOf<T>,
1920-
state_toggler: AccountIdLookupOf<T>,
1917+
bouncer: AccountIdLookupOf<T>,
19211918
pool_id: PoolId,
19221919
) -> DispatchResult {
19231920
let depositor = ensure_signed(origin)?;
19241921

19251922
ensure!(!BondedPools::<T>::contains_key(pool_id), Error::<T>::PoolIdInUse);
19261923
ensure!(pool_id < LastPoolId::<T>::get(), Error::<T>::InvalidPoolId);
19271924

1928-
Self::do_create(depositor, amount, root, nominator, state_toggler, pool_id)
1925+
Self::do_create(depositor, amount, root, nominator, bouncer, pool_id)
19291926
}
19301927

19311928
/// Nominate on behalf of the pool.
@@ -1955,7 +1952,7 @@ pub mod pallet {
19551952
///
19561953
/// The dispatch origin of this call must be either:
19571954
///
1958-
/// 1. signed by the state toggler, or the root role of the pool,
1955+
/// 1. signed by the bouncer, or the root role of the pool,
19591956
/// 2. if the pool conditions to be open are NOT met (as described by `ok_to_be_open`), and
19601957
/// then the state of the pool can be permissionlessly changed to `Destroying`.
19611958
#[pallet::call_index(9)]
@@ -1985,7 +1982,7 @@ pub mod pallet {
19851982

19861983
/// Set a new metadata for the pool.
19871984
///
1988-
/// The dispatch origin of this call must be signed by the state toggler, or the root role
1985+
/// The dispatch origin of this call must be signed by the bouncer, or the root role
19891986
/// of the pool.
19901987
#[pallet::call_index(10)]
19911988
#[pallet::weight(T::WeightInfo::set_metadata(metadata.len() as u32))]
@@ -2063,7 +2060,7 @@ pub mod pallet {
20632060
pool_id: PoolId,
20642061
new_root: ConfigOp<T::AccountId>,
20652062
new_nominator: ConfigOp<T::AccountId>,
2066-
new_state_toggler: ConfigOp<T::AccountId>,
2063+
new_bouncer: ConfigOp<T::AccountId>,
20672064
) -> DispatchResult {
20682065
let mut bonded_pool = match ensure_root(origin.clone()) {
20692066
Ok(()) => BondedPool::<T>::get(pool_id).ok_or(Error::<T>::PoolNotFound)?,
@@ -2086,16 +2083,16 @@ pub mod pallet {
20862083
ConfigOp::Remove => bonded_pool.roles.nominator = None,
20872084
ConfigOp::Set(v) => bonded_pool.roles.nominator = Some(v),
20882085
};
2089-
match new_state_toggler {
2086+
match new_bouncer {
20902087
ConfigOp::Noop => (),
2091-
ConfigOp::Remove => bonded_pool.roles.state_toggler = None,
2092-
ConfigOp::Set(v) => bonded_pool.roles.state_toggler = Some(v),
2088+
ConfigOp::Remove => bonded_pool.roles.bouncer = None,
2089+
ConfigOp::Set(v) => bonded_pool.roles.bouncer = Some(v),
20932090
};
20942091

20952092
Self::deposit_event(Event::<T>::RolesUpdated {
20962093
root: bonded_pool.roles.root.clone(),
20972094
nominator: bonded_pool.roles.nominator.clone(),
2098-
state_toggler: bonded_pool.roles.state_toggler.clone(),
2095+
bouncer: bonded_pool.roles.bouncer.clone(),
20992096
});
21002097

21012098
bonded_pool.put();
@@ -2336,12 +2333,12 @@ impl<T: Config> Pallet<T> {
23362333
amount: BalanceOf<T>,
23372334
root: AccountIdLookupOf<T>,
23382335
nominator: AccountIdLookupOf<T>,
2339-
state_toggler: AccountIdLookupOf<T>,
2336+
bouncer: AccountIdLookupOf<T>,
23402337
pool_id: PoolId,
23412338
) -> DispatchResult {
23422339
let root = T::Lookup::lookup(root)?;
23432340
let nominator = T::Lookup::lookup(nominator)?;
2344-
let state_toggler = T::Lookup::lookup(state_toggler)?;
2341+
let bouncer = T::Lookup::lookup(bouncer)?;
23452342

23462343
ensure!(amount >= Pallet::<T>::depositor_min_bond(), Error::<T>::MinimumBondNotMet);
23472344
ensure!(
@@ -2354,7 +2351,7 @@ impl<T: Config> Pallet<T> {
23542351
PoolRoles {
23552352
root: Some(root),
23562353
nominator: Some(nominator),
2357-
state_toggler: Some(state_toggler),
2354+
bouncer: Some(bouncer),
23582355
depositor: who.clone(),
23592356
},
23602357
);

frame/nomination-pools/src/migration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub mod v1 {
2828
pub depositor: AccountId,
2929
pub root: AccountId,
3030
pub nominator: AccountId,
31-
pub state_toggler: AccountId,
31+
pub bouncer: AccountId,
3232
}
3333

3434
impl<AccountId> OldPoolRoles<AccountId> {
@@ -37,7 +37,7 @@ pub mod v1 {
3737
depositor: self.depositor,
3838
root: Some(self.root),
3939
nominator: Some(self.nominator),
40-
state_toggler: Some(self.state_toggler),
40+
bouncer: Some(self.bouncer),
4141
}
4242
}
4343
}

0 commit comments

Comments
 (0)