@@ -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 eyre:: WrapErr as _;
22+ use op_alloy_rpc_types_engine:: {
23+ OpFlashblockPayload , OpFlashblockPayloadBase , OpFlashblockPayloadDelta ,
24+ OpFlashblockPayloadMetadata ,
25+ } ;
2226use reth:: payload:: PayloadBuilderAttributes ;
2327use reth_basic_payload_builder:: BuildOutcome ;
2428use reth_chain_state:: ExecutedBlock ;
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_util:: BestPayloadTransactions ;
3438use reth_primitives_traits:: RecoveredBlock ;
3539use reth_provider:: {
@@ -42,11 +46,8 @@ use reth_revm::{
4246use reth_transaction_pool:: TransactionPool ;
4347use reth_trie:: { HashedPostState , updates:: TrieUpdates } ;
4448use revm:: Database ;
45- use rollup_boost:: {
46- ExecutionPayloadBaseV1 , ExecutionPayloadFlashblockDeltaV1 , FlashblocksPayloadV1 ,
47- } ;
48- use serde:: { Deserialize , Serialize } ;
4949use std:: {
50+ collections:: BTreeMap ,
5051 ops:: { Div , Rem } ,
5152 sync:: Arc ,
5253 time:: Instant ,
@@ -55,6 +56,24 @@ use tokio::sync::mpsc;
5556use tokio_util:: sync:: CancellationToken ;
5657use tracing:: { debug, error, info, metadata:: Level , span, warn} ;
5758
59+ /// Converts a reth OpReceipt to an op-alloy OpReceipt
60+ /// TODO: remove this once reth updates to use the op-alloy defined type as well.
61+ fn convert_receipt ( receipt : & OpReceipt ) -> op_alloy_consensus:: OpReceipt {
62+ match receipt {
63+ OpReceipt :: Legacy ( r) => op_alloy_consensus:: OpReceipt :: Legacy ( r. clone ( ) ) ,
64+ OpReceipt :: Eip2930 ( r) => op_alloy_consensus:: OpReceipt :: Eip2930 ( r. clone ( ) ) ,
65+ OpReceipt :: Eip1559 ( r) => op_alloy_consensus:: OpReceipt :: Eip1559 ( r. clone ( ) ) ,
66+ OpReceipt :: Eip7702 ( r) => op_alloy_consensus:: OpReceipt :: Eip7702 ( r. clone ( ) ) ,
67+ OpReceipt :: Deposit ( r) => {
68+ op_alloy_consensus:: OpReceipt :: Deposit ( op_alloy_consensus:: OpDepositReceipt {
69+ inner : r. inner . clone ( ) ,
70+ deposit_nonce : r. deposit_nonce ,
71+ deposit_receipt_version : r. deposit_receipt_version ,
72+ } )
73+ }
74+ }
75+ }
76+
5877type NextBestFlashblocksTxs < Pool > = BestFlashblocksTxs <
5978 <Pool as TransactionPool >:: Transaction ,
6079 Box <
@@ -939,13 +958,6 @@ where
939958 }
940959}
941960
942- #[ derive( Debug , Serialize , Deserialize ) ]
943- struct FlashblocksMetadata {
944- receipts : HashMap < B256 , <OpPrimitives as NodePrimitives >:: Receipt > ,
945- new_account_balances : HashMap < Address , U256 > ,
946- block_number : u64 ,
947- }
948-
949961fn execute_pre_steps < DB , ExtraCtx > (
950962 state : & mut State < DB > ,
951963 ctx : & OpPayloadBuilderCtx < ExtraCtx > ,
@@ -971,7 +983,7 @@ pub(super) fn build_block<DB, P, ExtraCtx>(
971983 ctx : & OpPayloadBuilderCtx < ExtraCtx > ,
972984 info : & mut ExecutionInfo < FlashblocksExecutionInfo > ,
973985 calculate_state_root : bool ,
974- ) -> Result < ( OpBuiltPayload , FlashblocksPayloadV1 ) , PayloadBuilderError >
986+ ) -> Result < ( OpBuiltPayload , OpFlashblockPayload ) , PayloadBuilderError >
975987where
976988 DB : Database < Error = ProviderError > + AsRef < P > ,
977989 P : StateRootProvider + HashedPostStateProvider + StorageRootProvider ,
@@ -1138,16 +1150,16 @@ where
11381150 let receipts_with_hash = new_transactions
11391151 . iter ( )
11401152 . zip ( new_receipts. iter ( ) )
1141- . map ( |( tx, receipt) | ( tx. tx_hash ( ) , receipt . clone ( ) ) )
1142- . collect :: < HashMap < B256 , OpReceipt > > ( ) ;
1153+ . map ( |( tx, receipt) | ( tx. tx_hash ( ) , convert_receipt ( receipt ) ) )
1154+ . collect :: < BTreeMap < B256 , op_alloy_consensus :: OpReceipt > > ( ) ;
11431155 let new_account_balances = state
11441156 . bundle_state
11451157 . state
11461158 . iter ( )
11471159 . filter_map ( |( address, account) | account. info . as_ref ( ) . map ( |info| ( * address, info. balance ) ) )
1148- . collect :: < HashMap < Address , U256 > > ( ) ;
1160+ . collect :: < BTreeMap < Address , U256 > > ( ) ;
11491161
1150- let metadata: FlashblocksMetadata = FlashblocksMetadata {
1162+ let metadata = OpFlashblockPayloadMetadata {
11511163 receipts : receipts_with_hash,
11521164 new_account_balances,
11531165 block_number : ctx. parent ( ) . number + 1 ,
@@ -1156,10 +1168,10 @@ where
11561168 let ( _, blob_gas_used) = ctx. blob_fields ( info) ;
11571169
11581170 // Prepare the flashblocks message
1159- let fb_payload = FlashblocksPayloadV1 {
1171+ let fb_payload = OpFlashblockPayload {
11601172 payload_id : ctx. payload_id ( ) ,
11611173 index : 0 ,
1162- base : Some ( ExecutionPayloadBaseV1 {
1174+ base : Some ( OpFlashblockPayloadBase {
11631175 parent_beacon_block_root : ctx
11641176 . attributes ( )
11651177 . payload_attributes
@@ -1172,9 +1184,9 @@ where
11721184 gas_limit : ctx. block_gas_limit ( ) ,
11731185 timestamp : ctx. attributes ( ) . payload_attributes . timestamp ,
11741186 extra_data : ctx. extra_data ( ) ?,
1175- base_fee_per_gas : ctx. base_fee ( ) . try_into ( ) . unwrap ( ) ,
1187+ base_fee_per_gas : U256 :: from ( ctx. base_fee ( ) ) ,
11761188 } ) ,
1177- diff : ExecutionPayloadFlashblockDeltaV1 {
1189+ diff : OpFlashblockPayloadDelta {
11781190 state_root,
11791191 receipts_root,
11801192 logs_bloom,
@@ -1185,7 +1197,7 @@ where
11851197 withdrawals_root : withdrawals_root. unwrap_or_default ( ) ,
11861198 blob_gas_used,
11871199 } ,
1188- metadata : serde_json :: to_value ( & metadata ) . unwrap_or_default ( ) ,
1200+ metadata,
11891201 } ;
11901202
11911203 // We clean bundle and place initial state transaction back
0 commit comments