From 1cc9cbd6a96ab97ce6ec068dd2f035b7c77f017a Mon Sep 17 00:00:00 2001 From: NC Date: Wed, 8 May 2024 18:12:36 +0300 Subject: [PATCH] feat: rename deposit receipt to deposit request for Pectra (#6748) * Rename receipt to request * Remove stats.html --- packages/beacon-node/src/chain/chain.ts | 2 +- .../src/eth1/eth1DepositDataTracker.ts | 4 +- .../src/execution/engine/interface.ts | 4 +- .../src/execution/engine/payloadIdCache.ts | 2 +- .../beacon-node/src/execution/engine/types.ts | 40 +++++++++---------- .../test/sim/electra-interop.test.ts | 28 ++++++------- .../test/spec/presets/operations.test.ts | 6 +-- .../test/unit/executionEngine/http.test.ts | 8 ++-- packages/beacon-node/test/utils/state.ts | 2 +- packages/light-client/src/spec/utils.ts | 8 ++-- .../src/block/processDeposit.ts | 6 +-- ...sitReceipt.ts => processDepositRequest.ts} | 10 ++--- .../src/block/processOperations.ts | 8 ++-- .../src/slot/upgradeStateToElectra.ts | 6 +-- packages/state-transition/src/util/deposit.ts | 4 +- .../state-transition/src/util/execution.ts | 4 +- packages/state-transition/src/util/genesis.ts | 2 +- .../test/unit/util/deposit.test.ts | 4 +- packages/types/src/electra/sszTypes.ts | 12 +++--- packages/types/src/electra/types.ts | 4 +- 20 files changed, 82 insertions(+), 82 deletions(-) rename packages/state-transition/src/block/{processDepositReceipt.ts => processDepositRequest.ts} (55%) diff --git a/packages/beacon-node/src/chain/chain.ts b/packages/beacon-node/src/chain/chain.ts index 475dd7e54b2..ff9e724ade9 100644 --- a/packages/beacon-node/src/chain/chain.ts +++ b/packages/beacon-node/src/chain/chain.ts @@ -1097,7 +1097,7 @@ export class BeaconChain implements IBeaconChain { // Will resolve this later // if (cpEpoch >= (this.config.ELECTRA_FORK_EPOCH ?? Infinity)) { // // finalizedState can be safely casted to Electra state since cp is already post-Electra - // if (finalizedState.eth1DepositIndex >= (finalizedState as CachedBeaconStateElectra).depositReceiptsStartIndex) { + // if (finalizedState.eth1DepositIndex >= (finalizedState as CachedBeaconStateElectra).depositRequestsStartIndex) { // // Signal eth1 to stop polling eth1Data // this.eth1.stopPollingEth1Data(); // } diff --git a/packages/beacon-node/src/eth1/eth1DepositDataTracker.ts b/packages/beacon-node/src/eth1/eth1DepositDataTracker.ts index c0b3ab35a73..d0578718f29 100644 --- a/packages/beacon-node/src/eth1/eth1DepositDataTracker.ts +++ b/packages/beacon-node/src/eth1/eth1DepositDataTracker.ts @@ -129,9 +129,9 @@ export class Eth1DepositDataTracker { async getEth1DataAndDeposits(state: CachedBeaconStateAllForks): Promise { if ( state.epochCtx.isAfterElectra() && - state.eth1DepositIndex >= (state as CachedBeaconStateElectra).depositReceiptsStartIndex + state.eth1DepositIndex >= (state as CachedBeaconStateElectra).depositRequestsStartIndex ) { - // No need to poll eth1Data since Electra deprecates the mechanism after depositReceiptsStartIndex is reached + // No need to poll eth1Data since Electra deprecates the mechanism after depositRequestsStartIndex is reached return {eth1Data: state.eth1Data, deposits: []}; } const eth1Data = this.forcedEth1DataVote ?? (await this.getEth1Data(state)); diff --git a/packages/beacon-node/src/execution/engine/interface.ts b/packages/beacon-node/src/execution/engine/interface.ts index 4328edc399c..cb8593617e4 100644 --- a/packages/beacon-node/src/execution/engine/interface.ts +++ b/packages/beacon-node/src/execution/engine/interface.ts @@ -3,10 +3,10 @@ import {KZGCommitment, Blob, KZGProof} from "@lodestar/types/deneb"; import {Root, RootHex, capella, Wei, ExecutionPayload} from "@lodestar/types"; import {DATA} from "../../eth1/provider/utils.js"; -import {PayloadIdCache, PayloadId, WithdrawalV1, DepositReceiptV1} from "./payloadIdCache.js"; +import {PayloadIdCache, PayloadId, WithdrawalV1, DepositRequestV1} from "./payloadIdCache.js"; import {ExecutionPayloadBody} from "./types.js"; -export {PayloadIdCache, type PayloadId, type WithdrawalV1, type DepositReceiptV1}; +export {PayloadIdCache, type PayloadId, type WithdrawalV1, type DepositRequestV1}; export enum ExecutionPayloadStatus { /** given payload is valid */ diff --git a/packages/beacon-node/src/execution/engine/payloadIdCache.ts b/packages/beacon-node/src/execution/engine/payloadIdCache.ts index b5fe3d33e26..f79c2858245 100644 --- a/packages/beacon-node/src/execution/engine/payloadIdCache.ts +++ b/packages/beacon-node/src/execution/engine/payloadIdCache.ts @@ -18,7 +18,7 @@ export type WithdrawalV1 = { amount: QUANTITY; }; -export type DepositReceiptV1 = { +export type DepositRequestV1 = { pubkey: DATA; withdrawalCredentials: DATA; amount: QUANTITY; diff --git a/packages/beacon-node/src/execution/engine/types.ts b/packages/beacon-node/src/execution/engine/types.ts index 79e0a8e810a..5c40e7e7895 100644 --- a/packages/beacon-node/src/execution/engine/types.ts +++ b/packages/beacon-node/src/execution/engine/types.ts @@ -17,7 +17,7 @@ import { quantityToBigint, } from "../../eth1/provider/utils.js"; import {ExecutionPayloadStatus, BlobsBundle, PayloadAttributes, VersionedHashes} from "./interface.js"; -import {WithdrawalV1, DepositReceiptV1, ExecutionLayerWithdrawalRequestV1} from "./payloadIdCache.js"; +import {WithdrawalV1, DepositRequestV1, ExecutionLayerWithdrawalRequestV1} from "./payloadIdCache.js"; /* eslint-disable @typescript-eslint/naming-convention */ @@ -120,14 +120,14 @@ export type ExecutionPayloadBodyRpc = { withdrawals: WithdrawalV1[] | null | undefined; // currently there is a discepancy between EL and CL field name references for deposit requests // its likely CL receipt will be renamed to requests - depositRequests: DepositReceiptV1[] | null | undefined; + depositRequests: DepositRequestV1[] | null | undefined; withdrawalRequests: ExecutionLayerWithdrawalRequestV1[] | null | undefined; }; export type ExecutionPayloadBody = { transactions: bellatrix.Transaction[]; withdrawals: capella.Withdrawals | null; - depositReceipts: electra.DepositReceipts | null; + depositRequests: electra.DepositRequests | null; withdrawalRequests: electra.ExecutionLayerWithdrawalRequests | null; }; @@ -150,7 +150,7 @@ export type ExecutionPayloadRpc = { blobGasUsed?: QUANTITY; // DENEB excessBlobGas?: QUANTITY; // DENEB parentBeaconBlockRoot?: QUANTITY; // DENEB - depositRequests?: DepositReceiptRpc[]; // ELECTRA + depositRequests?: DepositRequestRpc[]; // ELECTRA withdrawalRequests?: ExecutionLayerWithdrawalRequestRpc[]; // ELECTRA }; @@ -161,7 +161,7 @@ export type WithdrawalRpc = { amount: QUANTITY; }; -export type DepositReceiptRpc = DepositReceiptV1; +export type DepositRequestRpc = DepositRequestV1; export type ExecutionLayerWithdrawalRequestRpc = ExecutionLayerWithdrawalRequestV1; export type VersionedHashesRpc = DATA[]; @@ -215,10 +215,10 @@ export function serializeExecutionPayload(fork: ForkName, data: ExecutionPayload payload.excessBlobGas = numToQuantity(excessBlobGas); } - // ELECTRA adds depositReceipts/depositRequests to the ExecutionPayload + // ELECTRA adds depositRequests/depositRequests to the ExecutionPayload if (ForkSeq[fork] >= ForkSeq.electra) { - const {depositReceipts, withdrawalRequests} = data as electra.ExecutionPayload; - payload.depositRequests = depositReceipts.map(serializeDepositReceipt); + const {depositRequests, withdrawalRequests} = data as electra.ExecutionPayload; + payload.depositRequests = depositRequests.map(serializeDepositRequest); payload.withdrawalRequests = withdrawalRequests.map(serializeExecutionLayerWithdrawalRequest); } @@ -308,7 +308,7 @@ export function parseExecutionPayload( } if (ForkSeq[fork] >= ForkSeq.electra) { - // electra adds depositRequests/depositReceipts + // electra adds depositRequests/depositRequests const {depositRequests, withdrawalRequests} = data; // Geth can also reply with null if (depositRequests == null) { @@ -316,7 +316,7 @@ export function parseExecutionPayload( `depositRequests missing for ${fork} >= electra executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}` ); } - (executionPayload as electra.ExecutionPayload).depositReceipts = depositRequests.map(deserializeDepositReceipt); + (executionPayload as electra.ExecutionPayload).depositRequests = depositRequests.map(deserializeDepositRequest); if (withdrawalRequests == null) { throw Error( @@ -394,24 +394,24 @@ export function deserializeWithdrawal(serialized: WithdrawalRpc): capella.Withdr } as capella.Withdrawal; } -export function serializeDepositReceipt(depositReceipt: electra.DepositReceipt): DepositReceiptRpc { +export function serializeDepositRequest(depositRequest: electra.DepositRequest): DepositRequestRpc { return { - pubkey: bytesToData(depositReceipt.pubkey), - withdrawalCredentials: bytesToData(depositReceipt.withdrawalCredentials), - amount: numToQuantity(depositReceipt.amount), - signature: bytesToData(depositReceipt.signature), - index: numToQuantity(depositReceipt.index), + pubkey: bytesToData(depositRequest.pubkey), + withdrawalCredentials: bytesToData(depositRequest.withdrawalCredentials), + amount: numToQuantity(depositRequest.amount), + signature: bytesToData(depositRequest.signature), + index: numToQuantity(depositRequest.index), }; } -export function deserializeDepositReceipt(serialized: DepositReceiptRpc): electra.DepositReceipt { +export function deserializeDepositRequest(serialized: DepositRequestRpc): electra.DepositRequest { 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 electra.DepositReceipt; + } as electra.DepositRequest; } export function serializeExecutionLayerWithdrawalRequest( @@ -439,7 +439,7 @@ export function deserializeExecutionPayloadBody(data: ExecutionPayloadBodyRpc | ? { transactions: data.transactions.map((tran) => dataToBytes(tran, null)), withdrawals: data.withdrawals ? data.withdrawals.map(deserializeWithdrawal) : null, - depositReceipts: data.depositRequests ? data.depositRequests.map(deserializeDepositReceipt) : null, + depositRequests: data.depositRequests ? data.depositRequests.map(deserializeDepositRequest) : null, withdrawalRequests: data.withdrawalRequests ? data.withdrawalRequests.map(deserializeExecutionLayerWithdrawalRequest) : null, @@ -452,7 +452,7 @@ export function serializeExecutionPayloadBody(data: ExecutionPayloadBody | null) ? { transactions: data.transactions.map((tran) => bytesToData(tran)), withdrawals: data.withdrawals ? data.withdrawals.map(serializeWithdrawal) : null, - depositRequests: data.depositReceipts ? data.depositReceipts.map(serializeDepositReceipt) : null, + depositRequests: data.depositRequests ? data.depositRequests.map(serializeDepositRequest) : null, withdrawalRequests: data.withdrawalRequests ? data.withdrawalRequests.map(serializeExecutionLayerWithdrawalRequest) : null, diff --git a/packages/beacon-node/test/sim/electra-interop.test.ts b/packages/beacon-node/test/sim/electra-interop.test.ts index 29483b249c8..c503052a74f 100644 --- a/packages/beacon-node/test/sim/electra-interop.test.ts +++ b/packages/beacon-node/test/sim/electra-interop.test.ts @@ -72,7 +72,7 @@ describe("executionEngine / ExecutionEngineHttp", function () { } }); - it("Send and get payloads with depositReceipts to/from EL", async () => { + it("Send and get payloads with depositRequests to/from EL", async () => { const {elClient, tearDownCallBack} = await runEL( {...elSetupConfig, mode: ELStartMode.PostMerge, genesisTemplate: "electra.tmpl"}, {...elRunOptions, ttd: BigInt(0)}, @@ -111,7 +111,7 @@ describe("executionEngine / ExecutionEngineHttp", function () { // 2. Send raw deposit transaction A and B. tx A is to be imported via newPayload, tx B is to be included in payload via getPayload const depositTransactionA = "0x02f9021c8217de808459682f008459682f0e830271009442424242424242424242424242424242424242428901bc16d674ec800000b901a422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120749715de5d1226545c6b3790f515d551a5cc5bf1d49c87a696860554d2fc4f14000000000000000000000000000000000000000000000000000000000000003096a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef20000000000000000000000000000000000000000000000000000000000000060b1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9c080a09f597089338d7f44f5c59f8230bb38f243849228a8d4e9d2e2956e6050f5b2c7a076486996c7e62802b8f95eee114783e4b403fd11093ba96286ff42c595f24452"; - const depositReceiptA = { + const depositRequestA = { amount: 32000000000, index: 0, pubkey: dataToBytes( @@ -127,7 +127,7 @@ describe("executionEngine / ExecutionEngineHttp", function () { const depositTransactionB = "0x02f9021c8217de018459682f008459682f0e830271009442424242424242424242424242424242424242428901bc16d674ec800000b901a422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120a18b4c7cab0afa273ea9504904521ea8421a4e32740b7611bd3d5095ca99f0cb0000000000000000000000000000000000000000000000000000000000000030a5c85a60ba2905c215f6a12872e62b1ee037051364244043a5f639aa81b04a204c55e7cc851f29c7c183be253ea1510b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020001db70c485b6264692f26b8aeaab5b0c384180df8e2184a21a808a3ec8e86ca00000000000000000000000000000000000000000000000000000000000000609561731785b48cf1886412234531e4940064584463e96ac63a1a154320227e333fb51addc4a89b7e0d3f862d7c1fd4ea03bd8eb3d8806f1e7daf591cbbbb92b0beb74d13c01617f22c5026b4f9f9f294a8a7c32db895de3b01bee0132c9209e1c001a0644e0a763a34b4bfb9f56a677857b57fcf15e3db57e2f57060e92084f75f3d82a018ba8eaacbd8e6f6917675b1d0362b12ca82850ca8ef9c010430760c2b2e0cb5"; - const depositReceiptB = { + const depositRequestB = { amount: 32000000000, index: 1, pubkey: dataToBytes( @@ -168,7 +168,7 @@ describe("executionEngine / ExecutionEngineHttp", function () { excessBlobGas: 0n, transactions: [dataToBytes(depositTransactionA, null)], withdrawals: [], - depositReceipts: [depositReceiptA], + depositRequests: [depositRequestA], blockNumber: 1, blockHash: dataToBytes(newPayloadBlockHash, 32), receiptsRoot: dataToBytes("0x79ee3424eb720a3ad4b1c5a372bb8160580cbe4d893778660f34213c685627a9", 32), @@ -205,7 +205,7 @@ describe("executionEngine / ExecutionEngineHttp", function () { ); if (!payloadId2) throw Error("InvalidPayloadId"); - // 5. Get the payload. Check depositReceipts field contains deposit + // 5. Get the payload. Check depositRequests field contains deposit // Wait a bit first for besu to pick up tx from the tx pool. await sleep(1000); const payloadAndBlockValue = await executionEngine.getPayload(ForkName.electra, payloadId2); @@ -221,16 +221,16 @@ describe("executionEngine / ExecutionEngineHttp", function () { } } - if (payload.depositReceipts.length !== 1) { - throw Error(`Number of depositReceipts mismatched. Expected: 1, actual: ${payload.depositReceipts.length}`); + if (payload.depositRequests.length !== 1) { + throw Error(`Number of depositRequests mismatched. Expected: 1, actual: ${payload.depositRequests.length}`); } - const actualDepositReceipt = payload.depositReceipts[0]; + const actualDepositRequest = payload.depositRequests[0]; assert.deepStrictEqual( - actualDepositReceipt, - depositReceiptB, - `Deposit receipts mismatched. Expected: ${JSON.stringify(depositReceiptB)}, actual: ${JSON.stringify( - actualDepositReceipt + actualDepositRequest, + depositRequestB, + `Deposit receipts mismatched. Expected: ${JSON.stringify(depositRequestB)}, actual: ${JSON.stringify( + actualDepositRequest )}` ); }); @@ -432,8 +432,8 @@ describe("executionEngine / ExecutionEngineHttp", function () { throw Error("Historical validator length for epoch 1 or 2 is not dropped properly"); } - if (headState.depositReceiptsStartIndex === UNSET_DEPOSIT_RECEIPTS_START_INDEX) { - throw Error("state.depositReceiptsStartIndex is not set upon processing new deposit receipt"); + if (headState.depositRequestsStartIndex === UNSET_DEPOSIT_RECEIPTS_START_INDEX) { + throw Error("state.depositRequestsStartIndex is not set upon processing new deposit receipt"); } // wait for 1 slot to print current epoch stats diff --git a/packages/beacon-node/test/spec/presets/operations.test.ts b/packages/beacon-node/test/spec/presets/operations.test.ts index a96d3829854..0e6fdafd225 100644 --- a/packages/beacon-node/test/spec/presets/operations.test.ts +++ b/packages/beacon-node/test/spec/presets/operations.test.ts @@ -57,9 +57,9 @@ const operationFns: Record> = blockFns.processDeposit(fork, state, testCase.deposit); }, - deposit_receipt: (state, testCase: {deposit_receipt: electra.DepositReceipt}) => { + deposit_receipt: (state, testCase: {deposit_receipt: electra.DepositRequest}) => { const fork = state.config.getForkSeq(state.slot); - blockFns.processDepositReceipt(fork, state as CachedBeaconStateElectra, testCase.deposit_receipt); + blockFns.processDepositRequest(fork, state as CachedBeaconStateElectra, testCase.deposit_receipt); }, proposer_slashing: (state, testCase: {proposer_slashing: phase0.ProposerSlashing}) => { @@ -127,7 +127,7 @@ const operations: TestRunnerFn = (fork, block: ssz[fork].BeaconBlock, body: ssz[fork].BeaconBlockBody, deposit: ssz.phase0.Deposit, - deposit_receipt: ssz.electra.DepositReceipt, + deposit_receipt: ssz.electra.DepositRequest, proposer_slashing: ssz.phase0.ProposerSlashing, voluntary_exit: ssz.phase0.SignedVoluntaryExit, // Altair diff --git a/packages/beacon-node/test/unit/executionEngine/http.test.ts b/packages/beacon-node/test/unit/executionEngine/http.test.ts index 5721b9ce5ad..6d3cb17335e 100644 --- a/packages/beacon-node/test/unit/executionEngine/http.test.ts +++ b/packages/beacon-node/test/unit/executionEngine/http.test.ts @@ -188,7 +188,7 @@ describe("ExecutionEngine / http", () => { amount: "0x7b", }, ], - depositReceipts: null, // depositReceipts is null pre-electra + depositRequests: null, // depositRequests is null pre-electra withdrawalRequests: null, }, null, // null returned for missing blocks @@ -198,7 +198,7 @@ describe("ExecutionEngine / http", () => { "0xb084c10440f05f5a23a55d1d7ebcb1b3892935fb56f23cdc9a7f42c348eed174", ], withdrawals: null, // withdrawals is null pre-capella - depositReceipts: null, // depositReceipts is null pre-electra + depositRequests: null, // depositRequests is null pre-electra withdrawalRequests: null, }, ], @@ -247,7 +247,7 @@ describe("ExecutionEngine / http", () => { amount: "0x7b", }, ], - depositReceipts: null, // depositReceipts is null pre-electra + depositRequests: null, // depositRequests is null pre-electra withdrawalRequests: null, }, null, // null returned for missing blocks @@ -257,7 +257,7 @@ describe("ExecutionEngine / http", () => { "0xb084c10440f05f5a23a55d1d7ebcb1b3892935fb56f23cdc9a7f42c348eed174", ], withdrawals: null, // withdrawals is null pre-capella - depositReceipts: null, // depositReceipts is null pre-electra + depositRequests: null, // depositRequests is null pre-electra withdrawalRequests: null, }, ], diff --git a/packages/beacon-node/test/utils/state.ts b/packages/beacon-node/test/utils/state.ts index 15d76b35094..751010c92a6 100644 --- a/packages/beacon-node/test/utils/state.ts +++ b/packages/beacon-node/test/utils/state.ts @@ -97,7 +97,7 @@ export function generateState( if (forkSeq >= ForkSeq.electra) { const stateElectra = state as electra.BeaconState; - stateElectra.depositReceiptsStartIndex = 2023n; + stateElectra.depositRequestsStartIndex = 2023n; stateElectra.latestExecutionPayloadHeader = ssz.electra.ExecutionPayloadHeader.defaultValue(); } diff --git a/packages/light-client/src/spec/utils.ts b/packages/light-client/src/spec/utils.ts index 1b460dd39cf..679371a54d6 100644 --- a/packages/light-client/src/spec/utils.ts +++ b/packages/light-client/src/spec/utils.ts @@ -115,9 +115,9 @@ export function upgradeLightClientHeader( // eslint-disable-next-line no-fallthrough case ForkName.electra: - (upgradedHeader as LightClientHeader).execution.depositReceiptsRoot = - ssz.electra.LightClientHeader.fields.execution.fields.depositReceiptsRoot.defaultValue(); - (upgradedHeader as electra.LightClientHeader).execution.withdrawalRequestsRoot = + (upgradedHeader as LightClientHeader).execution.depositRequestsRoot = + ssz.electra.LightClientHeader.fields.execution.fields.depositRequestsRoot.defaultValue(); + (upgradedHeader as LightClientHeader).execution.withdrawalRequestsRoot = ssz.electra.LightClientHeader.fields.execution.fields.withdrawalRequestsRoot.defaultValue(); // Break if no further upgrades is required else fall through @@ -157,7 +157,7 @@ export function isValidLightClientHeader(config: ChainForkConfig, header: LightC if (epoch < config.ELECTRA_FORK_EPOCH) { if ( - (header as LightClientHeader).execution.depositReceiptsRoot !== undefined || + (header as LightClientHeader).execution.depositRequestsRoot !== undefined || (header as LightClientHeader).execution.withdrawalRequestsRoot !== undefined ) { return false; diff --git a/packages/state-transition/src/block/processDeposit.ts b/packages/state-transition/src/block/processDeposit.ts index 676d78e2757..3592fa0b61d 100644 --- a/packages/state-transition/src/block/processDeposit.ts +++ b/packages/state-transition/src/block/processDeposit.ts @@ -13,7 +13,7 @@ import { } from "@lodestar/params"; import {DepositData} from "@lodestar/types/lib/phase0/types.js"; -import {DepositReceipt} from "@lodestar/types/lib/electra/types.js"; +import {DepositRequest} from "@lodestar/types/lib/electra/types.js"; import {BeaconConfig} from "@lodestar/config"; import {ZERO_HASH} from "../constants/index.js"; import { @@ -54,13 +54,13 @@ export function processDeposit(fork: ForkSeq, state: CachedBeaconStateAllForks, /** * Adds a new validator into the registry. Or increase balance if already exist. - * Follows applyDeposit() in consensus spec. Will be used by processDeposit() and processDepositReceipt() + * Follows applyDeposit() in consensus spec. Will be used by processDeposit() and processDepositRequest() * */ export function applyDeposit( fork: ForkSeq, state: CachedBeaconStateAllForks, - deposit: DepositData | DepositReceipt + deposit: DepositData | DepositRequest ): void { const {config, validators, epochCtx} = state; const {pubkey, withdrawalCredentials, amount} = deposit; diff --git a/packages/state-transition/src/block/processDepositReceipt.ts b/packages/state-transition/src/block/processDepositRequest.ts similarity index 55% rename from packages/state-transition/src/block/processDepositReceipt.ts rename to packages/state-transition/src/block/processDepositRequest.ts index 140e38d634f..ca6fe420618 100644 --- a/packages/state-transition/src/block/processDepositReceipt.ts +++ b/packages/state-transition/src/block/processDepositRequest.ts @@ -4,14 +4,14 @@ import {ForkSeq, UNSET_DEPOSIT_RECEIPTS_START_INDEX} from "@lodestar/params"; import {CachedBeaconStateElectra} from "../types.js"; import {applyDeposit} from "./processDeposit.js"; -export function processDepositReceipt( +export function processDepositRequest( fork: ForkSeq, state: CachedBeaconStateElectra, - depositReceipt: electra.DepositReceipt + depositRequest: electra.DepositRequest ): void { - if (state.depositReceiptsStartIndex === UNSET_DEPOSIT_RECEIPTS_START_INDEX) { - state.depositReceiptsStartIndex = BigInt(depositReceipt.index); + if (state.depositRequestsStartIndex === UNSET_DEPOSIT_RECEIPTS_START_INDEX) { + state.depositRequestsStartIndex = BigInt(depositRequest.index); } - applyDeposit(fork, state, depositReceipt); + applyDeposit(fork, state, depositRequest); } diff --git a/packages/state-transition/src/block/processOperations.ts b/packages/state-transition/src/block/processOperations.ts index 8d65762931e..3ddc3668e48 100644 --- a/packages/state-transition/src/block/processOperations.ts +++ b/packages/state-transition/src/block/processOperations.ts @@ -10,7 +10,7 @@ import {processDeposit} from "./processDeposit.js"; import {processVoluntaryExit} from "./processVoluntaryExit.js"; import {processBlsToExecutionChange} from "./processBlsToExecutionChange.js"; import {processExecutionLayerWithdrawalRequest} from "./processExecutionLayerWithdrawalRequest.js"; -import {processDepositReceipt} from "./processDepositReceipt.js"; +import {processDepositRequest} from "./processDepositRequest.js"; import {ProcessBlockOpts} from "./types.js"; import {processConsolidation} from "./processConsolidation.js"; @@ -22,7 +22,7 @@ export { processVoluntaryExit, processExecutionLayerWithdrawalRequest, processBlsToExecutionChange, - processDepositReceipt, + processDepositRequest, }; export function processOperations( @@ -70,8 +70,8 @@ export function processOperations( processExecutionLayerWithdrawalRequest(fork, state as CachedBeaconStateElectra, elWithdrawalRequest); } - for (const depositReceipt of bodyElectra.executionPayload.depositReceipts) { - processDepositReceipt(fork, stateElectra, depositReceipt); + for (const depositRequest of bodyElectra.executionPayload.depositRequests) { + processDepositRequest(fork, stateElectra, depositRequest); } for (const consolidation of bodyElectra.consolidations) { diff --git a/packages/state-transition/src/slot/upgradeStateToElectra.ts b/packages/state-transition/src/slot/upgradeStateToElectra.ts index 760595c3a86..a6bc6c331e1 100644 --- a/packages/state-transition/src/slot/upgradeStateToElectra.ts +++ b/packages/state-transition/src/slot/upgradeStateToElectra.ts @@ -25,9 +25,9 @@ export function upgradeStateToElectra(stateDeneb: CachedBeaconStateDeneb): Cache epoch: stateDeneb.epochCtx.epoch, }); - // latestExecutionPayloadHeader's depositReceiptsRoot and withdrawalRequestsRoot set to zeros by default - // default value of depositReceiptsStartIndex is UNSET_DEPOSIT_RECEIPTS_START_INDEX - stateElectra.depositReceiptsStartIndex = UNSET_DEPOSIT_RECEIPTS_START_INDEX; + // latestExecutionPayloadHeader's depositRequestsRoot and withdrawalRequestsRoot set to zeros by default + // default value of depositRequestsStartIndex is UNSET_DEPOSIT_RECEIPTS_START_INDEX + stateElectra.depositRequestsStartIndex = UNSET_DEPOSIT_RECEIPTS_START_INDEX; const validatorsArr = stateElectra.validators.getAllReadonly(); diff --git a/packages/state-transition/src/util/deposit.ts b/packages/state-transition/src/util/deposit.ts index 493099fdd98..e8ef93c515d 100644 --- a/packages/state-transition/src/util/deposit.ts +++ b/packages/state-transition/src/util/deposit.ts @@ -9,9 +9,9 @@ export function getEth1DepositCount(state: CachedBeaconStateAllForks, eth1Data?: // eth1DataIndexLimit = min(UintNum64, UintBn64) can be safely casted as UintNum64 // since the result lies within upper and lower bound of UintNum64 const eth1DataIndexLimit: UintNum64 = - eth1DataToUse.depositCount < electraState.depositReceiptsStartIndex + eth1DataToUse.depositCount < electraState.depositRequestsStartIndex ? eth1DataToUse.depositCount - : Number(electraState.depositReceiptsStartIndex); + : Number(electraState.depositRequestsStartIndex); if (state.eth1DepositIndex < eth1DataIndexLimit) { return Math.min(MAX_DEPOSITS, eth1DataIndexLimit - state.eth1DepositIndex); diff --git a/packages/state-transition/src/util/execution.ts b/packages/state-transition/src/util/execution.ts index c7f0ec2f395..2c55dc61a50 100644 --- a/packages/state-transition/src/util/execution.ts +++ b/packages/state-transition/src/util/execution.ts @@ -172,8 +172,8 @@ export function executionPayloadToPayloadHeader(fork: ForkSeq, payload: Executio } if (fork >= ForkSeq.electra) { - (bellatrixPayloadFields as electra.ExecutionPayloadHeader).depositReceiptsRoot = - ssz.electra.DepositReceipts.hashTreeRoot((payload as electra.ExecutionPayload).depositReceipts); + (bellatrixPayloadFields as electra.ExecutionPayloadHeader).depositRequestsRoot = + ssz.electra.DepositRequests.hashTreeRoot((payload as electra.ExecutionPayload).depositRequests); (bellatrixPayloadFields as electra.ExecutionPayloadHeader).withdrawalRequestsRoot = ssz.electra.ExecutionLayerWithdrawalRequests.hashTreeRoot( (payload as electra.ExecutionPayload).withdrawalRequests diff --git a/packages/state-transition/src/util/genesis.ts b/packages/state-transition/src/util/genesis.ts index 537edc7f976..d5f4c577711 100644 --- a/packages/state-transition/src/util/genesis.ts +++ b/packages/state-transition/src/util/genesis.ts @@ -293,7 +293,7 @@ export function initializeBeaconStateFromEth1( stateElectra.latestExecutionPayloadHeader = (executionPayloadHeader as CompositeViewDU) ?? ssz.electra.ExecutionPayloadHeader.defaultViewDU(); - stateElectra.depositReceiptsStartIndex = UNSET_DEPOSIT_RECEIPTS_START_INDEX; + stateElectra.depositRequestsStartIndex = UNSET_DEPOSIT_RECEIPTS_START_INDEX; } state.commit(); diff --git a/packages/state-transition/test/unit/util/deposit.test.ts b/packages/state-transition/test/unit/util/deposit.test.ts index e8f7f7a86af..677a15724ec 100644 --- a/packages/state-transition/test/unit/util/deposit.test.ts +++ b/packages/state-transition/test/unit/util/deposit.test.ts @@ -43,7 +43,7 @@ describe("getEth1DepositCount", () => { throw Error("Not a post-Electra state"); } - postElectraState.depositReceiptsStartIndex = 1000n; + postElectraState.depositRequestsStartIndex = 1000n; postElectraState.eth1Data.depositCount = 995; // 1. Should get less than MAX_DEPOSIT @@ -77,7 +77,7 @@ describe("getEth1DepositCount", () => { throw Error("Not a post-Electra state"); } - postElectraState.depositReceiptsStartIndex = 1000n; + postElectraState.depositRequestsStartIndex = 1000n; postElectraState.eth1Data.depositCount = 1005; // Before eth1DepositIndex reaching the start index diff --git a/packages/types/src/electra/sszTypes.ts b/packages/types/src/electra/sszTypes.ts index 26539dd6136..246c731d838 100644 --- a/packages/types/src/electra/sszTypes.ts +++ b/packages/types/src/electra/sszTypes.ts @@ -110,7 +110,7 @@ export const SignedAggregateAndProof = new ContainerType( {typeName: "SignedAggregateAndProof", jsonCase: "eth2"} ); -export const DepositReceipt = new ContainerType( +export const DepositRequest = new ContainerType( { pubkey: BLSPubkey, withdrawalCredentials: Bytes32, @@ -118,10 +118,10 @@ export const DepositReceipt = new ContainerType( signature: BLSSignature, index: DepositIndex, }, - {typeName: "DepositReceipt", jsonCase: "eth2"} + {typeName: "DepositRequest", jsonCase: "eth2"} ); -export const DepositReceipts = new ListCompositeType(DepositReceipt, MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD); +export const DepositRequests = new ListCompositeType(DepositRequest, MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD); export const ExecutionLayerWithdrawalRequest = new ContainerType( { @@ -139,7 +139,7 @@ export const ExecutionLayerWithdrawalRequests = new ListCompositeType( export const ExecutionPayload = new ContainerType( { ...denebSsz.ExecutionPayload.fields, - depositReceipts: DepositReceipts, // New in ELECTRA + depositRequests: DepositRequests, // New in ELECTRA withdrawalRequests: ExecutionLayerWithdrawalRequests, // New in ELECTRA }, {typeName: "ExecutionPayload", jsonCase: "eth2"} @@ -148,7 +148,7 @@ export const ExecutionPayload = new ContainerType( export const ExecutionPayloadHeader = new ContainerType( { ...denebSsz.ExecutionPayloadHeader.fields, - depositReceiptsRoot: Root, // New in ELECTRA + depositRequestsRoot: Root, // New in ELECTRA withdrawalRequestsRoot: Root, // New in ELECTRA }, {typeName: "ExecutionPayloadHeader", jsonCase: "eth2"} @@ -335,7 +335,7 @@ export const BeaconState = new ContainerType( nextWithdrawalValidatorIndex: capellaSsz.BeaconState.fields.nextWithdrawalValidatorIndex, // Deep history valid from Capella onwards historicalSummaries: capellaSsz.BeaconState.fields.historicalSummaries, - depositReceiptsStartIndex: UintBn64, // New in ELECTRA + depositRequestsStartIndex: UintBn64, // New in ELECTRA depositBalanceToConsume: Gwei, // [New in Electra] exitBalanceToConsume: Gwei, // [New in Electra] earliestExitEpoch: Epoch, // [New in Electra] diff --git a/packages/types/src/electra/types.ts b/packages/types/src/electra/types.ts index 4de209b4896..53b95e95525 100644 --- a/packages/types/src/electra/types.ts +++ b/packages/types/src/electra/types.ts @@ -9,8 +9,8 @@ export type AttesterSlashing = ValueOf; export type AggregateAndProof = ValueOf; export type SignedAggregateAndProof = ValueOf; -export type DepositReceipt = ValueOf; -export type DepositReceipts = ValueOf; +export type DepositRequest = ValueOf; +export type DepositRequests = ValueOf; export type ExecutionLayerWithdrawalRequest = ValueOf; export type ExecutionLayerWithdrawalRequests = ValueOf;