Switch default slasher backend to LMDB (#4360)

## Issue Addressed

Closes #4354
Closes #3987

Replaces #4305, #4283

## Proposed Changes

This switches the default slasher backend _back_ to LMDB.

If an MDBX database exists and the MDBX backend is enabled then MDBX will continue to be used. Our release binaries and Docker images will continue to include MDBX for as long as it is practical, so users of these should not notice any difference.

The main benefit is to users compiling from source and devs running tests. These users no longer have to struggle to compile MDBX and deal with the compatibility issues that arises. Similarly, devs don't need to worry about toggling feature flags in tests or risk forgetting to run the slasher tests due to backend issues.
This commit is contained in:
Michael Sproul
2023-06-07 01:50:33 +00:00
parent b14d1493cc
commit 299cfe1fe6
15 changed files with 184 additions and 35 deletions

View File

@@ -16,7 +16,7 @@ pub use client::{Client, ClientBuilder, ClientConfig, ClientGenesis};
pub use config::{get_config, get_data_dir, get_slots_per_restore_point, set_network_config};
use environment::RuntimeContext;
pub use eth2_config::Eth2Config;
use slasher::Slasher;
use slasher::{DatabaseBackendOverride, Slasher};
use slog::{info, warn};
use std::ops::{Deref, DerefMut};
use std::sync::Arc;
@@ -86,7 +86,27 @@ impl<E: EthSpec> ProductionBeaconNode<E> {
.http_api_config(client_config.http_api.clone())
.disk_store(&db_path, &freezer_db_path, store_config, log.clone())?;
let builder = if let Some(slasher_config) = client_config.slasher.clone() {
let builder = if let Some(mut slasher_config) = client_config.slasher.clone() {
match slasher_config.override_backend() {
DatabaseBackendOverride::Success(old_backend) => {
info!(
log,
"Slasher backend overriden";
"reason" => "database exists",
"configured_backend" => %old_backend,
"override_backend" => %slasher_config.backend,
);
}
DatabaseBackendOverride::Failure(path) => {
warn!(
log,
"Slasher backend override failed";
"advice" => "delete old MDBX database or enable MDBX backend",
"path" => path.display()
);
}
_ => {}
}
let slasher = Arc::new(
Slasher::open(slasher_config, log.new(slog::o!("service" => "slasher")))
.map_err(|e| format!("Slasher open error: {:?}", e))?,