Skip to content

Commit

Permalink
Merge 1f8f8c5 into f69bc11
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Jun 29, 2024
2 parents f69bc11 + 1f8f8c5 commit e81e67b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
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

0 comments on commit e81e67b

Please sign in to comment.