11use crate :: journal:: { AcctDiff , BundleStateIndex , InfoOutcome } ;
22use alloy:: {
3+ consensus:: Header ,
34 primitives:: { Address , Bytes , B256 , U256 } ,
45 rlp:: { Buf , BufMut } ,
56} ;
@@ -69,6 +70,9 @@ pub enum JournalDecodeError {
6970
7071 /// Error decoding an EIP-7702 bytecode.
7172 Eip7702Decode ( Eip7702DecodeError ) ,
73+
74+ /// RLP decoding error.
75+ Rlp ( alloy:: rlp:: Error ) ,
7276}
7377
7478impl core:: fmt:: Display for JournalDecodeError {
@@ -89,6 +93,9 @@ impl core::fmt::Display for JournalDecodeError {
8993 Self :: Eip7702Decode ( e) => {
9094 write ! ( f, "error decoding EIP-7702 bytecode: {e}" )
9195 }
96+ Self :: Rlp ( e) => {
97+ write ! ( f, "error decoding RLP: {e}" )
98+ }
9299 }
93100 }
94101}
@@ -97,6 +104,7 @@ impl core::error::Error for JournalDecodeError {
97104 fn cause ( & self ) -> Option < & dyn core:: error:: Error > {
98105 match self {
99106 Self :: Eip7702Decode ( e) => Some ( e) ,
107+ Self :: Rlp ( e) => Some ( e) ,
100108 _ => None ,
101109 }
102110 }
@@ -108,6 +116,7 @@ impl core::error::Error for JournalDecodeError {
108116 fn source ( & self ) -> Option < & ( dyn core:: error:: Error + ' static ) > {
109117 match self {
110118 Self :: Eip7702Decode ( e) => Some ( e) ,
119+ Self :: Rlp ( e) => Some ( e) ,
111120 _ => None ,
112121 }
113122 }
@@ -119,6 +128,12 @@ impl From<Eip7702DecodeError> for JournalDecodeError {
119128 }
120129}
121130
131+ impl From < alloy:: rlp:: Error > for JournalDecodeError {
132+ fn from ( err : alloy:: rlp:: Error ) -> Self {
133+ Self :: Rlp ( err)
134+ }
135+ }
136+
122137macro_rules! check_len {
123138 ( $buf: ident, $ty_name: literal, $len: expr) => {
124139 let rem = $buf. remaining( ) ;
@@ -601,6 +616,24 @@ impl JournalDecode for BundleState {
601616 }
602617}
603618
619+ impl JournalEncode for Header {
620+ fn serialized_size ( & self ) -> usize {
621+ // Assuming the header is encoded in a way that is compatible with RLP
622+ alloy:: rlp:: Encodable :: length ( & self )
623+ }
624+
625+ fn encode ( & self , buf : & mut dyn BufMut ) {
626+ // Assuming the header is encoded in a way that is compatible with RLP
627+ alloy:: rlp:: Encodable :: encode ( self , buf) ;
628+ }
629+ }
630+
631+ impl JournalDecode for Header {
632+ fn decode ( buf : & mut & [ u8 ] ) -> Result < Self > {
633+ alloy:: rlp:: Decodable :: decode ( buf) . map_err ( Into :: into)
634+ }
635+ }
636+
604637#[ cfg( test) ]
605638mod test {
606639 use super :: * ;
0 commit comments