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: add warning log to notifier if execution client is offline #6919

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 2 additions & 4 deletions packages/beacon-node/src/execution/engine/disabled.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {ExecutionEngineState, IExecutionEngine, PayloadIdCache} from "./interface.js";

export class ExecutionEngineDisabled implements IExecutionEngine {
state = ExecutionEngineState.OFFLINE;

readonly payloadIdCache = new PayloadIdCache();

async notifyNewPayload(): Promise<never> {
Expand All @@ -26,8 +28,4 @@ export class ExecutionEngineDisabled implements IExecutionEngine {
getPayloadBodiesByRange(): Promise<never> {
throw Error("Execution engine disabled");
}

getState(): ExecutionEngineState {
throw Error("Execution engine disabled");
}
}
6 changes: 1 addition & 5 deletions packages/beacon-node/src/execution/engine/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class ExecutionEngineHttp implements IExecutionEngine {
// The default state is ONLINE, it will be updated to SYNCING once we receive the first payload
// This assumption is better than the OFFLINE state, since we can't be sure if the EL is offline and being offline may trigger some notifications
// It's safer to to avoid false positives and assume that the EL is syncing until we receive the first payload
private state: ExecutionEngineState = ExecutionEngineState.ONLINE;
state: ExecutionEngineState = ExecutionEngineState.ONLINE;

readonly payloadIdCache = new PayloadIdCache();
/**
Expand Down Expand Up @@ -417,10 +417,6 @@ export class ExecutionEngineHttp implements IExecutionEngine {
return response.map(deserializeExecutionPayloadBody);
}

getState(): ExecutionEngineState {
return this.state;
}

private updateEngineState(newState: ExecutionEngineState): void {
const oldState = this.state;

Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/src/execution/engine/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export type VersionedHashes = Uint8Array[];
* - Integrated code into the same binary
*/
export interface IExecutionEngine {
readonly state: ExecutionEngineState;

payloadIdCache: PayloadIdCache;
/**
* A state transition function which applies changes to the self.execution_state.
Expand Down Expand Up @@ -146,6 +148,4 @@ export interface IExecutionEngine {
getPayloadBodiesByHash(blockHash: DATA[]): Promise<(ExecutionPayloadBody | null)[]>;

getPayloadBodiesByRange(start: number, count: number): Promise<(ExecutionPayloadBody | null)[]>;

getState(): ExecutionEngineState;
}
11 changes: 10 additions & 1 deletion packages/beacon-node/src/node/notifier.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {BeaconConfig} from "@lodestar/config";
import {Epoch} from "@lodestar/types";
import {CachedBeaconStateAllForks} from "@lodestar/state-transition";
import {CachedBeaconStateAllForks, computeStartSlotAtEpoch} from "@lodestar/state-transition";
import {ProtoBlock, ExecutionStatus} from "@lodestar/fork-choice";
import {ErrorAborted, Logger, sleep, prettyBytes, prettyBytesShort} from "@lodestar/utils";
import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH} from "@lodestar/params";
import {computeEpochAtSlot, isExecutionCachedStateType, isMergeTransitionComplete} from "@lodestar/state-transition";
import {ExecutionEngineState} from "../execution/index.js";
import {IBeaconChain} from "../chain/index.js";
import {INetwork} from "../network/index.js";
import {IBeaconSync, SyncState} from "../sync/index.js";
Expand Down Expand Up @@ -53,6 +54,14 @@ export async function runNodeNotifier(modules: NodeNotifierModules): Promise<voi
const clockSlot = chain.clock.currentSlot;
const clockEpoch = computeEpochAtSlot(clockSlot);

if (
clockEpoch >= config.BELLATRIX_FORK_EPOCH &&
computeStartSlotAtEpoch(clockEpoch) === clockSlot &&
chain.executionEngine.state === ExecutionEngineState.OFFLINE
) {
logger.warn("Execution client is offline");
}

const headInfo = chain.forkChoice.getHead();
const headState = chain.getHeadState();
const finalizedEpoch = headState.finalizedCheckpoint.epoch;
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/sync/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class BeaconSync implements IBeaconSync {

getSyncStatus(): SyncingStatus {
const currentSlot = this.chain.clock.currentSlot;
const elOffline = this.chain.executionEngine.getState() === ExecutionEngineState.OFFLINE;
const elOffline = this.chain.executionEngine.state === ExecutionEngineState.OFFLINE;

// If we are pre/at genesis, signal ready
if (currentSlot <= GENESIS_SLOT) {
Expand Down
Loading