mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 11:51:12 +00:00
Remove all code related to sentry nodes (#8079)
* Remove all code related to sentry nodes * More fixing
This commit is contained in:
@@ -224,7 +224,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
||||
name: Some(name),
|
||||
observer_enabled: false,
|
||||
keystore,
|
||||
is_authority: role.is_network_authority(),
|
||||
is_authority: role.is_authority(),
|
||||
};
|
||||
|
||||
if enable_grandpa {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<MultiaddrWithPeerId>,
|
||||
|
||||
/// 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<usize>,
|
||||
|
||||
/// 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<MultiaddrWithPeerId>,
|
||||
|
||||
/// 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
|
||||
})
|
||||
|
||||
@@ -486,7 +486,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: 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()
|
||||
|
||||
@@ -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`."
|
||||
|
||||
@@ -563,12 +563,10 @@ impl<N: Ord> Peers<N> {
|
||||
}
|
||||
|
||||
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<Block: BlockT> Inner<Block> {
|
||||
}
|
||||
|
||||
match peer.roles {
|
||||
ObservedRole::OurGuardedAuthority | ObservedRole::OurSentry => true,
|
||||
ObservedRole::Authority => {
|
||||
let authorities = self.peers.authorities();
|
||||
|
||||
@@ -1214,7 +1210,6 @@ impl<Block: BlockT> Inner<Block> {
|
||||
};
|
||||
|
||||
match peer.roles {
|
||||
ObservedRole::OurSentry | ObservedRole::OurGuardedAuthority => true,
|
||||
ObservedRole::Authority => {
|
||||
let authorities = self.peers.authorities();
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -135,7 +135,6 @@ impl MetricsService {
|
||||
let role_bits = match config.role {
|
||||
Role::Full => 1u64,
|
||||
Role::Light => 2u64,
|
||||
Role::Sentry { .. } => 3u64,
|
||||
Role::Authority { .. } => 4u64,
|
||||
};
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ impl<G, E, F, L, U> TestNet<G, E, F, L, U> 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,
|
||||
|
||||
Reference in New Issue
Block a user