Remove superflous parameter overseer_enable_anyways and make parachain node type more explicit (#7617)

* Remove superflous parameter `overseer_enable_anyways`

We don't need this flag, as we don't need the overseer enabled when the
node isn't a collator or validator.

* Rename `IsCollator` to `IsParachainNode`

`IsParachainNode` is more expressive and also encapsulates the state of
the parachain node being a full node. Some functionality like the
overseer needs to run always when the node runs alongside a parachain
node. The parachain node needs the overseer to e.g. recover PoVs. Other
things like candidate validation or pvf checking are only required for
when the node is running as validator.

* FMT

* Fix CI
This commit is contained in:
Bastian Köcher
2023-08-15 10:51:27 +02:00
committed by GitHub
parent e9c6c72f5a
commit cf3271fea2
16 changed files with 148 additions and 130 deletions
+1 -2
View File
@@ -287,14 +287,13 @@ where
let task_manager = service::build_full( let task_manager = service::build_full(
config, config,
service::NewFullParams { service::NewFullParams {
is_collator: service::IsCollator::No, is_parachain_node: service::IsParachainNode::No,
grandpa_pause, grandpa_pause,
jaeger_agent, jaeger_agent,
telemetry_worker_handle: None, telemetry_worker_handle: None,
node_version, node_version,
workers_path: cli.run.workers_path, workers_path: cli.run.workers_path,
workers_names: None, workers_names: None,
overseer_enable_anyways: false,
overseer_gen, overseer_gen,
overseer_message_channel_capacity_override: cli overseer_message_channel_capacity_override: cli
.run .run
@@ -2253,7 +2253,7 @@ where
// //
// 1. This is not a local approval, as we don't store anything new in the approval entry. // 1. This is not a local approval, as we don't store anything new in the approval entry.
// 2. The candidate is not newly approved, as we haven't altered the approval entry's // 2. The candidate is not newly approved, as we haven't altered the approval entry's
// approved flag with `mark_approved` above. // approved flag with `mark_approved` above.
// 3. The approver, if any, had already approved the candidate, as we haven't altered the // 3. The approver, if any, had already approved the candidate, as we haven't altered the
// bitfield. // bitfield.
if transition.is_local_approval() || newly_approved || !already_approved_by.unwrap_or(true) if transition.is_local_approval() || newly_approved || !already_approved_by.unwrap_or(true)
@@ -55,8 +55,8 @@ use tokio::{io, net::UnixStream};
// //
// There are quirks to that configuration knob: // There are quirks to that configuration knob:
// //
// 1. It only limits the amount of stack space consumed by wasm but does not ensure nor check // 1. It only limits the amount of stack space consumed by wasm but does not ensure nor check that
// that the stack space is actually available. // the stack space is actually available.
// //
// That means, if the calling thread has 1 MiB of stack space left and the wasm code consumes // That means, if the calling thread has 1 MiB of stack space left and the wasm code consumes
// more, then the wasmtime limit will **not** trigger. Instead, the wasm code will hit the // more, then the wasmtime limit will **not** trigger. Instead, the wasm code will hit the
@@ -1319,13 +1319,13 @@ impl State {
} }
// Here we're leaning on a few behaviors of assignment propagation: // Here we're leaning on a few behaviors of assignment propagation:
// 1. At this point, the only peer we're aware of which has the approval // 1. At this point, the only peer we're aware of which has the approval message is
// message is the source peer. // the source peer.
// 2. We have sent the assignment message to every peer in the required routing // 2. We have sent the assignment message to every peer in the required routing which
// which is aware of this block _unless_ the peer we originally received the // is aware of this block _unless_ the peer we originally received the assignment
// assignment from was part of the required routing. In that case, we've sent // from was part of the required routing. In that case, we've sent the assignment
// the assignment to all aware peers in the required routing _except_ the original // to all aware peers in the required routing _except_ the original source of the
// source of the assignment. Hence the `in_topology_check`. // assignment. Hence the `in_topology_check`.
// 3. Any randomly selected peers have been sent the assignment already. // 3. Any randomly selected peers have been sent the assignment already.
let in_topology = topology let in_topology = topology
.map_or(false, |t| t.local_grid_neighbors().route_to_peer(required_routing, peer)); .map_or(false, |t| t.local_grid_neighbors().route_to_peer(required_routing, peer));
@@ -463,8 +463,8 @@ fn delay_reputation_change() {
/// <https://github.com/paritytech/polkadot/pull/2160#discussion_r547594835> /// <https://github.com/paritytech/polkadot/pull/2160#discussion_r547594835>
/// ///
/// 1. Send a view update that removes block B from their view. /// 1. Send a view update that removes block B from their view.
/// 2. Send a message from B that they incur `COST_UNEXPECTED_MESSAGE` for, /// 2. Send a message from B that they incur `COST_UNEXPECTED_MESSAGE` for, but then they receive
/// but then they receive `BENEFIT_VALID_MESSAGE`. /// `BENEFIT_VALID_MESSAGE`.
/// 3. Send all other messages related to B. /// 3. Send all other messages related to B.
#[test] #[test]
fn spam_attack_results_in_negative_reputation_change() { fn spam_attack_results_in_negative_reputation_change() {
@@ -37,7 +37,7 @@ use polkadot_node_network_protocol::{
}; };
use polkadot_primitives::CollatorPair; use polkadot_primitives::CollatorPair;
use polkadot_node_subsystem::{errors::SubsystemError, overseer, SpawnedSubsystem}; use polkadot_node_subsystem::{errors::SubsystemError, overseer, DummySubsystem, SpawnedSubsystem};
mod error; mod error;
@@ -82,6 +82,8 @@ pub enum ProtocolSide {
IncomingRequestReceiver<request_v1::CollationFetchingRequest>, IncomingRequestReceiver<request_v1::CollationFetchingRequest>,
collator_side::Metrics, collator_side::Metrics,
), ),
/// No protocol side, just disable it.
None,
} }
/// The collator protocol subsystem. /// The collator protocol subsystem.
@@ -98,24 +100,22 @@ impl CollatorProtocolSubsystem {
pub fn new(protocol_side: ProtocolSide) -> Self { pub fn new(protocol_side: ProtocolSide) -> Self {
Self { protocol_side } Self { protocol_side }
} }
async fn run<Context>(self, ctx: Context) -> std::result::Result<(), error::FatalError> {
match self.protocol_side {
ProtocolSide::Validator { keystore, eviction_policy, metrics } =>
validator_side::run(ctx, keystore, eviction_policy, metrics).await,
ProtocolSide::Collator(local_peer_id, collator_pair, req_receiver, metrics) =>
collator_side::run(ctx, local_peer_id, collator_pair, req_receiver, metrics).await,
}
}
} }
#[overseer::subsystem(CollatorProtocol, error=SubsystemError, prefix=self::overseer)] #[overseer::subsystem(CollatorProtocol, error=SubsystemError, prefix=self::overseer)]
impl<Context> CollatorProtocolSubsystem { impl<Context> CollatorProtocolSubsystem {
fn start(self, ctx: Context) -> SpawnedSubsystem { fn start(self, ctx: Context) -> SpawnedSubsystem {
let future = self let future = match self.protocol_side {
.run(ctx) ProtocolSide::Validator { keystore, eviction_policy, metrics } =>
.map_err(|e| SubsystemError::with_origin("collator-protocol", e)) validator_side::run(ctx, keystore, eviction_policy, metrics)
.boxed(); .map_err(|e| SubsystemError::with_origin("collator-protocol", e))
.boxed(),
ProtocolSide::Collator(local_peer_id, collator_pair, req_receiver, metrics) =>
collator_side::run(ctx, local_peer_id, collator_pair, req_receiver, metrics)
.map_err(|e| SubsystemError::with_origin("collator-protocol", e))
.boxed(),
ProtocolSide::None => return DummySubsystem.start(ctx),
};
SpawnedSubsystem { name: "collator-protocol-subsystem", future } SpawnedSubsystem { name: "collator-protocol-subsystem", future }
} }
@@ -183,8 +183,7 @@ where
} }
/// 1. Determine if the current session index has changed. /// 1. Determine if the current session index has changed.
/// 2. If it has, determine relevant validators /// 2. If it has, determine relevant validators and issue a connection request.
/// and issue a connection request.
async fn handle_active_leaves( async fn handle_active_leaves(
&mut self, &mut self,
sender: &mut impl overseer::GossipSupportSenderTrait, sender: &mut impl overseer::GossipSupportSenderTrait,
@@ -62,8 +62,8 @@ pub async fn respond(
// //
// 1. We want some requesters to have full data fast, rather then lots of them having them // 1. We want some requesters to have full data fast, rather then lots of them having them
// late, as each requester having the data will help distributing it. // late, as each requester having the data will help distributing it.
// 2. If we take too long, the requests timing out will not yet have had any data sent, // 2. If we take too long, the requests timing out will not yet have had any data sent, thus
// thus we wasted no bandwidth. // we wasted no bandwidth.
// 3. If the queue is full, requestes will get an immediate error instead of running in a // 3. If the queue is full, requestes will get an immediate error instead of running in a
// timeout, thus requesters can immediately try another peer and be faster. // timeout, thus requesters can immediately try another peer and be faster.
// //
+79 -67
View File
@@ -627,7 +627,7 @@ where
#[cfg(feature = "full-node")] #[cfg(feature = "full-node")]
pub struct NewFullParams<OverseerGenerator: OverseerGen> { pub struct NewFullParams<OverseerGenerator: OverseerGen> {
pub is_collator: IsCollator, pub is_parachain_node: IsParachainNode,
pub grandpa_pause: Option<(u32, u32)>, pub grandpa_pause: Option<(u32, u32)>,
pub jaeger_agent: Option<std::net::SocketAddr>, pub jaeger_agent: Option<std::net::SocketAddr>,
pub telemetry_worker_handle: Option<TelemetryWorkerHandle>, pub telemetry_worker_handle: Option<TelemetryWorkerHandle>,
@@ -638,7 +638,6 @@ pub struct NewFullParams<OverseerGenerator: OverseerGen> {
pub workers_path: Option<std::path::PathBuf>, pub workers_path: Option<std::path::PathBuf>,
/// Optional custom names for the prepare and execute workers. /// Optional custom names for the prepare and execute workers.
pub workers_names: Option<(String, String)>, pub workers_names: Option<(String, String)>,
pub overseer_enable_anyways: bool,
pub overseer_gen: OverseerGenerator, pub overseer_gen: OverseerGenerator,
pub overseer_message_channel_capacity_override: Option<usize>, pub overseer_message_channel_capacity_override: Option<usize>,
#[allow(dead_code)] #[allow(dead_code)]
@@ -657,32 +656,46 @@ pub struct NewFull {
pub backend: Arc<FullBackend>, pub backend: Arc<FullBackend>,
} }
/// Is this node a collator? /// Is this node running as in-process node for a parachain node?
#[cfg(feature = "full-node")] #[cfg(feature = "full-node")]
#[derive(Clone)] #[derive(Clone)]
pub enum IsCollator { pub enum IsParachainNode {
/// This node is a collator. /// This node is running as in-process node for a parachain collator.
Yes(CollatorPair), Collator(CollatorPair),
/// This node is not a collator. /// This node is running as in-process node for a parachain full node.
FullNode,
/// This node is not running as in-process node for a parachain node, aka a normal relay chain
/// node.
No, No,
} }
#[cfg(feature = "full-node")] #[cfg(feature = "full-node")]
impl std::fmt::Debug for IsCollator { impl std::fmt::Debug for IsParachainNode {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
use sp_core::Pair; use sp_core::Pair;
match self { match self {
IsCollator::Yes(pair) => write!(fmt, "Yes({})", pair.public()), IsParachainNode::Collator(pair) => write!(fmt, "Collator({})", pair.public()),
IsCollator::No => write!(fmt, "No"), IsParachainNode::FullNode => write!(fmt, "FullNode"),
IsParachainNode::No => write!(fmt, "No"),
} }
} }
} }
#[cfg(feature = "full-node")] #[cfg(feature = "full-node")]
impl IsCollator { impl IsParachainNode {
/// Is this a collator? /// Is this running alongside a collator?
fn is_collator(&self) -> bool { fn is_collator(&self) -> bool {
matches!(self, Self::Yes(_)) matches!(self, Self::Collator(_))
}
/// Is this running alongside a full node?
fn is_full_node(&self) -> bool {
matches!(self, Self::FullNode)
}
/// Is this node running alongside a relay chain node?
fn is_running_alongside_parachain_node(&self) -> bool {
self.is_collator() || self.is_full_node()
} }
} }
@@ -696,11 +709,6 @@ pub const AVAILABILITY_CONFIG: AvailabilityConfig = AvailabilityConfig {
/// This is an advanced feature and not recommended for general use. Generally, `build_full` is /// This is an advanced feature and not recommended for general use. Generally, `build_full` is
/// a better choice. /// a better choice.
/// ///
/// `overseer_enable_anyways` always enables the overseer, based on the provided
/// `OverseerGenerator`, regardless of the role the node has. The relay chain selection (longest or
/// disputes-aware) is still determined based on the role of the node. Likewise for authority
/// discovery.
///
/// `workers_path` is used to get the path to the directory where auxiliary worker binaries reside. /// `workers_path` is used to get the path to the directory where auxiliary worker binaries reside.
/// If not specified, the main binary's directory is searched first, then `/usr/lib/polkadot` is /// If not specified, the main binary's directory is searched first, then `/usr/lib/polkadot` is
/// searched. If the path points to an executable rather then directory, that executable is used /// searched. If the path points to an executable rather then directory, that executable is used
@@ -709,14 +717,13 @@ pub const AVAILABILITY_CONFIG: AvailabilityConfig = AvailabilityConfig {
pub fn new_full<OverseerGenerator: OverseerGen>( pub fn new_full<OverseerGenerator: OverseerGen>(
mut config: Configuration, mut config: Configuration,
NewFullParams { NewFullParams {
is_collator, is_parachain_node,
grandpa_pause, grandpa_pause,
jaeger_agent, jaeger_agent,
telemetry_worker_handle, telemetry_worker_handle,
node_version, node_version,
workers_path, workers_path,
workers_names, workers_names,
overseer_enable_anyways,
overseer_gen, overseer_gen,
overseer_message_channel_capacity_override, overseer_message_channel_capacity_override,
malus_finality_delay: _malus_finality_delay, malus_finality_delay: _malus_finality_delay,
@@ -768,8 +775,9 @@ pub fn new_full<OverseerGenerator: OverseerGen>(
let chain_spec = config.chain_spec.cloned_box(); let chain_spec = config.chain_spec.cloned_box();
let keystore = basics.keystore_container.local_keystore(); let keystore = basics.keystore_container.local_keystore();
let auth_or_collator = role.is_authority() || is_collator.is_collator(); let auth_or_collator = role.is_authority() || is_parachain_node.is_collator();
let pvf_checker_enabled = role.is_authority() && !is_collator.is_collator(); // We only need to enable the pvf checker when this is a validator.
let pvf_checker_enabled = role.is_authority();
let select_chain = if auth_or_collator { let select_chain = if auth_or_collator {
let metrics = let metrics =
@@ -832,7 +840,12 @@ pub fn new_full<OverseerGenerator: OverseerGen>(
let peerset_protocol_names = let peerset_protocol_names =
PeerSetProtocolNames::new(genesis_hash, config.chain_spec.fork_id()); PeerSetProtocolNames::new(genesis_hash, config.chain_spec.fork_id());
if auth_or_collator || overseer_enable_anyways { // If this is a validator or running alongside a parachain node, we need to enable the
// networking protocols.
//
// Collators and parachain full nodes require the collator and validator networking to send
// collations and to be able to recover PoVs.
if role.is_authority() || is_parachain_node.is_running_alongside_parachain_node() {
use polkadot_network_bridge::{peer_sets_info, IsAuthority}; use polkadot_network_bridge::{peer_sets_info, IsAuthority};
let is_authority = if role.is_authority() { IsAuthority::Yes } else { IsAuthority::No }; let is_authority = if role.is_authority() { IsAuthority::Yes } else { IsAuthority::No };
for config in peer_sets_info(is_authority, &peerset_protocol_names) { for config in peer_sets_info(is_authority, &peerset_protocol_names) {
@@ -910,7 +923,7 @@ pub fn new_full<OverseerGenerator: OverseerGen>(
slot_duration_millis: slot_duration.as_millis() as u64, slot_duration_millis: slot_duration.as_millis() as u64,
}; };
let candidate_validation_config = if role.is_authority() && !is_collator.is_collator() { let candidate_validation_config = if role.is_authority() {
let (prep_worker_path, exec_worker_path) = let (prep_worker_path, exec_worker_path) =
workers::determine_workers_paths(workers_path, workers_names, node_version.clone())?; workers::determine_workers_paths(workers_path, workers_names, node_version.clone())?;
log::info!("🚀 Using prepare-worker binary at: {:?}", prep_worker_path); log::info!("🚀 Using prepare-worker binary at: {:?}", prep_worker_path);
@@ -979,46 +992,50 @@ pub fn new_full<OverseerGenerator: OverseerGen>(
let overseer_client = client.clone(); let overseer_client = client.clone();
let spawner = task_manager.spawn_handle(); let spawner = task_manager.spawn_handle();
let authority_discovery_service = if auth_or_collator || overseer_enable_anyways { let authority_discovery_service =
use futures::StreamExt; // We need the authority discovery if this node is either a validator or running alongside a parachain node.
use sc_network::{Event, NetworkEventStream}; // Parachains node require the authority discovery for finding relay chain validators for sending
// their PoVs or recovering PoVs.
if role.is_authority() || is_parachain_node.is_running_alongside_parachain_node() {
use futures::StreamExt;
use sc_network::{Event, NetworkEventStream};
let authority_discovery_role = if role.is_authority() { let authority_discovery_role = if role.is_authority() {
sc_authority_discovery::Role::PublishAndDiscover(keystore_container.keystore()) sc_authority_discovery::Role::PublishAndDiscover(keystore_container.keystore())
} else {
// don't publish our addresses when we're not an authority (collator, cumulus, ..)
sc_authority_discovery::Role::Discover
};
let dht_event_stream =
network.event_stream("authority-discovery").filter_map(|e| async move {
match e {
Event::Dht(e) => Some(e),
_ => None,
}
});
let (worker, service) = sc_authority_discovery::new_worker_and_service_with_config(
sc_authority_discovery::WorkerConfig {
publish_non_global_ips: auth_disc_publish_non_global_ips,
// Require that authority discovery records are signed.
strict_record_validation: true,
..Default::default()
},
client.clone(),
network.clone(),
Box::pin(dht_event_stream),
authority_discovery_role,
prometheus_registry.clone(),
);
task_manager.spawn_handle().spawn(
"authority-discovery-worker",
Some("authority-discovery"),
Box::pin(worker.run()),
);
Some(service)
} else { } else {
// don't publish our addresses when we're not an authority (collator, cumulus, ..) None
sc_authority_discovery::Role::Discover
}; };
let dht_event_stream =
network.event_stream("authority-discovery").filter_map(|e| async move {
match e {
Event::Dht(e) => Some(e),
_ => None,
}
});
let (worker, service) = sc_authority_discovery::new_worker_and_service_with_config(
sc_authority_discovery::WorkerConfig {
publish_non_global_ips: auth_disc_publish_non_global_ips,
// Require that authority discovery records are signed.
strict_record_validation: true,
..Default::default()
},
client.clone(),
network.clone(),
Box::pin(dht_event_stream),
authority_discovery_role,
prometheus_registry.clone(),
);
task_manager.spawn_handle().spawn(
"authority-discovery-worker",
Some("authority-discovery"),
Box::pin(worker.run()),
);
Some(service)
} else {
None
};
let overseer_handle = if let Some(authority_discovery_service) = authority_discovery_service { let overseer_handle = if let Some(authority_discovery_service) = authority_discovery_service {
let (overseer, overseer_handle) = overseer_gen let (overseer, overseer_handle) = overseer_gen
@@ -1039,7 +1056,7 @@ pub fn new_full<OverseerGenerator: OverseerGen>(
dispute_req_receiver, dispute_req_receiver,
registry: prometheus_registry.as_ref(), registry: prometheus_registry.as_ref(),
spawner, spawner,
is_collator, is_parachain_node,
approval_voting_config, approval_voting_config,
availability_config: AVAILABILITY_CONFIG, availability_config: AVAILABILITY_CONFIG,
candidate_validation_config, candidate_validation_config,
@@ -1332,11 +1349,6 @@ pub fn new_chain_ops(
/// ///
/// The actual "flavor", aka if it will use `Polkadot`, `Rococo` or `Kusama` is determined based on /// The actual "flavor", aka if it will use `Polkadot`, `Rococo` or `Kusama` is determined based on
/// [`IdentifyVariant`] using the chain spec. /// [`IdentifyVariant`] using the chain spec.
///
/// `overseer_enable_anyways` always enables the overseer, based on the provided
/// `OverseerGenerator`, regardless of the role the node has. The relay chain selection (longest or
/// disputes-aware) is still determined based on the role of the node. Likewise for authority
/// discovery.
#[cfg(feature = "full-node")] #[cfg(feature = "full-node")]
pub fn build_full<OverseerGenerator: OverseerGen>( pub fn build_full<OverseerGenerator: OverseerGen>(
config: Configuration, config: Configuration,
+7 -6
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. // along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use super::{AuthorityDiscoveryApi, Block, Error, Hash, IsCollator, Registry}; use super::{AuthorityDiscoveryApi, Block, Error, Hash, IsParachainNode, Registry};
use polkadot_node_subsystem_types::DefaultSubsystemClient; use polkadot_node_subsystem_types::DefaultSubsystemClient;
use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_core::traits::SpawnNamed; use sp_core::traits::SpawnNamed;
@@ -108,7 +108,7 @@ where
/// Task spawner to be used throughout the overseer and the APIs it provides. /// Task spawner to be used throughout the overseer and the APIs it provides.
pub spawner: Spawner, pub spawner: Spawner,
/// Determines the behavior of the collator. /// Determines the behavior of the collator.
pub is_collator: IsCollator, pub is_parachain_node: IsParachainNode,
/// Configuration for the approval voting subsystem. /// Configuration for the approval voting subsystem.
pub approval_voting_config: ApprovalVotingConfig, pub approval_voting_config: ApprovalVotingConfig,
/// Configuration for the availability store subsystem. /// Configuration for the availability store subsystem.
@@ -149,7 +149,7 @@ pub fn prepared_overseer_builder<Spawner, RuntimeClient>(
dispute_req_receiver, dispute_req_receiver,
registry, registry,
spawner, spawner,
is_collator, is_parachain_node,
approval_voting_config, approval_voting_config,
availability_config, availability_config,
candidate_validation_config, candidate_validation_config,
@@ -266,14 +266,15 @@ where
.chain_api(ChainApiSubsystem::new(runtime_client.clone(), Metrics::register(registry)?)) .chain_api(ChainApiSubsystem::new(runtime_client.clone(), Metrics::register(registry)?))
.collation_generation(CollationGenerationSubsystem::new(Metrics::register(registry)?)) .collation_generation(CollationGenerationSubsystem::new(Metrics::register(registry)?))
.collator_protocol({ .collator_protocol({
let side = match is_collator { let side = match is_parachain_node {
IsCollator::Yes(collator_pair) => ProtocolSide::Collator( IsParachainNode::Collator(collator_pair) => ProtocolSide::Collator(
network_service.local_peer_id(), network_service.local_peer_id(),
collator_pair, collator_pair,
collation_req_receiver, collation_req_receiver,
Metrics::register(registry)?, Metrics::register(registry)?,
), ),
IsCollator::No => ProtocolSide::Validator { IsParachainNode::FullNode => ProtocolSide::None,
IsParachainNode::No => ProtocolSide::Validator {
keystore: keystore.clone(), keystore: keystore.clone(),
eviction_policy: Default::default(), eviction_policy: Default::default(),
metrics: Metrics::register(registry)?, metrics: Metrics::register(registry)?,
+5 -6
View File
@@ -28,7 +28,7 @@ use polkadot_overseer::Handle;
use polkadot_primitives::{Balance, CollatorPair, HeadData, Id as ParaId, ValidationCode}; use polkadot_primitives::{Balance, CollatorPair, HeadData, Id as ParaId, ValidationCode};
use polkadot_runtime_common::BlockHashCount; use polkadot_runtime_common::BlockHashCount;
use polkadot_runtime_parachains::paras::{ParaGenesisArgs, ParaKind}; use polkadot_runtime_parachains::paras::{ParaGenesisArgs, ParaKind};
use polkadot_service::{Error, FullClient, IsCollator, NewFull, PrometheusConfig}; use polkadot_service::{Error, FullClient, IsParachainNode, NewFull, PrometheusConfig};
use polkadot_test_runtime::{ use polkadot_test_runtime::{
ParasCall, ParasSudoWrapperCall, Runtime, SignedExtra, SignedPayload, SudoCall, ParasCall, ParasSudoWrapperCall, Runtime, SignedExtra, SignedPayload, SudoCall,
UncheckedExtrinsic, VERSION, UncheckedExtrinsic, VERSION,
@@ -71,7 +71,7 @@ pub use polkadot_service::{FullBackend, GetLastTimestamp};
#[sc_tracing::logging::prefix_logs_with(config.network.node_name.as_str())] #[sc_tracing::logging::prefix_logs_with(config.network.node_name.as_str())]
pub fn new_full( pub fn new_full(
config: Configuration, config: Configuration,
is_collator: IsCollator, is_parachain_node: IsParachainNode,
workers_path: Option<PathBuf>, workers_path: Option<PathBuf>,
) -> Result<NewFull, Error> { ) -> Result<NewFull, Error> {
let workers_path = Some(workers_path.unwrap_or_else(get_relative_workers_path_for_test)); let workers_path = Some(workers_path.unwrap_or_else(get_relative_workers_path_for_test));
@@ -79,14 +79,13 @@ pub fn new_full(
polkadot_service::new_full( polkadot_service::new_full(
config, config,
polkadot_service::NewFullParams { polkadot_service::NewFullParams {
is_collator, is_parachain_node,
grandpa_pause: None, grandpa_pause: None,
jaeger_agent: None, jaeger_agent: None,
telemetry_worker_handle: None, telemetry_worker_handle: None,
node_version: None, node_version: None,
workers_path, workers_path,
workers_names: None, workers_names: None,
overseer_enable_anyways: false,
overseer_gen: polkadot_service::RealOverseerGen, overseer_gen: polkadot_service::RealOverseerGen,
overseer_message_channel_capacity_override: None, overseer_message_channel_capacity_override: None,
malus_finality_delay: None, malus_finality_delay: None,
@@ -207,7 +206,7 @@ pub fn run_validator_node(
) -> PolkadotTestNode { ) -> PolkadotTestNode {
let multiaddr = config.network.listen_addresses[0].clone(); let multiaddr = config.network.listen_addresses[0].clone();
let NewFull { task_manager, client, network, rpc_handlers, overseer_handle, .. } = let NewFull { task_manager, client, network, rpc_handlers, overseer_handle, .. } =
new_full(config, IsCollator::No, worker_program_path) new_full(config, IsParachainNode::No, worker_program_path)
.expect("could not create Polkadot test service"); .expect("could not create Polkadot test service");
let overseer_handle = overseer_handle.expect("test node must have an overseer handle"); let overseer_handle = overseer_handle.expect("test node must have an overseer handle");
@@ -239,7 +238,7 @@ pub fn run_collator_node(
let config = node_config(storage_update_func, tokio_handle, key, boot_nodes, false); let config = node_config(storage_update_func, tokio_handle, key, boot_nodes, false);
let multiaddr = config.network.listen_addresses[0].clone(); let multiaddr = config.network.listen_addresses[0].clone();
let NewFull { task_manager, client, network, rpc_handlers, overseer_handle, .. } = let NewFull { task_manager, client, network, rpc_handlers, overseer_handle, .. } =
new_full(config, IsCollator::Yes(collator_pair), None) new_full(config, IsParachainNode::Collator(collator_pair), None)
.expect("could not create Polkadot test service"); .expect("could not create Polkadot test service");
let overseer_handle = overseer_handle.expect("test node must have an overseer handle"); let overseer_handle = overseer_handle.expect("test node must have an overseer handle");
@@ -21,6 +21,7 @@ use polkadot_node_primitives::CollationGenerationConfig;
use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage}; use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage};
use polkadot_primitives::Id as ParaId; use polkadot_primitives::Id as ParaId;
use sc_cli::{Error as SubstrateCliError, SubstrateCli}; use sc_cli::{Error as SubstrateCliError, SubstrateCli};
use sc_service::Role;
use sp_core::hexdisplay::HexDisplay; use sp_core::hexdisplay::HexDisplay;
use test_parachain_adder_collator::Collator; use test_parachain_adder_collator::Collator;
@@ -57,10 +58,15 @@ fn main() -> Result<()> {
let collator = Collator::new(); let collator = Collator::new();
config.disable_beefy = true; config.disable_beefy = true;
// Zombienet is spawning all collators currently with the same CLI, this means it
// sets `--validator` and this is wrong here.
config.role = Role::Full;
let full_node = polkadot_service::build_full( let full_node = polkadot_service::build_full(
config, config,
polkadot_service::NewFullParams { polkadot_service::NewFullParams {
is_collator: polkadot_service::IsCollator::Yes(collator.collator_key()), is_parachain_node: polkadot_service::IsParachainNode::Collator(
collator.collator_key(),
),
grandpa_pause: None, grandpa_pause: None,
jaeger_agent: None, jaeger_agent: None,
telemetry_worker_handle: None, telemetry_worker_handle: None,
@@ -70,7 +76,6 @@ fn main() -> Result<()> {
workers_path: None, workers_path: None,
workers_names: None, workers_names: None,
overseer_enable_anyways: false,
overseer_gen: polkadot_service::RealOverseerGen, overseer_gen: polkadot_service::RealOverseerGen,
overseer_message_channel_capacity_override: None, overseer_message_channel_capacity_override: None,
malus_finality_delay: None, malus_finality_delay: None,
@@ -21,6 +21,7 @@ use polkadot_node_primitives::CollationGenerationConfig;
use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage}; use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage};
use polkadot_primitives::Id as ParaId; use polkadot_primitives::Id as ParaId;
use sc_cli::{Error as SubstrateCliError, SubstrateCli}; use sc_cli::{Error as SubstrateCliError, SubstrateCli};
use sc_service::Role;
use sp_core::hexdisplay::HexDisplay; use sp_core::hexdisplay::HexDisplay;
use test_parachain_undying_collator::Collator; use test_parachain_undying_collator::Collator;
@@ -57,10 +58,15 @@ fn main() -> Result<()> {
let collator = Collator::new(cli.run.pov_size, cli.run.pvf_complexity); let collator = Collator::new(cli.run.pov_size, cli.run.pvf_complexity);
config.disable_beefy = true; config.disable_beefy = true;
// Zombienet is spawning all collators currently with the same CLI, this means it
// sets `--validator` and this is wrong here.
config.role = Role::Full;
let full_node = polkadot_service::build_full( let full_node = polkadot_service::build_full(
config, config,
polkadot_service::NewFullParams { polkadot_service::NewFullParams {
is_collator: polkadot_service::IsCollator::Yes(collator.collator_key()), is_parachain_node: polkadot_service::IsParachainNode::Collator(
collator.collator_key(),
),
grandpa_pause: None, grandpa_pause: None,
jaeger_agent: None, jaeger_agent: None,
telemetry_worker_handle: None, telemetry_worker_handle: None,
@@ -70,7 +76,6 @@ fn main() -> Result<()> {
workers_path: None, workers_path: None,
workers_names: None, workers_names: None,
overseer_enable_anyways: false,
overseer_gen: polkadot_service::RealOverseerGen, overseer_gen: polkadot_service::RealOverseerGen,
overseer_message_channel_capacity_override: None, overseer_message_channel_capacity_override: None,
malus_finality_delay: None, malus_finality_delay: None,
@@ -1244,28 +1244,27 @@ impl<T: Config> Pallet<T> {
) -> DispatchResult { ) -> DispatchResult {
let mut pending_configs = <PendingConfigs<T>>::get(); let mut pending_configs = <PendingConfigs<T>>::get();
// 1. pending_configs = [] // 1. pending_configs = [] No pending configuration changes.
// No pending configuration changes.
// //
// That means we should use the active config as the base configuration. We will insert // That means we should use the active config as the base configuration. We will insert
// the new pending configuration as (cur+2, new_config) into the list. // the new pending configuration as (cur+2, new_config) into the list.
// //
// 2. pending_configs = [(cur+2, X)] // 2. pending_configs = [(cur+2, X)] There is a configuration that is pending for the
// There is a configuration that is pending for the scheduled session. // scheduled session.
// //
// We will use X as the base configuration. We can update the pending configuration X // We will use X as the base configuration. We can update the pending configuration X
// directly. // directly.
// //
// 3. pending_configs = [(cur+1, X)] // 3. pending_configs = [(cur+1, X)] There is a pending configuration scheduled and it will
// There is a pending configuration scheduled and it will be applied in the next session. // be applied in the next session.
// //
// We will use X as the base configuration. We need to schedule a new configuration // We will use X as the base configuration. We need to schedule a new configuration
// change for the `scheduled_session` and use X as the base for the new configuration. // change for the `scheduled_session` and use X as the base for the new configuration.
// //
// 4. pending_configs = [(cur+1, X), (cur+2, Y)] // 4. pending_configs = [(cur+1, X), (cur+2, Y)] There is a pending configuration change in
// There is a pending configuration change in the next session and for the scheduled // the next session and for the scheduled session. Due to case №3, we can be sure that Y
// session. Due to case №3, we can be sure that Y is based on top of X. This means we // is based on top of X. This means we can use Y as the base configuration and update Y
// can use Y as the base configuration and update Y directly. // directly.
// //
// There cannot be (cur, X) because those are applied in the session change handler for the // There cannot be (cur, X) because those are applied in the session change handler for the
// current session. // current session.
@@ -977,8 +977,8 @@ fn compute_entropy<T: Config>(parent_hash: T::Hash) -> [u8; 32] {
/// 2. If exceeded: /// 2. If exceeded:
/// 1. Check validity of all dispute statements sequentially /// 1. Check validity of all dispute statements sequentially
/// 2. If not exceeded: /// 2. If not exceeded:
/// 1. If weight is exceeded by locals, pick the older ones (lower indices) /// 1. If weight is exceeded by locals, pick the older ones (lower indices) until the weight limit
/// until the weight limit is reached. /// is reached.
/// ///
/// Returns the consumed weight amount, that is guaranteed to be less than the provided /// Returns the consumed weight amount, that is guaranteed to be less than the provided
/// `max_consumable_weight`. /// `max_consumable_weight`.
@@ -23,8 +23,7 @@
//! will contain methods from `vstaging`. //! will contain methods from `vstaging`.
//! The promotion consists of the following steps: //! The promotion consists of the following steps:
//! 1. Bump the version of the stable module (e.g. `v2` becomes `v3`) //! 1. Bump the version of the stable module (e.g. `v2` becomes `v3`)
//! 2. Move methods from `vstaging` to `v3`. The new stable version should include //! 2. Move methods from `vstaging` to `v3`. The new stable version should include all methods from
//! all methods from `vstaging` tagged with the new version number (e.g. all //! `vstaging` tagged with the new version number (e.g. all `v3` methods).
//! `v3` methods).
pub mod v5; pub mod v5;
pub mod vstaging; pub mod vstaging;