Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add relay parent to inherent and to digest #304

Closed
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 collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ where
horizontal_messages,
validation_data: validation_data.clone(),
relay_chain_state,
relay_parent,
}
};

Expand Down
10 changes: 10 additions & 0 deletions parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ use sp_std::{vec::Vec, cmp};

mod relay_state_snapshot;
use relay_state_snapshot::MessagingStateSnapshot;
use sp_runtime::DigestItem;
use codec::Encode;

/// The pallet's configuration trait.
pub trait Config: frame_system::Config {
Expand Down Expand Up @@ -153,6 +155,7 @@ decl_module! {
relay_chain_state,
downward_messages,
horizontal_messages,
relay_parent,
} = data;

// initialization logic: we know that this runs exactly once every block,
Expand Down Expand Up @@ -219,6 +222,12 @@ decl_module! {
);
}

// Add the relay parent to a digest to track which parents this block was built on.
frame_system::Module::<T>::deposit_log(DigestItem::<T::Hash>::Consensus(
*b"rlyp", // "rlyp" -> "relay parent"
relay_parent.encode(),
));

Ok(())
}

Expand Down Expand Up @@ -932,6 +941,7 @@ mod tests {
relay_chain_state,
downward_messages: Default::default(),
horizontal_messages: Default::default(),
relay_parent: Default::default(),
})
.expect("failed to put VFP inherent");
inherent_data
Expand Down
3 changes: 3 additions & 0 deletions primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub mod inherents {
use super::{InboundDownwardMessage, InboundHrmpMessage, ParaId};
use sp_inherents::InherentIdentifier;
use sp_std::{collections::btree_map::BTreeMap, vec::Vec};
use polkadot_primitives::v1::Hash as PHash;

/// The identifier for the parachain-system inherent.
pub const SYSTEM_INHERENT_IDENTIFIER: InherentIdentifier = *b"sysi1337";
Expand All @@ -68,6 +69,8 @@ pub mod inherents {
/// were sent. In combination with the rule of no more than one message in a channel per block,
/// this means `sent_at` is **strictly** greater than the previous one (if any).
pub horizontal_messages: BTreeMap<ParaId, Vec<InboundHrmpMessage>>,
/// The hash of the relay parent block on which this block is built.
pub relay_parent: PHash,
}
}

Expand Down
1 change: 1 addition & 0 deletions test/client/src/block_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ impl InitBlockBuilder for Client {
relay_chain_state,
downward_messages: Default::default(),
horizontal_messages: Default::default(),
relay_parent: Default::default(),
},
)
.expect("Put validation function params failed");
Expand Down