1
1
use alloy_primitives:: { Address , B256 , U256 } ;
2
2
use alloy_rpc_types:: BlockId ;
3
3
use futures:: channel:: mpsc:: { SendError , TrySendError } ;
4
- use revm:: primitives:: EVMError ;
5
4
use std:: {
6
5
convert:: Infallible ,
7
6
sync:: { mpsc:: RecvError , Arc } ,
@@ -14,12 +13,6 @@ pub type DatabaseResult<T> = Result<T, DatabaseError>;
14
13
#[ derive( Debug , thiserror:: Error ) ]
15
14
#[ allow( missing_docs) ]
16
15
pub enum DatabaseError {
17
- #[ error( "{0}" ) ]
18
- Message ( String ) ,
19
- #[ error( "cheatcodes are not enabled for {0}; see `vm.allowCheatcodes(address)`" ) ]
20
- NoCheats ( Address ) ,
21
- #[ error( "failed to fetch account info for {0}" ) ]
22
- MissingAccount ( Address ) ,
23
16
#[ error( "missing bytecode for code hash {0}" ) ]
24
17
MissingCode ( B256 ) ,
25
18
#[ error( transparent) ]
@@ -38,30 +31,9 @@ pub enum DatabaseError {
38
31
BlockNotFound ( BlockId ) ,
39
32
#[ error( "failed to get transaction {0}: {1}" ) ]
40
33
GetTransaction ( B256 , Arc < eyre:: Error > ) ,
41
- #[ error( "transaction {0} not found" ) ]
42
- TransactionNotFound ( B256 ) ,
43
- #[ error(
44
- "CREATE2 Deployer (0x4e59b44847b379578588920ca78fbf26c0b4956c) not present on this chain.\n \
45
- For a production environment, you can deploy it using the pre-signed transaction from \
46
- https://github.com/Arachnid/deterministic-deployment-proxy.\n \
47
- For a test environment, you can use `etch` to place the required bytecode at that address."
48
- ) ]
49
- MissingCreate2Deployer ,
50
- #[ error( "{0}" ) ]
51
- Other ( String ) ,
52
34
}
53
35
54
36
impl DatabaseError {
55
- /// Create a new error with a message
56
- pub fn msg ( msg : impl Into < String > ) -> Self {
57
- Self :: Message ( msg. into ( ) )
58
- }
59
-
60
- /// Create a new error with a message
61
- pub fn display ( msg : impl std:: fmt:: Display ) -> Self {
62
- Self :: Message ( msg. to_string ( ) )
63
- }
64
-
65
37
fn get_rpc_error ( & self ) -> Option < & eyre:: Error > {
66
38
match self {
67
39
Self :: GetAccount ( _, err) => Some ( err) ,
@@ -70,16 +42,7 @@ impl DatabaseError {
70
42
Self :: GetFullBlock ( _, err) => Some ( err) ,
71
43
Self :: GetTransaction ( _, err) => Some ( err) ,
72
44
// Enumerate explicitly to make sure errors are updated if a new one is added.
73
- Self :: NoCheats ( _)
74
- | Self :: MissingAccount ( _)
75
- | Self :: MissingCode ( _)
76
- | Self :: Recv ( _)
77
- | Self :: Send ( _)
78
- | Self :: Message ( _)
79
- | Self :: BlockNotFound ( _)
80
- | Self :: TransactionNotFound ( _)
81
- | Self :: MissingCreate2Deployer => None ,
82
- Self :: Other ( _) => None ,
45
+ Self :: MissingCode ( _) | Self :: Recv ( _) | Self :: Send ( _) | Self :: BlockNotFound ( _) => None ,
83
46
}
84
47
}
85
48
@@ -94,12 +57,6 @@ impl DatabaseError {
94
57
}
95
58
}
96
59
97
- impl From < tokio:: task:: JoinError > for DatabaseError {
98
- fn from ( value : tokio:: task:: JoinError ) -> Self {
99
- Self :: display ( value)
100
- }
101
- }
102
-
103
60
impl < T > From < TrySendError < T > > for DatabaseError {
104
61
fn from ( value : TrySendError < T > ) -> Self {
105
62
value. into_send_error ( ) . into ( )
@@ -111,13 +68,3 @@ impl From<Infallible> for DatabaseError {
111
68
match value { }
112
69
}
113
70
}
114
-
115
- // Note: this is mostly necessary to use some revm internals that return an [EVMError]
116
- impl From < EVMError < Self > > for DatabaseError {
117
- fn from ( err : EVMError < Self > ) -> Self {
118
- match err {
119
- EVMError :: Database ( err) => err,
120
- err => Self :: Other ( err. to_string ( ) ) ,
121
- }
122
- }
123
- }
0 commit comments