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

Commit

Permalink
fix errors caused by improper rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
coriolinus committed Jul 10, 2020
1 parent 3a47236 commit 38110d5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 62 deletions.
29 changes: 6 additions & 23 deletions node/core/backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ use futures::{

use keystore::KeyStorePtr;
use polkadot_primitives::v1::{
CommittedCandidateReceipt, BackedCandidate, Id as ParaId, ValidatorPair, ValidatorId,
CommittedCandidateReceipt, BackedCandidate, Id as ParaId, ValidatorId,
ValidatorIndex, SigningContext, PoV, OmittedValidationData,
CandidateDescriptor, AvailableData, ErasureChunk, ValidatorSignature, Hash, CandidateReceipt,
CandidateCommitments,
};
use polkadot_node_primitives::{
FromTableMisbehavior, Statement, SignedFullStatement, MisbehaviorReport, ValidationResult,
FromTableMisbehavior, Statement, SignedFullStatement, MisbehaviorReport,
ValidationOutputs, ValidationResult,
};
use polkadot_subsystem::{
messages::{
Expand All @@ -46,19 +47,12 @@ use polkadot_subsystem::{
},
util::{
self,
request_head_data,
request_signing_context,
request_validator_groups,
request_validators,
Validator,
},
};
use polkadot_subsystem::messages::{
AllMessages, CandidateBackingMessage, CandidateSelectionMessage,
RuntimeApiMessage, CandidateValidationMessage, ValidationFailed,
StatementDistributionMessage, NewBackedCandidate, ProvisionerMessage, ProvisionableData,
PoVDistributionMessage, AvailabilityStoreMessage,
};
use statement_table::{
generic::AttestedCandidate as TableAttestedCandidate,
Context as TableContextTrait,
Expand Down Expand Up @@ -95,9 +89,6 @@ pub struct CandidateBackingJob {
rx_to: mpsc::Receiver<ToJob>,
/// Outbound message channel sending part.
tx_from: mpsc::Sender<FromJob>,

/// `HeadData`s of the parachains that this validator is assigned to.
head_data: HeadData,
/// The `ParaId`s assigned to this validator.
assignment: ParaId,
/// We issued `Valid` or `Invalid` statements on about these candidates.
Expand All @@ -106,7 +97,6 @@ pub struct CandidateBackingJob {
seconded: Option<Hash>,
/// We have already reported misbehaviors for these validators.
reported_misbehavior_for: HashSet<ValidatorIndex>,

table: Table<TableContext>,
table_context: TableContext,
}
Expand Down Expand Up @@ -148,7 +138,7 @@ impl TableContextTrait for TableContext {
}

/// A message type that is sent from `CandidateBackingSubsystem` to `CandidateBackingJob`.
enum ToJob {
pub enum ToJob {
/// A `CandidateBackingMessage`.
CandidateBacking(CandidateBackingMessage),
/// Stop working.
Expand Down Expand Up @@ -709,8 +699,6 @@ impl util::JobTrait for CandidateBackingJob {
}
}

let head_data = request_head_data(parent, &mut tx_from, assignment).await?.await?;

let table_context = TableContext {
groups,
validators,
Expand All @@ -722,9 +710,8 @@ impl util::JobTrait for CandidateBackingJob {
parent,
rx_to,
tx_from,
head_data,
assignment,
issued_validity: HashSet::new(),
issued_statements: HashSet::new(),
seconded: None,
reported_misbehavior_for: HashSet::new(),
table: Table::default(),
Expand All @@ -750,7 +737,7 @@ mod tests {
future, Future,
};
use polkadot_primitives::v1::{
AssignmentKind, BlockData, CandidateCommitments, CollatorId, CoreAssignment, CoreIndex,
AssignmentKind, BlockData, CandidateCommitments, CollatorId, CoreAssignment, CoreIndex,
LocalValidationData, GlobalValidationSchedule, GroupIndex, HeadData,
ValidatorPair, ValidityAttestation,
};
Expand Down Expand Up @@ -1382,7 +1369,6 @@ mod tests {
AllMessages::CandidateValidation(
CandidateValidationMessage::ValidateFromChainState(
c,
head_data,
pov,
tx,
)
Expand All @@ -1406,14 +1392,11 @@ mod tests {

virtual_overseer.send(FromOverseer::Communication{ msg: second }).await;

let expected_head_data = test_state.head_data.get(&test_state.chain_ids[0]).unwrap();

assert_matches!(
virtual_overseer.recv().await,
AllMessages::CandidateValidation(
CandidateValidationMessage::ValidateFromChainState(
c,
head_data,
pov,
tx,
)
Expand Down
5 changes: 3 additions & 2 deletions node/subsystem/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub enum CandidateBackingMessage {
impl CandidateBackingMessage {
pub fn hash(&self) -> Option<Hash> {
match self {
Self::RegisterBackingWatcher(hash, _) => Some(*hash),
Self::GetBackedCandidates(hash, _) => Some(*hash),
Self::Second(hash, _, _) => Some(*hash),
Self::Statement(hash, _) => Some(*hash),
}
Expand Down Expand Up @@ -124,7 +124,8 @@ pub enum CandidateValidationMessage {
impl CandidateValidationMessage {
pub fn hash(&self) -> Option<Hash> {
match self {
Self::Validate(hash, _, _, _, _) => Some(*hash),
Self::ValidateFromChainState(CandidateDescriptor{ relay_parent, ..}, _, _) => Some(*relay_parent),
Self::ValidateFromExhaustive(_, _, CandidateDescriptor{ relay_parent, ..}, _, _) => Some(*relay_parent),
}
}
}
Expand Down
40 changes: 3 additions & 37 deletions node/subsystem/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ use futures::{
use futures_timer::Delay;
use keystore::KeyStorePtr;
use parity_scale_codec::Encode;
use polkadot_primitives::{
parachain::{
EncodeAs, GlobalValidationSchedule, HeadData, Id as ParaId, LocalValidationData, Signed,
SigningContext, ValidatorId, ValidatorIndex, ValidatorPair,
},
Hash,
use polkadot_primitives::v1::{
EncodeAs, Hash, HeadData, Id as ParaId, Signed, SigningContext,
ValidatorId, ValidatorIndex, ValidatorPair,
};
use sp_core::Pair;
use std::{
Expand Down Expand Up @@ -94,37 +91,6 @@ where
Ok(rx)
}

/// Request a `GlobalValidationSchedule` from `RuntimeApi`.
pub async fn request_global_validation_schedule<SenderMessage>(
parent: Hash,
s: &mut mpsc::Sender<SenderMessage>,
) -> Result<oneshot::Receiver<GlobalValidationSchedule>, Error>
where
SenderMessage: TryFrom<AllMessages>,
<SenderMessage as TryFrom<AllMessages>>::Error: std::fmt::Debug,
{
request_from_runtime(parent, s, |tx| {
RuntimeApiRequest::GlobalValidationSchedule(tx)
})
.await
}

/// Request a `LocalValidationData` from `RuntimeApi`.
pub async fn request_local_validation_data<SenderMessage>(
parent: Hash,
para_id: ParaId,
s: &mut mpsc::Sender<SenderMessage>,
) -> Result<oneshot::Receiver<Option<LocalValidationData>>, Error>
where
SenderMessage: TryFrom<AllMessages>,
<SenderMessage as TryFrom<AllMessages>>::Error: std::fmt::Debug,
{
request_from_runtime(parent, s, |tx| {
RuntimeApiRequest::LocalValidationData(para_id, tx)
})
.await
}

/// Request a validator set from the `RuntimeApi`.
pub async fn request_validators<SenderMessage>(
parent: Hash,
Expand Down

0 comments on commit 38110d5

Please sign in to comment.