Remove Default bound for AccountId (#10403)

* Remove Default for AccountId

* More removals of default

* Update frame/authorship/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/authorship/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/authorship/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/authorship/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* More work

* More work

* Remove old code

* More work

* pallet-asset-tx-payment

* tips

* sc-consensus-babe

* sc-finality-grandpa

* sc-consensus-babe-rpc

* sc-cli

* make npos crates accept non-default account (#10420)

* minimal changes to make npos pallets all work

* make this pesky reduce.rs a bit cleaner

* more work

* more work

* Tests build

* Fix imonline tests

* Formatting

* Fixes

* Fixes

* Fix bench

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Formatting

* Fixes

* Formatting

* Fixes

* Formatting

* Fixes

* Formatting

* Fixes

* Formatting

* Update client/keystore/src/local.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/finality-grandpa/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/keystore/src/local.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/keystore/src/local.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/staking/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/staking/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update primitives/runtime/src/traits.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Formatting

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: kianenigma <kian@parity.io>
This commit is contained in:
Gavin Wood
2021-12-13 15:03:59 +01:00
committed by GitHub
parent a4ccc26e33
commit 1e24e45ea1
118 changed files with 998 additions and 4181 deletions
+33 -25
View File
@@ -217,16 +217,17 @@ fn rewards_should_work() {
Payee::<Test>::insert(21, RewardDestination::Controller);
Payee::<Test>::insert(101, RewardDestination::Controller);
<Pallet<Test>>::reward_by_ids(vec![(11, 50)]);
<Pallet<Test>>::reward_by_ids(vec![(11, 50)]);
Pallet::<Test>::reward_by_ids(vec![(11, 50)]);
Pallet::<Test>::reward_by_ids(vec![(11, 50)]);
// This is the second validator of the current elected set.
<Pallet<Test>>::reward_by_ids(vec![(21, 50)]);
Pallet::<Test>::reward_by_ids(vec![(21, 50)]);
// Compute total payout now for whole duration of the session.
let total_payout_0 = current_total_payout_for_duration(reward_time_per_era());
let maximum_payout = maximum_payout_for_duration(reward_time_per_era());
start_session(1);
assert_eq_uvec!(Session::validators(), vec![11, 21]);
assert_eq!(Balances::total_balance(&10), init_balance_10);
assert_eq!(Balances::total_balance(&11), init_balance_11);
@@ -234,7 +235,6 @@ fn rewards_should_work() {
assert_eq!(Balances::total_balance(&21), init_balance_21);
assert_eq!(Balances::total_balance(&100), init_balance_100);
assert_eq!(Balances::total_balance(&101), init_balance_101);
assert_eq_uvec!(Session::validators(), vec![11, 21]);
assert_eq!(
Staking::eras_reward_points(active_era()),
EraRewardPoints {
@@ -283,7 +283,7 @@ fn rewards_should_work() {
assert_eq_error_rate!(Balances::total_balance(&101), init_balance_101, 2);
assert_eq_uvec!(Session::validators(), vec![11, 21]);
<Pallet<Test>>::reward_by_ids(vec![(11, 1)]);
Pallet::<Test>::reward_by_ids(vec![(11, 1)]);
// Compute total payout now for whole duration as other parameter won't change
let total_payout_1 = current_total_payout_for_duration(reward_time_per_era());
@@ -338,6 +338,7 @@ fn staking_should_work() {
// add a new candidate for being a validator. account 3 controlled by 4.
assert_ok!(Staking::bond(Origin::signed(3), 4, 1500, RewardDestination::Controller));
assert_ok!(Staking::validate(Origin::signed(4), ValidatorPrefs::default()));
assert_ok!(Session::set_keys(Origin::signed(4), SessionKeys { other: 4.into() }, vec![]));
// No effects will be seen so far.
assert_eq_uvec!(validator_controllers(), vec![20, 10]);
@@ -519,8 +520,8 @@ fn nominating_and_rewards_should_work() {
// the total reward for era 0
let total_payout_0 = current_total_payout_for_duration(reward_time_per_era());
<Pallet<Test>>::reward_by_ids(vec![(41, 1)]);
<Pallet<Test>>::reward_by_ids(vec![(21, 1)]);
Pallet::<Test>::reward_by_ids(vec![(41, 1)]);
Pallet::<Test>::reward_by_ids(vec![(21, 1)]);
mock::start_active_era(1);
@@ -561,8 +562,8 @@ fn nominating_and_rewards_should_work() {
// the total reward for era 1
let total_payout_1 = current_total_payout_for_duration(reward_time_per_era());
<Pallet<Test>>::reward_by_ids(vec![(21, 2)]);
<Pallet<Test>>::reward_by_ids(vec![(11, 1)]);
Pallet::<Test>::reward_by_ids(vec![(21, 2)]);
Pallet::<Test>::reward_by_ids(vec![(11, 1)]);
mock::start_active_era(2);
@@ -942,7 +943,7 @@ fn reward_destination_works() {
// Compute total payout now for whole duration as other parameter won't change
let total_payout_0 = current_total_payout_for_duration(reward_time_per_era());
<Pallet<Test>>::reward_by_ids(vec![(11, 1)]);
Pallet::<Test>::reward_by_ids(vec![(11, 1)]);
mock::start_active_era(1);
mock::make_all_reward_payment(0);
@@ -968,7 +969,7 @@ fn reward_destination_works() {
// Compute total payout now for whole duration as other parameter won't change
let total_payout_1 = current_total_payout_for_duration(reward_time_per_era());
<Pallet<Test>>::reward_by_ids(vec![(11, 1)]);
Pallet::<Test>::reward_by_ids(vec![(11, 1)]);
mock::start_active_era(2);
mock::make_all_reward_payment(1);
@@ -999,7 +1000,7 @@ fn reward_destination_works() {
// Compute total payout now for whole duration as other parameter won't change
let total_payout_2 = current_total_payout_for_duration(reward_time_per_era());
<Pallet<Test>>::reward_by_ids(vec![(11, 1)]);
Pallet::<Test>::reward_by_ids(vec![(11, 1)]);
mock::start_active_era(3);
mock::make_all_reward_payment(2);
@@ -1049,7 +1050,7 @@ fn validator_payment_prefs_work() {
// Compute total payout now for whole duration as other parameter won't change
let total_payout_1 = current_total_payout_for_duration(reward_time_per_era());
let exposure_1 = Staking::eras_stakers(active_era(), 11);
<Pallet<Test>>::reward_by_ids(vec![(11, 1)]);
Pallet::<Test>::reward_by_ids(vec![(11, 1)]);
mock::start_active_era(2);
mock::make_all_reward_payment(1);
@@ -1610,8 +1611,8 @@ fn reward_to_stake_works() {
// Compute total payout now for whole duration as other parameter won't change
let total_payout_0 = current_total_payout_for_duration(reward_time_per_era());
<Pallet<Test>>::reward_by_ids(vec![(11, 1)]);
<Pallet<Test>>::reward_by_ids(vec![(21, 1)]);
Pallet::<Test>::reward_by_ids(vec![(11, 1)]);
Pallet::<Test>::reward_by_ids(vec![(21, 1)]);
// New era --> rewards are paid --> stakes are changed
mock::start_active_era(1);
@@ -1707,6 +1708,7 @@ fn switching_roles() {
// add a new validator candidate
assert_ok!(Staking::bond(Origin::signed(5), 6, 1000, RewardDestination::Controller));
assert_ok!(Staking::validate(Origin::signed(6), ValidatorPrefs::default()));
assert_ok!(Session::set_keys(Origin::signed(6), SessionKeys { other: 6.into() }, vec![]));
mock::start_active_era(1);
@@ -1715,6 +1717,7 @@ fn switching_roles() {
// 2 decides to be a validator. Consequences:
assert_ok!(Staking::validate(Origin::signed(2), ValidatorPrefs::default()));
assert_ok!(Session::set_keys(Origin::signed(2), SessionKeys { other: 2.into() }, vec![]));
// new stakes:
// 10: 1000 self vote
// 20: 1000 self vote + 250 vote
@@ -1819,6 +1822,11 @@ fn bond_with_little_staked_value_bounded() {
// Stingy validator.
assert_ok!(Staking::bond(Origin::signed(1), 2, 1, RewardDestination::Controller));
assert_ok!(Staking::validate(Origin::signed(2), ValidatorPrefs::default()));
assert_ok!(Session::set_keys(
Origin::signed(2),
SessionKeys { other: 2.into() },
vec![]
));
// 1 era worth of reward. BUT, we set the timestamp after on_initialize, so outdated by
// one block.
@@ -2051,12 +2059,12 @@ fn reward_from_authorship_event_handler_works() {
ExtBuilder::default().build_and_execute(|| {
use pallet_authorship::EventHandler;
assert_eq!(<pallet_authorship::Pallet<Test>>::author(), 11);
assert_eq!(<pallet_authorship::Pallet<Test>>::author(), Some(11));
<Pallet<Test>>::note_author(11);
<Pallet<Test>>::note_uncle(21, 1);
Pallet::<Test>::note_author(11);
Pallet::<Test>::note_uncle(21, 1);
// Rewarding the same two times works.
<Pallet<Test>>::note_uncle(11, 1);
Pallet::<Test>::note_uncle(11, 1);
// Not mandatory but must be coherent with rewards
assert_eq_uvec!(Session::validators(), vec![11, 21]);
@@ -2079,9 +2087,9 @@ fn add_reward_points_fns_works() {
// Not mandatory but must be coherent with rewards
assert_eq_uvec!(Session::validators(), vec![21, 11]);
<Pallet<Test>>::reward_by_ids(vec![(21, 1), (11, 1), (11, 1)]);
Pallet::<Test>::reward_by_ids(vec![(21, 1), (11, 1), (11, 1)]);
<Pallet<Test>>::reward_by_ids(vec![(21, 1), (11, 1), (11, 1)]);
Pallet::<Test>::reward_by_ids(vec![(21, 1), (11, 1), (11, 1)]);
assert_eq!(
ErasRewardPoints::<Test>::get(active_era()),
@@ -3091,13 +3099,13 @@ fn claim_reward_at_the_last_era_and_no_double_claim_and_invalid_claim() {
Payee::<Test>::insert(11, RewardDestination::Controller);
Payee::<Test>::insert(101, RewardDestination::Controller);
<Pallet<Test>>::reward_by_ids(vec![(11, 1)]);
Pallet::<Test>::reward_by_ids(vec![(11, 1)]);
// Compute total payout now for whole duration as other parameter won't change
let total_payout_0 = current_total_payout_for_duration(reward_time_per_era());
mock::start_active_era(1);
<Pallet<Test>>::reward_by_ids(vec![(11, 1)]);
Pallet::<Test>::reward_by_ids(vec![(11, 1)]);
// Change total issuance in order to modify total payout
let _ = Balances::deposit_creating(&999, 1_000_000_000);
// Compute total payout now for whole duration as other parameter won't change
@@ -3106,7 +3114,7 @@ fn claim_reward_at_the_last_era_and_no_double_claim_and_invalid_claim() {
mock::start_active_era(2);
<Pallet<Test>>::reward_by_ids(vec![(11, 1)]);
Pallet::<Test>::reward_by_ids(vec![(11, 1)]);
// Change total issuance in order to modify total payout
let _ = Balances::deposit_creating(&999, 1_000_000_000);
// Compute total payout now for whole duration as other parameter won't change
@@ -3266,7 +3274,7 @@ fn test_max_nominator_rewarded_per_validator_and_cant_steal_someone_else_reward(
}
mock::start_active_era(1);
<Pallet<Test>>::reward_by_ids(vec![(11, 1)]);
Pallet::<Test>::reward_by_ids(vec![(11, 1)]);
// compute and ensure the reward amount is greater than zero.
let _ = current_total_payout_for_duration(reward_time_per_era());