Skip to content

Commit

Permalink
Merge branch 'master' into tsv-disabling-node-side
Browse files Browse the repository at this point in the history
  • Loading branch information
tdimitrov committed Sep 28, 2023
2 parents 2a5af89 + 769bdd3 commit 2c53894
Show file tree
Hide file tree
Showing 13 changed files with 680 additions and 564 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions polkadot/node/core/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,15 +579,15 @@ where
query!(
ParaBackingState,
para_backing_state(para),
ver = Request::STAGING_BACKING_STATE,
ver = Request::ASYNC_BACKING_STATE_RUNTIME_REQUIREMENT,
sender
)
},
Request::AsyncBackingParams(sender) => {
query!(
AsyncBackingParams,
async_backing_params(),
ver = Request::STAGING_BACKING_STATE,
ver = Request::ASYNC_BACKING_STATE_RUNTIME_REQUIREMENT,
sender
)
},
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/subsystem-types/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ impl RuntimeApiRequest {
pub const MINIMUM_BACKING_VOTES_RUNTIME_REQUIREMENT: u32 = 6;

/// Minimum version to enable asynchronous backing: `AsyncBackingParams` and `ParaBackingState`.
pub const STAGING_BACKING_STATE: u32 = 7;
pub const ASYNC_BACKING_STATE_RUNTIME_REQUIREMENT: u32 = 7;

/// `DisabledValidators`
pub const DISABLED_VALIDATORS_RUNTIME_REQUIREMENT: u32 = 8;
Expand Down
1 change: 0 additions & 1 deletion polkadot/node/subsystem-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ specialize_requests! {
fn request_key_ownership_proof(validator_id: ValidatorId) -> Option<slashing::OpaqueKeyOwnershipProof>; KeyOwnershipProof;
fn request_submit_report_dispute_lost(dp: slashing::DisputeProof, okop: slashing::OpaqueKeyOwnershipProof) -> Option<()>; SubmitReportDisputeLost;
fn request_disabled_validators() -> Vec<ValidatorIndex>; DisabledValidators;

fn request_async_backing_params() -> AsyncBackingParams; AsyncBackingParams;
}

Expand Down
28 changes: 18 additions & 10 deletions substrate/client/network/common/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use sp_runtime::{
};
use warp::WarpSyncProgress;

use std::{any::Any, fmt, fmt::Formatter, pin::Pin, sync::Arc, task::Poll};
use std::{any::Any, fmt, fmt::Formatter, pin::Pin, sync::Arc};

/// The sync status of a peer we are trying to sync with
#[derive(Debug)]
Expand Down Expand Up @@ -204,6 +204,23 @@ pub enum PeerRequest<B: BlockT> {
WarpProof,
}

#[derive(Debug)]
pub enum PeerRequestType {
Block,
State,
WarpProof,
}

impl<B: BlockT> PeerRequest<B> {
pub fn get_type(&self) -> PeerRequestType {
match self {
PeerRequest::Block(_) => PeerRequestType::Block,
PeerRequest::State => PeerRequestType::State,
PeerRequest::WarpProof => PeerRequestType::WarpProof,
}
}
}

/// Wrapper for implementation-specific state request.
///
/// NOTE: Implementation must be able to encode and decode it for network purposes.
Expand Down Expand Up @@ -289,9 +306,6 @@ pub trait ChainSync<Block: BlockT>: Send {
/// Returns the current number of peers stored within this state machine.
fn num_peers(&self) -> usize;

/// Returns the number of peers we're connected to and that are being queried.
fn num_active_peers(&self) -> usize;

/// Handle a new connected peer.
///
/// Call this method whenever we connect to a new peer.
Expand Down Expand Up @@ -369,10 +383,4 @@ pub trait ChainSync<Block: BlockT>: Send {

/// Return some key metrics.
fn metrics(&self) -> Metrics;

/// Advance the state of `ChainSync`
fn poll(&mut self, cx: &mut std::task::Context) -> Poll<()>;

/// Send block request to peer
fn send_block_request(&mut self, who: PeerId, request: BlockRequest<Block>);
}
1 change: 1 addition & 0 deletions substrate/client/network/sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ prost = "0.11"
schnellru = "0.2.1"
smallvec = "1.11.0"
thiserror = "1.0"
tokio-stream = "0.1.14"
fork-tree = { path = "../../../utils/fork-tree" }
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus" }
sc-client-api = { path = "../../api" }
Expand Down
Loading

0 comments on commit 2c53894

Please sign in to comment.