Skip to content

Implement selections Beacon API endpoints to support DVT middleware #7016

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

Open
wants to merge 81 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
fc657db
Define type and modify function
chong-he Feb 18, 2025
8c7a995
Add client side endpoint
chong-he Feb 19, 2025
358646c
update if loop
chong-he Feb 19, 2025
83db29a
Revise a bit
chong-he Feb 20, 2025
20ecb35
post endpoint return selection proof
chong-he Feb 20, 2025
7ff3ffe
Fix error
chong-he Feb 20, 2025
d8d31b7
Add Vec
chong-he Feb 20, 2025
cba2adb
println logs
chong-he Mar 6, 2025
61e79b6
println response
chong-he Mar 6, 2025
4518b46
Testing
chong-he Mar 7, 2025
8e0315d
remove serde
chong-he Mar 7, 2025
0d724b1
Correct output type thanks Michael
chong-he Mar 10, 2025
d6c7461
Add timeout for aggregator
chong-he Mar 10, 2025
7ef2a48
update aggregator timeout
chong-he Mar 12, 2025
81ee8e3
Change timeout and add debug log
chong-he Mar 13, 2025
376bc70
space
chong-he Mar 13, 2025
0c360c8
log
chong-he Mar 13, 2025
50ec5f1
add distributed lookahead
chong-he Mar 16, 2025
7dd7ed2
simplify
chong-he Mar 17, 2025
4f3b3d5
correct timeout
chong-he Mar 17, 2025
52854a0
Add public key in log
chong-he Mar 19, 2025
8b2f058
Sign selection proof in parallel
chong-he Mar 20, 2025
1631c86
Implement sync committee selection endpoint
chong-he Mar 24, 2025
f7f5bf1
Modify only current slot
chong-he Mar 24, 2025
d2bb70e
Remove current slot
chong-he Mar 25, 2025
3b883c3
Testing distributed mode
chong-he Mar 26, 2025
57e0bb6
remove proof_slot
chong-he Mar 26, 2025
1535f40
Add back proof slot
chong-he Mar 27, 2025
b21451f
Fix
chong-he Mar 27, 2025
7ac6867
Add debug logging
chong-he Mar 27, 2025
ef90462
Remove transparent
chong-he Mar 27, 2025
89e19ec
Merge branch 'unstable' into dvt
chong-he Mar 31, 2025
1118d62
Update logging
chong-he Mar 31, 2025
9459c36
Simplify beacon committee selection logging and code
chong-he Apr 1, 2025
101f24c
logging
chong-he Apr 1, 2025
d222ce8
tidy up sync.rs
chong-he Apr 1, 2025
6f2ea51
sync.rs
chong-he Apr 1, 2025
e8ca60e
Fix logging from middleware
chong-he Apr 1, 2025
6eb692b
Merge branch 'unstable' into dvt
chong-he Apr 1, 2025
e3406be
remove subnet for loop
chong-he Apr 1, 2025
dca0060
Merge branch 'dvt' of https://github.com/chong-he/lighthouse into dvt
chong-he Apr 1, 2025
1877f09
Add comment
chong-he Apr 1, 2025
41422b1
reduce diff
chong-he Apr 1, 2025
8fd345c
move log
chong-he Apr 1, 2025
bf75ee4
revert
chong-he Apr 1, 2025
120fa54
simplify
chong-he Apr 1, 2025
d3dbe87
Add SelectionProofConfig
chong-he Apr 9, 2025
a11cee2
Use FuturesUnordered
chong-he Apr 9, 2025
af676d4
Remove negation
chong-he Apr 10, 2025
76125fa
Process each result
chong-he Apr 11, 2025
ea13f74
Add duration of computation offset
chong-he Apr 11, 2025
44bd5f1
rearrange
chong-he Apr 11, 2025
b506fa5
Remove duplication with a function
chong-he Apr 15, 2025
3fc62f2
Merge branch 'unstable' into dvt
chong-he Apr 15, 2025
ab1d2c0
Modify to FuturesUnordered for Sync
chong-he Apr 15, 2025
2612a6b
create helper function in sync
chong-he Apr 16, 2025
efa14b0
refactor distributed sync part
chong-he Apr 17, 2025
24b125f
Try to fix
chong-he Apr 18, 2025
f2725ce
Add log to debug
chong-he Apr 18, 2025
23fefa3
Add more logging
chong-he Apr 18, 2025
67d2f9b
change computation offset
chong-he Apr 21, 2025
247f133
change to slot
chong-he Apr 21, 2025
239c183
proof_slot
chong-he Apr 21, 2025
37a0276
Merge branch 'unstable' into dvt
chong-he Apr 22, 2025
67bfd11
refactor for normal mode
chong-he Apr 23, 2025
980e399
Revise to SyncDutiesMap
chong-he Apr 23, 2025
c71de71
change to 0
chong-he Apr 23, 2025
2bcb984
Revised to sync_duties
chong-he Apr 23, 2025
23c9013
remove logging
chong-he Apr 23, 2025
43b209f
add transparent
chong-he Apr 23, 2025
f20f749
Add comments
chong-he Apr 23, 2025
05df47b
Comment
chong-he Apr 23, 2025
b71e40d
Revise config move to lib.rs
chong-he Apr 29, 2025
9d6d1cb
Revise a bit
chong-he Apr 29, 2025
d34a91a
address comments
chong-he Apr 29, 2025
9d8a9e7
revise comment
chong-he May 6, 2025
bcfe5ff
Merge branch 'unstable' into dvt
chong-he May 9, 2025
46c29b0
fix
chong-he May 9, 2025
c790d9d
Fix
chong-he May 9, 2025
4e77e39
Add debug
chong-he May 9, 2025
69e7e60
Add comment for clarity
chong-he May 9, 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
16 changes: 16 additions & 0 deletions common/eth2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,22 @@ impl BeaconNodeHttpClient {
)
.await
}

