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
@@ -209,7 +209,11 @@ frame_benchmarking::benchmarks! {
let receiver = account("receiver", 0, SEED);
let initial_balance = T::Currency::minimum_balance() * 10u32.into();
T::Currency::make_free_balance_be(&receiver, initial_balance);
let ready: ReadySolution<T::AccountId> = Default::default();
let ready = ReadySolution {
supports: vec![],
score: Default::default(),
compute: Default::default()
};
let deposit: BalanceOf<T> = 10u32.into();
let reward: BalanceOf<T> = 20u32.into();
@@ -314,7 +318,12 @@ frame_benchmarking::benchmarks! {
score: [(10_000_000 + i).into(), 0, 0],
..Default::default()
};
let signed_submission = SignedSubmission { raw_solution, ..Default::default() };
let signed_submission = SignedSubmission {
raw_solution,
who: account("submitters", i, SEED),
deposit: Default::default(),
reward: Default::default(),
};
signed_submissions.insert(signed_submission);
}
signed_submissions.put();
@@ -1189,7 +1189,7 @@ pub mod pallet {
/// affect; we shouldn't need a cryptographically secure hasher.
#[pallet::storage]
pub(crate) type SignedSubmissionsMap<T: Config> =
StorageMap<_, Twox64Concat, u32, SignedSubmissionOf<T>, ValueQuery>;
StorageMap<_, Twox64Concat, u32, SignedSubmissionOf<T>, OptionQuery>;
// `SignedSubmissions` items end here.
@@ -42,7 +42,7 @@ use sp_std::{
/// A raw, unchecked signed submission.
///
/// This is just a wrapper around [`RawSolution`] and some additional info.
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, Default, scale_info::TypeInfo)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, scale_info::TypeInfo)]
pub struct SignedSubmission<AccountId, Balance: HasCompact, Solution> {
/// Who submitted this solution.
pub who: AccountId,
@@ -167,17 +167,17 @@ impl<T: Config> SignedSubmissions<T> {
}
/// Get the submission at a particular index.
fn get_submission(&self, idx: u32) -> Option<SignedSubmissionOf<T>> {
if self.deletion_overlay.contains(&idx) {
fn get_submission(&self, index: u32) -> Option<SignedSubmissionOf<T>> {
if self.deletion_overlay.contains(&index) {
// Note: can't actually remove the item from the insertion overlay (if present)
// because we don't want to use `&mut self` here. There may be some kind of
// `RefCell` optimization possible here in the future.
None
} else {
self.insertion_overlay
.get(&idx)
.get(&index)
.cloned()
.or_else(|| SignedSubmissionsMap::<T>::try_get(idx).ok())
.or_else(|| SignedSubmissionsMap::<T>::get(index))
}
}
@@ -200,18 +200,18 @@ impl<T: Config> SignedSubmissions<T> {
remove_score: ElectionScore,
insert: Option<(ElectionScore, u32)>,
) -> Option<SignedSubmissionOf<T>> {
let remove_idx = self.indices.remove(&remove_score)?;
let remove_index = self.indices.remove(&remove_score)?;
if let Some((insert_score, insert_idx)) = insert {
self.indices
.try_insert(insert_score, insert_idx)
.expect("just removed an item, we must be under capacity; qed");
}
self.insertion_overlay.remove(&remove_idx).or_else(|| {
(!self.deletion_overlay.contains(&remove_idx))
self.insertion_overlay.remove(&remove_index).or_else(|| {
(!self.deletion_overlay.contains(&remove_index))
.then(|| {
self.deletion_overlay.insert(remove_idx);
SignedSubmissionsMap::<T>::try_get(remove_idx).ok()
self.deletion_overlay.insert(remove_index);
SignedSubmissionsMap::<T>::get(remove_index)
})
.flatten()
})