Add pallet-timestamp

Ensures the timestamp is sent, within expected parameters, and the correctness
in relation to `pallet-babe`.
This commit is contained in:
Luke Parker
2025-11-14 09:57:18 -05:00
parent 82ca889ed3
commit 556d294157
20 changed files with 234 additions and 134 deletions

View File

@@ -159,6 +159,29 @@ mod substrate {
pub unix_time_in_millis: u64,
}
impl SeraiPreExecutionDigest {
/// The consensus ID for a Serai pre-execution digest.
pub const CONSENSUS_ID: [u8; 4] = *b"SRIP";
/// Find the pre-execution digest within a `Digest`.
///
/// This will panic if the digest either isn't found or is invalid.
pub fn find(digest: &Digest) -> Self {
for log in digest.logs() {
match log {
DigestItem::PreRuntime(consensus, encoded)
if *consensus == SeraiPreExecutionDigest::CONSENSUS_ID =>
{
return <_>::deserialize_reader(&mut encoded.as_slice())
.expect("invalid `SeraiPreExecutionDigest`");
}
_ => {}
}
}
panic!("missing `SeraiPreExecutionDigest`");
}
}
/// The digest for all of the Serai-specific header fields determined during execution of the
/// block.
#[derive(Clone, Copy, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
@@ -171,11 +194,6 @@ mod substrate {
pub events_commitment: UnbalancedMerkleTree,
}
impl SeraiPreExecutionDigest {
/// The consensus ID for a Serai pre-execution digest.
pub const CONSENSUS_ID: [u8; 4] = *b"SRIP";
}
impl SeraiExecutionDigest {
/// The consensus ID for a Serai execution digest.
pub const CONSENSUS_ID: [u8; 4] = *b"SRIE";