mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +00:00
* 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:
@@ -25,12 +25,8 @@
|
||||
use codec::{Decode, Encode};
|
||||
use futures::{channel::oneshot, FutureExt};
|
||||
|
||||
use keystore::KeyStorePtr;
|
||||
use sp_core::{
|
||||
crypto::Public,
|
||||
traits::BareCryptoStore,
|
||||
};
|
||||
use sc_keystore as keystore;
|
||||
use sp_core::crypto::Public;
|
||||
use sp_keystore::{CryptoStore, SyncCryptoStorePtr};
|
||||
|
||||
use log::{trace, warn};
|
||||
use polkadot_erasure_coding::branch_hash;
|
||||
@@ -293,7 +289,7 @@ impl ProtocolState {
|
||||
/// which depends on the message type received.
|
||||
async fn handle_network_msg<Context>(
|
||||
ctx: &mut Context,
|
||||
keystore: KeyStorePtr,
|
||||
keystore: &SyncCryptoStorePtr,
|
||||
state: &mut ProtocolState,
|
||||
metrics: &Metrics,
|
||||
bridge_message: NetworkBridgeEvent<protocol_v1::AvailabilityDistributionMessage>,
|
||||
@@ -332,7 +328,7 @@ where
|
||||
/// Handle the changes necessary when our view changes.
|
||||
async fn handle_our_view_change<Context>(
|
||||
ctx: &mut Context,
|
||||
keystore: KeyStorePtr,
|
||||
keystore: &SyncCryptoStorePtr,
|
||||
state: &mut ProtocolState,
|
||||
view: View,
|
||||
metrics: &Metrics,
|
||||
@@ -353,7 +349,7 @@ where
|
||||
let validator_index = obtain_our_validator_index(
|
||||
&validators,
|
||||
keystore.clone(),
|
||||
);
|
||||
).await;
|
||||
state.add_relay_parent(ctx, added, validators, validator_index).await?;
|
||||
}
|
||||
|
||||
@@ -579,18 +575,16 @@ where
|
||||
/// Obtain the first key which has a signing key.
|
||||
/// Returns the index within the validator set as `ValidatorIndex`, if there exists one,
|
||||
/// otherwise, `None` is returned.
|
||||
fn obtain_our_validator_index(
|
||||
async fn obtain_our_validator_index(
|
||||
validators: &[ValidatorId],
|
||||
keystore: KeyStorePtr,
|
||||
keystore: SyncCryptoStorePtr,
|
||||
) -> Option<ValidatorIndex> {
|
||||
let keystore = keystore.read();
|
||||
validators.iter().enumerate().find_map(|(idx, validator)| {
|
||||
if keystore.has_keys(&[(validator.to_raw_vec(), PARACHAIN_KEY_TYPE_ID)]) {
|
||||
Some(idx as ValidatorIndex)
|
||||
} else {
|
||||
None
|
||||
for (idx, validator) in validators.iter().enumerate() {
|
||||
if CryptoStore::has_keys(&*keystore, &[(validator.to_raw_vec(), PARACHAIN_KEY_TYPE_ID)]).await {
|
||||
return Some(idx as ValidatorIndex)
|
||||
}
|
||||
})
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Handle an incoming message from a peer.
|
||||
@@ -712,7 +706,7 @@ where
|
||||
/// The bitfield distribution subsystem.
|
||||
pub struct AvailabilityDistributionSubsystem {
|
||||
/// Pointer to a keystore, which is required for determining this nodes validator index.
|
||||
keystore: KeyStorePtr,
|
||||
keystore: SyncCryptoStorePtr,
|
||||
/// Prometheus metrics.
|
||||
metrics: Metrics,
|
||||
}
|
||||
@@ -722,7 +716,7 @@ impl AvailabilityDistributionSubsystem {
|
||||
const K: usize = 3;
|
||||
|
||||
/// Create a new instance of the availability distribution.
|
||||
pub fn new(keystore: KeyStorePtr, metrics: Metrics) -> Self {
|
||||
pub fn new(keystore: SyncCryptoStorePtr, metrics: Metrics) -> Self {
|
||||
Self { keystore, metrics }
|
||||
}
|
||||
|
||||
@@ -741,7 +735,7 @@ impl AvailabilityDistributionSubsystem {
|
||||
} => {
|
||||
if let Err(e) = handle_network_msg(
|
||||
&mut ctx,
|
||||
self.keystore.clone(),
|
||||
&self.keystore.clone(),
|
||||
&mut state,
|
||||
&self.metrics,
|
||||
event,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user