kona_interop/derived.rs
1//! Contains derived types for interop.
2
3use alloy_eips::eip1898::BlockNumHash;
4use derive_more::Display;
5use kona_protocol::BlockInfo;
6
7/// A pair of [`BlockNumHash`]s representing a derivation relationship between two blocks.
8///
9/// The [`DerivedIdPair`] links a source block (L1) to a derived block (L2) where the derived block
10/// is derived from the source block.
11///
12/// - `source`: The [`BlockNumHash`] of the source (L1) block.
13/// - `derived`: The [`BlockNumHash`] of the derived (L2) block.
14#[derive(Debug, Clone, Copy, PartialEq, Eq)]
15#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
16#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
17pub struct DerivedIdPair {
18 /// The [`BlockNumHash`] of the source (L1) block.
19 pub source: BlockNumHash,
20 /// The [`BlockNumHash`] of the derived (L2) block.
21 pub derived: BlockNumHash,
22}
23
24/// A pair of [`BlockInfo`]s representing a derivation relationship between two blocks.
25///
26/// The [`DerivedRefPair`] contains full block information for both the source (L1) and
27/// derived (L2) blocks, where the derived block is produced from the source block.
28///
29/// - `source`: The [`BlockInfo`] of the source (L1) block.
30/// - `derived`: The [`BlockInfo`] of the derived (L2) block.
31// todo: link specs in docs once spec PR #708 is merged
32#[derive(Debug, Clone, Copy, Display, PartialEq, Eq)]
33#[display("source: {source}, derived: {derived}")]
34#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
35#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
36pub struct DerivedRefPair {
37 /// The [`BlockInfo`] of the source (L1) block.
38 pub source: BlockInfo,
39 /// The [`BlockInfo`] of the derived (L2) block.
40 pub derived: BlockInfo,
41}