Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cumulus/client/parachain-inherent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ impl ParachainInherentDataProvider {
validation_data: validation_data.clone(),
relay_chain_state,
relay_parent_descendants,
collator_peer_id: None,
})
}
}
1 change: 1 addition & 0 deletions cumulus/client/parachain-inherent/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ impl<R: Send + Sync + GenerateRandomness<u64>> InherentDataProvider
horizontal_messages,
relay_chain_state: proof,
relay_parent_descendants: Default::default(),
collator_peer_id: None,
};

parachain_inherent_data.provide_inherent_data(inherent_data).await
Expand Down
1 change: 1 addition & 0 deletions cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ pub mod pallet {
downward_messages,
horizontal_messages,
relay_parent_descendants,
collator_peer_id: _,
} = data;

// Check that the associated relay chain block number is as expected.
Expand Down
1 change: 1 addition & 0 deletions cumulus/pallets/parachain-system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ impl BlockTests {
downward_messages: Default::default(),
horizontal_messages: Default::default(),
relay_parent_descendants: Default::default(),
collator_peer_id: None,
};
if let Some(ref hook) = self.inherent_data_hook {
hook(self, relay_parent_number, &mut system_inherent_data);
Expand Down
2 changes: 2 additions & 0 deletions cumulus/pallets/parachain-system/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fn test_inherent_compatibility() {
downward_messages: Default::default(),
horizontal_messages: Default::default(),
relay_parent_descendants: Default::default(),
collator_peer_id: None,
},
)
.expect("Put validation function params failed");
Expand All @@ -80,6 +81,7 @@ fn test_inherent_compatibility() {
downward_messages: Default::default(),
horizontal_messages: Default::default(),
relay_parent_descendants: Default::default(),
collator_peer_id: None,
};
let _ = futures::executor::block_on(
data.provide_inherent_data(&mut valid_inherent_data_full_compatibility),
Expand Down
2 changes: 2 additions & 0 deletions cumulus/parachains/runtimes/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ where
downward_messages: Default::default(),
horizontal_messages: Default::default(),
relay_parent_descendants: Default::default(),
collator_peer_id: None,
};

let _ = cumulus_pallet_parachain_system::Pallet::<Runtime>::set_validation_data(
Expand Down Expand Up @@ -710,6 +711,7 @@ pub fn mock_open_hrmp_channel<
downward_messages: Default::default(),
horizontal_messages: Default::default(),
relay_parent_descendants: Default::default(),
collator_peer_id: None,
};
inherent_data
.put_data(
Expand Down
10 changes: 8 additions & 2 deletions cumulus/primitives/parachain-inherent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
extern crate alloc;

use cumulus_primitives_core::{
relay_chain::{BlakeTwo256, Hash as RelayHash, HashT as _, Header as RelayHeader},
relay_chain::{
vstaging::ApprovedPeerId, BlakeTwo256, Hash as RelayHash, HashT as _, Header as RelayHeader,
},
InboundDownwardMessage, InboundHrmpMessage, ParaId, PersistedValidationData,
};

Expand All @@ -44,7 +46,7 @@ pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"sysi1338";

/// Legacy ParachainInherentData that is kept around for backward compatibility.
/// Can be removed once we can safely assume that parachain nodes provide the
/// `relay_parent_descendants` field.
/// `relay_parent_descendants` and `collator_peer_id` fields.
pub mod v0 {
use alloc::{collections::BTreeMap, vec::Vec};
use cumulus_primitives_core::{
Expand Down Expand Up @@ -115,6 +117,9 @@ pub struct ParachainInherentData {
/// This information is used to ensure that a parachain node builds blocks
/// at a specified offset from the chain tip rather than directly at the tip.
pub relay_parent_descendants: Vec<RelayHeader>,
/// Contains the collator peer ID, which is later sent by the parachain to the
/// relay chain via a UMP signal to promote the reputation of the given peer ID.
pub collator_peer_id: Option<ApprovedPeerId>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sw10pa just a dq, I am not sure about now, when we add this field here, doesn't it change encoding or with None no? I am thinking about when the runtime with this change is enacted, what about older validators/collators without this change, do they still work? Will the ParachainInherentData with collator_peer_id: None produce the same data as ParachainInherentData without collator_peer_id field? Will both validators/collators produce the same state_root or whatever? Other words, is this change backwards-compatible? Will the older validators/collators still work?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skunert added this new inherent data type in #8299 in a backwards compatible way. This new data type is written at a different key. This PR piggy-backs on that logic.

  • Old collators, old runtime. This is the present state, which works just fine.
  • Old collators, new runtime. New runtime will attempt to decode both data types. If the new one fails, it will fall back to the old one.
  • New collators supply both inherent data types (most of the data being duplicated). Old runtime will decode the old one, new runtime will decode the new one

}

// Upgrades the ParachainInherentData v0 to the newest format.
Expand All @@ -126,6 +131,7 @@ impl Into<ParachainInherentData> for v0::ParachainInherentData {
downward_messages: self.downward_messages,
horizontal_messages: self.horizontal_messages,
relay_parent_descendants: Vec::new(),
collator_peer_id: None,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions cumulus/test/client/src/block_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ fn init_block_builder(
downward_messages: Default::default(),
horizontal_messages: Default::default(),
relay_parent_descendants: Default::default(),
collator_peer_id: None,
},
)
.expect("Put validation function params failed");
Expand Down
1 change: 1 addition & 0 deletions cumulus/test/service/src/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub fn extrinsic_set_validation_data(
downward_messages: Default::default(),
horizontal_messages: Default::default(),
relay_parent_descendants: Default::default(),
collator_peer_id: None,
};

cumulus_test_runtime::UncheckedExtrinsic::new_bare(
Expand Down
1 change: 1 addition & 0 deletions cumulus/xcm/xcm-emulator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@ macro_rules! decl_test_networks {
downward_messages: Default::default(),
horizontal_messages: Default::default(),
relay_parent_descendants: Default::default(),
collator_peer_id: None,
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions prdoc/pr_8708.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
title: "feat: add collator peer ID to ParachainInherentData"

doc:
- audience: Runtime Dev
description: |
Adds an optional `collator_peer_id` field to the new version of `ParachainInherentData`
introduced in PR #8299. The field is currently unused and defaults to `None`, but is
included proactively to avoid creating another inherent data version in the future.
This sets the stage for sending collator peer IDs via UMP signals in upcoming work.

crates:
- name: cumulus-client-parachain-inherent
bump: patch
- name: cumulus-pallet-parachain-system
bump: patch
- name: parachains-runtimes-test-utils
bump: patch
- name: cumulus-primitives-parachain-inherent
bump: major
- name: xcm-emulator
bump: patch