-
Notifications
You must be signed in to change notification settings - Fork 378
Conversation
//! total number of parachain validators. | ||
//! | ||
//! 4. The parachain candidate with the highest number of approvals is choosen by the relay-chain | ||
//! block producer to be backed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approvals means supporting parachain validators I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, prefer the term backing as approval means something else in parachain consensus.
client/consensus/common/src/lib.rs
Outdated
/// | ||
/// # NOTE | ||
/// | ||
/// It is expected that the block is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall. I am not sure how it fixes #36 though
client/collator/src/lib.rs
Outdated
@@ -343,14 +260,15 @@ where | |||
relay_parent: PHash, | |||
validation_data: PersistedValidationData, | |||
) -> Option<CollationResult> { | |||
trace!(target: LOG_TARGET, "Producing candidate"); | |||
tracing::trace!(target: LOG_TARGET, "Producing candidate"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth adding relay_parent
tag here?
} | ||
|
||
impl<Block: BlockT, PF, BI, BS, Backend, PBackend, PClient, PBackend2> Clone | ||
for Collator<Block, PF, BI, BS, Backend, PBackend, PClient, PBackend2> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay!
#36 was a rather shitty issue. In the end I settled with myself on requiring that people will need to implement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a little late here, but I'll submit this anyway. Thanks for this PR.
/// implementation could for example check if this specific collator is part of the validator. | ||
#[async_trait::async_trait] | ||
pub trait ParachainConsensus<B: BlockT>: Send + Sync + dyn_clone::DynClone { | ||
/// Produce a new candidate at the given parent block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Produce a new candidate at the given parent block. | |
/// Produce a new candidate at the given parent and relay-parent blocks. |
/// The collator will call [`Self::produce_candidate`] every time there is a free core for the parachain | ||
/// this collator is collating for. It is the job of the consensus implementation to decide if this | ||
/// specific collator should build candidate for the given relay chain block. The consensus | ||
/// implementation could for example check if this specific collator is part of the validator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// The collator will call [`Self::produce_candidate`] every time there is a free core for the parachain | |
/// this collator is collating for. It is the job of the consensus implementation to decide if this | |
/// specific collator should build candidate for the given relay chain block. The consensus | |
/// implementation could for example check if this specific collator is part of the validator. | |
/// The collator will call [`Self::produce_candidate`] every time there is a free core for the parachain | |
/// this collator is collating for. It is the job of the consensus implementation to decide whether this | |
/// specific collator should build a candidate for the given relay chain block. The consensus | |
/// implementation could, for example, check whether this specific collator is part of a staked set. |
@@ -511,6 +510,52 @@ where | |||
} | |||
} | |||
|
|||
/// The result of [`ParachainConsensus::produce_candidate`]. | |||
pub struct ParachainCandidate<B> { | |||
/// The block that was build for this candidate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// The block that was build for this candidate. | |
/// The block that was built for this candidate. |
//! 3. The parachain validators validate at most X different parachain candidates, where X is the | ||
//! total number of parachain validators. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! 3. The parachain validators validate at most X different parachain candidates, where X is the | |
//! total number of parachain validators. | |
//! 3. The validators assigned to this parachain validate at most X different parachain candidates, where X is the | |
//! total number of validators assigned to this parachain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly suggested this one because I worry that people who haven't read all the docs might think that "parachain validators" means collators.
@JoshOrndorff could you open a pr with your suggestions please? |
Could you explain a little bit more about the Why is it necessary? I don't quite understand the comment:
I mostly understand the explanation, but I don't understand why the builder needs a concrete relay chain client instance. Is this pattern used somewhere else? This seems more complex than the analogous code in sc_consensus_aura |
I guess this is the part that is really bending my brain: /// Build the relay chain consensus.
fn build(self) -> Box<dyn ParachainConsensus<Block>> {
self.relay_chain_client.clone().execute_with(self)
} |
This works around some missing type system features :P A polkadot client can either be Kusama/Polkadot/Rococo/Test and all use some small different types. Actually most of them are equal, but the compiler can not resolve this. To circumvent this problem on the polkadot side, there is this |
Thanks for explaining. I see the part you mean in Polkadot now. |
This pr introduces abstractions around the parachain consensus that is driven by the collator. It moves the current implementation into the
RelayChainConsensus
as a consensus that is entirely dependent on the relay chain.Fixes: #36