Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Revert "Incorporate sc-peerset into sc-network (#14236)"
Browse files Browse the repository at this point in the history
This reverts commit a8e7ba1.
  • Loading branch information
dmitry-markin committed Jul 3, 2023
1 parent 54dec3d commit bbee969
Show file tree
Hide file tree
Showing 40 changed files with 337 additions and 304 deletions.
27 changes: 26 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ members = [
"client/network/sync",
"client/network/test",
"client/offchain",
"client/peerset",
"client/allocator",
"client/proposer-metrics",
"client/rpc",
Expand Down
1 change: 1 addition & 0 deletions client/network-gossip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.
sc-network = { version = "0.10.0-dev", path = "../network/" }
sc-network-common = { version = "0.10.0-dev", path = "../network/common" }
sp-runtime = { version = "24.0.0", path = "../../primitives/runtime" }
sc-peerset = { version = "4.0.0-dev", path = "../peerset" }

[dev-dependencies]
tokio = "1.22.0"
Expand Down
3 changes: 2 additions & 1 deletion client/network-gossip/src/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ use crate::{
Network, Syncing, Validator,
};

use sc_network::{event::Event, types::ProtocolName, ReputationChange};
use sc_network::{event::Event, types::ProtocolName};
use sc_network_common::sync::SyncEvent;
use sc_peerset::ReputationChange;

use futures::{
channel::mpsc::{channel, Receiver, Sender},
Expand Down
5 changes: 3 additions & 2 deletions client/network-gossip/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const REBROADCAST_INTERVAL: time::Duration = time::Duration::from_millis(750);
pub(crate) const PERIODIC_MAINTENANCE_INTERVAL: time::Duration = time::Duration::from_millis(1100);

mod rep {
use sc_network::ReputationChange as Rep;
use sc_peerset::ReputationChange as Rep;
/// Reputation change when a peer sends us a gossip message that we didn't know about.
pub const GOSSIP_SUCCESS: Rep = Rep::new(1 << 4, "Successful gossip");
/// Reputation change when a peer sends us a gossip message that we already knew about.
Expand Down Expand Up @@ -529,8 +529,9 @@ mod tests {
use sc_network::{
config::MultiaddrWithPeerId, event::Event, NetworkBlock, NetworkEventStream,
NetworkNotification, NetworkPeers, NotificationSenderError,
NotificationSenderT as NotificationSender, ReputationChange,
NotificationSenderT as NotificationSender,
};
use sc_peerset::ReputationChange;
use sp_runtime::{
testing::{Block as RawBlock, ExtrinsicWrapper, H256},
traits::NumberFor,
Expand Down
3 changes: 1 addition & 2 deletions client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ linked_hash_set = "0.1.3"
log = "0.4.17"
mockall = "0.11.3"
parking_lot = "0.12.1"
partial_sort = "0.2.0"
pin-project = "1.0.12"
rand = "0.8.5"
serde = { version = "1.0.163", features = ["derive"] }
Expand All @@ -42,6 +41,7 @@ zeroize = "1.4.3"
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" }
sc-client-api = { version = "4.0.0-dev", path = "../api" }
sc-network-common = { version = "0.10.0-dev", path = "./common" }
sc-peerset = { version = "4.0.0-dev", path = "../peerset" }
sc-utils = { version = "4.0.0-dev", path = "../utils" }
sp-arithmetic = { version = "16.0.0", path = "../../primitives/arithmetic" }
sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" }
Expand All @@ -51,7 +51,6 @@ wasm-timer = "0.2"

[dev-dependencies]
assert_matches = "1.3"
mockall = "0.11.3"
multistream-select = "0.12.1"
rand = "0.8.5"
tempfile = "3.1.0"
Expand Down
1 change: 1 addition & 0 deletions client/network/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ codec = { package = "parity-scale-codec", version = "3.6.1", features = [
futures = "0.3.21"
libp2p-identity = { version = "0.1.2", features = ["peerid"] }
sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" }
sc-peerset = { version = "4.0.0-dev", path = "../../peerset" }
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../../primitives/consensus/grandpa" }
sp-runtime = { version = "24.0.0", path = "../../../primitives/runtime" }
Expand Down
1 change: 0 additions & 1 deletion client/network/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
pub mod message;
pub mod role;
pub mod sync;
pub mod types;

/// Minimum Requirements for a Hash within Networking
pub trait ExHashT: std::hash::Hash + Eq + std::fmt::Debug + Clone + Send + Sync + 'static {}
Expand Down
4 changes: 2 additions & 2 deletions client/network/common/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub mod message;
pub mod metrics;
pub mod warp;

use crate::{role::Roles, types::ReputationChange};
use crate::role::Roles;
use futures::Stream;

use libp2p_identity::PeerId;
Expand Down Expand Up @@ -106,7 +106,7 @@ pub struct SyncStatus<Block: BlockT> {

/// A peer did not behave as expected and should be reported.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BadPeer(pub PeerId, pub ReputationChange);
pub struct BadPeer(pub PeerId, pub sc_peerset::ReputationChange);

impl fmt::Display for BadPeer {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
38 changes: 0 additions & 38 deletions client/network/common/src/types.rs

This file was deleted.

1 change: 1 addition & 0 deletions client/network/light/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain"
sc-client-api = { version = "4.0.0-dev", path = "../../api" }
sc-network = { version = "0.10.0-dev", path = "../" }
sp-core = { version = "21.0.0", path = "../../../primitives/core" }
sc-peerset = { version = "4.0.0-dev", path = "../../peerset" }
sp-runtime = { version = "24.0.0", path = "../../../primitives/runtime" }
thiserror = "1.0"
2 changes: 1 addition & 1 deletion client/network/light/src/light_client_requests/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ use sc_client_api::{BlockBackend, ProofProvider};
use sc_network::{
config::ProtocolId,
request_responses::{IncomingRequest, OutgoingResponse, ProtocolConfig},
ReputationChange,
};
use sc_peerset::ReputationChange;
use sp_core::{
hexdisplay::HexDisplay,
storage::{ChildInfo, ChildType, PrefixedStorageKey},
Expand Down
3 changes: 1 addition & 2 deletions client/network/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ use crate::{
discovery::{DiscoveryBehaviour, DiscoveryConfig, DiscoveryOut},
event::DhtEvent,
peer_info,
peerset::PeersetHandle,
protocol::{CustomMessageOutcome, NotificationsSink, Protocol},
request_responses::{self, IfDisconnected, ProtocolConfig, RequestFailure},
types::ProtocolName,
ReputationChange,
};

use bytes::Bytes;
Expand All @@ -35,6 +33,7 @@ use libp2p::{
};

use sc_network_common::role::{ObservedRole, Roles};
use sc_peerset::{PeersetHandle, ReputationChange};
use sp_runtime::traits::Block as BlockT;
use std::{collections::HashSet, time::Duration};

Expand Down
6 changes: 2 additions & 4 deletions client/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,7 @@
//! More precise usage details are still being worked on and will likely change in the future.
mod behaviour;
mod peer_store;
mod peerset;
mod protocol;
mod protocol_controller;
mod service;

pub mod config;
Expand All @@ -270,7 +267,6 @@ pub use sc_network_common::{
warp::{WarpSyncPhase, WarpSyncProgress},
ExtendedPeerInfo, StateDownloadProgress, SyncEventStream, SyncState, SyncStatusProvider,
},
types::ReputationChange,
};
pub use service::{
signature::Signature,
Expand All @@ -285,6 +281,8 @@ pub use service::{
};
pub use types::ProtocolName;

pub use sc_peerset::ReputationChange;

/// The maximum allowed number of established connections per peer.
///
/// Typically, and by design of the network behaviours in this crate,
Expand Down
Loading

0 comments on commit bbee969

Please sign in to comment.