@@ -14,11 +14,8 @@ use reth_codecs::Compact;
1414/// [EIP-7702 Set Code Transaction](https://eips.ethereum.org/EIPS/eip-7702)
1515///
1616/// Set EOA account code for one transaction
17- #[ cfg_attr(
18- any( test, feature = "reth-codec" ) ,
19- reth_codecs:: reth_codec( no_arbitrary, add_arbitrary_tests)
20- ) ]
21- #[ derive( Debug , Clone , PartialEq , Eq , Default ) ]
17+ #[ cfg_attr( any( test, feature = "reth-codec" ) , reth_codecs:: reth_codec) ]
18+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Default ) ]
2219pub struct TxEip7702 {
2320 /// Added as EIP-155: Simple replay attack protection
2421 pub chain_id : ChainId ,
@@ -247,91 +244,6 @@ impl TxEip7702 {
247244 }
248245}
249246
250- // TODO(onbjerg): This is temporary until we upstream `Arbitrary` to EIP-7702 types and `Signature`
251- // in alloy
252- #[ cfg( any( test, feature = "arbitrary" ) ) ]
253- impl < ' a > arbitrary:: Arbitrary < ' a > for TxEip7702 {
254- fn arbitrary ( u : & mut arbitrary:: Unstructured < ' a > ) -> arbitrary:: Result < Self > {
255- use arbitrary:: Arbitrary ;
256- #[ derive( Arbitrary ) ]
257- struct ArbitrarySignedAuth {
258- chain_id : ChainId ,
259- address : alloy_primitives:: Address ,
260- nonce : Option < u64 > ,
261- parity : bool ,
262- r : U256 ,
263- s : U256 ,
264- }
265-
266- let iter = u. arbitrary_iter :: < ArbitrarySignedAuth > ( ) ?;
267- let mut authorization_list = Vec :: new ( ) ;
268- for auth in iter {
269- let auth = auth?;
270-
271- let sig = alloy_primitives:: Signature :: from_rs_and_parity (
272- auth. r ,
273- auth. s ,
274- alloy_primitives:: Parity :: Parity ( auth. parity ) ,
275- )
276- . unwrap_or_else ( |_| {
277- // Give a default one if the randomly generated one failed
278- alloy_primitives:: Signature :: from_rs_and_parity (
279- alloy_primitives:: b256!(
280- "1fd474b1f9404c0c5df43b7620119ffbc3a1c3f942c73b6e14e9f55255ed9b1d"
281- )
282- . into ( ) ,
283- alloy_primitives:: b256!(
284- "29aca24813279a901ec13b5f7bb53385fa1fc627b946592221417ff74a49600d"
285- )
286- . into ( ) ,
287- false ,
288- )
289- . unwrap ( )
290- } ) ;
291-
292- authorization_list. push (
293- alloy_eips:: eip7702:: Authorization {
294- chain_id : auth. chain_id ,
295- address : auth. address ,
296- nonce : auth. nonce . into ( ) ,
297- }
298- . into_signed ( sig) ,
299- ) ;
300- }
301-
302- Ok ( Self {
303- chain_id : Arbitrary :: arbitrary ( u) ?,
304- nonce : Arbitrary :: arbitrary ( u) ?,
305- gas_limit : Arbitrary :: arbitrary ( u) ?,
306- max_fee_per_gas : Arbitrary :: arbitrary ( u) ?,
307- max_priority_fee_per_gas : Arbitrary :: arbitrary ( u) ?,
308- to : Arbitrary :: arbitrary ( u) ?,
309- value : Arbitrary :: arbitrary ( u) ?,
310- access_list : Arbitrary :: arbitrary ( u) ?,
311- authorization_list,
312- input : Arbitrary :: arbitrary ( u) ?,
313- } )
314- }
315- }
316-
317- // TODO(onbjerg): This is temporary until we upstream `Hash` for EIP-7702 types in alloy
318- impl core:: hash:: Hash for TxEip7702 {
319- fn hash < H : core:: hash:: Hasher > ( & self , state : & mut H ) {
320- self . chain_id . hash ( state) ;
321- self . nonce . hash ( state) ;
322- self . gas_limit . hash ( state) ;
323- self . max_fee_per_gas . hash ( state) ;
324- self . max_priority_fee_per_gas . hash ( state) ;
325- self . to . hash ( state) ;
326- self . value . hash ( state) ;
327- self . access_list . hash ( state) ;
328- for auth in & self . authorization_list {
329- auth. signature_hash ( ) . hash ( state) ;
330- }
331- self . input . hash ( state) ;
332- }
333- }
334-
335247#[ cfg( test) ]
336248mod tests {
337249 use super :: TxEip7702 ;
0 commit comments