Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include reason in block production selection logs #7350

Open
wants to merge 2 commits into
base: unstable
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ type ProduceFullOrBlindedBlockOrContentsRes = {executionPayloadSource: ProducedB
);

/**
* Engine block selection reasons tracked in metrics
* Engine block selection reasons tracked in metrics / logs
*/
export enum EngineBlockSelectionReason {
BuilderDisabled = "builder_disabled",
Expand All @@ -138,7 +138,7 @@ export enum EngineBlockSelectionReason {
}

/**
* Builder block selection reasons tracked in metrics
* Builder block selection reasons tracked in metrics / logs
*/
export enum BuilderBlockSelectionReason {
EngineDisabled = "engine_disabled",
Expand Down 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
Loading