diff --git a/substrate/bin/node-template/node/src/service.rs b/substrate/bin/node-template/node/src/service.rs index 4061dce438..f565156a64 100644 --- a/substrate/bin/node-template/node/src/service.rs +++ b/substrate/bin/node-template/node/src/service.rs @@ -224,7 +224,7 @@ pub fn new_full(mut config: Configuration) -> Result name: Some(name), observer_enabled: false, keystore, - is_authority: role.is_network_authority(), + is_authority: role.is_authority(), }; if enable_grandpa { diff --git a/substrate/bin/node/cli/src/service.rs b/substrate/bin/node/cli/src/service.rs index dcce31bd32..ca647c5834 100644 --- a/substrate/bin/node/cli/src/service.rs +++ b/substrate/bin/node/cli/src/service.rs @@ -312,7 +312,7 @@ pub fn new_full_base( name: Some(name), observer_enabled: false, keystore, - is_authority: role.is_network_authority(), + is_authority: role.is_authority(), }; if enable_grandpa { diff --git a/substrate/client/cli/src/commands/run_cmd.rs b/substrate/client/cli/src/commands/run_cmd.rs index bbb8d6f68d..bb6f77819d 100644 --- a/substrate/client/cli/src/commands/run_cmd.rs +++ b/substrate/client/cli/src/commands/run_cmd.rs @@ -27,7 +27,7 @@ use crate::params::TransactionPoolParams; use crate::CliConfiguration; use regex::Regex; use sc_service::{ - config::{BasePath, MultiaddrWithPeerId, PrometheusConfig, TransactionPoolOptions}, + config::{BasePath, PrometheusConfig, TransactionPoolOptions}, ChainSpec, Role, }; use sc_telemetry::TelemetryEndpoints; @@ -43,33 +43,16 @@ pub struct RunCmd { /// participate in any consensus task that it can (e.g. depending on /// availability of local keys). #[structopt( - long = "validator", - conflicts_with_all = &[ "sentry" ] + long = "validator" )] pub validator: bool, - /// Enable sentry mode. - /// - /// The node will be started with the authority role and participate in - /// consensus tasks as an "observer", it will never actively participate - /// regardless of whether it could (e.g. keys are available locally). This - /// mode is useful as a secure proxy for validators (which would run - /// detached from the network), since we want this node to participate in - /// the full consensus protocols in order to have all needed consensus data - /// available to relay to private nodes. - #[structopt( - long = "sentry", - conflicts_with_all = &[ "validator", "light" ], - parse(try_from_str) - )] - pub sentry: Vec, - /// Disable GRANDPA voter when running in validator mode, otherwise disable the GRANDPA observer. #[structopt(long)] pub no_grandpa: bool, /// Experimental: Run in light client mode. - #[structopt(long = "light", conflicts_with = "sentry")] + #[structopt(long = "light")] pub light: bool, /// Listen to all RPC interfaces. @@ -245,17 +228,6 @@ pub struct RunCmd { #[structopt(long)] pub max_runtime_instances: Option, - /// Specify a list of sentry node public addresses. - /// - /// Can't be used with --public-addr as the sentry node would take precedence over the public address - /// specified there. - #[structopt( - long = "sentry-nodes", - value_name = "ADDR", - conflicts_with_all = &[ "sentry", "public-addr" ] - )] - pub sentry_nodes: Vec, - /// Run a temporary node. /// /// A temporary directory will be created to store the configuration and will be deleted @@ -366,13 +338,7 @@ impl CliConfiguration for RunCmd { Ok(if is_light { sc_service::Role::Light } else if is_authority { - sc_service::Role::Authority { - sentry_nodes: self.sentry_nodes.clone(), - } - } else if !self.sentry.is_empty() { - sc_service::Role::Sentry { - validators: self.sentry.clone(), - } + sc_service::Role::Authority } else { sc_service::Role::Full }) diff --git a/substrate/client/cli/src/config.rs b/substrate/client/cli/src/config.rs index 247f6d2fdd..f81a64bf15 100644 --- a/substrate/client/cli/src/config.rs +++ b/substrate/client/cli/src/config.rs @@ -486,7 +486,7 @@ pub trait CliConfiguration: Sized { let node_key = self.node_key(&net_config_dir)?; let role = self.role(is_dev)?; let max_runtime_instances = self.max_runtime_instances()?.unwrap_or(8); - let is_validator = role.is_network_authority(); + let is_validator = role.is_authority(); let (keystore_remote, keystore) = self.keystore_config(&config_dir)?; let telemetry_endpoints = telemetry_handle .as_ref() diff --git a/substrate/client/cli/src/params/pruning_params.rs b/substrate/client/cli/src/params/pruning_params.rs index 467ca25353..987b8527e6 100644 --- a/substrate/client/cli/src/params/pruning_params.rs +++ b/substrate/client/cli/src/params/pruning_params.rs @@ -46,10 +46,10 @@ impl PruningParams { // unless `unsafe_pruning` is set. Ok(match &self.pruning { Some(ref s) if s == "archive" => PruningMode::ArchiveAll, - None if role.is_network_authority() => PruningMode::ArchiveAll, + None if role.is_authority() => PruningMode::ArchiveAll, None => PruningMode::default(), Some(s) => { - if role.is_network_authority() && !unsafe_pruning { + if role.is_authority() && !unsafe_pruning { return Err(error::Error::Input( "Validators should run with state pruning disabled (i.e. archive). \ You can ignore this check with `--unsafe-pruning`." diff --git a/substrate/client/finality-grandpa/src/communication/gossip.rs b/substrate/client/finality-grandpa/src/communication/gossip.rs index 1e616f3fa3..9f5582e5ce 100644 --- a/substrate/client/finality-grandpa/src/communication/gossip.rs +++ b/substrate/client/finality-grandpa/src/communication/gossip.rs @@ -563,12 +563,10 @@ impl Peers { } fn authorities(&self) -> usize { - // Note that our sentry and our validator are neither authorities nor non-authorities. self.inner.iter().filter(|(_, info)| matches!(info.roles, ObservedRole::Authority)).count() } fn non_authorities(&self) -> usize { - // Note that our sentry and our validator are neither authorities nor non-authorities. self.inner .iter() .filter(|(_, info)| matches!(info.roles, ObservedRole::Full | ObservedRole::Light)) @@ -665,8 +663,7 @@ impl CatchUpConfig { match self { CatchUpConfig::Disabled => false, CatchUpConfig::Enabled { only_from_authorities, .. } => match peer.roles { - ObservedRole::Authority | ObservedRole::OurSentry | - ObservedRole::OurGuardedAuthority => true, + ObservedRole::Authority => true, _ => !only_from_authorities } } @@ -1158,7 +1155,6 @@ impl Inner { } match peer.roles { - ObservedRole::OurGuardedAuthority | ObservedRole::OurSentry => true, ObservedRole::Authority => { let authorities = self.peers.authorities(); @@ -1214,7 +1210,6 @@ impl Inner { }; match peer.roles { - ObservedRole::OurSentry | ObservedRole::OurGuardedAuthority => true, ObservedRole::Authority => { let authorities = self.peers.authorities(); diff --git a/substrate/client/network/src/behaviour.rs b/substrate/client/network/src/behaviour.rs index 06c91de886..4a183e219f 100644 --- a/substrate/client/network/src/behaviour.rs +++ b/substrate/client/network/src/behaviour.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . 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 { #[behaviour(ignore)] events: VecDeque>, - /// 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, @@ -180,7 +176,6 @@ impl Behaviour { /// Builds a new `Behaviour`. pub fn new( substrate: Protocol, - role: Role, user_agent: String, local_public_key: PublicKey, light_client_request_sender: light_client_requests::sender::LightClientRequestSender, @@ -206,7 +201,6 @@ impl Behaviour { 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 Behaviour { } } -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 { ); }, 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(), }); }, diff --git a/substrate/client/network/src/block_request_handler.rs b/substrate/client/network/src/block_request_handler.rs index 92f21f44f9..8faa6a7f6c 100644 --- a/substrate/client/network/src/block_request_handler.rs +++ b/substrate/client/network/src/block_request_handler.rs @@ -72,7 +72,7 @@ impl BlockRequestHandler { pub fn new(protocol_id: &ProtocolId, client: Arc>) -> (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. // diff --git a/substrate/client/network/src/config.rs b/substrate/client/network/src/config.rs index 5a2327dda1..7f8cac95f9 100644 --- a/substrate/client/network/src/config.rs +++ b/substrate/client/network/src/config.rs @@ -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, - }, /// Actual authority. - Authority { - /// List of public addresses and identities of our sentry nodes. - sentry_nodes: Vec, - } + 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"), } } diff --git a/substrate/client/network/src/protocol.rs b/substrate/client/network/src/protocol.rs index 4997bc36e5..acb5d9101e 100644 --- a/substrate/client/network/src/protocol.rs +++ b/substrate/client/network/src/protocol.rs @@ -384,21 +384,6 @@ impl Protocol { 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())); diff --git a/substrate/client/network/src/protocol/event.rs b/substrate/client/network/src/protocol/event.rs index e20dbcb9ee..fb2e3b33dd 100644 --- a/substrate/client/network/src/protocol/event.rs +++ b/substrate/client/network/src/protocol/event.rs @@ -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, } diff --git a/substrate/client/network/src/protocol/message.rs b/substrate/client/network/src/protocol/message.rs index 3161f91e53..ed27210328 100644 --- a/substrate/client/network/src/protocol/message.rs +++ b/substrate/client/network/src/protocol/message.rs @@ -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, } } diff --git a/substrate/client/network/src/service.rs b/substrate/client/network/src/service.rs index 39eaa606d0..9ac7483467 100644 --- a/substrate/client/network/src/service.rs +++ b/substrate/client/network/src/service.rs @@ -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 NetworkWorker { } )?; - // 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 NetworkWorker { 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, diff --git a/substrate/client/rpc-api/src/system/helpers.rs b/substrate/client/rpc-api/src/system/helpers.rs index b2b793a8ee..c2fc807471 100644 --- a/substrate/client/rpc-api/src/system/helpers.rs +++ b/substrate/client/rpc-api/src/system/helpers.rs @@ -82,8 +82,6 @@ pub enum NodeRole { LightClient, /// The node is an authority Authority, - /// The node is a sentry - Sentry, } /// The state of the syncing of the node. diff --git a/substrate/client/service/src/lib.rs b/substrate/client/service/src/lib.rs index 4880b8cffd..39bad8f2f3 100644 --- a/substrate/client/service/src/lib.rs +++ b/substrate/client/service/src/lib.rs @@ -309,7 +309,6 @@ async fn build_network_future< Role::Authority { .. } => NodeRole::Authority, Role::Light => NodeRole::LightClient, Role::Full => NodeRole::Full, - Role::Sentry { .. } => NodeRole::Sentry, }; let _ = sender.send(vec![node_role]); diff --git a/substrate/client/service/src/metrics.rs b/substrate/client/service/src/metrics.rs index 446cce9527..4fbfa4d77f 100644 --- a/substrate/client/service/src/metrics.rs +++ b/substrate/client/service/src/metrics.rs @@ -135,7 +135,6 @@ impl MetricsService { let role_bits = match config.role { Role::Full => 1u64, Role::Light => 2u64, - Role::Sentry { .. } => 3u64, Role::Authority { .. } => 4u64, }; diff --git a/substrate/client/service/test/src/lib.rs b/substrate/client/service/test/src/lib.rs index a42dba84df..d286c945f0 100644 --- a/substrate/client/service/test/src/lib.rs +++ b/substrate/client/service/test/src/lib.rs @@ -337,7 +337,7 @@ impl TestNet where let node_config = node_config( self.nodes, &self.chain_spec, - Role::Authority { sentry_nodes: Vec::new() }, + Role::Authority, task_executor.clone(), Some(key), self.base_port,