Update to work with async keystore – Companion PR for #7000 (#1740)

* Fix keystore types

* Use SyncCryptoStorePtr

* Borrow keystore

* Fix unused imports

* Fix polkadot service

* Fix bitfield-distribution tests

* Fix indentation

* Fix backing tests

* Fix tests

* Fix provisioner tests

* Removed SyncCryptoStorePtr

* Fix services

* Address PR feedback

* Address PR feedback - 2

* Update CryptoStorePtr imports to be from sp_keystore

* Typo

* Fix CryptoStore import

* Document the reason behind using filesystem keystore

* Remove VALIDATORS

* Fix duplicate dependency

* Mark sp-keystore as optional

* Fix availability distribution

* Fix call to sign_with

* Fix keystore usage

* Remove tokio and fix parachains Cargo config

* Typos

* Fix keystore dereferencing

* Fix CryptoStore import

* Fix provisioner

* Fix node backing

* Update services

* Cleanup dependencies

* Use sync_keystore

* Fix node service

* Fix node service - 2

* Fix node service - 3

* Rename CryptoStorePtr to SyncCryptoStorePtr

* "Update Substrate"

* Apply suggestions from code review

* Update node/core/backing/Cargo.toml

* Update primitives/src/v0.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Fix wasm build

* Update Cargo.lock

Co-authored-by: parity-processbot <>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Rakan Alhneiti
2020-10-09 12:54:03 +02:00
committed by GitHub
parent a2044bb87e
commit bd75a4ce18
23 changed files with 663 additions and 395 deletions
@@ -20,7 +20,7 @@ use polkadot_erasure_coding::{branches, obtain_chunks_v1 as obtain_chunks};
use polkadot_primitives::v1::{
AvailableData, BlockData, CandidateCommitments, CandidateDescriptor, GroupIndex,
GroupRotationInfo, HeadData, PersistedValidationData, OccupiedCore,
PoV, ScheduledCore, ValidatorPair,
PoV, ScheduledCore,
};
use polkadot_subsystem_testhelpers::{self as test_helpers};
use polkadot_node_subsystem_util::TimeoutExt;
@@ -29,7 +29,10 @@ use polkadot_node_network_protocol::ObservedRole;
use futures::{executor, future, Future};
use futures_timer::Delay;
use smallvec::smallvec;
use std::time::Duration;
use std::{sync::Arc, time::Duration};
use sc_keystore::LocalKeystore;
use sp_keystore::{SyncCryptoStorePtr, SyncCryptoStore};
use sp_application_crypto::AppKey;
macro_rules! view {
( $( $hash:expr ),* $(,)? ) => [
@@ -57,7 +60,7 @@ struct TestHarness {
}
fn test_harness<T: Future<Output = ()>>(
keystore: KeyStorePtr,
keystore: SyncCryptoStorePtr,
test: impl FnOnce(TestHarness) -> T,
) {
let _ = env_logger::builder()
@@ -144,7 +147,7 @@ struct TestState {
validator_index: Option<ValidatorIndex>,
validator_groups: (Vec<Vec<ValidatorIndex>>, GroupRotationInfo),
head_data: HashMap<ParaId, HeadData>,
keystore: KeyStorePtr,
keystore: SyncCryptoStorePtr,
relay_parent: Hash,
ancestors: Vec<Hash>,
availability_cores: Vec<CoreState>,
@@ -170,11 +173,9 @@ impl Default for TestState {
Sr25519Keyring::Dave,
];
let keystore = keystore::Store::new_in_memory();
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory());
keystore
.write()
.insert_ephemeral_from_seed::<ValidatorPair>(&validators[0].to_seed())
SyncCryptoStore::sr25519_generate_new(&*keystore, ValidatorId::ID, Some(&validators[0].to_seed()))
.expect("Insert key into keystore");
let validator_public = validator_pubkeys(&validators);