mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 20:25:40 +00:00
Merged companions and update Subtrate (#882)
* expunge legacy code from polkadot-network * mostly rip out old legacy protocol from service * ensure validation work is spawned by incoming messages * decouple availabliity store from network logic; clean up data flow * av_store: test helpers and use futures-abort * update polkadot-validation to pass n_validators when submitting chunks * fallible erasure-chunk fetching * implement `ErasureNetworking` for new network prot * API for registering availability store in network * fully integrate new network service into service * fix validation tests * scaffolding for porting collator over to new network * track connected validators' peer IDs and distribute collators' collations * helper in network for fetching all checked statements * fix adder-collator * actually register notifications protocol * Update service/src/lib.rs * Make needed changes to service * Merge two companion PRs. - #880 - #881 * Some effort towards compilation * Fix * remove `NetworkSpecialization` references from network * fix compilation errors in service and collator * ensure protocol name is valid * Fixes * Fix Co-authored-by: Robert Habermeier <rphmeier@gmail.com> Co-authored-by: Ashley <ashley.ruglys@gmail.com>
This commit is contained in:
@@ -52,7 +52,7 @@
|
||||
use sp_runtime::traits::{BlakeTwo256, Hash as HashT};
|
||||
use sp_blockchain::Error as ClientError;
|
||||
use sc_network::{config::Roles, PeerId, ReputationChange};
|
||||
use sc_network::{NetworkService as SubstrateNetworkService, specialization::NetworkSpecialization};
|
||||
use sc_network::NetworkService;
|
||||
use sc_network_gossip::{
|
||||
ValidationResult as GossipValidationResult,
|
||||
ValidatorContext, MessageIntent,
|
||||
@@ -266,11 +266,11 @@ pub(crate) fn attestation_topic(parent_hash: Hash) -> Hash {
|
||||
// NOTE: since RegisteredMessageValidator is meant to be a type-safe proof
|
||||
// that we've actually done the registration, this should be the only way
|
||||
// to construct it outside of tests.
|
||||
pub fn register_validator<C: ChainContext + 'static, S: NetworkSpecialization<Block>>(
|
||||
service: Arc<SubstrateNetworkService<Block, S, Hash>>,
|
||||
pub fn register_validator<C: ChainContext + 'static>(
|
||||
service: Arc<NetworkService<Block, Hash>>,
|
||||
chain: C,
|
||||
executor: &impl futures::task::Spawn,
|
||||
) -> RegisteredMessageValidator<S>
|
||||
) -> RegisteredMessageValidator
|
||||
{
|
||||
let s = service.clone();
|
||||
let report_handle = Box::new(move |peer: &PeerId, cost_benefit: ReputationChange| {
|
||||
@@ -344,25 +344,16 @@ impl NewLeafActions {
|
||||
/// A registered message validator.
|
||||
///
|
||||
/// Create this using `register_validator`.
|
||||
pub struct RegisteredMessageValidator<S: NetworkSpecialization<Block>> {
|
||||
#[derive(Clone)]
|
||||
pub struct RegisteredMessageValidator {
|
||||
inner: Arc<MessageValidator<dyn ChainContext>>,
|
||||
// Note: this is always `Some` in real code and `None` in tests.
|
||||
service: Option<Arc<SubstrateNetworkService<Block, S, Hash>>>,
|
||||
service: Option<Arc<NetworkService<Block, Hash>>>,
|
||||
// Note: this is always `Some` in real code and `None` in tests.
|
||||
gossip_engine: Option<sc_network_gossip::GossipEngine<Block>>,
|
||||
}
|
||||
|
||||
impl<S: NetworkSpecialization<Block>> Clone for RegisteredMessageValidator<S> {
|
||||
fn clone(&self) -> Self {
|
||||
RegisteredMessageValidator {
|
||||
inner: self.inner.clone(),
|
||||
service: self.service.clone(),
|
||||
gossip_engine: self.gossip_engine.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: NetworkSpecialization<Block>> RegisteredMessageValidator<S> {
|
||||
impl RegisteredMessageValidator {
|
||||
/// Register an availabilty store the gossip service can query.
|
||||
pub(crate) fn register_availability_store(&self, availability_store: av_store::Store) {
|
||||
self.inner.inner.write().availability_store = Some(availability_store);
|
||||
@@ -437,7 +428,7 @@ impl<S: NetworkSpecialization<Block>> RegisteredMessageValidator<S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: NetworkSpecialization<Block>> GossipService for RegisteredMessageValidator<S> {
|
||||
impl GossipService for RegisteredMessageValidator {
|
||||
fn gossip_messages_for(&self, topic: Hash) -> GossipMessageStream {
|
||||
RegisteredMessageValidator::gossip_messages_for(self, topic)
|
||||
}
|
||||
|
||||
@@ -24,14 +24,8 @@ use polkadot_primitives::{Block, Hash, BlakeTwo256, HashT};
|
||||
pub mod legacy;
|
||||
pub mod protocol;
|
||||
|
||||
sc_network::construct_simple_protocol! {
|
||||
/// Stub until https://github.com/paritytech/substrate/pull/4665 is merged
|
||||
#[derive(Clone)]
|
||||
pub struct PolkadotProtocol where Block = Block { }
|
||||
}
|
||||
|
||||
/// Specialization of the network service for the polkadot protocol.
|
||||
pub type PolkadotNetworkService = sc_network::NetworkService<Block, PolkadotProtocol, Hash>;
|
||||
/// Specialization of the network service for the polkadot block type.
|
||||
pub type PolkadotNetworkService = sc_network::NetworkService<Block, Hash>;
|
||||
|
||||
mod cost {
|
||||
use sc_network::ReputationChange as Rep;
|
||||
|
||||
@@ -50,7 +50,7 @@ use std::time::Duration;
|
||||
|
||||
use super::{cost, benefit, PolkadotNetworkService};
|
||||
use crate::legacy::collator_pool::Role as CollatorRole;
|
||||
use crate::legacy::gossip::{GossipMessage, ErasureChunkMessage};
|
||||
use crate::legacy::gossip::{GossipMessage, ErasureChunkMessage, RegisteredMessageValidator};
|
||||
|
||||
/// The current protocol version.
|
||||
pub const VERSION: u32 = 1;
|
||||
@@ -60,7 +60,7 @@ pub const MIN_SUPPORTED_VERSION: u32 = 1;
|
||||
/// The engine ID of the polkadot network protocol.
|
||||
pub const POLKADOT_ENGINE_ID: sp_runtime::ConsensusEngineId = *b"dot2";
|
||||
/// The protocol name.
|
||||
pub const POLKADOT_PROTOCOL_NAME: &[u8] = b"dot2-proto";
|
||||
pub const POLKADOT_PROTOCOL_NAME: &[u8] = b"/polkadot/1";
|
||||
|
||||
pub use crate::legacy::gossip::ChainContext;
|
||||
|
||||
@@ -305,8 +305,6 @@ struct ConsensusNetworkingInstance {
|
||||
_drop_signal: exit_future::Signal,
|
||||
}
|
||||
|
||||
type RegisteredMessageValidator = crate::legacy::gossip::RegisteredMessageValidator<crate::PolkadotProtocol>;
|
||||
|
||||
/// Protocol configuration.
|
||||
#[derive(Default)]
|
||||
pub struct Config {
|
||||
|
||||
Reference in New Issue
Block a user