mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
* 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:
@@ -57,7 +57,7 @@ use futures::{
|
||||
prelude::*,
|
||||
};
|
||||
use indexmap::{map::Entry as IEntry, IndexMap};
|
||||
use sp_keystore::SyncCryptoStorePtr;
|
||||
use sp_keystore::KeystorePtr;
|
||||
use util::runtime::RuntimeInfo;
|
||||
|
||||
use std::collections::{hash_map::Entry, HashMap, HashSet, VecDeque};
|
||||
@@ -119,7 +119,7 @@ const MAX_LARGE_STATEMENTS_PER_SENDER: usize = 20;
|
||||
/// The statement distribution subsystem.
|
||||
pub struct StatementDistributionSubsystem<R> {
|
||||
/// Pointer to a keystore, which is required for determining this node's validator index.
|
||||
keystore: SyncCryptoStorePtr,
|
||||
keystore: KeystorePtr,
|
||||
/// Receiver for incoming large statement requests.
|
||||
req_receiver: Option<IncomingRequestReceiver<request_v1::StatementFetchingRequest>>,
|
||||
/// Prometheus metrics
|
||||
@@ -1745,7 +1745,7 @@ async fn handle_network_update<Context, R>(
|
||||
impl<R: rand::Rng> StatementDistributionSubsystem<R> {
|
||||
/// Create a new Statement Distribution Subsystem
|
||||
pub fn new(
|
||||
keystore: SyncCryptoStorePtr,
|
||||
keystore: KeystorePtr,
|
||||
req_receiver: IncomingRequestReceiver<request_v1::StatementFetchingRequest>,
|
||||
metrics: Metrics,
|
||||
rng: R,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use super::{metrics::Metrics, *};
|
||||
use assert_matches::assert_matches;
|
||||
use futures::executor::{self, block_on};
|
||||
use futures::executor;
|
||||
use futures_timer::Delay;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use polkadot_node_network_protocol::{
|
||||
@@ -45,7 +45,7 @@ use sc_keystore::LocalKeystore;
|
||||
use sp_application_crypto::{sr25519::Pair, AppKey, Pair as TraitPair};
|
||||
use sp_authority_discovery::AuthorityPair;
|
||||
use sp_keyring::Sr25519Keyring;
|
||||
use sp_keystore::{CryptoStore, SyncCryptoStore, SyncCryptoStorePtr};
|
||||
use sp_keystore::{Keystore, KeystorePtr};
|
||||
use std::{iter::FromIterator as _, sync::Arc, time::Duration};
|
||||
|
||||
// Some deterministic genesis hash for protocol names
|
||||
@@ -90,14 +90,14 @@ fn active_head_accepts_only_2_seconded_per_validator() {
|
||||
PerLeafSpan::new(Arc::new(jaeger::Span::Disabled), "test"),
|
||||
);
|
||||
|
||||
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = SyncCryptoStore::sr25519_generate_new(
|
||||
let keystore: KeystorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = Keystore::sr25519_generate_new(
|
||||
&*keystore,
|
||||
ValidatorId::ID,
|
||||
Some(&Sr25519Keyring::Alice.to_seed()),
|
||||
)
|
||||
.unwrap();
|
||||
let bob_public = SyncCryptoStore::sr25519_generate_new(
|
||||
let bob_public = Keystore::sr25519_generate_new(
|
||||
&*keystore,
|
||||
ValidatorId::ID,
|
||||
Some(&Sr25519Keyring::Bob.to_seed()),
|
||||
@@ -105,13 +105,13 @@ fn active_head_accepts_only_2_seconded_per_validator() {
|
||||
.unwrap();
|
||||
|
||||
// note A
|
||||
let a_seconded_val_0 = block_on(SignedFullStatement::sign(
|
||||
let a_seconded_val_0 = SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Seconded(candidate_a.clone()),
|
||||
&signing_context,
|
||||
ValidatorIndex(0),
|
||||
&alice_public.into(),
|
||||
))
|
||||
)
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed");
|
||||
@@ -132,13 +132,13 @@ fn active_head_accepts_only_2_seconded_per_validator() {
|
||||
assert_matches!(noted, NotedStatement::UsefulButKnown);
|
||||
|
||||
// note B
|
||||
let statement = block_on(SignedFullStatement::sign(
|
||||
let statement = SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Seconded(candidate_b.clone()),
|
||||
&signing_context,
|
||||
ValidatorIndex(0),
|
||||
&alice_public.into(),
|
||||
))
|
||||
)
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed");
|
||||
@@ -149,13 +149,13 @@ fn active_head_accepts_only_2_seconded_per_validator() {
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
// note C (beyond 2 - ignored)
|
||||
let statement = block_on(SignedFullStatement::sign(
|
||||
let statement = SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Seconded(candidate_c.clone()),
|
||||
&signing_context,
|
||||
ValidatorIndex(0),
|
||||
&alice_public.into(),
|
||||
))
|
||||
)
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed");
|
||||
@@ -167,13 +167,13 @@ fn active_head_accepts_only_2_seconded_per_validator() {
|
||||
assert_matches!(noted, NotedStatement::NotUseful);
|
||||
|
||||
// note B (new validator)
|
||||
let statement = block_on(SignedFullStatement::sign(
|
||||
let statement = SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Seconded(candidate_b.clone()),
|
||||
&signing_context,
|
||||
ValidatorIndex(1),
|
||||
&bob_public.into(),
|
||||
))
|
||||
)
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed");
|
||||
@@ -184,13 +184,13 @@ fn active_head_accepts_only_2_seconded_per_validator() {
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
// note C (new validator)
|
||||
let statement = block_on(SignedFullStatement::sign(
|
||||
let statement = SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Seconded(candidate_c.clone()),
|
||||
&signing_context,
|
||||
ValidatorIndex(1),
|
||||
&bob_public.into(),
|
||||
))
|
||||
)
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed");
|
||||
@@ -408,21 +408,21 @@ fn peer_view_update_sends_messages() {
|
||||
let session_index = 1;
|
||||
let signing_context = SigningContext { parent_hash: hash_c, session_index };
|
||||
|
||||
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let keystore: KeystorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
|
||||
let alice_public = SyncCryptoStore::sr25519_generate_new(
|
||||
let alice_public = Keystore::sr25519_generate_new(
|
||||
&*keystore,
|
||||
ValidatorId::ID,
|
||||
Some(&Sr25519Keyring::Alice.to_seed()),
|
||||
)
|
||||
.unwrap();
|
||||
let bob_public = SyncCryptoStore::sr25519_generate_new(
|
||||
let bob_public = Keystore::sr25519_generate_new(
|
||||
&*keystore,
|
||||
ValidatorId::ID,
|
||||
Some(&Sr25519Keyring::Bob.to_seed()),
|
||||
)
|
||||
.unwrap();
|
||||
let charlie_public = SyncCryptoStore::sr25519_generate_new(
|
||||
let charlie_public = Keystore::sr25519_generate_new(
|
||||
&*keystore,
|
||||
ValidatorId::ID,
|
||||
Some(&Sr25519Keyring::Charlie.to_seed()),
|
||||
@@ -436,13 +436,13 @@ fn peer_view_update_sends_messages() {
|
||||
PerLeafSpan::new(Arc::new(jaeger::Span::Disabled), "test"),
|
||||
);
|
||||
|
||||
let statement = block_on(SignedFullStatement::sign(
|
||||
let statement = SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Seconded(candidate.clone()),
|
||||
&signing_context,
|
||||
ValidatorIndex(0),
|
||||
&alice_public.into(),
|
||||
))
|
||||
)
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed");
|
||||
@@ -453,13 +453,13 @@ fn peer_view_update_sends_messages() {
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
let statement = block_on(SignedFullStatement::sign(
|
||||
let statement = SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Valid(candidate_hash),
|
||||
&signing_context,
|
||||
ValidatorIndex(1),
|
||||
&bob_public.into(),
|
||||
))
|
||||
)
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed");
|
||||
@@ -470,13 +470,13 @@ fn peer_view_update_sends_messages() {
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
let statement = block_on(SignedFullStatement::sign(
|
||||
let statement = SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Valid(candidate_hash),
|
||||
&signing_context,
|
||||
ValidatorIndex(2),
|
||||
&charlie_public.into(),
|
||||
))
|
||||
)
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed");
|
||||
@@ -614,13 +614,12 @@ fn circulated_statement_goes_to_all_peers_with_view() {
|
||||
executor::block_on(async move {
|
||||
let signing_context = SigningContext { parent_hash: hash_b, session_index };
|
||||
|
||||
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = CryptoStore::sr25519_generate_new(
|
||||
let keystore: KeystorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = Keystore::sr25519_generate_new(
|
||||
&*keystore,
|
||||
ValidatorId::ID,
|
||||
Some(&Sr25519Keyring::Alice.to_seed()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let statement = SignedFullStatement::sign(
|
||||
@@ -630,7 +629,6 @@ fn circulated_statement_goes_to_all_peers_with_view() {
|
||||
ValidatorIndex(0),
|
||||
&alice_public.into(),
|
||||
)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed");
|
||||
@@ -827,13 +825,12 @@ fn receiving_from_one_sends_to_another_and_to_candidate_backing() {
|
||||
let statement = {
|
||||
let signing_context = SigningContext { parent_hash: hash_a, session_index };
|
||||
|
||||
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = CryptoStore::sr25519_generate_new(
|
||||
let keystore: KeystorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = Keystore::sr25519_generate_new(
|
||||
&*keystore,
|
||||
ValidatorId::ID,
|
||||
Some(&Sr25519Keyring::Alice.to_seed()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
SignedFullStatement::sign(
|
||||
@@ -843,7 +840,6 @@ fn receiving_from_one_sends_to_another_and_to_candidate_backing() {
|
||||
ValidatorIndex(0),
|
||||
&alice_public.into(),
|
||||
)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed")
|
||||
@@ -1071,13 +1067,12 @@ fn receiving_large_statement_from_one_sends_to_another_and_to_candidate_backing(
|
||||
let statement = {
|
||||
let signing_context = SigningContext { parent_hash: hash_a, session_index };
|
||||
|
||||
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = CryptoStore::sr25519_generate_new(
|
||||
let keystore: KeystorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = Keystore::sr25519_generate_new(
|
||||
&*keystore,
|
||||
ValidatorId::ID,
|
||||
Some(&Sr25519Keyring::Alice.to_seed()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
SignedFullStatement::sign(
|
||||
@@ -1087,7 +1082,6 @@ fn receiving_large_statement_from_one_sends_to_another_and_to_candidate_backing(
|
||||
ValidatorIndex(0),
|
||||
&alice_public.into(),
|
||||
)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed")
|
||||
@@ -1627,13 +1621,12 @@ fn share_prioritizes_backing_group() {
|
||||
let statement = {
|
||||
let signing_context = SigningContext { parent_hash: hash_a, session_index };
|
||||
|
||||
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let ferdie_public = CryptoStore::sr25519_generate_new(
|
||||
let keystore: KeystorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let ferdie_public = Keystore::sr25519_generate_new(
|
||||
&*keystore,
|
||||
ValidatorId::ID,
|
||||
Some(&Sr25519Keyring::Ferdie.to_seed()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
SignedFullStatement::sign(
|
||||
@@ -1643,7 +1636,6 @@ fn share_prioritizes_backing_group() {
|
||||
ValidatorIndex(4),
|
||||
&ferdie_public.into(),
|
||||
)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed")
|
||||
@@ -1819,13 +1811,12 @@ fn peer_cant_flood_with_large_statements() {
|
||||
let statement = {
|
||||
let signing_context = SigningContext { parent_hash: hash_a, session_index };
|
||||
|
||||
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = CryptoStore::sr25519_generate_new(
|
||||
let keystore: KeystorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = Keystore::sr25519_generate_new(
|
||||
&*keystore,
|
||||
ValidatorId::ID,
|
||||
Some(&Sr25519Keyring::Alice.to_seed()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
SignedFullStatement::sign(
|
||||
@@ -1835,7 +1826,6 @@ fn peer_cant_flood_with_large_statements() {
|
||||
ValidatorIndex(0),
|
||||
&alice_public.into(),
|
||||
)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed")
|
||||
@@ -2108,13 +2098,12 @@ fn handle_multiple_seconded_statements() {
|
||||
let statement = {
|
||||
let signing_context = SigningContext { parent_hash: relay_parent_hash, session_index };
|
||||
|
||||
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = CryptoStore::sr25519_generate_new(
|
||||
let keystore: KeystorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = Keystore::sr25519_generate_new(
|
||||
&*keystore,
|
||||
ValidatorId::ID,
|
||||
Some(&Sr25519Keyring::Alice.to_seed()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
SignedFullStatement::sign(
|
||||
@@ -2124,7 +2113,6 @@ fn handle_multiple_seconded_statements() {
|
||||
ValidatorIndex(0),
|
||||
&alice_public.into(),
|
||||
)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed")
|
||||
@@ -2211,13 +2199,12 @@ fn handle_multiple_seconded_statements() {
|
||||
let statement = {
|
||||
let signing_context = SigningContext { parent_hash: relay_parent_hash, session_index };
|
||||
|
||||
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = CryptoStore::sr25519_generate_new(
|
||||
let keystore: KeystorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = Keystore::sr25519_generate_new(
|
||||
&*keystore,
|
||||
ValidatorId::ID,
|
||||
Some(&Sr25519Keyring::Alice.to_seed()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
SignedFullStatement::sign(
|
||||
@@ -2227,7 +2214,6 @@ fn handle_multiple_seconded_statements() {
|
||||
ValidatorIndex(0),
|
||||
&alice_public.into(),
|
||||
)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("should be signed")
|
||||
|
||||
Reference in New Issue
Block a user