diff --git a/packages/api/test/unit/beacon/oapiSpec.test.ts b/packages/api/test/unit/beacon/oapiSpec.test.ts index e5d473ab6a5..00f1a3d8731 100644 --- a/packages/api/test/unit/beacon/oapiSpec.test.ts +++ b/packages/api/test/unit/beacon/oapiSpec.test.ts @@ -86,6 +86,11 @@ const ignoredTopics = [ topic block_gossip not implemented */ "block_gossip", + + // Modified in electra to include version + // should be removed from the ignore list after spec update + "attestation", + "attester_slashing", ]; // eventstream types are defined as comments in the description of "examples". diff --git a/packages/beacon-node/src/api/impl/config/constants.ts b/packages/beacon-node/src/api/impl/config/constants.ts index b5f81015758..78262ce1523 100644 --- a/packages/beacon-node/src/api/impl/config/constants.ts +++ b/packages/beacon-node/src/api/impl/config/constants.ts @@ -38,7 +38,7 @@ import { VERSIONED_HASH_VERSION_KZG, COMPOUNDING_WITHDRAWAL_PREFIX, DOMAIN_CONSOLIDATION, - UNSET_DEPOSIT_RECEIPTS_START_INDEX, + UNSET_DEPOSIT_REQUESTS_START_INDEX, FULL_EXIT_REQUEST_AMOUNT, } from "@lodestar/params"; @@ -108,6 +108,6 @@ export const specConstants = { VERSIONED_HASH_VERSION_KZG, // electra - UNSET_DEPOSIT_RECEIPTS_START_INDEX, + UNSET_DEPOSIT_REQUESTS_START_INDEX, FULL_EXIT_REQUEST_AMOUNT, }; diff --git a/packages/beacon-node/src/chain/blocks/types.ts b/packages/beacon-node/src/chain/blocks/types.ts index 5eb5eebc784..80c94e2d6fd 100644 --- a/packages/beacon-node/src/chain/blocks/types.ts +++ b/packages/beacon-node/src/chain/blocks/types.ts @@ -1,7 +1,7 @@ import {CachedBeaconStateAllForks, computeEpochAtSlot} from "@lodestar/state-transition"; import {MaybeValidExecutionStatus, DataAvailabilityStatus} from "@lodestar/fork-choice"; import {deneb, Slot, RootHex, SignedBeaconBlock} from "@lodestar/types"; -import {ForkSeq, ForkName} from "@lodestar/params"; +import {ForkSeq, ForkName, ForkBlobs} from "@lodestar/params"; import {ChainForkConfig} from "@lodestar/config"; export enum BlockInputType { @@ -36,7 +36,7 @@ export enum GossipedInputType { type BlobsCacheMap = Map; -type ForkBlobsInfo = {fork: ForkName.deneb | ForkName.electra}; +type ForkBlobsInfo = {fork: ForkBlobs}; type BlobsData = {blobs: deneb.BlobSidecars; blobsBytes: (Uint8Array | null)[]; blobsSource: BlobsSource}; export type BlockInputDataBlobs = ForkBlobsInfo & BlobsData; export type BlockInputData = BlockInputDataBlobs; diff --git a/packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts b/packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts index acd1dafe1ea..6751329a9c1 100644 --- a/packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts +++ b/packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts @@ -1,5 +1,4 @@ -import {aggregateSignatures} from "@chainsafe/blst"; -import {Signature} from "@chainsafe/bls/types"; +import {aggregateSignatures, Signature} from "@chainsafe/blst"; import {BitArray, toHexString} from "@chainsafe/ssz"; import { ForkName, diff --git a/packages/beacon-node/src/chain/opPools/opPool.ts b/packages/beacon-node/src/chain/opPools/opPool.ts index 8de08b7b419..bc7ae31d949 100644 --- a/packages/beacon-node/src/chain/opPools/opPool.ts +++ b/packages/beacon-node/src/chain/opPools/opPool.ts @@ -209,7 +209,7 @@ export class OpPool { const endAttesterSlashings = stepsMetrics?.startTimer(); const attesterSlashings: AttesterSlashing[] = []; - const maxAttesterSlashing = stateFork >= ForkSeq.electra ? MAX_ATTESTER_SLASHINGS_ELECTRA : MAX_ATTESTER_SLASHINGS; + const maxAttesterSlashings = stateFork >= ForkSeq.electra ? MAX_ATTESTER_SLASHINGS_ELECTRA : MAX_ATTESTER_SLASHINGS; attesterSlashing: for (const attesterSlashing of this.attesterSlashings.values()) { /** Indices slashable in this attester slashing */ const slashableIndices = new Set(); @@ -224,7 +224,7 @@ export class OpPool { if (isSlashableAtEpoch(validator, stateEpoch)) { slashableIndices.add(index); } - if (attesterSlashings.length >= maxAttesterSlashing) { + if (attesterSlashings.length >= maxAttesterSlashings) { break attesterSlashing; } } diff --git a/packages/beacon-node/src/chain/stateCache/types.ts b/packages/beacon-node/src/chain/stateCache/types.ts index ad93def481e..1e8d6bd1bd6 100644 --- a/packages/beacon-node/src/chain/stateCache/types.ts +++ b/packages/beacon-node/src/chain/stateCache/types.ts @@ -33,7 +33,8 @@ export interface BlockStateCache { prune(headStateRootHex: RootHex): void; deleteAllBeforeEpoch(finalizedEpoch: Epoch): void; dumpSummary(): routes.lodestar.StateCacheItem[]; - getStates(): IterableIterator; // Expose beacon states stored in cache. Use with caution + /** Expose beacon states stored in cache. Use with caution */ + getStates(): IterableIterator; } /** @@ -75,7 +76,8 @@ export interface CheckpointStateCache { processState(blockRootHex: RootHex, state: CachedBeaconStateAllForks): Promise; clear(): void; dumpSummary(): routes.lodestar.StateCacheItem[]; - getStates(): IterableIterator; // Expose beacon states stored in cache. Use with caution + /** Expose beacon states stored in cache. Use with caution */ + getStates(): IterableIterator; } export enum CacheItemType { diff --git a/packages/beacon-node/src/chain/validation/signatureSets/aggregateAndProof.ts b/packages/beacon-node/src/chain/validation/signatureSets/aggregateAndProof.ts index 2945b4d445d..31d93181859 100644 --- a/packages/beacon-node/src/chain/validation/signatureSets/aggregateAndProof.ts +++ b/packages/beacon-node/src/chain/validation/signatureSets/aggregateAndProof.ts @@ -1,4 +1,4 @@ -import type {PublicKey} from "@chainsafe/bls/types"; +import {PublicKey} from "@chainsafe/blst"; import {DOMAIN_AGGREGATE_AND_PROOF, ForkSeq} from "@lodestar/params"; import {ssz, SignedAggregateAndProof} from "@lodestar/types"; import {Epoch} from "@lodestar/types"; diff --git a/packages/beacon-node/src/execution/engine/interface.ts b/packages/beacon-node/src/execution/engine/interface.ts index a835fa76f50..5226a46ac72 100644 --- a/packages/beacon-node/src/execution/engine/interface.ts +++ b/packages/beacon-node/src/execution/engine/interface.ts @@ -177,6 +177,4 @@ export interface IExecutionEngine { getPayloadBodiesByHash(fork: ForkName, blockHash: DATA[]): Promise<(ExecutionPayloadBody | null)[]>; getPayloadBodiesByRange(fork: ForkName, start: number, count: number): Promise<(ExecutionPayloadBody | null)[]>; - - getState(): ExecutionEngineState; } diff --git a/packages/beacon-node/test/perf/chain/stateCache/updateUnfinalizedPubkeys.test.ts b/packages/beacon-node/test/perf/chain/stateCache/updateUnfinalizedPubkeys.test.ts index b8f5c30a70e..46659ab3d28 100644 --- a/packages/beacon-node/test/perf/chain/stateCache/updateUnfinalizedPubkeys.test.ts +++ b/packages/beacon-node/test/perf/chain/stateCache/updateUnfinalizedPubkeys.test.ts @@ -2,8 +2,7 @@ import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {Map} from "immutable"; import {toBufferBE} from "bigint-buffer"; import {digest} from "@chainsafe/as-sha256"; -import type {SecretKey} from "@chainsafe/bls/types"; -import bls from "@chainsafe/bls"; +import {SecretKey} from "@chainsafe/blst"; import {ssz} from "@lodestar/types"; import {type CachedBeaconStateAllForks, PubkeyIndexMap} from "@lodestar/state-transition"; import {bytesToBigInt, intToBytes} from "@lodestar/utils"; @@ -106,6 +105,7 @@ describe("updateUnfinalizedPubkeys perf tests", function () { function generatePrivateKey(index: number): SecretKey { const secretKeyBytes = toBufferBE(bytesToBigInt(digest(intToBytes(index, 32))) % BigInt("38581184513"), 32); - return bls.SecretKey.fromBytes(secretKeyBytes); + const secret: SecretKey = SecretKey.fromBytes(secretKeyBytes); + return secret; } }); diff --git a/packages/beacon-node/test/sim/electra-interop.test.ts b/packages/beacon-node/test/sim/electra-interop.test.ts index 2dfa5ee0f77..02fc99f9cfa 100644 --- a/packages/beacon-node/test/sim/electra-interop.test.ts +++ b/packages/beacon-node/test/sim/electra-interop.test.ts @@ -3,7 +3,7 @@ import assert from "node:assert"; import {describe, it, vi, afterAll, afterEach} from "vitest"; import {LogLevel, sleep} from "@lodestar/utils"; -import {ForkName, SLOTS_PER_EPOCH, UNSET_DEPOSIT_RECEIPTS_START_INDEX} from "@lodestar/params"; +import {ForkName, SLOTS_PER_EPOCH, UNSET_DEPOSIT_REQUESTS_START_INDEX} from "@lodestar/params"; import {electra, Epoch, Slot} from "@lodestar/types"; import {ValidatorProposerConfig} from "@lodestar/validator"; @@ -431,7 +431,7 @@ describe("executionEngine / ExecutionEngineHttp", function () { throw Error("Historical validator length for epoch 1 or 2 is not dropped properly"); } - if (headState.depositRequestsStartIndex === UNSET_DEPOSIT_RECEIPTS_START_INDEX) { + if (headState.depositRequestsStartIndex === UNSET_DEPOSIT_REQUESTS_START_INDEX) { throw Error("state.depositRequestsStartIndex is not set upon processing new deposit receipt"); } diff --git a/packages/beacon-node/test/spec/presets/fork_choice.test.ts b/packages/beacon-node/test/spec/presets/fork_choice.test.ts index 01adcc77500..7cb6e3c3d69 100644 --- a/packages/beacon-node/test/spec/presets/fork_choice.test.ts +++ b/packages/beacon-node/test/spec/presets/fork_choice.test.ts @@ -4,7 +4,17 @@ import {toHexString} from "@chainsafe/ssz"; import {BeaconStateAllForks, isExecutionStateType, signedBlockToSignedHeader} from "@lodestar/state-transition"; import {InputType} from "@lodestar/spec-test-util"; import {CheckpointWithHex, ForkChoice} from "@lodestar/fork-choice"; -import {phase0, bellatrix, ssz, RootHex, deneb, BeaconBlock, SignedBeaconBlock} from "@lodestar/types"; +import { + bellatrix, + ssz, + RootHex, + deneb, + BeaconBlock, + SignedBeaconBlock, + sszTypesFor, + Attestation, + AttesterSlashing, +} from "@lodestar/types"; import {bnToNum, fromHex} from "@lodestar/utils"; import {createBeaconConfig} from "@lodestar/config"; import {ACTIVE_PRESET, ForkSeq, isForkBlobs, ForkName} from "@lodestar/params"; @@ -136,7 +146,7 @@ const forkChoiceTest = const attestation = testcase.attestations.get(step.attestation); if (!attestation) throw Error(`No attestation ${step.attestation}`); const headState = chain.getHeadState(); - const attDataRootHex = toHexString(ssz.phase0.AttestationData.hashTreeRoot(attestation.data)); + const attDataRootHex = toHexString(sszTypesFor(fork).AttestationData.hashTreeRoot(attestation.data)); chain.forkChoice.onAttestation( headState.epochCtx.getIndexedAttestation(ForkSeq[fork], attestation), attDataRootHex @@ -343,16 +353,16 @@ const forkChoiceTest = [BLOCK_FILE_NAME]: ssz[fork].SignedBeaconBlock, [BLOBS_FILE_NAME]: ssz.deneb.Blobs, [POW_BLOCK_FILE_NAME]: ssz.bellatrix.PowBlock, - [ATTESTATION_FILE_NAME]: ssz.phase0.Attestation, - [ATTESTER_SLASHING_FILE_NAME]: ssz.phase0.AttesterSlashing, + [ATTESTATION_FILE_NAME]: sszTypesFor(fork).Attestation, + [ATTESTER_SLASHING_FILE_NAME]: sszTypesFor(fork).AttesterSlashing, }, mapToTestCase: (t: Record) => { // t has input file name as key const blocks = new Map(); const blobs = new Map(); const powBlocks = new Map(); - const attestations = new Map(); - const attesterSlashings = new Map(); + const attestations = new Map(); + const attesterSlashings = new Map(); for (const key in t) { const blockMatch = key.match(BLOCK_FILE_NAME); if (blockMatch) { @@ -495,8 +505,8 @@ type ForkChoiceTestCase = { blocks: Map; blobs: Map; powBlocks: Map; - attestations: Map; - attesterSlashings: Map; + attestations: Map; + attesterSlashings: Map; }; function isTick(step: Step): step is OnTick { diff --git a/packages/beacon-node/test/spec/presets/operations.test.ts b/packages/beacon-node/test/spec/presets/operations.test.ts index 24f51b05c4f..c978cac3c8a 100644 --- a/packages/beacon-node/test/spec/presets/operations.test.ts +++ b/packages/beacon-node/test/spec/presets/operations.test.ts @@ -135,8 +135,8 @@ const operations: TestRunnerFn = (fork, sszTypes: { pre: ssz[fork].BeaconState, post: ssz[fork].BeaconState, - attestation: ssz.phase0.Attestation, - attester_slashing: ssz.phase0.AttesterSlashing, + attestation: sszTypesFor(fork).Attestation, + attester_slashing: sszTypesFor(fork).AttesterSlashing, block: ssz[fork].BeaconBlock, body: ssz[fork].BeaconBlockBody, deposit: ssz.phase0.Deposit, diff --git a/packages/beacon-node/test/unit/chain/opPools/aggregatedAttestationPool.test.ts b/packages/beacon-node/test/unit/chain/opPools/aggregatedAttestationPool.test.ts index 57b5d6fad00..c9c128e5485 100644 --- a/packages/beacon-node/test/unit/chain/opPools/aggregatedAttestationPool.test.ts +++ b/packages/beacon-node/test/unit/chain/opPools/aggregatedAttestationPool.test.ts @@ -1,6 +1,6 @@ import {BitArray, fromHexString, toHexString} from "@chainsafe/ssz"; import {describe, it, expect, beforeEach, beforeAll, afterEach, vi} from "vitest"; -import {SecretKey, Signature, fastAggregateVerify} from "@chainsafe/blst"; +import {SecretKey, Signature, fastAggregateVerify, aggregateSignatures} from "@chainsafe/blst"; import {CachedBeaconStateAllForks, newFilledArray} from "@lodestar/state-transition"; import { FAR_FUTURE_EPOCH, @@ -331,9 +331,9 @@ describe("MatchingDataAttestationGroup aggregateInto", function () { }); describe("aggregateConsolidation", function () { - const sk0 = bls.SecretKey.fromBytes(Buffer.alloc(32, 1)); - const sk1 = bls.SecretKey.fromBytes(Buffer.alloc(32, 2)); - const sk2 = bls.SecretKey.fromBytes(Buffer.alloc(32, 3)); + const sk0 = SecretKey.fromBytes(Buffer.alloc(32, 1)); + const sk1 = SecretKey.fromBytes(Buffer.alloc(32, 2)); + const sk2 = SecretKey.fromBytes(Buffer.alloc(32, 3)); const skArr = [sk0, sk1, sk2]; const testCases: { name: string; @@ -397,7 +397,7 @@ describe("aggregateConsolidation", function () { expect(finalAttestation.aggregationBits.uint8Array).toEqual(new Uint8Array(expectedAggregationBits)); expect(finalAttestation.committeeBits.toBoolArray()).toEqual(expectedCommitteeBits); expect(finalAttestation.data).toEqual(attData); - expect(finalAttestation.signature).toEqual(bls.Signature.aggregate(sigArr).toBytes()); + expect(finalAttestation.signature).toEqual(aggregateSignatures(sigArr).toBytes()); }); } }); diff --git a/packages/params/src/forkName.ts b/packages/params/src/forkName.ts index e1f1b2eda73..4a41f063734 100644 --- a/packages/params/src/forkName.ts +++ b/packages/params/src/forkName.ts @@ -80,3 +80,16 @@ export const forkBlobs = exclude(forkAll, [ForkName.phase0, ForkName.altair, For export function isForkBlobs(fork: ForkName): fork is ForkBlobs { return isForkWithdrawals(fork) && fork !== ForkName.capella; } + +export type ForkPreElectra = ForkPreBlobs | ForkName.deneb; +export type ForkElectra = Exclude; +export const forkElectra = exclude(forkAll, [ + ForkName.phase0, + ForkName.altair, + ForkName.bellatrix, + ForkName.capella, + ForkName.deneb, +]); +export function isForkElectra(fork: ForkName): fork is ForkElectra { + return isForkBlobs(fork) && fork !== ForkName.deneb; +} diff --git a/packages/params/src/index.ts b/packages/params/src/index.ts index 00e9d48346c..e7fd5b97633 100644 --- a/packages/params/src/index.ts +++ b/packages/params/src/index.ts @@ -262,7 +262,7 @@ export const KZG_COMMITMENT_SUBTREE_INDEX0 = KZG_COMMITMENT_GINDEX0 - 2 ** KZG_C export const BLOBSIDECAR_FIXED_SIZE = ACTIVE_PRESET === PresetName.minimal ? 131672 : 131928; // Electra Misc -export const UNSET_DEPOSIT_RECEIPTS_START_INDEX = 2n ** 64n - 1n; +export const UNSET_DEPOSIT_REQUESTS_START_INDEX = 2n ** 64n - 1n; export const FULL_EXIT_REQUEST_AMOUNT = 0; export const NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA = 87; export const NEXT_SYNC_COMMITTEE_DEPTH_ELECTRA = 6; diff --git a/packages/params/test/unit/__snapshots__/forkName.test.ts.snap b/packages/params/test/unit/__snapshots__/forkName.test.ts.snap index 3d7009a7c2e..a54f9dd6913 100644 --- a/packages/params/test/unit/__snapshots__/forkName.test.ts.snap +++ b/packages/params/test/unit/__snapshots__/forkName.test.ts.snap @@ -7,12 +7,14 @@ exports[`forkName > should have valid allForks 1`] = ` "bellatrix", "capella", "deneb", + "electra", ] `; exports[`forkName > should have valid blobs forks 1`] = ` [ "deneb", + "electra", ] `; @@ -21,6 +23,7 @@ exports[`forkName > should have valid execution forks 1`] = ` "bellatrix", "capella", "deneb", + "electra", ] `; @@ -30,6 +33,7 @@ exports[`forkName > should have valid lightclient forks 1`] = ` "bellatrix", "capella", "deneb", + "electra", ] `; @@ -37,5 +41,6 @@ exports[`forkName > should have valid withdrawal forks 1`] = ` [ "capella", "deneb", + "electra", ] `; diff --git a/packages/state-transition/src/block/processDeposit.ts b/packages/state-transition/src/block/processDeposit.ts index bc140b864ad..7e343d7fc33 100644 --- a/packages/state-transition/src/block/processDeposit.ts +++ b/packages/state-transition/src/block/processDeposit.ts @@ -172,7 +172,7 @@ function isValidDepositSignature( const publicKey = PublicKey.fromBytes(pubkey, true); const signature = Signature.fromBytes(depositSignature, true); - return verify(signingRoot, publicKey, signature) + return verify(signingRoot, publicKey, signature); } catch (e) { return false; // Catch all BLS errors: failed key validation, failed signature validation, invalid signature } diff --git a/packages/state-transition/src/block/processDepositRequest.ts b/packages/state-transition/src/block/processDepositRequest.ts index ca6fe420618..e5dd99a40c4 100644 --- a/packages/state-transition/src/block/processDepositRequest.ts +++ b/packages/state-transition/src/block/processDepositRequest.ts @@ -1,5 +1,5 @@ import {electra} from "@lodestar/types"; -import {ForkSeq, UNSET_DEPOSIT_RECEIPTS_START_INDEX} from "@lodestar/params"; +import {ForkSeq, UNSET_DEPOSIT_REQUESTS_START_INDEX} from "@lodestar/params"; import {CachedBeaconStateElectra} from "../types.js"; import {applyDeposit} from "./processDeposit.js"; @@ -9,7 +9,7 @@ export function processDepositRequest( state: CachedBeaconStateElectra, depositRequest: electra.DepositRequest ): void { - if (state.depositRequestsStartIndex === UNSET_DEPOSIT_RECEIPTS_START_INDEX) { + if (state.depositRequestsStartIndex === UNSET_DEPOSIT_REQUESTS_START_INDEX) { state.depositRequestsStartIndex = BigInt(depositRequest.index); } diff --git a/packages/state-transition/src/slot/upgradeStateToElectra.ts b/packages/state-transition/src/slot/upgradeStateToElectra.ts index 7031aaa76fc..974f0d6a608 100644 --- a/packages/state-transition/src/slot/upgradeStateToElectra.ts +++ b/packages/state-transition/src/slot/upgradeStateToElectra.ts @@ -1,5 +1,5 @@ import {Epoch, ValidatorIndex, ssz} from "@lodestar/types"; -import {FAR_FUTURE_EPOCH, UNSET_DEPOSIT_RECEIPTS_START_INDEX} from "@lodestar/params"; +import {FAR_FUTURE_EPOCH, UNSET_DEPOSIT_REQUESTS_START_INDEX} from "@lodestar/params"; import {CachedBeaconStateDeneb} from "../types.js"; import {CachedBeaconStateElectra, getCachedBeaconState} from "../cache/stateCache.js"; import { @@ -59,8 +59,8 @@ export function upgradeStateToElectra(stateDeneb: CachedBeaconStateDeneb): Cache stateElectraView.historicalSummaries = stateElectraCloned.historicalSummaries; // latestExecutionPayloadHeader's depositRequestsRoot and withdrawalRequestsRoot set to zeros by default - // default value of depositRequestsStartIndex is UNSET_DEPOSIT_RECEIPTS_START_INDEX - stateElectraView.depositRequestsStartIndex = UNSET_DEPOSIT_RECEIPTS_START_INDEX; + // default value of depositRequestsStartIndex is UNSET_DEPOSIT_REQUESTS_START_INDEX + stateElectraView.depositRequestsStartIndex = UNSET_DEPOSIT_REQUESTS_START_INDEX; stateElectraView.depositBalanceToConsume = BigInt(0); stateElectraView.exitBalanceToConsume = BigInt(0); @@ -138,8 +138,8 @@ export function upgradeStateToElectraOriginal(stateDeneb: CachedBeaconStateDeneb }); // 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; + // default value of depositRequestsStartIndex is UNSET_DEPOSIT_REQUESTS_START_INDEX + stateElectra.depositRequestsStartIndex = UNSET_DEPOSIT_REQUESTS_START_INDEX; const validatorsArr = stateElectra.validators.getAllReadonly(); diff --git a/packages/state-transition/src/util/electra.ts b/packages/state-transition/src/util/electra.ts index 53f53aaf8d6..666f45435eb 100644 --- a/packages/state-transition/src/util/electra.ts +++ b/packages/state-transition/src/util/electra.ts @@ -28,15 +28,15 @@ export function isFullyWithdrawableValidator( balance: number, epoch: number ): boolean { - const {withdrawableEpoch, withdrawalCredentials: withdrawalCredential} = validatorCredential; + const {withdrawableEpoch, withdrawalCredentials} = validatorCredential; if (fork < ForkSeq.capella) { throw new Error(`isFullyWithdrawableValidator not supported at forkSeq=${fork} < ForkSeq.capella`); } const hasWithdrawableCredentials = fork >= ForkSeq.electra - ? hasExecutionWithdrawalCredential(withdrawalCredential) - : hasEth1WithdrawalCredential(withdrawalCredential); + ? hasExecutionWithdrawalCredential(withdrawalCredentials) + : hasEth1WithdrawalCredential(withdrawalCredentials); return hasWithdrawableCredentials && withdrawableEpoch <= epoch && balance > 0; } @@ -46,18 +46,18 @@ export function isPartiallyWithdrawableValidator( validatorCredential: ValidatorInfo, balance: number ): boolean { - const {effectiveBalance, withdrawalCredentials: withdrawalCredential} = validatorCredential; + const {effectiveBalance, withdrawalCredentials} = validatorCredential; if (fork < ForkSeq.capella) { throw new Error(`isPartiallyWithdrawableValidator not supported at forkSeq=${fork} < ForkSeq.capella`); } const hasWithdrawableCredentials = fork >= ForkSeq.electra - ? hasExecutionWithdrawalCredential(withdrawalCredential) - : hasEth1WithdrawalCredential(withdrawalCredential); + ? hasExecutionWithdrawalCredential(withdrawalCredentials) + : hasEth1WithdrawalCredential(withdrawalCredentials); const validatorMaxEffectiveBalance = - fork >= ForkSeq.electra ? getValidatorMaxEffectiveBalance(withdrawalCredential) : MAX_EFFECTIVE_BALANCE; + fork >= ForkSeq.electra ? getValidatorMaxEffectiveBalance(withdrawalCredentials) : MAX_EFFECTIVE_BALANCE; const hasMaxEffectiveBalance = effectiveBalance === validatorMaxEffectiveBalance; const hasExcessBalance = balance > validatorMaxEffectiveBalance; diff --git a/packages/state-transition/src/util/genesis.ts b/packages/state-transition/src/util/genesis.ts index d1f09a9796e..7bdc420d645 100644 --- a/packages/state-transition/src/util/genesis.ts +++ b/packages/state-transition/src/util/genesis.ts @@ -8,7 +8,7 @@ import { GENESIS_EPOCH, GENESIS_SLOT, MAX_EFFECTIVE_BALANCE, - UNSET_DEPOSIT_RECEIPTS_START_INDEX, + UNSET_DEPOSIT_REQUESTS_START_INDEX, } from "@lodestar/params"; import {Bytes32, phase0, Root, ssz, TimeSeconds} from "@lodestar/types"; @@ -312,7 +312,7 @@ export function initializeBeaconStateFromEth1( stateElectra.latestExecutionPayloadHeader = (executionPayloadHeader as CompositeViewDU) ?? ssz.electra.ExecutionPayloadHeader.defaultViewDU(); - stateElectra.depositRequestsStartIndex = UNSET_DEPOSIT_RECEIPTS_START_INDEX; + stateElectra.depositRequestsStartIndex = UNSET_DEPOSIT_REQUESTS_START_INDEX; } state.commit(); diff --git a/packages/types/src/utils/typeguards.ts b/packages/types/src/utils/typeguards.ts index a41b45eec54..2af11159878 100644 --- a/packages/types/src/utils/typeguards.ts +++ b/packages/types/src/utils/typeguards.ts @@ -1,4 +1,4 @@ -import {ForkBlobs, ForkExecution, ForkName} from "@lodestar/params"; +import {ForkBlobs, ForkExecution, ForkElectra} from "@lodestar/params"; import { BlockContents, SignedBeaconBlock, @@ -68,8 +68,6 @@ export function isSignedBlockContents( return (data as SignedBlockContents).kzgProofs !== undefined; } -export function isElectraAttestation( - attestation: Attestation -): attestation is Attestation { +export function isElectraAttestation(attestation: Attestation): attestation is Attestation { return (attestation as Attestation).committeeBits !== undefined; } diff --git a/yarn.lock b/yarn.lock index 3e8d9e79c4e..722b6e50bbb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3050,6 +3050,13 @@ resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-5.0.4.tgz#1a31c3d378850d2778dabb6374d036dcba4ba708" integrity sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw== +"@types/buffer-xor@^2.0.0": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@types/buffer-xor/-/buffer-xor-2.0.2.tgz#d8c463583b8fbb322ea824562dc78a0c3cea2ca6" + integrity sha512-OqdCua7QCTupPnJgmyGJUpxWgbuOi0IMIVslXTSePS2o+qDrDB6f2Pg44zRyqhUA5GbFAf39U8z0+mH4WG0fLQ== + dependencies: + "@types/node" "*" + "@types/cacheable-request@^6.0.1": version "6.0.3" resolved "https://registry.yarnpkg.com/@types/cacheable-request/-/cacheable-request-6.0.3.tgz#a430b3260466ca7b5ca5bfd735693b36e7a9d183" @@ -4626,6 +4633,13 @@ buffer-xor@^1.0.3: resolved "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz" integrity sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk= +buffer-xor@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-2.0.2.tgz#34f7c64f04c777a1f8aac5e661273bb9dd320289" + integrity sha512-eHslX0bin3GB+Lx2p7lEYRShRewuNZL3fUl4qlVJGGiwoPGftmt8JQgk2Y9Ji5/01TnVDo33E5b5O3vUB1HdqQ== + dependencies: + safe-buffer "^5.1.1" + buffer@4.9.2, buffer@^4.3.0: version "4.9.2" resolved "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz"