|
| 1 | +use alloy_consensus::Header; |
| 2 | +use alloy_primitives::{Signature, B256}; |
| 3 | +use reth_network_peers::PeerId; |
| 4 | +use reth_scroll_primitives::ScrollBlock; |
| 5 | +use rollup_node_primitives::{BatchInfo, BlockInfo, ChainImport, L2BlockInfoWithL1Messages}; |
| 6 | + |
| 7 | +/// An event emitted by the `ChainOrchestrator`. |
| 8 | +#[derive(Debug, Clone, PartialEq, Eq)] |
| 9 | +pub enum ChainOrchestratorEvent { |
| 10 | + /// A new block has been received from the network but we have insufficient data to process it |
| 11 | + /// due to being in optimistic mode. |
| 12 | + InsufficientDataForReceivedBlock(B256), |
| 13 | + /// The block that we have received is already known. |
| 14 | + BlockAlreadyKnown(B256, PeerId), |
| 15 | + /// A fork of the chain that is older than the current chain has been received. |
| 16 | + OldForkReceived { |
| 17 | + /// The headers of the old fork. |
| 18 | + headers: Vec<Header>, |
| 19 | + /// The peer that provided the old fork. |
| 20 | + peer_id: PeerId, |
| 21 | + /// The signature of the old fork. |
| 22 | + signature: Signature, |
| 23 | + }, |
| 24 | + /// The chain should be optimistically synced to the provided block. |
| 25 | + OptimisticSync(ScrollBlock), |
| 26 | + /// The chain has been extended, returning the new blocks. |
| 27 | + ChainExtended(ChainImport), |
| 28 | + /// The chain has reorged, returning the new chain and the peer that provided them. |
| 29 | + ChainReorged(ChainImport), |
| 30 | + /// A `BatchCommit` event has been indexed returning the batch info and L1 block number at |
| 31 | + /// which the event was emitted. If this event is associated with a batch revert then the |
| 32 | + /// `safe_head` will also be populated with the `BlockInfo` that represents the new L2 head. |
| 33 | + BatchCommitIndexed { |
| 34 | + /// The batch info. |
| 35 | + batch_info: BatchInfo, |
| 36 | + /// The L1 block number in which the batch was committed. |
| 37 | + l1_block_number: u64, |
| 38 | + /// The safe L2 block info. |
| 39 | + safe_head: Option<BlockInfo>, |
| 40 | + }, |
| 41 | + /// A batch has been finalized returning the batch hash and new an optional finalized |
| 42 | + /// L2 block. |
| 43 | + BatchFinalized(B256, Option<BlockInfo>), |
| 44 | + /// An L1 block has been finalized returning the L1 block number and an optional |
| 45 | + /// finalized L2 block. |
| 46 | + L1BlockFinalized(u64, Option<BlockInfo>), |
| 47 | + /// A `L1Message` event has been committed returning the message queue index. |
| 48 | + L1MessageCommitted(u64), |
| 49 | + /// A reorg has occurred on L1, returning the L1 block number of the new L1 head, |
| 50 | + /// the L1 message queue index of the new L1 head, and optionally the L2 head and safe block |
| 51 | + /// info if the reorg resulted in a new L2 head or safe block. |
| 52 | + L1Reorg { |
| 53 | + /// The L1 block number of the new L1 head. |
| 54 | + l1_block_number: u64, |
| 55 | + /// The L1 message queue index of the new L1 head. |
| 56 | + queue_index: Option<u64>, |
| 57 | + /// The L2 head block info. |
| 58 | + l2_head_block_info: Option<BlockInfo>, |
| 59 | + /// The L2 safe block info. |
| 60 | + l2_safe_block_info: Option<BlockInfo>, |
| 61 | + }, |
| 62 | + /// An L2 block has been committed returning the [`L2BlockInfoWithL1Messages`] and an |
| 63 | + /// optional [`BatchInfo`] if the block is associated with a committed batch. |
| 64 | + L2ChainCommitted(L2BlockInfoWithL1Messages, Option<BatchInfo>, bool), |
| 65 | + /// An L2 consolidated block has been committed returning the [`L2BlockInfoWithL1Messages`]. |
| 66 | + L2ConsolidatedBlockCommitted(L2BlockInfoWithL1Messages), |
| 67 | +} |
0 commit comments