@@ -44,11 +44,48 @@ const ACCOUNT_INFO_BYTES: usize = 8 + 32 + 32;
44
44
const INFO_OUTCOME_MIN_BYTES : usize = 1 + ACCOUNT_INFO_BYTES ;
45
45
const ACCT_DIFF_MIN_BYTES : usize = 4 + INFO_OUTCOME_MIN_BYTES ;
46
46
47
+ // /// Error decoding journal types.
48
+ // #[derive(thiserror::Error, Debug, Copy, Clone, PartialEq, Eq)]
49
+ // pub enum JournalDecodeError {
50
+ // /// The buffer does not contain enough data to decode the type.
51
+ // #[error("buffer overrun while decoding {ty_name}. Expected {expected} bytes, but only {remaining} bytes remain")]
52
+ // Overrun {
53
+ // /// The name of the type being decoded.
54
+ // ty_name: &'static str,
55
+ // /// The number of bytes required to decode the type.
56
+ // expected: usize,
57
+ // /// The number of bytes remaining in the buffer.
58
+ // remaining: usize,
59
+ // },
60
+
61
+ // /// Invalid tag while decoding a type.
62
+ // #[error("invalid tag while decoding {ty_name}. Expected a tag in range 0..={max_expected}, got {tag}")]
63
+ // InvalidTag {
64
+ // /// The name of the type being decoded.
65
+ // ty_name: &'static str,
66
+ // /// The tag that was decoded.
67
+ // tag: u8,
68
+ // /// The maximum expected tag value.
69
+ // max_expected: u8,
70
+ // },
71
+
72
+ // /// Storage slot is unchanged, journal should not contain unchanged slots.
73
+ // #[error("storage slot is unchanged. Unchanged items should never be in the journal")]
74
+ // UnchangedStorage,
75
+
76
+ // /// Error decoding an EOF bytecode.
77
+ // #[error("error decoding EOF bytecode: {0}")]
78
+ // EofDecode(#[from] EofDecodeError),
79
+
80
+ // /// Error decoding an EIP-7702 bytecode.
81
+ // #[error("error decoding EIP-7702 bytecode: {0}")]
82
+ // Eip7702Decode(#[from] Eip7702DecodeError),
83
+ // }
84
+
47
85
/// Error decoding journal types.
48
- #[ derive( thiserror :: Error , Debug , Copy , Clone , PartialEq , Eq ) ]
86
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
49
87
pub enum JournalDecodeError {
50
88
/// The buffer does not contain enough data to decode the type.
51
- #[ error( "buffer overrun while decoding {ty_name}. Expected {expected} bytes, but only {remaining} bytes remain" ) ]
52
89
Overrun {
53
90
/// The name of the type being decoded.
54
91
ty_name : & ' static str ,
@@ -59,7 +96,6 @@ pub enum JournalDecodeError {
59
96
} ,
60
97
61
98
/// Invalid tag while decoding a type.
62
- #[ error( "invalid tag while decoding {ty_name}. Expected a tag in range 0..={max_expected}, got {tag}" ) ]
63
99
InvalidTag {
64
100
/// The name of the type being decoded.
65
101
ty_name : & ' static str ,
@@ -70,16 +106,50 @@ pub enum JournalDecodeError {
70
106
} ,
71
107
72
108
/// Storage slot is unchanged, journal should not contain unchanged slots.
73
- #[ error( "storage slot is unchanged. Unchanged items should never be in the journal" ) ]
74
109
UnchangedStorage ,
75
110
76
111
/// Error decoding an EOF bytecode.
77
- #[ error( "error decoding EOF bytecode: {0}" ) ]
78
- EofDecode ( #[ from] EofDecodeError ) ,
112
+ EofDecode ( EofDecodeError ) ,
79
113
80
114
/// Error decoding an EIP-7702 bytecode.
81
- #[ error( "error decoding EIP-7702 bytecode: {0}" ) ]
82
- Eip7702Decode ( #[ from] Eip7702DecodeError ) ,
115
+ Eip7702Decode ( Eip7702DecodeError ) ,
116
+ }
117
+
118
+ impl core:: fmt:: Display for JournalDecodeError {
119
+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
120
+ match self {
121
+ Self :: Overrun { ty_name, expected, remaining } => {
122
+ write ! ( f, "buffer overrun while decoding {ty_name}. Expected {expected} bytes, but only {remaining} bytes remain" )
123
+ }
124
+ Self :: InvalidTag { ty_name, tag, max_expected } => {
125
+ write ! ( f, "invalid tag while decoding {ty_name}. Expected a tag in range 0..={max_expected}, got {tag}" )
126
+ }
127
+ Self :: UnchangedStorage => {
128
+ write ! (
129
+ f,
130
+ "storage slot is unchanged. Unchanged items should never be in the journal"
131
+ )
132
+ }
133
+ Self :: EofDecode ( e) => {
134
+ write ! ( f, "error decoding EOF bytecode: {e}" )
135
+ }
136
+ Self :: Eip7702Decode ( e) => {
137
+ write ! ( f, "error decoding EIP-7702 bytecode: {e}" )
138
+ }
139
+ }
140
+ }
141
+ }
142
+
143
+ impl From < EofDecodeError > for JournalDecodeError {
144
+ fn from ( err : EofDecodeError ) -> Self {
145
+ Self :: EofDecode ( err)
146
+ }
147
+ }
148
+
149
+ impl From < Eip7702DecodeError > for JournalDecodeError {
150
+ fn from ( err : Eip7702DecodeError ) -> Self {
151
+ Self :: Eip7702Decode ( err)
152
+ }
83
153
}
84
154
85
155
macro_rules! check_len {
0 commit comments