mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 21:45:41 +00:00
Staking::{bond, set_controller} to set controllers to stash only. (#14039)
* update set_controller * clone * bond uses `stash` * remove controller from bond(), chill_other test works * remove ctlr from testing_utils & dead ctlr -> dead payee * mvs controllers to stashes for 3 tests * migrate mock bond fns & fix 1 test * mvs controllers to stashes for 7 tests * mvs controllers to stashes for 9 tests * remove double_controlling_should_fail * remove double_staking_should_fail * mvs controllers to stashes for 10 tests * mvs controllers to stashes for 2 tests * remove payout_creates_controller * mvs controllers to stashes for 27 tests * remove println! * fix rewards_should_work * fix test_payout_stakers * fix bond benchmark * clone * rm unused import * rm unused var * rm controller from create_offender * fix GenesisConfig stakers * fix controllers in consensus pallets * fix unqiue controller in chain_spec * fmt * fix create_offender * fix set_controller benchmark * add TODO * create_unique_stash_controller * staking benchmarks working * fmt * fix args * rm println * import * import * fix fast unstake tests * fix staking-tests-e2e * fix root-offenses * fmt * differentiate controller to stash * bring back change_controller_works w. unique ctrl * bring back double_staking_should_fail * double_controlling_attempt_should_fail * bring back payout_creates_controller * add commnet to controller balances * + set_controller call description * fmt * rm clones * fmt * clippy fixes * fmt * update README * small fixes * use controller_to_be_deprecated * .comment * comment * bump zombienet version * ci --------- Co-authored-by: parity-processbot <> Co-authored-by: Javier Viola <javier@parity.io>
This commit is contained in:
@@ -432,7 +432,7 @@ impl ExtBuilder {
|
||||
(2, 20 * self.balance_factor),
|
||||
(3, 300 * self.balance_factor),
|
||||
(4, 400 * self.balance_factor),
|
||||
// controllers
|
||||
// controllers (still used in some tests. Soon to be deprecated).
|
||||
(10, self.balance_factor),
|
||||
(20, self.balance_factor),
|
||||
(30, self.balance_factor),
|
||||
@@ -465,18 +465,18 @@ impl ExtBuilder {
|
||||
stakers = vec![
|
||||
// (stash, ctrl, stake, status)
|
||||
// these two will be elected in the default test where we elect 2.
|
||||
(11, 10, self.balance_factor * 1000, StakerStatus::<AccountId>::Validator),
|
||||
(21, 20, self.balance_factor * 1000, StakerStatus::<AccountId>::Validator),
|
||||
(11, 11, self.balance_factor * 1000, StakerStatus::<AccountId>::Validator),
|
||||
(21, 21, self.balance_factor * 1000, StakerStatus::<AccountId>::Validator),
|
||||
// a loser validator
|
||||
(31, 30, self.balance_factor * 500, StakerStatus::<AccountId>::Validator),
|
||||
(31, 31, self.balance_factor * 500, StakerStatus::<AccountId>::Validator),
|
||||
// an idle validator
|
||||
(41, 40, self.balance_factor * 1000, StakerStatus::<AccountId>::Idle),
|
||||
(41, 41, self.balance_factor * 1000, StakerStatus::<AccountId>::Idle),
|
||||
];
|
||||
// optionally add a nominator
|
||||
if self.nominate {
|
||||
stakers.push((
|
||||
101,
|
||||
100,
|
||||
101,
|
||||
self.balance_factor * 500,
|
||||
StakerStatus::<AccountId>::Nominator(vec![11, 21]),
|
||||
))
|
||||
@@ -563,35 +563,24 @@ pub(crate) fn current_era() -> EraIndex {
|
||||
Staking::current_era().unwrap()
|
||||
}
|
||||
|
||||
pub(crate) fn bond(stash: AccountId, ctrl: AccountId, val: Balance) {
|
||||
let _ = Balances::make_free_balance_be(&stash, val);
|
||||
let _ = Balances::make_free_balance_be(&ctrl, val);
|
||||
assert_ok!(Staking::bond(
|
||||
RuntimeOrigin::signed(stash),
|
||||
ctrl,
|
||||
val,
|
||||
RewardDestination::Controller
|
||||
));
|
||||
pub(crate) fn bond(who: AccountId, val: Balance) {
|
||||
let _ = Balances::make_free_balance_be(&who, val);
|
||||
assert_ok!(Staking::bond(RuntimeOrigin::signed(who), val, RewardDestination::Controller));
|
||||
}
|
||||
|
||||
pub(crate) fn bond_validator(stash: AccountId, ctrl: AccountId, val: Balance) {
|
||||
bond(stash, ctrl, val);
|
||||
assert_ok!(Staking::validate(RuntimeOrigin::signed(ctrl), ValidatorPrefs::default()));
|
||||
pub(crate) fn bond_validator(who: AccountId, val: Balance) {
|
||||
bond(who, val);
|
||||
assert_ok!(Staking::validate(RuntimeOrigin::signed(who), ValidatorPrefs::default()));
|
||||
assert_ok!(Session::set_keys(
|
||||
RuntimeOrigin::signed(ctrl),
|
||||
SessionKeys { other: ctrl.into() },
|
||||
RuntimeOrigin::signed(who),
|
||||
SessionKeys { other: who.into() },
|
||||
vec![]
|
||||
));
|
||||
}
|
||||
|
||||
pub(crate) fn bond_nominator(
|
||||
stash: AccountId,
|
||||
ctrl: AccountId,
|
||||
val: Balance,
|
||||
target: Vec<AccountId>,
|
||||
) {
|
||||
bond(stash, ctrl, val);
|
||||
assert_ok!(Staking::nominate(RuntimeOrigin::signed(ctrl), target));
|
||||
pub(crate) fn bond_nominator(who: AccountId, val: Balance, target: Vec<AccountId>) {
|
||||
bond(who, val);
|
||||
assert_ok!(Staking::nominate(RuntimeOrigin::signed(who), target));
|
||||
}
|
||||
|
||||
/// Progress to the given block, triggering session and era changes as we progress.
|
||||
|
||||
Reference in New Issue
Block a user