Skip to content

Commit

Permalink
Trivial networking changes for Substrate PR paritytech/substrate#11940
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Jul 29, 2022
1 parent e7461a6 commit 09bcd4a
Show file tree
Hide file tree
Showing 11 changed files with 530 additions and 186 deletions.
447 changes: 274 additions & 173 deletions Cargo.lock

Large diffs are not rendered by default.

238 changes: 238 additions & 0 deletions Cargo.toml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions node/core/approval-voting/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl TestSyncOracleHandle {
}

impl SyncOracle for TestSyncOracle {
fn is_major_syncing(&mut self) -> bool {
fn is_major_syncing(&self) -> bool {
let is_major_syncing = self.flag.load(Ordering::SeqCst);

if !is_major_syncing {
Expand All @@ -92,7 +92,7 @@ impl SyncOracle for TestSyncOracle {
is_major_syncing
}

fn is_offline(&mut self) -> bool {
fn is_offline(&self) -> bool {
unimplemented!("not used in network bridge")
}
}
Expand Down
1 change: 1 addition & 0 deletions node/network/bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ gum = { package = "tracing-gum", path = "../../gum" }
polkadot-primitives = { path = "../../../primitives" }
parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
polkadot-node-subsystem = {path = "../../subsystem" }
polkadot-overseer = { path = "../../overseer" }
Expand Down
17 changes: 8 additions & 9 deletions node/network/bridge/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ use sc_network::{
config::parse_addr, multiaddr::Multiaddr, Event as NetworkEvent, IfDisconnected,
NetworkService, OutboundFailure, RequestFailure,
};
use sc_network_common::service::{
NetworkEventStream, NetworkNotification, NetworkPeers, NetworkRequest,
};

use polkadot_node_network_protocol::{
peer_set::PeerSet,
Expand Down Expand Up @@ -121,27 +124,23 @@ impl Network for Arc<NetworkService<Block, Hash>> {
protocol: Cow<'static, str>,
multiaddresses: HashSet<Multiaddr>,
) -> Result<(), String> {
sc_network::NetworkService::set_reserved_peers(&**self, protocol, multiaddresses)
NetworkService::set_reserved_peers(&**self, protocol, multiaddresses)
}

async fn remove_from_peers_set(&mut self, protocol: Cow<'static, str>, peers: Vec<PeerId>) {
sc_network::NetworkService::remove_peers_from_reserved_set(&**self, protocol, peers);
NetworkService::remove_peers_from_reserved_set(&**self, protocol, peers);
}

fn report_peer(&self, who: PeerId, cost_benefit: Rep) {
sc_network::NetworkService::report_peer(&**self, who, cost_benefit.into_base_rep());
NetworkService::report_peer(&**self, who, cost_benefit.into_base_rep());
}

fn disconnect_peer(&self, who: PeerId, peer_set: PeerSet) {
sc_network::NetworkService::disconnect_peer(
&**self,
who,
peer_set.into_default_protocol_name(),
);
NetworkService::disconnect_peer(&**self, who, peer_set.into_default_protocol_name());
}

fn write_notification(&self, who: PeerId, peer_set: PeerSet, message: Vec<u8>) {
sc_network::NetworkService::write_notification(
NetworkService::write_notification(
&**self,
who,
peer_set.into_default_protocol_name(),
Expand Down
4 changes: 2 additions & 2 deletions node/network/bridge/src/rx/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl TestSyncOracleHandle {
}

impl SyncOracle for TestSyncOracle {
fn is_major_syncing(&mut self) -> bool {
fn is_major_syncing(&self) -> bool {
let is_major_syncing = self.is_major_syncing.load(Ordering::SeqCst);

if !is_major_syncing {
Expand All @@ -248,7 +248,7 @@ impl SyncOracle for TestSyncOracle {
is_major_syncing
}

fn is_offline(&mut self) -> bool {
fn is_offline(&self) -> bool {
unimplemented!("not used in network bridge")
}
}
Expand Down
1 change: 1 addition & 0 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "mast
sc-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-sync-state-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
1 change: 1 addition & 0 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ where
let authority_discovery_service = if auth_or_collator || overseer_enable_anyways {
use futures::StreamExt;
use sc_network::Event;
use sc_network_common::service::NetworkEventStream;

let authority_discovery_role = if role.is_authority() {
sc_authority_discovery::Role::PublishAndDiscover(keystore_container.keystore())
Expand Down
1 change: 1 addition & 0 deletions node/service/src/overseer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use polkadot_primitives::runtime_api::ParachainHost;
use sc_authority_discovery::Service as AuthorityDiscoveryService;
use sc_client_api::AuxStore;
use sc_keystore::LocalKeystore;
use sc_network_common::service::NetworkStateInfo;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_consensus_babe::BabeApi;
Expand Down
1 change: 1 addition & 0 deletions node/test/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "mas
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = [ "wasmtime" ] }
Expand Down
1 change: 1 addition & 0 deletions node/test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use sc_network::{
config::{NetworkConfiguration, TransportConfig},
multiaddr,
};
use sc_network_common::service::NetworkStateInfo;
use sc_service::{
config::{
DatabaseSource, KeystoreConfig, MultiaddrWithPeerId, WasmExecutionMethod,
Expand Down

0 comments on commit 09bcd4a

Please sign in to comment.