Skip to content

Commit 5ce30dc

Browse files
committed
Start prometheus endpoint in minimal-node
Use prebuilt try-runtime binary in CI (paritytech#1898) `cargo install` takes a long time in CI. We want to run it relatively frequently without chewing through so much compute (see paritytech/ci_cd#771) so I added automatic binary releases to the try-runtime-cli repo. A small added benefit is we can use it in our existing `on-runtime-upgrade` checks, which should cut their execution time by about half. Cumulus: Allow aura to use initialized collation request receiver (paritytech#1911) When launching our [small network](https://github.com/paritytech/polkadot-sdk/blob/master/cumulus/zombienet/examples/small_network.toml) for testing the node was crashing here shortly after launch: https://github.com/paritytech/polkadot-sdk/blob/5cdd819ed295645958afd9d937d989978fd0c84e/polkadot/node/collation-generation/src/lib.rs#L140 After changes in paritytech#1788 for the asset hub collator we are waiting for blocks of the shell runtime to pass before we initialize aura. However, this means that we attempted to initialize the collation related relay chain subsystems twice, leading to the error. I modified Aura to let it optionally take an already initialized stream of collation requests. Remove comments
1 parent 3e98021 commit 5ce30dc

9 files changed

Lines changed: 49 additions & 26 deletions

File tree

.gitlab/pipeline/check.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,16 @@ test-rust-feature-propagation:
112112
script:
113113
- |
114114
export RUST_LOG=remote-ext=debug,runtime=debug
115-
echo "---------- Installing try-runtime-cli ----------"
116-
time cargo install --locked --git https://github.com/paritytech/try-runtime-cli --tag v0.3.0
115+
116+
echo "---------- Downloading try-runtime CLI ----------"
117+
curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/v0.3.3/try-runtime-x86_64-unknown-linux-musl -o try-runtime
118+
chmod +x ./try-runtime
119+
117120
echo "---------- Building ${PACKAGE} runtime ----------"
118121
time cargo build --release --locked -p "$PACKAGE" --features try-runtime
122+
119123
echo "---------- Executing `on-runtime-upgrade` for ${NETWORK} ----------"
120-
time try-runtime \
124+
time ./try-runtime \
121125
--runtime ./target/release/wbuild/"$PACKAGE"/"$WASM" \
122126
on-runtime-upgrade --checks=pre-and-post ${EXTRA_ARGS} live --uri ${URI}
123127

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cumulus/client/consensus/aura/src/collators/basic.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
//! For more information about AuRa, the Substrate crate should be checked.
2424
2525
use codec::{Codec, Decode};
26-
use cumulus_client_collator::service::ServiceInterface as CollatorServiceInterface;
26+
use cumulus_client_collator::{
27+
relay_chain_driven::CollationRequest, service::ServiceInterface as CollatorServiceInterface,
28+
};
2729
use cumulus_client_consensus_common::ParachainBlockImportMarker;
2830
use cumulus_client_consensus_proposer::ProposerInterface;
2931
use cumulus_primitives_core::{relay_chain::BlockId as RBlockId, CollectCollationInfo};
@@ -33,7 +35,7 @@ use polkadot_node_primitives::CollationResult;
3335
use polkadot_overseer::Handle as OverseerHandle;
3436
use polkadot_primitives::{CollatorPair, Id as ParaId};
3537

36-
use futures::prelude::*;
38+
use futures::{channel::mpsc::Receiver, prelude::*};
3739
use sc_client_api::{backend::AuxStore, BlockBackend, BlockOf};
3840
use sc_consensus::BlockImport;
3941
use sp_api::ProvideRuntimeApi;
@@ -81,6 +83,10 @@ pub struct Params<BI, CIDP, Client, RClient, SO, Proposer, CS> {
8183
pub collator_service: CS,
8284
/// The amount of time to spend authoring each block.
8385
pub authoring_duration: Duration,
86+
/// Receiver for collation requests. If `None`, Aura consensus will establish a new receiver.
87+
/// Should be used when a chain migrates from a different consensus algorithm and was already
88+
/// processing collation requests before initializing Aura.
89+
pub collation_request_receiver: Option<Receiver<CollationRequest>>,
8490
}
8591

8692
/// Run bare Aura consensus as a relay-chain-driven collator.
@@ -110,12 +116,16 @@ where
110116
P::Signature: TryFrom<Vec<u8>> + Member + Codec,
111117
{
112118
async move {
113-
let mut collation_requests = cumulus_client_collator::relay_chain_driven::init(
114-
params.collator_key,
115-
params.para_id,
116-
params.overseer_handle,
117-
)
118-
.await;
119+
let mut collation_requests = match params.collation_request_receiver {
120+
Some(receiver) => receiver,
121+
None =>
122+
cumulus_client_collator::relay_chain_driven::init(
123+
params.collator_key,
124+
params.para_id,
125+
params.overseer_handle,
126+
)
127+
.await,
128+
};
119129

120130
let mut collator = {
121131
let params = collator_util::Params {

cumulus/client/relay-chain-minimal-node/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ sc-authority-discovery = { path = "../../../substrate/client/authority-discovery
2323
sc-network = { path = "../../../substrate/client/network" }
2424
sc-network-common = { path = "../../../substrate/client/network/common" }
2525
sc-service = { path = "../../../substrate/client/service" }
26+
substrate-prometheus-endpoint = { path = "../../../substrate/utils/prometheus" }
2627
sc-tracing = { path = "../../../substrate/client/tracing" }
2728
sc-utils = { path = "../../../substrate/client/utils" }
2829
sp-api = { path = "../../../substrate/primitives/api" }

cumulus/client/relay-chain-minimal-node/src/collator_overseer.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use sc_authority_discovery::Service as AuthorityDiscoveryService;
4444
use sc_network::NetworkStateInfo;
4545
use sc_service::TaskManager;
4646
use sc_utils::mpsc::tracing_unbounded;
47-
use sp_runtime::traits::Block as BlockT;
4847

4948
use cumulus_primitives_core::relay_chain::{Block, Hash as PHash};
5049
use cumulus_relay_chain_interface::RelayChainError;
@@ -209,8 +208,6 @@ pub struct NewMinimalNode {
209208
pub task_manager: TaskManager,
210209
/// Overseer handle to interact with subsystems
211210
pub overseer_handle: Handle,
212-
/// Network service
213-
pub network: Arc<sc_network::NetworkService<Block, <Block as BlockT>::Hash>>,
214211
}
215212

216213
/// Glues together the [`Overseer`] and `BlockchainEvents` by forwarding

cumulus/client/relay-chain-minimal-node/src/lib.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ use polkadot_primitives::CollatorPair;
3232

3333
use sc_authority_discovery::Service as AuthorityDiscoveryService;
3434
use sc_network::{config::FullNetworkConfiguration, Event, NetworkEventStream, NetworkService};
35-
use sc_service::{Configuration, TaskManager};
35+
use sc_service::{config::PrometheusConfig, Configuration, TaskManager};
3636
use sp_runtime::{app_crypto::Pair, traits::Block as BlockT};
3737

38-
use futures::StreamExt;
38+
use futures::{FutureExt, StreamExt};
3939
use std::sync::Arc;
4040

4141
mod blockchain_rpc_client;
@@ -69,7 +69,7 @@ fn build_authority_discovery_service<Block: BlockT>(
6969
..Default::default()
7070
},
7171
client,
72-
network.clone(),
72+
network,
7373
Box::pin(dht_event_stream),
7474
authority_discovery_role,
7575
prometheus_registry,
@@ -160,12 +160,16 @@ async fn new_minimal_relay_chain(
160160
let role = config.role.clone();
161161
let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network);
162162

163-
let task_manager = {
164-
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
165-
TaskManager::new(config.tokio_handle.clone(), registry)?
166-
};
163+
let prometheus_registry = config.prometheus_registry();
164+
let task_manager = TaskManager::new(config.tokio_handle.clone(), prometheus_registry)?;
167165

168-
let prometheus_registry = config.prometheus_registry().cloned();
166+
if let Some(PrometheusConfig { port, registry }) = config.prometheus_config.clone() {
167+
task_manager.spawn_handle().spawn(
168+
"prometheus-endpoint",
169+
None,
170+
substrate_prometheus_endpoint::init_prometheus(port, registry).map(drop),
171+
);
172+
}
169173

170174
let genesis_hash = relay_chain_rpc_client
171175
.block_get_hash(Some(0))
@@ -203,18 +207,18 @@ async fn new_minimal_relay_chain(
203207
relay_chain_rpc_client.clone(),
204208
&config,
205209
network.clone(),
206-
prometheus_registry.clone(),
210+
prometheus_registry.cloned(),
207211
);
208212

209213
let overseer_args = CollatorOverseerGenArgs {
210214
runtime_client: relay_chain_rpc_client.clone(),
211-
network_service: network.clone(),
215+
network_service: network,
212216
sync_oracle,
213217
authority_discovery_service,
214218
collation_req_receiver_v1,
215219
collation_req_receiver_v2,
216220
available_data_req_receiver,
217-
registry: prometheus_registry.as_ref(),
221+
registry: prometheus_registry,
218222
spawner: task_manager.spawn_handle(),
219223
collator_pair,
220224
req_protocol_names: request_protocol_names,
@@ -226,7 +230,7 @@ async fn new_minimal_relay_chain(
226230

227231
network_starter.start_network();
228232

229-
Ok(NewMinimalNode { task_manager, overseer_handle, network })
233+
Ok(NewMinimalNode { task_manager, overseer_handle })
230234
}
231235

232236
fn build_request_response_protocol_receivers(

cumulus/parachain-template/node/src/service.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ fn start_consensus(
411411
collator_service,
412412
// Very limited proposal time.
413413
authoring_duration: Duration::from_millis(500),
414+
collation_request_receiver: None,
414415
};
415416

416417
let fut =

cumulus/polkadot-parachain/src/service.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,7 @@ pub async fn start_rococo_parachain_node(
988988
collator_service,
989989
// Very limited proposal time.
990990
authoring_duration: Duration::from_millis(500),
991+
collation_request_receiver: None,
991992
};
992993

993994
let fut = basic_aura::run::<
@@ -1380,6 +1381,7 @@ where
13801381
collator_service,
13811382
// Very limited proposal time.
13821383
authoring_duration: Duration::from_millis(500),
1384+
collation_request_receiver: None,
13831385
};
13841386

13851387
let fut =
@@ -1520,6 +1522,7 @@ where
15201522
collator_service,
15211523
// Very limited proposal time.
15221524
authoring_duration: Duration::from_millis(500),
1525+
collation_request_receiver: Some(request_stream),
15231526
};
15241527

15251528
basic_aura::run::<Block, <AuraId as AppCrypto>::Pair, _, _, _, _, _, _, _>(params)
@@ -1925,6 +1928,7 @@ pub async fn start_contracts_rococo_node(
19251928
collator_service,
19261929
// Very limited proposal time.
19271930
authoring_duration: Duration::from_millis(500),
1931+
collation_request_receiver: None,
19281932
};
19291933

19301934
let fut = basic_aura::run::<

substrate/client/service/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub use self::{
5959
},
6060
client::{ClientConfig, LocalCallExecutor},
6161
error::Error,
62+
metrics::MetricsService,
6263
};
6364

6465
pub use sc_chain_spec::{

0 commit comments

Comments
 (0)