mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Merge unstable 20230925 into deneb-free-blobs.
This commit is contained in:
@@ -2,63 +2,63 @@
|
||||
name = "validator_client"
|
||||
version = "0.3.5"
|
||||
authors = ["Paul Hauner <paul@paulhauner.com>", "Age Manning <Age@AgeManning.com>", "Luke Anderson <luke@lukeanderson.com.au>"]
|
||||
edition = "2021"
|
||||
edition = { workspace = true }
|
||||
|
||||
[lib]
|
||||
name = "validator_client"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "1.14.0", features = ["time", "rt-multi-thread", "macros"] }
|
||||
tokio = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
tree_hash = "0.5.2"
|
||||
clap = "2.33.3"
|
||||
slashing_protection = { path = "./slashing_protection" }
|
||||
slot_clock = { path = "../common/slot_clock" }
|
||||
types = { path = "../consensus/types" }
|
||||
safe_arith = { path = "../consensus/safe_arith" }
|
||||
serde = "1.0.116"
|
||||
tree_hash = { workspace = true }
|
||||
clap = { workspace = true }
|
||||
slashing_protection = { workspace = true }
|
||||
slot_clock = { workspace = true }
|
||||
types = { workspace = true }
|
||||
safe_arith = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_derive = "1.0.116"
|
||||
bincode = "1.3.1"
|
||||
serde_json = "1.0.58"
|
||||
slog = { version = "2.5.2", features = ["max_level_trace", "release_max_level_trace"] }
|
||||
tokio = { version = "1.14.0", features = ["time"] }
|
||||
tokio-stream = { version = "0.1.3", features = ["sync"] }
|
||||
futures = "0.3.7"
|
||||
dirs = "3.0.1"
|
||||
directory = { path = "../common/directory" }
|
||||
lockfile = { path = "../common/lockfile" }
|
||||
environment = { path = "../lighthouse/environment" }
|
||||
parking_lot = "0.12.0"
|
||||
exit-future = "0.2.0"
|
||||
filesystem = { path = "../common/filesystem" }
|
||||
hex = "0.4.2"
|
||||
deposit_contract = { path = "../common/deposit_contract" }
|
||||
bls = { path = "../crypto/bls" }
|
||||
eth2 = { path = "../common/eth2" }
|
||||
tempfile = "3.1.0"
|
||||
validator_dir = { path = "../common/validator_dir" }
|
||||
clap_utils = { path = "../common/clap_utils" }
|
||||
eth2_keystore = { path = "../crypto/eth2_keystore" }
|
||||
account_utils = { path = "../common/account_utils" }
|
||||
lighthouse_version = { path = "../common/lighthouse_version" }
|
||||
warp_utils = { path = "../common/warp_utils" }
|
||||
warp = "0.3.2"
|
||||
hyper = "0.14.4"
|
||||
ethereum_serde_utils = "0.5.0"
|
||||
libsecp256k1 = "0.7.0"
|
||||
ring = "0.16.19"
|
||||
rand = { version = "0.8.5", features = ["small_rng"] }
|
||||
lighthouse_metrics = { path = "../common/lighthouse_metrics" }
|
||||
lazy_static = "1.4.0"
|
||||
itertools = "0.10.0"
|
||||
monitoring_api = { path = "../common/monitoring_api" }
|
||||
sensitive_url = { path = "../common/sensitive_url" }
|
||||
task_executor = { path = "../common/task_executor" }
|
||||
reqwest = { version = "0.11.0", features = ["json","stream"] }
|
||||
url = "2.2.2"
|
||||
malloc_utils = { path = "../common/malloc_utils" }
|
||||
sysinfo = "0.26.5"
|
||||
bincode = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
slog = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
tokio-stream = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
dirs = { workspace = true }
|
||||
directory = { workspace = true }
|
||||
lockfile = { workspace = true }
|
||||
environment = { workspace = true }
|
||||
parking_lot = { workspace = true }
|
||||
exit-future = { workspace = true }
|
||||
filesystem = { workspace = true }
|
||||
hex = { workspace = true }
|
||||
deposit_contract = { workspace = true }
|
||||
bls = { workspace = true }
|
||||
eth2 = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
validator_dir = { workspace = true }
|
||||
clap_utils = { workspace = true }
|
||||
eth2_keystore = { workspace = true }
|
||||
account_utils = { workspace = true }
|
||||
lighthouse_version = { workspace = true }
|
||||
warp_utils = { workspace = true }
|
||||
warp = { workspace = true }
|
||||
hyper = { workspace = true }
|
||||
ethereum_serde_utils = { workspace = true }
|
||||
libsecp256k1 = { workspace = true }
|
||||
ring = { workspace = true }
|
||||
rand = { workspace = true, features = ["small_rng"] }
|
||||
lighthouse_metrics = { workspace = true }
|
||||
lazy_static = { workspace = true }
|
||||
itertools = { workspace = true }
|
||||
monitoring_api = { workspace = true }
|
||||
sensitive_url = { workspace = true }
|
||||
task_executor = { workspace = true }
|
||||
reqwest = { workspace = true }
|
||||
url = { workspace = true }
|
||||
malloc_utils = { workspace = true }
|
||||
sysinfo = { workspace = true }
|
||||
system_health = { path = "../common/system_health" }
|
||||
logging = { path = "../common/logging" }
|
||||
logging = { workspace = true }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name = "slashing_protection"
|
||||
version = "0.1.0"
|
||||
authors = ["Michael Sproul <michael@sigmaprime.io>", "pscott <scottpiriou@gmail.com>"]
|
||||
edition = "2021"
|
||||
edition = { workspace = true }
|
||||
autotests = false
|
||||
|
||||
[[test]]
|
||||
@@ -10,21 +10,21 @@ name = "slashing_protection_tests"
|
||||
path = "tests/main.rs"
|
||||
|
||||
[dependencies]
|
||||
tempfile = "3.1.0"
|
||||
types = { path = "../../consensus/types" }
|
||||
rusqlite = { version = "0.28.0", features = ["bundled"] }
|
||||
r2d2 = "0.8.9"
|
||||
tempfile = { workspace = true }
|
||||
types = { workspace = true }
|
||||
rusqlite = { workspace = true }
|
||||
r2d2 = { workspace = true }
|
||||
r2d2_sqlite = "0.21.0"
|
||||
serde = "1.0.116"
|
||||
serde = { workspace = true }
|
||||
serde_derive = "1.0.116"
|
||||
serde_json = "1.0.58"
|
||||
ethereum_serde_utils = "0.5.0"
|
||||
filesystem = { path = "../../common/filesystem" }
|
||||
arbitrary = { version = "1.0", features = ["derive"], optional = true }
|
||||
serde_json = { workspace = true }
|
||||
ethereum_serde_utils = { workspace = true }
|
||||
filesystem = { workspace = true }
|
||||
arbitrary = { workspace = true, features = ["derive"] }
|
||||
|
||||
[dev-dependencies]
|
||||
lazy_static = "1.4.0"
|
||||
rayon = "1.4.1"
|
||||
lazy_static = { workspace = true }
|
||||
rayon = { workspace = true }
|
||||
|
||||
[features]
|
||||
arbitrary-fuzz = ["arbitrary", "types/arbitrary-fuzz"]
|
||||
arbitrary-fuzz = ["types/arbitrary-fuzz"]
|
||||
|
||||
@@ -170,6 +170,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name("http-address")
|
||||
.long("http-address")
|
||||
.requires("http")
|
||||
.value_name("ADDRESS")
|
||||
.help("Set the address for the HTTP address. The HTTP server is not encrypted \
|
||||
and therefore it is unsafe to publish on a public network. When this \
|
||||
@@ -189,14 +190,16 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name("http-port")
|
||||
.long("http-port")
|
||||
.requires("http")
|
||||
.value_name("PORT")
|
||||
.help("Set the listen TCP port for the RESTful HTTP API server.")
|
||||
.default_value("5062")
|
||||
.default_value_if("http", None, "5062")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("http-allow-origin")
|
||||
.long("http-allow-origin")
|
||||
.requires("http")
|
||||
.value_name("ORIGIN")
|
||||
.help("Set the value of the Access-Control-Allow-Origin response HTTP header. \
|
||||
Use * to allow any origin (not recommended in production). \
|
||||
@@ -207,21 +210,21 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name("http-allow-keystore-export")
|
||||
.long("http-allow-keystore-export")
|
||||
.requires("http")
|
||||
.help("If present, allow access to the DELETE /lighthouse/keystores HTTP \
|
||||
API method, which allows exporting keystores and passwords to HTTP API \
|
||||
consumers who have access to the API token. This method is useful for \
|
||||
exporting validators, however it should be used with caution since it \
|
||||
exposes private key data to authorized users.")
|
||||
.required(false)
|
||||
.takes_value(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("http-store-passwords-in-secrets-dir")
|
||||
.long("http-store-passwords-in-secrets-dir")
|
||||
.requires("http")
|
||||
.help("If present, any validators created via the HTTP will have keystore \
|
||||
passwords stored in the secrets-dir rather than the validator \
|
||||
definitions file.")
|
||||
.required(false)
|
||||
.takes_value(false),
|
||||
)
|
||||
/* Prometheus metrics HTTP server related arguments */
|
||||
@@ -234,22 +237,25 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name("metrics-address")
|
||||
.long("metrics-address")
|
||||
.requires("metrics")
|
||||
.value_name("ADDRESS")
|
||||
.help("Set the listen address for the Prometheus metrics HTTP server.")
|
||||
.default_value("127.0.0.1")
|
||||
.default_value_if("metrics", None, "127.0.0.1")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("metrics-port")
|
||||
.long("metrics-port")
|
||||
.requires("metrics")
|
||||
.value_name("PORT")
|
||||
.help("Set the listen TCP port for the Prometheus metrics HTTP server.")
|
||||
.default_value("5064")
|
||||
.default_value_if("metrics", None, "5064")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("metrics-allow-origin")
|
||||
.long("metrics-allow-origin")
|
||||
.requires("metrics")
|
||||
.value_name("ORIGIN")
|
||||
.help("Set the value of the Access-Control-Allow-Origin response HTTP header. \
|
||||
Use * to allow any origin (not recommended in production). \
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::validator_store::ValidatorStore;
|
||||
use bls::{PublicKey, PublicKeyBytes};
|
||||
use eth2::types::GenericResponse;
|
||||
use slog::{info, Logger};
|
||||
use slot_clock::SlotClock;
|
||||
use std::sync::Arc;
|
||||
@@ -11,7 +12,7 @@ pub async fn create_signed_voluntary_exit<T: 'static + SlotClock + Clone, E: Eth
|
||||
validator_store: Arc<ValidatorStore<T, E>>,
|
||||
slot_clock: T,
|
||||
log: Logger,
|
||||
) -> Result<SignedVoluntaryExit, warp::Rejection> {
|
||||
) -> Result<GenericResponse<SignedVoluntaryExit>, warp::Rejection> {
|
||||
let epoch = match maybe_epoch {
|
||||
Some(epoch) => epoch,
|
||||
None => get_current_epoch::<T, E>(slot_clock).ok_or_else(|| {
|
||||
@@ -60,7 +61,7 @@ pub async fn create_signed_voluntary_exit<T: 'static + SlotClock + Clone, E: Eth
|
||||
))
|
||||
})?;
|
||||
|
||||
Ok(signed_voluntary_exit)
|
||||
Ok(GenericResponse::from(signed_voluntary_exit))
|
||||
}
|
||||
|
||||
/// Calculates the current epoch from the genesis time and current time.
|
||||
|
||||
@@ -502,7 +502,7 @@ impl ApiTester {
|
||||
.await;
|
||||
|
||||
assert!(resp.is_ok());
|
||||
assert_eq!(resp.unwrap().message.epoch, expected_exit_epoch);
|
||||
assert_eq!(resp.unwrap().data.message.epoch, expected_exit_epoch);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ const HTTP_SYNC_DUTIES_TIMEOUT_QUOTIENT: u32 = 4;
|
||||
const HTTP_GET_BEACON_BLOCK_SSZ_TIMEOUT_QUOTIENT: u32 = 4;
|
||||
const HTTP_GET_DEBUG_BEACON_STATE_QUOTIENT: u32 = 4;
|
||||
const HTTP_GET_DEPOSIT_SNAPSHOT_QUOTIENT: u32 = 4;
|
||||
const HTTP_GET_VALIDATOR_BLOCK_SSZ_TIMEOUT_QUOTIENT: u32 = 4;
|
||||
|
||||
const DOPPELGANGER_SERVICE_NAME: &str = "doppelganger";
|
||||
|
||||
@@ -98,6 +99,8 @@ pub struct ProductionValidatorClient<T: EthSpec> {
|
||||
slot_clock: SystemTimeSlotClock,
|
||||
http_api_listen_addr: Option<SocketAddr>,
|
||||
config: Config,
|
||||
beacon_nodes: Arc<BeaconNodeFallback<SystemTimeSlotClock, T>>,
|
||||
genesis_time: u64,
|
||||
}
|
||||
|
||||
impl<T: EthSpec> ProductionValidatorClient<T> {
|
||||
@@ -307,6 +310,8 @@ impl<T: EthSpec> ProductionValidatorClient<T> {
|
||||
/ HTTP_GET_BEACON_BLOCK_SSZ_TIMEOUT_QUOTIENT,
|
||||
get_debug_beacon_states: slot_duration / HTTP_GET_DEBUG_BEACON_STATE_QUOTIENT,
|
||||
get_deposit_snapshot: slot_duration / HTTP_GET_DEPOSIT_SNAPSHOT_QUOTIENT,
|
||||
get_validator_block_ssz: slot_duration
|
||||
/ HTTP_GET_VALIDATOR_BLOCK_SSZ_TIMEOUT_QUOTIENT,
|
||||
}
|
||||
} else {
|
||||
Timeouts::set_all(slot_duration)
|
||||
@@ -501,12 +506,6 @@ impl<T: EthSpec> ProductionValidatorClient<T> {
|
||||
context.service_context("sync_committee".into()),
|
||||
);
|
||||
|
||||
// Wait until genesis has occurred.
|
||||
//
|
||||
// It seems most sensible to move this into the `start_service` function, but I'm caution
|
||||
// of making too many changes this close to genesis (<1 week).
|
||||
wait_for_genesis(&beacon_nodes, genesis_time, &context).await?;
|
||||
|
||||
Ok(Self {
|
||||
context,
|
||||
duties_service,
|
||||
@@ -519,10 +518,12 @@ impl<T: EthSpec> ProductionValidatorClient<T> {
|
||||
config,
|
||||
slot_clock,
|
||||
http_api_listen_addr: None,
|
||||
genesis_time,
|
||||
beacon_nodes,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn start_service(&mut self) -> Result<(), String> {
|
||||
pub async fn start_service(&mut self) -> Result<(), String> {
|
||||
// We use `SLOTS_PER_EPOCH` as the capacity of the block notification channel, because
|
||||
// we don't expect notifications to be delayed by more than a single slot, let alone a
|
||||
// whole epoch!
|
||||
@@ -530,6 +531,44 @@ impl<T: EthSpec> ProductionValidatorClient<T> {
|
||||
let (block_service_tx, block_service_rx) = mpsc::channel(channel_capacity);
|
||||
let log = self.context.log();
|
||||
|
||||
let api_secret = ApiSecret::create_or_open(&self.config.validator_dir)?;
|
||||
|
||||
self.http_api_listen_addr = if self.config.http_api.enabled {
|
||||
let ctx = Arc::new(http_api::Context {
|
||||
task_executor: self.context.executor.clone(),
|
||||
api_secret,
|
||||
validator_store: Some(self.validator_store.clone()),
|
||||
validator_dir: Some(self.config.validator_dir.clone()),
|
||||
secrets_dir: Some(self.config.secrets_dir.clone()),
|
||||
graffiti_file: self.config.graffiti_file.clone(),
|
||||
graffiti_flag: self.config.graffiti,
|
||||
spec: self.context.eth2_config.spec.clone(),
|
||||
config: self.config.http_api.clone(),
|
||||
sse_logging_components: self.context.sse_logging_components.clone(),
|
||||
slot_clock: self.slot_clock.clone(),
|
||||
log: log.clone(),
|
||||
_phantom: PhantomData,
|
||||
});
|
||||
|
||||
let exit = self.context.executor.exit();
|
||||
|
||||
let (listen_addr, server) = http_api::serve(ctx, exit)
|
||||
.map_err(|e| format!("Unable to start HTTP API server: {:?}", e))?;
|
||||
|
||||
self.context
|
||||
.clone()
|
||||
.executor
|
||||
.spawn_without_exit(server, "http-api");
|
||||
|
||||
Some(listen_addr)
|
||||
} else {
|
||||
info!(log, "HTTP API server is disabled");
|
||||
None
|
||||
};
|
||||
|
||||
// Wait until genesis has occurred.
|
||||
wait_for_genesis(&self.beacon_nodes, self.genesis_time, &self.context).await?;
|
||||
|
||||
duties_service::start_update_service(self.duties_service.clone(), block_service_tx);
|
||||
|
||||
self.block_service
|
||||
@@ -568,41 +607,6 @@ impl<T: EthSpec> ProductionValidatorClient<T> {
|
||||
|
||||
spawn_notifier(self).map_err(|e| format!("Failed to start notifier: {}", e))?;
|
||||
|
||||
let api_secret = ApiSecret::create_or_open(&self.config.validator_dir)?;
|
||||
|
||||
self.http_api_listen_addr = if self.config.http_api.enabled {
|
||||
let ctx = Arc::new(http_api::Context {
|
||||
task_executor: self.context.executor.clone(),
|
||||
api_secret,
|
||||
validator_store: Some(self.validator_store.clone()),
|
||||
validator_dir: Some(self.config.validator_dir.clone()),
|
||||
secrets_dir: Some(self.config.secrets_dir.clone()),
|
||||
graffiti_file: self.config.graffiti_file.clone(),
|
||||
graffiti_flag: self.config.graffiti,
|
||||
spec: self.context.eth2_config.spec.clone(),
|
||||
config: self.config.http_api.clone(),
|
||||
sse_logging_components: self.context.sse_logging_components.clone(),
|
||||
slot_clock: self.slot_clock.clone(),
|
||||
log: log.clone(),
|
||||
_phantom: PhantomData,
|
||||
});
|
||||
|
||||
let exit = self.context.executor.exit();
|
||||
|
||||
let (listen_addr, server) = http_api::serve(ctx, exit)
|
||||
.map_err(|e| format!("Unable to start HTTP API server: {:?}", e))?;
|
||||
|
||||
self.context
|
||||
.clone()
|
||||
.executor
|
||||
.spawn_without_exit(server, "http-api");
|
||||
|
||||
Some(listen_addr)
|
||||
} else {
|
||||
info!(log, "HTTP API server is disabled");
|
||||
None
|
||||
};
|
||||
|
||||
if self.config.enable_latency_measurement_service {
|
||||
latency::start_latency_service(
|
||||
self.context.clone(),
|
||||
|
||||
Reference in New Issue
Block a user