11use alloy:: consensus:: { Header as ConsensusHeader , Transaction as TxTrait } ;
2- use alloy:: primitives:: { b256, fixed_bytes, keccak256, Address , B256 , U256 , U64 } ;
2+ use alloy:: primitives:: { b256, fixed_bytes, keccak256, Address , Bloom , BloomInput , B256 , U256 } ;
33use alloy:: rlp:: Decodable ;
44use alloy:: rpc:: types:: {
55 Block , EIP1186AccountProofResponse , Header , Transaction as EthTransaction ,
66} ;
77use alloy_rlp:: encode;
88use eyre:: { eyre, OptionExt , Result } ;
99use op_alloy_consensus:: OpTxEnvelope ;
10+ use op_alloy_network:: primitives:: BlockTransactions ;
1011use op_alloy_rpc_types:: Transaction ;
1112use std:: str:: FromStr ;
1213use std:: time:: Duration ;
@@ -82,7 +83,7 @@ impl ConsensusClient {
8283 }
8384}
8485
85- impl Consensus < Transaction > for ConsensusClient {
86+ impl Consensus < Block < Transaction > > for ConsensusClient {
8687 fn chain_id ( & self ) -> u64 {
8788 self . chain_id
8889 }
@@ -142,7 +143,7 @@ impl Inner {
142143 let number = payload. block_number ;
143144
144145 if let Ok ( block) = payload_to_block ( payload) {
145- self . latest_block = Some ( block. number . to ( ) ) ;
146+ self . latest_block = Some ( block. header . number ) ;
146147 _ = self . block_send . send ( block) . await ;
147148
148149 tracing:: info!(
@@ -193,7 +194,10 @@ fn verify_unsafe_signer(config: Config, signer: Arc<Mutex<Address>>) {
193194 . ok_or_eyre ( "failed to receive block" ) ?;
194195
195196 // Query proof from op consensus server
196- let req = format ! ( "{}unsafe_signer_proof/{}" , config. consensus_rpc, block. hash) ;
197+ let req = format ! (
198+ "{}unsafe_signer_proof/{}" ,
199+ config. consensus_rpc, block. header. hash
200+ ) ;
197201 let proof = reqwest:: get ( req)
198202 . await ?
199203 . json :: < EIP1186AccountProofResponse > ( )
@@ -205,7 +209,7 @@ fn verify_unsafe_signer(config: Config, signer: Arc<Mutex<Address>>) {
205209 let account_encoded = encode_account ( & proof) ;
206210 let is_valid = verify_proof (
207211 & proof. account_proof ,
208- block. state_root . as_slice ( ) ,
212+ block. header . state_root . as_slice ( ) ,
209213 & account_path,
210214 & account_encoded,
211215 ) ;
@@ -340,36 +344,38 @@ fn payload_to_block(value: ExecutionPayload) -> Result<Block<Transaction>> {
340344
341345 let withdrawals = value. withdrawals . iter ( ) . map ( |v| encode ( v) ) ;
342346 let withdrawals_root = ordered_trie_root ( withdrawals) ;
347+ let logs_bloom: Bloom = Bloom :: from ( BloomInput :: Raw ( & value. logs_bloom . to_vec ( ) ) ) ;
343348
344349 let consensus_header = ConsensusHeader {
345- parent_hash : * value. block_hash ( ) ,
350+ parent_hash : value. parent_hash . into ( ) ,
346351 ommers_hash : empty_uncle_hash,
347- beneficiary : * value. fee_recipient ( ) ,
348- state_root : * value. state_root ( ) ,
352+ beneficiary : Address :: from ( * value. fee_recipient ) ,
353+ state_root : value. state_root . into ( ) ,
349354 transactions_root : B256 :: from_slice ( txs_root. as_bytes ( ) ) ,
350- receipts_root : * value. receipts_root ( ) ,
355+ receipts_root : value. receipts_root . into ( ) ,
351356 withdrawals_root : Some ( B256 :: from_slice ( withdrawals_root. as_bytes ( ) ) ) ,
352- logs_bloom : value . logs_bloom ( ) . inner . to_vec ( ) . into ( ) ,
357+ logs_bloom : logs_bloom,
353358 difficulty : U256 :: ZERO ,
354- number : * value. block_number ( ) ,
355- gas_limit : * value. gas_limit ( ) ,
356- gas_used : * value. gas_used ( ) ,
357- timestamp : * value. timestamp ( ) ,
358- mix_hash : * value. prev_randao ( ) ,
359+ number : value. block_number ,
360+ gas_limit : value. gas_limit ,
361+ gas_used : value. gas_used ,
362+ timestamp : value. timestamp ,
363+ mix_hash : value. prev_randao . into ( ) ,
359364 nonce : empty_nonce,
360- base_fee_per_gas : Some ( * value. base_fee_per_gas ( ) . into ( ) ) ,
361- blob_gas_used : value. blob_gas_used ( ) . cloned ( ) . ok ( ) ,
362- excess_blob_gas : value. excess_blob_gas ( ) . cloned ( ) . ok ( ) ,
363- parent_beacon_block_root : Some ( * value . parent_hash ( ) ) ,
364- extra_data : value. extra_data ( ) . inner . to_vec ( ) . into ( ) ,
365+ base_fee_per_gas : Some ( value. base_fee_per_gas . to :: < u64 > ( ) ) ,
366+ blob_gas_used : Some ( value. blob_gas_used ) ,
367+ excess_blob_gas : Some ( value. excess_blob_gas ) ,
368+ parent_beacon_block_root : None ,
369+ extra_data : value. extra_data . to_vec ( ) . into ( ) ,
365370 requests_hash : None ,
366371 } ;
367372
368- let header = Header :: from_consensus (
369- Sealed :: new ( consensus_header) ,
370- Some ( U256 :: ZERO ) ,
371- Some ( U256 :: ZERO ) ,
372- ) ;
373+ let header = Header {
374+ hash : value. block_hash ,
375+ inner : consensus_header,
376+ total_difficulty : Some ( U256 :: ZERO ) ,
377+ size : Some ( U256 :: ZERO ) ,
378+ } ;
373379
374380 Ok ( Block :: new ( header, BlockTransactions :: Full ( txs) ) )
375381}
0 commit comments