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

[Companion #13615] Keystore overhaul #2336

Merged
merged 5 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use sp_consensus::{EnableProofRecording, Environment, ProofRecording, Proposer,
use sp_consensus_aura::{AuraApi, SlotDuration};
use sp_core::crypto::Pair;
use sp_inherents::CreateInherentDataProviders;
use sp_keystore::SyncCryptoStorePtr;
use sp_keystore::KeystorePtr;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Member, NumberFor};
use std::{convert::TryFrom, hash::Hash, marker::PhantomData, sync::Arc};

Expand Down Expand Up @@ -79,7 +79,7 @@ pub struct BuildAuraConsensusParams<PF, BI, CIDP, Client, BS, SO> {
pub para_client: Arc<Client>,
pub backoff_authoring_blocks: Option<BS>,
pub sync_oracle: SO,
pub keystore: SyncCryptoStorePtr,
pub keystore: KeystorePtr,
pub force_authoring: bool,
pub slot_duration: SlotDuration,
pub telemetry: Option<TelemetryHandle>,
Expand Down
15 changes: 7 additions & 8 deletions client/network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use sp_blockchain::HeaderBackend;
use sp_consensus::BlockOrigin;
use sp_core::{Pair, H256};
use sp_keyring::Sr25519Keyring;
use sp_keystore::{testing::KeyStore, SyncCryptoStore, SyncCryptoStorePtr};
use sp_keystore::{testing::MemoryKeystore, Keystore, KeystorePtr};
use sp_runtime::RuntimeAppPublic;
use sp_state_machine::StorageValue;
use std::{collections::BTreeMap, time::Duration};
Expand Down Expand Up @@ -273,8 +273,8 @@ async fn make_gossip_message_and_header(
relay_parent: H256,
validator_index: u32,
) -> (CollationSecondedSignal, Header) {
let keystore: SyncCryptoStorePtr = Arc::new(KeyStore::new());
let alice_public = SyncCryptoStore::sr25519_generate_new(
let keystore: KeystorePtr = Arc::new(MemoryKeystore::new());
let alice_public = Keystore::sr25519_generate_new(
&*keystore,
ValidatorId::ID,
Some(&Sr25519Keyring::Alice.to_seed()),
Expand Down Expand Up @@ -309,7 +309,6 @@ async fn make_gossip_message_and_header(
validator_index.into(),
&alice_public.into(),
)
.await
.ok()
.flatten()
.expect("Signing statement");
Expand Down Expand Up @@ -454,8 +453,8 @@ async fn check_statement_seconded() {
let header = default_header();
let relay_parent = H256::from_low_u64_be(1);

let keystore: SyncCryptoStorePtr = Arc::new(KeyStore::new());
let alice_public = SyncCryptoStore::sr25519_generate_new(
let keystore: KeystorePtr = Arc::new(MemoryKeystore::new());
let alice_public = Keystore::sr25519_generate_new(
&*keystore,
ValidatorId::ID,
Some(&Sr25519Keyring::Alice.to_seed()),
Expand All @@ -466,13 +465,13 @@ async fn check_statement_seconded() {

let statement = Statement::Valid(Default::default());

let signed_statement = block_on(SignedFullStatement::sign(
let signed_statement = SignedFullStatement::sign(
&keystore,
statement,
&signing_context,
0.into(),
&alice_public.into(),
))
)
.ok()
.flatten()
.expect("Signs statement");
Expand Down
8 changes: 4 additions & 4 deletions parachain-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use sc_network::NetworkBlock;
use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
use sp_keystore::SyncCryptoStorePtr;
use sp_keystore::KeystorePtr;
use substrate_prometheus_endpoint::Registry;

/// Native executor type.
Expand Down Expand Up @@ -212,7 +212,7 @@ async fn start_node_impl(
transaction_pool: transaction_pool.clone(),
task_manager: &mut task_manager,
config: parachain_config,
keystore: params.keystore_container.sync_keystore(),
keystore: params.keystore_container.keystore(),
backend,
network: network.clone(),
sync_service: sync_service.clone(),
Expand Down Expand Up @@ -263,7 +263,7 @@ async fn start_node_impl(
relay_chain_interface.clone(),
transaction_pool,
sync_service,
params.keystore_container.sync_keystore(),
params.keystore_container.keystore(),
force_authoring,
para_id,
)?;
Expand Down Expand Up @@ -352,7 +352,7 @@ fn build_consensus(
relay_chain_interface: Arc<dyn RelayChainInterface>,
transaction_pool: Arc<sc_transaction_pool::FullPool<Block, ParachainClient>>,
sync_oracle: Arc<SyncingService<Block>>,
keystore: SyncCryptoStorePtr,
keystore: KeystorePtr,
force_authoring: bool,
para_id: ParaId,
) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error> {
Expand Down
20 changes: 10 additions & 10 deletions polkadot-parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, Ta
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
use sp_api::{ApiExt, ConstructRuntimeApi};
use sp_consensus_aura::AuraApi;
use sp_keystore::SyncCryptoStorePtr;
use sp_keystore::KeystorePtr;
use sp_runtime::{
app_crypto::AppKey,
traits::{BlakeTwo256, Header as HeaderT},
Expand Down Expand Up @@ -359,7 +359,7 @@ where
Arc<dyn RelayChainInterface>,
Arc<sc_transaction_pool::FullPool<Block, ParachainClient<RuntimeApi>>>,
Arc<SyncingService<Block>>,
SyncCryptoStorePtr,
KeystorePtr,
bool,
) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,
{
Expand Down Expand Up @@ -411,7 +411,7 @@ where
transaction_pool: transaction_pool.clone(),
task_manager: &mut task_manager,
config: parachain_config,
keystore: params.keystore_container.sync_keystore(),
keystore: params.keystore_container.keystore(),
backend: backend.clone(),
network: network.clone(),
sync_service: sync_service.clone(),
Expand Down Expand Up @@ -457,7 +457,7 @@ where
relay_chain_interface.clone(),
transaction_pool,
sync_service,
params.keystore_container.sync_keystore(),
params.keystore_container.keystore(),
force_authoring,
)?;

Expand Down Expand Up @@ -547,7 +547,7 @@ where
Arc<dyn RelayChainInterface>,
Arc<sc_transaction_pool::FullPool<Block, ParachainClient<RuntimeApi>>>,
Arc<SyncingService<Block>>,
SyncCryptoStorePtr,
KeystorePtr,
bool,
) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,
{
Expand Down Expand Up @@ -611,7 +611,7 @@ where
transaction_pool: transaction_pool.clone(),
task_manager: &mut task_manager,
config: parachain_config,
keystore: params.keystore_container.sync_keystore(),
keystore: params.keystore_container.keystore(),
backend: backend.clone(),
network: network.clone(),
sync_service: sync_service.clone(),
Expand Down Expand Up @@ -656,7 +656,7 @@ where
relay_chain_interface.clone(),
transaction_pool,
sync_service,
params.keystore_container.sync_keystore(),
params.keystore_container.keystore(),
force_authoring,
)?;

Expand Down Expand Up @@ -1317,7 +1317,7 @@ where
Arc<dyn RelayChainInterface>,
Arc<sc_transaction_pool::FullPool<Block, ParachainClient<RuntimeApi>>>,
Arc<SyncingService<Block>>,
SyncCryptoStorePtr,
KeystorePtr,
bool,
) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,
{
Expand Down Expand Up @@ -1380,7 +1380,7 @@ where
transaction_pool: transaction_pool.clone(),
task_manager: &mut task_manager,
config: parachain_config,
keystore: params.keystore_container.sync_keystore(),
keystore: params.keystore_container.keystore(),
backend: backend.clone(),
network: network.clone(),
sync_service: sync_service.clone(),
Expand Down Expand Up @@ -1425,7 +1425,7 @@ where
relay_chain_interface.clone(),
transaction_pool,
sync_service,
params.keystore_container.sync_keystore(),
params.keystore_container.keystore(),
force_authoring,
)?;

Expand Down
2 changes: 1 addition & 1 deletion test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ where
transaction_pool: transaction_pool.clone(),
task_manager: &mut task_manager,
config: parachain_config,
keystore: params.keystore_container.sync_keystore(),
keystore: params.keystore_container.keystore(),
backend: backend.clone(),
network: network.clone(),
sync_service: sync_service.clone(),
Expand Down