diff --git a/polkadot/node/network/collator-protocol/src/collator_side/mod.rs b/polkadot/node/network/collator-protocol/src/collator_side/mod.rs index 5713ad647c..5f0425d8cd 100644 --- a/polkadot/node/network/collator-protocol/src/collator_side/mod.rs +++ b/polkadot/node/network/collator-protocol/src/collator_side/mod.rs @@ -32,7 +32,7 @@ use polkadot_node_network_protocol::{ }, v1 as protocol_v1, OurView, PeerId, UnifiedReputationChange as Rep, View, }; -use polkadot_node_primitives::{PoV, SignedFullStatement, Statement}; +use polkadot_node_primitives::{CollationSecondedSignal, PoV, Statement}; use polkadot_node_subsystem_util::{ metrics::{self, prometheus}, runtime::{get_availability_cores, get_group_rotation_info, RuntimeInfo}, @@ -266,7 +266,7 @@ struct State { collations: HashMap, /// The result senders per collation. - collation_result_senders: HashMap>, + collation_result_senders: HashMap>, /// Our validator groups per active leaf. our_validators_groups: HashMap, @@ -336,7 +336,7 @@ async fn distribute_collation( id: ParaId, receipt: CandidateReceipt, pov: PoV, - result_sender: Option>, + result_sender: Option>, ) -> Result<()> where Context: SubsystemContext, @@ -866,7 +866,7 @@ where ?origin, "received a `CollationSeconded`", ); - let _ = sender.send(statement); + let _ = sender.send(CollationSecondedSignal { statement, relay_parent }); } } }, diff --git a/polkadot/node/primitives/src/lib.rs b/polkadot/node/primitives/src/lib.rs index 1ec3291f80..19ee14f05a 100644 --- a/polkadot/node/primitives/src/lib.rs +++ b/polkadot/node/primitives/src/lib.rs @@ -215,6 +215,17 @@ pub struct Collation { pub hrmp_watermark: BlockNumber, } +/// Signal that is being returned back when a collation was seconded by a validator. +#[derive(Debug)] +pub struct CollationSecondedSignal { + /// The hash of the relay chain block that was used as context to sign [`Self::statement`]. + pub relay_parent: Hash, + /// The statement about seconding the collation. + /// + /// Anything else than [`Statement::Seconded`](Statement::Seconded) is forbidden here. + pub statement: SignedFullStatement, +} + /// Result of the [`CollatorFn`] invocation. pub struct CollationResult { /// The collation that was build. @@ -224,14 +235,14 @@ pub struct CollationResult { /// There is no guarantee that this sender is informed ever about any result, it is completely okay to just drop it. /// However, if it is called, it should be called with the signed statement of a parachain validator seconding the /// collation. - pub result_sender: Option>, + pub result_sender: Option>, } impl CollationResult { /// Convert into the inner values. pub fn into_inner( self, - ) -> (Collation, Option>) { + ) -> (Collation, Option>) { (self.collation, self.result_sender) } } diff --git a/polkadot/node/subsystem-types/src/messages.rs b/polkadot/node/subsystem-types/src/messages.rs index b6cf9d0a0d..7ffc84b3a9 100644 --- a/polkadot/node/subsystem-types/src/messages.rs +++ b/polkadot/node/subsystem-types/src/messages.rs @@ -35,8 +35,8 @@ use polkadot_node_network_protocol::{ use polkadot_node_primitives::{ approval::{BlockApprovalMeta, IndirectAssignmentCert, IndirectSignedApprovalVote}, AvailableData, BabeEpoch, BlockWeight, CandidateVotes, CollationGenerationConfig, - DisputeMessage, ErasureChunk, PoV, SignedDisputeStatement, SignedFullStatement, - ValidationResult, + CollationSecondedSignal, DisputeMessage, ErasureChunk, PoV, SignedDisputeStatement, + SignedFullStatement, ValidationResult, }; use polkadot_primitives::v1::{ AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateDescriptor, CandidateEvent, @@ -158,7 +158,7 @@ pub enum CollatorProtocolMessage { /// /// The result sender should be informed when at least one parachain validator seconded the collation. It is also /// completely okay to just drop the sender. - DistributeCollation(CandidateReceipt, PoV, Option>), + DistributeCollation(CandidateReceipt, PoV, Option>), /// Report a collator as having provided an invalid collation. This should lead to disconnect /// and blacklist of the collator. ReportCollator(CollatorId), diff --git a/polkadot/parachain/test-parachains/adder/collator/src/lib.rs b/polkadot/parachain/test-parachains/adder/collator/src/lib.rs index a7da25c30a..95e54a5344 100644 --- a/polkadot/parachain/test-parachains/adder/collator/src/lib.rs +++ b/polkadot/parachain/test-parachains/adder/collator/src/lib.rs @@ -20,7 +20,7 @@ use futures::channel::oneshot; use futures_timer::Delay; use parity_scale_codec::{Decode, Encode}; use polkadot_node_primitives::{ - Collation, CollationResult, CollatorFn, PoV, SignedFullStatement, Statement, + Collation, CollationResult, CollationSecondedSignal, CollatorFn, PoV, Statement, }; use polkadot_primitives::v1::{CollatorId, CollatorPair}; use sp_core::{traits::SpawnNamed, Pair}; @@ -182,19 +182,19 @@ impl Collator { let compressed_pov = polkadot_node_primitives::maybe_compress_pov(pov); - let (result_sender, recv) = oneshot::channel::(); + let (result_sender, recv) = oneshot::channel::(); let seconded_collations = seconded_collations.clone(); spawner.spawn( "adder-collator-seconded", async move { if let Ok(res) = recv.await { if !matches!( - res.payload(), + res.statement.payload(), Statement::Seconded(s) if s.descriptor.pov_hash == compressed_pov.hash(), ) { log::error!( "Seconded statement should match our collation: {:?}", - res.payload() + res.statement.payload() ); std::process::exit(-1); } diff --git a/polkadot/roadmap/implementers-guide/src/types/overseer-protocol.md b/polkadot/roadmap/implementers-guide/src/types/overseer-protocol.md index b4f9b9a47a..b1b139f859 100644 --- a/polkadot/roadmap/implementers-guide/src/types/overseer-protocol.md +++ b/polkadot/roadmap/implementers-guide/src/types/overseer-protocol.md @@ -387,7 +387,7 @@ enum CollatorProtocolMessage { /// /// The result sender should be informed when at least one parachain validator seconded the collation. It is also /// completely okay to just drop the sender. - DistributeCollation(CandidateReceipt, PoV, Option>), + DistributeCollation(CandidateReceipt, PoV, Option>), /// Fetch a collation under the given relay-parent for the given ParaId. FetchCollation(Hash, ParaId, ResponseChannel<(CandidateReceipt, PoV)>), /// Report a collator as having provided an invalid collation. This should lead to disconnect