kona_protocol/
sync.rs

1//! Common sync types
2
3use crate::{BlockInfo, L2BlockInfo};
4
5/// The [`SyncStatus`][ss] of an Optimism Rollup Node.
6///
7/// The sync status is a snapshot of the current state of the node's sync process.
8/// Values may not be derived yet and are zeroed out if they are not yet derived.
9///
10/// [ss]: https://github.com/ethereum-optimism/optimism/blob/develop/op-service/eth/sync_status.go#L5
11#[derive(Clone, Debug, PartialEq, Eq)]
12#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
13#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
14pub struct SyncStatus {
15    /// The current L1 block.
16    ///
17    /// This is the L1 block that the derivation process is last idled at.
18    /// This may not be fully derived into L2 data yet.
19    /// The safe L2 blocks were produced/included fully from the L1 chain up to _but excluding_
20    /// this L1 block. If the node is synced, this matches the `head_l1`, minus the verifier
21    /// confirmation distance.
22    pub current_l1: BlockInfo,
23    /// The current L1 finalized block.
24    ///
25    /// This is a legacy sync-status attribute. This is deprecated.
26    /// A previous version of the L1 finalization-signal was updated only after the block was
27    /// retrieved by number. This attribute just matches `finalized_l1` now.
28    pub current_l1_finalized: BlockInfo,
29    /// The L1 head block ref.
30    ///
31    /// The head is not guaranteed to build on the other L1 sync status fields,
32    /// as the node may be in progress of resetting to adapt to a L1 reorg.
33    pub head_l1: BlockInfo,
34    /// The L1 safe head block ref.
35    pub safe_l1: BlockInfo,
36    /// The finalized L1 block ref.
37    pub finalized_l1: BlockInfo,
38    /// The unsafe L2 block ref.
39    ///
40    /// This is the absolute tip of the L2 chain, pointing to block data that has not been
41    /// submitted to L1 yet. The sequencer is building this, and verifiers may also be ahead of
42    /// the safe L2 block if they sync blocks via p2p or other offchain sources.
43    /// This is considered to only be local-unsafe post-interop, see `cross_unsafe_l2` for cross-L2
44    /// guarantees.
45    pub unsafe_l2: L2BlockInfo,
46    /// The safe L2 block ref.
47    ///
48    /// This points to the L2 block that was derived from the L1 chain.
49    /// This point may still reorg if the L1 chain reorgs.
50    /// This is considered to be cross-safe post-interop, see `local_safe_l2` to ignore cross-L2
51    /// guarantees.
52    pub safe_l2: L2BlockInfo,
53    /// The finalized L2 block ref.
54    ///
55    /// This points to the L2 block that was derived fully from finalized L1 information, thus
56    /// irreversible.
57    pub finalized_l2: L2BlockInfo,
58    /// Cross unsafe L2 block ref.
59    ///
60    /// This is an unsafe L2 block, that has been verified to match cross-L2 dependencies.
61    /// Pre-interop every unsafe L2 block is also cross-unsafe.
62    pub cross_unsafe_l2: L2BlockInfo,
63    /// Local safe L2 block ref.
64    ///
65    /// This is an L2 block derived from L1, not yet verified to have valid cross-L2 dependencies.
66    pub local_safe_l2: L2BlockInfo,
67}