11use alloy_consensus:: BlockHeader ;
2- use alloy_eips:: { eip4895 :: Withdrawals , Decodable2718 } ;
2+ use alloy_eips:: Decodable2718 ;
33use alloy_primitives:: { Address , Bytes , B256 } ;
44use alloy_rpc_types:: {
55 engine:: { PayloadAttributes as RpcPayloadAttributes , PayloadId } ,
66 Withdrawal ,
77} ;
88use reth_chainspec:: EthereumHardforks ;
99use reth_engine_local:: payload:: LocalPayloadAttributesBuilder ;
10- use reth_ethereum:: node:: api:: payload:: { PayloadAttributes , PayloadBuilderAttributes } ;
11- use reth_payload_builder:: EthPayloadBuilderAttributes ;
12- use reth_payload_primitives:: PayloadAttributesBuilder ;
10+ use reth_ethereum:: node:: api:: payload:: PayloadAttributes ;
11+ use reth_payload_primitives:: { payload_id, PayloadAttributesBuilder } ;
1312use reth_primitives_traits:: SealedHeader ;
1413use serde:: { Deserialize , Serialize } ;
1514
16- use crate :: tracing_ext:: RecordDurationOnDrop ;
17- use tracing:: { info, instrument} ;
18-
1915use crate :: error:: EvolveEngineError ;
16+ use crate :: tracing_ext:: RecordDurationOnDrop ;
2017use ev_primitives:: TransactionSigned ;
18+ use tracing:: { info, instrument} ;
2119
2220/// Evolve payload attributes that support passing transactions via Engine API.
2321#[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
@@ -33,6 +31,10 @@ pub struct EvolveEnginePayloadAttributes {
3331}
3432
3533impl PayloadAttributes for EvolveEnginePayloadAttributes {
34+ fn payload_id ( & self , parent_hash : & B256 ) -> PayloadId {
35+ payload_id ( parent_hash, & self . inner )
36+ }
37+
3638 fn timestamp ( & self ) -> u64 {
3739 self . inner . timestamp ( )
3840 }
@@ -57,33 +59,37 @@ impl From<RpcPayloadAttributes> for EvolveEnginePayloadAttributes {
5759}
5860
5961/// Evolve payload builder attributes.
60- #[ derive( Clone , Debug , PartialEq , Eq ) ]
62+ ///
63+ /// In reth v2.0.0, `PayloadBuilderAttributes` was removed. This type now implements
64+ /// `PayloadAttributes` directly and stores the decoded transactions from the Engine API.
65+ #[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
6166pub struct EvolveEnginePayloadBuilderAttributes {
62- /// Ethereum payload builder attributes.
63- pub ethereum_attributes : EthPayloadBuilderAttributes ,
67+ /// The inner RPC payload attributes.
68+ #[ serde( flatten) ]
69+ pub inner : RpcPayloadAttributes ,
70+ /// Parent block hash.
71+ pub parent : B256 ,
6472 /// Decoded transactions from the Engine API.
73+ #[ serde( skip) ]
6574 pub transactions : Vec < TransactionSigned > ,
6675 /// Gas limit for the payload.
76+ #[ serde( rename = "gasLimit" ) ]
6777 pub gas_limit : Option < u64 > ,
6878}
6979
70- impl PayloadBuilderAttributes for EvolveEnginePayloadBuilderAttributes {
71- type RpcPayloadAttributes = EvolveEnginePayloadAttributes ;
72- type Error = EvolveEngineError ;
73-
74- #[ instrument( skip( parent, attributes, _version) , fields(
80+ impl EvolveEnginePayloadBuilderAttributes {
81+ /// Creates builder attributes from RPC attributes with decoded transactions.
82+ #[ instrument( skip( parent, attributes) , fields(
7583 parent_hash = %parent,
7684 raw_tx_count = attributes. transactions. as_ref( ) . map_or( 0 , |t| t. len( ) ) ,
7785 gas_limit = ?attributes. gas_limit,
7886 duration_ms = tracing:: field:: Empty ,
7987 ) ) ]
80- fn try_new (
88+ pub fn try_new (
8189 parent : B256 ,
8290 attributes : EvolveEnginePayloadAttributes ,
83- _version : u8 ,
84- ) -> Result < Self , Self :: Error > {
91+ ) -> Result < Self , EvolveEngineError > {
8592 let _duration = RecordDurationOnDrop :: new ( ) ;
86- let ethereum_attributes = EthPayloadBuilderAttributes :: new ( parent, attributes. inner ) ;
8793
8894 // Decode transactions from bytes if provided.
8995 let transactions = attributes
@@ -102,47 +108,54 @@ impl PayloadBuilderAttributes for EvolveEnginePayloadBuilderAttributes {
102108 ) ;
103109
104110 Ok ( Self {
105- ethereum_attributes,
111+ inner : attributes. inner ,
112+ parent,
106113 transactions,
107114 gas_limit : attributes. gas_limit ,
108115 } )
109116 }
110117
111- fn payload_id ( & self ) -> PayloadId {
112- self . ethereum_attributes . id
118+ /// Returns the parent block hash.
119+ pub fn parent ( & self ) -> B256 {
120+ self . parent
113121 }
114122
115- fn parent ( & self ) -> B256 {
116- self . ethereum_attributes . parent
123+ /// Returns the suggested fee recipient.
124+ pub fn suggested_fee_recipient ( & self ) -> Address {
125+ self . inner . suggested_fee_recipient
117126 }
118127
119- fn timestamp ( & self ) -> u64 {
120- self . ethereum_attributes . timestamp
128+ /// Returns the prev randao value.
129+ pub fn prev_randao ( & self ) -> B256 {
130+ self . inner . prev_randao
121131 }
132+ }
122133
123- fn parent_beacon_block_root ( & self ) -> Option < B256 > {
124- self . ethereum_attributes . parent_beacon_block_root
134+ impl PayloadAttributes for EvolveEnginePayloadBuilderAttributes {
135+ fn payload_id ( & self , parent_hash : & B256 ) -> PayloadId {
136+ payload_id ( parent_hash, & self . inner )
125137 }
126138
127- fn suggested_fee_recipient ( & self ) -> Address {
128- self . ethereum_attributes . suggested_fee_recipient
139+ fn timestamp ( & self ) -> u64 {
140+ self . inner . timestamp
129141 }
130142
131- fn prev_randao ( & self ) -> B256 {
132- self . ethereum_attributes . prev_randao
143+ fn withdrawals ( & self ) -> Option < & Vec < Withdrawal > > {
144+ self . inner . withdrawals . as_ref ( )
133145 }
134146
135- fn withdrawals ( & self ) -> & Withdrawals {
136- & self . ethereum_attributes . withdrawals
147+ fn parent_beacon_block_root ( & self ) -> Option < B256 > {
148+ self . inner . parent_beacon_block_root
137149 }
138150}
139151
140- impl From < EthPayloadBuilderAttributes > for EvolveEnginePayloadBuilderAttributes {
141- fn from ( eth : EthPayloadBuilderAttributes ) -> Self {
152+ impl From < EvolveEnginePayloadAttributes > for EvolveEnginePayloadBuilderAttributes {
153+ fn from ( attrs : EvolveEnginePayloadAttributes ) -> Self {
142154 Self {
143- ethereum_attributes : eth,
155+ inner : attrs. inner ,
156+ parent : B256 :: ZERO ,
144157 transactions : Vec :: new ( ) ,
145- gas_limit : None ,
158+ gas_limit : attrs . gas_limit ,
146159 }
147160 }
148161}
@@ -206,7 +219,7 @@ mod tests {
206219 } ;
207220
208221 // we only care that the span was created with the right fields.
209- let _ = EvolveEnginePayloadBuilderAttributes :: try_new ( parent, attrs, 3 ) ;
222+ let _ = EvolveEnginePayloadBuilderAttributes :: try_new ( parent, attrs) ;
210223
211224 let span = collector
212225 . find_span ( "try_new" )
0 commit comments