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

@@ -7,7 +7,7 @@ autotests = false
rust-version = "1.80.0"
[features]
default = ["slasher-lmdb"]
default = ["slasher-lmdb", "beacon-node-leveldb"]
# Writes debugging .ssz files to /tmp during block processing.
write_ssz_files = ["beacon_node/write_ssz_files"]
# Compiles the BLS crypto code so that the binary is portable across machines.
@@ -24,6 +24,11 @@ slasher-mdbx = ["slasher/mdbx"]
slasher-lmdb = ["slasher/lmdb"]
# Support slasher redb backend.
slasher-redb = ["slasher/redb"]
# Supports beacon node leveldb backend.
beacon-node-leveldb = ["store/leveldb"]
# Supports beacon node redb backend.
beacon-node-redb = ["store/redb"]
# Deprecated. This is now enabled by default on non windows targets.
jemalloc = []
@@ -56,6 +61,7 @@ serde_json = { workspace = true }
serde_yaml = { workspace = true }
slasher = { workspace = true }
slog = { workspace = true }
store = { workspace = true }
task_executor = { workspace = true }
types = { workspace = true }
unused_port = { workspace = true }

View File

@@ -1,11 +1,12 @@
use beacon_node::ClientConfig as Config;
use crate::exec::{CommandLineTestExec, CompletedTest};
use beacon_node::beacon_chain::chain_config::{
DisallowedReOrgOffsets, DEFAULT_RE_ORG_CUTOFF_DENOMINATOR, DEFAULT_RE_ORG_HEAD_THRESHOLD,
DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION,
};
use beacon_node::beacon_chain::graffiti_calculator::GraffitiOrigin;
use beacon_node::{
beacon_chain::graffiti_calculator::GraffitiOrigin,
beacon_chain::store::config::DatabaseBackend as BeaconNodeBackend, ClientConfig as Config,
};
use beacon_processor::BeaconProcessorConfig;
use eth1::Eth1Endpoint;
use lighthouse_network::PeerId;
@@ -2691,3 +2692,13 @@ fn genesis_state_url_value() {
assert_eq!(config.genesis_state_url_timeout, Duration::from_secs(42));
});
}
#[test]
fn beacon_node_backend_override() {
CommandLineTest::new()
.flag("beacon-node-backend", Some("leveldb"))
.run_with_zero_port()
.with_config(|config| {
assert_eq!(config.store.backend, BeaconNodeBackend::LevelDb);
});
}