Skip to content

Commit e647fd7

Browse files
authored
fix: handle getDependentRoot() error when importing block (#7552)
1 parent 71d195b commit e647fd7

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

packages/beacon-node/src/chain/blocks/importBlock.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,20 @@ export async function importBlock(
216216
// Set head state as strong reference
217217
this.regen.updateHeadState(newHead, postState);
218218

219-
this.emitter.emit(routes.events.EventType.head, {
220-
block: newHead.blockRoot,
221-
epochTransition: computeStartSlotAtEpoch(computeEpochAtSlot(newHead.slot)) === newHead.slot,
222-
slot: newHead.slot,
223-
state: newHead.stateRoot,
224-
previousDutyDependentRoot: this.forkChoice.getDependentRoot(newHead, EpochDifference.previous),
225-
currentDutyDependentRoot: this.forkChoice.getDependentRoot(newHead, EpochDifference.current),
226-
executionOptimistic: isOptimisticBlock(newHead),
227-
});
219+
try {
220+
this.emitter.emit(routes.events.EventType.head, {
221+
block: newHead.blockRoot,
222+
epochTransition: computeStartSlotAtEpoch(computeEpochAtSlot(newHead.slot)) === newHead.slot,
223+
slot: newHead.slot,
224+
state: newHead.stateRoot,
225+
previousDutyDependentRoot: this.forkChoice.getDependentRoot(newHead, EpochDifference.previous),
226+
currentDutyDependentRoot: this.forkChoice.getDependentRoot(newHead, EpochDifference.current),
227+
executionOptimistic: isOptimisticBlock(newHead),
228+
});
229+
} catch (e) {
230+
// getDependentRoot() may fail with error: "No block for root" as we can see in holesky non-finality issue
231+
this.logger.debug("Error emitting head event", {slot: newHead.slot, root: newHead.blockRoot}, e as Error);
232+
}
228233

229234
const delaySec = this.clock.secFromSlot(newHead.slot);
230235
this.logger.verbose("New chain head", {

0 commit comments

Comments
 (0)