Skip to content

Modularize validator store #6705

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

Merged
merged 24 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a57ed6b
pass slots_per_epoch at runtime
jxs Dec 16, 2024
ceb1706
remove generic E from unrequired types
jxs Dec 18, 2024
bbddbba
move `validator_store` to `lighthouse_validator_store`
dknopik Dec 19, 2024
3b7b9c6
make validator_store into a trait
dknopik Dec 10, 2024
4505298
further reduce dependencies
dknopik Dec 10, 2024
d90ad1f
remove `environment` dependency on `beacon_node_fallback`
dknopik Dec 12, 2024
36925e3
remove `environment` from `validator_services`
dknopik Dec 12, 2024
87068cb
unify boost factor accessors
dknopik Dec 12, 2024
74cc922
add builder for DutiesService
dknopik Dec 13, 2024
fb62fec
remove PhantomData from SyncDutiesMap
jxs Dec 20, 2024
61a932b
Add `E` to `ValidatorStore` as associated type
dknopik Jan 3, 2025
b050917
derive Clone for ValidatorStore's Error and required sub-errors
dknopik Jan 7, 2025
0ab9c9a
switch to enum for block signing to allow differing types
dknopik Jan 9, 2025
b30f739
Merge branch 'unstable' into modularize-validator-store
dknopik Mar 14, 2025
05f9669
Merge branch 'unstable' into modularize-validator-store
dknopik Apr 2, 2025
47e3e38
Merge branch 'unstable' into modularize-validator-store
dknopik Apr 4, 2025
05367e0
remove unused dep
dknopik Apr 4, 2025
9f1b47d
Merge branch 'unstable' into modularize-validator-store
dknopik Apr 15, 2025
07cf6b9
Merge remote-tracking branch 'origin/unstable' into modularize-valida…
michaelsproul May 5, 2025
7a9a9c4
Fix URL
michaelsproul May 5, 2025
eab1c64
Fix blank line in Cargo.toml
dknopik May 5, 2025
508bbed
Remove BlockService::get_builder_boost_factor
michaelsproul May 6, 2025
ffe96a4
Update comment on `determine_builder_boost_factor`
michaelsproul May 6, 2025
d0f169d
Move `sign_voluntary_exit` from `ValidatorStore` to `LighthouseValida…
dknopik May 6, 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
49 changes: 33 additions & 16 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,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 @@ -228,7 +228,6 @@ compare_fields = { path = "common/compare_fields" }
deposit_contract = { path = "common/deposit_contract" }
directory = { path = "common/directory" }
doppelganger_service = { path = "validator_client/doppelganger_service" }
validator_services = { path = "validator_client/validator_services" }
environment = { path = "lighthouse/environment" }
eth1 = { path = "beacon_node/eth1" }
eth1_test_rig = { path = "testing/eth1_test_rig" }
Expand All @@ -250,6 +249,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" }
workspace_members = { path = "common/workspace_members" }
lockfile = { path = "common/lockfile" }
Expand Down Expand Up @@ -281,6 +281,7 @@ validator_dir = { path = "common/validator_dir" }
validator_http_api = { path = "validator_client/http_api" }
validator_http_metrics = { path = "validator_client/http_metrics" }
validator_metrics = { path = "validator_client/validator_metrics" }
validator_services = { path = "validator_client/validator_services" }
validator_store = { path = "validator_client/validator_store" }
validator_test_rig = { path = "testing/validator_test_rig" }
warp_utils = { path = "common/warp_utils" }
Expand Down
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),
BitfieldError(ssz::BitfieldError),
Expand Down
16 changes: 11 additions & 5 deletions consensus/types/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub trait AbstractExecPayload<E: EthSpec>:
+ TryInto<Self::Deneb>
+ TryInto<Self::Electra>
+ TryInto<Self::Fulu>
+ Sync
{
type Ref<'a>: ExecPayload<E>
+ Copy
Expand All @@ -97,23 +98,28 @@ 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;
type Fulu: OwnedExecPayload<E>
+ Into<Self>
+ for<'a> From<Cow<'a, ExecutionPayloadFulu<E>>>
+ TryFrom<ExecutionPayloadHeaderFulu<E>>;
+ TryFrom<ExecutionPayloadHeaderFulu<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
34 changes: 20 additions & 14 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 parking_lot::Mutex;
use reqwest::Client;
use serde::Serialize;
Expand All @@ -44,7 +45,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, SignedBlock, 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 @@ -73,6 +74,7 @@ mod tests {
impl SignedObject for Signature {}
impl SignedObject for Attestation<E> {}
impl SignedObject for SignedBeaconBlock<E> {}
impl SignedObject for SignedBlock<E> {}
impl SignedObject for SignedAggregateAndProof<E> {}
impl SignedObject for SelectionProof {}
impl SignedObject for SyncSelectionProof {}
Expand Down Expand Up @@ -301,7 +303,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 @@ -352,12 +354,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::<_, E>::new(
initialized_validators,
slashing_protection,
Hash256::repeat_byte(42),
Expand Down Expand Up @@ -481,7 +483,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 @@ -516,8 +518,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 Expand Up @@ -591,10 +593,10 @@ mod tests {
.assert_signatures_match("beacon_block_base", |pubkey, validator_store| {
let spec = spec.clone();
async move {
let block = BeaconBlock::Base(BeaconBlockBase::empty(&spec));
let block = BeaconBlock::<E>::Base(BeaconBlockBase::empty(&spec));
let block_slot = block.slot();
validator_store
.sign_block(pubkey, block, block_slot)
.sign_block(pubkey, block.into(), block_slot)
.await
.unwrap()
}
Expand Down Expand Up @@ -664,7 +666,11 @@ mod tests {
let mut altair_block = BeaconBlockAltair::empty(&spec);
altair_block.slot = altair_fork_slot;
validator_store
.sign_block(pubkey, BeaconBlock::Altair(altair_block), altair_fork_slot)
.sign_block(
pubkey,
BeaconBlock::<E>::Altair(altair_block).into(),
altair_fork_slot,
)
.await
.unwrap()
}
Expand Down Expand Up @@ -749,7 +755,7 @@ mod tests {
validator_store
.sign_block(
pubkey,
BeaconBlock::Bellatrix(bellatrix_block),
BeaconBlock::<E>::Bellatrix(bellatrix_block).into(),
bellatrix_fork_slot,
)
.await
Expand Down Expand Up @@ -805,7 +811,7 @@ mod tests {
};

let first_block = || {
let mut bellatrix_block = BeaconBlockBellatrix::empty(&spec);
let mut bellatrix_block = BeaconBlockBellatrix::<E>::empty(&spec);
bellatrix_block.slot = bellatrix_fork_slot;
BeaconBlock::Bellatrix(bellatrix_block)
};
Expand Down Expand Up @@ -871,7 +877,7 @@ mod tests {
let block = first_block();
let slot = block.slot();
validator_store
.sign_block(pubkey, block, slot)
.sign_block(pubkey, block.into(), slot)
.await
.unwrap()
})
Expand All @@ -882,7 +888,7 @@ mod tests {
let block = double_vote_block();
let slot = block.slot();
validator_store
.sign_block(pubkey, block, slot)
.sign_block(pubkey, block.into(), slot)
.await
.map(|_| ())
},
Expand Down
1 change: 1 addition & 0 deletions validator_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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
3 changes: 1 addition & 2 deletions validator_client/beacon_node_fallback/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ path = "src/lib.rs"

[dependencies]
clap = { workspace = true }
environment = { workspace = true }
eth2 = { workspace = true }
futures = { workspace = true }
itertools = { workspace = true }
serde = { 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 }

[dev-dependencies]
logging = { workspace = true }
validator_test_rig = { workspace = true }
Loading
Loading