Modularize beacon node backend (#4718)

#4669


  Modularize the beacon node backend to make it easier to add new database implementations
This commit is contained in:
Eitan Seri-Levi
2025-01-23 09:12:16 +07:00
committed by GitHub
parent 266b241123
commit a1b7d616b4
38 changed files with 1479 additions and 650 deletions

View File

@@ -2,6 +2,8 @@ use crate::chunked_vector::ChunkError;
use crate::config::StoreConfigError;
use crate::hot_cold_store::HotColdDBError;
use crate::{hdiff, DBColumn};
#[cfg(feature = "leveldb")]
use leveldb::error::Error as LevelDBError;
use ssz::DecodeError;
use state_processing::BlockReplayError;
use types::{milhouse, BeaconStateError, EpochCacheError, Hash256, InconsistentFork, Slot};
@@ -48,6 +50,16 @@ pub enum Error {
MissingGenesisState,
MissingSnapshot(Slot),
BlockReplayError(BlockReplayError),
AddPayloadLogicError,
InvalidKey,
InvalidBytes,
InconsistentFork(InconsistentFork),
#[cfg(feature = "leveldb")]
LevelDbError(LevelDBError),
#[cfg(feature = "redb")]
RedbError(redb::Error),
CacheBuildError(EpochCacheError),
RandaoMixOutOfBounds,
MilhouseError(milhouse::Error),
Compression(std::io::Error),
FinalizedStateDecreasingSlot,
@@ -56,17 +68,11 @@ pub enum Error {
state_root: Hash256,
slot: Slot,
},
AddPayloadLogicError,
InvalidKey,
InvalidBytes,
InconsistentFork(InconsistentFork),
Hdiff(hdiff::Error),
CacheBuildError(EpochCacheError),
ForwardsIterInvalidColumn(DBColumn),
ForwardsIterGap(DBColumn, Slot, Slot),
StateShouldNotBeRequired(Slot),
MissingBlock(Hash256),
RandaoMixOutOfBounds,
GenesisStateUnknown,
ArithError(safe_arith::ArithError),
}
@@ -145,6 +151,62 @@ impl From<InconsistentFork> for Error {
}
}
#[cfg(feature = "leveldb")]
impl From<LevelDBError> for Error {
fn from(e: LevelDBError) -> Error {
Error::LevelDbError(e)
}
}
#[cfg(feature = "redb")]
impl From<redb::Error> for Error {
fn from(e: redb::Error) -> Self {
Error::RedbError(e)
}
}
#[cfg(feature = "redb")]
impl From<redb::TableError> for Error {
fn from(e: redb::TableError) -> Self {
Error::RedbError(e.into())
}
}
#[cfg(feature = "redb")]
impl From<redb::TransactionError> for Error {
fn from(e: redb::TransactionError) -> Self {
Error::RedbError(e.into())
}
}
#[cfg(feature = "redb")]
impl From<redb::DatabaseError> for Error {
fn from(e: redb::DatabaseError) -> Self {
Error::RedbError(e.into())
}
}
#[cfg(feature = "redb")]
impl From<redb::StorageError> for Error {
fn from(e: redb::StorageError) -> Self {
Error::RedbError(e.into())
}
}
#[cfg(feature = "redb")]
impl From<redb::CommitError> for Error {
fn from(e: redb::CommitError) -> Self {
Error::RedbError(e.into())
}
}
#[cfg(feature = "redb")]
impl From<redb::CompactionError> for Error {
fn from(e: redb::CompactionError) -> Self {
Error::RedbError(e.into())
}
}
impl From<EpochCacheError> for Error {
fn from(e: EpochCacheError) -> Error {
Error::CacheBuildError(e)