@@ -16,20 +16,24 @@ use alloy_consensus::{
1616 BlockBody , EMPTY_OMMER_ROOT_HASH , Header , constants:: EMPTY_WITHDRAWALS , proofs,
1717} ;
1818use alloy_eips:: { Encodable2718 , eip7685:: EMPTY_REQUESTS_HASH , merge:: BEACON_NONCE } ;
19- use alloy_primitives:: { Address , B256 , U256 , map :: foldhash :: HashMap } ;
19+ use alloy_primitives:: { Address , B256 , U256 } ;
2020use core:: time:: Duration ;
2121use either:: Either ;
2222use eyre:: WrapErr as _;
23+ use op_alloy_rpc_types_engine:: {
24+ OpFlashblockPayload , OpFlashblockPayloadBase , OpFlashblockPayloadDelta ,
25+ OpFlashblockPayloadMetadata ,
26+ } ;
2327use reth:: payload:: PayloadBuilderAttributes ;
2428use reth_basic_payload_builder:: BuildOutcome ;
2529use reth_chainspec:: EthChainSpec ;
2630use reth_evm:: { ConfigureEvm , execute:: BlockBuilder } ;
27- use reth_node_api:: { Block , NodePrimitives , PayloadBuilderError } ;
31+ use reth_node_api:: { Block , PayloadBuilderError } ;
2832use reth_optimism_consensus:: { calculate_receipt_root_no_memo_optimism, isthmus} ;
2933use reth_optimism_evm:: { OpEvmConfig , OpNextBlockEnvAttributes } ;
3034use reth_optimism_forks:: OpHardforks ;
3135use reth_optimism_node:: { OpBuiltPayload , OpPayloadBuilderAttributes } ;
32- use reth_optimism_primitives:: { OpPrimitives , OpReceipt , OpTransactionSigned } ;
36+ use reth_optimism_primitives:: { OpReceipt , OpTransactionSigned } ;
3337use reth_payload_primitives:: BuiltPayloadExecutedBlock ;
3438use reth_payload_util:: BestPayloadTransactions ;
3539use reth_primitives_traits:: RecoveredBlock ;
@@ -43,11 +47,8 @@ use reth_revm::{
4347use reth_transaction_pool:: TransactionPool ;
4448use reth_trie:: { HashedPostState , updates:: TrieUpdates } ;
4549use revm:: Database ;
46- use rollup_boost:: {
47- ExecutionPayloadBaseV1 , ExecutionPayloadFlashblockDeltaV1 , FlashblocksPayloadV1 ,
48- } ;
49- use serde:: { Deserialize , Serialize } ;
5050use std:: {
51+ collections:: BTreeMap ,
5152 ops:: { Div , Rem } ,
5253 sync:: Arc ,
5354 time:: Instant ,
@@ -56,6 +57,24 @@ use tokio::sync::mpsc;
5657use tokio_util:: sync:: CancellationToken ;
5758use tracing:: { debug, error, info, metadata:: Level , span, warn} ;
5859
60+ /// Converts a reth OpReceipt to an op-alloy OpReceipt
61+ /// TODO: remove this once reth updates to use the op-alloy defined type as well.
62+ fn convert_receipt ( receipt : & OpReceipt ) -> op_alloy_consensus:: OpReceipt {
63+ match receipt {
64+ OpReceipt :: Legacy ( r) => op_alloy_consensus:: OpReceipt :: Legacy ( r. clone ( ) ) ,
65+ OpReceipt :: Eip2930 ( r) => op_alloy_consensus:: OpReceipt :: Eip2930 ( r. clone ( ) ) ,
66+ OpReceipt :: Eip1559 ( r) => op_alloy_consensus:: OpReceipt :: Eip1559 ( r. clone ( ) ) ,
67+ OpReceipt :: Eip7702 ( r) => op_alloy_consensus:: OpReceipt :: Eip7702 ( r. clone ( ) ) ,
68+ OpReceipt :: Deposit ( r) => {
69+ op_alloy_consensus:: OpReceipt :: Deposit ( op_alloy_consensus:: OpDepositReceipt {
70+ inner : r. inner . clone ( ) ,
71+ deposit_nonce : r. deposit_nonce ,
72+ deposit_receipt_version : r. deposit_receipt_version ,
73+ } )
74+ }
75+ }
76+ }
77+
5978type NextBestFlashblocksTxs < Pool > = BestFlashblocksTxs <
6079 <Pool as TransactionPool >:: Transaction ,
6180 Box <
@@ -916,13 +935,6 @@ where
916935 }
917936}
918937
919- #[ derive( Debug , Serialize , Deserialize ) ]
920- struct FlashblocksMetadata {
921- receipts : HashMap < B256 , <OpPrimitives as NodePrimitives >:: Receipt > ,
922- new_account_balances : HashMap < Address , U256 > ,
923- block_number : u64 ,
924- }
925-
926938fn execute_pre_steps < DB , ExtraCtx > (
927939 state : & mut State < DB > ,
928940 ctx : & OpPayloadBuilderCtx < ExtraCtx > ,
@@ -948,7 +960,7 @@ pub(super) fn build_block<DB, P, ExtraCtx>(
948960 ctx : & OpPayloadBuilderCtx < ExtraCtx > ,
949961 info : & mut ExecutionInfo < FlashblocksExecutionInfo > ,
950962 calculate_state_root : bool ,
951- ) -> Result < ( OpBuiltPayload , FlashblocksPayloadV1 ) , PayloadBuilderError >
963+ ) -> Result < ( OpBuiltPayload , OpFlashblockPayload ) , PayloadBuilderError >
952964where
953965 DB : Database < Error = ProviderError > + AsRef < P > ,
954966 P : StateRootProvider + HashedPostStateProvider + StorageRootProvider ,
@@ -1115,16 +1127,16 @@ where
11151127 let receipts_with_hash = new_transactions
11161128 . iter ( )
11171129 . zip ( new_receipts. iter ( ) )
1118- . map ( |( tx, receipt) | ( tx. tx_hash ( ) , receipt . clone ( ) ) )
1119- . collect :: < HashMap < B256 , OpReceipt > > ( ) ;
1130+ . map ( |( tx, receipt) | ( tx. tx_hash ( ) , convert_receipt ( receipt ) ) )
1131+ . collect :: < BTreeMap < B256 , op_alloy_consensus :: OpReceipt > > ( ) ;
11201132 let new_account_balances = state
11211133 . bundle_state
11221134 . state
11231135 . iter ( )
11241136 . filter_map ( |( address, account) | account. info . as_ref ( ) . map ( |info| ( * address, info. balance ) ) )
1125- . collect :: < HashMap < Address , U256 > > ( ) ;
1137+ . collect :: < BTreeMap < Address , U256 > > ( ) ;
11261138
1127- let metadata: FlashblocksMetadata = FlashblocksMetadata {
1139+ let metadata = OpFlashblockPayloadMetadata {
11281140 receipts : receipts_with_hash,
11291141 new_account_balances,
11301142 block_number : ctx. parent ( ) . number + 1 ,
@@ -1133,10 +1145,10 @@ where
11331145 let ( _, blob_gas_used) = ctx. blob_fields ( info) ;
11341146
11351147 // Prepare the flashblocks message
1136- let fb_payload = FlashblocksPayloadV1 {
1148+ let fb_payload = OpFlashblockPayload {
11371149 payload_id : ctx. payload_id ( ) ,
11381150 index : 0 ,
1139- base : Some ( ExecutionPayloadBaseV1 {
1151+ base : Some ( OpFlashblockPayloadBase {
11401152 parent_beacon_block_root : ctx
11411153 . attributes ( )
11421154 . payload_attributes
@@ -1149,9 +1161,9 @@ where
11491161 gas_limit : ctx. block_gas_limit ( ) ,
11501162 timestamp : ctx. attributes ( ) . payload_attributes . timestamp ,
11511163 extra_data : ctx. extra_data ( ) ?,
1152- base_fee_per_gas : ctx. base_fee ( ) . try_into ( ) . unwrap ( ) ,
1164+ base_fee_per_gas : U256 :: from ( ctx. base_fee ( ) ) ,
11531165 } ) ,
1154- diff : ExecutionPayloadFlashblockDeltaV1 {
1166+ diff : OpFlashblockPayloadDelta {
11551167 state_root,
11561168 receipts_root,
11571169 logs_bloom,
@@ -1162,7 +1174,7 @@ where
11621174 withdrawals_root : withdrawals_root. unwrap_or_default ( ) ,
11631175 blob_gas_used,
11641176 } ,
1165- metadata : serde_json :: to_value ( & metadata ) . unwrap_or_default ( ) ,
1177+ metadata,
11661178 } ;
11671179
11681180 // We clean bundle and place initial state transaction back
0 commit comments