kona_rpc/l1_watcher.rs
1use kona_genesis::RollupConfig;
2use kona_protocol::BlockInfo;
3use tokio::sync::oneshot::Sender;
4
5/// The L1 watcher state accessible from RPC queries.
6#[derive(Debug, Clone)]
7pub struct L1State {
8 /// The current L1 block.
9 ///
10 /// This is the L1 block that the derivation process is last idled at.
11 /// This may not be fully derived into L2 data yet.
12 /// The safe L2 blocks were produced/included fully from the L1 chain up to _but excluding_
13 /// this L1 block. If the node is synced, this matches the `head_l1`, minus the verifier
14 /// confirmation distance.
15 pub current_l1: Option<BlockInfo>,
16 /// The current L1 finalized block.
17 ///
18 /// This is a legacy sync-status attribute. This is deprecated.
19 /// A previous version of the L1 finalization-signal was updated only after the block was
20 /// retrieved by number. This attribute just matches `finalized_l1` now.
21 pub current_l1_finalized: Option<BlockInfo>,
22 /// The L1 head block ref.
23 ///
24 /// The head is not guaranteed to build on the other L1 sync status fields,
25 /// as the node may be in progress of resetting to adapt to a L1 reorg.
26 pub head_l1: Option<BlockInfo>,
27 /// The L1 safe head block ref.
28 pub safe_l1: Option<BlockInfo>,
29 /// The finalized L1 block ref.
30 pub finalized_l1: Option<BlockInfo>,
31}
32
33/// A sender for L1 watcher queries.
34pub type L1WatcherQuerySender = tokio::sync::mpsc::Sender<L1WatcherQueries>;
35
36/// The inbound queries to the L1 watcher.
37#[derive(Debug)]
38pub enum L1WatcherQueries {
39 /// Get the rollup config from the L1 watcher.
40 Config(Sender<RollupConfig>),
41 /// Get a complete view of the L1 state.
42 L1State(Sender<L1State>),
43}