Skip to content

Commit 4fbf353

Browse files
collator-protocol revamp: Send RC PeerId with ApprovedPeer UMP signal (#12388)
Currently the collator sends its parachain PeerId within the ApprovedPeer UMP signal, which is wrong because this peer id is not known on the relay chain. As a result on CandidateIncluded event the score is bumped for the wrong PeerId and the collator remains with zero reputation no matter its honest work. --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> (cherry picked from commit 44b3a38)
1 parent 82af15d commit 4fbf353

4 files changed

Lines changed: 29 additions & 15 deletions

File tree

cumulus/polkadot-omni-node/lib/src/common/spec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ pub(crate) trait NodeSpec: BaseNodeSpec {
408408
metrics,
409409
})
410410
.await?;
411-
let peer_id = network.local_peer_id();
411+
let peer_id = relay_chain_network.local_peer_id();
412412

413413
let statement_store = statement_handler_proto
414414
.map(|(statement_handler_proto, config)| {

cumulus/test/service/src/lib.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ use sc_network::{
7272
config::{FullNetworkConfiguration, TransportConfig},
7373
multiaddr,
7474
service::traits::NetworkService,
75-
NetworkBackend, NetworkBlock, NetworkStateInfo,
75+
NetworkBackend, NetworkBlock, NetworkStateInfo, PeerId,
7676
};
7777
use sc_service::{
7878
config::{
@@ -257,7 +257,7 @@ async fn build_relay_chain_interface(
257257
collator_key: Option<CollatorPair>,
258258
collator_options: CollatorOptions,
259259
task_manager: &mut TaskManager,
260-
) -> RelayChainResult<Arc<dyn RelayChainInterface + 'static>> {
260+
) -> RelayChainResult<(Arc<dyn RelayChainInterface + 'static>, PeerId)> {
261261
let relay_chain_node = match collator_options.relay_chain_mode {
262262
cumulus_client_cli::RelayChainMode::Embedded => polkadot_test_service::new_full(
263263
relay_chain_config,
@@ -279,20 +279,25 @@ async fn build_relay_chain_interface(
279279
rpc_target_urls,
280280
)
281281
.await
282-
.map(|r| r.0)
282+
.map(|r| (r.0, r.2.local_peer_id()))
283283
},
284284
};
285285

286+
let relay_chain_peer_id = relay_chain_node.network.local_peer_id();
287+
286288
task_manager.add_child(relay_chain_node.task_manager);
287289
tracing::info!("Using inprocess node.");
288-
Ok(Arc::new(RelayChainInProcessInterface::new(
289-
relay_chain_node.client.clone(),
290-
relay_chain_node.backend.clone(),
291-
relay_chain_node.sync_service.clone(),
292-
relay_chain_node.overseer_handle.ok_or(RelayChainError::GenericError(
293-
"Overseer should be running in full node.".to_string(),
294-
))?,
295-
)))
290+
Ok((
291+
Arc::new(RelayChainInProcessInterface::new(
292+
relay_chain_node.client.clone(),
293+
relay_chain_node.backend.clone(),
294+
relay_chain_node.sync_service.clone(),
295+
relay_chain_node.overseer_handle.ok_or(RelayChainError::GenericError(
296+
"Overseer should be running in full node.".to_string(),
297+
))?,
298+
)),
299+
relay_chain_peer_id,
300+
))
296301
}
297302

298303
/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.
@@ -332,7 +337,7 @@ where
332337

333338
let block_import = params.other.0;
334339
let slot_based_handle = params.other.1;
335-
let relay_chain_interface = build_relay_chain_interface(
340+
let (relay_chain_interface, relay_chain_peer_id) = build_relay_chain_interface(
336341
relay_chain_config,
337342
parachain_config.prometheus_registry(),
338343
collator_key.clone(),
@@ -434,7 +439,7 @@ where
434439
prometheus_registry: None,
435440
})?;
436441

437-
let collator_peer_id = network.local_peer_id();
442+
let collator_peer_id = relay_chain_peer_id;
438443
if let Some(collator_key) = collator_key {
439444
let proposer = sc_basic_authorship::ProposerFactory::new(
440445
task_manager.spawn_handle(),

prdoc/pr_12388.prdoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
title: 'collator-protocol revamp: Send RC PeerId with ApprovedPeer UMP signal'
2+
doc:
3+
- audience: Node Dev
4+
description: |-
5+
Currently the collator sends its parachain PeerId within the ApprovedPeer UMP signal, which is wrong because this peer id is not known on the relay chain.
6+
As a result on CandidateIncluded event the score is bumped for the wrong PeerId and the collator remains with zero reputation no matter its honest work.
7+
crates:
8+
- name: polkadot-omni-node-lib
9+
bump: patch

templates/parachain/node/src/service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ pub async fn start_parachain_node(
303303
),
304304
})
305305
.await?;
306-
let collator_peer_id = network.local_peer_id();
306+
let collator_peer_id = relay_chain_network.local_peer_id();
307307

308308
if parachain_config.offchain_worker.enabled {
309309
use futures::FutureExt;

0 commit comments

Comments
 (0)