Skip to content

Commit

Permalink
rename eip6110 to elctra
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Feb 15, 2024
1 parent d6d281e commit 661df6e
Show file tree
Hide file tree
Showing 56 changed files with 414 additions and 624 deletions.
6 changes: 3 additions & 3 deletions packages/beacon-node/src/chain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,11 +987,11 @@ export class BeaconChain implements IBeaconChain {
}
}

// TODO-6110: Deprecating eth1Data poll requires a check on a finalized checkpoint state.
// TODO-Electra: Deprecating eth1Data poll requires a check on a finalized checkpoint state.
// Will resolve this later
// if (cpEpoch >= (this.config.ELECTRA_FORK_EPOCH ?? Infinity)) {
// // finalizedState can be safely casted to 6110 state since cp is already post-6110
// if (finalizedState.eth1DepositIndex >= (finalizedState as CachedBeaconStateEIP6110).depositReceiptsStartIndex) {
// // finalizedState can be safely casted to Electra state since cp is already post-Electra
// if (finalizedState.eth1DepositIndex >= (finalizedState as CachedBeaconStateElectra).depositReceiptsStartIndex) {
// // Signal eth1 to stop polling eth1Data
// this.eth1.stopPollingEth1Data();
// }
Expand Down
12 changes: 6 additions & 6 deletions packages/beacon-node/src/eth1/eth1DepositDataTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {ChainForkConfig} from "@lodestar/config";
import {
BeaconStateAllForks,
CachedBeaconStateAllForks,
CachedBeaconStateEIP6110,
CachedBeaconStateElectra,
becomesNewEth1Data,
} from "@lodestar/state-transition";
import {ErrorAborted, TimeoutError, fromHex, Logger, isErrorAborted, sleep} from "@lodestar/utils";
Expand Down Expand Up @@ -88,7 +88,7 @@ export class Eth1DepositDataTracker {
this.depositsCache = new Eth1DepositsCache(opts, config, db);
this.eth1DataCache = new Eth1DataCache(config, db);
this.eth1FollowDistance = config.ETH1_FOLLOW_DISTANCE;
// TODO 6110: fix scenario where node starts post-6110 and `stopPolling` will always be false
// TODO Electra: fix scenario where node starts post-Electra and `stopPolling` will always be false
this.stopPolling = false;

this.forcedEth1DataVote = opts.forcedEth1DataVote
Expand Down Expand Up @@ -118,7 +118,7 @@ export class Eth1DepositDataTracker {
}
}

