This commit is contained in:
Tan Chee Keong
2025-04-01 10:02:32 +08:00
parent 9459c362dd
commit 101f24c440

View File

@@ -134,8 +134,7 @@ async fn make_selection_proof<T: SlotClock + 'static, E: EthSpec>(
beacon_nodes: &Arc<BeaconNodeFallback<T, E>>, beacon_nodes: &Arc<BeaconNodeFallback<T, E>>,
) -> Result<Option<SelectionProof>, Error> { ) -> Result<Option<SelectionProof>, Error> {
let selection_proof = if distributed { let selection_proof = if distributed {
// Submit a partial selection proof in the data field of the POST HTTP endpoint let beacon_committee_selection = BeaconCommitteeSelection {
let selection = BeaconCommitteeSelection {
validator_index: duty.validator_index, validator_index: duty.validator_index,
slot: duty.slot, slot: duty.slot,
selection_proof: validator_store selection_proof: validator_store
@@ -145,38 +144,38 @@ async fn make_selection_proof<T: SlotClock + 'static, E: EthSpec>(
.into(), .into(),
}; };
// Call the endpoint /eth/v1/validator/beacon_committee_selections // Call the endpoint /eth/v1/validator/beacon_committee_selections
// The middleware should return a full selection proof here // by sending the BeaconCommitteeSelection that contains partial selection proof
let response = beacon_nodes // The middleware should return BeaconCommitteeSelection that contains full selection proof
let middleware_response = beacon_nodes
.first_success(|beacon_node| { .first_success(|beacon_node| {
let selections = selection.clone(); let selection_data = beacon_committee_selection.clone();
debug!( debug!(
"Selection proof" = ?selections, "validator_index" = duty.validator_index,
"Partial selection proof from VC" "slot" = %duty.slot,
"partial selection proof" = ?beacon_committee_selection.selection_proof,
"Sending beacon committee selection to middleware"
); );
// println!("Selection proof: {:?}", selections);
async move { async move {
let response = beacon_node beacon_node
.post_validator_beacon_committee_selections(&[selections]) .post_validator_beacon_committee_selections(&[selection_data])
.await; .await
debug!(?response, "Response from middleware");
// println!("Response from middleware {:?}", response);
response
} }
}) })
.await; .await;
SelectionProof::from(
response let response_data = &middleware_response
.map_err(|e| { .map_err(|e| {
Error::FailedToProduceSelectionProof(ValidatorStoreError::Middleware( Error::FailedToProduceSelectionProof(ValidatorStoreError::Middleware(e.to_string()))
e.to_string(), })?
)) .data[0];
})?
.data[0] debug!(
.selection_proof "validator_index" = response_data.validator_index,
.clone(), "slot" = %response_data.slot,
) "full selection proof" = ?response_data.selection_proof,
"Received beacon committee selection from middleware"
);
SelectionProof::from(response_data.selection_proof.clone())
} else { } else {
validator_store validator_store
.produce_selection_proof(duty.pubkey, duty.slot) .produce_selection_proof(duty.pubkey, duty.slot)