Skip to content

Commit e007db0

Browse files
authored
feat(cumulus): Adds support for additional relay state keys in parachain validation data inherent (#9262)
Adds the possibility for parachain clients to collect additional relay state keys into the validation data inherent. With this change, other consensus engines can collect additional relay keys into the parachain inherent data: ```rs let paras_inherent_data = ParachainInherentDataProvider::create_at( relay_parent, relay_client, validation_data, para_id, vec![ relay_well_known_keys::EPOCH_INDEX.to_vec() // <----- Example ], ) .await; ```
1 parent 8b21416 commit e007db0

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

cumulus/client/consensus/aura/src/collator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ where
137137
relay_parent_descendants
138138
.map(RelayParentData::into_inherent_descendant_list)
139139
.unwrap_or_default(),
140+
Vec::new(),
140141
)
141142
.await;
142143

cumulus/client/parachain-inherent/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ async fn collect_relay_storage_proof(
3939
relay_parent: PHash,
4040
include_authorities: bool,
4141
include_next_authorities: bool,
42+
additional_relay_state_keys: Vec<Vec<u8>>,
4243
) -> Option<sp_state_machine::StorageProof> {
4344
use relay_chain::well_known_keys as relay_well_known_keys;
4445

@@ -133,6 +134,13 @@ async fn collect_relay_storage_proof(
133134
relevant_keys.push(relay_well_known_keys::NEXT_AUTHORITIES.to_vec());
134135
}
135136

137+
// Add additional relay state keys
138+
let unique_keys: Vec<Vec<u8>> = additional_relay_state_keys
139+
.into_iter()
140+
.filter(|key| !relevant_keys.contains(key))
141+
.collect();
142+
relevant_keys.extend(unique_keys);
143+
136144
relay_chain_interface
137145
.prove_read(relay_parent, &relevant_keys)
138146
.await
@@ -159,6 +167,7 @@ impl ParachainInherentDataProvider {
159167
validation_data: &PersistedValidationData,
160168
para_id: ParaId,
161169
relay_parent_descendants: Vec<RelayHeader>,
170+
additional_relay_state_keys: Vec<Vec<u8>>,
162171
) -> Option<ParachainInherentData> {
163172
// Only include next epoch authorities when the descendants include an epoch digest.
164173
// Skip the first entry because this is the relay parent itself.
@@ -174,6 +183,7 @@ impl ParachainInherentDataProvider {
174183
relay_parent,
175184
!relay_parent_descendants.is_empty(),
176185
include_next_authorities,
186+
additional_relay_state_keys,
177187
)
178188
.await?;
179189

prdoc/pr_9262.prdoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
title: 'Adds support for additional relay state keys in parachain validation data inherent'
2+
doc:
3+
- audience: Node Dev
4+
description: |-
5+
Adds the possibility for parachain clients to collect additional relay state keys into the validation data inherent.
6+
crates:
7+
- name: cumulus-client-consensus-aura
8+
bump: patch
9+
- name: cumulus-client-parachain-inherent
10+
bump: major

0 commit comments

Comments
 (0)