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-past-session-slashing-client
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)
  inherent disputes: remove per block initializer and disputes timeout event (#6937)
  • Loading branch information
ordian committed Mar 28, 2023
2 parents e9dc42b + 03ed777 commit 176c7b2
Show file tree
Hide file tree
Showing 31 changed files with 169 additions and 338 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
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 @@ -568,18 +568,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 @@ -279,7 +279,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 @@ -295,13 +295,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
1 change: 0 additions & 1 deletion roadmap/implementers-guide/src/disputes-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ stateDiagram-v2
[*] --> WaitForDisputeVote: backing Vote received
WaitForBackingVote --> Open: negative Vote received
WaitForDisputeVote --> Open: backing Vote received
Open --> Concluded: Timeout without supermajority
Open --> Concluded: Incoming Vote via Gossip
Open --> Open: No ⅔ supermajority
Open --> [*]
Expand Down
2 changes: 1 addition & 1 deletion roadmap/implementers-guide/src/protocol-disputes.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ Validators are rewarded for providing statements to the chain as well as for par

## Dispute Conclusion

Disputes, roughly, are over when one side reaches a ⅔ supermajority. They may also conclude after a timeout, without either side witnessing supermajority, which will only happen if the majority of validators are unable to vote for some reason. Furthermore, disputes on-chain will stay open for some fixed amount of time even after concluding, to accept new votes.
Disputes, roughly, are over when one side reaches a ⅔ supermajority. They may also never conclude without either side witnessing supermajority, which will only happen if the majority of validators are unable to vote for some reason. Furthermore, disputes on-chain will stay open for some fixed amount of time even after concluding, to accept new votes.

Late votes, after the dispute already reached a ⅔ supermajority, must be rewarded (albeit a smaller amount) as well.
2 changes: 1 addition & 1 deletion roadmap/implementers-guide/src/runtime/disputes.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Frozen: Option<BlockNumber>,

## Block Initialization

1. Iterate through all disputes. If any have not concluded and started more than `config.dispute_conclusion_by_timeout_period` blocks ago, set them to `Concluded` and mildly punish all validators associated, as they have failed to distribute available data.
This is currently a `no op`.

## Routines

Expand Down
2 changes: 0 additions & 2 deletions roadmap/implementers-guide/src/types/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ struct HostConfiguration {
pub dispute_post_conclusion_acceptance_period: BlockNumber,
/// The maximum number of dispute spam slots
pub dispute_max_spam_slots: u32,
/// How long it takes for a dispute to conclude by time-out, if no supermajority is reached.
pub dispute_conclusion_by_time_out_period: BlockNumber,
/// The amount of consensus slots that must pass between submitting an assignment and
/// submitting an approval vote before a validator is considered a no-show.
/// Must be at least 1.
Expand Down
1 change: 1 addition & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,7 @@ pub type Migrations = (
Runtime,
NominationPoolsMigrationV4OldPallet,
>,
parachains_configuration::migration::v5::MigrateToV5<Runtime>,
);

/// Unchecked extrinsic type as expected by this runtime.
Expand Down
19 changes: 0 additions & 19 deletions runtime/parachains/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ pub struct HostConfiguration<BlockNumber> {
pub dispute_period: SessionIndex,
/// How long after dispute conclusion to accept statements.
pub dispute_post_conclusion_acceptance_period: BlockNumber,
/// How long it takes for a dispute to conclude by time-out, if no supermajority is reached.
pub dispute_conclusion_by_time_out_period: BlockNumber,
/// The amount of consensus slots that must pass between submitting an assignment and
/// submitting an approval vote before a validator is considered a no-show.
///
Expand Down Expand Up @@ -262,7 +260,6 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
max_validators: None,
dispute_period: 6,
dispute_post_conclusion_acceptance_period: 100.into(),
dispute_conclusion_by_time_out_period: 200.into(),
n_delay_tranches: Default::default(),
zeroth_delay_tranche_width: Default::default(),
needed_approvals: Default::default(),
Expand Down Expand Up @@ -765,22 +762,6 @@ pub mod pallet {
})
}

/// Set the dispute conclusion by time out period.
#[pallet::call_index(17)]
#[pallet::weight((
T::WeightInfo::set_config_with_block_number(),
DispatchClass::Operational,
))]
pub fn set_dispute_conclusion_by_time_out_period(
origin: OriginFor<T>,
new: T::BlockNumber,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
config.dispute_conclusion_by_time_out_period = new;
})
}

/// Set the no show slots, in number of number of consensus slots.
/// Must be at least 1.
#[pallet::call_index(18)]
Expand Down
Loading

0 comments on commit 176c7b2

Please sign in to comment.