mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 02:42:38 +00:00
Add lighthouse db command!
This commit is contained in:
@@ -171,7 +171,7 @@ impl Config {
|
||||
/// For more information, see:
|
||||
///
|
||||
/// https://github.com/sigp/lighthouse/pull/2843
|
||||
fn get_data_dir(&self) -> PathBuf {
|
||||
pub fn get_data_dir(&self) -> PathBuf {
|
||||
let existing_legacy_dir = self.get_existing_legacy_data_dir();
|
||||
|
||||
if let Some(legacy_dir) = existing_legacy_dir {
|
||||
|
||||
@@ -255,16 +255,7 @@ pub fn get_config<E: EthSpec>(
|
||||
client_config.freezer_db_path = Some(PathBuf::from(freezer_dir));
|
||||
}
|
||||
|
||||
if let Some(slots_per_restore_point) = cli_args.value_of("slots-per-restore-point") {
|
||||
client_config.store.slots_per_restore_point = slots_per_restore_point
|
||||
.parse()
|
||||
.map_err(|_| "slots-per-restore-point is not a valid integer".to_string())?;
|
||||
} else {
|
||||
client_config.store.slots_per_restore_point = std::cmp::min(
|
||||
E::slots_per_historical_root() as u64,
|
||||
store::config::DEFAULT_SLOTS_PER_RESTORE_POINT,
|
||||
);
|
||||
}
|
||||
client_config.store.slots_per_restore_point = get_slots_per_restore_point::<E>(cli_args)?;
|
||||
|
||||
if let Some(block_cache_size) = clap_utils::parse_optional(cli_args, "block-cache-size")? {
|
||||
client_config.store.block_cache_size = block_cache_size;
|
||||
@@ -791,3 +782,17 @@ pub fn get_data_dir(cli_args: &ArgMatches) -> PathBuf {
|
||||
})
|
||||
.unwrap_or_else(|| PathBuf::from("."))
|
||||
}
|
||||
|
||||
/// Get the `slots_per_restore_point` value to use for the database.
|
||||
pub fn get_slots_per_restore_point<E: EthSpec>(cli_args: &ArgMatches) -> Result<u64, String> {
|
||||
if let Some(slots_per_restore_point) =
|
||||
clap_utils::parse_optional(cli_args, "slots-per-restore-point")?
|
||||
{
|
||||
Ok(slots_per_restore_point)
|
||||
} else {
|
||||
Ok(std::cmp::min(
|
||||
E::slots_per_historical_root() as u64,
|
||||
store::config::DEFAULT_SLOTS_PER_RESTORE_POINT,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use beacon_chain::{
|
||||
use clap::ArgMatches;
|
||||
pub use cli::cli_app;
|
||||
pub use client::{Client, ClientBuilder, ClientConfig, ClientGenesis};
|
||||
pub use config::{get_config, get_data_dir, set_network_config};
|
||||
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;
|
||||
|
||||
@@ -29,6 +29,7 @@ directory = { path = "../../common/directory" }
|
||||
tree_hash = "0.4.0"
|
||||
take-until = "0.1.0"
|
||||
zstd = "0.10.0"
|
||||
strum = { version = "0.24", features = ["derive"] }
|
||||
|
||||
[features]
|
||||
milhouse = ["state_processing/milhouse"]
|
||||
|
||||
@@ -41,6 +41,7 @@ pub use impls::beacon_state::StorageContainer as BeaconStateStorageContainer;
|
||||
pub use metadata::AnchorInfo;
|
||||
pub use metrics::scrape_for_metrics;
|
||||
use parking_lot::MutexGuard;
|
||||
use strum::{EnumString, IntoStaticStr};
|
||||
pub use types::*;
|
||||
|
||||
pub trait KeyValueStore<E: EthSpec>: Sync + Send + Sized + 'static {
|
||||
@@ -157,60 +158,52 @@ pub enum StoreOp<'a, E: EthSpec> {
|
||||
}
|
||||
|
||||
/// A unique column identifier.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, IntoStaticStr, EnumString)]
|
||||
pub enum DBColumn {
|
||||
/// For data related to the database itself.
|
||||
#[strum(serialize = "bma")]
|
||||
BeaconMeta,
|
||||
#[strum(serialize = "blk")]
|
||||
BeaconBlock,
|
||||
/// For full `BeaconState`s in the hot database (finalized or fork-boundary states).
|
||||
#[strum(serialize = "ste")]
|
||||
BeaconState,
|
||||
/// For compact `BeaconStateDiff`s.
|
||||
#[strum(serialize = "bsd")]
|
||||
BeaconStateDiff,
|
||||
/// For the mapping from state roots to their slots or summaries.
|
||||
#[strum(serialize = "bss")]
|
||||
BeaconStateSummary,
|
||||
/// For the list of temporary states stored during block import,
|
||||
/// and then made non-temporary by the deletion of their state root from this column.
|
||||
#[strum(serialize = "bst")]
|
||||
BeaconStateTemporary,
|
||||
/// For persisting in-memory state to the database.
|
||||
#[strum(serialize = "bch")]
|
||||
BeaconChain,
|
||||
#[strum(serialize = "opo")]
|
||||
OpPool,
|
||||
#[strum(serialize = "etc")]
|
||||
Eth1Cache,
|
||||
#[strum(serialize = "frk")]
|
||||
ForkChoice,
|
||||
#[strum(serialize = "pkc")]
|
||||
PubkeyCache,
|
||||
/// For the table mapping restore point numbers to state roots.
|
||||
#[strum(serialize = "brp")]
|
||||
BeaconRestorePoint,
|
||||
#[strum(serialize = "bbr")]
|
||||
BeaconBlockRoots,
|
||||
#[strum(serialize = "bsr")]
|
||||
BeaconStateRoots,
|
||||
#[strum(serialize = "bhr")]
|
||||
BeaconHistoricalRoots,
|
||||
#[strum(serialize = "brm")]
|
||||
BeaconRandaoMixes,
|
||||
#[strum(serialize = "dht")]
|
||||
DhtEnrs,
|
||||
}
|
||||
|
||||
impl Into<&'static str> for DBColumn {
|
||||
/// Returns a `&str` prefix to be added to keys before they hit the key-value database.
|
||||
fn into(self) -> &'static str {
|
||||
match self {
|
||||
DBColumn::BeaconMeta => "bma",
|
||||
DBColumn::BeaconBlock => "blk",
|
||||
DBColumn::BeaconState => "ste",
|
||||
DBColumn::BeaconStateDiff => "bsd",
|
||||
DBColumn::BeaconStateSummary => "bss",
|
||||
DBColumn::BeaconStateTemporary => "bst",
|
||||
DBColumn::BeaconChain => "bch",
|
||||
DBColumn::OpPool => "opo",
|
||||
DBColumn::Eth1Cache => "etc",
|
||||
DBColumn::ForkChoice => "frk",
|
||||
DBColumn::PubkeyCache => "pkc",
|
||||
DBColumn::BeaconRestorePoint => "brp",
|
||||
DBColumn::BeaconBlockRoots => "bbr",
|
||||
DBColumn::BeaconStateRoots => "bsr",
|
||||
DBColumn::BeaconHistoricalRoots => "bhr",
|
||||
DBColumn::BeaconRandaoMixes => "brm",
|
||||
DBColumn::DhtEnrs => "dht",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DBColumn {
|
||||
pub fn as_str(self) -> &'static str {
|
||||
self.into()
|
||||
|
||||
Reference in New Issue
Block a user