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

Commit

Permalink
Merge branch 'master' into ao-malus-dont-panic
Browse files Browse the repository at this point in the history
* master:
  bump timestamp script to v0.2 (#6954)
  Subsystem channel tweaks (#6905)
  Companion for #13683 (#6944)
  • Loading branch information
ordian committed Mar 27, 2023
2 parents 01b7a53 + 03ed777 commit 736ec15
Show file tree
Hide file tree
Showing 19 changed files with 240 additions and 259 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ include:
- scripts/ci/gitlab/pipeline/zombienet.yml
# timestamp handler
- project: parity/infrastructure/ci_cd/shared
ref: v0.1
ref: v0.2
file: /common/timestamp.yml

#### stage: .post
Expand Down
374 changes: 187 additions & 187 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion node/core/backing/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use polkadot_primitives::{
CandidateDescriptor, CollatorId, GroupRotationInfo, HeadData, PersistedValidationData,
PvfExecTimeoutKind, ScheduledCore,
};
use sp_application_crypto::AppKey;
use sp_application_crypto::AppCrypto;
use sp_keyring::Sr25519Keyring;
use sp_keystore::Keystore;
use sp_tracing as _;
Expand Down
14 changes: 7 additions & 7 deletions node/core/dispute-coordinator/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use polkadot_node_subsystem::{

use polkadot_node_subsystem_util::TimeoutExt;
use sc_keystore::LocalKeystore;
use sp_application_crypto::AppKey;
use sp_application_crypto::AppCrypto;
use sp_core::{sr25519::Pair, testing::TaskExecutor, Pair as PairT};
use sp_keyring::Sr25519Keyring;
use sp_keystore::{Keystore, KeystorePtr};
Expand Down Expand Up @@ -562,18 +562,18 @@ impl TestState {
let validator_id = self.validators[index.0 as usize].public();

let payload = ApprovalVote(candidate_hash).signing_payload(session);
let signature =
Keystore::sign_with(&*keystore, ValidatorId::ID, &validator_id.into(), &payload[..])
.ok()
.flatten()
.unwrap();
let signature = keystore
.sr25519_sign(ValidatorId::ID, &validator_id, &payload)
.ok()
.flatten()
.unwrap();

SignedDisputeStatement::new_unchecked_from_trusted_source(
DisputeStatement::Valid(ValidDisputeStatementKind::ApprovalChecking),
candidate_hash,
session,
validator_id.into(),
signature.try_into().unwrap(),
signature.into(),
)
}

Expand Down
2 changes: 1 addition & 1 deletion node/core/provisioner/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn scheduled_core(id: u32) -> ScheduledCore {
mod select_availability_bitfields {
use super::{super::*, default_bitvec, occupied_core};
use polkadot_primitives::{ScheduledCore, SigningContext, ValidatorId, ValidatorIndex};
use sp_application_crypto::AppKey;
use sp_application_crypto::AppCrypto;
use sp_keystore::{testing::MemoryKeystore, Keystore, KeystorePtr};
use std::sync::Arc;

Expand Down
2 changes: 1 addition & 1 deletion node/core/pvf-checker/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use polkadot_primitives::{
BlockNumber, Hash, Header, PvfCheckStatement, SessionIndex, ValidationCode, ValidationCodeHash,
ValidatorId,
};
use sp_application_crypto::AppKey;
use sp_application_crypto::AppCrypto;
use sp_core::testing::TaskExecutor;
use sp_keyring::Sr25519Keyring;
use sp_keystore::Keystore;
Expand Down
2 changes: 1 addition & 1 deletion node/network/bitfield-distribution/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use polkadot_node_subsystem_test_helpers::make_subsystem_context;
use polkadot_node_subsystem_util::TimeoutExt;
use polkadot_primitives::{AvailabilityBitfield, Signed, ValidatorIndex};
use rand_chacha::ChaCha12Rng;
use sp_application_crypto::AppKey;
use sp_application_crypto::AppCrypto;
use sp_authority_discovery::AuthorityPair as AuthorityDiscoveryPair;
use sp_core::Pair as PairT;
use sp_keyring::Sr25519Keyring;
Expand Down
2 changes: 1 addition & 1 deletion node/network/bridge/src/rx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ where
)
.remote_handle();

ctx.spawn("network-bridge-in-network-worker", Box::pin(task))?;
ctx.spawn_blocking("network-bridge-in-network-worker", Box::pin(task))?;
futures::pin_mut!(network_event_handler);

let orchestra_signal_handler = run_incoming_orchestra_signals(
Expand Down
2 changes: 1 addition & 1 deletion node/network/dispute-distribution/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use lazy_static::lazy_static;

use polkadot_node_network_protocol::{authority_discovery::AuthorityDiscovery, PeerId};
use sc_keystore::LocalKeystore;
use sp_application_crypto::AppKey;
use sp_application_crypto::AppCrypto;
use sp_keyring::Sr25519Keyring;
use sp_keystore::{Keystore, KeystorePtr};

Expand Down
2 changes: 1 addition & 1 deletion node/network/gossip-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use rand::{seq::SliceRandom as _, SeedableRng};
use rand_chacha::ChaCha20Rng;

use sc_network::Multiaddr;
use sp_application_crypto::{AppKey, ByteArray};
use sp_application_crypto::{AppCrypto, ByteArray};
use sp_keystore::{Keystore, KeystorePtr};

use polkadot_node_network_protocol::{
Expand Down
2 changes: 1 addition & 1 deletion node/network/statement-distribution/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use polkadot_primitives_test_helpers::{
dummy_committed_candidate_receipt, dummy_hash, AlwaysZeroRng,
};
use sc_keystore::LocalKeystore;
use sp_application_crypto::{sr25519::Pair, AppKey, Pair as TraitPair};
use sp_application_crypto::{sr25519::Pair, AppCrypto, Pair as TraitPair};
use sp_authority_discovery::AuthorityPair;
use sp_keyring::Sr25519Keyring;
use sp_keystore::{Keystore, KeystorePtr};
Expand Down
2 changes: 1 addition & 1 deletion node/overseer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ polkadot-node-primitives = { path = "../primitives" }
polkadot-node-subsystem-types = { path = "../subsystem-types" }
polkadot-node-metrics = { path = "../metrics" }
polkadot-primitives = { path = "../../primitives" }
orchestra = "0.0.4"
orchestra = "0.0.5"
gum = { package = "tracing-gum", path = "../gum" }
lru = "0.9"
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
8 changes: 4 additions & 4 deletions node/overseer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ pub struct Overseer<SupportsParachains> {
])]
availability_store: AvailabilityStore,

#[subsystem(NetworkBridgeRxMessage, sends: [
#[subsystem(blocking, NetworkBridgeRxMessage, sends: [
BitfieldDistributionMessage,
StatementDistributionMessage,
ApprovalDistributionMessage,
Expand All @@ -540,7 +540,7 @@ pub struct Overseer<SupportsParachains> {
])]
network_bridge_rx: NetworkBridgeRx,

#[subsystem(NetworkBridgeTxMessage, sends: [])]
#[subsystem(blocking, NetworkBridgeTxMessage, sends: [])]
network_bridge_tx: NetworkBridgeTx,

#[subsystem(blocking, ChainApiMessage, sends: [])]
Expand All @@ -559,7 +559,7 @@ pub struct Overseer<SupportsParachains> {
])]
collator_protocol: CollatorProtocol,

