mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 00:51:06 +00:00
Keystore overhaul (#13615)
* Remove 'supported_keys' 'sign_with_any' and 'sign_with_all' from keystore trait * Remove the aync keystore * Renaming: - SyncCryptoStore -> Keystore - SyncCryptoStorePtr -> KeystorePtr - KeyStore -> MemoryKeystore * Fix authority discovery worker and tests * Rename 'insert_unknown' to 'insert' * Remove leftover
This commit is contained in:
@@ -49,7 +49,7 @@ use parity_scale_codec::{Decode, Encode};
|
||||
use sc_network::{NetworkBlock, NetworkSyncForkRequest, ReputationChange};
|
||||
use sc_network_gossip::{GossipEngine, Network as GossipNetwork};
|
||||
use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_INFO};
|
||||
use sp_keystore::SyncCryptoStorePtr;
|
||||
use sp_keystore::KeystorePtr;
|
||||
use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, NumberFor};
|
||||
|
||||
use crate::{
|
||||
@@ -136,7 +136,7 @@ mod benefit {
|
||||
|
||||
/// A type that ties together our local authority id and a keystore where it is
|
||||
/// available for signing.
|
||||
pub struct LocalIdKeystore((AuthorityId, SyncCryptoStorePtr));
|
||||
pub struct LocalIdKeystore((AuthorityId, KeystorePtr));
|
||||
|
||||
impl LocalIdKeystore {
|
||||
/// Returns a reference to our local authority id.
|
||||
@@ -145,13 +145,13 @@ impl LocalIdKeystore {
|
||||
}
|
||||
|
||||
/// Returns a reference to the keystore.
|
||||
fn keystore(&self) -> SyncCryptoStorePtr {
|
||||
fn keystore(&self) -> KeystorePtr {
|
||||
(self.0).1.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(AuthorityId, SyncCryptoStorePtr)> for LocalIdKeystore {
|
||||
fn from(inner: (AuthorityId, SyncCryptoStorePtr)) -> LocalIdKeystore {
|
||||
impl From<(AuthorityId, KeystorePtr)> for LocalIdKeystore {
|
||||
fn from(inner: (AuthorityId, KeystorePtr)) -> LocalIdKeystore {
|
||||
LocalIdKeystore(inner)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ use sp_consensus_grandpa::{
|
||||
AuthorityList, AuthoritySignature, SetId, CLIENT_LOG_TARGET as LOG_TARGET,
|
||||
};
|
||||
use sp_core::{crypto::ByteArray, traits::CallContext};
|
||||
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
|
||||
use sp_keystore::{Keystore, KeystorePtr};
|
||||
use sp_runtime::{
|
||||
generic::BlockId,
|
||||
traits::{Block as BlockT, NumberFor, Zero},
|
||||
@@ -228,7 +228,7 @@ pub struct Config {
|
||||
/// Some local identifier of the voter.
|
||||
pub name: Option<String>,
|
||||
/// The keystore that manages the keys of this node.
|
||||
pub keystore: Option<SyncCryptoStorePtr>,
|
||||
pub keystore: Option<KeystorePtr>,
|
||||
/// TelemetryHandle instance.
|
||||
pub telemetry: Option<TelemetryHandle>,
|
||||
/// Chain specific GRANDPA protocol name. See [`crate::protocol_standard_name`].
|
||||
@@ -623,7 +623,7 @@ fn global_communication<BE, Block: BlockT, C, N, S>(
|
||||
voters: &Arc<VoterSet<AuthorityId>>,
|
||||
client: Arc<C>,
|
||||
network: &NetworkBridge<Block, N, S>,
|
||||
keystore: Option<&SyncCryptoStorePtr>,
|
||||
keystore: Option<&KeystorePtr>,
|
||||
metrics: Option<until_imported::Metrics>,
|
||||
) -> (
|
||||
impl Stream<
|
||||
@@ -1136,14 +1136,12 @@ where
|
||||
/// available.
|
||||
fn local_authority_id(
|
||||
voters: &VoterSet<AuthorityId>,
|
||||
keystore: Option<&SyncCryptoStorePtr>,
|
||||
keystore: Option<&KeystorePtr>,
|
||||
) -> Option<AuthorityId> {
|
||||
keystore.and_then(|keystore| {
|
||||
voters
|
||||
.iter()
|
||||
.find(|(p, _)| {
|
||||
SyncCryptoStore::has_keys(&**keystore, &[(p.to_raw_vec(), AuthorityId::ID)])
|
||||
})
|
||||
.find(|(p, _)| Keystore::has_keys(&**keystore, &[(p.to_raw_vec(), AuthorityId::ID)]))
|
||||
.map(|(p, _)| p.clone())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ use sc_utils::mpsc::TracingUnboundedReceiver;
|
||||
use sp_blockchain::HeaderMetadata;
|
||||
use sp_consensus::SelectChain;
|
||||
use sp_consensus_grandpa::AuthorityId;
|
||||
use sp_keystore::SyncCryptoStorePtr;
|
||||
use sp_keystore::KeystorePtr;
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
|
||||
use crate::{
|
||||
@@ -220,7 +220,7 @@ struct ObserverWork<B: BlockT, BE, Client, N: NetworkT<B>, S: SyncingT<B>> {
|
||||
client: Arc<Client>,
|
||||
network: NetworkBridge<B, N, S>,
|
||||
persistent_data: PersistentData<B>,
|
||||
keystore: Option<SyncCryptoStorePtr>,
|
||||
keystore: Option<KeystorePtr>,
|
||||
voter_commands_rx: TracingUnboundedReceiver<VoterCommand<B::Hash, NumberFor<B>>>,
|
||||
justification_sender: Option<GrandpaJustificationSender<B>>,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
@@ -240,7 +240,7 @@ where
|
||||
client: Arc<Client>,
|
||||
network: NetworkBridge<B, Network, Syncing>,
|
||||
persistent_data: PersistentData<B>,
|
||||
keystore: Option<SyncCryptoStorePtr>,
|
||||
keystore: Option<KeystorePtr>,
|
||||
voter_commands_rx: TracingUnboundedReceiver<VoterCommand<B::Hash, NumberFor<B>>>,
|
||||
justification_sender: Option<GrandpaJustificationSender<B>>,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
|
||||
@@ -40,7 +40,7 @@ use sp_consensus_grandpa::{
|
||||
};
|
||||
use sp_core::H256;
|
||||
use sp_keyring::Ed25519Keyring;
|
||||
use sp_keystore::{testing::KeyStore as TestKeyStore, SyncCryptoStore, SyncCryptoStorePtr};
|
||||
use sp_keystore::{testing::MemoryKeystore, Keystore, KeystorePtr};
|
||||
use sp_runtime::{
|
||||
codec::Encode,
|
||||
generic::{BlockId, DigestItem},
|
||||
@@ -280,9 +280,9 @@ fn make_ids(keys: &[Ed25519Keyring]) -> AuthorityList {
|
||||
keys.iter().map(|&key| key.public().into()).map(|id| (id, 1)).collect()
|
||||
}
|
||||
|
||||
fn create_keystore(authority: Ed25519Keyring) -> SyncCryptoStorePtr {
|
||||
let keystore = Arc::new(TestKeyStore::new());
|
||||
SyncCryptoStore::ed25519_generate_new(&*keystore, GRANDPA, Some(&authority.to_seed()))
|
||||
fn create_keystore(authority: Ed25519Keyring) -> KeystorePtr {
|
||||
let keystore = Arc::new(MemoryKeystore::new());
|
||||
Keystore::ed25519_generate_new(&*keystore, GRANDPA, Some(&authority.to_seed()))
|
||||
.expect("Creates authority key");
|
||||
keystore
|
||||
}
|
||||
@@ -1376,7 +1376,7 @@ type TestEnvironment<N, S, SC, VR> =
|
||||
|
||||
fn test_environment_with_select_chain<N, S, VR, SC>(
|
||||
link: &TestLinkHalf,
|
||||
keystore: Option<SyncCryptoStorePtr>,
|
||||
keystore: Option<KeystorePtr>,
|
||||
network_service: N,
|
||||
sync_service: S,
|
||||
select_chain: SC,
|
||||
@@ -1428,7 +1428,7 @@ where
|
||||
|
||||
fn test_environment<N, S, VR>(
|
||||
link: &TestLinkHalf,
|
||||
keystore: Option<SyncCryptoStorePtr>,
|
||||
keystore: Option<KeystorePtr>,
|
||||
network_service: N,
|
||||
sync_service: S,
|
||||
voting_rule: VR,
|
||||
|
||||
Reference in New Issue
Block a user