mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
NetworkBridge: validator (authorities) discovery api (#1699)
* stupid, but it compiles * redo * cleanup * add ValidatorDiscovery to msgs * sketch network bridge code * ConnectToAuthorities instead of validators * more stuff * cleanup * more stuff * complete ConnectToAuthoritiesState * Update node/network/bridge/src/lib.rs Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * Collator protocol subsystem (#1659) * WIP * The initial implementation of the collator side. * Improve comments * Multiple collation requests * Add more tests and comments to validator side * Add comments, remove dead code * Apply suggestions from code review Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * Fix build after suggested changes * Also connect to the next validator group * Remove a Future impl and move TimeoutExt to util * Minor nits * Fix build * Change FetchCollations back to FetchCollation * Try this * Final fixes * Fix build Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * handle multiple in-flight connection requests * handle cancelled requests * Update node/core/runtime-api/src/lib.rs Co-authored-by: Bernhard Schuster <bernhard@ahoi.io> * redo it again * more stuff * redo it again * update comments * workaround Future is not Send * fix trailing spaces * clarify comments * bridge: fix compilation in tests * update more comments * small fixes * port collator protocol to new validator discovery api * collator tests compile * collator tests pass * do not revoke a request when the stream receiver is closed * make revoking opt-in * fix is_fulfilled * handle request revokation in collator * tests * wait for validator connections asyncronously * fix compilation * relabel my todos * apply Fedor's patch * resolve reconnection TODO * resolve revoking TODO * resolve channel capacity TODO * resolve peer cloning TODO * resolve peer disconnected TODO * resolve PeerSet TODO * wip tests * more tests * resolve Arc TODO * rename pending to non_revoked * one more test * extract utility function into util crate * fix compilation in tests * Apply suggestions from code review Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com> * revert pin_project removal * fix while let loop * Revert "revert pin_project removal" This reverts commit ae7f529d8de982ef66c3007dd1ff74c6ddce80d2. * fix compilation * Update node/subsystem/src/messages.rs * docs on pub items * guide updates * remove a TODO * small guide update * fix a typo * link to the issue * validator discovery: on_request docs Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com> Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>
This commit is contained in:
@@ -25,14 +25,14 @@
|
||||
use futures::channel::{mpsc, oneshot};
|
||||
|
||||
use polkadot_node_network_protocol::{
|
||||
v1 as protocol_v1, NetworkBridgeEvent, ReputationChange, PeerId, PeerSet,
|
||||
v1 as protocol_v1, NetworkBridgeEvent, ReputationChange, PeerId,
|
||||
};
|
||||
use polkadot_node_primitives::{
|
||||
CollationGenerationConfig, MisbehaviorReport, SignedFullStatement, ValidationResult,
|
||||
};
|
||||
use polkadot_primitives::v1::{
|
||||
AvailableData, BackedCandidate, BlockNumber, CandidateDescriptor, CandidateEvent,
|
||||
CandidateReceipt, CollatorId, CommittedCandidateReceipt,
|
||||
AuthorityDiscoveryId, AvailableData, BackedCandidate, BlockNumber, CandidateDescriptor,
|
||||
CandidateEvent, CandidateReceipt, CollatorId, CommittedCandidateReceipt,
|
||||
CoreState, ErasureChunk, GroupRotationInfo, Hash, Id as ParaId,
|
||||
OccupiedCoreAssumption, PersistedValidationData, PoV, SessionIndex, SignedAvailabilityBitfield,
|
||||
TransientValidationData, ValidationCode, ValidatorId, ValidationData, ValidatorIndex,
|
||||
@@ -196,11 +196,25 @@ pub enum NetworkBridgeMessage {
|
||||
/// Send a message to one or more peers on the collation peer-set.
|
||||
SendCollationMessage(Vec<PeerId>, protocol_v1::CollationProtocol),
|
||||
|
||||
/// Connect to peers who represent the given `ValidatorId`s at the given relay-parent.
|
||||
/// Connect to peers who represent the given `validator_ids`.
|
||||
///
|
||||
/// Also accepts a response channel by which the issuer can learn the `PeerId`s of those
|
||||
/// validators.
|
||||
ConnectToValidators(PeerSet, Vec<ValidatorId>, oneshot::Sender<Vec<(ValidatorId, PeerId)>>),
|
||||
/// Also ask the network to stay connected to these peers at least
|
||||
/// until the request is revoked.
|
||||
ConnectToValidators {
|
||||
/// Ids of the validators to connect to.
|
||||
validator_ids: Vec<AuthorityDiscoveryId>,
|
||||
/// Response sender by which the issuer can learn the `PeerId`s of
|
||||
/// the validators as they are connected.
|
||||
/// The response is sent immediately for already connected peers.
|
||||
connected: mpsc::Sender<(AuthorityDiscoveryId, PeerId)>,
|
||||
/// By revoking the request the caller allows the network to
|
||||
/// free some peer slots thus freeing the resources.
|
||||
/// It doesn't necessarily lead to peers disconnection though.
|
||||
/// The revokation is enacted on in the next connection request.
|
||||
///
|
||||
/// This can be done by sending to the channel or dropping the sender.
|
||||
revoke: oneshot::Receiver<()>,
|
||||
},
|
||||
}
|
||||
|
||||
impl NetworkBridgeMessage {
|
||||
@@ -210,7 +224,7 @@ impl NetworkBridgeMessage {
|
||||
Self::ReportPeer(_, _) => None,
|
||||
Self::SendValidationMessage(_, _) => None,
|
||||
Self::SendCollationMessage(_, _) => None,
|
||||
Self::ConnectToValidators(_, _, _) => None,
|
||||
Self::ConnectToValidators { .. } => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -389,6 +403,11 @@ pub enum RuntimeApiRequest {
|
||||
/// Get all events concerning candidates (backing, inclusion, time-out) in the parent of
|
||||
/// the block in whose state this request is executed.
|
||||
CandidateEvents(RuntimeApiSender<Vec<CandidateEvent>>),
|
||||
/// Get the `AuthorityDiscoveryId`s corresponding to the given `ValidatorId`s.
|
||||
/// Currently this request is limited to validators in the current session.
|
||||
///
|
||||
/// Returns `None` for validators not found in the current session.
|
||||
ValidatorDiscovery(Vec<ValidatorId>, RuntimeApiSender<Vec<Option<AuthorityDiscoveryId>>>),
|
||||
}
|
||||
|
||||
/// A message to the Runtime API subsystem.
|
||||
|
||||
Reference in New Issue
Block a user