Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modularize validator store #6705

Draft
wants to merge 25 commits into
base: unstable
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
73743a5
Tracing executor and metrics rename
AgeManning Sep 23, 2024
eb0cef9
Merge latest unstable
AgeManning Nov 26, 2024
0ecd6c3
pass slots_per_epoch at runtime
jxs Dec 16, 2024
6f3fe95
remove generic E from unrequired types
jxs Dec 18, 2024
a9cc2fb
Merge branch 'unstable' of github.com:sigp/lighthouse into remove-e-f…
jxs Dec 19, 2024
30998cd
move `validator_store` to `lighthouse_validator_store`
dknopik Dec 19, 2024
f539f85
make validator_store into a trait
dknopik Dec 10, 2024
e473f63
further reduce dependencies
dknopik Dec 10, 2024
45ce473
remove `environment` dependency on `beacon_node_fallback`
dknopik Dec 12, 2024
be95852
Manually pull in some changes from tracing-integration (thanks sayan!)
dknopik Dec 12, 2024
77eca5a
remove `environment` from `validator_services`
dknopik Dec 12, 2024
9b7c160
unify boost factor accessors
dknopik Dec 12, 2024
b49845a
add builder for DutiesService
dknopik Dec 13, 2024
79367de
Manually merge tracing PR for beacon_node_fallback
dknopik Dec 13, 2024
838eed6
Fix chain_spec for BlockService
dknopik Dec 13, 2024
6533a67
address review
jxs Dec 20, 2024
36a4d2f
remove PhantomData from SyncDutiesMap
jxs Dec 20, 2024
c5ab120
Merge branch 'remove-e-from-validator-client' into modularize-validat…
dknopik Jan 2, 2025
ebfe234
fix tests
dknopik Jan 2, 2025
07dbf15
correct test
dknopik Jan 2, 2025
39aec1b
Add `E` to `ValidatorStore` as associated type
dknopik Jan 3, 2025
e0da923
fix tests
dknopik Jan 3, 2025
4510b73
derive Clone for ValidatorStore's Error and required sub-errors
dknopik Jan 7, 2025
3208430
Merge pull request #6768 from sigp/unstable
jimmygchen Jan 8, 2025
c0fffc0
Merge branch 'anchor' into modularize-validator-store
jimmygchen Jan 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ members = [
"validator_client/http_api",
"validator_client/http_metrics",
"validator_client/initialized_validators",
"validator_client/lighthouse_validator_store",
"validator_client/signing_method",
"validator_client/slashing_protection",
"validator_client/validator_metrics",
"validator_client/validator_services",
"validator_client/validator_store",

"validator_manager",

Expand Down Expand Up @@ -253,6 +253,7 @@ int_to_bytes = { path = "consensus/int_to_bytes" }
kzg = { path = "crypto/kzg" }
metrics = { path = "common/metrics" }
lighthouse_network = { path = "beacon_node/lighthouse_network" }
lighthouse_validator_store = { path = "validator_client/lighthouse_validator_store" }
lighthouse_version = { path = "common/lighthouse_version" }
lockfile = { path = "common/lockfile" }
logging = { path = "common/logging" }
Expand Down
1 change: 1 addition & 0 deletions common/logging/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
pub const MAX_MESSAGE_WIDTH: usize = 40;

pub mod async_record;
pub mod macros;
mod sse_logging_components;
mod tracing_logging_layer;
mod tracing_metrics_layer;
Expand Down
6 changes: 6 additions & 0 deletions common/logging/src/macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[macro_export]
macro_rules! crit {
($($arg:tt)*) => {
tracing::error!(error_type = "crit", $($arg)*);
};
}
2 changes: 1 addition & 1 deletion consensus/types/src/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::{
Signature, SignedRoot,
};

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Clone)]
pub enum Error {
SszTypesError(ssz_types::Error),
AlreadySigned(usize),
Expand Down
13 changes: 9 additions & 4 deletions consensus/types/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ pub trait AbstractExecPayload<E: EthSpec>:
+ TryInto<Self::Capella>
+ TryInto<Self::Deneb>
+ TryInto<Self::Electra>
+ Sync
{
type Ref<'a>: ExecPayload<E>
+ Copy
Expand All @@ -95,19 +96,23 @@ pub trait AbstractExecPayload<E: EthSpec>:
type Bellatrix: OwnedExecPayload<E>
+ Into<Self>
+ for<'a> From<Cow<'a, ExecutionPayloadBellatrix<E>>>
+ TryFrom<ExecutionPayloadHeaderBellatrix<E>>;
+ TryFrom<ExecutionPayloadHeaderBellatrix<E>>
+ Sync;
type Capella: OwnedExecPayload<E>
+ Into<Self>
+ for<'a> From<Cow<'a, ExecutionPayloadCapella<E>>>
+ TryFrom<ExecutionPayloadHeaderCapella<E>>;
+ TryFrom<ExecutionPayloadHeaderCapella<E>>
+ Sync;
type Deneb: OwnedExecPayload<E>
+ Into<Self>
+ for<'a> From<Cow<'a, ExecutionPayloadDeneb<E>>>
+ TryFrom<ExecutionPayloadHeaderDeneb<E>>;
+ TryFrom<ExecutionPayloadHeaderDeneb<E>>
+ Sync;
type Electra: OwnedExecPayload<E>
+ Into<Self>
+ for<'a> From<Cow<'a, ExecutionPayloadElectra<E>>>
+ TryFrom<ExecutionPayloadHeaderElectra<E>>;
+ TryFrom<ExecutionPayloadHeaderElectra<E>>
+ Sync;
}

#[superstruct(
Expand Down
1 change: 1 addition & 0 deletions testing/web3signer_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ eth2_keystore = { workspace = true }
eth2_network_config = { workspace = true }
futures = { workspace = true }
initialized_validators = { workspace = true }
lighthouse_validator_store = { workspace = true }
logging = { workspace = true }
parking_lot = { workspace = true }
reqwest = { workspace = true }
Expand Down
15 changes: 8 additions & 7 deletions testing/web3signer_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mod tests {
use initialized_validators::{
load_pem_certificate, load_pkcs12_identity, InitializedValidators,
};
use lighthouse_validator_store::LighthouseValidatorStore;
use logging::test_logger;
use parking_lot::Mutex;
use reqwest::Client;
Expand All @@ -45,7 +46,7 @@ mod tests {
use tokio::time::sleep;
use types::{attestation::AttestationBase, *};
use url::Url;
use validator_store::{Error as ValidatorStoreError, ValidatorStore};
use validator_store::{Error as ValidatorStoreError, SignBlock, ValidatorStore};

/// If the we are unable to reach the Web3Signer HTTP API within this time out then we will
/// assume it failed to start.
Expand Down Expand Up @@ -309,7 +310,7 @@ mod tests {

/// A testing rig which holds a `ValidatorStore`.
struct ValidatorStoreRig {
validator_store: Arc<ValidatorStore<TestingSlotClock, E>>,
validator_store: Arc<LighthouseValidatorStore<TestingSlotClock, E>>,
_validator_dir: TempDir,
runtime: Arc<tokio::runtime::Runtime>,
_runtime_shutdown: async_channel::Sender<()>,
Expand Down Expand Up @@ -358,12 +359,12 @@ mod tests {

let slot_clock =
TestingSlotClock::new(Slot::new(0), Duration::from_secs(0), Duration::from_secs(1));
let config = validator_store::Config {
let config = lighthouse_validator_store::Config {
enable_web3signer_slashing_protection: slashing_protection_config.local,
..Default::default()
};

let validator_store = ValidatorStore::<_, E>::new(
let validator_store = LighthouseValidatorStore::new(
initialized_validators,
slashing_protection,
Hash256::repeat_byte(42),
Expand Down Expand Up @@ -488,7 +489,7 @@ mod tests {
generate_sig: F,
) -> Self
where
F: Fn(PublicKeyBytes, Arc<ValidatorStore<TestingSlotClock, E>>) -> R,
F: Fn(PublicKeyBytes, Arc<LighthouseValidatorStore<TestingSlotClock, E>>) -> R,
R: Future<Output = S>,
// We use the `SignedObject` trait to white-list objects for comparison. This avoids
// accidentally comparing something meaningless like a `()`.
Expand Down Expand Up @@ -523,8 +524,8 @@ mod tests {
web3signer_should_sign: bool,
) -> Self
where
F: Fn(PublicKeyBytes, Arc<ValidatorStore<TestingSlotClock, E>>) -> R,
R: Future<Output = Result<(), ValidatorStoreError>>,
F: Fn(PublicKeyBytes, Arc<LighthouseValidatorStore<TestingSlotClock, E>>) -> R,
R: Future<Output = Result<(), lighthouse_validator_store::Error>>,
{
for validator_rig in &self.validator_rigs {
let result =
Expand Down
1 change: 1 addition & 0 deletions validator_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fdlimit = "0.3.0"
graffiti_file = { workspace = true }
hyper = { workspace = true }
initialized_validators = { workspace = true }
lighthouse_validator_store = { workspace = true }
metrics = { workspace = true }
monitoring_api = { workspace = true }
parking_lot = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions validator_client/beacon_node_fallback/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ name = "beacon_node_fallback"
path = "src/lib.rs"

[dependencies]
environment = { workspace = true }
eth2 = { workspace = true }
futures = { workspace = true }
itertools = { workspace = true }
serde = { workspace = true }
slog = { workspace = true }
slot_clock = { workspace = true }
strum = { workspace = true }
task_executor = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
types = { workspace = true }
validator_metrics = { workspace = true }
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use super::CandidateError;
use eth2::BeaconNodeHttpClient;
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use slog::{warn, Logger};
use std::cmp::Ordering;
use std::fmt::{Debug, Display, Formatter};
use std::str::FromStr;
use tracing::warn;
use types::Slot;

/// Sync distances between 0 and DEFAULT_SYNC_TOLERANCE are considered `synced`.
Expand Down Expand Up @@ -290,15 +290,13 @@ impl BeaconNodeHealth {

pub async fn check_node_health(
beacon_node: &BeaconNodeHttpClient,
log: &Logger,
) -> Result<(Slot, bool, bool), CandidateError> {
let resp = match beacon_node.get_node_syncing().await {
Ok(resp) => resp,
Err(e) => {
warn!(
log,
"Unable connect to beacon node";
"error" => %e
error = %e,
"Unable connect to beacon node"
);

return Err(CandidateError::Offline);
Expand Down
Loading
Loading