diff --git a/packages/api/src/beacon/routes/beacon/pool.ts b/packages/api/src/beacon/routes/beacon/pool.ts index 3c390aa41481..499e8af432d7 100644 --- a/packages/api/src/beacon/routes/beacon/pool.ts +++ b/packages/api/src/beacon/routes/beacon/pool.ts @@ -17,6 +17,7 @@ import { } from "../../../utils/codecs.js"; import {MetaHeader, VersionCodec, VersionMeta} from "../../../utils/metadata.js"; import {toForkName} from "../../../utils/fork.js"; +import {fromHeaders} from "../../../utils/headers.js"; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes @@ -247,7 +248,12 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions { - const fork = toForkName(headers[MetaHeader.Version]); + const versionHeader = fromHeaders(headers, MetaHeader.Version, false); + const fork = + versionHeader !== undefined + ? toForkName(versionHeader) + : config.getForkName(Number((body as {data: {slot: string}}[])[0]?.data.slot ?? 0)); + return { signedAttestations: ForkSeq[fork] >= ForkSeq.electra @@ -266,7 +272,8 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions { - const fork = toForkName(headers[MetaHeader.Version]); + const versionHeader = fromHeaders(headers, MetaHeader.Version, true); + const fork = toForkName(versionHeader); return { signedAttestations: ForkSeq[fork] >= ForkSeq.electra diff --git a/packages/api/src/beacon/routes/validator.ts b/packages/api/src/beacon/routes/validator.ts index 56c23ceb4866..5be4a03800f9 100644 --- a/packages/api/src/beacon/routes/validator.ts +++ b/packages/api/src/beacon/routes/validator.ts @@ -40,6 +40,7 @@ import { VersionMeta, VersionType, } from "../../utils/metadata.js"; +import {fromHeaders} from "../../utils/headers.js"; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes @@ -856,7 +857,7 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions ({ attestationDataRoot: fromHexString(query.attestation_data_root), slot: query.slot, - committeeIndex: query.slot, + committeeIndex: query.committeeIndex, }), schema: { query: { @@ -878,7 +879,7 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions { - const fork = config.getForkName(signedAggregateAndProofs[0].message.aggregate.data.slot); + const fork = config.getForkName(signedAggregateAndProofs[0]?.message.aggregate.data.slot ?? 0); return { body: ForkSeq[fork] >= ForkSeq.electra @@ -892,7 +893,16 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions { - const fork = toForkName(headers[MetaHeader.Version]); + const versionHeader = fromHeaders(headers, MetaHeader.Version, false); + const fork = + versionHeader !== undefined + ? toForkName(versionHeader) + : config.getForkName( + Number( + (body as {message: {aggregate: {data: {slot: string}}}}[])[0]?.message.aggregate.data.slot ?? 0 + ) + ); + return { signedAggregateAndProofs: ForkSeq[fork] >= ForkSeq.electra @@ -901,7 +911,7 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions { - const fork = config.getForkName(signedAggregateAndProofs[0].message.aggregate.data.slot); + const fork = config.getForkName(signedAggregateAndProofs[0]?.message.aggregate.data.slot ?? 0); return { body: ForkSeq[fork] >= ForkSeq.electra @@ -915,7 +925,8 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions { - const fork = toForkName(headers[MetaHeader.Version]); + const versionHeader = fromHeaders(headers, MetaHeader.Version, true); + const fork = toForkName(versionHeader); return { signedAggregateAndProofs: ForkSeq[fork] >= ForkSeq.electra diff --git a/packages/api/test/unit/beacon/testData/beacon.ts b/packages/api/test/unit/beacon/testData/beacon.ts index 9dad5f0079a2..be381f44b7de 100644 --- a/packages/api/test/unit/beacon/testData/beacon.ts +++ b/packages/api/test/unit/beacon/testData/beacon.ts @@ -89,7 +89,7 @@ export const testData: GenericServerTestCases = { getPoolAttestations: { args: {slot: 1, committeeIndex: 2}, - res: {data: [ssz.phase0.Attestation.defaultValue()]}, + res: {data: [ssz.phase0.Attestation.defaultValue()], meta: {version: ForkName.deneb}}, }, getPoolAttesterSlashings: { args: undefined, diff --git a/packages/api/test/unit/beacon/testData/validator.ts b/packages/api/test/unit/beacon/testData/validator.ts index 01783241bd2b..8ba02ee1435a 100644 --- a/packages/api/test/unit/beacon/testData/validator.ts +++ b/packages/api/test/unit/beacon/testData/validator.ts @@ -103,7 +103,7 @@ export const testData: GenericServerTestCases = { res: {data: ssz.altair.SyncCommitteeContribution.defaultValue()}, }, getAggregatedAttestation: { - args: {attestationDataRoot: ZERO_HASH, slot: 32000, index: 2}, + args: {attestationDataRoot: ZERO_HASH, slot: 32000, committeeIndex: 2}, res: {data: ssz.phase0.Attestation.defaultValue(), meta: {version: ForkName.phase0}}, }, publishAggregateAndProofs: { diff --git a/packages/beacon-node/src/chain/blocks/types.ts b/packages/beacon-node/src/chain/blocks/types.ts index 2996bac7887f..6368f91e9197 100644 --- a/packages/beacon-node/src/chain/blocks/types.ts +++ b/packages/beacon-node/src/chain/blocks/types.ts @@ -36,7 +36,7 @@ export enum GossipedInputType { type BlobsCacheMap = Map; -type ForkBlobsInfo = {fork: ForkName.deneb}; +type ForkBlobsInfo = {fork: ForkName.deneb | ForkName.electra}; type BlobsData = {blobs: deneb.BlobSidecars; blobsBytes: (Uint8Array | null)[]; blobsSource: BlobsSource}; export type BlockInputDataBlobs = ForkBlobsInfo & BlobsData; export type BlockInputData = BlockInputDataBlobs; diff --git a/packages/light-client/test/unit/webEsmBundle.browser.test.ts b/packages/light-client/test/unit/webEsmBundle.browser.test.ts index defc421d7071..49b0f877d46c 100644 --- a/packages/light-client/test/unit/webEsmBundle.browser.test.ts +++ b/packages/light-client/test/unit/webEsmBundle.browser.test.ts @@ -1,7 +1,7 @@ -/* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access */ import {expect, describe, it, vi, beforeAll} from "vitest"; import {sleep} from "@lodestar/utils"; -import {Lightclient, LightclientEvent, utils, transport} from "../../dist/lightclient.min.mjs"; +import {Lightclient, LightclientEvent, utils, transport} from "../../src/index.js"; describe("web bundle for lightclient", () => { vi.setConfig({testTimeout: 20_000}); diff --git a/packages/state-transition/package.json b/packages/state-transition/package.json index 3a27cc8986c2..10041b6080e0 100644 --- a/packages/state-transition/package.json +++ b/packages/state-transition/package.json @@ -59,8 +59,8 @@ "types": "lib/index.d.ts", "dependencies": { "@chainsafe/as-sha256": "^0.4.1", - "@chainsafe/bls": "^8.1.0", - "@chainsafe/blst": "^1.0.0", + "@chainsafe/bls": "7.1.3", + "@chainsafe/blst": "^0.2.11", "@chainsafe/persistent-merkle-tree": "^0.7.1", "@chainsafe/ssz": "^0.16.0", "@lodestar/config": "^1.19.0", diff --git a/packages/validator/package.json b/packages/validator/package.json index 42df23ae5d9d..3bac2810e037 100644 --- a/packages/validator/package.json +++ b/packages/validator/package.json @@ -45,7 +45,7 @@ "blockchain" ], "dependencies": { - "@chainsafe/bls": "^8.1.0", + "@chainsafe/bls": "7.1.3", "@chainsafe/ssz": "^0.16.0", "@lodestar/api": "^1.19.0", "@lodestar/config": "^1.19.0", diff --git a/packages/validator/test/unit/services/attestation.test.ts b/packages/validator/test/unit/services/attestation.test.ts index 9227af9c8e08..f71dd4715a60 100644 --- a/packages/validator/test/unit/services/attestation.test.ts +++ b/packages/validator/test/unit/services/attestation.test.ts @@ -5,6 +5,7 @@ import {ssz} from "@lodestar/types"; import {routes} from "@lodestar/api"; import {createChainForkConfig} from "@lodestar/config"; import {config} from "@lodestar/config/default"; +import {ForkName} from "@lodestar/params"; import {AttestationService, AttestationServiceOpts} from "../../../src/services/attestation.js"; import {AttDutyAndProof} from "../../../src/services/attestationDuties.js"; import {ValidatorStore} from "../../../src/services/validatorStore.js"; @@ -100,7 +101,9 @@ describe("AttestationService", function () { // Mock beacon's attestation and aggregates endpoints api.validator.produceAttestationData.mockResolvedValue(mockApiResponse({data: attestation.data})); - api.validator.getAggregatedAttestation.mockResolvedValue(mockApiResponse({data: attestation})); + api.validator.getAggregatedAttestation.mockResolvedValue( + mockApiResponse({data: attestation, meta: {version: ForkName.phase0}}) + ); api.beacon.submitPoolAttestations.mockResolvedValue(mockApiResponse({})); api.validator.publishAggregateAndProofs.mockResolvedValue(mockApiResponse({})); diff --git a/yarn.lock b/yarn.lock index e70da22818ce..4a7675f3a837 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2849,6 +2849,13 @@ resolved "https://registry.yarnpkg.com/@types/argparse/-/argparse-1.0.38.tgz#a81fd8606d481f873a3800c6ebae4f1d768a56a9" integrity sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA== +"@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" @@ -4435,6 +4442,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"