reth_optimism_primitives/
bedrock.rs

1//! OP mainnet bedrock related data.
2
3use alloy_consensus::{Header, EMPTY_OMMER_ROOT_HASH, EMPTY_ROOT_HASH};
4use alloy_primitives::{address, b256, bloom, bytes, B256, B64, U256};
5
6/// Transaction 0x9ed8f713b2cc6439657db52dcd2fdb9cc944915428f3c6e2a7703e242b259cb9 in block 985,
7/// replayed in blocks:
8///
9/// 19 022
10/// 45 036
11pub const TX_BLOCK_985: [u64; 2] = [19_022, 45_036];
12
13/// Transaction 0xc033250c5a45f9d104fc28640071a776d146d48403cf5e95ed0015c712e26cb6 in block
14/// 123 322, replayed in block:
15///
16/// 123 542
17pub const TX_BLOCK_123_322: u64 = 123_542;
18
19/// Transaction 0x86f8c77cfa2b439e9b4e92a10f6c17b99fce1220edf4001e4158b57f41c576e5 in block
20/// 1 133 328, replayed in blocks:
21///
22/// 1 135 391
23/// 1 144 468
24pub const TX_BLOCK_1_133_328: [u64; 2] = [1_135_391, 1_144_468];
25
26/// Transaction 0x3cc27e7cc8b7a9380b2b2f6c224ea5ef06ade62a6af564a9dd0bcca92131cd4e in block
27/// 1 244 152, replayed in block:
28///
29/// 1 272 994
30pub const TX_BLOCK_1_244_152: u64 = 1_272_994;
31
32/// The six blocks with replayed transactions.
33pub const BLOCK_NUMS_REPLAYED_TX: [u64; 6] = [
34    TX_BLOCK_985[0],
35    TX_BLOCK_985[1],
36    TX_BLOCK_123_322,
37    TX_BLOCK_1_133_328[0],
38    TX_BLOCK_1_133_328[1],
39    TX_BLOCK_1_244_152,
40];
41
42/// Returns `true` if transaction is the second or third appearance of the transaction. The blocks
43/// with replayed transaction happen to only contain the single transaction.
44pub fn is_dup_tx(block_number: u64) -> bool {
45    if block_number > BLOCK_NUMS_REPLAYED_TX[5] {
46        return false
47    }
48
49    // these blocks just have one transaction!
50    if BLOCK_NUMS_REPLAYED_TX.contains(&block_number) {
51        return true
52    }
53
54    false
55}
56
57/// OVM Header #1 hash.
58///
59/// <https://optimistic.etherscan.io/block/0xbee7192e575af30420cae0c7776304ac196077ee72b048970549e4f08e875453>
60pub const OVM_HEADER_1_HASH: B256 =
61    b256!("0xbee7192e575af30420cae0c7776304ac196077ee72b048970549e4f08e875453");
62
63/// Bedrock hash on Optimism Mainnet.
64///
65/// <https://optimistic.etherscan.io/block/0xdbf6a80fef073de06add9b0d14026d6e5a86c85f6d102c36d3d8e9cf89c2afd3>
66pub const BEDROCK_HEADER_HASH: B256 =
67    b256!("0xdbf6a80fef073de06add9b0d14026d6e5a86c85f6d102c36d3d8e9cf89c2afd3");
68
69/// Bedrock on Optimism Mainnet. (`105_235_063`)
70pub const BEDROCK_HEADER: Header = Header {
71    difficulty: U256::ZERO,
72    extra_data: bytes!("424544524f434b"),
73    gas_limit: 30000000,
74    gas_used: 0,
75    logs_bloom: bloom!(
76        "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
77    ),
78    nonce: B64::ZERO,
79    number: 105235063,
80    parent_hash: b256!("0x21a168dfa5e727926063a28ba16fd5ee84c814e847c81a699c7a0ea551e4ca50"),
81    receipts_root: EMPTY_ROOT_HASH,
82    state_root: b256!("0x920314c198da844a041d63bf6cbe8b59583165fd2229d1b3f599da812fd424cb"),
83    timestamp: 1686068903,
84    transactions_root: EMPTY_ROOT_HASH,
85    ommers_hash: EMPTY_OMMER_ROOT_HASH,
86    beneficiary: address!("0x4200000000000000000000000000000000000011"),
87    withdrawals_root: None,
88    mix_hash: B256::ZERO,
89    base_fee_per_gas: Some(0x3b9aca00),
90    blob_gas_used: None,
91    excess_blob_gas: None,
92    parent_beacon_block_root: None,
93    requests_hash: None,
94};
95
96/// Bedrock total difficulty on Optimism Mainnet.
97pub const BEDROCK_HEADER_TTD: U256 = U256::ZERO;
98
99#[cfg(test)]
100mod tests {
101    use super::*;
102
103    #[test]
104    fn test_bedrock_header() {
105        assert_eq!(BEDROCK_HEADER.hash_slow(), BEDROCK_HEADER_HASH);
106    }
107}