// TODO 6110: Figure out how an elegant way to stop eth1data polling
// TODO Electra: Figure out how an elegant way to stop eth1data polling
stopPollingEth1Data(): void {
this.stopPolling = true;
}
Expand All @@ -128,10 +128,10 @@ export class Eth1DepositDataTracker {
*/
async getEth1DataAndDeposits(state: CachedBeaconStateAllForks): Promise<Eth1DataAndDeposits> {
if (
state.epochCtx.isAfterEIP6110() &&
state.eth1DepositIndex >= (state as CachedBeaconStateEIP6110).depositReceiptsStartIndex
state.epochCtx.isAfterElectra() &&
state.eth1DepositIndex >= (state as CachedBeaconStateElectra).depositReceiptsStartIndex
) {
// No need to poll eth1Data since EIP6110 deprecates the mechanism after depositReceiptsStartIndex is reached
// No need to poll eth1Data since Electra deprecates the mechanism after depositReceiptsStartIndex is reached
return {eth1Data: state.eth1Data, deposits: []};
}
const eth1Data = this.forcedEth1DataVote ?? (await this.getEth1Data(state));
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/eth1/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export interface IEth1ForBlockProduction {
startPollingMergeBlock(): void;

/**
* Should stop polling eth1Data after a 6110 block is finalized AND deposit_receipts_start_index is reached
* Should stop polling eth1Data after a Electra block is finalized AND deposit_receipts_start_index is reached
*/
stopPollingEth1Data(): void;
}
Expand Down
10 changes: 5 additions & 5 deletions packages/beacon-node/src/execution/engine/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ export class ExecutionEngineHttp implements IExecutionEngine {
parentBlockRoot?: Root
): Promise<ExecutePayloadResponse> {
const method =
ForkSeq[fork] >= ForkSeq.eip6110
? "engine_newPayloadV6110"
ForkSeq[fork] >= ForkSeq.electra
? "engine_newPayloadV4"
: ForkSeq[fork] >= ForkSeq.deneb
? "engine_newPayloadV3"
: ForkSeq[fork] >= ForkSeq.capella
Expand All @@ -198,7 +198,7 @@ export class ExecutionEngineHttp implements IExecutionEngine {
const serializedVersionedHashes = serializeVersionedHashes(versionedHashes);
const parentBeaconBlockRoot = serializeBeaconBlockRoot(parentBlockRoot);

const method = ForkSeq[fork] >= ForkSeq.eip6110 ? "engine_newPayloadV6110" : "engine_newPayloadV3";
const method = ForkSeq[fork] >= ForkSeq.electra ? "engine_newPayloadV4" : "engine_newPayloadV3";
engineRequest = {
method,
params: [serializedExecutionPayload, serializedVersionedHashes, parentBeaconBlockRoot],
Expand Down Expand Up @@ -372,8 +372,8 @@ export class ExecutionEngineHttp implements IExecutionEngine {
shouldOverrideBuilder?: boolean;
}> {
const method =
ForkSeq[fork] >= ForkSeq.eip6110
? "engine_getPayloadV6110"
ForkSeq[fork] >= ForkSeq.electra
? "engine_getPayloadV4"
: ForkSeq[fork] >= ForkSeq.deneb
? "engine_getPayloadV3"
: ForkSeq[fork] >= ForkSeq.capella
Expand Down
8 changes: 4 additions & 4 deletions packages/beacon-node/src/execution/engine/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type ExecutionEngineMockOpts = {
onlyPredefinedResponses?: boolean;
capellaForkTimestamp?: number;
denebForkTimestamp?: number;
eip6110ForkTimestamp?: number;
electraForkTimestamp?: number;
};

type ExecutionBlock = {
Expand Down Expand Up @@ -89,14 +89,14 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
engine_newPayloadV1: this.notifyNewPayload.bind(this),
engine_newPayloadV2: this.notifyNewPayload.bind(this),
engine_newPayloadV3: this.notifyNewPayload.bind(this),
engine_newPayloadV6110: this.notifyNewPayload.bind(this),
engine_newPayloadV4: this.notifyNewPayload.bind(this),
engine_forkchoiceUpdatedV1: this.notifyForkchoiceUpdate.bind(this),
engine_forkchoiceUpdatedV2: this.notifyForkchoiceUpdate.bind(this),
engine_forkchoiceUpdatedV3: this.notifyForkchoiceUpdate.bind(this),
engine_getPayloadV1: this.getPayload.bind(this),
engine_getPayloadV2: this.getPayload.bind(this),
engine_getPayloadV3: this.getPayload.bind(this),
engine_getPayloadV6110: this.getPayload.bind(this),
engine_getPayloadV4: this.getPayload.bind(this),
engine_getPayloadBodiesByHashV1: this.getPayloadBodiesByHash.bind(this),
engine_getPayloadBodiesByRangeV1: this.getPayloadBodiesByRange.bind(this),
};
Expand Down Expand Up @@ -390,7 +390,7 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
}

private timestampToFork(timestamp: number): ForkExecution {
if (timestamp > (this.opts.eip6110ForkTimestamp ?? Infinity)) return ForkName.eip6110;
if (timestamp > (this.opts.electraForkTimestamp ?? Infinity)) return ForkName.electra;
if (timestamp > (this.opts.denebForkTimestamp ?? Infinity)) return ForkName.deneb;
if (timestamp > (this.opts.capellaForkTimestamp ?? Infinity)) return ForkName.capella;
return ForkName.bellatrix;
Expand Down
32 changes: 16 additions & 16 deletions packages/beacon-node/src/execution/engine/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {allForks, capella, deneb, Wei, bellatrix, Root, eip6110} from "@lodestar/types";
import {allForks, capella, deneb, Wei, bellatrix, Root, electra} from "@lodestar/types";
import {
BYTES_PER_LOGS_BLOOM,
FIELD_ELEMENTS_PER_BLOB,
Expand Down Expand Up @@ -28,7 +28,7 @@ export type EngineApiRpcParamTypes = {
engine_newPayloadV1: [ExecutionPayloadRpc];
engine_newPayloadV2: [ExecutionPayloadRpc];
engine_newPayloadV3: [ExecutionPayloadRpc, VersionedHashesRpc, DATA];
engine_newPayloadV6110: [ExecutionPayloadRpc, VersionedHashesRpc, DATA];
engine_newPayloadV4: [ExecutionPayloadRpc, VersionedHashesRpc, DATA];
/**
* 1. Object - Payload validity status with respect to the consensus rules:
* - blockHash: DATA, 32 Bytes - block hash value of the payload
Expand All @@ -52,7 +52,7 @@ export type EngineApiRpcParamTypes = {
engine_getPayloadV1: [QUANTITY];
engine_getPayloadV2: [QUANTITY];
engine_getPayloadV3: [QUANTITY];
engine_getPayloadV6110: [QUANTITY];
engine_getPayloadV4: [QUANTITY];

/**
* 1. Array of DATA - Array of block_hash field values of the ExecutionPayload structure
Expand Down Expand Up @@ -80,7 +80,7 @@ export type EngineApiRpcReturnTypes = {
engine_newPayloadV1: PayloadStatus;
engine_newPayloadV2: PayloadStatus;
engine_newPayloadV3: PayloadStatus;
engine_newPayloadV6110: PayloadStatus;
engine_newPayloadV4: PayloadStatus;
engine_forkchoiceUpdatedV1: {
payloadStatus: PayloadStatus;
payloadId: QUANTITY | null;
Expand All @@ -99,7 +99,7 @@ export type EngineApiRpcReturnTypes = {
engine_getPayloadV1: ExecutionPayloadRpc;
engine_getPayloadV2: ExecutionPayloadResponse;
engine_getPayloadV3: ExecutionPayloadResponse;
engine_getPayloadV6110: ExecutionPayloadResponse;
engine_getPayloadV4: ExecutionPayloadResponse;

engine_getPayloadBodiesByHashV1: (ExecutionPayloadBodyRpc | null)[];

Expand All @@ -124,7 +124,7 @@ export type ExecutionPayloadBodyRpc = {
export type ExecutionPayloadBody = {
transactions: bellatrix.Transaction[];
withdrawals: capella.Withdrawals | null;
depositReceipts: eip6110.DepositReceipts | null;
depositReceipts: electra.DepositReceipts | null;
};

export type ExecutionPayloadRpc = {
Expand All @@ -146,7 +146,7 @@ export type ExecutionPayloadRpc = {
blobGasUsed?: QUANTITY; // DENEB
excessBlobGas?: QUANTITY; // DENEB
parentBeaconBlockRoot?: QUANTITY; // DENEB
depositReceipts?: DepositReceiptRpc[]; // EIP6110
depositReceipts?: DepositReceiptRpc[]; // ELECTRA
};

export type WithdrawalRpc = {
Expand Down Expand Up @@ -215,9 +215,9 @@ export function serializeExecutionPayload(fork: ForkName, data: allForks.Executi
payload.excessBlobGas = numToQuantity(excessBlobGas);
}

// EIP6110 adds depositReceipts to the ExecutionPayload
if (ForkSeq[fork] >= ForkSeq.eip6110) {
const {depositReceipts} = data as eip6110.ExecutionPayload;
// ELECTRA adds depositReceipts to the ExecutionPayload
if (ForkSeq[fork] >= ForkSeq.electra) {
const {depositReceipts} = data as electra.ExecutionPayload;
payload.depositReceipts = depositReceipts.map(serializeDepositReceipt);
}

Expand Down Expand Up @@ -306,15 +306,15 @@ export function parseExecutionPayload(
(executionPayload as deneb.ExecutionPayload).excessBlobGas = quantityToBigint(excessBlobGas);
}

if (ForkSeq[fork] >= ForkSeq.eip6110) {
if (ForkSeq[fork] >= ForkSeq.electra) {
const {depositReceipts} = data;
// Geth can also reply with null
if (depositReceipts == null) {
throw Error(
`depositReceipts missing for ${fork} >= eip6110 executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}`
`depositReceipts missing for ${fork} >= electra executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}`
);
}
(executionPayload as eip6110.ExecutionPayload).depositReceipts = depositReceipts.map(deserializeDepositReceipts);
(executionPayload as electra.ExecutionPayload).depositReceipts = depositReceipts.map(deserializeDepositReceipts);
}

return {executionPayload, executionPayloadValue, blobsBundle, shouldOverrideBuilder};
Expand Down Expand Up @@ -383,7 +383,7 @@ export function deserializeWithdrawal(serialized: WithdrawalRpc): capella.Withdr
} as capella.Withdrawal;
}

export function serializeDepositReceipt(depositReceipt: eip6110.DepositReceipt): DepositReceiptRpc {
export function serializeDepositReceipt(depositReceipt: electra.DepositReceipt): DepositReceiptRpc {
return {
pubkey: bytesToData(depositReceipt.pubkey),
withdrawalCredentials: bytesToData(depositReceipt.withdrawalCredentials),
Expand All @@ -393,14 +393,14 @@ export function serializeDepositReceipt(depositReceipt: eip6110.DepositReceipt):
};
}

export function deserializeDepositReceipts(serialized: DepositReceiptRpc): eip6110.DepositReceipt {
export function deserializeDepositReceipts(serialized: DepositReceiptRpc): electra.DepositReceipt {
return {
pubkey: dataToBytes(serialized.pubkey, 48),
withdrawalCredentials: dataToBytes(serialized.withdrawalCredentials, 32),
amount: quantityToNum(serialized.amount),
signature: dataToBytes(serialized.signature, 96),
index: quantityToNum(serialized.index),
} as eip6110.DepositReceipt;
} as electra.DepositReceipt;
}

export function deserializeExecutionPayloadBody(data: ExecutionPayloadBodyRpc | null): ExecutionPayloadBody | null {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe(`getAttestationsForBlock vc=${vc}`, () => {
before(function () {
this.timeout(5 * 60 * 1000); // Generating the states for the first time is very slow

originalState = generatePerfTestCachedStateAltair({goBackOneSlot: true, vc});
originalState = generatePerfTestCachedStateAltair({goBackOneSlot: true, vc}) as unknown as CachedBeaconStateAltair;

const {blockHeader, checkpoint} = computeAnchorCheckpoint(originalState.config, originalState);
// TODO figure out why getBlockRootAtSlot(originalState, justifiedSlot) is not the same to justifiedCheckpoint.root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("opPool", () => {
before(function () {
this.timeout(2 * 60 * 1000); // Generating the states for the first time is very slow

originalState = generatePerfTestCachedStateAltair({goBackOneSlot: true});
originalState = generatePerfTestCachedStateAltair({goBackOneSlot: true}) as unknown as CachedBeaconStateAltair;
});

itBench({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("produceBlockBody", () => {

before(async () => {
db = new BeaconDb(config, await LevelDbController.create({name: ".tmpdb"}, {logger}));
state = stateOg.clone();
state = stateOg.clone() as unknown as CachedBeaconStateAltair;
chain = new BeaconChain(
{
proposerBoostEnabled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {ssz} from "@lodestar/types";
import {type CachedBeaconStateAllForks, PubkeyIndexMap} from "@lodestar/state-transition";
import {bytesToBigInt, intToBytes} from "@lodestar/utils";
import {CheckpointStateCache, StateContextCache} from "../../../../src/chain/stateCache/index.js";
import {generateCached6110State} from "../../../utils/state.js";
import {generateCachedElectraState} from "../../../utils/state.js";

// Benchmark date from Mon Nov 21 2023 - Intel Core i7-9750H @ 2.60Ghz
// ✔ updateUnfinalizedPubkeys - updating 10 pubkeys 1444.173 ops/s 692.4380 us/op - 1057 runs 6.03 s
Expand All @@ -25,7 +25,7 @@ describe("updateUnfinalizedPubkeys perf tests", function () {
let stateCache: StateContextCache;

const unfinalizedPubkey2Index = generatePubkey2Index(0, Math.max.apply(null, numPubkeysToBeFinalizedCases));
const baseState = generateCached6110State();
const baseState = generateCachedElectraState();

for (const numPubkeysToBeFinalized of numPubkeysToBeFinalizedCases) {
itBench({
Expand Down
Loading

0 comments on commit 661df6e

Please sign in to comment.