Skip to content

Commit 981dbb8

Browse files
committed
DatabaseError -> BackendError
1 parent 93a1abc commit 981dbb8

File tree

2 files changed

+7
-60
lines changed

2 files changed

+7
-60
lines changed

src/cache.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,17 @@ impl BlockchainDb {
9999
}
100100

101101
/// Returns the Env related metadata
102-
pub fn meta(&self) -> &Arc<RwLock<BlockchainDbMeta>> {
102+
pub const fn meta(&self) -> &Arc<RwLock<BlockchainDbMeta>> {
103103
&self.meta
104104
}
105105

106106
/// Returns the inner cache
107-
pub fn cache(&self) -> &Arc<JsonBlockCacheDB> {
107+
pub const fn cache(&self) -> &Arc<JsonBlockCacheDB> {
108108
&self.cache
109109
}
110110

111111
/// Returns the underlying storage
112-
pub fn db(&self) -> &Arc<MemDb> {
112+
pub const fn db(&self) -> &Arc<MemDb> {
113113
&self.db
114114
}
115115
}
@@ -364,17 +364,17 @@ impl JsonBlockCacheDB {
364364
}
365365

366366
/// Returns the [MemDb] it holds access to
367-
pub fn db(&self) -> &Arc<MemDb> {
367+
pub const fn db(&self) -> &Arc<MemDb> {
368368
&self.data.data
369369
}
370370

371371
/// Metadata stored alongside the data
372-
pub fn meta(&self) -> &Arc<RwLock<BlockchainDbMeta>> {
372+
pub const fn meta(&self) -> &Arc<RwLock<BlockchainDbMeta>> {
373373
&self.data.meta
374374
}
375375

376376
/// Returns `true` if this is a transient cache and nothing will be flushed
377-
pub fn is_transient(&self) -> bool {
377+
pub const fn is_transient(&self) -> bool {
378378
self.cache_path.is_none()
379379
}
380380

src/error.rs

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use alloy_primitives::{Address, B256, U256};
22
use alloy_rpc_types::BlockId;
33
use futures::channel::mpsc::{SendError, TrySendError};
4-
use revm::primitives::EVMError;
54
use std::{
65
convert::Infallible,
76
sync::{mpsc::RecvError, Arc},
@@ -14,12 +13,6 @@ pub type DatabaseResult<T> = Result<T, DatabaseError>;
1413
#[derive(Debug, thiserror::Error)]
1514
#[allow(missing_docs)]
1615
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),
2316
#[error("missing bytecode for code hash {0}")]
2417
MissingCode(B256),
2518
#[error(transparent)]
@@ -38,30 +31,9 @@ pub enum DatabaseError {
3831
BlockNotFound(BlockId),
3932
#[error("failed to get transaction {0}: {1}")]
4033
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),
5234
}
5335

5436
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-
6537
fn get_rpc_error(&self) -> Option<&eyre::Error> {
6638
match self {
6739
Self::GetAccount(_, err) => Some(err),
@@ -70,16 +42,7 @@ impl DatabaseError {
7042
Self::GetFullBlock(_, err) => Some(err),
7143
Self::GetTransaction(_, err) => Some(err),
7244
// 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,
8346
}
8447
}
8548

@@ -94,12 +57,6 @@ impl DatabaseError {
9457
}
9558
}
9659

97-
impl From<tokio::task::JoinError> for DatabaseError {
98-
fn from(value: tokio::task::JoinError) -> Self {
99-
Self::display(value)
100-
}
101-
}
102-
10360
impl<T> From<TrySendError<T>> for DatabaseError {
10461
fn from(value: TrySendError<T>) -> Self {
10562
value.into_send_error().into()
@@ -111,13 +68,3 @@ impl From<Infallible> for DatabaseError {
11168
match value {}
11269
}
11370
}
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

Comments
 (0)