mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 13:28:33 +00:00
Add lighthouse db command (#3129)
## Proposed Changes Add a `lighthouse db` command with three initial subcommands: - `lighthouse db version`: print the database schema version. - `lighthouse db migrate --to N`: manually upgrade (or downgrade!) the database to a different version. - `lighthouse db inspect --column C`: log the key and size in bytes of every value in a given `DBColumn`. This PR lays the groundwork for other changes, namely: - Mark's fast-deposit sync (https://github.com/sigp/lighthouse/pull/2915), for which I think we should implement a database downgrade (from v9 to v8). - My `tree-states` work, which already implements a downgrade (v10 to v8). - Standalone purge commands like `lighthouse db purge-dht` per https://github.com/sigp/lighthouse/issues/2824. ## Additional Info I updated the `strum` crate to 0.24.0, which necessitated some changes in the network code to remove calls to deprecated methods. Thanks to @winksaville for the motivation, and implementation work that I used as a source of inspiration (https://github.com/sigp/lighthouse/pull/2685).
This commit is contained in:
@@ -36,7 +36,7 @@ task_executor = { path = "../../common/task_executor" }
|
||||
rand = "0.7.3"
|
||||
directory = { path = "../../common/directory" }
|
||||
regex = "1.5.5"
|
||||
strum = { version = "0.21.0", features = ["derive"] }
|
||||
strum = { version = "0.24.0", features = ["derive"] }
|
||||
superstruct = "0.4.1"
|
||||
prometheus-client = "0.15.0"
|
||||
unused_port = { path = "../../common/unused_port" }
|
||||
|
||||
@@ -388,7 +388,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
/// Updates `PeerInfo` with `identify` information.
|
||||
pub fn identify(&mut self, peer_id: &PeerId, info: &IdentifyInfo) {
|
||||
if let Some(peer_info) = self.network_globals.peers.write().peer_info_mut(peer_id) {
|
||||
let previous_kind = peer_info.client().kind.clone();
|
||||
let previous_kind = peer_info.client().kind;
|
||||
let previous_listening_addresses =
|
||||
peer_info.set_listening_addresses(info.listen_addrs.clone());
|
||||
peer_info.set_client(peerdb::client::Client::from_identify_info(info));
|
||||
@@ -412,12 +412,9 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
) {
|
||||
metrics::inc_gauge_vec(
|
||||
&metrics::PEERS_PER_CLIENT,
|
||||
&[&peer_info.client().kind.to_string()],
|
||||
);
|
||||
metrics::dec_gauge_vec(
|
||||
&metrics::PEERS_PER_CLIENT,
|
||||
&[&previous_kind.to_string()],
|
||||
&[peer_info.client().kind.as_ref()],
|
||||
);
|
||||
metrics::dec_gauge_vec(&metrics::PEERS_PER_CLIENT, &[previous_kind.as_ref()]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -674,7 +671,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
let value = clients_per_peer.get(&client_kind.to_string()).unwrap_or(&0);
|
||||
metrics::set_gauge_vec(
|
||||
&metrics::PEERS_PER_CLIENT,
|
||||
&[&client_kind.to_string()],
|
||||
&[client_kind.as_ref()],
|
||||
*value as i64,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
use libp2p::identify::IdentifyInfo;
|
||||
use serde::Serialize;
|
||||
use strum::{AsRefStr, AsStaticStr, EnumIter};
|
||||
use strum::{AsRefStr, EnumIter, IntoStaticStr};
|
||||
|
||||
/// Various client and protocol information related to a node.
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
@@ -21,7 +21,7 @@ pub struct Client {
|
||||
pub agent_string: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, PartialEq, AsRefStr, AsStaticStr, EnumIter)]
|
||||
#[derive(Clone, Copy, Debug, Serialize, PartialEq, AsRefStr, IntoStaticStr, EnumIter)]
|
||||
pub enum ClientKind {
|
||||
/// A lighthouse node (the best kind).
|
||||
Lighthouse,
|
||||
|
||||
@@ -9,7 +9,7 @@ use ssz_types::{
|
||||
VariableList,
|
||||
};
|
||||
use std::ops::Deref;
|
||||
use strum::AsStaticStr;
|
||||
use strum::IntoStaticStr;
|
||||
use superstruct::superstruct;
|
||||
use types::{Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot};
|
||||
|
||||
@@ -263,7 +263,7 @@ pub enum RPCCodedResponse<T: EthSpec> {
|
||||
}
|
||||
|
||||
/// The code assigned to an erroneous `RPCResponse`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, AsStaticStr)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, IntoStaticStr)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum RPCResponseErrorCode {
|
||||
RateLimited,
|
||||
|
||||
@@ -14,7 +14,7 @@ use std::io;
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use strum::{AsStaticRef, AsStaticStr};
|
||||
use strum::IntoStaticStr;
|
||||
use tokio_io_timeout::TimeoutStream;
|
||||
use tokio_util::{
|
||||
codec::Framed,
|
||||
@@ -510,7 +510,7 @@ impl<TSpec: EthSpec> InboundRequest<TSpec> {
|
||||
}
|
||||
|
||||
/// Error in RPC Encoding/Decoding.
|
||||
#[derive(Debug, Clone, PartialEq, AsStaticStr)]
|
||||
#[derive(Debug, Clone, PartialEq, IntoStaticStr)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum RPCError {
|
||||
/// Error when decoding the raw buffer from ssz.
|
||||
@@ -617,8 +617,8 @@ impl RPCError {
|
||||
/// Used for metrics.
|
||||
pub fn as_static_str(&self) -> &'static str {
|
||||
match self {
|
||||
RPCError::ErrorResponse(ref code, ..) => code.as_static(),
|
||||
e => e.as_static(),
|
||||
RPCError::ErrorResponse(ref code, ..) => code.into(),
|
||||
e => e.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user