[Companion #13615] Keystore overhaul (#6892)

* Remove not required async calls

* Fixed missing renaming

* make_keystore can be sync

* More fixes

* Trivial nitpicks

* Cherry pick test fix from master

* Fixes after master merge

* update lockfile for {"substrate"}

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
Davide Galassi
2023-03-17 13:09:15 +01:00
committed by GitHub
parent 4d904951fd
commit 46c36e5a4f
38 changed files with 546 additions and 648 deletions
@@ -28,7 +28,7 @@ use futures::{
FutureExt, TryFutureExt,
};
use sp_keystore::SyncCryptoStorePtr;
use sp_keystore::KeystorePtr;
use polkadot_node_network_protocol::{
request_response::{v1 as request_v1, IncomingRequestReceiver},
@@ -70,7 +70,7 @@ pub enum ProtocolSide {
/// Validators operate on the relay chain.
Validator {
/// The keystore holding validator keys.
keystore: SyncCryptoStorePtr,
keystore: KeystorePtr,
/// An eviction policy for inactive peers or validators.
eviction_policy: CollatorEvictionPolicy,
/// Prometheus metrics for validators.
@@ -30,7 +30,7 @@ use std::{
time::{Duration, Instant},
};
use sp_keystore::SyncCryptoStorePtr;
use sp_keystore::KeystorePtr;
use polkadot_node_network_protocol::{
self as net_protocol,
@@ -367,7 +367,7 @@ impl ActiveParas {
async fn assign_incoming(
&mut self,
sender: &mut impl SubsystemSender<RuntimeApiMessage>,
keystore: &SyncCryptoStorePtr,
keystore: &KeystorePtr,
new_relay_parents: impl IntoIterator<Item = Hash>,
) {
for relay_parent in new_relay_parents {
@@ -404,7 +404,6 @@ impl ActiveParas {
let para_now =
match polkadot_node_subsystem_util::signing_key_and_index(&validators, keystore)
.await
.and_then(|(_, index)| {
polkadot_node_subsystem_util::find_validator_group(&groups, index)
}) {
@@ -993,7 +992,7 @@ async fn remove_relay_parent(state: &mut State, relay_parent: Hash) -> Result<()
async fn handle_our_view_change<Context>(
ctx: &mut Context,
state: &mut State,
keystore: &SyncCryptoStorePtr,
keystore: &KeystorePtr,
view: OurView,
) -> Result<()> {
let old_view = std::mem::replace(&mut state.view, view);
@@ -1049,7 +1048,7 @@ async fn handle_our_view_change<Context>(
async fn handle_network_msg<Context>(
ctx: &mut Context,
state: &mut State,
keystore: &SyncCryptoStorePtr,
keystore: &KeystorePtr,
bridge_message: NetworkBridgeEvent<net_protocol::CollatorProtocolMessage>,
) -> Result<()> {
use NetworkBridgeEvent::*;
@@ -1084,7 +1083,7 @@ async fn handle_network_msg<Context>(
#[overseer::contextbounds(CollatorProtocol, prefix = self::overseer)]
async fn process_msg<Context>(
ctx: &mut Context,
keystore: &SyncCryptoStorePtr,
keystore: &KeystorePtr,
msg: CollatorProtocolMessage,
state: &mut State,
) {
@@ -1165,7 +1164,7 @@ async fn process_msg<Context>(
#[overseer::contextbounds(CollatorProtocol, prefix = self::overseer)]
pub(crate) async fn run<Context>(
mut ctx: Context,
keystore: SyncCryptoStorePtr,
keystore: KeystorePtr,
eviction_policy: crate::CollatorEvictionPolicy,
metrics: Metrics,
) -> std::result::Result<(), crate::error::FatalError> {
@@ -19,7 +19,7 @@ use assert_matches::assert_matches;
use futures::{executor, future, Future};
use sp_core::{crypto::Pair, Encode};
use sp_keyring::Sr25519Keyring;
use sp_keystore::{testing::KeyStore as TestKeyStore, SyncCryptoStore};
use sp_keystore::{testing::MemoryKeystore, Keystore};
use std::{iter, sync::Arc, task::Poll, time::Duration};
use polkadot_node_network_protocol::{
@@ -130,7 +130,7 @@ fn test_harness<T: Future<Output = VirtualOverseer>>(test: impl FnOnce(TestHarne
let (context, virtual_overseer) = test_helpers::make_subsystem_context(pool.clone());
let keystore = TestKeyStore::new();
let keystore = MemoryKeystore::new();
keystore
.sr25519_generate_new(
polkadot_primitives::PARACHAIN_KEY_TYPE_ID,