@@ -5,7 +5,7 @@ use std::sync::Arc;
55use alloy:: consensus:: { Transaction as TxTrait , TxEnvelope } ;
66use alloy:: primitives:: { b256, fixed_bytes, B256 , U256 , U64 } ;
77use alloy:: rlp:: { encode, Decodable } ;
8- use alloy:: rpc:: types:: { Parity , Signature , Transaction } ;
8+ use alloy:: rpc:: types:: Transaction ;
99use chrono:: Duration ;
1010use eyre:: eyre;
1111use eyre:: Result ;
@@ -590,89 +590,16 @@ fn payload_to_block<S: ConsensusSpec>(value: ExecutionPayload<S>) -> Block<Trans
590590 let mut tx_bytes_slice = tx_bytes. as_slice ( ) ;
591591 let tx_envelope = TxEnvelope :: decode ( & mut tx_bytes_slice) . unwrap ( ) ;
592592
593- let mut tx = Transaction {
594- hash : * tx_envelope . tx_hash ( ) ,
595- nonce : tx_envelope . nonce ( ) ,
593+ let base_fee = Some ( value . base_fee_per_gas ( ) . to ( ) ) ;
594+
595+ Transaction {
596596 block_hash : Some ( * value. block_hash ( ) ) ,
597597 block_number : Some ( * value. block_number ( ) ) ,
598598 transaction_index : Some ( i as u64 ) ,
599- to : tx_envelope. to ( ) . to ( ) . cloned ( ) ,
600- value : tx_envelope. value ( ) ,
601- gas_price : tx_envelope. gas_price ( ) ,
602- gas : tx_envelope. gas_limit ( ) ,
603- input : tx_envelope. input ( ) . to_vec ( ) . into ( ) ,
604- chain_id : tx_envelope. chain_id ( ) ,
605- transaction_type : Some ( tx_envelope. tx_type ( ) . into ( ) ) ,
606- ..Default :: default ( )
607- } ;
608-
609- match tx_envelope {
610- TxEnvelope :: Legacy ( inner) => {
611- tx. from = inner. recover_signer ( ) . unwrap ( ) ;
612- tx. signature = Some ( Signature {
613- r : inner. signature ( ) . r ( ) ,
614- s : inner. signature ( ) . s ( ) ,
615- v : U256 :: from ( inner. signature ( ) . v ( ) . to_u64 ( ) ) ,
616- y_parity : None ,
617- } ) ;
618- }
619- TxEnvelope :: Eip2930 ( inner) => {
620- tx. from = inner. recover_signer ( ) . unwrap ( ) ;
621- tx. signature = Some ( Signature {
622- r : inner. signature ( ) . r ( ) ,
623- s : inner. signature ( ) . s ( ) ,
624- v : U256 :: from ( inner. signature ( ) . v ( ) . to_u64 ( ) ) ,
625- y_parity : Some ( Parity ( inner. signature ( ) . v ( ) . to_u64 ( ) == 1 ) ) ,
626- } ) ;
627- tx. access_list = Some ( inner. tx ( ) . access_list . clone ( ) ) ;
628- }
629- TxEnvelope :: Eip1559 ( inner) => {
630- tx. from = inner. recover_signer ( ) . unwrap ( ) ;
631- tx. signature = Some ( Signature {
632- r : inner. signature ( ) . r ( ) ,
633- s : inner. signature ( ) . s ( ) ,
634- v : U256 :: from ( inner. signature ( ) . v ( ) . to_u64 ( ) ) ,
635- y_parity : Some ( Parity ( inner. signature ( ) . v ( ) . to_u64 ( ) == 1 ) ) ,
636- } ) ;
637-
638- let tx_inner = inner. tx ( ) ;
639- tx. access_list = Some ( tx_inner. access_list . clone ( ) ) ;
640- tx. max_fee_per_gas = Some ( tx_inner. max_fee_per_gas ) ;
641- tx. max_priority_fee_per_gas = Some ( tx_inner. max_priority_fee_per_gas ) ;
642-
643- tx. gas_price = Some ( gas_price (
644- tx_inner. max_fee_per_gas ,
645- tx_inner. max_priority_fee_per_gas ,
646- value. base_fee_per_gas ( ) . to ( ) ,
647- ) ) ;
648- }
649- TxEnvelope :: Eip4844 ( inner) => {
650- tx. from = inner. recover_signer ( ) . unwrap ( ) ;
651- tx. signature = Some ( Signature {
652- r : inner. signature ( ) . r ( ) ,
653- s : inner. signature ( ) . s ( ) ,
654- v : U256 :: from ( inner. signature ( ) . v ( ) . to_u64 ( ) ) ,
655- y_parity : Some ( Parity ( inner. signature ( ) . v ( ) . to_u64 ( ) == 1 ) ) ,
656- } ) ;
657-
658- let tx_inner = inner. tx ( ) . tx ( ) ;
659- tx. access_list = Some ( tx_inner. access_list . clone ( ) ) ;
660- tx. max_fee_per_gas = Some ( tx_inner. max_fee_per_gas ) ;
661- tx. max_priority_fee_per_gas = Some ( tx_inner. max_priority_fee_per_gas ) ;
662- tx. max_fee_per_blob_gas = Some ( tx_inner. max_fee_per_blob_gas ) ;
663- tx. gas_price = Some ( tx_inner. max_fee_per_gas ) ;
664- tx. blob_versioned_hashes = Some ( tx_inner. blob_versioned_hashes . clone ( ) ) ;
665-
666- tx. gas_price = Some ( gas_price (
667- tx_inner. max_fee_per_gas ,
668- tx_inner. max_priority_fee_per_gas ,
669- value. base_fee_per_gas ( ) . to ( ) ,
670- ) ) ;
671- }
672- _ => todo ! ( ) ,
599+ from : tx_envelope. recover_signer ( ) . unwrap ( ) . clone ( ) ,
600+ effective_gas_price : Some ( tx_envelope. effective_gas_price ( base_fee) ) ,
601+ inner : tx_envelope,
673602 }
674-
675- tx
676603 } )
677604 . collect :: < Vec < Transaction > > ( ) ;
678605
@@ -711,10 +638,6 @@ fn payload_to_block<S: ConsensusSpec>(value: ExecutionPayload<S>) -> Block<Trans
711638 }
712639}
713640
714- fn gas_price ( max_fee : u128 , max_prio_fee : u128 , base_fee : u128 ) -> u128 {
715- u128:: min ( max_fee, max_prio_fee + base_fee)
716- }
717-
718641#[ cfg( test) ]
719642mod tests {
720643 use std:: sync:: Arc ;
0 commit comments