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

Companion #10403: Remove Default for AccountId #4500

Merged
merged 22 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
326 changes: 163 additions & 163 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bridges/bin/millau/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ fn testnet_genesis(
aura: AuraConfig { authorities: Vec::new() },
beefy: BeefyConfig { authorities: Vec::new() },
grandpa: GrandpaConfig { authorities: Vec::new() },
sudo: SudoConfig { key: root_key },
sudo: SudoConfig { key: Some(root_key) },
session: SessionConfig {
keys: initial_authorities
.iter()
Expand Down
2 changes: 1 addition & 1 deletion bridges/bin/rialto-parachain/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fn testnet_genesis(
balances: rialto_parachain_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
},
sudo: rialto_parachain_runtime::SudoConfig { key: root_key },
sudo: rialto_parachain_runtime::SudoConfig { key: Some(root_key) },
parachain_info: rialto_parachain_runtime::ParachainInfoConfig { parachain_id: id },
aura: rialto_parachain_runtime::AuraConfig { authorities: initial_authorities },
aura_ext: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion bridges/bin/rialto/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ fn testnet_genesis(
},
beefy: BeefyConfig { authorities: Vec::new() },
grandpa: GrandpaConfig { authorities: Vec::new() },
sudo: SudoConfig { key: root_key },
sudo: SudoConfig { key: Some(root_key) },
session: SessionConfig {
keys: initial_authorities
.iter()
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/messages/src/instant_payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn pay_relayers_rewards<Currency, AccountId>(
relayer_fund_account: &AccountId,
confirmation_fee: Currency::Balance,
) where
AccountId: Debug + Default + Encode + PartialEq,
AccountId: Debug + Encode + PartialEq,
Currency: CurrencyT<AccountId>,
Currency::Balance: From<u64>,
{
Expand Down
3 changes: 2 additions & 1 deletion bridges/primitives/header-chain/tests/justification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ fn justification_with_invalid_commit_rejected() {
#[test]
fn justification_with_invalid_authority_signature_rejected() {
let mut justification = make_default_justification::<TestHeader>(&test_header(1));
justification.commit.precommits[0].signature = Default::default();
justification.commit.precommits[0].signature =
sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64]);

assert_eq!(
verify_justification::<TestHeader>(
Expand Down
17 changes: 13 additions & 4 deletions bridges/primitives/polkadot-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use bp_runtime::Chain;
use frame_support::{
dispatch::Dispatchable,
parameter_types,
unsigned::TransactionValidityError,
weights::{
constants::{BlockExecutionWeight, WEIGHT_PER_SECOND},
DispatchClass, Weight,
Expand All @@ -33,7 +34,7 @@ use scale_info::{StaticTypeInfo, TypeInfo};
use sp_core::Hasher as HasherT;
use sp_runtime::{
generic,
traits::{BlakeTwo256, IdentifyAccount, Verify},
traits::{BlakeTwo256, DispatchInfoOf, IdentifyAccount, Verify},
MultiAddress, MultiSignature, OpaqueExtrinsic,
};
use sp_std::prelude::Vec;
Expand Down Expand Up @@ -343,11 +344,19 @@ where
type AdditionalSigned = AdditionalSigned;
type Pre = ();

fn additional_signed(
&self,
) -> Result<Self::AdditionalSigned, frame_support::unsigned::TransactionValidityError> {
fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> {
Ok(self.additional_signed)
}

fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(self.validate(who, call, info, len).map(|_| ())?)
}
}

/// Polkadot-like chain.
Expand Down
3 changes: 1 addition & 2 deletions bridges/primitives/test-utils/src/keyring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use codec::Encode;
use ed25519_dalek::{Keypair, PublicKey, SecretKey, Signature};
use finality_grandpa::voter_set::VoterSet;
use sp_application_crypto::Public;
use sp_finality_grandpa::{AuthorityId, AuthorityList, AuthorityWeight};
use sp_runtime::RuntimeDebug;
use sp_std::prelude::*;
Expand Down Expand Up @@ -70,7 +69,7 @@ impl Account {

impl From<Account> for AuthorityId {
fn from(p: Account) -> Self {
AuthorityId::from_slice(&p.public().to_bytes())
sp_application_crypto::UncheckedFrom::unchecked_from(p.public().to_bytes())
}
}

Expand Down
2 changes: 1 addition & 1 deletion node/core/approval-voting/src/criteria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use polkadot_primitives::v1::{
AssignmentId, AssignmentPair, CandidateHash, CoreIndex, GroupIndex, SessionInfo, ValidatorIndex,
};
use sc_keystore::LocalKeystore;
use sp_application_crypto::Public;
use sp_application_crypto::ByteArray;

use merlin::Transcript;
use schnorrkel::vrf::VRFInOut;
Expand Down
12 changes: 8 additions & 4 deletions node/network/approval-distribution/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ use std::time::Duration;

type VirtualOverseer = test_helpers::TestSubsystemContextHandle<ApprovalDistributionMessage>;

fn dummy_signature() -> polkadot_primitives::v1::ValidatorSignature {
sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64])
}

fn test_harness<T: Future<Output = VirtualOverseer>>(
mut state: State,
test_fn: impl FnOnce(VirtualOverseer) -> T,
Expand Down Expand Up @@ -470,7 +474,7 @@ fn import_approval_happy_path() {
block_hash: hash,
candidate_index,
validator: validator_index,
signature: Default::default(),
signature: dummy_signature(),
};
let msg = protocol_v1::ApprovalDistributionMessage::Approvals(vec![approval.clone()]);
send_message_from_peer(overseer, &peer_b, msg).await;
Expand Down Expand Up @@ -537,7 +541,7 @@ fn import_approval_bad() {
block_hash: hash,
candidate_index,
validator: validator_index,
signature: Default::default(),
signature: dummy_signature(),
};
let msg = protocol_v1::ApprovalDistributionMessage::Approvals(vec![approval.clone()]);
send_message_from_peer(overseer, &peer_b, msg).await;
Expand Down Expand Up @@ -867,7 +871,7 @@ fn import_remotely_then_locally() {
block_hash: hash,
candidate_index,
validator: validator_index,
signature: Default::default(),
signature: dummy_signature(),
};
let msg = protocol_v1::ApprovalDistributionMessage::Approvals(vec![approval.clone()]);
send_message_from_peer(overseer, peer, msg).await;
Expand Down Expand Up @@ -922,7 +926,7 @@ fn sends_assignments_even_when_state_is_approved() {
block_hash: hash,
candidate_index,
validator: validator_index,
signature: Default::default(),
signature: dummy_signature(),
};

overseer_send(
Expand Down
2 changes: 1 addition & 1 deletion node/network/bridge/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ fn relays_collation_protocol_messages() {
let collator_protocol_message = protocol_v1::CollatorProtocolMessage::Declare(
Sr25519Keyring::Alice.public().into(),
Default::default(),
Default::default(),
sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64]),
);

let message =
Expand Down
2 changes: 1 addition & 1 deletion node/network/gossip-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use rand::{seq::SliceRandom as _, SeedableRng};
use rand_chacha::ChaCha20Rng;

use sc_network::Multiaddr;
use sp_application_crypto::{AppKey, Public};
use sp_application_crypto::{AppKey, ByteArray};
use sp_keystore::{CryptoStore, SyncCryptoStorePtr};

use polkadot_node_network_protocol::{
Expand Down
4 changes: 2 additions & 2 deletions node/overseer/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,12 +895,12 @@ fn test_dispute_distribution_msg() -> DisputeDistributionMessage {
session_index: 0,
invalid_vote: InvalidDisputeVote {
validator_index: ValidatorIndex(0),
signature: Default::default(),
signature: sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64]),
kind: InvalidDisputeStatementKind::Explicit,
},
valid_vote: ValidDisputeVote {
validator_index: ValidatorIndex(0),
signature: Default::default(),
signature: sp_core::crypto::UncheckedFrom::unchecked_from([2u8; 64]),
kind: ValidDisputeStatementKind::Explicit,
},
};
Expand Down
2 changes: 1 addition & 1 deletion node/primitives/src/approval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use polkadot_primitives::v1::{
BlockNumber, CandidateHash, CandidateIndex, CoreIndex, Hash, Header, ValidatorIndex,
ValidatorSignature,
};
use sp_application_crypto::Public;
use sp_application_crypto::ByteArray;
use sp_consensus_babe as babe_primitives;

/// Validators assigning to check a particular candidate are split up into tranches.
Expand Down
8 changes: 4 additions & 4 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
im_online: Default::default(),
authority_discovery: westend::AuthorityDiscoveryConfig { keys: vec![] },
vesting: westend::VestingConfig { vesting: vec![] },
sudo: westend::SudoConfig { key: endowed_accounts[0].clone() },
sudo: westend::SudoConfig { key: Some(endowed_accounts[0].clone()) },
hrmp: Default::default(),
configuration: westend::ConfigurationConfig {
config: default_parachains_host_configuration(),
Expand Down Expand Up @@ -1034,7 +1034,7 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
collective: Default::default(),
membership: Default::default(),
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig { keys: vec![] },
sudo: rococo_runtime::SudoConfig { key: endowed_accounts[0].clone() },
sudo: rococo_runtime::SudoConfig { key: Some(endowed_accounts[0].clone()) },
paras: rococo_runtime::ParasConfig { paras: vec![] },
hrmp: Default::default(),
configuration: rococo_runtime::ConfigurationConfig {
Expand Down Expand Up @@ -1470,7 +1470,7 @@ pub fn westend_testnet_genesis(
im_online: Default::default(),
authority_discovery: westend::AuthorityDiscoveryConfig { keys: vec![] },
vesting: westend::VestingConfig { vesting: vec![] },
sudo: westend::SudoConfig { key: root_key },
sudo: westend::SudoConfig { key: Some(root_key) },
hrmp: Default::default(),
configuration: westend::ConfigurationConfig {
config: default_parachains_host_configuration(),
Expand Down Expand Up @@ -1541,7 +1541,7 @@ pub fn rococo_testnet_genesis(
collective: Default::default(),
membership: Default::default(),
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig { keys: vec![] },
sudo: rococo_runtime::SudoConfig { key: root_key.clone() },
sudo: rococo_runtime::SudoConfig { key: Some(root_key.clone()) },
hrmp: Default::default(),
configuration: rococo_runtime::ConfigurationConfig {
config: polkadot_runtime_parachains::configuration::HostConfiguration {
Expand Down
2 changes: 1 addition & 1 deletion node/subsystem-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use polkadot_primitives::v1::{
ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature,
};
use sp_application_crypto::AppKey;
use sp_core::{traits::SpawnNamed, Public};
use sp_core::{traits::SpawnNamed, ByteArray};
use sp_keystore::{CryptoStore, Error as KeystoreError, SyncCryptoStorePtr};
use std::{
collections::{hash_map::Entry, HashMap},
Expand Down
2 changes: 1 addition & 1 deletion node/subsystem-util/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use lru::LruCache;

use parity_scale_codec::Encode;
use sp_application_crypto::AppKey;
use sp_core::crypto::Public;
use sp_core::crypto::ByteArray;
use sp_keystore::{CryptoStore, SyncCryptoStorePtr};

use polkadot_node_subsystem::{SubsystemContext, SubsystemSender};
Expand Down
2 changes: 1 addition & 1 deletion node/test/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fn polkadot_testnet_genesis(
authority_discovery: runtime::AuthorityDiscoveryConfig { keys: vec![] },
claims: runtime::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: runtime::VestingConfig { vesting: vec![] },
sudo: runtime::SudoConfig { key: root_key },
sudo: runtime::SudoConfig { key: Some(root_key) },
configuration: runtime::ConfigurationConfig {
config: polkadot_runtime_parachains::configuration::HostConfiguration {
validation_upgrade_frequency: 10u32,
Expand Down
4 changes: 2 additions & 2 deletions node/test/service/tests/call-function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use polkadot_test_service::*;
use sp_keyring::Sr25519Keyring::{Alice, Bob};
use sp_keyring::Sr25519Keyring::{Alice, Bob, Charlie};

#[substrate_test_utils::test]
async fn call_function_actually_work() {
let alice =
run_validator_node(tokio::runtime::Handle::current(), Alice, || {}, Vec::new(), None);

let function = polkadot_test_runtime::Call::Balances(pallet_balances::Call::transfer {
dest: Default::default(),
dest: Charlie.to_account_id().into(),
value: 1,
});
let output = alice.send_extrinsic(function, Bob).await.unwrap();
Expand Down
1 change: 0 additions & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ frame-system = { git = "https://github.com/paritytech/substrate", branch = "mast
hex-literal = "0.3.4"
parity-util-mem = { version = "0.10.0", default-features = false, optional = true }


[features]
default = ["std"]
std = [
Expand Down
8 changes: 4 additions & 4 deletions primitives/src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ fn check_collator_signature<H: AsRef<[u8]>>(

/// All data pertaining to the execution of a parachain candidate.
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct CandidateReceipt<H = Hash, N = BlockNumber> {
/// The ID of the parachain this is a candidate for.
pub parachain_index: Id,
Expand Down Expand Up @@ -411,7 +411,7 @@ pub struct OmittedValidationData<N = BlockNumber> {
/// When submitting to the relay-chain, this data should be omitted as it can
/// be re-generated from relay-chain state.
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct AbridgedCandidateReceipt<H = Hash> {
/// The ID of the parachain this is a candidate for.
pub parachain_index: Id,
Expand Down Expand Up @@ -546,7 +546,7 @@ impl Ord for AbridgedCandidateReceipt {

/// A unique descriptor of the candidate receipt, in a lightweight format.
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct CandidateDescriptor<H = Hash> {
/// The ID of the para this is a candidate for.
pub para_id: Id,
Expand All @@ -566,7 +566,7 @@ pub struct CandidateDescriptor<H = Hash> {

/// A collation sent by a collator.
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct CollationInfo {
/// The ID of the parachain this is a candidate for.
pub parachain_index: Id,
Expand Down
14 changes: 4 additions & 10 deletions runtime/common/src/auctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,16 +635,10 @@ impl<T: Config> Pallet<T> {

winning_ranges
.into_iter()
.map(|range| {
let mut final_winner = Default::default();
swap(
&mut final_winner,
winning[range as u8 as usize]
.as_mut()
.expect("none values are filtered out in previous logic; qed"),
);
let (bidder, para, amount) = final_winner;
(bidder, para, amount, range)
.filter_map(|range| {
winning[range as u8 as usize]
.take()
.map(|(bidder, para, amount)| (bidder, para, amount, range))
})
.collect::<Vec<_>>()
}
Expand Down
10 changes: 10 additions & 0 deletions runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,16 @@ where
Ok(())
}

fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(self.validate(who, call, info, len).map(|_| ())?)
}

// <weight>
// The weight of this logic is included in the `attest` dispatchable.
// </weight>
Expand Down
Loading