work with additional key values (#1757)

Add the possibility to inject additional key-values in the
sproof-builder that generates the relay root that gets stored in
parachain-system.

Rationale: pallets that verify additional storage items (not those
verified by parachain-system) from the relay should be able to proof
against the relay root that gets stored in parachain-system. This PR
allows to create provide additional nibles that can later be used for
verifiability in other pallets
This commit is contained in:
girazoki
2023-11-22 18:29:06 +01:00
committed by GitHub
parent 0d6dcb3f48
commit 0956357b60
@@ -61,6 +61,8 @@ pub struct MockValidationDataInherentDataProvider<R = ()> {
pub raw_downward_messages: Vec<Vec<u8>>, pub raw_downward_messages: Vec<Vec<u8>>,
// Inbound Horizontal messages sorted by channel // Inbound Horizontal messages sorted by channel
pub raw_horizontal_messages: Vec<(ParaId, Vec<u8>)>, pub raw_horizontal_messages: Vec<(ParaId, Vec<u8>)>,
// Additional key-value pairs that should be injected.
pub additional_key_values: Option<Vec<(Vec<u8>, Vec<u8>)>>,
} }
pub trait GenerateRandomness<I> { pub trait GenerateRandomness<I> {
@@ -210,6 +212,10 @@ impl<R: Send + Sync + GenerateRandomness<u64>> InherentDataProvider
sproof_builder.randomness = sproof_builder.randomness =
self.relay_randomness_config.generate_randomness(self.current_para_block.into()); self.relay_randomness_config.generate_randomness(self.current_para_block.into());
if let Some(key_values) = &self.additional_key_values {
sproof_builder.additional_key_values = key_values.clone()
}
let (relay_parent_storage_root, proof) = sproof_builder.into_state_root_and_proof(); let (relay_parent_storage_root, proof) = sproof_builder.into_state_root_and_proof();
inherent_data.put_data( inherent_data.put_data(