1
1
use crate :: {
2
2
trevm_bail, trevm_ensure, unwrap_or_trevm_err, Block , BundleDriver , DriveBundleResult ,
3
3
} ;
4
+ use alloc:: vec:: Vec ;
4
5
use alloy:: {
5
6
consensus:: { Transaction , TxEip4844Variant , TxEnvelope } ,
6
7
eips:: { eip2718:: Decodable2718 , BlockNumberOrTag } ,
@@ -11,51 +12,82 @@ use alloy::{
11
12
} ;
12
13
use alloy_primitives:: { bytes:: Buf , keccak256, Address , Bytes , TxKind , U256 } ;
13
14
use revm:: primitives:: { EVMError , ExecutionResult , MAX_BLOB_GAS_PER_BLOCK } ;
14
- use thiserror:: Error ;
15
15
16
16
/// Possible errors that can occur while driving a bundle.
17
- #[ derive( Error ) ]
18
17
pub enum BundleError < Db : revm:: Database > {
19
18
/// The block number of the bundle does not match the block number of the revm block configuration.
20
- #[ error( "revm block number must match the bundle block number" ) ]
21
19
BlockNumberMismatch ,
22
20
/// The timestamp of the bundle is out of range.
23
- #[ error( "timestamp out of range" ) ]
24
21
TimestampOutOfRange ,
25
22
/// The bundle was reverted (or halted).
26
- #[ error( "bundle reverted" ) ]
27
23
BundleReverted ,
28
24
/// The bundle has no transactions
29
- #[ error( "bundle has no transactions" ) ]
30
25
BundleEmpty ,
31
26
/// Too many blob transactions
32
- #[ error( "max blob gas limit exceeded" ) ]
33
27
Eip4844BlobGasExceeded ,
34
28
/// An unsupported transaction type was encountered.
35
- #[ error( "unsupported transaction type" ) ]
36
29
UnsupportedTransactionType ,
37
30
/// An error occurred while decoding a transaction contained in the bundle.
38
- #[ error( "transaction decoding error" ) ]
39
- TransactionDecodingError ( #[ from] alloy:: eips:: eip2718:: Eip2718Error ) ,
40
- /// An error ocurred while recovering the sender of a transaction
41
- #[ error( "transaction sender recovery error" ) ]
42
- TransactionSenderRecoveryError ( #[ from] alloy_primitives:: SignatureError ) ,
31
+ TransactionDecodingError ( alloy:: eips:: eip2718:: Eip2718Error ) ,
32
+ /// An error occurred while recovering the sender of a transaction.
33
+ TransactionSenderRecoveryError ( alloy_primitives:: SignatureError ) ,
43
34
/// An error occurred while running the EVM.
44
- #[ error( "internal EVM Error" ) ]
45
35
EVMError {
46
36
/// The error that occurred while running the EVM.
47
37
inner : EVMError < Db :: Error > ,
48
38
} ,
49
39
}
50
40
41
+ impl < Db : revm:: Database > core:: fmt:: Display for BundleError < Db > {
42
+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
43
+ match self {
44
+ Self :: BlockNumberMismatch => {
45
+ write ! ( f, "revm block number must match the bundle block number" )
46
+ }
47
+ Self :: TimestampOutOfRange => write ! ( f, "timestamp out of range" ) ,
48
+ Self :: BundleReverted => write ! ( f, "bundle reverted" ) ,
49
+ Self :: BundleEmpty => write ! ( f, "bundle has no transactions" ) ,
50
+ Self :: Eip4844BlobGasExceeded => write ! ( f, "max blob gas limit exceeded" ) ,
51
+ Self :: UnsupportedTransactionType => write ! ( f, "unsupported transaction type" ) ,
52
+ Self :: TransactionDecodingError ( _) => write ! ( f, "transaction decoding error" ) ,
53
+ Self :: TransactionSenderRecoveryError ( _) => {
54
+ write ! ( f, "transaction sender recovery error" )
55
+ }
56
+ Self :: EVMError { inner : _ } => write ! ( f, "internal EVM Error" ) ,
57
+ }
58
+ }
59
+ }
60
+
61
+ impl < Db : revm:: Database > From < alloy:: eips:: eip2718:: Eip2718Error > for BundleError < Db > {
62
+ fn from ( err : alloy:: eips:: eip2718:: Eip2718Error ) -> Self {
63
+ Self :: TransactionDecodingError ( err)
64
+ }
65
+ }
66
+
67
+ impl < Db : revm:: Database > From < alloy_primitives:: SignatureError > for BundleError < Db > {
68
+ fn from ( err : alloy_primitives:: SignatureError ) -> Self {
69
+ Self :: TransactionSenderRecoveryError ( err)
70
+ }
71
+ }
72
+
51
73
impl < Db : revm:: Database > From < EVMError < Db :: Error > > for BundleError < Db > {
52
74
fn from ( inner : EVMError < Db :: Error > ) -> Self {
53
75
Self :: EVMError { inner }
54
76
}
55
77
}
56
78
57
- impl < Db : revm:: Database > std:: fmt:: Debug for BundleError < Db > {
58
- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
79
+ impl < Db : revm:: Database > core:: error:: Error for BundleError < Db > {
80
+ fn source ( & self ) -> Option < & ( dyn core:: error:: Error + ' static ) > {
81
+ match self {
82
+ Self :: TransactionDecodingError ( err) => Some ( err) ,
83
+ Self :: TransactionSenderRecoveryError ( err) => Some ( err) ,
84
+ _ => None ,
85
+ }
86
+ }
87
+ }
88
+
89
+ impl < Db : revm:: Database > core:: fmt:: Debug for BundleError < Db > {
90
+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
59
91
match self {
60
92
Self :: TimestampOutOfRange => write ! ( f, "TimestampOutOfRange" ) ,
61
93
Self :: BlockNumberMismatch => write ! ( f, "BlockNumberMismatch" ) ,
94
126
/// Clear the driver, resetting the response. This resets the driver,
95
127
/// allowing for resimulation of the same bundle.
96
128
pub fn clear ( & mut self ) -> R {
97
- std :: mem:: take ( & mut self . response )
129
+ core :: mem:: take ( & mut self . response )
98
130
}
99
131
}
100
132
0 commit comments