-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Generalize the Consensus Infrastructure #883
Conversation
tht's fine - bbq birch will be decommissioned as soon as shaft(grandpa)/aura are operational. |
404c543
to
bfb31c0
Compare
Updated the comment to reflect the latest design and process decisions, specifically:
Previously, this also attempted to, but won't be part of this
|
core/network/src/import_queue.rs
Outdated
} | ||
|
||
#[cfg(any(test, feature = "test-helpers"))] | ||
unsafe impl Send for PassThroughVerifier {} |
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.
PassThroughVerifier
stores only a bool -- are these necessary?
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.
nope. this stems from a previous version, where it stored more than a bool
. removed.
294d9a1
to
21d394e
Compare
core/client/src/client.rs
Outdated
body: Option<Vec<<Block as BlockT>::Extrinsic>>, | ||
finalized: bool, | ||
import_block: ImportBlock<Block>, | ||
new_authorities: Option<Vec<AuthorityId>>, |
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.
This value (named new_authorities
) is actually cached under parent header Id - previously it meant 'authorities that have justified this block'. So probably rename back to authorities
, since it is not necessary the new authorities set? Or the meaning has changed?
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.
@svyatonik the meaning has changed. While you described how it was previously, all actual checks are done within the Verifier
now and this only communicates the changes to import: the Block itself and optionally a new Set of Authorities - as changes of authority set will also be consensus engine driven. This is a temporary hack until we have the signaling in place, in which case this wouldn't be passed here anymore but instead a NewAuthorities
-Signal will be triggered at import time instead.
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.
OK, thanks. Then better to wait for actual Verifier
implementation && see if some changes are required here (and in the authorities cache).
core/client/src/client.rs
Outdated
pub header: Block::Header, | ||
/// Justification provided for this block from the outside | ||
pub external_justification: Justification, | ||
/// internal Justification for the 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.
Nitpick: Capitalize Internal
.
core/consensus/rhd/src/lib.rs
Outdated
|
||
/// Sign a BFT message with the given key. | ||
pub fn sign_message<B: Block + Clone>(message: Message<B>, key: &ed25519::Pair, parent_hash: B::Hash) -> LocalizedMessage<B> { | ||
// fn check_justification_signed_message<H>( |
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.
Why did you need this code entirely? If you need this code anytime in the future, you can just use git to get it back^^
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! a few minor nits.
core/client/src/client.rs
Outdated
body: Option<Vec<<Block as BlockT>::Extrinsic>>, | ||
finalized: bool, | ||
import_block: ImportBlock<Block>, | ||
new_authorities: Option<Vec<AuthorityId>>, |
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.
Stray spaces
node/service/src/lib.rs
Outdated
/// A collection of type to generalise specific components over full / light client. | ||
pub trait Components: service::Components { | ||
/// Demo API. | ||
type Api: 'static + AuthoringApi + Send + Sync; | ||
type Api: 'static + Send + Sync; |
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.
Double space
core/network/src/protocol.rs
Outdated
sync.on_block_data(&mut ProtocolContext::new(&self.context_data, io), peer, request, response) | ||
}; | ||
|
||
if let Some((origin, new_blocks)) = new_blocks { |
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.
Double space
core/service/src/components.rs
Outdated
} | ||
|
||
} else { | ||
Err("Chain Specification doesn't containg any consensus_engine name".into()) |
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.
containg
→ contain
?
core/service/src/components.rs
Outdated
} | ||
|
||
} else { | ||
Err("Chain Specification doesn't containg any consensus_engine name".into()) |
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.
containg
→ contain
?
core/service/src/chain_ops.rs
Outdated
receipt: None, | ||
message_queue: None | ||
}; | ||
// import queue handels verification and importing it into the client |
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.
handels
→ handles
@@ -71,10 +60,33 @@ pub type ChainSpec = service::ChainSpec<GenesisConfig>; | |||
pub type ComponentClient<C> = Client<<C as Components>::Backend, <C as Components>::Executor, Block>; | |||
pub type NetworkService = network::Service<Block, <Factory as service::ServiceFactory>::NetworkProtocol, Hash>; | |||
|
|||
/// A verifier that doesn't actually do any checks | |||
pub struct NoneVerifier; |
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.
Using ()
for "null" implementations of traits by convention.
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.
Can't be done here: impl<B: BlockT> Verifier<B> for ()
can only be done within the crate that defines Verifier
, not in node-service
but in substrate-network
. However we don't want to provide such a bad implementation in substrate-network
.
Leaving it as is for now, as this is only temporarily to make the compiler happy and will be replaced in the next chunk of work with an actual Verifier
implementation.
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.
Minor grumble that might be nice/reasonable to address
- simplify ImportQueue.import_blocks - remove Deadlock on import_block - Adding Verifier-Trait - Implement import_queue provisioning in service; allow cli to import
0e77cc7
to
dc0826b
Compare
Co-authored-by: cheme <emericchevalier.pro@gmail.com>
Bumps [regex](https://github.com/rust-lang/regex) from 1.7.1 to 1.7.3. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](rust-lang/regex@1.7.1...1.7.3) --- updated-dependencies: - dependency-name: regex dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
In our efforts to allow pluggable consensus engines in substrate, this PR attempts to generalize consensus messages over the network, blocks and the client.
NetworkMessage
s for Consensus as an opaqueVec<u8>
Justification
as a Consensus-specific opaqueVec<u8>
ConsensusGossip
over any consensus internal informationbft:*
) fromcore
,sr-*
and thesrml
import_block
fromclient
cli
to allow substrate to decide on consensus engine