mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +00:00
Remove all code related to sentry nodes (#8079)
* Remove all code related to sentry nodes * More fixing
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
config::{ProtocolId, Role},
|
||||
config::ProtocolId,
|
||||
bitswap::Bitswap,
|
||||
discovery::{DiscoveryBehaviour, DiscoveryConfig, DiscoveryOut},
|
||||
protocol::{message::Roles, CustomMessageOutcome, NotificationsSink, Protocol},
|
||||
@@ -71,10 +71,6 @@ pub struct Behaviour<B: BlockT, H: ExHashT> {
|
||||
#[behaviour(ignore)]
|
||||
events: VecDeque<BehaviourOut<B>>,
|
||||
|
||||
/// Role of our local node, as originally passed from the configuration.
|
||||
#[behaviour(ignore)]
|
||||
role: Role,
|
||||
|
||||
/// Light client request handling.
|
||||
#[behaviour(ignore)]
|
||||
light_client_request_sender: light_client_requests::sender::LightClientRequestSender<B>,
|
||||
@@ -180,7 +176,6 @@ impl<B: BlockT, H: ExHashT> Behaviour<B, H> {
|
||||
/// Builds a new `Behaviour`.
|
||||
pub fn new(
|
||||
substrate: Protocol<B, H>,
|
||||
role: Role,
|
||||
user_agent: String,
|
||||
local_public_key: PublicKey,
|
||||
light_client_request_sender: light_client_requests::sender::LightClientRequestSender<B>,
|
||||
@@ -206,7 +201,6 @@ impl<B: BlockT, H: ExHashT> Behaviour<B, H> {
|
||||
request_responses::RequestResponsesBehaviour::new(request_response_protocols.into_iter())?,
|
||||
light_client_request_sender,
|
||||
events: VecDeque::new(),
|
||||
role,
|
||||
|
||||
block_request_protocol_name,
|
||||
})
|
||||
@@ -290,15 +284,9 @@ impl<B: BlockT, H: ExHashT> Behaviour<B, H> {
|
||||
}
|
||||
}
|
||||
|
||||
fn reported_roles_to_observed_role(local_role: &Role, remote: &PeerId, roles: Roles) -> ObservedRole {
|
||||
fn reported_roles_to_observed_role(roles: Roles) -> ObservedRole {
|
||||
if roles.is_authority() {
|
||||
match local_role {
|
||||
Role::Authority { sentry_nodes }
|
||||
if sentry_nodes.iter().any(|s| s.peer_id == *remote) => ObservedRole::OurSentry,
|
||||
Role::Sentry { validators }
|
||||
if validators.iter().any(|s| s.peer_id == *remote) => ObservedRole::OurGuardedAuthority,
|
||||
_ => ObservedRole::Authority
|
||||
}
|
||||
ObservedRole::Authority
|
||||
} else if roles.is_full() {
|
||||
ObservedRole::Full
|
||||
} else {
|
||||
@@ -337,11 +325,10 @@ Behaviour<B, H> {
|
||||
);
|
||||
},
|
||||
CustomMessageOutcome::NotificationStreamOpened { remote, protocol, roles, notifications_sink } => {
|
||||
let role = reported_roles_to_observed_role(&self.role, &remote, roles);
|
||||
self.events.push_back(BehaviourOut::NotificationStreamOpened {
|
||||
remote,
|
||||
protocol,
|
||||
role: role.clone(),
|
||||
role: reported_roles_to_observed_role(roles),
|
||||
notifications_sink: notifications_sink.clone(),
|
||||
});
|
||||
},
|
||||
|
||||
@@ -72,7 +72,7 @@ impl <B: BlockT> BlockRequestHandler<B> {
|
||||
pub fn new(protocol_id: &ProtocolId, client: Arc<dyn Client<B>>) -> (Self, ProtocolConfig) {
|
||||
// Rate of arrival multiplied with the waiting time in the queue equals the queue length.
|
||||
//
|
||||
// An average Polkadot sentry node serves less than 5 requests per second. The 95th percentile
|
||||
// An average Polkadot node serves less than 5 requests per second. The 95th percentile
|
||||
// serving a request is less than 2 second. Thus one would estimate the queue length to be
|
||||
// below 10.
|
||||
//
|
||||
|
||||
@@ -128,18 +128,8 @@ pub enum Role {
|
||||
Full,
|
||||
/// Regular light node.
|
||||
Light,
|
||||
/// Sentry node that guards an authority. Will be reported as "authority" on the wire protocol.
|
||||
Sentry {
|
||||
/// Address and identity of the validator nodes that we're guarding.
|
||||
///
|
||||
/// The nodes will be granted some priviledged status.
|
||||
validators: Vec<MultiaddrWithPeerId>,
|
||||
},
|
||||
/// Actual authority.
|
||||
Authority {
|
||||
/// List of public addresses and identities of our sentry nodes.
|
||||
sentry_nodes: Vec<MultiaddrWithPeerId>,
|
||||
}
|
||||
Authority,
|
||||
}
|
||||
|
||||
impl Role {
|
||||
@@ -147,12 +137,6 @@ impl Role {
|
||||
pub fn is_authority(&self) -> bool {
|
||||
matches!(self, Role::Authority { .. })
|
||||
}
|
||||
|
||||
/// True for `Role::Authority` and `Role::Sentry` since they're both
|
||||
/// announced as having the authority role to the network.
|
||||
pub fn is_network_authority(&self) -> bool {
|
||||
matches!(self, Role::Authority { .. } | Role::Sentry { .. })
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Role {
|
||||
@@ -160,7 +144,6 @@ impl fmt::Display for Role {
|
||||
match self {
|
||||
Role::Full => write!(f, "FULL"),
|
||||
Role::Light => write!(f, "LIGHT"),
|
||||
Role::Sentry { .. } => write!(f, "SENTRY"),
|
||||
Role::Authority { .. } => write!(f, "AUTHORITY"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,21 +384,6 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
|
||||
let mut sets = Vec::with_capacity(NUM_HARDCODED_PEERSETS + network_config.extra_sets.len());
|
||||
|
||||
let mut default_sets_reserved = HashSet::new();
|
||||
match config_role {
|
||||
config::Role::Sentry { validators } => {
|
||||
for validator in validators {
|
||||
default_sets_reserved.insert(validator.peer_id.clone());
|
||||
known_addresses.push((validator.peer_id.clone(), validator.multiaddr.clone()));
|
||||
}
|
||||
}
|
||||
config::Role::Authority { sentry_nodes } => {
|
||||
for sentry_node in sentry_nodes {
|
||||
default_sets_reserved.insert(sentry_node.peer_id.clone());
|
||||
known_addresses.push((sentry_node.peer_id.clone(), sentry_node.multiaddr.clone()));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
for reserved in network_config.default_peers_set.reserved_nodes.iter() {
|
||||
default_sets_reserved.insert(reserved.peer_id.clone());
|
||||
known_addresses.push((reserved.peer_id.clone(), reserved.multiaddr.clone()));
|
||||
|
||||
@@ -92,16 +92,16 @@ pub enum Event {
|
||||
|
||||
/// Role that the peer sent to us during the handshake, with the addition of what our local node
|
||||
/// knows about that peer.
|
||||
///
|
||||
/// > **Note**: This enum is different from the `Role` enum. The `Role` enum indicates what a
|
||||
/// > node says about itself, while `ObservedRole` is a `Role` merged with the
|
||||
/// > information known locally about that node.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ObservedRole {
|
||||
/// Full node.
|
||||
Full,
|
||||
/// Light node.
|
||||
Light,
|
||||
/// When we are a validator node, this is a sentry that protects us.
|
||||
OurSentry,
|
||||
/// When we are a sentry node, this is the authority we are protecting.
|
||||
OurGuardedAuthority,
|
||||
/// Third-party authority.
|
||||
Authority,
|
||||
}
|
||||
|
||||
@@ -191,7 +191,6 @@ pub mod generic {
|
||||
match roles {
|
||||
crate::config::Role::Full => Roles::FULL,
|
||||
crate::config::Role::Light => Roles::LIGHT,
|
||||
crate::config::Role::Sentry { .. } => Roles::AUTHORITY,
|
||||
crate::config::Role::Authority { .. } => Roles::AUTHORITY,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
use crate::{
|
||||
ExHashT, NetworkStateInfo, NetworkStatus,
|
||||
behaviour::{self, Behaviour, BehaviourOut},
|
||||
config::{parse_str_addr, Params, Role, TransportConfig},
|
||||
config::{parse_str_addr, Params, TransportConfig},
|
||||
DhtEvent,
|
||||
discovery::DiscoveryConfig,
|
||||
error::Error,
|
||||
@@ -225,22 +225,6 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkWorker<B, H> {
|
||||
}
|
||||
)?;
|
||||
|
||||
// Print a message about the deprecation of sentry nodes.
|
||||
let print_deprecated_message = match ¶ms.role {
|
||||
Role::Sentry { .. } => true,
|
||||
Role::Authority { sentry_nodes } if !sentry_nodes.is_empty() => true,
|
||||
_ => false,
|
||||
};
|
||||
if print_deprecated_message {
|
||||
log::warn!(
|
||||
"🙇 Sentry nodes are deprecated, and the `--sentry` and `--sentry-nodes` \
|
||||
CLI options will eventually be removed in a future version. The Substrate \
|
||||
and Polkadot networking protocol require validators to be \
|
||||
publicly-accessible. Please do not block access to your validator nodes. \
|
||||
For details, see https://github.com/paritytech/substrate/issues/6845."
|
||||
);
|
||||
}
|
||||
|
||||
let checker = params.on_demand.as_ref()
|
||||
.map(|od| od.checker().clone())
|
||||
.unwrap_or_else(|| Arc::new(AlwaysBadChecker));
|
||||
@@ -339,7 +323,6 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkWorker<B, H> {
|
||||
let bitswap = if params.network_config.ipfs_server { Some(Bitswap::new(client)) } else { None };
|
||||
let result = Behaviour::new(
|
||||
protocol,
|
||||
params.role,
|
||||
user_agent,
|
||||
local_public,
|
||||
light_client_request_sender,
|
||||
|
||||
Reference in New Issue
Block a user