Skip to content

Commit

Permalink
feat: deprecate engine_exchangeTransitionConfigurationV1 (#5724)
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech authored Jul 1, 2023
1 parent a20ec34 commit 0f0f533
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 234 deletions.
118 changes: 0 additions & 118 deletions dashboards/lodestar_execution_engine.json
Original file line number Diff line number Diff line change
Expand Up @@ -1792,124 +1792,6 @@
"title": "forkchoiceUpdatedV2",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "µs"
},
"overrides": [
{
"__systemRef": "hideSeriesFrom",
"matcher": {
"id": "byNames",
"options": {
"mode": "exclude",
"names": [
"0.9999"
],
"prefix": "All except:",
"readOnly": true
}
},
"properties": [
{
"id": "custom.hideFrom",
"value": {
"legend": false,
"tooltip": false,
"viz": true
}
}
]
}
]
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 59
},
"id": 487,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"expr": "rpc_duration_engine_exchangeTransitionConfigurationV1_success",
"legendFormat": "{{quantile}}",
"range": true,
"refId": "A"
}
],
"title": "exchangeTransitionConfigurationV1",
"type": "timeseries"
},
{
"collapsed": false,
"datasource": {
Expand Down
65 changes: 1 addition & 64 deletions packages/beacon-node/src/chain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
import {GENESIS_EPOCH, ZERO_HASH} from "../constants/index.js";
import {IBeaconDb} from "../db/index.js";
import {Metrics} from "../metrics/index.js";
import {bytesToData, numToQuantity} from "../eth1/provider/utils.js";
import {wrapError} from "../util/wrapError.js";
import {IEth1ForBlockProduction} from "../eth1/index.js";
import {IExecutionEngine, IExecutionBuilder, TransitionConfigurationV1} from "../execution/index.js";
import {IExecutionEngine, IExecutionBuilder} from "../execution/index.js";
import {Clock, ClockEvent, IClock} from "../util/clock.js";
import {ensureDir, writeIfNotExist} from "../util/file.js";
import {isOptimisticBlock} from "../util/forkChoice.js";
Expand Down Expand Up @@ -143,9 +141,6 @@ export class BeaconChain implements IBeaconChain {
protected readonly db: IBeaconDb;
private readonly archiver: Archiver;
private abortController = new AbortController();
private successfulExchangeTransition = false;
private readonly exchangeTransitionConfigurationEverySlots: number;

private processShutdownCallback: ProcessShutdownCallback;

constructor(
Expand Down Expand Up @@ -187,11 +182,6 @@ export class BeaconChain implements IBeaconChain {
this.eth1 = eth1;
this.executionEngine = executionEngine;
this.executionBuilder = executionBuilder;
// From https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md#specification-3
// > Consensus Layer client software SHOULD poll this endpoint every 60 seconds.
// Align to a multiple of SECONDS_PER_SLOT for nicer logs
this.exchangeTransitionConfigurationEverySlots = Math.floor(60 / this.config.SECONDS_PER_SLOT);

const signal = this.abortController.signal;
const emitter = new ChainEventEmitter();
// by default, verify signatures on both main threads and worker threads
Expand Down Expand Up @@ -778,13 +768,6 @@ export class BeaconChain implements IBeaconChain {
this.seenAttestationDatas.onSlot(slot);
this.reprocessController.onSlot(slot);

if (isFinite(this.config.BELLATRIX_FORK_EPOCH) && slot % this.exchangeTransitionConfigurationEverySlots === 0) {
this.exchangeTransitionConfiguration().catch((e) => {
// Should never throw
this.logger.error("Error on exchangeTransitionConfiguration", {}, e as Error);
});
}

// Prune old blobSidecars for block production, those are only useful on their slot
if (this.config.getForkSeq(slot) >= ForkSeq.deneb) {
if (this.producedBlobSidecarsCache.size > 0) {
Expand Down Expand Up @@ -857,52 +840,6 @@ export class BeaconChain implements IBeaconChain {
}
}

/**
* perform heart beat for EL lest it logs warning that CL is not connected
*/
private async exchangeTransitionConfiguration(): Promise<void> {
const clConfig: TransitionConfigurationV1 = {
terminalTotalDifficulty: numToQuantity(this.config.TERMINAL_TOTAL_DIFFICULTY),
terminalBlockHash: bytesToData(this.config.TERMINAL_BLOCK_HASH),
/** terminalBlockNumber has to be set to zero for now as per specs */
terminalBlockNumber: numToQuantity(0),
};

const elConfigRes = await wrapError(this.executionEngine.exchangeTransitionConfigurationV1(clConfig));

if (elConfigRes.err) {
// Note: Will throw an error if:
// - EL endpoint is offline, unreachable, port not exposed, etc
// - JWT secret is not properly configured
// - If there is a missmatch in configuration with Geth, see https://github.com/ethereum/go-ethereum/blob/0016eb7eeeb42568c8c20d0cb560ddfc9a938fad/eth/catalyst/api.go#L301
this.successfulExchangeTransition = false;

this.logger.warn("Could not validate transition configuration with execution client", {}, elConfigRes.err);
} else {
// Note: This code is useless when connected to Geth. If there's a configuration mismatch Geth returns an
// error instead of its own transition configuration, so we can't do this comparision.
const elConfig = elConfigRes.result;
const keysToCheck: (keyof TransitionConfigurationV1)[] = ["terminalTotalDifficulty", "terminalBlockHash"];
const errors: string[] = [];

for (const key of keysToCheck) {
if (elConfig[key] !== clConfig[key]) {
errors.push(`different ${key} (cl ${clConfig[key]} el ${elConfig[key]})`);
}
}

if (errors.length > 0) {
this.logger.warn(`Transition configuration mismatch: ${errors.join(", ")}`);
} else {
// Only log once per successful call
if (!this.successfulExchangeTransition) {
this.logger.info("Validated transition configuration with execution client", clConfig);
this.successfulExchangeTransition = true;
}
}
}
}

async updateBeaconProposerData(epoch: Epoch, proposers: ProposerPreparationData[]): Promise<void> {
proposers.forEach((proposer) => {
this.beaconProposerCache.add(epoch, proposer);
Expand Down
4 changes: 0 additions & 4 deletions packages/beacon-node/src/execution/engine/disabled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ export class ExecutionEngineDisabled implements IExecutionEngine {
throw Error("Execution engine disabled");
}

async exchangeTransitionConfigurationV1(): Promise<never> {
throw Error("Execution engine disabled");
}

getPayloadBodiesByHash(): Promise<never> {
throw Error("Execution engine disabled");
}
Expand Down
21 changes: 0 additions & 21 deletions packages/beacon-node/src/execution/engine/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
IExecutionEngine,
PayloadId,
PayloadAttributes,
TransitionConfigurationV1,
BlobsBundle,
VersionedHashes,
} from "./interface.js";
Expand Down Expand Up @@ -72,7 +71,6 @@ const QUEUE_MAX_LENGTH = EPOCHS_PER_BATCH * SLOTS_PER_EPOCH * 2;
const notifyNewPayloadOpts: ReqOpts = {routeId: "notifyNewPayload"};
const forkchoiceUpdatedV1Opts: ReqOpts = {routeId: "forkchoiceUpdated"};
const getPayloadOpts: ReqOpts = {routeId: "getPayload"};
const exchageTransitionConfigOpts: ReqOpts = {routeId: "exchangeTransitionConfiguration"};

/**
* based on Ethereum JSON-RPC API and inherits the following properties of this standard:
Expand Down Expand Up @@ -345,25 +343,6 @@ export class ExecutionEngineHttp implements IExecutionEngine {
return parseExecutionPayload(fork, payloadResponse);
}

/**
* `engine_exchangeTransitionConfigurationV1`
*
* An api method for EL<>CL transition config matching and heartbeat
*/

async exchangeTransitionConfigurationV1(
transitionConfiguration: TransitionConfigurationV1
): Promise<TransitionConfigurationV1> {
const method = "engine_exchangeTransitionConfigurationV1";
return this.rpc.fetchWithRetries<EngineApiRpcReturnTypes[typeof method], EngineApiRpcParamTypes[typeof method]>(
{
method,
params: [transitionConfiguration],
},
exchageTransitionConfigOpts
);
}

async prunePayloadIdCache(): Promise<void> {
this.payloadIdCache.prune();
}
Expand Down
4 changes: 0 additions & 4 deletions packages/beacon-node/src/execution/engine/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ export interface IExecutionEngine {
payloadId: PayloadId
): Promise<{executionPayload: allForks.ExecutionPayload; blockValue: Wei; blobsBundle?: BlobsBundle}>;

exchangeTransitionConfigurationV1(
transitionConfiguration: TransitionConfigurationV1
): Promise<TransitionConfigurationV1>;

getPayloadBodiesByHash(blockHash: DATA[]): Promise<(ExecutionPayloadBody | null)[]>;

getPayloadBodiesByRange(start: number, count: number): Promise<(ExecutionPayloadBody | null)[]>;
Expand Down
8 changes: 0 additions & 8 deletions packages/beacon-node/src/execution/engine/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
engine_getPayloadV1: this.getPayload.bind(this),
engine_getPayloadV2: this.getPayload.bind(this),
engine_getPayloadV3: this.getPayload.bind(this),
engine_exchangeTransitionConfigurationV1: this.exchangeTransitionConfigurationV1.bind(this),
engine_getPayloadBodiesByHashV1: this.getPayloadBodiesByHash.bind(this),
engine_getPayloadBodiesByRangeV1: this.getPayloadBodiesByRange.bind(this),
};
Expand Down Expand Up @@ -388,13 +387,6 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
return payload.executionPayload;
}

private exchangeTransitionConfigurationV1(
transitionConfiguration: EngineApiRpcParamTypes["engine_exchangeTransitionConfigurationV1"][0]
): EngineApiRpcReturnTypes["engine_exchangeTransitionConfigurationV1"] {
// echo same configuration from consensus, which will be considered valid
return transitionConfiguration;
}

private timestampToFork(timestamp: number): ForkExecution {
if (timestamp > (this.opts.denebForkTimestamp ?? Infinity)) return ForkName.deneb;
if (timestamp > (this.opts.capellaForkTimestamp ?? Infinity)) return ForkName.capella;
Expand Down
16 changes: 1 addition & 15 deletions packages/beacon-node/src/execution/engine/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ import {
QUANTITY,
quantityToBigint,
} from "../../eth1/provider/utils.js";
import {
ExecutePayloadStatus,
TransitionConfigurationV1,
BlobsBundle,
PayloadAttributes,
VersionedHashes,
} from "./interface.js";
import {ExecutePayloadStatus, BlobsBundle, PayloadAttributes, VersionedHashes} from "./interface.js";
import {WithdrawalV1} from "./payloadIdCache.js";

/* eslint-disable @typescript-eslint/naming-convention */
Expand Down Expand Up @@ -53,10 +47,6 @@ export type EngineApiRpcParamTypes = {
engine_getPayloadV1: [QUANTITY];
engine_getPayloadV2: [QUANTITY];
engine_getPayloadV3: [QUANTITY];
/**
* 1. Object - Instance of TransitionConfigurationV1
*/
engine_exchangeTransitionConfigurationV1: [TransitionConfigurationV1];

/**
* 1. Array of DATA - Array of block_hash field values of the ExecutionPayload structure
Expand Down Expand Up @@ -98,10 +88,6 @@ export type EngineApiRpcReturnTypes = {
engine_getPayloadV1: ExecutionPayloadRpc;
engine_getPayloadV2: ExecutionPayloadResponse;
engine_getPayloadV3: ExecutionPayloadResponse;
/**
* Object - Instance of TransitionConfigurationV1
*/
engine_exchangeTransitionConfigurationV1: TransitionConfigurationV1;

engine_getPayloadBodiesByHashV1: (ExecutionPayloadBodyRpc | null)[];

Expand Down

0 comments on commit 0f0f533

Please sign in to comment.