Sync committee sign bn fallback (#3624)
## Issue Addressed Closes #3612 ## Proposed Changes - Iterates through BNs until it finds a non-optimistic head. A slight change in error behavior: - Previously: `spawn_contribution_tasks` did not return an error for a non-optimistic block head. It returned `Ok(())` logged a warning. - Now: `spawn_contribution_tasks` returns an error if it cannot find a non-optimistic block head. The caller of `spawn_contribution_tasks` then logs the error as a critical error. Co-authored-by: Michael Sproul <micsproul@gmail.com>
This commit is contained in:
parent
3be41006a6
commit
5dba89e43b
@ -174,39 +174,40 @@ impl<T: SlotClock + 'static, E: EthSpec> SyncCommitteeService<T, E> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Fetch `block_root` and `execution_optimistic` for `SyncCommitteeContribution`.
|
||||
// Fetch `block_root` with non optimistic execution for `SyncCommitteeContribution`.
|
||||
let response = self
|
||||
.beacon_nodes
|
||||
.first_success(RequireSynced::Yes, OfflineOnFailure::Yes,|beacon_node| async move {
|
||||
beacon_node.get_beacon_blocks_root(BlockId::Head).await
|
||||
})
|
||||
.await
|
||||
.map_err(|e| e.to_string())?
|
||||
.ok_or_else(|| format!("No block root found for slot {}", slot))?;
|
||||
.first_success(
|
||||
RequireSynced::Yes,
|
||||
OfflineOnFailure::Yes,
|
||||
|beacon_node| async move {
|
||||
match beacon_node.get_beacon_blocks_root(BlockId::Head).await {
|
||||
Ok(Some(block)) if block.execution_optimistic == Some(false) => {
|
||||
Ok(block)
|
||||
}
|
||||
Ok(Some(_)) => {
|
||||
Err(format!("To sign sync committee messages for slot {slot} a non-optimistic head block is required"))
|
||||
}
|
||||
Ok(None) => Err(format!("No block root found for slot {}", slot)),
|
||||
Err(e) => Err(e.to_string()),
|
||||
}
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
let block_root = response.data.root;
|
||||
if let Some(execution_optimistic) = response.execution_optimistic {
|
||||
if execution_optimistic {
|
||||
let block_root = match response {
|
||||
Ok(block) => block.data.root,
|
||||
Err(errs) => {
|
||||
warn!(
|
||||
log,
|
||||
"Refusing to sign sync committee messages for optimistic head block";
|
||||
"Refusing to sign sync committee messages for an optimistic head block or \
|
||||
a block head with unknown optimistic status";
|
||||
"errors" => errs.to_string(),
|
||||
"slot" => slot,
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
} else if let Some(bellatrix_fork_epoch) = self.duties_service.spec.bellatrix_fork_epoch {
|
||||
// If the slot is post Bellatrix, do not sign messages when we cannot verify the
|
||||
// optimistic status of the head block.
|
||||
if slot.epoch(E::slots_per_epoch()) > bellatrix_fork_epoch {
|
||||
warn!(
|
||||
log,
|
||||
"Refusing to sign sync committee messages for a head block with an unknown \
|
||||
optimistic status";
|
||||
"slot" => slot,
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Spawn one task to publish all of the sync committee signatures.
|
||||
let validator_duties = slot_duties.duties;
|
||||
|
Loading…
Reference in New Issue
Block a user