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

Remove Default bound for AccountId #10403

Merged
merged 52 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d3af49f
Remove Default for AccountId
gavofyork Dec 2, 2021
f6827f1
More removals of default
gavofyork Dec 2, 2021
d397c5d
Update frame/authorship/src/lib.rs
gavofyork Dec 2, 2021
c446fff
Update frame/authorship/src/lib.rs
gavofyork Dec 2, 2021
19023db
Update frame/authorship/src/lib.rs
gavofyork Dec 2, 2021
80df1fb
Update frame/authorship/src/lib.rs
gavofyork Dec 2, 2021
2cbe13a
More work
gavofyork Dec 2, 2021
0930529
More work
gavofyork Dec 2, 2021
016a1ee
Remove old code
gavofyork Dec 2, 2021
594deb9
More work
gavofyork Dec 2, 2021
daa2942
pallet-asset-tx-payment
gavofyork Dec 2, 2021
0f270da
tips
gavofyork Dec 2, 2021
393ed87
sc-consensus-babe
gavofyork Dec 2, 2021
7169d84
sc-finality-grandpa
gavofyork Dec 2, 2021
a853bcc
sc-consensus-babe-rpc
gavofyork Dec 2, 2021
4cb42ff
sc-cli
gavofyork Dec 2, 2021
2a04445
make npos crates accept non-default account (#10420)
kianenigma Dec 4, 2021
452651c
more work
gavofyork Dec 4, 2021
227f360
more work
gavofyork Dec 4, 2021
345c87b
Tests build
gavofyork Dec 6, 2021
c12d8cf
Fix imonline tests
gavofyork Dec 7, 2021
2cfd1d0
Formatting
gavofyork Dec 7, 2021
b537356
Merge branch 'master' into gav-no-default-accountid
gavofyork Dec 7, 2021
f5758f1
Fixes
gavofyork Dec 7, 2021
9965af3
Merge branch 'gav-no-default-accountid' of github.com:paritytech/subs…
gavofyork Dec 7, 2021
3dc3969
Fixes
gavofyork Dec 7, 2021
b7fe115
Merge remote-tracking branch 'origin/master' into gav-no-default-acco…
gavofyork Dec 9, 2021
c9c7ba7
Fix bench
kianenigma Dec 9, 2021
ea520fa
Fixes
gavofyork Dec 9, 2021
b694599
Fixes
gavofyork Dec 9, 2021
97ec65a
Fixes
gavofyork Dec 10, 2021
b9c1e17
Fixes
gavofyork Dec 10, 2021
ddfbfa9
Fixes
gavofyork Dec 10, 2021
2316103
Formatting
gavofyork Dec 10, 2021
d302551
Fixes
gavofyork Dec 10, 2021
915bf1c
Formatting
gavofyork Dec 10, 2021
cfb1418
Fixes
gavofyork Dec 10, 2021
ed72cad
Formatting
gavofyork Dec 10, 2021
6e1b9e7
Fixes
gavofyork Dec 10, 2021
5fab98c
Formatting
gavofyork Dec 10, 2021
8eccc1d
Merge remote-tracking branch 'origin/master' into gav-no-default-acco…
gavofyork Dec 11, 2021
67492d1
Fixes
gavofyork Dec 11, 2021
b465b2d
Formatting
gavofyork Dec 11, 2021
26053ee
Merge branch 'master' into gav-no-default-accountid
gavofyork Dec 11, 2021
87351bb
Update client/keystore/src/local.rs
gavofyork Dec 12, 2021
f7939bb
Update client/finality-grandpa/src/lib.rs
gavofyork Dec 12, 2021
5e157c9
Update client/keystore/src/local.rs
gavofyork Dec 12, 2021
3557e13
Update client/keystore/src/local.rs
gavofyork Dec 12, 2021
c147de9
Update frame/staking/src/lib.rs
gavofyork Dec 12, 2021
fa596c1
Update frame/staking/src/lib.rs
gavofyork Dec 12, 2021
aa7ac28
Update primitives/runtime/src/traits.rs
gavofyork Dec 12, 2021
175596a
Formatting
gavofyork Dec 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ members = [
"frame/contracts/rpc/runtime-api",
"frame/democracy",
"frame/try-runtime",
"frame/elections",
"frame/election-provider-multi-phase",
"frame/election-provider-support",
"frame/examples/basic",
Expand Down
2 changes: 1 addition & 1 deletion bin/node-template/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fn testnet_genesis(
},
sudo: SudoConfig {
// Assign network admin rights.
key: root_key,
key: Some(root_key),
},
transaction_payment: Default::default(),
}
Expand Down
2 changes: 1 addition & 1 deletion bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ pub fn testnet_genesis(
.collect(),
phantom: Default::default(),
},
sudo: SudoConfig { key: root_key },
sudo: SudoConfig { key: Some(root_key) },
babe: BabeConfig {
authorities: vec![],
epoch_config: Some(node_runtime::BABE_GENESIS_EPOCH_CONFIG),
Expand Down
1 change: 1 addition & 0 deletions bin/node/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ sp-application-crypto = { version = "4.0.0-dev", path = "../../../primitives/app
sp-consensus-babe = { version = "0.10.0-dev", path = "../../../primitives/consensus/babe" }
sp-runtime = { version = "4.0.0-dev", path = "../../../primitives/runtime" }
sp-externalities = { version = "0.10.0", path = "../../../primitives/externalities" }
sp-keyring = { version = "4.0.0-dev", path = "../../../primitives/keyring" }
wat = "1.0"
futures = "0.3.9"

Expand Down
16 changes: 9 additions & 7 deletions bin/node/executor/tests/submit_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use frame_system::offchain::{SendSignedTransaction, Signer, SubmitTransaction};
use node_runtime::{Executive, Indices, Runtime, UncheckedExtrinsic};
use sp_application_crypto::AppKey;
use sp_core::offchain::{testing::TestTransactionPoolExt, TransactionPoolExt};
use sp_keyring::sr25519::Keyring::Alice;
use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStore};
use std::sync::Arc;

Expand All @@ -33,7 +34,8 @@ fn should_submit_unsigned_transaction() {
t.register_extension(TransactionPoolExt::new(pool));

t.execute_with(|| {
let signature = Default::default();
let signature =
pallet_im_online::sr25519::AuthoritySignature::try_from(vec![0; 64]).unwrap();
let heartbeat_data = pallet_im_online::Heartbeat {
block_number: 1,
network_state: Default::default(),
Expand Down Expand Up @@ -85,7 +87,7 @@ fn should_submit_signed_transaction() {
let results =
Signer::<Runtime, TestAuthorityId>::all_accounts().send_signed_transaction(|_| {
pallet_balances::Call::transfer {
dest: Default::default(),
dest: Alice.to_account_id().into(),
value: Default::default(),
}
});
Expand Down Expand Up @@ -122,7 +124,7 @@ fn should_submit_signed_twice_from_the_same_account() {
let result =
Signer::<Runtime, TestAuthorityId>::any_account().send_signed_transaction(|_| {
pallet_balances::Call::transfer {
dest: Default::default(),
dest: Alice.to_account_id().into(),
value: Default::default(),
}
});
Expand All @@ -134,7 +136,7 @@ fn should_submit_signed_twice_from_the_same_account() {
let result =
Signer::<Runtime, TestAuthorityId>::any_account().send_signed_transaction(|_| {
pallet_balances::Call::transfer {
dest: Default::default(),
dest: Alice.to_account_id().into(),
value: Default::default(),
}
});
Expand Down Expand Up @@ -172,7 +174,7 @@ fn should_submit_signed_twice_from_all_accounts() {
t.execute_with(|| {
let results = Signer::<Runtime, TestAuthorityId>::all_accounts()
.send_signed_transaction(|_| {
pallet_balances::Call::transfer { dest: Default::default(), value: Default::default() }
pallet_balances::Call::transfer { dest: Alice.to_account_id().into(), value: Default::default() }
});

let len = results.len();
Expand All @@ -183,7 +185,7 @@ fn should_submit_signed_twice_from_all_accounts() {
// submit another one from the same account. The nonce should be incremented.
let results = Signer::<Runtime, TestAuthorityId>::all_accounts()
.send_signed_transaction(|_| {
pallet_balances::Call::transfer { dest: Default::default(), value: Default::default() }
pallet_balances::Call::transfer { dest: Alice.to_account_id().into(), value: Default::default() }
});

let len = results.len();
Expand Down Expand Up @@ -237,7 +239,7 @@ fn submitted_transaction_should_be_valid() {
let results =
Signer::<Runtime, TestAuthorityId>::all_accounts().send_signed_transaction(|_| {
pallet_balances::Call::transfer {
dest: Default::default(),
dest: Alice.to_account_id().into(),
value: Default::default(),
}
});
Expand Down
11 changes: 7 additions & 4 deletions bin/node/runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ use pallet_asset_tx_payment::HandleCredit;
pub struct Author;
impl OnUnbalanced<NegativeImbalance> for Author {
fn on_nonzero_unbalanced(amount: NegativeImbalance) {
Balances::resolve_creating(&Authorship::author(), amount);
if let Some(author) = Authorship::author() {
Balances::resolve_creating(&author, amount);
}
}
}

Expand All @@ -36,9 +38,10 @@ impl OnUnbalanced<NegativeImbalance> for Author {
pub struct CreditToBlockAuthor;
impl HandleCredit<AccountId, Assets> for CreditToBlockAuthor {
fn handle_credit(credit: CreditOf<AccountId, Assets>) {
let author = pallet_authorship::Pallet::<Runtime>::author();
// Drop the result which will trigger the `OnDrop` of the imbalance in case of error.
let _ = Assets::resolve(&author, credit);
if let Some(author) = pallet_authorship::Pallet::<Runtime>::author() {
// Drop the result which will trigger the `OnDrop` of the imbalance in case of error.
let _ = Assets::resolve(&author, credit);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1835,8 +1835,8 @@ mod tests {
fn call_size() {
let size = core::mem::size_of::<Call>();
assert!(
size <= 200,
"size of Call {} is more than 200 bytes: some calls have too big arguments, use Box to reduce the
size <= 208,
"size of Call {} is more than 208 bytes: some calls have too big arguments, use Box to reduce the
size of Call.
If the limit is too strong, maybe consider increase the limit to 300.",
size,
Expand Down
6 changes: 3 additions & 3 deletions bin/node/testing/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> Gen
balances: BalancesConfig { balances: endowed },
session: SessionConfig {
keys: vec![
(dave(), alice(), to_session_keys(&Ed25519Keyring::Alice, &Sr25519Keyring::Alice)),
(eve(), bob(), to_session_keys(&Ed25519Keyring::Bob, &Sr25519Keyring::Bob)),
(alice(), dave(), to_session_keys(&Ed25519Keyring::Alice, &Sr25519Keyring::Alice)),
(bob(), eve(), to_session_keys(&Ed25519Keyring::Bob, &Sr25519Keyring::Bob)),
(
ferdie(),
charlie(),
ferdie(),
to_session_keys(&Ed25519Keyring::Charlie, &Sr25519Keyring::Charlie),
),
],
Expand Down
2 changes: 1 addition & 1 deletion bin/utils/chain-spec-builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use structopt::StructOpt;
use node_cli::chain_spec::{self, AccountId};
use sc_keystore::LocalKeystore;
use sp_core::{
crypto::{Public, Ss58Codec},
crypto::{ByteArray, Ss58Codec},
sr25519,
};
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
Expand Down
8 changes: 4 additions & 4 deletions client/basic-authorship/src/basic_authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ mod tests {
amount: Default::default(),
nonce,
from: AccountKeyring::Alice.into(),
to: Default::default(),
to: AccountKeyring::Bob.into(),
}
.into_signed_tx()
}
Expand All @@ -593,7 +593,7 @@ mod tests {
amount: 1,
nonce: 0,
from: pair.public(),
to: Default::default(),
to: AccountKeyring::Bob.into(),
};
let signature = pair.sign(&transfer.encode()).into();
Extrinsic::Transfer { transfer, signature, exhaust_resources_when_not_first: true }
Expand Down Expand Up @@ -777,14 +777,14 @@ mod tests {
amount: Default::default(),
nonce: 2,
from: AccountKeyring::Alice.into(),
to: Default::default(),
to: AccountKeyring::Bob.into(),
}.into_resources_exhausting_tx(),
extrinsic(3),
Transfer {
amount: Default::default(),
nonce: 4,
from: AccountKeyring::Alice.into(),
to: Default::default(),
to: AccountKeyring::Bob.into(),
}.into_resources_exhausting_tx(),
extrinsic(5),
extrinsic(6),
Expand Down
2 changes: 1 addition & 1 deletion client/cli/src/commands/insert_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn to_vec<P: sp_core::Pair>(uri: &str, pass: Option<SecretString>) -> Result<Vec
mod tests {
use super::*;
use sc_service::{ChainSpec, ChainType, GenericChainSpec, NoExtension};
use sp_core::{sr25519::Pair, Pair as _, Public};
use sp_core::{sr25519::Pair, ByteArray, Pair as _};
use structopt::StructOpt;
use tempfile::TempDir;

Expand Down
2 changes: 1 addition & 1 deletion client/cli/src/commands/inspect_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn expect_public_from_phrase<Pair: sp_core::Pair>(
#[cfg(test)]
mod tests {
use super::*;
use sp_core::crypto::{Pair, Public};
use sp_core::crypto::{ByteArray, Pair};
use sp_runtime::traits::IdentifyAccount;
use structopt::StructOpt;

Expand Down
15 changes: 5 additions & 10 deletions client/cli/src/commands/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! implementation of the `verify` subcommand

use crate::{error, utils, with_crypto_scheme, CryptoSchemeFlag};
use sp_core::{crypto::Ss58Codec, Public};
use sp_core::crypto::{ByteArray, Ss58Codec};
use structopt::StructOpt;

/// The `verify` command
Expand Down Expand Up @@ -66,19 +66,14 @@ impl VerifyCmd {
fn verify<Pair>(sig_data: Vec<u8>, message: Vec<u8>, uri: &str) -> error::Result<()>
where
Pair: sp_core::Pair,
Pair::Signature: Default + AsMut<[u8]>,
Pair::Signature: for<'a> std::convert::TryFrom<&'a [u8]>,
{
let mut signature = Pair::Signature::default();
if sig_data.len() != signature.as_ref().len() {
return Err(error::Error::SignatureInvalidLength {
read: sig_data.len(),
expected: signature.as_ref().len(),
})
}
signature.as_mut().copy_from_slice(&sig_data);
let signature =
Pair::Signature::try_from(&sig_data).map_err(|_| error::Error::SignatureFormatInvalid)?;

let pubkey = if let Ok(pubkey_vec) = hex::decode(uri) {
Pair::Public::from_slice(pubkey_vec.as_slice())
.map_err(|_| error::Error::KeyFormatInvalid)?
} else {
Pair::Public::from_string(uri)?
};
Expand Down
12 changes: 5 additions & 7 deletions client/cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ pub enum Error {
#[error("Invalid URI; expecting either a secret URI or a public URI.")]
InvalidUri(crypto::PublicError),

#[error("Signature has an invalid length. Read {read} bytes, expected {expected} bytes")]
SignatureInvalidLength {
/// Amount of signature bytes read.
read: usize,
/// Expected number of signature bytes.
expected: usize,
},
#[error("Signature is an invalid format.")]
SignatureFormatInvalid,

#[error("Key is an invalid format.")]
KeyFormatInvalid,

#[error("Unknown key type, must be a known 4-character sequence")]
KeyTypeInvalid,
Expand Down
4 changes: 2 additions & 2 deletions client/cli/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<C: SubstrateCli> Runner<C> {
/// 2020-06-03 16:14:21 ✌️ version 2.0.0-rc3-f4940588c-x86_64-linux-gnu
/// 2020-06-03 16:14:21 ❤️ by Parity Technologies <admin@parity.io>, 2017-2020
/// 2020-06-03 16:14:21 📋 Chain specification: Flaming Fir
/// 2020-06-03 16:14:21 🏷 Node name: jolly-rod-7462
/// 2020-06-03 16:14:21 🏷 Node name: jolly-rod-7462
/// 2020-06-03 16:14:21 👤 Role: FULL
/// 2020-06-03 16:14:21 💾 Database: RocksDb at /tmp/c/chains/flamingfir7/db
/// 2020-06-03 16:14:21 ⛓ Native runtime: node-251 (substrate-node-1.tx1.au10)
Expand Down Expand Up @@ -199,7 +199,7 @@ pub fn print_node_infos<C: SubstrateCli>(config: &Configuration) {
info!("✌️ version {}", C::impl_version());
info!("❤️ by {}, {}-{}", C::author(), C::copyright_start_year(), Local::today().year());
info!("📋 Chain specification: {}", config.chain_spec.name());
info!("🏷 Node name: {}", config.network.node_name);
info!("🏷 Node name: {}", config.network.node_name);
info!("👤 Role: {}", config.display_role());
info!(
"💾 Database: {} at {}",
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use sp_consensus::{
BlockOrigin, CanAuthorWith, Environment, Error as ConsensusError, Proposer, SelectChain,
};
use sp_consensus_slots::Slot;
use sp_core::crypto::{Pair, Public};
use sp_core::crypto::{ByteArray, Pair, Public};
use sp_inherents::CreateInherentDataProviders;
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
use sp_runtime::{
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/babe/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use sp_application_crypto::AppKey;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_consensus::{Error as ConsensusError, SelectChain};
use sp_consensus_babe::{digests::PreDigest, AuthorityId, BabeApi as BabeRuntimeApi};
use sp_core::crypto::Public;
use sp_core::crypto::ByteArray;
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
use sp_runtime::traits::{Block as BlockT, Header as _};
use std::{collections::HashMap, sync::Arc};
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/babe/src/authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use sp_consensus_babe::{
make_transcript, make_transcript_data, AuthorityId, BabeAuthorityWeight, Slot, BABE_VRF_PREFIX,
};
use sp_consensus_vrf::schnorrkel::{VRFOutput, VRFProof};
use sp_core::{blake2_256, crypto::Public, U256};
use sp_core::{blake2_256, crypto::ByteArray, U256};
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};

/// Calculates the primary selection threshold for a given authority, taking
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ use sp_consensus::{
};
use sp_consensus_babe::inherents::BabeInherentData;
use sp_consensus_slots::Slot;
use sp_core::{crypto::Public, ExecutionContext};
use sp_core::{crypto::ByteArray, ExecutionContext};
use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider};
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
use sp_runtime::{
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/babe/src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use sp_consensus_babe::{
make_transcript, AuthorityId, AuthorityPair, AuthoritySignature,
};
use sp_consensus_slots::Slot;
use sp_core::{Pair, Public};
use sp_core::{ByteArray, Pair};
use sp_runtime::{traits::Header, DigestItem};

/// BABE verification parameters
Expand Down
8 changes: 4 additions & 4 deletions client/finality-grandpa/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ mod tests {
report, AuthorityId, FinalityProof, GrandpaJustification, GrandpaJustificationSender,
};
use sp_blockchain::HeaderBackend;
use sp_core::crypto::Public;
use sp_core::crypto::ByteArray;
use sp_keyring::Ed25519Keyring;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
use substrate_test_runtime_client::{
Expand All @@ -196,8 +196,8 @@ mod tests {
}

fn voters() -> HashSet<AuthorityId> {
let voter_id_1 = AuthorityId::from_slice(&[1; 32]);
let voter_id_2 = AuthorityId::from_slice(&[2; 32]);
let voter_id_1 = AuthorityId::from_slice(&[1; 32]).unwrap();
let voter_id_2 = AuthorityId::from_slice(&[2; 32]).unwrap();

vec![voter_id_1, voter_id_2].into_iter().collect()
}
Expand Down Expand Up @@ -245,7 +245,7 @@ mod tests {

impl ReportVoterState for TestVoterState {
fn get(&self) -> Option<report::VoterState<AuthorityId>> {
let voter_id_1 = AuthorityId::from_slice(&[1; 32]);
let voter_id_1 = AuthorityId::from_slice(&[1; 32]).unwrap();
let voters_best: HashSet<_> = vec![voter_id_1].into_iter().collect();

let best_round_state = sc_finality_grandpa::report::RoundState {
Expand Down
Loading