mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 19:51:05 +00:00
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:
@@ -44,7 +44,7 @@ pub use sp_application_crypto as app_crypto;
|
||||
pub use sp_core::storage::{Storage, StorageChild};
|
||||
|
||||
use sp_core::{
|
||||
crypto::{self, Public},
|
||||
crypto::{self, ByteArray},
|
||||
ecdsa, ed25519,
|
||||
hash::{H256, H512},
|
||||
sr25519,
|
||||
@@ -284,12 +284,6 @@ impl TryFrom<MultiSignature> for ecdsa::Signature {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MultiSignature {
|
||||
fn default() -> Self {
|
||||
Self::Ed25519(Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
/// Public key for any known crypto algorithm.
|
||||
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
@@ -302,12 +296,6 @@ pub enum MultiSigner {
|
||||
Ecdsa(ecdsa::Public),
|
||||
}
|
||||
|
||||
impl Default for MultiSigner {
|
||||
fn default() -> Self {
|
||||
Self::Ed25519(Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
/// NOTE: This implementations is required by `SimpleAddressDeterminer`,
|
||||
/// we convert the hash into some AccountId, it's fine to use any scheme.
|
||||
impl<T: Into<H256>> crypto::UncheckedFrom<T> for MultiSigner {
|
||||
@@ -403,10 +391,14 @@ impl Verify for MultiSignature {
|
||||
type Signer = MultiSigner;
|
||||
fn verify<L: Lazy<[u8]>>(&self, mut msg: L, signer: &AccountId32) -> bool {
|
||||
match (self, signer) {
|
||||
(Self::Ed25519(ref sig), who) =>
|
||||
sig.verify(msg, &ed25519::Public::from_slice(who.as_ref())),
|
||||
(Self::Sr25519(ref sig), who) =>
|
||||
sig.verify(msg, &sr25519::Public::from_slice(who.as_ref())),
|
||||
(Self::Ed25519(ref sig), who) => match ed25519::Public::from_slice(who.as_ref()) {
|
||||
Ok(signer) => sig.verify(msg, &signer),
|
||||
Err(()) => false,
|
||||
},
|
||||
(Self::Sr25519(ref sig), who) => match sr25519::Public::from_slice(who.as_ref()) {
|
||||
Ok(signer) => sig.verify(msg, &signer),
|
||||
Err(()) => false,
|
||||
},
|
||||
(Self::Ecdsa(ref sig), who) => {
|
||||
let m = sp_io::hashing::blake2_256(msg.get());
|
||||
match sp_io::crypto::secp256k1_ecdsa_recover_compressed(sig.as_ref(), &m) {
|
||||
@@ -433,7 +425,10 @@ impl Verify for AnySignature {
|
||||
.map(|s| s.verify(msg, signer))
|
||||
.unwrap_or(false) ||
|
||||
ed25519::Signature::try_from(self.0.as_fixed_bytes().as_ref())
|
||||
.map(|s| s.verify(msg, &ed25519::Public::from_slice(signer.as_ref())))
|
||||
.map(|s| match ed25519::Public::from_slice(signer.as_ref()) {
|
||||
Err(()) => false,
|
||||
Ok(signer) => s.verify(msg, &signer),
|
||||
})
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
@@ -924,7 +919,7 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
use codec::{Decode, Encode};
|
||||
use sp_core::crypto::Pair;
|
||||
use sp_core::crypto::{Pair, UncheckedFrom};
|
||||
use sp_io::TestExternalities;
|
||||
use sp_state_machine::create_proof_check_backend;
|
||||
|
||||
@@ -1010,7 +1005,9 @@ mod tests {
|
||||
|
||||
ext.execute_with(|| {
|
||||
let _batching = SignatureBatching::start();
|
||||
sp_io::crypto::sr25519_verify(&Default::default(), &Vec::new(), &Default::default());
|
||||
let dummy = UncheckedFrom::unchecked_from([1; 32]);
|
||||
let dummy_sig = UncheckedFrom::unchecked_from([1; 64]);
|
||||
sp_io::crypto::sr25519_verify(&dummy_sig, &Vec::new(), &dummy);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user