Skip to content

Commit

Permalink
feat: include reason in block production selection logs
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Jan 10, 2025
1 parent e6a0cb2 commit c8d462d
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -762,44 +762,50 @@ export function getValidatorApi(
}

if (builder.status === "fulfilled" && engine.status !== "fulfilled") {
const reason =
isEngineEnabled === false
? BuilderBlockSelectionReason.EngineDisabled
: engine.status === "pending"
? BuilderBlockSelectionReason.EnginePending
: BuilderBlockSelectionReason.EngineError;

logger.info("Selected builder block: no engine block produced", {
reason,
...loggerContext,
durationMs: builder.durationMs,
...getBlockValueLogInfo(builder.value),
});

metrics?.blockProductionSelectionResults.inc({
source: ProducedBlockSource.builder,
reason:
isEngineEnabled === false
? BuilderBlockSelectionReason.EngineDisabled
: engine.status === "pending"
? BuilderBlockSelectionReason.EnginePending
: BuilderBlockSelectionReason.EngineError,
reason,
});

return {...builder.value, executionPayloadBlinded: true, executionPayloadSource: ProducedBlockSource.builder};
}

if (engine.status === "fulfilled" && builder.status !== "fulfilled") {
const reason =
isBuilderEnabled === false
? EngineBlockSelectionReason.BuilderDisabled
: builder.status === "pending"
? EngineBlockSelectionReason.BuilderPending
: builder.reason instanceof NoBidReceived
? EngineBlockSelectionReason.BuilderNoBid
: builder.reason instanceof TimeoutError
? EngineBlockSelectionReason.BuilderTimeout
: EngineBlockSelectionReason.BuilderError;

logger.info("Selected engine block: no builder block produced", {
reason,
...loggerContext,
durationMs: engine.durationMs,
...getBlockValueLogInfo(engine.value),
});

metrics?.blockProductionSelectionResults.inc({
source: ProducedBlockSource.engine,
reason:
isBuilderEnabled === false
? EngineBlockSelectionReason.BuilderDisabled
: builder.status === "pending"
? EngineBlockSelectionReason.BuilderPending
: builder.reason instanceof NoBidReceived
? EngineBlockSelectionReason.BuilderNoBid
: builder.reason instanceof TimeoutError
? EngineBlockSelectionReason.BuilderTimeout
: EngineBlockSelectionReason.BuilderError,
reason,
});

return {...engine.value, executionPayloadBlinded: false, executionPayloadSource: ProducedBlockSource.engine};
Expand All @@ -817,6 +823,7 @@ export function getValidatorApi(
metrics?.blockProductionSelectionResults.inc(result);

logger.info(`Selected ${executionPayloadSource} block`, {
reason: result.reason,
...loggerContext,
engineDurationMs: engine.durationMs,
...getBlockValueLogInfo(engine.value, ProducedBlockSource.engine),
Expand Down

0 comments on commit c8d462d

Please sign in to comment.