@@ -308,7 +308,8 @@ pub struct JsonExecutionPayload<T: EthSpec> {
308308 pub base_fee_per_gas : Uint256 ,
309309 pub block_hash : Hash256 ,
310310 #[ serde( with = "serde_transactions" ) ]
311- pub transactions : VariableList < Transaction < T > , T :: MaxTransactionsPerPayload > ,
311+ pub transactions :
312+ VariableList < Transaction < T :: MaxBytesPerTransaction > , T :: MaxTransactionsPerPayload > ,
312313}
313314
314315impl < T : EthSpec > From < ExecutionPayload < T > > for JsonExecutionPayload < T > {
@@ -410,16 +411,16 @@ pub mod serde_transactions {
410411 use serde:: { de, Deserializer , Serializer } ;
411412 use std:: marker:: PhantomData ;
412413
413- type Value < T , N > = VariableList < Transaction < T > , N > ;
414+ type Value < M , N > = VariableList < Transaction < M > , N > ;
414415
415416 #[ derive( Default ) ]
416- pub struct ListOfBytesListVisitor < T , N > {
417- _phantom_t : PhantomData < T > ,
417+ pub struct ListOfBytesListVisitor < M , N > {
418+ _phantom_m : PhantomData < M > ,
418419 _phantom_n : PhantomData < N > ,
419420 }
420421
421- impl < ' a , T : EthSpec , N : Unsigned > serde:: de:: Visitor < ' a > for ListOfBytesListVisitor < T , N > {
422- type Value = Value < T , N > ;
422+ impl < ' a , M : Unsigned , N : Unsigned > serde:: de:: Visitor < ' a > for ListOfBytesListVisitor < M , N > {
423+ type Value = Value < M , N > ;
423424
424425 fn expecting ( & self , formatter : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
425426 write ! ( formatter, "a list of 0x-prefixed byte lists" )
@@ -433,10 +434,9 @@ pub mod serde_transactions {
433434
434435 while let Some ( val) = seq. next_element :: < String > ( ) ? {
435436 let inner_vec = hex:: decode ( & val) . map_err ( de:: Error :: custom) ?;
436- let opaque_transaction = VariableList :: new ( inner_vec) . map_err ( |e| {
437+ let transaction = VariableList :: new ( inner_vec) . map_err ( |e| {
437438 serde:: de:: Error :: custom ( format ! ( "transaction too large: {:?}" , e) )
438439 } ) ?;
439- let transaction = Transaction :: OpaqueTransaction ( opaque_transaction) ;
440440 outer. push ( transaction) . map_err ( |e| {
441441 serde:: de:: Error :: custom ( format ! ( "too many transactions: {:?}" , e) )
442442 } ) ?;
@@ -446,8 +446,8 @@ pub mod serde_transactions {
446446 }
447447 }
448448
449- pub fn serialize < S , T : EthSpec , N : Unsigned > (
450- value : & Value < T , N > ,
449+ pub fn serialize < S , M : Unsigned , N : Unsigned > (
450+ value : & Value < M , N > ,
451451 serializer : S ,
452452 ) -> Result < S :: Ok , S :: Error >
453453 where
@@ -458,21 +458,19 @@ pub mod serde_transactions {
458458 // It's important to match on the inner values of the transaction. Serializing the
459459 // entire `Transaction` will result in appending the SSZ union prefix byte. The
460460 // execution node does not want that.
461- let hex = match transaction {
462- Transaction :: OpaqueTransaction ( val) => hex:: encode ( & val[ ..] ) ,
463- } ;
461+ let hex = hex:: encode ( & transaction[ ..] ) ;
464462 seq. serialize_element ( & hex) ?;
465463 }
466464 seq. end ( )
467465 }
468466
469- pub fn deserialize < ' de , D , T : EthSpec , N : Unsigned > (
467+ pub fn deserialize < ' de , D , M : Unsigned , N : Unsigned > (
470468 deserializer : D ,
471- ) -> Result < Value < T , N > , D :: Error >
469+ ) -> Result < Value < M , N > , D :: Error >
472470 where
473471 D : Deserializer < ' de > ,
474472 {
475- let visitor: ListOfBytesListVisitor < T , N > = <_ >:: default ( ) ;
473+ let visitor: ListOfBytesListVisitor < M , N > = <_ >:: default ( ) ;
476474 deserializer. deserialize_any ( visitor)
477475 }
478476}
@@ -558,7 +556,10 @@ mod test {
558556 const LOGS_BLOOM_01 : & str = "0x01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101" ;
559557
560558 fn encode_transactions < E : EthSpec > (
561- transactions : VariableList < Transaction < E > , E :: MaxTransactionsPerPayload > ,
559+ transactions : VariableList <
560+ Transaction < E :: MaxBytesPerTransaction > ,
561+ E :: MaxTransactionsPerPayload ,
562+ > ,
562563 ) -> Result < serde_json:: Value , serde_json:: Error > {
563564 let ep: JsonExecutionPayload < E > = JsonExecutionPayload {
564565 transactions,
@@ -570,7 +571,10 @@ mod test {
570571
571572 fn decode_transactions < E : EthSpec > (
572573 transactions : serde_json:: Value ,
573- ) -> Result < VariableList < Transaction < E > , E :: MaxTransactionsPerPayload > , serde_json:: Error > {
574+ ) -> Result <
575+ VariableList < Transaction < E :: MaxBytesPerTransaction > , E :: MaxTransactionsPerPayload > ,
576+ serde_json:: Error ,
577+ > {
574578 let json = json ! ( {
575579 "parentHash" : HASH_00 ,
576580 "coinbase" : ADDRESS_01 ,
@@ -593,35 +597,35 @@ mod test {
593597
594598 fn assert_transactions_serde < E : EthSpec > (
595599 name : & str ,
596- as_obj : VariableList < Transaction < E > , E :: MaxTransactionsPerPayload > ,
600+ as_obj : VariableList < Transaction < E :: MaxBytesPerTransaction > , E :: MaxTransactionsPerPayload > ,
597601 as_json : serde_json:: Value ,
598602 ) {
599603 assert_eq ! (
600- encode_transactions( as_obj. clone( ) ) . unwrap( ) ,
604+ encode_transactions:: < E > ( as_obj. clone( ) ) . unwrap( ) ,
601605 as_json,
602606 "encoding for {}" ,
603607 name
604608 ) ;
605609 assert_eq ! (
606- decode_transactions( as_json) . unwrap( ) ,
610+ decode_transactions:: < E > ( as_json) . unwrap( ) ,
607611 as_obj,
608612 "decoding for {}" ,
609613 name
610614 ) ;
611615 }
612616
613617 /// Example: if `spec == &[1, 1]`, then two one-byte transactions will be created.
614- fn generate_opaque_transactions < E : EthSpec > (
618+ fn generate_transactions < E : EthSpec > (
615619 spec : & [ usize ] ,
616- ) -> VariableList < Transaction < E > , E :: MaxTransactionsPerPayload > {
620+ ) -> VariableList < Transaction < E :: MaxBytesPerTransaction > , E :: MaxTransactionsPerPayload > {
617621 let mut txs = VariableList :: default ( ) ;
618622
619623 for & num_bytes in spec {
620624 let mut tx = VariableList :: default ( ) ;
621625 for _ in 0 ..num_bytes {
622626 tx. push ( 0 ) . unwrap ( ) ;
623627 }
624- txs. push ( Transaction :: OpaqueTransaction ( tx ) ) . unwrap ( ) ;
628+ txs. push ( tx ) . unwrap ( ) ;
625629 }
626630
627631 txs
@@ -631,32 +635,32 @@ mod test {
631635 fn transaction_serde ( ) {
632636 assert_transactions_serde :: < MainnetEthSpec > (
633637 "empty" ,
634- generate_opaque_transactions ( & [ ] ) ,
638+ generate_transactions :: < MainnetEthSpec > ( & [ ] ) ,
635639 json ! ( [ ] ) ,
636640 ) ;
637641 assert_transactions_serde :: < MainnetEthSpec > (
638642 "one empty tx" ,
639- generate_opaque_transactions ( & [ 0 ] ) ,
643+ generate_transactions :: < MainnetEthSpec > ( & [ 0 ] ) ,
640644 json ! ( [ "0x" ] ) ,
641645 ) ;
642646 assert_transactions_serde :: < MainnetEthSpec > (
643647 "two empty txs" ,
644- generate_opaque_transactions ( & [ 0 , 0 ] ) ,
648+ generate_transactions :: < MainnetEthSpec > ( & [ 0 , 0 ] ) ,
645649 json ! ( [ "0x" , "0x" ] ) ,
646650 ) ;
647651 assert_transactions_serde :: < MainnetEthSpec > (
648652 "one one-byte tx" ,
649- generate_opaque_transactions ( & [ 1 ] ) ,
653+ generate_transactions :: < MainnetEthSpec > ( & [ 1 ] ) ,
650654 json ! ( [ "0x00" ] ) ,
651655 ) ;
652656 assert_transactions_serde :: < MainnetEthSpec > (
653657 "two one-byte txs" ,
654- generate_opaque_transactions ( & [ 1 , 1 ] ) ,
658+ generate_transactions :: < MainnetEthSpec > ( & [ 1 , 1 ] ) ,
655659 json ! ( [ "0x00" , "0x00" ] ) ,
656660 ) ;
657661 assert_transactions_serde :: < MainnetEthSpec > (
658662 "mixed bag" ,
659- generate_opaque_transactions ( & [ 0 , 1 , 3 , 0 ] ) ,
663+ generate_transactions :: < MainnetEthSpec > ( & [ 0 , 1 , 3 , 0 ] ) ,
660664 json ! ( [ "0x" , "0x00" , "0x000000" , "0x" ] ) ,
661665 ) ;
662666
@@ -680,7 +684,7 @@ mod test {
680684
681685 use eth2_serde_utils:: hex;
682686
683- let num_max_bytes = <MainnetEthSpec as EthSpec >:: MaxBytesPerOpaqueTransaction :: to_usize ( ) ;
687+ let num_max_bytes = <MainnetEthSpec as EthSpec >:: MaxBytesPerTransaction :: to_usize ( ) ;
684688 let max_bytes = ( 0 ..num_max_bytes) . map ( |_| 0_u8 ) . collect :: < Vec < _ > > ( ) ;
685689 let too_many_bytes = ( 0 ..=num_max_bytes) . map ( |_| 0_u8 ) . collect :: < Vec < _ > > ( ) ;
686690 decode_transactions :: < MainnetEthSpec > (
0 commit comments