#[subsystem(ApprovalDistributionMessage, sends: [
#[subsystem(blocking, message_capacity: 64000, ApprovalDistributionMessage, sends: [
NetworkBridgeTxMessage,
ApprovalVotingMessage,
])]
Expand All @@ -584,7 +584,7 @@ pub struct Overseer<SupportsParachains> {
])]
gossip_support: GossipSupport,

#[subsystem(blocking, DisputeCoordinatorMessage, sends: [
#[subsystem(blocking, message_capacity: 32000, DisputeCoordinatorMessage, sends: [
RuntimeApiMessage,
ChainApiMessage,
DisputeDistributionMessage,
Expand Down
34 changes: 12 additions & 22 deletions node/primitives/src/disputes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use std::collections::{

use parity_scale_codec::{Decode, Encode};

use sp_application_crypto::AppKey;
use sp_keystore::{Error as KeystoreError, Keystore, KeystorePtr};
use sp_application_crypto::AppCrypto;
use sp_keystore::{Error as KeystoreError, KeystorePtr};

use super::{Statement, UncheckedSignedFullStatement};
use polkadot_primitives::{
Expand Down Expand Up @@ -221,26 +221,16 @@ impl SignedDisputeStatement {
};

let data = dispute_statement.payload_data(candidate_hash, session_index);
let signature = Keystore::sign_with(
&**keystore,
ValidatorId::ID,
&validator_public.clone().into(),
&data,
)?;

let signature = match signature {
Some(sig) =>
sig.try_into().map_err(|_| KeystoreError::KeyNotSupported(ValidatorId::ID))?,
None => return Ok(None),
};

Ok(Some(Self {
dispute_statement,
candidate_hash,
validator_public,
validator_signature: signature,
session_index,
}))
let signature = keystore
.sr25519_sign(ValidatorId::ID, validator_public.as_ref(), &data)?
.map(|sig| Self {
dispute_statement,
candidate_hash,
validator_public,
validator_signature: sig.into(),
session_index,
});
Ok(signature)
}

/// Access the underlying dispute statement
Expand Down
2 changes: 1 addition & 1 deletion node/subsystem-test-helpers/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::sync::Arc;

use sc_keystore::LocalKeystore;
use sp_application_crypto::AppKey;
use sp_application_crypto::AppCrypto;
use sp_keyring::Sr25519Keyring;
use sp_keystore::{Keystore, KeystorePtr};

Expand Down
2 changes: 1 addition & 1 deletion node/subsystem-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ polkadot-node-primitives = { path = "../primitives" }
polkadot-node-network-protocol = { path = "../network/protocol" }
polkadot-statement-table = { path = "../../statement-table" }
polkadot-node-jaeger = { path = "../jaeger" }
orchestra = "0.0.4"
orchestra = "0.0.5"
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
17 changes: 7 additions & 10 deletions node/subsystem-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ use polkadot_primitives::{
ValidatorSignature,
};
pub use rand;
use sp_application_crypto::AppKey;
use sp_application_crypto::AppCrypto;
use sp_core::ByteArray;
use sp_keystore::{Error as KeystoreError, Keystore, KeystorePtr};
use sp_keystore::{Error as KeystoreError, KeystorePtr};
use std::time::Duration;
use thiserror::Error;

Expand Down Expand Up @@ -276,7 +276,7 @@ pub fn signing_key_and_index(
keystore: &KeystorePtr,
) -> Option<(ValidatorId, ValidatorIndex)> {
for (i, v) in validators.iter().enumerate() {
if Keystore::has_keys(&**keystore, &[(v.to_raw_vec(), ValidatorId::ID)]) {
if keystore.has_keys(&[(v.to_raw_vec(), ValidatorId::ID)]) {
return Some((v.clone(), ValidatorIndex(i as _)))
}
}
Expand All @@ -292,13 +292,10 @@ pub fn sign(
key: &ValidatorId,
data: &[u8],
) -> Result<Option<ValidatorSignature>, KeystoreError> {
let signature = Keystore::sign_with(&**keystore, ValidatorId::ID, &key.into(), &data)?;

match signature {
Some(sig) =>
Ok(Some(sig.try_into().map_err(|_| KeystoreError::KeyNotSupported(ValidatorId::ID))?)),
None => Ok(None),
}
let signature = keystore
.sr25519_sign(ValidatorId::ID, key.as_ref(), data)?
.map(|sig| sig.into());
Ok(signature)
}

/// Find the validator group the given validator index belongs to.
Expand Down
2 changes: 1 addition & 1 deletion node/subsystem-util/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::num::NonZeroUsize;
use lru::LruCache;

use parity_scale_codec::Encode;
use sp_application_crypto::AppKey;
use sp_application_crypto::AppCrypto;
use sp_core::crypto::ByteArray;
use sp_keystore::{Keystore, KeystorePtr};

Expand Down
26 changes: 10 additions & 16 deletions primitives/src/v4/signed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;

#[cfg(feature = "std")]
use application_crypto::AppKey;
use application_crypto::AppCrypto;
#[cfg(feature = "std")]
use sp_keystore::{Error as KeystoreError, Keystore, KeystorePtr};
use sp_keystore::{Error as KeystoreError, KeystorePtr};
use sp_std::prelude::Vec;

use primitives::RuntimeDebug;
Expand Down Expand Up @@ -252,20 +252,14 @@ impl<Payload: EncodeAs<RealPayload>, RealPayload: Encode> UncheckedSigned<Payloa
key: &ValidatorId,
) -> Result<Option<Self>, KeystoreError> {
let data = Self::payload_data(&payload, context);
let signature = Keystore::sign_with(&**keystore, ValidatorId::ID, &key.into(), &data)?;

let signature = match signature {
Some(sig) =>
sig.try_into().map_err(|_| KeystoreError::KeyNotSupported(ValidatorId::ID))?,
None => return Ok(None),
};

Ok(Some(Self {
payload,
validator_index,
signature,
real_payload: std::marker::PhantomData,
}))
let signature =
keystore.sr25519_sign(ValidatorId::ID, key.as_ref(), &data)?.map(|sig| Self {
payload,
validator_index,
signature: sig.into(),
real_payload: std::marker::PhantomData,
});
Ok(signature)
}

/// Validate the payload given the context and public key
Expand Down

0 comments on commit 736ec15

Please sign in to comment.