/// `POST validator/beacon_committee_selections`
pub async fn post_validator_beacon_committee_selections(
&self,
selections: &[BeaconCommitteeSelection],
) -> Result<GenericResponse<Vec<SelectionProof>>, Error> {
let mut path = self.eth_path(V1)?;

path.path_segments_mut()
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
.push("validator")
.push("beacon_committee_selections");

self.post_with_timeout_and_response(path, &selections, self.timeouts.attester_duties)
.await
}
}

/// Returns `Ok(response)` if the response is a `200 OK` response. Otherwise, creates an
Expand Down
7 changes: 7 additions & 0 deletions common/eth2/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,13 @@ pub struct PeerCount {
pub disconnecting: u64,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BeaconCommitteeSelection {
#[serde(with = "serde_utils::quoted_u64")]
pub validator_index: u64,
pub slot: Slot,
pub selection_proof: Signature,
}
// --------- Server Sent Event Types -----------

#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)]
Expand Down
4 changes: 3 additions & 1 deletion consensus/types/src/selection_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ use crate::{
};
use ethereum_hashing::hash;
use safe_arith::{ArithError, SafeArith};
use serde::{Deserialize, Serialize};
use ssz::Encode;
use std::cmp;

#[derive(arbitrary::Arbitrary, PartialEq, Debug, Clone)]
#[derive(arbitrary::Arbitrary, PartialEq, Debug, Clone, Serialize, Deserialize)]
#[serde(transparent)]
pub struct SelectionProof(Signature);

impl SelectionProof {
Expand Down
52 changes: 47 additions & 5 deletions validator_client/validator_services/src/duties_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use beacon_node_fallback::{ApiTopic, BeaconNodeFallback};
use doppelganger_service::DoppelgangerStatus;
use environment::RuntimeContext;
use eth2::types::{
AttesterData, BeaconCommitteeSubscription, DutiesResponse, ProposerData, StateId, ValidatorId,
AttesterData, BeaconCommitteeSelection, BeaconCommitteeSubscription, DutiesResponse,
ProposerData, StateId, ValidatorId,
};
use futures::{stream, StreamExt};
use parking_lot::RwLock;
Expand Down Expand Up @@ -129,11 +130,50 @@ async fn make_selection_proof<T: SlotClock + 'static, E: EthSpec>(
duty: &AttesterData,
validator_store: &ValidatorStore<T, E>,
spec: &ChainSpec,
distributed: bool,
beacon_nodes: &Arc<BeaconNodeFallback<T, E>>,
) -> Result<Option<SelectionProof>, Error> {
let selection_proof = validator_store
.produce_selection_proof(duty.pubkey, duty.slot)
.await
.map_err(Error::FailedToProduceSelectionProof)?;
let selection_proof = if distributed {
// Submit a partial selection proof in the data field of the POST HTTP endpoint
let selection = BeaconCommitteeSelection {
validator_index: duty.validator_index,
slot: duty.slot,
selection_proof: validator_store
.produce_selection_proof(duty.pubkey, duty.slot)
.await
.map_err(Error::FailedToProduceSelectionProof)?
.into(),
};
// Call the endpoint /eth/v1/validator/beacon_committee_selections
// The middleware should return a full selection proof here

let response = beacon_nodes
.first_success(|beacon_node| {
let selections = selection.clone();
println!("Selection proof: {:?}", selections);
async move {
let response = beacon_node
.post_validator_beacon_committee_selections(&[selections])
.await;

println!("Response from middleware {:?}", response);

response
}
})
.await;
response
.map_err(|e| {
Error::FailedToProduceSelectionProof(ValidatorStoreError::Middleware(e.to_string()))
})?
.data[0]
.clone()
} else {
validator_store
.produce_selection_proof(duty.pubkey, duty.slot)
.await
.map_err(Error::FailedToProduceSelectionProof)?
};

selection_proof
.is_aggregator(duty.committee_length as usize, spec)
Expand Down Expand Up @@ -1101,6 +1141,8 @@ async fn fill_in_selection_proofs<T: SlotClock + 'static, E: EthSpec>(
&duty,
&duties_service.validator_store,
&duties_service.spec,
duties_service.distributed,
&duties_service.beacon_nodes,
)
.await?;
Ok((duty, opt_selection_proof))
Expand Down
1 change: 1 addition & 0 deletions validator_client/validator_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub enum Error {
GreaterThanCurrentEpoch { epoch: Epoch, current_epoch: Epoch },
UnableToSignAttestation(AttestationError),
UnableToSign(SigningError),
Middleware(String),
}

impl From<SigningError> for Error {
Expand Down
Loading