op_alloy_rpc_types/
sync.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Op types related to sync.

use alloy_eips::BlockNumHash;
use alloy_primitives::{BlockNumber, B256};
use serde::{Deserialize, Serialize};

/// The block reference for an L2 block.
///
/// See: <https://github.com/ethereum-optimism/optimism/blob/develop/op-service/eth/id.go#L33>
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct L2BlockRef {
    /// The block hash.
    pub hash: B256,
    /// The block number.
    pub number: BlockNumber,
    /// The parent hash.
    pub parent_hash: B256,
    /// The timestamp.
    pub timestamp: u64,
    /// The L1 origin.
    #[serde(rename = "l1origin")]
    pub l1_origin: BlockNumHash,
    /// The sequence number.
    pub sequence_number: u64,
}

/// The block reference for an L1 block.
///
/// See: <https://github.com/ethereum-optimism/optimism/blob/develop/op-service/eth/id.go#L52>
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct L1BlockRef {
    /// The block hash.
    pub hash: B256,
    /// The block number.
    pub number: BlockNumber,
    /// The parent hash.
    pub parent_hash: B256,
    /// The timestamp.
    pub timestamp: u64,
}

/// The [`SyncStatus`][ss] of an Optimism Rollup Node.
///
/// [ss]: https://github.com/ethereum-optimism/optimism/blob/develop/op-service/eth/sync_status.go#L5
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct SyncStatus {
    /// The current L1 block.
    pub current_l1: L1BlockRef,
    /// The current L1 finalized block.
    pub current_l1_finalized: L1BlockRef,
    /// The L1 head block ref.
    pub head_l1: L1BlockRef,
    /// The L1 safe head block ref.
    pub safe_l1: L1BlockRef,
    /// The finalized L1 block ref.
    pub finalized_l1: L1BlockRef,
    /// The unsafe L2 block ref.
    pub unsafe_l2: L2BlockRef,
    /// The safe L2 block ref.
    pub safe_l2: L2BlockRef,
    /// The finalized L2 block ref.
    pub finalized_l2: L2BlockRef,
    /// The pending safe L2 block ref.
    pub pending_safe_l2: L2BlockRef,
}