Skip to content

Commit 17598f1

Browse files
tthebstmichaelsproul
authored andcommittedJan 6, 2024
Sync committee sign bn fallback (sigp#3624)
## Issue Addressed Closes sigp#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>
1 parent ea4097e commit 17598f1

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed
 

‎validator_client/src/sync_committee_service.rs

+25-24
Original file line numberDiff line numberDiff line change
@@ -174,39 +174,40 @@ impl<T: SlotClock + 'static, E: EthSpec> SyncCommitteeService<T, E> {
174174
return Ok(());
175175
}
176176

177-
// Fetch `block_root` and `execution_optimistic` for `SyncCommitteeContribution`.
177+
// Fetch `block_root` with non optimistic execution for `SyncCommitteeContribution`.
178178
let response = self
179179
.beacon_nodes
180-
.first_success(RequireSynced::Yes, OfflineOnFailure::Yes,|beacon_node| async move {
181-
beacon_node.get_beacon_blocks_root(BlockId::Head).await
182-
})
183-
.await
184-
.map_err(|e| e.to_string())?
185-
.ok_or_else(|| format!("No block root found for slot {}", slot))?;
180+
.first_success(
181+
RequireSynced::Yes,
182+
OfflineOnFailure::Yes,
183+
|beacon_node| async move {
184+
match beacon_node.get_beacon_blocks_root(BlockId::Head).await {
185+
Ok(Some(block)) if block.execution_optimistic == Some(false) => {
186+
Ok(block)
187+
}
188+
Ok(Some(_)) => {
189+
Err(format!("To sign sync committee messages for slot {slot} a non-optimistic head block is required"))
190+
}
191+
Ok(None) => Err(format!("No block root found for slot {}", slot)),
192+
Err(e) => Err(e.to_string()),
193+
}
194+
},
195+
)
196+
.await;
186197

187-
let block_root = response.data.root;
188-
if let Some(execution_optimistic) = response.execution_optimistic {
189-
if execution_optimistic {
198+
let block_root = match response {
199+
Ok(block) => block.data.root,
200+
Err(errs) => {
190201
warn!(
191202
log,
192-
"Refusing to sign sync committee messages for optimistic head block";
203+
"Refusing to sign sync committee messages for an optimistic head block or \
204+
a block head with unknown optimistic status";
205+
"errors" => errs.to_string(),
193206
"slot" => slot,
194207
);
195208
return Ok(());
196209
}
197-
} else if let Some(bellatrix_fork_epoch) = self.duties_service.spec.bellatrix_fork_epoch {
198-
// If the slot is post Bellatrix, do not sign messages when we cannot verify the
199-
// optimistic status of the head block.
200-
if slot.epoch(E::slots_per_epoch()) > bellatrix_fork_epoch {
201-
warn!(
202-
log,
203-
"Refusing to sign sync committee messages for a head block with an unknown \
204-
optimistic status";
205-
"slot" => slot,
206-
);
207-
return Ok(());
208-
}
209-
}
210+
};
210211

211212
// Spawn one task to publish all of the sync committee signatures.
212213
let validator_duties = slot_duties.duties;

0 commit comments

Comments
 (0)
Please sign in to comment.