remove assumption of shared finalized-block ancestery between fork choice and chaindag in getDebugForkChoice (#5328)

This commit is contained in:
tersec 2023-08-20 07:19:07 +00:00 committed by GitHub
parent b4b40fa7d2
commit d889b62b79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -113,10 +113,17 @@ proc installDebugApiHandlers*(router: var RestRouter, node: BeaconNode) =
validity:
if item.invalid:
RestNodeValidity.invalid
elif node.dag.is_optimistic(item.bid):
RestNodeValidity.optimistic
else:
RestNodeValidity.valid,
# Fork choice doesn't necessarily prune finalized blocks in a
# synchronized way to the chaindag, so can't assume that when
# item.bid.slot is before finalizedHead, it has shared status
# regarding optimistic/validity as finalizedHead, so fallback
# to optimistic is more appropriate for this REST endpoint.
let blck = node.dag.getBlockRef(item.bid.root)
if blck.isNone() or not blck.get.executionValid:
RestNodeValidity.optimistic
else:
RestNodeValidity.valid,
execution_block_hash: node.dag.loadExecutionBlockHash(item.bid),
extra_data: some RestNodeExtraData(
justified_root: item.checkpoints.justified.root,