diff --git a/biome.jsonc b/biome.jsonc index 212a61d86aa2..f50f4ad9c8d1 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -18,10 +18,7 @@ "ignore": ["**/lib", "**/.nyc_output", "./packages/*/spec-tests", "**/node_modules", "./packages/*/node_modules/**"] }, "organizeImports": { - // TODO: We will enable this settings as soon mono-repo support is provided in biome. - // Currently it didn't recognize local packages in repo and sort those higher than npm packages - // https://github.com/biomejs/biome/issues/2228 - "enabled": false + "enabled": true }, "linter": { "enabled": true, diff --git a/packages/api/src/beacon/client/debug.ts b/packages/api/src/beacon/client/debug.ts index 4df3bef12cf8..c0f2514fa3eb 100644 --- a/packages/api/src/beacon/client/debug.ts +++ b/packages/api/src/beacon/client/debug.ts @@ -1,5 +1,5 @@ import {ChainForkConfig} from "@lodestar/config"; -import {ApiClientMethods, createApiClientMethods, IHttpClient} from "../../utils/client/index.js"; +import {ApiClientMethods, IHttpClient, createApiClientMethods} from "../../utils/client/index.js"; import {Endpoints, getDefinitions} from "../routes/debug.js"; export type ApiClient = ApiClientMethods; diff --git a/packages/api/src/beacon/routes/beacon/block.ts b/packages/api/src/beacon/routes/beacon/block.ts index cd3cae9fd7ff..8fadfa1b9002 100644 --- a/packages/api/src/beacon/routes/beacon/block.ts +++ b/packages/api/src/beacon/routes/beacon/block.ts @@ -1,21 +1,23 @@ import {ContainerType, ListCompositeType, ValueOf} from "@chainsafe/ssz"; import {ChainForkConfig} from "@lodestar/config"; +import {ForkName, ForkPreElectra, ForkPreExecution, isForkBlobs, isForkExecution} from "@lodestar/params"; import { - Slot, - ssz, + BeaconBlockBody, RootHex, - deneb, - isSignedBlockContents, SignedBeaconBlock, - BeaconBlockBody, SignedBeaconBlockOrContents, SignedBlindedBeaconBlock, SignedBlockContents, + Slot, + deneb, + isSignedBlockContents, + ssz, sszTypesFor, } from "@lodestar/types"; -import {ForkName, ForkPreElectra, ForkPreExecution, isForkBlobs, isForkExecution} from "@lodestar/params"; -import {Endpoint, RequestCodec, RouteDefinitions, Schema} from "../../../utils/index.js"; import {EmptyMeta, EmptyResponseCodec, EmptyResponseData, WithVersion} from "../../../utils/codecs.js"; +import {getExecutionForkTypes, toForkName} from "../../../utils/fork.js"; +import {fromHeaders} from "../../../utils/headers.js"; +import {Endpoint, RequestCodec, RouteDefinitions, Schema} from "../../../utils/index.js"; import { ExecutionOptimisticAndFinalizedCodec, ExecutionOptimisticAndFinalizedMeta, @@ -23,8 +25,6 @@ import { ExecutionOptimisticFinalizedAndVersionMeta, MetaHeader, } from "../../../utils/metadata.js"; -import {getExecutionForkTypes, toForkName} from "../../../utils/fork.js"; -import {fromHeaders} from "../../../utils/headers.js"; import {WireFormat} from "../../../utils/wireFormat.js"; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes diff --git a/packages/api/src/beacon/routes/beacon/index.ts b/packages/api/src/beacon/routes/beacon/index.ts index 39d7d995dfb1..5c4a9163a1b7 100644 --- a/packages/api/src/beacon/routes/beacon/index.ts +++ b/packages/api/src/beacon/routes/beacon/index.ts @@ -1,11 +1,11 @@ import {ChainForkConfig} from "@lodestar/config"; import {phase0, ssz} from "@lodestar/types"; +import {EmptyArgs, EmptyMeta, EmptyMetaCodec, EmptyRequest, EmptyRequestCodec} from "../../../utils/codecs.js"; import {Endpoint, RouteDefinitions} from "../../../utils/types.js"; -import {EmptyArgs, EmptyRequestCodec, EmptyMeta, EmptyMetaCodec, EmptyRequest} from "../../../utils/codecs.js"; import * as block from "./block.js"; import * as pool from "./pool.js"; -import * as state from "./state.js"; import * as rewards from "./rewards.js"; +import * as state from "./state.js"; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes diff --git a/packages/api/src/beacon/routes/beacon/pool.ts b/packages/api/src/beacon/routes/beacon/pool.ts index 3f0b8ac74284..4d909c2aac7b 100644 --- a/packages/api/src/beacon/routes/beacon/pool.ts +++ b/packages/api/src/beacon/routes/beacon/pool.ts @@ -1,22 +1,22 @@ import {ValueOf} from "@chainsafe/ssz"; import {ChainForkConfig} from "@lodestar/config"; import {isForkPostElectra} from "@lodestar/params"; -import {phase0, capella, CommitteeIndex, Slot, ssz, electra, AttesterSlashing} from "@lodestar/types"; -import {Schema, Endpoint, RouteDefinitions} from "../../../utils/index.js"; +import {AttesterSlashing, CommitteeIndex, Slot, capella, electra, phase0, ssz} from "@lodestar/types"; import { ArrayOf, EmptyArgs, - EmptyRequestCodec, EmptyMeta, EmptyMetaCodec, EmptyRequest, + EmptyRequestCodec, EmptyResponseCodec, EmptyResponseData, WithVersion, } from "../../../utils/codecs.js"; -import {MetaHeader, VersionCodec, VersionMeta} from "../../../utils/metadata.js"; import {toForkName} from "../../../utils/fork.js"; import {fromHeaders} from "../../../utils/headers.js"; +import {Endpoint, RouteDefinitions, Schema} from "../../../utils/index.js"; +import {MetaHeader, VersionCodec, VersionMeta} from "../../../utils/metadata.js"; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes diff --git a/packages/api/src/beacon/routes/beacon/rewards.ts b/packages/api/src/beacon/routes/beacon/rewards.ts index d41b5ef705f0..3acb09955cb4 100644 --- a/packages/api/src/beacon/routes/beacon/rewards.ts +++ b/packages/api/src/beacon/routes/beacon/rewards.ts @@ -2,10 +2,10 @@ import {ContainerType, ValueOf} from "@chainsafe/ssz"; import {ChainForkConfig} from "@lodestar/config"; import {Epoch, ssz} from "@lodestar/types"; -import {Schema, Endpoint, RouteDefinitions} from "../../../utils/index.js"; -import {fromValidatorIdsStr, toValidatorIdsStr} from "../../../utils/serdes.js"; import {ArrayOf, JsonOnlyReq} from "../../../utils/codecs.js"; +import {Endpoint, RouteDefinitions, Schema} from "../../../utils/index.js"; import {ExecutionOptimisticAndFinalizedCodec, ExecutionOptimisticAndFinalizedMeta} from "../../../utils/metadata.js"; +import {fromValidatorIdsStr, toValidatorIdsStr} from "../../../utils/serdes.js"; import {BlockArgs} from "./block.js"; import {ValidatorId} from "./state.js"; diff --git a/packages/api/src/beacon/routes/beacon/state.ts b/packages/api/src/beacon/routes/beacon/state.ts index 4127bb1ce793..d1284558f98f 100644 --- a/packages/api/src/beacon/routes/beacon/state.ts +++ b/packages/api/src/beacon/routes/beacon/state.ts @@ -1,9 +1,9 @@ import {ContainerType, ValueOf} from "@chainsafe/ssz"; import {ChainForkConfig} from "@lodestar/config"; import {MAX_VALIDATORS_PER_COMMITTEE} from "@lodestar/params"; -import {phase0, CommitteeIndex, Slot, Epoch, ssz, RootHex, StringType, ValidatorStatus} from "@lodestar/types"; -import {Endpoint, RequestCodec, RouteDefinitions, Schema} from "../../../utils/index.js"; +import {CommitteeIndex, Epoch, RootHex, Slot, StringType, ValidatorStatus, phase0, ssz} from "@lodestar/types"; import {ArrayOf, JsonOnlyReq} from "../../../utils/codecs.js"; +import {Endpoint, RequestCodec, RouteDefinitions, Schema} from "../../../utils/index.js"; import {ExecutionOptimisticAndFinalizedCodec, ExecutionOptimisticAndFinalizedMeta} from "../../../utils/metadata.js"; import {fromValidatorIdsStr, toValidatorIdsStr} from "../../../utils/serdes.js"; import {WireFormat} from "../../../utils/wireFormat.js"; diff --git a/packages/api/src/beacon/routes/config.ts b/packages/api/src/beacon/routes/config.ts index afce0898908c..cd76c2bf41b2 100644 --- a/packages/api/src/beacon/routes/config.ts +++ b/packages/api/src/beacon/routes/config.ts @@ -4,10 +4,10 @@ import {ssz} from "@lodestar/types"; import { ArrayOf, EmptyArgs, - EmptyRequestCodec, EmptyMeta, EmptyMetaCodec, EmptyRequest, + EmptyRequestCodec, JsonOnlyResp, } from "../../utils/codecs.js"; import {Endpoint, RouteDefinitions} from "../../utils/index.js"; diff --git a/packages/api/src/beacon/routes/debug.ts b/packages/api/src/beacon/routes/debug.ts index 349684f62ccd..9afc96d5a637 100644 --- a/packages/api/src/beacon/routes/debug.ts +++ b/packages/api/src/beacon/routes/debug.ts @@ -1,22 +1,22 @@ import {ContainerType, Type, ValueOf} from "@chainsafe/ssz"; import {ChainForkConfig} from "@lodestar/config"; -import {ssz, StringType, BeaconState} from "@lodestar/types"; +import {BeaconState, StringType, ssz} from "@lodestar/types"; import { ArrayOf, EmptyArgs, - EmptyRequestCodec, EmptyMeta, EmptyMetaCodec, EmptyRequest, + EmptyRequestCodec, WithVersion, } from "../../utils/codecs.js"; import { ExecutionOptimisticFinalizedAndVersionCodec, ExecutionOptimisticFinalizedAndVersionMeta, } from "../../utils/metadata.js"; +import {Schema} from "../../utils/schema.js"; import {Endpoint, RouteDefinitions} from "../../utils/types.js"; import {WireFormat} from "../../utils/wireFormat.js"; -import {Schema} from "../../utils/schema.js"; import {StateArgs} from "./beacon/state.js"; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes diff --git a/packages/api/src/beacon/routes/events.ts b/packages/api/src/beacon/routes/events.ts index 5fa218bc02f3..81bd6e7a7f5e 100644 --- a/packages/api/src/beacon/routes/events.ts +++ b/packages/api/src/beacon/routes/events.ts @@ -1,27 +1,27 @@ import {ContainerType, ValueOf} from "@chainsafe/ssz"; import {ChainForkConfig} from "@lodestar/config"; +import {ForkName} from "@lodestar/params"; import { + Attestation, + AttesterSlashing, Epoch, - phase0, - capella, + LightClientFinalityUpdate, + LightClientOptimisticUpdate, + RootHex, + SSEPayloadAttributes, Slot, - ssz, StringType, - RootHex, - altair, UintNum64, - LightClientOptimisticUpdate, - LightClientFinalityUpdate, - SSEPayloadAttributes, - Attestation, - AttesterSlashing, + altair, + capella, + phase0, + ssz, sszTypesFor, } from "@lodestar/types"; -import {ForkName} from "@lodestar/params"; -import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js"; import {EmptyMeta, EmptyResponseCodec, EmptyResponseData} from "../../utils/codecs.js"; import {getExecutionForkTypes, getLightClientForkTypes} from "../../utils/fork.js"; +import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js"; import {VersionType} from "../../utils/metadata.js"; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes diff --git a/packages/api/src/beacon/routes/lightclient.ts b/packages/api/src/beacon/routes/lightclient.ts index bac73b43ddb2..d3e60a69bae9 100644 --- a/packages/api/src/beacon/routes/lightclient.ts +++ b/packages/api/src/beacon/routes/lightclient.ts @@ -1,27 +1,27 @@ import {ListCompositeType, ValueOf} from "@chainsafe/ssz"; +import {BeaconConfig, ChainForkConfig, createBeaconConfig} from "@lodestar/config"; +import {NetworkName, genesisData} from "@lodestar/config/networks"; +import {ForkName, ZERO_HASH} from "@lodestar/params"; import { LightClientBootstrap, LightClientFinalityUpdate, LightClientOptimisticUpdate, LightClientUpdate, - ssz, SyncPeriod, + ssz, } from "@lodestar/types"; import {fromHex} from "@lodestar/utils"; -import {ForkName, ZERO_HASH} from "@lodestar/params"; -import {BeaconConfig, ChainForkConfig, createBeaconConfig} from "@lodestar/config"; -import {genesisData, NetworkName} from "@lodestar/config/networks"; -import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js"; -import {MetaHeader, VersionCodec, VersionMeta} from "../../utils/metadata.js"; -import {getLightClientForkTypes, toForkName} from "../../utils/fork.js"; import { EmptyArgs, - EmptyRequestCodec, EmptyMeta, EmptyMetaCodec, EmptyRequest, + EmptyRequestCodec, WithVersion, } from "../../utils/codecs.js"; +import {getLightClientForkTypes, toForkName} from "../../utils/fork.js"; +import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js"; +import {MetaHeader, VersionCodec, VersionMeta} from "../../utils/metadata.js"; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes diff --git a/packages/api/src/beacon/routes/lodestar.ts b/packages/api/src/beacon/routes/lodestar.ts index 1d3c62ca2082..81191efd2696 100644 --- a/packages/api/src/beacon/routes/lodestar.ts +++ b/packages/api/src/beacon/routes/lodestar.ts @@ -1,15 +1,15 @@ import {ChainForkConfig} from "@lodestar/config"; import {Epoch, RootHex, Slot} from "@lodestar/types"; -import {Schema, Endpoint, RouteDefinitions} from "../../utils/index.js"; import { EmptyArgs, - EmptyRequestCodec, EmptyMeta, EmptyRequest, + EmptyRequestCodec, EmptyResponseCodec, EmptyResponseData, JsonOnlyResponseCodec, } from "../../utils/codecs.js"; +import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js"; import {FilterGetPeers, NodePeer, PeerDirection, PeerState} from "./node.js"; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes diff --git a/packages/api/src/beacon/routes/node.ts b/packages/api/src/beacon/routes/node.ts index c7a6c2e36361..e98c0f42ec56 100644 --- a/packages/api/src/beacon/routes/node.ts +++ b/packages/api/src/beacon/routes/node.ts @@ -1,19 +1,19 @@ import {ContainerType, ValueOf} from "@chainsafe/ssz"; import {ChainForkConfig} from "@lodestar/config"; import {ssz, stringType} from "@lodestar/types"; -import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js"; import { ArrayOf, EmptyArgs, - EmptyRequestCodec, EmptyMeta, EmptyMetaCodec, EmptyRequest, + EmptyRequestCodec, EmptyResponseCodec, EmptyResponseData, JsonOnlyResponseCodec, } from "../../utils/codecs.js"; import {HttpStatusCode} from "../../utils/httpStatusCode.js"; +import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js"; import {WireFormat} from "../../utils/wireFormat.js"; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes diff --git a/packages/api/src/beacon/routes/proof.ts b/packages/api/src/beacon/routes/proof.ts index 0c6d5a058cea..63f6765e3873 100644 --- a/packages/api/src/beacon/routes/proof.ts +++ b/packages/api/src/beacon/routes/proof.ts @@ -1,10 +1,10 @@ import {CompactMultiProof, ProofType} from "@chainsafe/persistent-merkle-tree"; import {ByteListType, ContainerType} from "@chainsafe/ssz"; -import {fromHex, toHex} from "@lodestar/utils"; import {ChainForkConfig} from "@lodestar/config"; import {ssz} from "@lodestar/types"; -import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js"; +import {fromHex, toHex} from "@lodestar/utils"; import {ArrayOf} from "../../utils/codecs.js"; +import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js"; import {VersionCodec, VersionMeta} from "../../utils/metadata.js"; export const CompactMultiProofType = new ContainerType({ diff --git a/packages/api/src/beacon/routes/validator.ts b/packages/api/src/beacon/routes/validator.ts index cf30d5748a46..313459f4db97 100644 --- a/packages/api/src/beacon/routes/validator.ts +++ b/packages/api/src/beacon/routes/validator.ts @@ -2,27 +2,24 @@ import {ContainerType, Type, ValueOf} from "@chainsafe/ssz"; import {ChainForkConfig} from "@lodestar/config"; import {isForkBlobs, isForkPostElectra} from "@lodestar/params"; import { - altair, + Attestation, BLSSignature, + BeaconBlockOrContents, + BlindedBeaconBlock, CommitteeIndex, Epoch, - phase0, + ProducedBlockSource, Root, Slot, - ssz, UintBn64, ValidatorIndex, - ProducedBlockSource, - stringType, - BeaconBlockOrContents, - BlindedBeaconBlock, - Attestation, + altair, + phase0, + ssz, sszTypesFor, + stringType, } from "@lodestar/types"; import {fromHex, toHex, toRootHex} from "@lodestar/utils"; -import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js"; -import {fromGraffitiHex, toBoolean, toGraffitiHex} from "../../utils/serdes.js"; -import {getExecutionForkTypes, toForkName} from "../../utils/fork.js"; import { ArrayOf, EmptyMeta, @@ -33,6 +30,9 @@ import { WithMeta, WithVersion, } from "../../utils/codecs.js"; +import {getExecutionForkTypes, toForkName} from "../../utils/fork.js"; +import {fromHeaders} from "../../utils/headers.js"; +import {Endpoint, RouteDefinitions, Schema} from "../../utils/index.js"; import { ExecutionOptimisticAndDependentRootCodec, ExecutionOptimisticAndDependentRootMeta, @@ -43,7 +43,7 @@ import { VersionMeta, VersionType, } from "../../utils/metadata.js"; -import {fromHeaders} from "../../utils/headers.js"; +import {fromGraffitiHex, toBoolean, toGraffitiHex} from "../../utils/serdes.js"; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes diff --git a/packages/api/src/beacon/server/events.ts b/packages/api/src/beacon/server/events.ts index b9027ab1879d..a68edb6c4146 100644 --- a/packages/api/src/beacon/server/events.ts +++ b/packages/api/src/beacon/server/events.ts @@ -1,6 +1,6 @@ import {ChainForkConfig} from "@lodestar/config"; import {ApiError, ApplicationMethods, FastifyRoutes, createFastifyRoutes} from "../../utils/server/index.js"; -import {Endpoints, getDefinitions, eventTypes, getEventSerdes} from "../routes/events.js"; +import {Endpoints, eventTypes, getDefinitions, getEventSerdes} from "../routes/events.js"; export function getRoutes(config: ChainForkConfig, methods: ApplicationMethods): FastifyRoutes { const eventSerdes = getEventSerdes(config); diff --git a/packages/api/src/beacon/server/index.ts b/packages/api/src/beacon/server/index.ts index 304f4d42be17..cc5005aa2740 100644 --- a/packages/api/src/beacon/server/index.ts +++ b/packages/api/src/beacon/server/index.ts @@ -1,5 +1,5 @@ -import type {FastifyInstance} from "fastify"; import {ChainForkConfig} from "@lodestar/config"; +import type {FastifyInstance} from "fastify"; import {ApplicationMethods, FastifyRoute} from "../../utils/server/index.js"; import {Endpoints} from "../routes/index.js"; diff --git a/packages/api/src/builder/index.ts b/packages/api/src/builder/index.ts index d1d9d31a17ab..9497cd5e95ba 100644 --- a/packages/api/src/builder/index.ts +++ b/packages/api/src/builder/index.ts @@ -1,7 +1,7 @@ import {ChainForkConfig} from "@lodestar/config"; import {HttpClient, HttpClientModules, HttpClientOptions, IHttpClient} from "../utils/client/httpClient.js"; -import {Endpoints} from "./routes.js"; import type {ApiClient} from "./client.js"; +import {Endpoints} from "./routes.js"; import * as builder from "./client.js"; diff --git a/packages/api/src/builder/routes.ts b/packages/api/src/builder/routes.ts index 3911a515e1c6..91042539f96b 100644 --- a/packages/api/src/builder/routes.ts +++ b/packages/api/src/builder/routes.ts @@ -1,27 +1,25 @@ +import {ChainForkConfig} from "@lodestar/config"; +import {ForkName, isForkBlobs} from "@lodestar/params"; import { - ssz, - bellatrix, - Slot, - Root, BLSPubkey, ExecutionPayload, ExecutionPayloadAndBlobsBundle, + Root, SignedBlindedBeaconBlock, SignedBuilderBid, + Slot, WithOptionalBytes, + bellatrix, + ssz, } from "@lodestar/types"; -import {ForkName, isForkBlobs} from "@lodestar/params"; -import {ChainForkConfig} from "@lodestar/config"; import {fromHex, toPubkeyHex, toRootHex} from "@lodestar/utils"; -import {Endpoint, RouteDefinitions, Schema} from "../utils/index.js"; -import {MetaHeader, VersionCodec, VersionMeta} from "../utils/metadata.js"; import { ArrayOf, EmptyArgs, - EmptyRequestCodec, EmptyMeta, EmptyRequest, + EmptyRequestCodec, EmptyResponseCodec, EmptyResponseData, JsonOnlyReq, @@ -29,6 +27,8 @@ import { } from "../utils/codecs.js"; import {getBlobsForkTypes, getExecutionForkTypes, toForkName} from "../utils/fork.js"; import {fromHeaders} from "../utils/headers.js"; +import {Endpoint, RouteDefinitions, Schema} from "../utils/index.js"; +import {MetaHeader, VersionCodec, VersionMeta} from "../utils/metadata.js"; // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes diff --git a/packages/api/src/builder/server/index.ts b/packages/api/src/builder/server/index.ts index 888d6bb64bec..5e59e5d9807b 100644 --- a/packages/api/src/builder/server/index.ts +++ b/packages/api/src/builder/server/index.ts @@ -1,8 +1,8 @@ -import type {FastifyInstance} from "fastify"; import {ChainForkConfig} from "@lodestar/config"; +import type {FastifyInstance} from "fastify"; +import {AnyEndpoint} from "../../utils/codecs.js"; import {ApplicationMethods, FastifyRoute, FastifyRoutes, createFastifyRoutes} from "../../utils/server/index.js"; import {Endpoints, getDefinitions} from "../routes.js"; -import {AnyEndpoint} from "../../utils/codecs.js"; export type BuilderApiMethods = ApplicationMethods; diff --git a/packages/api/src/keymanager/index.ts b/packages/api/src/keymanager/index.ts index 1ffcaef897eb..3034b03acdb0 100644 --- a/packages/api/src/keymanager/index.ts +++ b/packages/api/src/keymanager/index.ts @@ -1,5 +1,5 @@ import {ChainForkConfig} from "@lodestar/config"; -import {IHttpClient, HttpClient, HttpClientModules, HttpClientOptions} from "../utils/client/index.js"; +import {HttpClient, HttpClientModules, HttpClientOptions, IHttpClient} from "../utils/client/index.js"; import type {ApiClient} from "./client.js"; import * as keymanager from "./client.js"; diff --git a/packages/api/src/keymanager/routes.ts b/packages/api/src/keymanager/routes.ts index 0db096d14e83..58ad44f49115 100644 --- a/packages/api/src/keymanager/routes.ts +++ b/packages/api/src/keymanager/routes.ts @@ -1,19 +1,19 @@ import {ContainerType, ValueOf} from "@chainsafe/ssz"; import {ChainForkConfig} from "@lodestar/config"; import {Epoch, phase0, ssz, stringType} from "@lodestar/types"; -import {Schema, Endpoint, RouteDefinitions} from "../utils/index.js"; -import {WireFormat} from "../utils/wireFormat.js"; import { EmptyArgs, - EmptyRequestCodec, EmptyMeta, EmptyMetaCodec, EmptyRequest, + EmptyRequestCodec, EmptyResponseCodec, EmptyResponseData, JsonOnlyReq, JsonOnlyResponseCodec, } from "../utils/codecs.js"; +import {Endpoint, RouteDefinitions, Schema} from "../utils/index.js"; +import {WireFormat} from "../utils/wireFormat.js"; export enum ImportStatus { /** Keystore successfully decrypted and imported to keymanager permanent storage */ diff --git a/packages/api/src/keymanager/server/index.ts b/packages/api/src/keymanager/server/index.ts index f4d0e75f971e..065bcb5ac5d8 100644 --- a/packages/api/src/keymanager/server/index.ts +++ b/packages/api/src/keymanager/server/index.ts @@ -1,8 +1,8 @@ -import type {FastifyInstance} from "fastify"; import {ChainForkConfig} from "@lodestar/config"; +import type {FastifyInstance} from "fastify"; +import {AnyEndpoint} from "../../utils/codecs.js"; import {ApplicationMethods, FastifyRoute, FastifyRoutes, createFastifyRoutes} from "../../utils/server/index.js"; import {Endpoints, getDefinitions} from "../routes.js"; -import {AnyEndpoint} from "../../utils/codecs.js"; export type KeymanagerApiMethods = ApplicationMethods; diff --git a/packages/api/src/utils/client/httpClient.ts b/packages/api/src/utils/client/httpClient.ts index 33b93e3a9d41..85585e8f40f7 100644 --- a/packages/api/src/utils/client/httpClient.ts +++ b/packages/api/src/utils/client/httpClient.ts @@ -1,8 +1,10 @@ import {ErrorAborted, Logger, MapDef, TimeoutError, isValidHttpUrl, retry, toPrintableUrl} from "@lodestar/utils"; import {mergeHeaders} from "../headers.js"; +import {HttpStatusCode} from "../httpStatusCode.js"; import {Endpoint} from "../types.js"; import {WireFormat} from "../wireFormat.js"; -import {HttpStatusCode} from "../httpStatusCode.js"; +import {fetch, isFetchError} from "./fetch.js"; +import {Metrics} from "./metrics.js"; import { ApiRequestInit, ApiRequestInitRequired, @@ -13,8 +15,6 @@ import { createApiRequest, } from "./request.js"; import {ApiResponse} from "./response.js"; -import {Metrics} from "./metrics.js"; -import {fetch, isFetchError} from "./fetch.js"; /** A higher default timeout, validator will set its own shorter timeoutMs */ const DEFAULT_TIMEOUT_MS = 60_000; diff --git a/packages/api/src/utils/codecs.ts b/packages/api/src/utils/codecs.ts index c075d8592a46..fad6396af085 100644 --- a/packages/api/src/utils/codecs.ts +++ b/packages/api/src/utils/codecs.ts @@ -2,12 +2,12 @@ import {ArrayType, ListBasicType, ListCompositeType, Type, isBasicType, isCompos import {ForkName} from "@lodestar/params"; import {objectToExpectedCase} from "@lodestar/utils"; import { - RequestWithoutBodyCodec, + Endpoint, RequestWithBodyCodec, + RequestWithoutBodyCodec, ResponseCodec, ResponseDataCodec, ResponseMetadataCodec, - Endpoint, SszRequestMethods, } from "./types.js"; import {WireFormat} from "./wireFormat.js"; diff --git a/packages/api/src/utils/metadata.ts b/packages/api/src/utils/metadata.ts index 2ee9b2f51f0e..6186c06a7047 100644 --- a/packages/api/src/utils/metadata.ts +++ b/packages/api/src/utils/metadata.ts @@ -1,10 +1,10 @@ import {ContainerType, ValueOf} from "@chainsafe/ssz"; import {ForkName} from "@lodestar/params"; import {StringType, ssz, stringType} from "@lodestar/types"; -import {ResponseMetadataCodec} from "./types.js"; -import {toBoolean} from "./serdes.js"; import {toForkName} from "./fork.js"; import {HttpHeader} from "./headers.js"; +import {toBoolean} from "./serdes.js"; +import {ResponseMetadataCodec} from "./types.js"; export const VersionType = new ContainerType({ /** diff --git a/packages/api/src/utils/server/handler.ts b/packages/api/src/utils/server/handler.ts index 035f4328141a..b444d263cf09 100644 --- a/packages/api/src/utils/server/handler.ts +++ b/packages/api/src/utils/server/handler.ts @@ -2,15 +2,15 @@ import type * as fastify from "fastify"; import {HttpHeader, MediaType, SUPPORTED_MEDIA_TYPES, parseAcceptHeader, parseContentTypeHeader} from "../headers.js"; import { Endpoint, - RequestData, JsonRequestData, JsonRequestMethods, + RequestData, RequestWithBodyCodec, + RequestWithoutBodyCodec, RouteDefinition, SszRequestData, SszRequestMethods, isRequestWithoutBody, - RequestWithoutBodyCodec, } from "../types.js"; import {WireFormat, fromWireFormat, getWireFormat} from "../wireFormat.js"; import {ApiError} from "./error.js"; diff --git a/packages/api/src/utils/server/route.ts b/packages/api/src/utils/server/route.ts index aa04a1f11cf7..26bf07b6790e 100644 --- a/packages/api/src/utils/server/route.ts +++ b/packages/api/src/utils/server/route.ts @@ -1,5 +1,5 @@ -import type * as fastify from "fastify"; import {mapValues} from "@lodestar/utils"; +import type * as fastify from "fastify"; import {getFastifySchema} from "../schema.js"; import {Endpoint, RouteDefinition, RouteDefinitions} from "../types.js"; import {toColonNotationPath} from "../urlFormat.js"; diff --git a/packages/api/test/unit/beacon/genericServerTest/beacon.test.ts b/packages/api/test/unit/beacon/genericServerTest/beacon.test.ts index f8c13b33afb6..5f2c2d4d50e7 100644 --- a/packages/api/test/unit/beacon/genericServerTest/beacon.test.ts +++ b/packages/api/test/unit/beacon/genericServerTest/beacon.test.ts @@ -1,7 +1,7 @@ -import {describe} from "vitest"; import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; -import {Endpoints} from "../../../../src/beacon/routes/beacon/index.js"; +import {describe} from "vitest"; import {getClient} from "../../../../src/beacon/client/beacon.js"; +import {Endpoints} from "../../../../src/beacon/routes/beacon/index.js"; import {getRoutes} from "../../../../src/beacon/server/beacon.js"; import {runGenericServerTest} from "../../../utils/genericServerTest.js"; import {testData} from "../testData/beacon.js"; diff --git a/packages/api/test/unit/beacon/genericServerTest/config.test.ts b/packages/api/test/unit/beacon/genericServerTest/config.test.ts index 91075f96d1e3..a66eb1768e2c 100644 --- a/packages/api/test/unit/beacon/genericServerTest/config.test.ts +++ b/packages/api/test/unit/beacon/genericServerTest/config.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; import {config} from "@lodestar/config/default"; -import {Endpoints, getDefinitions} from "../../../../src/beacon/routes/config.js"; +import {describe, expect, it} from "vitest"; import {getClient} from "../../../../src/beacon/client/config.js"; +import {Endpoints, getDefinitions} from "../../../../src/beacon/routes/config.js"; import {getRoutes} from "../../../../src/beacon/server/config.js"; import {runGenericServerTest} from "../../../utils/genericServerTest.js"; import {testData} from "../testData/config.js"; diff --git a/packages/api/test/unit/beacon/genericServerTest/debug.test.ts b/packages/api/test/unit/beacon/genericServerTest/debug.test.ts index f329382dbe46..d6140fa20512 100644 --- a/packages/api/test/unit/beacon/genericServerTest/debug.test.ts +++ b/packages/api/test/unit/beacon/genericServerTest/debug.test.ts @@ -1,19 +1,19 @@ -import {describe, it, expect, beforeAll, afterAll, vi} from "vitest"; import {toHexString} from "@chainsafe/ssz"; -import {FastifyInstance} from "fastify"; +import {config} from "@lodestar/config/default"; import {ForkName} from "@lodestar/params"; import {ssz} from "@lodestar/types"; -import {config} from "@lodestar/config/default"; -import {Endpoints, getDefinitions} from "../../../../src/beacon/routes/debug.js"; +import {FastifyInstance} from "fastify"; +import {afterAll, beforeAll, describe, expect, it, vi} from "vitest"; import {getClient} from "../../../../src/beacon/client/debug.js"; +import {Endpoints, getDefinitions} from "../../../../src/beacon/routes/debug.js"; import {getRoutes} from "../../../../src/beacon/server/debug.js"; -import {runGenericServerTest} from "../../../utils/genericServerTest.js"; -import {getMockApi, getTestServer} from "../../../utils/utils.js"; import {HttpClient} from "../../../../src/utils/client/httpClient.js"; -import {testData} from "../testData/debug.js"; -import {FastifyRoute} from "../../../../src/utils/server/index.js"; import {AnyEndpoint} from "../../../../src/utils/codecs.js"; +import {FastifyRoute} from "../../../../src/utils/server/index.js"; import {WireFormat} from "../../../../src/utils/wireFormat.js"; +import {runGenericServerTest} from "../../../utils/genericServerTest.js"; +import {getMockApi, getTestServer} from "../../../utils/utils.js"; +import {testData} from "../testData/debug.js"; describe("beacon / debug", () => { // Extend timeout since states are very big diff --git a/packages/api/test/unit/beacon/genericServerTest/events.test.ts b/packages/api/test/unit/beacon/genericServerTest/events.test.ts index 16123ec624e8..c0480c8368c9 100644 --- a/packages/api/test/unit/beacon/genericServerTest/events.test.ts +++ b/packages/api/test/unit/beacon/genericServerTest/events.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect, beforeEach, afterEach, beforeAll, afterAll} from "vitest"; -import {FastifyInstance} from "fastify"; -import {sleep} from "@lodestar/utils"; import {config} from "@lodestar/config/default"; -import {Endpoints, getDefinitions, EventType, BeaconEvent} from "../../../../src/beacon/routes/events.js"; +import {sleep} from "@lodestar/utils"; +import {FastifyInstance} from "fastify"; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from "vitest"; import {getClient} from "../../../../src/beacon/client/events.js"; +import {BeaconEvent, Endpoints, EventType, getDefinitions} from "../../../../src/beacon/routes/events.js"; import {getRoutes} from "../../../../src/beacon/server/events.js"; import {getMockApi, getTestServer} from "../../../utils/utils.js"; import {eventTestData} from "../testData/events.js"; diff --git a/packages/api/test/unit/beacon/genericServerTest/lightclient.test.ts b/packages/api/test/unit/beacon/genericServerTest/lightclient.test.ts index 5bf8b7827161..84c06d2a0d17 100644 --- a/packages/api/test/unit/beacon/genericServerTest/lightclient.test.ts +++ b/packages/api/test/unit/beacon/genericServerTest/lightclient.test.ts @@ -1,7 +1,7 @@ -import {describe} from "vitest"; import {config} from "@lodestar/config/default"; -import {Endpoints} from "../../../../src/beacon/routes/lightclient.js"; +import {describe} from "vitest"; import {getClient} from "../../../../src/beacon/client/lightclient.js"; +import {Endpoints} from "../../../../src/beacon/routes/lightclient.js"; import {getRoutes} from "../../../../src/beacon/server/lightclient.js"; import {runGenericServerTest} from "../../../utils/genericServerTest.js"; import {testData} from "../testData/lightclient.js"; diff --git a/packages/api/test/unit/beacon/genericServerTest/node.test.ts b/packages/api/test/unit/beacon/genericServerTest/node.test.ts index 0affaf014c4a..c54737b387ae 100644 --- a/packages/api/test/unit/beacon/genericServerTest/node.test.ts +++ b/packages/api/test/unit/beacon/genericServerTest/node.test.ts @@ -1,7 +1,7 @@ -import {describe} from "vitest"; import {config} from "@lodestar/config/default"; -import {Endpoints} from "../../../../src/beacon/routes/node.js"; +import {describe} from "vitest"; import {getClient} from "../../../../src/beacon/client/node.js"; +import {Endpoints} from "../../../../src/beacon/routes/node.js"; import {getRoutes} from "../../../../src/beacon/server/node.js"; import {runGenericServerTest} from "../../../utils/genericServerTest.js"; import {testData} from "../testData/node.js"; diff --git a/packages/api/test/unit/beacon/genericServerTest/proofs.test.ts b/packages/api/test/unit/beacon/genericServerTest/proofs.test.ts index d31137886e2f..518c3f70381d 100644 --- a/packages/api/test/unit/beacon/genericServerTest/proofs.test.ts +++ b/packages/api/test/unit/beacon/genericServerTest/proofs.test.ts @@ -1,7 +1,7 @@ -import {describe} from "vitest"; import {config} from "@lodestar/config/default"; -import {Endpoints} from "../../../../src/beacon/routes/proof.js"; +import {describe} from "vitest"; import {getClient} from "../../../../src/beacon/client/proof.js"; +import {Endpoints} from "../../../../src/beacon/routes/proof.js"; import {getRoutes} from "../../../../src/beacon/server/proof.js"; import {runGenericServerTest} from "../../../utils/genericServerTest.js"; import {testData} from "../testData/proofs.js"; diff --git a/packages/api/test/unit/beacon/genericServerTest/validator.test.ts b/packages/api/test/unit/beacon/genericServerTest/validator.test.ts index 0aed65cd6f17..650bc6c8f9a2 100644 --- a/packages/api/test/unit/beacon/genericServerTest/validator.test.ts +++ b/packages/api/test/unit/beacon/genericServerTest/validator.test.ts @@ -1,7 +1,7 @@ -import {describe} from "vitest"; import {config} from "@lodestar/config/default"; -import {Endpoints} from "../../../../src/beacon/routes/validator.js"; +import {describe} from "vitest"; import {getClient} from "../../../../src/beacon/client/validator.js"; +import {Endpoints} from "../../../../src/beacon/routes/validator.js"; import {getRoutes} from "../../../../src/beacon/server/validator.js"; import {runGenericServerTest} from "../../../utils/genericServerTest.js"; import {testData} from "../testData/validator.js"; diff --git a/packages/api/test/unit/beacon/oapiSpec.test.ts b/packages/api/test/unit/beacon/oapiSpec.test.ts index f6a38505e264..a3033355c984 100644 --- a/packages/api/test/unit/beacon/oapiSpec.test.ts +++ b/packages/api/test/unit/beacon/oapiSpec.test.ts @@ -1,11 +1,11 @@ import path from "node:path"; import {fileURLToPath} from "node:url"; -import {describe, it, beforeAll, expect} from "vitest"; import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; -import {OpenApiFile} from "../../utils/parseOpenApiSpec.js"; +import {beforeAll, describe, expect, it} from "vitest"; import {routes} from "../../../src/beacon/index.js"; import {IgnoredProperty, runTestCheckAgainstSpec} from "../../utils/checkAgainstSpec.js"; import {fetchOpenApiSpec} from "../../utils/fetchOpenApiSpec.js"; +import {OpenApiFile} from "../../utils/parseOpenApiSpec.js"; // Import all testData and merge below import {testData as beaconTestData} from "./testData/beacon.js"; import {testData as configTestData} from "./testData/config.js"; diff --git a/packages/api/test/unit/beacon/testData/config.ts b/packages/api/test/unit/beacon/testData/config.ts index dddc90ae6b25..ab0437650df7 100644 --- a/packages/api/test/unit/beacon/testData/config.ts +++ b/packages/api/test/unit/beacon/testData/config.ts @@ -1,7 +1,7 @@ -import {ssz} from "@lodestar/types"; import {chainConfigToJson} from "@lodestar/config"; import {chainConfig} from "@lodestar/config/default"; import {activePreset, presetToJson} from "@lodestar/params"; +import {ssz} from "@lodestar/types"; import {Endpoints} from "../../../../src/beacon/routes/config.js"; import {GenericServerTestCases} from "../../../utils/genericServerTest.js"; diff --git a/packages/api/test/unit/beacon/testData/events.ts b/packages/api/test/unit/beacon/testData/events.ts index 3d2ffb708965..c9ba39d24efe 100644 --- a/packages/api/test/unit/beacon/testData/events.ts +++ b/packages/api/test/unit/beacon/testData/events.ts @@ -1,5 +1,5 @@ -import {ssz} from "@lodestar/types"; import {ForkName} from "@lodestar/params"; +import {ssz} from "@lodestar/types"; import {Endpoints, EventData, EventType, blobSidecarSSE} from "../../../../src/beacon/routes/events.js"; import {GenericServerTestCases} from "../../../utils/genericServerTest.js"; diff --git a/packages/api/test/unit/beacon/testData/lightclient.ts b/packages/api/test/unit/beacon/testData/lightclient.ts index f405d514fc5d..715f823a1d29 100644 --- a/packages/api/test/unit/beacon/testData/lightclient.ts +++ b/packages/api/test/unit/beacon/testData/lightclient.ts @@ -1,6 +1,6 @@ import {toHexString} from "@chainsafe/ssz"; -import {ssz} from "@lodestar/types"; import {ForkName} from "@lodestar/params"; +import {ssz} from "@lodestar/types"; import {Endpoints} from "../../../../src/beacon/routes/lightclient.js"; import {GenericServerTestCases} from "../../../utils/genericServerTest.js"; diff --git a/packages/api/test/unit/beacon/testData/validator.ts b/packages/api/test/unit/beacon/testData/validator.ts index d4fae4bfe290..327100cedab1 100644 --- a/packages/api/test/unit/beacon/testData/validator.ts +++ b/packages/api/test/unit/beacon/testData/validator.ts @@ -1,5 +1,5 @@ import {ForkName} from "@lodestar/params"; -import {ssz, ProducedBlockSource} from "@lodestar/types"; +import {ProducedBlockSource, ssz} from "@lodestar/types"; import {BuilderSelection, Endpoints} from "../../../../src/beacon/routes/validator.js"; import {GenericServerTestCases} from "../../../utils/genericServerTest.js"; diff --git a/packages/api/test/unit/builder/builder.test.ts b/packages/api/test/unit/builder/builder.test.ts index d2e25916069e..00a38563a100 100644 --- a/packages/api/test/unit/builder/builder.test.ts +++ b/packages/api/test/unit/builder/builder.test.ts @@ -1,7 +1,7 @@ -import {describe} from "vitest"; import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; -import {Endpoints} from "../../../src/builder/routes.js"; +import {describe} from "vitest"; import {getClient} from "../../../src/builder/client.js"; +import {Endpoints} from "../../../src/builder/routes.js"; import {getRoutes} from "../../../src/builder/server/index.js"; import {runGenericServerTest} from "../../utils/genericServerTest.js"; import {testData} from "./testData.js"; diff --git a/packages/api/test/unit/builder/oapiSpec.test.ts b/packages/api/test/unit/builder/oapiSpec.test.ts index d972b64905e5..8f567a5c0e1e 100644 --- a/packages/api/test/unit/builder/oapiSpec.test.ts +++ b/packages/api/test/unit/builder/oapiSpec.test.ts @@ -2,10 +2,10 @@ import path from "node:path"; import {fileURLToPath} from "node:url"; import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; -import {OpenApiFile} from "../../utils/parseOpenApiSpec.js"; import {getDefinitions} from "../../../src/builder/routes.js"; import {runTestCheckAgainstSpec} from "../../utils/checkAgainstSpec.js"; import {fetchOpenApiSpec} from "../../utils/fetchOpenApiSpec.js"; +import {OpenApiFile} from "../../utils/parseOpenApiSpec.js"; import {testData} from "./testData.js"; // Global variable __dirname no longer available in ES6 modules. diff --git a/packages/api/test/unit/builder/testData.ts b/packages/api/test/unit/builder/testData.ts index a807620258df..ad0ce95f5a8b 100644 --- a/packages/api/test/unit/builder/testData.ts +++ b/packages/api/test/unit/builder/testData.ts @@ -1,6 +1,6 @@ import {fromHexString} from "@chainsafe/ssz"; -import {ssz} from "@lodestar/types"; import {ForkName} from "@lodestar/params"; +import {ssz} from "@lodestar/types"; import {Endpoints} from "../../../src/builder/routes.js"; import {GenericServerTestCases} from "../../utils/genericServerTest.js"; diff --git a/packages/api/test/unit/client/fetch.test.ts b/packages/api/test/unit/client/fetch.test.ts index 1faf7d979a02..067e97e4ba6a 100644 --- a/packages/api/test/unit/client/fetch.test.ts +++ b/packages/api/test/unit/client/fetch.test.ts @@ -1,6 +1,6 @@ import crypto from "node:crypto"; import http from "node:http"; -import {describe, it, expect, afterEach} from "vitest"; +import {afterEach, describe, expect, it} from "vitest"; import {FetchError, FetchErrorType, fetch} from "../../../src/utils/client/fetch.js"; describe("FetchError", () => { diff --git a/packages/api/test/unit/client/httpClient.test.ts b/packages/api/test/unit/client/httpClient.test.ts index 577b860c4cca..aa689967f7b4 100644 --- a/packages/api/test/unit/client/httpClient.test.ts +++ b/packages/api/test/unit/client/httpClient.test.ts @@ -1,26 +1,26 @@ import {IncomingMessage} from "node:http"; -import {describe, it, afterEach, expect, vi} from "vitest"; -import {RouteOptions, fastify} from "fastify"; import {BooleanType, ContainerType, UintNumberType, ValueOf} from "@chainsafe/ssz"; import {ErrorAborted, TimeoutError, toBase64} from "@lodestar/utils"; +import {RouteOptions, fastify} from "fastify"; +import {afterEach, describe, expect, it, vi} from "vitest"; +import {WireFormat} from "../../../src/index.js"; +import {addSszContentTypeParser} from "../../../src/server/index.js"; import {HttpClient, RouteDefinitionExtra} from "../../../src/utils/client/index.js"; -import {HttpStatusCode} from "../../../src/utils/httpStatusCode.js"; import { AnyEndpoint, EmptyArgs, - EmptyRequestCodec, EmptyMeta, EmptyRequest, + EmptyRequestCodec, EmptyResponseCodec, + EmptyResponseData, JsonOnlyReq, JsonOnlyResponseCodec, - EmptyResponseData, } from "../../../src/utils/codecs.js"; -import {compileRouteUrlFormatter} from "../../../src/utils/urlFormat.js"; -import {Endpoint, Schema} from "../../../src/utils/index.js"; -import {WireFormat} from "../../../src/index.js"; import {HttpHeader, MediaType} from "../../../src/utils/headers.js"; -import {addSszContentTypeParser} from "../../../src/server/index.js"; +import {HttpStatusCode} from "../../../src/utils/httpStatusCode.js"; +import {Endpoint, Schema} from "../../../src/utils/index.js"; +import {compileRouteUrlFormatter} from "../../../src/utils/urlFormat.js"; /* eslint-disable @typescript-eslint/return-await */ diff --git a/packages/api/test/unit/client/httpClientOptions.test.ts b/packages/api/test/unit/client/httpClientOptions.test.ts index 9bc7ab2bfaf8..b2eb374e26c9 100644 --- a/packages/api/test/unit/client/httpClientOptions.test.ts +++ b/packages/api/test/unit/client/httpClientOptions.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {HttpClient} from "../../../src/index.js"; describe("HTTPClient options", () => { diff --git a/packages/api/test/unit/client/urlFormat.test.ts b/packages/api/test/unit/client/urlFormat.test.ts index 5132044b7631..a97a2dfe94a1 100644 --- a/packages/api/test/unit/client/urlFormat.test.ts +++ b/packages/api/test/unit/client/urlFormat.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { - compileRouteUrlFormatter, - toColonNotationPath, Token, TokenType, + compileRouteUrlFormatter, + toColonNotationPath, urlToTokens, } from "../../../src/utils/urlFormat.js"; diff --git a/packages/api/test/unit/keymanager/keymanager.test.ts b/packages/api/test/unit/keymanager/keymanager.test.ts index 42e6a3dbf511..64778dcab7fc 100644 --- a/packages/api/test/unit/keymanager/keymanager.test.ts +++ b/packages/api/test/unit/keymanager/keymanager.test.ts @@ -1,7 +1,7 @@ -import {describe} from "vitest"; import {config} from "@lodestar/config/default"; -import {Endpoints} from "../../../src/keymanager/routes.js"; +import {describe} from "vitest"; import {getClient} from "../../../src/keymanager/client.js"; +import {Endpoints} from "../../../src/keymanager/routes.js"; import {getRoutes} from "../../../src/keymanager/server/index.js"; import {runGenericServerTest} from "../../utils/genericServerTest.js"; import {testData} from "./testData.js"; diff --git a/packages/api/test/unit/keymanager/oapiSpec.test.ts b/packages/api/test/unit/keymanager/oapiSpec.test.ts index aab4e1823ab0..d3817598029b 100644 --- a/packages/api/test/unit/keymanager/oapiSpec.test.ts +++ b/packages/api/test/unit/keymanager/oapiSpec.test.ts @@ -1,10 +1,10 @@ import path from "node:path"; import {fileURLToPath} from "node:url"; import {config} from "@lodestar/config/default"; -import {OpenApiFile} from "../../utils/parseOpenApiSpec.js"; import {getDefinitions} from "../../../src/keymanager/routes.js"; import {runTestCheckAgainstSpec} from "../../utils/checkAgainstSpec.js"; import {fetchOpenApiSpec} from "../../utils/fetchOpenApiSpec.js"; +import {OpenApiFile} from "../../utils/parseOpenApiSpec.js"; import {testData} from "./testData.js"; // Global variable __dirname no longer available in ES6 modules. diff --git a/packages/api/test/unit/utils/headers.test.ts b/packages/api/test/unit/utils/headers.test.ts index 3416335b0dcd..a96a36233505 100644 --- a/packages/api/test/unit/utils/headers.test.ts +++ b/packages/api/test/unit/utils/headers.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {MediaType, SUPPORTED_MEDIA_TYPES, mergeHeaders, parseAcceptHeader} from "../../../src/utils/headers.js"; describe("utils / headers", () => { diff --git a/packages/api/test/unit/utils/serdes.test.ts b/packages/api/test/unit/utils/serdes.test.ts index 5b55ef66805e..e9e178782bb2 100644 --- a/packages/api/test/unit/utils/serdes.test.ts +++ b/packages/api/test/unit/utils/serdes.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {fromGraffitiHex, toGraffitiHex} from "../../../src/utils/serdes.js"; describe("utils / serdes", () => { diff --git a/packages/api/test/utils/checkAgainstSpec.ts b/packages/api/test/utils/checkAgainstSpec.ts index a3f943ad4816..be076dfeb381 100644 --- a/packages/api/test/utils/checkAgainstSpec.ts +++ b/packages/api/test/utils/checkAgainstSpec.ts @@ -1,9 +1,9 @@ import Ajv, {ErrorObject} from "ajv"; -import {expect, describe, beforeAll, it} from "vitest"; -import {WireFormat} from "../../src/utils/wireFormat.js"; +import {beforeAll, describe, expect, it} from "vitest"; import {Endpoint, RequestWithBodyCodec, RouteDefinitions, isRequestWithoutBody} from "../../src/utils/types.js"; -import {applyRecursively, JsonSchema, OpenApiJson, parseOpenApiSpec} from "./parseOpenApiSpec.js"; +import {WireFormat} from "../../src/utils/wireFormat.js"; import {GenericServerTestCases} from "./genericServerTest.js"; +import {JsonSchema, OpenApiJson, applyRecursively, parseOpenApiSpec} from "./parseOpenApiSpec.js"; const ajv = new Ajv({ strict: true, diff --git a/packages/api/test/utils/genericServerTest.ts b/packages/api/test/utils/genericServerTest.ts index 1c01bb449306..3223ff5ca5a5 100644 --- a/packages/api/test/utils/genericServerTest.ts +++ b/packages/api/test/utils/genericServerTest.ts @@ -1,10 +1,10 @@ -import {it, expect, describe, beforeAll, afterAll, MockInstance} from "vitest"; -import {FastifyInstance} from "fastify"; import {ChainForkConfig} from "@lodestar/config"; +import {FastifyInstance} from "fastify"; +import {MockInstance, afterAll, beforeAll, describe, expect, it} from "vitest"; +import {ApiClientMethods, ApiRequestInit, HttpClient, IHttpClient} from "../../src/utils/client/index.js"; import {Endpoint} from "../../src/utils/index.js"; -import {WireFormat} from "../../src/utils/wireFormat.js"; import {ApplicationMethods, ApplicationResponse, FastifyRoutes} from "../../src/utils/server/index.js"; -import {ApiClientMethods, ApiRequestInit, HttpClient, IHttpClient} from "../../src/utils/client/index.js"; +import {WireFormat} from "../../src/utils/wireFormat.js"; import {getMockApi, getTestServer} from "./utils.js"; export type GenericServerTestCases> = { diff --git a/packages/api/test/utils/utils.ts b/packages/api/test/utils/utils.ts index d3ecbc964435..26302db60792 100644 --- a/packages/api/test/utils/utils.ts +++ b/packages/api/test/utils/utils.ts @@ -1,7 +1,7 @@ -import {MockedObject, vi} from "vitest"; -import {parse as parseQueryString} from "qs"; -import {FastifyInstance, fastify} from "fastify"; import {mapValues} from "@lodestar/utils"; +import {FastifyInstance, fastify} from "fastify"; +import {parse as parseQueryString} from "qs"; +import {MockedObject, vi} from "vitest"; import {Endpoint} from "../../src/utils/index.js"; import {ApplicationMethods, addSszContentTypeParser} from "../../src/utils/server/index.js"; diff --git a/packages/beacon-node/src/api/impl/api.ts b/packages/beacon-node/src/api/impl/api.ts index 3647feed2d7c..65d79112f50c 100644 --- a/packages/beacon-node/src/api/impl/api.ts +++ b/packages/beacon-node/src/api/impl/api.ts @@ -1,6 +1,5 @@ import {BeaconApiMethods} from "@lodestar/api/beacon/server"; import {ApiOptions} from "../options.js"; -import {ApiModules} from "./types.js"; import {getBeaconApi} from "./beacon/index.js"; import {getConfigApi} from "./config/index.js"; import {getDebugApi} from "./debug/index.js"; @@ -9,6 +8,7 @@ import {getLightclientApi} from "./lightclient/index.js"; import {getLodestarApi} from "./lodestar/index.js"; import {getNodeApi} from "./node/index.js"; import {getProofApi} from "./proof/index.js"; +import {ApiModules} from "./types.js"; import {getValidatorApi} from "./validator/index.js"; export function getApi(opts: ApiOptions, modules: ApiModules): BeaconApiMethods { diff --git a/packages/beacon-node/src/api/impl/beacon/blocks/index.ts b/packages/beacon-node/src/api/impl/beacon/blocks/index.ts index 2d36505d822a..bda72bc3b997 100644 --- a/packages/beacon-node/src/api/impl/beacon/blocks/index.ts +++ b/packages/beacon-node/src/api/impl/beacon/blocks/index.ts @@ -1,40 +1,40 @@ import {routes} from "@lodestar/api"; import {ApiError, ApplicationMethods} from "@lodestar/api/server"; +import {ForkExecution, SLOTS_PER_HISTORICAL_ROOT, isForkExecution, isForkPostElectra} from "@lodestar/params"; import { computeEpochAtSlot, computeTimeAtSlot, reconstructFullBlockOrContents, signedBeaconBlockToBlinded, } from "@lodestar/state-transition"; -import {ForkExecution, SLOTS_PER_HISTORICAL_ROOT, isForkExecution, isForkPostElectra} from "@lodestar/params"; -import {sleep, fromHex, toRootHex} from "@lodestar/utils"; import { - deneb, - isSignedBlockContents, ProducedBlockSource, SignedBeaconBlock, SignedBeaconBlockOrContents, SignedBlindedBeaconBlock, WithOptionalBytes, + deneb, + isSignedBlockContents, } from "@lodestar/types"; +import {fromHex, sleep, toRootHex} from "@lodestar/utils"; import { - BlockSource, - getBlockInput, - ImportBlockOpts, - BlockInput, BlobsSource, + BlockInput, BlockInputDataBlobs, + BlockSource, + ImportBlockOpts, + getBlockInput, } from "../../../../chain/blocks/types.js"; -import {promiseAllMaybeAsync} from "../../../../util/promises.js"; -import {isOptimisticBlock} from "../../../../util/forkChoice.js"; -import {computeBlobSidecars} from "../../../../util/blobs.js"; +import {verifyBlocksInEpoch} from "../../../../chain/blocks/verifyBlock.js"; +import {BeaconChain} from "../../../../chain/chain.js"; import {BlockError, BlockErrorCode, BlockGossipError} from "../../../../chain/errors/index.js"; +import {validateGossipBlock} from "../../../../chain/validation/block.js"; import {OpSource} from "../../../../metrics/validatorMonitor.js"; import {NetworkEvent} from "../../../../network/index.js"; +import {computeBlobSidecars} from "../../../../util/blobs.js"; +import {isOptimisticBlock} from "../../../../util/forkChoice.js"; +import {promiseAllMaybeAsync} from "../../../../util/promises.js"; import {ApiModules} from "../../types.js"; -import {validateGossipBlock} from "../../../../chain/validation/block.js"; -import {verifyBlocksInEpoch} from "../../../../chain/blocks/verifyBlock.js"; -import {BeaconChain} from "../../../../chain/chain.js"; import {getBlockResponse, toBeaconHeaderResponse} from "./utils.js"; type PublishBlockOpts = ImportBlockOpts; diff --git a/packages/beacon-node/src/api/impl/beacon/blocks/utils.ts b/packages/beacon-node/src/api/impl/beacon/blocks/utils.ts index 44152ff4b8a9..b1030c6de58b 100644 --- a/packages/beacon-node/src/api/impl/beacon/blocks/utils.ts +++ b/packages/beacon-node/src/api/impl/beacon/blocks/utils.ts @@ -1,12 +1,12 @@ import {routes} from "@lodestar/api"; -import {blockToHeader} from "@lodestar/state-transition"; import {ChainForkConfig} from "@lodestar/config"; -import {RootHex, SignedBeaconBlock, Slot} from "@lodestar/types"; import {IForkChoice} from "@lodestar/fork-choice"; -import {GENESIS_SLOT} from "../../../../constants/index.js"; -import {ApiError, ValidationError} from "../../errors.js"; +import {blockToHeader} from "@lodestar/state-transition"; +import {RootHex, SignedBeaconBlock, Slot} from "@lodestar/types"; import {IBeaconChain} from "../../../../chain/interface.js"; +import {GENESIS_SLOT} from "../../../../constants/index.js"; import {rootHexRegex} from "../../../../eth1/provider/utils.js"; +import {ApiError, ValidationError} from "../../errors.js"; export function toBeaconHeaderResponse( config: ChainForkConfig, diff --git a/packages/beacon-node/src/api/impl/beacon/index.ts b/packages/beacon-node/src/api/impl/beacon/index.ts index 2e75dc76782c..0003e9c97878 100644 --- a/packages/beacon-node/src/api/impl/beacon/index.ts +++ b/packages/beacon-node/src/api/impl/beacon/index.ts @@ -3,8 +3,8 @@ import {ApplicationMethods} from "@lodestar/api/server"; import {ApiModules} from "../types.js"; import {getBeaconBlockApi} from "./blocks/index.js"; import {getBeaconPoolApi} from "./pool/index.js"; -import {getBeaconStateApi} from "./state/index.js"; import {getBeaconRewardsApi} from "./rewards/index.js"; +import {getBeaconStateApi} from "./state/index.js"; export function getBeaconApi( modules: Pick diff --git a/packages/beacon-node/src/api/impl/beacon/pool/index.ts b/packages/beacon-node/src/api/impl/beacon/pool/index.ts index 9343dd67a399..45fb763d9540 100644 --- a/packages/beacon-node/src/api/impl/beacon/pool/index.ts +++ b/packages/beacon-node/src/api/impl/beacon/pool/index.ts @@ -1,22 +1,22 @@ import {routes} from "@lodestar/api"; import {ApplicationMethods} from "@lodestar/api/server"; -import {Attestation, Epoch, isElectraAttestation, ssz} from "@lodestar/types"; import {ForkName, SYNC_COMMITTEE_SUBNET_SIZE, isForkPostElectra} from "@lodestar/params"; -import {validateApiAttestation} from "../../../../chain/validation/index.js"; -import {validateApiAttesterSlashing} from "../../../../chain/validation/attesterSlashing.js"; -import {validateApiProposerSlashing} from "../../../../chain/validation/proposerSlashing.js"; -import {validateApiVoluntaryExit} from "../../../../chain/validation/voluntaryExit.js"; -import {validateApiBlsToExecutionChange} from "../../../../chain/validation/blsToExecutionChange.js"; -import {validateApiSyncCommittee} from "../../../../chain/validation/syncCommittee.js"; -import {ApiModules} from "../../types.js"; +import {Attestation, Epoch, isElectraAttestation, ssz} from "@lodestar/types"; import { AttestationError, AttestationErrorCode, GossipAction, SyncCommitteeError, } from "../../../../chain/errors/index.js"; +import {validateApiAttesterSlashing} from "../../../../chain/validation/attesterSlashing.js"; +import {validateApiBlsToExecutionChange} from "../../../../chain/validation/blsToExecutionChange.js"; +import {validateApiAttestation} from "../../../../chain/validation/index.js"; +import {validateApiProposerSlashing} from "../../../../chain/validation/proposerSlashing.js"; +import {validateApiSyncCommittee} from "../../../../chain/validation/syncCommittee.js"; +import {validateApiVoluntaryExit} from "../../../../chain/validation/voluntaryExit.js"; import {validateGossipFnRetryUnknownRoot} from "../../../../network/processor/gossipHandlers.js"; import {ApiError, FailureList, IndexedError} from "../../errors.js"; +import {ApiModules} from "../../types.js"; export function getBeaconPoolApi({ chain, diff --git a/packages/beacon-node/src/api/impl/beacon/state/index.ts b/packages/beacon-node/src/api/impl/beacon/state/index.ts index a1e17b80ea84..916507cc56fc 100644 --- a/packages/beacon-node/src/api/impl/beacon/state/index.ts +++ b/packages/beacon-node/src/api/impl/beacon/state/index.ts @@ -1,5 +1,6 @@ import {routes} from "@lodestar/api"; import {ApplicationMethods} from "@lodestar/api/server"; +import {EPOCHS_PER_HISTORICAL_VECTOR} from "@lodestar/params"; import { BeaconStateAllForks, CachedBeaconStateAltair, @@ -8,12 +9,11 @@ import { getCurrentEpoch, getRandaoMix, } from "@lodestar/state-transition"; -import {EPOCHS_PER_HISTORICAL_VECTOR} from "@lodestar/params"; import {getValidatorStatus} from "@lodestar/types"; import {fromHex} from "@lodestar/utils"; import {ApiError} from "../../errors.js"; import {ApiModules} from "../../types.js"; -import {filterStateValidatorsByStatus, getStateValidatorIndex, getStateResponse, toValidatorResponse} from "./utils.js"; +import {filterStateValidatorsByStatus, getStateResponse, getStateValidatorIndex, toValidatorResponse} from "./utils.js"; export function getBeaconStateApi({ chain, diff --git a/packages/beacon-node/src/api/impl/beacon/state/utils.ts b/packages/beacon-node/src/api/impl/beacon/state/utils.ts index 392262a563be..f23fd52f0286 100644 --- a/packages/beacon-node/src/api/impl/beacon/state/utils.ts +++ b/packages/beacon-node/src/api/impl/beacon/state/utils.ts @@ -1,10 +1,10 @@ import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; import {routes} from "@lodestar/api"; +import {CheckpointWithHex, IForkChoice} from "@lodestar/fork-choice"; import {GENESIS_SLOT} from "@lodestar/params"; import {BeaconStateAllForks} from "@lodestar/state-transition"; -import {BLSPubkey, Epoch, getValidatorStatus, phase0, RootHex, Slot, ValidatorIndex} from "@lodestar/types"; +import {BLSPubkey, Epoch, RootHex, Slot, ValidatorIndex, getValidatorStatus, phase0} from "@lodestar/types"; import {fromHex} from "@lodestar/utils"; -import {CheckpointWithHex, IForkChoice} from "@lodestar/fork-choice"; import {IBeaconChain} from "../../../../chain/index.js"; import {ApiError, ValidationError} from "../../errors.js"; diff --git a/packages/beacon-node/src/api/impl/config/constants.ts b/packages/beacon-node/src/api/impl/config/constants.ts index e951da35bdd2..c55cfe7008f4 100644 --- a/packages/beacon-node/src/api/impl/config/constants.ts +++ b/packages/beacon-node/src/api/impl/config/constants.ts @@ -1,44 +1,44 @@ import { - GENESIS_SLOT, - GENESIS_EPOCH, - FAR_FUTURE_EPOCH, + ATTESTATION_SUBNET_COUNT, BASE_REWARDS_PER_EPOCH, - DEPOSIT_CONTRACT_TREE_DEPTH, - JUSTIFICATION_BITS_LENGTH, + BLOB_TX_TYPE, BLS_WITHDRAWAL_PREFIX, - ETH1_ADDRESS_WITHDRAWAL_PREFIX, - DOMAIN_BEACON_PROPOSER, + COMPOUNDING_WITHDRAWAL_PREFIX, + DEPOSIT_CONTRACT_TREE_DEPTH, + DOMAIN_AGGREGATE_AND_PROOF, + DOMAIN_APPLICATION_BUILDER, DOMAIN_BEACON_ATTESTER, - DOMAIN_RANDAO, + DOMAIN_BEACON_PROPOSER, + DOMAIN_BLS_TO_EXECUTION_CHANGE, + DOMAIN_CONTRIBUTION_AND_PROOF, DOMAIN_DEPOSIT, - DOMAIN_VOLUNTARY_EXIT, + DOMAIN_RANDAO, DOMAIN_SELECTION_PROOF, - DOMAIN_AGGREGATE_AND_PROOF, DOMAIN_SYNC_COMMITTEE, DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF, - DOMAIN_CONTRIBUTION_AND_PROOF, - DOMAIN_BLS_TO_EXECUTION_CHANGE, - DOMAIN_APPLICATION_BUILDER, - TIMELY_SOURCE_FLAG_INDEX, - TIMELY_TARGET_FLAG_INDEX, - TIMELY_HEAD_FLAG_INDEX, - TIMELY_SOURCE_WEIGHT, - TIMELY_TARGET_WEIGHT, - TIMELY_HEAD_WEIGHT, - SYNC_REWARD_WEIGHT, + DOMAIN_VOLUNTARY_EXIT, + EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION, + ETH1_ADDRESS_WITHDRAWAL_PREFIX, + FAR_FUTURE_EPOCH, + FULL_EXIT_REQUEST_AMOUNT, + GENESIS_EPOCH, + GENESIS_SLOT, + JUSTIFICATION_BITS_LENGTH, PROPOSER_WEIGHT, - WEIGHT_DENOMINATOR, - TARGET_AGGREGATORS_PER_COMMITTEE, RANDOM_SUBNETS_PER_VALIDATOR, - EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION, - ATTESTATION_SUBNET_COUNT, - TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE, SYNC_COMMITTEE_SUBNET_COUNT, - BLOB_TX_TYPE, - VERSIONED_HASH_VERSION_KZG, - COMPOUNDING_WITHDRAWAL_PREFIX, + SYNC_REWARD_WEIGHT, + TARGET_AGGREGATORS_PER_COMMITTEE, + TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE, + TIMELY_HEAD_FLAG_INDEX, + TIMELY_HEAD_WEIGHT, + TIMELY_SOURCE_FLAG_INDEX, + TIMELY_SOURCE_WEIGHT, + TIMELY_TARGET_FLAG_INDEX, + TIMELY_TARGET_WEIGHT, UNSET_DEPOSIT_REQUESTS_START_INDEX, - FULL_EXIT_REQUEST_AMOUNT, + VERSIONED_HASH_VERSION_KZG, + WEIGHT_DENOMINATOR, } from "@lodestar/params"; /** diff --git a/packages/beacon-node/src/api/impl/config/index.ts b/packages/beacon-node/src/api/impl/config/index.ts index 9b8694aa5914..f9d3924430ad 100644 --- a/packages/beacon-node/src/api/impl/config/index.ts +++ b/packages/beacon-node/src/api/impl/config/index.ts @@ -1,6 +1,6 @@ import {routes} from "@lodestar/api"; import {ApplicationMethods} from "@lodestar/api/server"; -import {chainConfigToJson, ChainConfig, specValuesToJson} from "@lodestar/config"; +import {ChainConfig, chainConfigToJson, specValuesToJson} from "@lodestar/config"; import {activePreset, presetToJson} from "@lodestar/params"; import {ApiModules} from "../types.js"; import {specConstants} from "./constants.js"; diff --git a/packages/beacon-node/src/api/impl/debug/index.ts b/packages/beacon-node/src/api/impl/debug/index.ts index e5b6450b206f..e6c104272237 100644 --- a/packages/beacon-node/src/api/impl/debug/index.ts +++ b/packages/beacon-node/src/api/impl/debug/index.ts @@ -1,12 +1,12 @@ import {routes} from "@lodestar/api"; import {ApplicationMethods} from "@lodestar/api/server"; import {ExecutionStatus} from "@lodestar/fork-choice"; -import {BeaconState} from "@lodestar/types"; import {ZERO_HASH_HEX} from "@lodestar/params"; -import {getStateResponseWithRegen} from "../beacon/state/utils.js"; -import {ApiModules} from "../types.js"; +import {BeaconState} from "@lodestar/types"; import {isOptimisticBlock} from "../../../util/forkChoice.js"; import {getStateSlotFromBytes} from "../../../util/multifork.js"; +import {getStateResponseWithRegen} from "../beacon/state/utils.js"; +import {ApiModules} from "../types.js"; export function getDebugApi({ chain, diff --git a/packages/beacon-node/src/api/impl/lightclient/index.ts b/packages/beacon-node/src/api/impl/lightclient/index.ts index 0dd366accf68..850a8312978c 100644 --- a/packages/beacon-node/src/api/impl/lightclient/index.ts +++ b/packages/beacon-node/src/api/impl/lightclient/index.ts @@ -1,9 +1,9 @@ -import {fromHex} from "@lodestar/utils"; import {routes} from "@lodestar/api"; import {ApplicationMethods} from "@lodestar/api/server"; -import {MAX_REQUEST_LIGHT_CLIENT_UPDATES, MAX_REQUEST_LIGHT_CLIENT_COMMITTEE_HASHES} from "@lodestar/params"; -import {ApiModules} from "../types.js"; +import {MAX_REQUEST_LIGHT_CLIENT_COMMITTEE_HASHES, MAX_REQUEST_LIGHT_CLIENT_UPDATES} from "@lodestar/params"; +import {fromHex} from "@lodestar/utils"; import {assertLightClientServer} from "../../../node/utils/lightclient.js"; +import {ApiModules} from "../types.js"; // TODO: Import from lightclient/server package export function getLightclientApi({ diff --git a/packages/beacon-node/src/api/impl/lodestar/index.ts b/packages/beacon-node/src/api/impl/lodestar/index.ts index f89959ad9da6..10787194f5f5 100644 --- a/packages/beacon-node/src/api/impl/lodestar/index.ts +++ b/packages/beacon-node/src/api/impl/lodestar/index.ts @@ -2,18 +2,18 @@ import fs from "node:fs"; import path from "node:path"; import {routes} from "@lodestar/api"; import {ApplicationMethods} from "@lodestar/api/server"; +import {ChainForkConfig} from "@lodestar/config"; import {Repository} from "@lodestar/db"; -import {toHex, toRootHex} from "@lodestar/utils"; +import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {getLatestWeakSubjectivityCheckpointEpoch} from "@lodestar/state-transition"; -import {ChainForkConfig} from "@lodestar/config"; import {ssz} from "@lodestar/types"; -import {SLOTS_PER_EPOCH} from "@lodestar/params"; +import {toHex, toRootHex} from "@lodestar/utils"; import {BeaconChain} from "../../../chain/index.js"; import {QueuedStateRegenerator, RegenRequest} from "../../../chain/regen/index.js"; -import {GossipType} from "../../../network/index.js"; import {IBeaconDb} from "../../../db/interface.js"; -import {ApiModules} from "../types.js"; +import {GossipType} from "../../../network/index.js"; import {profileNodeJS, writeHeapSnapshot} from "../../../util/profile.js"; +import {ApiModules} from "../types.js"; export function getLodestarApi({ chain, diff --git a/packages/beacon-node/src/api/impl/node/index.ts b/packages/beacon-node/src/api/impl/node/index.ts index bd1fb85522de..0d476df32303 100644 --- a/packages/beacon-node/src/api/impl/node/index.ts +++ b/packages/beacon-node/src/api/impl/node/index.ts @@ -1,8 +1,8 @@ import {routes} from "@lodestar/api"; import {ApplicationMethods} from "@lodestar/api/server"; +import {ApiOptions} from "../../options.js"; import {ApiError} from "../errors.js"; import {ApiModules} from "../types.js"; -import {ApiOptions} from "../../options.js"; export function getNodeApi( opts: ApiOptions, diff --git a/packages/beacon-node/src/api/impl/proof/index.ts b/packages/beacon-node/src/api/impl/proof/index.ts index 9e1a33940225..7b61e280015f 100644 --- a/packages/beacon-node/src/api/impl/proof/index.ts +++ b/packages/beacon-node/src/api/impl/proof/index.ts @@ -1,10 +1,10 @@ -import {CompactMultiProof, createProof, ProofType} from "@chainsafe/persistent-merkle-tree"; +import {CompactMultiProof, ProofType, createProof} from "@chainsafe/persistent-merkle-tree"; import {routes} from "@lodestar/api"; import {ApplicationMethods} from "@lodestar/api/server"; -import {ApiModules} from "../types.js"; -import {getStateResponse} from "../beacon/state/utils.js"; -import {getBlockResponse} from "../beacon/blocks/utils.js"; import {ApiOptions} from "../../options.js"; +import {getBlockResponse} from "../beacon/blocks/utils.js"; +import {getStateResponse} from "../beacon/state/utils.js"; +import {ApiModules} from "../types.js"; export function getProofApi( opts: ApiOptions, diff --git a/packages/beacon-node/src/api/impl/types.ts b/packages/beacon-node/src/api/impl/types.ts index 6b14e79ef998..4b2649acc556 100644 --- a/packages/beacon-node/src/api/impl/types.ts +++ b/packages/beacon-node/src/api/impl/types.ts @@ -3,9 +3,9 @@ import {Logger} from "@lodestar/utils"; import {IBeaconChain} from "../../chain/index.js"; import {IBeaconDb} from "../../db/index.js"; -import {IBeaconSync} from "../../sync/index.js"; -import {INetwork} from "../../network/index.js"; import {Metrics} from "../../metrics/index.js"; +import {INetwork} from "../../network/index.js"; +import {IBeaconSync} from "../../sync/index.js"; export type ApiModules = { config: ChainForkConfig; diff --git a/packages/beacon-node/src/api/impl/validator/index.ts b/packages/beacon-node/src/api/impl/validator/index.ts index 2b558577c22c..b15644a8087e 100644 --- a/packages/beacon-node/src/api/impl/validator/index.ts +++ b/packages/beacon-node/src/api/impl/validator/index.ts @@ -1,61 +1,61 @@ import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; import {routes} from "@lodestar/api"; import {ApplicationMethods} from "@lodestar/api/server"; +import {DataAvailabilityStatus, ExecutionStatus} from "@lodestar/fork-choice"; import { - CachedBeaconStateAllForks, - computeStartSlotAtEpoch, - calculateCommitteeAssignments, - proposerShufflingDecisionRoot, - attesterShufflingDecisionRoot, - getBlockRootAtSlot, - computeEpochAtSlot, - getCurrentSlot, - beaconBlockToBlinded, - createCachedBeaconState, - loadState, -} from "@lodestar/state-transition"; -import { + ForkBlobs, + ForkExecution, + ForkPreBlobs, + ForkSeq, GENESIS_SLOT, SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT, SYNC_COMMITTEE_SUBNET_SIZE, isForkBlobs, isForkExecution, - ForkSeq, - ForkPreBlobs, - ForkBlobs, - ForkExecution, isForkPostElectra, } from "@lodestar/params"; -import {MAX_BUILDER_BOOST_FACTOR} from "@lodestar/validator"; import { + CachedBeaconStateAllForks, + attesterShufflingDecisionRoot, + beaconBlockToBlinded, + calculateCommitteeAssignments, + computeEpochAtSlot, + computeStartSlotAtEpoch, + createCachedBeaconState, + getBlockRootAtSlot, + getCurrentSlot, + loadState, + proposerShufflingDecisionRoot, +} from "@lodestar/state-transition"; +import { + BLSSignature, + BeaconBlock, + BlindedBeaconBlock, + BlockContents, + Epoch, + ProducedBlockSource, Root, Slot, ValidatorIndex, - ssz, - Epoch, - ProducedBlockSource, + Wei, bellatrix, - BLSSignature, + getValidatorStatus, isBlindedBeaconBlock, isBlockContents, phase0, - Wei, - BeaconBlock, - BlockContents, - BlindedBeaconBlock, - getValidatorStatus, + ssz, } from "@lodestar/types"; -import {ExecutionStatus, DataAvailabilityStatus} from "@lodestar/fork-choice"; import { + TimeoutError, + formatWeiToEth, fromHex, - toHex, - resolveOrRacePromises, prettyWeiToEth, + resolveOrRacePromises, + toHex, toRootHex, - TimeoutError, - formatWeiToEth, } from "@lodestar/utils"; +import {MAX_BUILDER_BOOST_FACTOR} from "@lodestar/validator"; import { AttestationError, AttestationErrorCode, @@ -63,23 +63,23 @@ import { SyncCommitteeError, SyncCommitteeErrorCode, } from "../../../chain/errors/index.js"; +import {ChainEvent, CheckpointHex, CommonBlockBody} from "../../../chain/index.js"; +import {SCHEDULER_LOOKAHEAD_FACTOR} from "../../../chain/prepareNextSlot.js"; +import {RegenCaller} from "../../../chain/regen/index.js"; import {validateApiAggregateAndProof} from "../../../chain/validation/index.js"; +import {validateSyncCommitteeGossipContributionAndProof} from "../../../chain/validation/syncCommitteeContributionAndProof.js"; import {ZERO_HASH} from "../../../constants/index.js"; +import {NoBidReceived} from "../../../execution/builder/http.js"; +import {validateGossipFnRetryUnknownRoot} from "../../../network/processor/gossipHandlers.js"; +import {CommitteeSubscription} from "../../../network/subnets/index.js"; import {SyncState} from "../../../sync/index.js"; import {isOptimisticBlock} from "../../../util/forkChoice.js"; import {getDefaultGraffiti, toGraffitiBuffer} from "../../../util/graffiti.js"; +import {getLodestarClientVersion} from "../../../util/metadata.js"; +import {ApiOptions} from "../../options.js"; +import {getStateResponseWithRegen} from "../beacon/state/utils.js"; import {ApiError, NodeIsSyncing, OnlySupportedByDVT} from "../errors.js"; -import {validateSyncCommitteeGossipContributionAndProof} from "../../../chain/validation/syncCommitteeContributionAndProof.js"; -import {CommitteeSubscription} from "../../../network/subnets/index.js"; import {ApiModules} from "../types.js"; -import {RegenCaller} from "../../../chain/regen/index.js"; -import {getStateResponseWithRegen} from "../beacon/state/utils.js"; -import {validateGossipFnRetryUnknownRoot} from "../../../network/processor/gossipHandlers.js"; -import {SCHEDULER_LOOKAHEAD_FACTOR} from "../../../chain/prepareNextSlot.js"; -import {ChainEvent, CheckpointHex, CommonBlockBody} from "../../../chain/index.js"; -import {ApiOptions} from "../../options.js"; -import {NoBidReceived} from "../../../execution/builder/http.js"; -import {getLodestarClientVersion} from "../../../util/metadata.js"; import {computeSubnetForCommitteesAtSlot, getPubkeysForIndices, selectBlockProductionSource} from "./utils.js"; /** diff --git a/packages/beacon-node/src/api/impl/validator/utils.ts b/packages/beacon-node/src/api/impl/validator/utils.ts index 36accf34cfda..b8e5aa525f25 100644 --- a/packages/beacon-node/src/api/impl/validator/utils.ts +++ b/packages/beacon-node/src/api/impl/validator/utils.ts @@ -1,6 +1,6 @@ -import {BeaconStateAllForks, computeSlotsSinceEpochStart} from "@lodestar/state-transition"; -import {ATTESTATION_SUBNET_COUNT} from "@lodestar/params"; import {routes} from "@lodestar/api"; +import {ATTESTATION_SUBNET_COUNT} from "@lodestar/params"; +import {BeaconStateAllForks, computeSlotsSinceEpochStart} from "@lodestar/state-transition"; import {BLSPubkey, CommitteeIndex, ProducedBlockSource, Slot, ValidatorIndex} from "@lodestar/types"; import {MAX_BUILDER_BOOST_FACTOR} from "@lodestar/validator"; import {BlockSelectionResult, BuilderBlockSelectionReason, EngineBlockSelectionReason} from "./index.js"; diff --git a/packages/beacon-node/src/api/options.ts b/packages/beacon-node/src/api/options.ts index 811621ba97bf..02d0c9c6cdf6 100644 --- a/packages/beacon-node/src/api/options.ts +++ b/packages/beacon-node/src/api/options.ts @@ -1,4 +1,4 @@ -import {beaconRestApiServerOpts, BeaconRestApiServerOpts} from "./rest/index.js"; +import {BeaconRestApiServerOpts, beaconRestApiServerOpts} from "./rest/index.js"; export type ApiOptions = { maxGindicesInProof?: number; diff --git a/packages/beacon-node/src/api/rest/base.ts b/packages/beacon-node/src/api/rest/base.ts index 276583dc7281..efa01b032230 100644 --- a/packages/beacon-node/src/api/rest/base.ts +++ b/packages/beacon-node/src/api/rest/base.ts @@ -1,9 +1,9 @@ -import {parse as parseQueryString} from "qs"; -import {FastifyInstance, FastifyRequest, fastify, errorCodes} from "fastify"; -import {fastifyCors} from "@fastify/cors"; import bearerAuthPlugin from "@fastify/bearer-auth"; +import {fastifyCors} from "@fastify/cors"; import {addSszContentTypeParser} from "@lodestar/api/server"; import {ErrorAborted, Gauge, Histogram, Logger} from "@lodestar/utils"; +import {FastifyInstance, FastifyRequest, errorCodes, fastify} from "fastify"; +import {parse as parseQueryString} from "qs"; import {isLocalhostIP} from "../../util/ip.js"; import {ApiError, FailureList, IndexedError, NodeIsSyncing} from "../impl/errors.js"; import {HttpActiveSocketsTracker, SocketMetrics} from "./activeSockets.js"; diff --git a/packages/beacon-node/src/api/rest/index.ts b/packages/beacon-node/src/api/rest/index.ts index 6beaf061588c..1d31080327e6 100644 --- a/packages/beacon-node/src/api/rest/index.ts +++ b/packages/beacon-node/src/api/rest/index.ts @@ -1,10 +1,10 @@ import {Endpoints} from "@lodestar/api"; import {BeaconApiMethods} from "@lodestar/api/beacon/server"; import {registerRoutes} from "@lodestar/api/beacon/server"; -import {ErrorAborted, Logger} from "@lodestar/utils"; import {ChainForkConfig} from "@lodestar/config"; +import {ErrorAborted, Logger} from "@lodestar/utils"; import {NodeIsSyncing} from "../impl/errors.js"; -import {RestApiServer, RestApiServerModules, RestApiServerMetrics, RestApiServerOpts} from "./base.js"; +import {RestApiServer, RestApiServerMetrics, RestApiServerModules, RestApiServerOpts} from "./base.js"; import {registerSwaggerUIRoutes} from "./swaggerUI.js"; export {allNamespaces} from "@lodestar/api"; diff --git a/packages/beacon-node/src/chain/archiver/archiveBlocks.ts b/packages/beacon-node/src/chain/archiver/archiveBlocks.ts index 8e1ac456579a..69c7dedfc560 100644 --- a/packages/beacon-node/src/chain/archiver/archiveBlocks.ts +++ b/packages/beacon-node/src/chain/archiver/archiveBlocks.ts @@ -1,10 +1,10 @@ -import {Epoch, Slot, RootHex} from "@lodestar/types"; +import {ChainForkConfig} from "@lodestar/config"; +import {KeyValue} from "@lodestar/db"; import {IForkChoice} from "@lodestar/fork-choice"; -import {Logger, fromHex, toRootHex} from "@lodestar/utils"; import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params"; import {computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition"; -import {KeyValue} from "@lodestar/db"; -import {ChainForkConfig} from "@lodestar/config"; +import {Epoch, RootHex, Slot} from "@lodestar/types"; +import {Logger, fromHex, toRootHex} from "@lodestar/utils"; import {IBeaconDb} from "../../db/index.js"; import {BlockArchiveBatchPutBinaryItem} from "../../db/repositories/index.js"; import {LightClientServer} from "../lightClient/index.js"; diff --git a/packages/beacon-node/src/chain/archiver/archiver.ts b/packages/beacon-node/src/chain/archiver/archiver.ts index 2d79f584ea79..6d5be3445eb2 100644 --- a/packages/beacon-node/src/chain/archiver/archiver.ts +++ b/packages/beacon-node/src/chain/archiver/archiver.ts @@ -1,13 +1,13 @@ -import {Logger} from "@lodestar/utils"; import {CheckpointWithHex} from "@lodestar/fork-choice"; +import {Logger} from "@lodestar/utils"; import {IBeaconDb} from "../../db/index.js"; +import {Metrics} from "../../metrics/metrics.js"; import {JobItemQueue} from "../../util/queue/index.js"; -import {IBeaconChain} from "../interface.js"; import {ChainEvent} from "../emitter.js"; -import {Metrics} from "../../metrics/metrics.js"; -import {FrequencyStateArchiveStrategy} from "./strategies/frequencyStateArchiveStrategy.js"; +import {IBeaconChain} from "../interface.js"; import {archiveBlocks} from "./archiveBlocks.js"; -import {StateArchiveMode, ArchiverOpts, StateArchiveStrategy} from "./interface.js"; +import {ArchiverOpts, StateArchiveMode, StateArchiveStrategy} from "./interface.js"; +import {FrequencyStateArchiveStrategy} from "./strategies/frequencyStateArchiveStrategy.js"; export const DEFAULT_STATE_ARCHIVE_MODE = StateArchiveMode.Frequency; diff --git a/packages/beacon-node/src/chain/archiver/interface.ts b/packages/beacon-node/src/chain/archiver/interface.ts index 48c930c78cd3..283fef579024 100644 --- a/packages/beacon-node/src/chain/archiver/interface.ts +++ b/packages/beacon-node/src/chain/archiver/interface.ts @@ -1,6 +1,6 @@ import {CheckpointWithHex} from "@lodestar/fork-choice"; -import {Metrics} from "../../metrics/metrics.js"; import {RootHex} from "@lodestar/types"; +import {Metrics} from "../../metrics/metrics.js"; export enum StateArchiveMode { Frequency = "frequency", diff --git a/packages/beacon-node/src/chain/archiver/strategies/frequencyStateArchiveStrategy.ts b/packages/beacon-node/src/chain/archiver/strategies/frequencyStateArchiveStrategy.ts index a701da5b22ec..6ae592ce7c63 100644 --- a/packages/beacon-node/src/chain/archiver/strategies/frequencyStateArchiveStrategy.ts +++ b/packages/beacon-node/src/chain/archiver/strategies/frequencyStateArchiveStrategy.ts @@ -1,14 +1,14 @@ -import {Logger} from "@lodestar/utils"; +import {CheckpointWithHex} from "@lodestar/fork-choice"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; -import {Slot, Epoch, RootHex} from "@lodestar/types"; import {computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition"; -import {CheckpointWithHex} from "@lodestar/fork-choice"; +import {Epoch, RootHex, Slot} from "@lodestar/types"; +import {Logger} from "@lodestar/utils"; import {IBeaconDb} from "../../../db/index.js"; -import {IStateRegenerator} from "../../regen/interface.js"; +import {Metrics} from "../../../metrics/metrics.js"; +import {AllocSource, BufferPool} from "../../../util/bufferPool.js"; import {getStateSlotFromBytes} from "../../../util/multifork.js"; +import {IStateRegenerator} from "../../regen/interface.js"; import {serializeState} from "../../serializeState.js"; -import {AllocSource, BufferPool} from "../../../util/bufferPool.js"; -import {Metrics} from "../../../metrics/metrics.js"; import {StateArchiveStrategy, StatesArchiverOpts} from "../interface.js"; /** diff --git a/packages/beacon-node/src/chain/balancesCache.ts b/packages/beacon-node/src/chain/balancesCache.ts index d29a6998f600..8fe09df4c275 100644 --- a/packages/beacon-node/src/chain/balancesCache.ts +++ b/packages/beacon-node/src/chain/balancesCache.ts @@ -1,11 +1,11 @@ +import {CheckpointWithHex} from "@lodestar/fork-choice"; import { CachedBeaconStateAllForks, - computeStartSlotAtEpoch, EffectiveBalanceIncrements, + computeStartSlotAtEpoch, getBlockRootAtSlot, getEffectiveBalanceIncrementsZeroInactive, } from "@lodestar/state-transition"; -import {CheckpointWithHex} from "@lodestar/fork-choice"; import {Epoch, RootHex} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; diff --git a/packages/beacon-node/src/chain/beaconProposerCache.ts b/packages/beacon-node/src/chain/beaconProposerCache.ts index f8638aa64bf7..dd46821e6d57 100644 --- a/packages/beacon-node/src/chain/beaconProposerCache.ts +++ b/packages/beacon-node/src/chain/beaconProposerCache.ts @@ -1,5 +1,5 @@ -import {Epoch} from "@lodestar/types"; import {routes} from "@lodestar/api"; +import {Epoch} from "@lodestar/types"; import {MapDef} from "@lodestar/utils"; import {Metrics} from "../metrics/index.js"; diff --git a/packages/beacon-node/src/chain/blocks/importBlock.ts b/packages/beacon-node/src/chain/blocks/importBlock.ts index 596f01f391a4..6b23112b03fe 100644 --- a/packages/beacon-node/src/chain/blocks/importBlock.ts +++ b/packages/beacon-node/src/chain/blocks/importBlock.ts @@ -1,26 +1,26 @@ -import {capella, ssz, altair, BeaconBlock} from "@lodestar/types"; +import {routes} from "@lodestar/api"; +import {AncestorStatus, EpochDifference, ForkChoiceError, ForkChoiceErrorCode} from "@lodestar/fork-choice"; import {ForkLightClient, ForkSeq, INTERVALS_PER_SLOT, MAX_SEED_LOOKAHEAD, SLOTS_PER_EPOCH} from "@lodestar/params"; import { CachedBeaconStateAltair, + RootCache, computeEpochAtSlot, computeStartSlotAtEpoch, isStateValidatorsNodesPopulated, - RootCache, } from "@lodestar/state-transition"; -import {routes} from "@lodestar/api"; -import {ForkChoiceError, ForkChoiceErrorCode, EpochDifference, AncestorStatus} from "@lodestar/fork-choice"; +import {BeaconBlock, altair, capella, ssz} from "@lodestar/types"; import {isErrorAborted, toHex, toRootHex} from "@lodestar/utils"; import {ZERO_HASH_HEX} from "../../constants/index.js"; -import {toCheckpointHex} from "../stateCache/index.js"; +import {kzgCommitmentToVersionedHash} from "../../util/blobs.js"; +import {callInNextEventLoop} from "../../util/eventLoop.js"; import {isOptimisticBlock} from "../../util/forkChoice.js"; import {isQueueErrorAborted} from "../../util/queue/index.js"; -import {kzgCommitmentToVersionedHash} from "../../util/blobs.js"; -import {ChainEvent, ReorgEventData} from "../emitter.js"; -import {REPROCESS_MIN_TIME_TO_NEXT_SLOT_SEC} from "../reprocess.js"; import type {BeaconChain} from "../chain.js"; -import {callInNextEventLoop} from "../../util/eventLoop.js"; +import {ChainEvent, ReorgEventData} from "../emitter.js"; import {ForkchoiceCaller} from "../forkChoice/index.js"; -import {FullyVerifiedBlock, ImportBlockOpts, AttestationImportOpt, BlockInputType} from "./types.js"; +import {REPROCESS_MIN_TIME_TO_NEXT_SLOT_SEC} from "../reprocess.js"; +import {toCheckpointHex} from "../stateCache/index.js"; +import {AttestationImportOpt, BlockInputType, FullyVerifiedBlock, ImportBlockOpts} from "./types.js"; import {getCheckpointFromState} from "./utils/checkpoint.js"; import {writeBlockInputToDb} from "./writeBlockInputToDb.js"; diff --git a/packages/beacon-node/src/chain/blocks/index.ts b/packages/beacon-node/src/chain/blocks/index.ts index f64e4b1f3813..6e8eed428a4b 100644 --- a/packages/beacon-node/src/chain/blocks/index.ts +++ b/packages/beacon-node/src/chain/blocks/index.ts @@ -1,14 +1,14 @@ -import {isErrorAborted, toRootHex} from "@lodestar/utils"; import {SignedBeaconBlock} from "@lodestar/types"; -import {JobItemQueue, isQueueErrorAborted} from "../../util/queue/index.js"; +import {isErrorAborted, toRootHex} from "@lodestar/utils"; import {Metrics} from "../../metrics/metrics.js"; +import {JobItemQueue, isQueueErrorAborted} from "../../util/queue/index.js"; +import type {BeaconChain} from "../chain.js"; import {BlockError, BlockErrorCode, isBlockErrorAborted} from "../errors/index.js"; import {BlockProcessOpts} from "../options.js"; -import type {BeaconChain} from "../chain.js"; -import {verifyBlocksInEpoch} from "./verifyBlock.js"; import {importBlock} from "./importBlock.js"; -import {assertLinearChainSegment} from "./utils/chainSegment.js"; import {BlockInput, FullyVerifiedBlock, ImportBlockOpts} from "./types.js"; +import {assertLinearChainSegment} from "./utils/chainSegment.js"; +import {verifyBlocksInEpoch} from "./verifyBlock.js"; import {verifyBlocksSanityChecks} from "./verifyBlocksSanityChecks.js"; import {removeEagerlyPersistedBlockInputs} from "./writeBlockInputToDb.js"; export {type ImportBlockOpts, AttestationImportOpt} from "./types.js"; diff --git a/packages/beacon-node/src/chain/blocks/types.ts b/packages/beacon-node/src/chain/blocks/types.ts index 8b793932e951..2b7186e91112 100644 --- a/packages/beacon-node/src/chain/blocks/types.ts +++ b/packages/beacon-node/src/chain/blocks/types.ts @@ -1,8 +1,8 @@ -import {CachedBeaconStateAllForks, computeEpochAtSlot} from "@lodestar/state-transition"; -import {MaybeValidExecutionStatus, DataAvailabilityStatus} from "@lodestar/fork-choice"; -import {deneb, Slot, RootHex, SignedBeaconBlock} from "@lodestar/types"; -import {ForkSeq, ForkBlobs} from "@lodestar/params"; import {ChainForkConfig} from "@lodestar/config"; +import {DataAvailabilityStatus, MaybeValidExecutionStatus} from "@lodestar/fork-choice"; +import {ForkBlobs, ForkSeq} from "@lodestar/params"; +import {CachedBeaconStateAllForks, computeEpochAtSlot} from "@lodestar/state-transition"; +import {RootHex, SignedBeaconBlock, Slot, deneb} from "@lodestar/types"; export enum BlockInputType { // preData is preDeneb diff --git a/packages/beacon-node/src/chain/blocks/utils/checkpoint.ts b/packages/beacon-node/src/chain/blocks/utils/checkpoint.ts index 2ff77600b2b8..855a1b19e741 100644 --- a/packages/beacon-node/src/chain/blocks/utils/checkpoint.ts +++ b/packages/beacon-node/src/chain/blocks/utils/checkpoint.ts @@ -1,5 +1,5 @@ -import {CachedBeaconStateAllForks, computeEpochAtSlot} from "@lodestar/state-transition"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; +import {CachedBeaconStateAllForks, computeEpochAtSlot} from "@lodestar/state-transition"; import {phase0, ssz} from "@lodestar/types"; import {ZERO_HASH} from "../../../constants/index.js"; diff --git a/packages/beacon-node/src/chain/blocks/verifyBlock.ts b/packages/beacon-node/src/chain/blocks/verifyBlock.ts index 4d21342bd8cc..47a9a9060572 100644 --- a/packages/beacon-node/src/chain/blocks/verifyBlock.ts +++ b/packages/beacon-node/src/chain/blocks/verifyBlock.ts @@ -1,26 +1,26 @@ +import {ChainForkConfig} from "@lodestar/config"; +import {DataAvailabilityStatus, ExecutionStatus, ProtoBlock} from "@lodestar/fork-choice"; +import {ForkName} from "@lodestar/params"; import { CachedBeaconStateAllForks, + DataAvailableStatus, computeEpochAtSlot, isStateValidatorsNodesPopulated, - DataAvailableStatus, } from "@lodestar/state-transition"; import {bellatrix, deneb} from "@lodestar/types"; -import {ForkName} from "@lodestar/params"; -import {ProtoBlock, ExecutionStatus, DataAvailabilityStatus} from "@lodestar/fork-choice"; -import {ChainForkConfig} from "@lodestar/config"; import {Logger, toRootHex} from "@lodestar/utils"; +import type {BeaconChain} from "../chain.js"; import {BlockError, BlockErrorCode} from "../errors/index.js"; import {BlockProcessOpts} from "../options.js"; import {RegenCaller} from "../regen/index.js"; -import type {BeaconChain} from "../chain.js"; -import {BlockInput, ImportBlockOpts, BlockInputType} from "./types.js"; -import {POS_PANDA_MERGE_TRANSITION_BANNER} from "./utils/pandaMergeTransitionBanner.js"; -import {CAPELLA_OWL_BANNER} from "./utils/ownBanner.js"; +import {BlockInput, BlockInputType, ImportBlockOpts} from "./types.js"; import {DENEB_BLOWFISH_BANNER} from "./utils/blowfishBanner.js"; -import {verifyBlocksStateTransitionOnly} from "./verifyBlocksStateTransitionOnly.js"; -import {verifyBlocksSignatures} from "./verifyBlocksSignatures.js"; -import {verifyBlocksExecutionPayload, SegmentExecStatus} from "./verifyBlocksExecutionPayloads.js"; +import {CAPELLA_OWL_BANNER} from "./utils/ownBanner.js"; +import {POS_PANDA_MERGE_TRANSITION_BANNER} from "./utils/pandaMergeTransitionBanner.js"; import {verifyBlocksDataAvailability} from "./verifyBlocksDataAvailability.js"; +import {SegmentExecStatus, verifyBlocksExecutionPayload} from "./verifyBlocksExecutionPayloads.js"; +import {verifyBlocksSignatures} from "./verifyBlocksSignatures.js"; +import {verifyBlocksStateTransitionOnly} from "./verifyBlocksStateTransitionOnly.js"; import {writeBlockInputToDb} from "./writeBlockInputToDb.js"; /** diff --git a/packages/beacon-node/src/chain/blocks/verifyBlocksDataAvailability.ts b/packages/beacon-node/src/chain/blocks/verifyBlocksDataAvailability.ts index 98bfae2c1ce3..1d8c72a46873 100644 --- a/packages/beacon-node/src/chain/blocks/verifyBlocksDataAvailability.ts +++ b/packages/beacon-node/src/chain/blocks/verifyBlocksDataAvailability.ts @@ -1,12 +1,12 @@ -import {computeTimeAtSlot} from "@lodestar/state-transition"; -import {DataAvailabilityStatus} from "@lodestar/fork-choice"; import {ChainForkConfig} from "@lodestar/config"; -import {deneb, UintNum64} from "@lodestar/types"; +import {DataAvailabilityStatus} from "@lodestar/fork-choice"; +import {computeTimeAtSlot} from "@lodestar/state-transition"; +import {UintNum64, deneb} from "@lodestar/types"; import {Logger} from "@lodestar/utils"; +import {Metrics} from "../../metrics/metrics.js"; import {BlockError, BlockErrorCode} from "../errors/index.js"; import {validateBlobSidecars} from "../validation/blobSidecar.js"; -import {Metrics} from "../../metrics/metrics.js"; -import {BlockInput, BlockInputType, ImportBlockOpts, BlobSidecarValidation, getBlockInput} from "./types.js"; +import {BlobSidecarValidation, BlockInput, BlockInputType, ImportBlockOpts, getBlockInput} from "./types.js"; // we can now wait for full 12 seconds because unavailable block sync will try pulling // the blobs from the network anyway after 500ms of seeing the block diff --git a/packages/beacon-node/src/chain/blocks/verifyBlocksExecutionPayloads.ts b/packages/beacon-node/src/chain/blocks/verifyBlocksExecutionPayloads.ts index e641ff9ae6d9..e37442bfde8f 100644 --- a/packages/beacon-node/src/chain/blocks/verifyBlocksExecutionPayloads.ts +++ b/packages/beacon-node/src/chain/blocks/verifyBlocksExecutionPayloads.ts @@ -1,32 +1,32 @@ +import {ChainForkConfig} from "@lodestar/config"; +import { + ExecutionStatus, + IForkChoice, + LVHInvalidResponse, + LVHValidResponse, + MaybeValidExecutionStatus, + ProtoBlock, + assertValidTerminalPowBlock, +} from "@lodestar/fork-choice"; +import {ForkSeq, SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY} from "@lodestar/params"; import { CachedBeaconStateAllForks, - isExecutionStateType, isExecutionBlockBodyType, - isMergeTransitionBlock as isMergeTransitionBlockFn, isExecutionEnabled, + isExecutionStateType, + isMergeTransitionBlock as isMergeTransitionBlockFn, } from "@lodestar/state-transition"; -import {bellatrix, Slot, deneb, SignedBeaconBlock, electra} from "@lodestar/types"; -import { - IForkChoice, - assertValidTerminalPowBlock, - ProtoBlock, - ExecutionStatus, - MaybeValidExecutionStatus, - LVHValidResponse, - LVHInvalidResponse, -} from "@lodestar/fork-choice"; -import {ChainForkConfig} from "@lodestar/config"; +import {SignedBeaconBlock, Slot, bellatrix, deneb, electra} from "@lodestar/types"; import {ErrorAborted, Logger, toRootHex} from "@lodestar/utils"; -import {ForkSeq, SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY} from "@lodestar/params"; +import {IEth1ForBlockProduction} from "../../eth1/index.js"; import {IExecutionEngine} from "../../execution/engine/interface.js"; -import {BlockError, BlockErrorCode} from "../errors/index.js"; -import {IClock} from "../../util/clock.js"; -import {kzgCommitmentToVersionedHash} from "../../util/blobs.js"; -import {BlockProcessOpts} from "../options.js"; import {ExecutionPayloadStatus} from "../../execution/engine/interface.js"; -import {IEth1ForBlockProduction} from "../../eth1/index.js"; import {Metrics} from "../../metrics/metrics.js"; +import {kzgCommitmentToVersionedHash} from "../../util/blobs.js"; +import {IClock} from "../../util/clock.js"; +import {BlockError, BlockErrorCode} from "../errors/index.js"; +import {BlockProcessOpts} from "../options.js"; import {ImportBlockOpts} from "./types.js"; export type VerifyBlockExecutionPayloadModules = { diff --git a/packages/beacon-node/src/chain/blocks/verifyBlocksSanityChecks.ts b/packages/beacon-node/src/chain/blocks/verifyBlocksSanityChecks.ts index 22b20a55fb67..5115f39ebf47 100644 --- a/packages/beacon-node/src/chain/blocks/verifyBlocksSanityChecks.ts +++ b/packages/beacon-node/src/chain/blocks/verifyBlocksSanityChecks.ts @@ -1,6 +1,6 @@ -import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {ChainForkConfig} from "@lodestar/config"; import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice"; +import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {Slot} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; import {IClock} from "../../util/clock.js"; diff --git a/packages/beacon-node/src/chain/blocks/verifyBlocksSignatures.ts b/packages/beacon-node/src/chain/blocks/verifyBlocksSignatures.ts index e86549cda7d3..d133579f97a5 100644 --- a/packages/beacon-node/src/chain/blocks/verifyBlocksSignatures.ts +++ b/packages/beacon-node/src/chain/blocks/verifyBlocksSignatures.ts @@ -1,10 +1,10 @@ import {CachedBeaconStateAllForks, getBlockSignatureSets} from "@lodestar/state-transition"; -import {Logger} from "@lodestar/utils"; import {SignedBeaconBlock} from "@lodestar/types"; +import {Logger} from "@lodestar/utils"; import {Metrics} from "../../metrics/metrics.js"; +import {nextEventLoop} from "../../util/eventLoop.js"; import {IBlsVerifier} from "../bls/index.js"; import {BlockError, BlockErrorCode} from "../errors/blockError.js"; -import {nextEventLoop} from "../../util/eventLoop.js"; import {ImportBlockOpts} from "./types.js"; /** diff --git a/packages/beacon-node/src/chain/blocks/verifyBlocksStateTransitionOnly.ts b/packages/beacon-node/src/chain/blocks/verifyBlocksStateTransitionOnly.ts index 49cd46220008..b2f70d6274b3 100644 --- a/packages/beacon-node/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +++ b/packages/beacon-node/src/chain/blocks/verifyBlocksStateTransitionOnly.ts @@ -1,16 +1,16 @@ import { CachedBeaconStateAllForks, - stateTransition, - ExecutionPayloadStatus, DataAvailableStatus, + ExecutionPayloadStatus, StateHashTreeRootSource, + stateTransition, } from "@lodestar/state-transition"; import {ErrorAborted, Logger} from "@lodestar/utils"; import {Metrics} from "../../metrics/index.js"; -import {BlockError, BlockErrorCode} from "../errors/index.js"; -import {BlockProcessOpts} from "../options.js"; import {byteArrayEquals} from "../../util/bytes.js"; import {nextEventLoop} from "../../util/eventLoop.js"; +import {BlockError, BlockErrorCode} from "../errors/index.js"; +import {BlockProcessOpts} from "../options.js"; import {BlockInput, ImportBlockOpts} from "./types.js"; /** diff --git a/packages/beacon-node/src/chain/bls/multithread/index.ts b/packages/beacon-node/src/chain/bls/multithread/index.ts index fc8ea7534ad7..4b1867c3793f 100644 --- a/packages/beacon-node/src/chain/bls/multithread/index.ts +++ b/packages/beacon-node/src/chain/bls/multithread/index.ts @@ -1,24 +1,21 @@ /* eslint-disable @typescript-eslint/strict-boolean-expressions */ import path from "node:path"; -import {spawn, Worker} from "@chainsafe/threads"; +import {Worker, spawn} from "@chainsafe/threads"; // `threads` library creates self global variable which breaks `timeout-abort-controller` https://github.com/jacobheun/timeout-abort-controller/issues/9 // Don't add an eslint disable here as a reminder that this has to be fixed eventually // @ts-ignore // biome-ignore lint/suspicious/noGlobalAssign: self = undefined; import {PublicKey} from "@chainsafe/blst"; -import {Logger} from "@lodestar/utils"; import {ISignatureSet} from "@lodestar/state-transition"; -import {QueueError, QueueErrorCode} from "../../../util/queue/index.js"; +import {Logger} from "@lodestar/utils"; import {Metrics} from "../../../metrics/index.js"; -import {IBlsVerifier, VerifySignatureOpts} from "../interface.js"; -import {getAggregatedPubkey, getAggregatedPubkeysCount} from "../utils.js"; -import {verifySignatureSetsMaybeBatch} from "../maybeBatch.js"; import {LinkedList} from "../../../util/array.js"; import {callInNextEventLoop} from "../../../util/eventLoop.js"; -import {BlsWorkReq, BlsWorkResult, WorkerData, WorkResultCode, WorkResultError} from "./types.js"; -import {chunkifyMaximizeChunkSize} from "./utils.js"; -import {defaultPoolSize} from "./poolSize.js"; +import {QueueError, QueueErrorCode} from "../../../util/queue/index.js"; +import {IBlsVerifier, VerifySignatureOpts} from "../interface.js"; +import {verifySignatureSetsMaybeBatch} from "../maybeBatch.js"; +import {getAggregatedPubkey, getAggregatedPubkeysCount} from "../utils.js"; import { JobQueueItem, JobQueueItemSameMessage, @@ -27,6 +24,9 @@ import { jobItemSigSets, jobItemWorkReq, } from "./jobItem.js"; +import {defaultPoolSize} from "./poolSize.js"; +import {BlsWorkReq, BlsWorkResult, WorkResultCode, WorkResultError, WorkerData} from "./types.js"; +import {chunkifyMaximizeChunkSize} from "./utils.js"; // Worker constructor consider the path relative to the current working directory const workerDir = process.env.NODE_ENV === "test" ? "../../../../lib/chain/bls/multithread" : "./"; diff --git a/packages/beacon-node/src/chain/bls/multithread/jobItem.ts b/packages/beacon-node/src/chain/bls/multithread/jobItem.ts index 63591af5ee77..efaaf36fd88f 100644 --- a/packages/beacon-node/src/chain/bls/multithread/jobItem.ts +++ b/packages/beacon-node/src/chain/bls/multithread/jobItem.ts @@ -1,9 +1,9 @@ import {PublicKey, asyncAggregateWithRandomness} from "@chainsafe/blst"; import {ISignatureSet, SignatureSetType} from "@lodestar/state-transition"; +import {Metrics} from "../../../metrics/metrics.js"; +import {LinkedList} from "../../../util/array.js"; import {VerifySignatureOpts} from "../interface.js"; import {getAggregatedPubkey} from "../utils.js"; -import {LinkedList} from "../../../util/array.js"; -import {Metrics} from "../../../metrics/metrics.js"; import {BlsWorkReq} from "./types.js"; export type JobQueueItem = JobQueueItemDefault | JobQueueItemSameMessage; diff --git a/packages/beacon-node/src/chain/bls/multithread/worker.ts b/packages/beacon-node/src/chain/bls/multithread/worker.ts index d2794db2e6bf..7fbd1701950b 100644 --- a/packages/beacon-node/src/chain/bls/multithread/worker.ts +++ b/packages/beacon-node/src/chain/bls/multithread/worker.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/strict-boolean-expressions */ import worker from "node:worker_threads"; -import {expose} from "@chainsafe/threads/worker"; import {PublicKey} from "@chainsafe/blst"; -import {verifySignatureSetsMaybeBatch, SignatureSetDeserialized} from "../maybeBatch.js"; -import {WorkerData, BlsWorkReq, WorkResult, WorkResultCode, SerializedSet, BlsWorkResult} from "./types.js"; +import {expose} from "@chainsafe/threads/worker"; +import {SignatureSetDeserialized, verifySignatureSetsMaybeBatch} from "../maybeBatch.js"; +import {BlsWorkReq, BlsWorkResult, SerializedSet, WorkResult, WorkResultCode, WorkerData} from "./types.js"; import {chunkifyMaximizeChunkSize} from "./utils.js"; /** diff --git a/packages/beacon-node/src/chain/chain.ts b/packages/beacon-node/src/chain/chain.ts index 144b73f0c01d..8b9fa0336283 100644 --- a/packages/beacon-node/src/chain/chain.ts +++ b/packages/beacon-node/src/chain/chain.ts @@ -1,106 +1,106 @@ import path from "node:path"; -import {CompositeTypeAny, TreeView, Type} from "@chainsafe/ssz"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; +import {CompositeTypeAny, TreeView, Type} from "@chainsafe/ssz"; +import {BeaconConfig} from "@lodestar/config"; +import {CheckpointWithHex, ExecutionStatus, IForkChoice, ProtoBlock, UpdateHeadOpt} from "@lodestar/fork-choice"; +import {ForkSeq, GENESIS_SLOT, SLOTS_PER_EPOCH} from "@lodestar/params"; import { BeaconStateAllForks, CachedBeaconStateAllForks, + EffectiveBalanceIncrements, + EpochShuffling, + Index2PubkeyCache, + computeAnchorCheckpoint, + computeEndSlotAtEpoch, computeEpochAtSlot, computeStartSlotAtEpoch, createCachedBeaconState, - EffectiveBalanceIncrements, getEffectiveBalanceIncrementsZeroInactive, isCachedBeaconState, - Index2PubkeyCache, - EpochShuffling, - computeEndSlotAtEpoch, - computeAnchorCheckpoint, } from "@lodestar/state-transition"; -import {BeaconConfig} from "@lodestar/config"; import { - UintNum64, + BeaconBlock, + BlindedBeaconBlock, + BlindedBeaconBlockBody, + Epoch, + ExecutionPayload, Root, - phase0, - Slot, RootHex, - Epoch, + SignedBeaconBlock, + Slot, + UintNum64, ValidatorIndex, - deneb, Wei, bellatrix, + deneb, isBlindedBeaconBlock, - BeaconBlock, - SignedBeaconBlock, - ExecutionPayload, - BlindedBeaconBlock, - BlindedBeaconBlockBody, + phase0, } from "@lodestar/types"; -import {CheckpointWithHex, ExecutionStatus, IForkChoice, ProtoBlock, UpdateHeadOpt} from "@lodestar/fork-choice"; -import {ProcessShutdownCallback} from "@lodestar/validator"; import {Logger, fromHex, gweiToWei, isErrorAborted, pruneSetToMax, sleep, toRootHex} from "@lodestar/utils"; -import {ForkSeq, GENESIS_SLOT, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {ProcessShutdownCallback} from "@lodestar/validator"; import {GENESIS_EPOCH, ZERO_HASH} from "../constants/index.js"; import {IBeaconDb} from "../db/index.js"; -import {Metrics} from "../metrics/index.js"; import {IEth1ForBlockProduction} from "../eth1/index.js"; -import {IExecutionEngine, IExecutionBuilder} from "../execution/index.js"; +import {IExecutionBuilder, IExecutionEngine} from "../execution/index.js"; +import {Metrics} from "../metrics/index.js"; +import {BufferPool} from "../util/bufferPool.js"; import {Clock, ClockEvent, IClock} from "../util/clock.js"; import {ensureDir, writeIfNotExist} from "../util/file.js"; import {isOptimisticBlock} from "../util/forkChoice.js"; -import {BufferPool} from "../util/bufferPool.js"; +import {Archiver} from "./archiver/archiver.js"; +import {CheckpointBalancesCache} from "./balancesCache.js"; +import {BeaconProposerCache} from "./beaconProposerCache.js"; import {BlockProcessor, ImportBlockOpts} from "./blocks/index.js"; -import {ChainEventEmitter, ChainEvent} from "./emitter.js"; +import {BlockInput} from "./blocks/types.js"; +import {BlsMultiThreadWorkerPool, BlsSingleThreadVerifier, IBlsVerifier} from "./bls/index.js"; +import {ChainEvent, ChainEventEmitter} from "./emitter.js"; +import {ForkchoiceCaller, initializeForkChoice} from "./forkChoice/index.js"; +import {HistoricalStateRegen} from "./historicalState/index.js"; import { - IBeaconChain, - ProposerPreparationData, BlockHash, - StateGetOpts, CommonBlockBody, FindHeadFnName, + IBeaconChain, + ProposerPreparationData, + StateGetOpts, } from "./interface.js"; -import {IChainOptions} from "./options.js"; -import {QueuedStateRegenerator, RegenCaller} from "./regen/index.js"; -import {ForkchoiceCaller, initializeForkChoice} from "./forkChoice/index.js"; -import {IBlsVerifier, BlsSingleThreadVerifier, BlsMultiThreadWorkerPool} from "./bls/index.js"; -import { - SeenAttesters, - SeenAggregators, - SeenBlockProposers, - SeenSyncCommitteeMessages, - SeenContributionAndProof, -} from "./seenCache/index.js"; +import {LightClientServer} from "./lightClient/index.js"; import { AggregatedAttestationPool, AttestationPool, + OpPool, SyncCommitteeMessagePool, SyncContributionAndProofPool, - OpPool, } from "./opPools/index.js"; -import {LightClientServer} from "./lightClient/index.js"; -import {Archiver} from "./archiver/archiver.js"; +import {IChainOptions} from "./options.js"; import {PrepareNextSlotScheduler} from "./prepareNextSlot.js"; -import {ReprocessController} from "./reprocess.js"; -import {SeenAggregatedAttestations} from "./seenCache/seenAggregateAndProof.js"; -import {SeenBlockAttesters} from "./seenCache/seenBlockAttesters.js"; -import {BeaconProposerCache} from "./beaconProposerCache.js"; -import {CheckpointBalancesCache} from "./balancesCache.js"; +import {computeNewStateRoot} from "./produceBlock/computeNewStateRoot.js"; import {AssembledBlockType, BlobsResultType, BlockType} from "./produceBlock/index.js"; import {BlockAttributes, produceBlockBody, produceCommonBlockBody} from "./produceBlock/produceBlockBody.js"; -import {computeNewStateRoot} from "./produceBlock/computeNewStateRoot.js"; -import {BlockInput} from "./blocks/types.js"; -import {SeenAttestationDatas} from "./seenCache/seenAttestationData.js"; -import {HistoricalStateRegen} from "./historicalState/index.js"; +import {QueuedStateRegenerator, RegenCaller} from "./regen/index.js"; +import {ReprocessController} from "./reprocess.js"; +import {AttestationsRewards, computeAttestationsRewards} from "./rewards/attestationsRewards.js"; import {BlockRewards, computeBlockRewards} from "./rewards/blockRewards.js"; +import {SyncCommitteeRewards, computeSyncCommitteeRewards} from "./rewards/syncCommitteeRewards.js"; +import { + SeenAggregators, + SeenAttesters, + SeenBlockProposers, + SeenContributionAndProof, + SeenSyncCommitteeMessages, +} from "./seenCache/index.js"; +import {SeenGossipBlockInput} from "./seenCache/index.js"; +import {SeenAggregatedAttestations} from "./seenCache/seenAggregateAndProof.js"; +import {SeenAttestationDatas} from "./seenCache/seenAttestationData.js"; +import {SeenBlockAttesters} from "./seenCache/seenBlockAttesters.js"; import {ShufflingCache} from "./shufflingCache.js"; import {BlockStateCacheImpl} from "./stateCache/blockStateCacheImpl.js"; -import {SeenGossipBlockInput} from "./seenCache/index.js"; -import {InMemoryCheckpointStateCache} from "./stateCache/inMemoryCheckpointsCache.js"; -import {FIFOBlockStateCache} from "./stateCache/fifoBlockStateCache.js"; -import {PersistentCheckpointStateCache} from "./stateCache/persistentCheckpointsCache.js"; import {DbCPStateDatastore} from "./stateCache/datastore/db.js"; import {FileCPStateDatastore} from "./stateCache/datastore/file.js"; -import {SyncCommitteeRewards, computeSyncCommitteeRewards} from "./rewards/syncCommitteeRewards.js"; -import {AttestationsRewards, computeAttestationsRewards} from "./rewards/attestationsRewards.js"; +import {FIFOBlockStateCache} from "./stateCache/fifoBlockStateCache.js"; +import {InMemoryCheckpointStateCache} from "./stateCache/inMemoryCheckpointsCache.js"; +import {PersistentCheckpointStateCache} from "./stateCache/persistentCheckpointsCache.js"; /** * Arbitrary constants, blobs and payloads should be consumed immediately in the same slot diff --git a/packages/beacon-node/src/chain/emitter.ts b/packages/beacon-node/src/chain/emitter.ts index 10b6455e48f5..a24c1e37bf92 100644 --- a/packages/beacon-node/src/chain/emitter.ts +++ b/packages/beacon-node/src/chain/emitter.ts @@ -2,9 +2,9 @@ import {EventEmitter} from "node:events"; import {StrictEventEmitter} from "strict-event-emitter-types"; import {routes} from "@lodestar/api"; -import {phase0} from "@lodestar/types"; import {CheckpointWithHex} from "@lodestar/fork-choice"; import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; +import {phase0} from "@lodestar/types"; /** * Important chain events that occur during normal chain operation. diff --git a/packages/beacon-node/src/chain/errors/attestationError.ts b/packages/beacon-node/src/chain/errors/attestationError.ts index 9f8e86cea1ab..618a334928ae 100644 --- a/packages/beacon-node/src/chain/errors/attestationError.ts +++ b/packages/beacon-node/src/chain/errors/attestationError.ts @@ -1,4 +1,4 @@ -import {Epoch, Slot, ValidatorIndex, RootHex} from "@lodestar/types"; +import {Epoch, RootHex, Slot, ValidatorIndex} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; import {GossipActionError} from "./gossipValidation.js"; diff --git a/packages/beacon-node/src/chain/errors/blobSidecarError.ts b/packages/beacon-node/src/chain/errors/blobSidecarError.ts index f38aa883002c..410574594911 100644 --- a/packages/beacon-node/src/chain/errors/blobSidecarError.ts +++ b/packages/beacon-node/src/chain/errors/blobSidecarError.ts @@ -1,4 +1,4 @@ -import {Slot, RootHex, ValidatorIndex} from "@lodestar/types"; +import {RootHex, Slot, ValidatorIndex} from "@lodestar/types"; import {GossipActionError} from "./gossipValidation.js"; export enum BlobSidecarErrorCode { diff --git a/packages/beacon-node/src/chain/errors/blockError.ts b/packages/beacon-node/src/chain/errors/blockError.ts index 6280533c7a68..bc5dd6c33956 100644 --- a/packages/beacon-node/src/chain/errors/blockError.ts +++ b/packages/beacon-node/src/chain/errors/blockError.ts @@ -1,6 +1,6 @@ +import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; import {RootHex, SignedBeaconBlock, Slot, ValidatorIndex} from "@lodestar/types"; import {LodestarError, toRootHex} from "@lodestar/utils"; -import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; import {ExecutionPayloadStatus} from "../../execution/engine/interface.js"; import {QueueErrorCode} from "../../util/queue/index.js"; import {GossipActionError} from "./gossipValidation.js"; diff --git a/packages/beacon-node/src/chain/errors/syncCommitteeError.ts b/packages/beacon-node/src/chain/errors/syncCommitteeError.ts index e4a92729cecd..1564a358ec4c 100644 --- a/packages/beacon-node/src/chain/errors/syncCommitteeError.ts +++ b/packages/beacon-node/src/chain/errors/syncCommitteeError.ts @@ -1,4 +1,4 @@ -import {ValidatorIndex, Slot, RootHex} from "@lodestar/types"; +import {RootHex, Slot, ValidatorIndex} from "@lodestar/types"; import {GossipActionError} from "./gossipValidation.js"; export enum SyncCommitteeErrorCode { diff --git a/packages/beacon-node/src/chain/forkChoice/index.ts b/packages/beacon-node/src/chain/forkChoice/index.ts index 839975de4e26..b3f5d11260f2 100644 --- a/packages/beacon-node/src/chain/forkChoice/index.ts +++ b/packages/beacon-node/src/chain/forkChoice/index.ts @@ -1,26 +1,26 @@ -import {Slot} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; import { + DataAvailabilityStatus, + ExecutionStatus, ForkChoice, - ProtoArray, ForkChoiceStore, - ExecutionStatus, JustifiedBalancesGetter, + ProtoArray, ForkChoiceOpts as RawForkChoiceOpts, - DataAvailabilityStatus, } from "@lodestar/fork-choice"; import { CachedBeaconStateAllForks, + computeAnchorCheckpoint, getEffectiveBalanceIncrementsZeroInactive, isExecutionStateType, isMergeTransitionComplete, - computeAnchorCheckpoint, } from "@lodestar/state-transition"; +import {Slot} from "@lodestar/types"; import {Logger, toRootHex} from "@lodestar/utils"; +import {GENESIS_SLOT} from "../../constants/index.js"; import {ChainEventEmitter} from "../emitter.js"; import {ChainEvent} from "../emitter.js"; -import {GENESIS_SLOT} from "../../constants/index.js"; export type ForkChoiceOpts = RawForkChoiceOpts & { // for testing only diff --git a/packages/beacon-node/src/chain/genesis/genesis.ts b/packages/beacon-node/src/chain/genesis/genesis.ts index 0c46f920d614..f56b42a3b89e 100644 --- a/packages/beacon-node/src/chain/genesis/genesis.ts +++ b/packages/beacon-node/src/chain/genesis/genesis.ts @@ -1,25 +1,25 @@ -import {toGindex, Tree} from "@chainsafe/persistent-merkle-tree"; -import {GENESIS_EPOCH, GENESIS_SLOT} from "@lodestar/params"; -import {phase0, ssz} from "@lodestar/types"; +import {Tree, toGindex} from "@chainsafe/persistent-merkle-tree"; import {BeaconConfig, ChainForkConfig} from "@lodestar/config"; +import {GENESIS_EPOCH, GENESIS_SLOT} from "@lodestar/params"; import { - getTemporaryBlockHeader, - getGenesisBeaconState, + BeaconStateAllForks, + CachedBeaconStateAllForks, applyDeposits, - applyTimestamp, applyEth1BlockHash, - CachedBeaconStateAllForks, + applyTimestamp, createCachedBeaconState, - BeaconStateAllForks, createEmptyEpochCacheImmutableData, getActiveValidatorIndices, + getGenesisBeaconState, + getTemporaryBlockHeader, } from "@lodestar/state-transition"; +import {phase0, ssz} from "@lodestar/types"; import {Logger} from "@lodestar/utils"; +import {DepositTree} from "../../db/repositories/depositDataRoot.js"; import {IEth1Provider} from "../../eth1/index.js"; import {IEth1StreamParams} from "../../eth1/interface.js"; import {getDepositsAndBlockStreamForGenesis, getDepositsStream} from "../../eth1/stream.js"; -import {DepositTree} from "../../db/repositories/depositDataRoot.js"; -import {IGenesisBuilder, GenesisResult} from "./interface.js"; +import {GenesisResult, IGenesisBuilder} from "./interface.js"; export type GenesisBuilderKwargs = { config: ChainForkConfig; diff --git a/packages/beacon-node/src/chain/genesis/interface.ts b/packages/beacon-node/src/chain/genesis/interface.ts index d1bae335b9ff..79c402cc29cb 100644 --- a/packages/beacon-node/src/chain/genesis/interface.ts +++ b/packages/beacon-node/src/chain/genesis/interface.ts @@ -1,6 +1,6 @@ import {CompositeViewDU, VectorCompositeType} from "@chainsafe/ssz"; -import {ssz} from "@lodestar/types"; import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; +import {ssz} from "@lodestar/types"; import {Eth1Block} from "../../eth1/interface.js"; export type GenesisResult = { diff --git a/packages/beacon-node/src/chain/historicalState/getHistoricalState.ts b/packages/beacon-node/src/chain/historicalState/getHistoricalState.ts index a9f254dea3f2..20a53c40d73d 100644 --- a/packages/beacon-node/src/chain/historicalState/getHistoricalState.ts +++ b/packages/beacon-node/src/chain/historicalState/getHistoricalState.ts @@ -1,4 +1,5 @@ import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; +import {BeaconConfig} from "@lodestar/config"; import { BeaconStateAllForks, CachedBeaconStateAllForks, @@ -7,7 +8,6 @@ import { createCachedBeaconState, stateTransition, } from "@lodestar/state-transition"; -import {BeaconConfig} from "@lodestar/config"; import {IBeaconDb} from "../../db/index.js"; import {HistoricalStateRegenMetrics, RegenErrorType} from "./types.js"; diff --git a/packages/beacon-node/src/chain/historicalState/index.ts b/packages/beacon-node/src/chain/historicalState/index.ts index 8688bcf9f372..250a80467951 100644 --- a/packages/beacon-node/src/chain/historicalState/index.ts +++ b/packages/beacon-node/src/chain/historicalState/index.ts @@ -1,5 +1,5 @@ import path from "node:path"; -import {ModuleThread, Thread, spawn, Worker} from "@chainsafe/threads"; +import {ModuleThread, Thread, Worker, spawn} from "@chainsafe/threads"; import {chainConfigToJson} from "@lodestar/config"; import {LoggerNode} from "@lodestar/logger/node"; import { diff --git a/packages/beacon-node/src/chain/historicalState/worker.ts b/packages/beacon-node/src/chain/historicalState/worker.ts index 2ea673d0faff..fabb985c66a5 100644 --- a/packages/beacon-node/src/chain/historicalState/worker.ts +++ b/packages/beacon-node/src/chain/historicalState/worker.ts @@ -1,21 +1,21 @@ import worker from "node:worker_threads"; -import {Transfer, expose} from "@chainsafe/threads/worker"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; -import {createBeaconConfig, chainConfigFromJson} from "@lodestar/config"; +import {Transfer, expose} from "@chainsafe/threads/worker"; +import {chainConfigFromJson, createBeaconConfig} from "@lodestar/config"; +import {LevelDbController} from "@lodestar/db"; import {getNodeLogger} from "@lodestar/logger/node"; import {EpochTransitionStep, StateCloneSource, StateHashTreeRootSource} from "@lodestar/state-transition"; -import {LevelDbController} from "@lodestar/db"; +import {BeaconDb} from "../../db/index.js"; import {RegistryMetricCreator, collectNodeJSMetrics} from "../../metrics/index.js"; import {JobFnQueue} from "../../util/queue/fnQueue.js"; import {QueueMetrics} from "../../util/queue/options.js"; -import {BeaconDb} from "../../db/index.js"; +import {getHistoricalState} from "./getHistoricalState.js"; import { HistoricalStateRegenMetrics, HistoricalStateWorkerApi, HistoricalStateWorkerData, RegenErrorType, } from "./types.js"; -import {getHistoricalState} from "./getHistoricalState.js"; // most of this setup copied from networkCoreWorker.ts diff --git a/packages/beacon-node/src/chain/initState.ts b/packages/beacon-node/src/chain/initState.ts index 2883cdc8388e..ff683867d14b 100644 --- a/packages/beacon-node/src/chain/initState.ts +++ b/packages/beacon-node/src/chain/initState.ts @@ -1,17 +1,17 @@ +import {ChainForkConfig} from "@lodestar/config"; import { - computeEpochAtSlot, BeaconStateAllForks, CachedBeaconStateAllForks, + computeEpochAtSlot, computeStartSlotAtEpoch, } from "@lodestar/state-transition"; import {SignedBeaconBlock} from "@lodestar/types"; -import {ChainForkConfig} from "@lodestar/config"; import {Logger, toHex, toRootHex} from "@lodestar/utils"; import {GENESIS_SLOT} from "../constants/index.js"; import {IBeaconDb} from "../db/index.js"; import {Eth1Provider} from "../eth1/index.js"; -import {Metrics} from "../metrics/index.js"; import {Eth1Options} from "../eth1/options.js"; +import {Metrics} from "../metrics/index.js"; import {GenesisBuilder} from "./genesis/genesis.js"; import {GenesisResult} from "./genesis/interface.js"; diff --git a/packages/beacon-node/src/chain/interface.ts b/packages/beacon-node/src/chain/interface.ts index 3b44ffd594ae..67b011ec0246 100644 --- a/packages/beacon-node/src/chain/interface.ts +++ b/packages/beacon-node/src/chain/interface.ts @@ -1,64 +1,64 @@ -import {CompositeTypeAny, TreeView, Type} from "@chainsafe/ssz"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; +import {CompositeTypeAny, TreeView, Type} from "@chainsafe/ssz"; +import {BeaconConfig} from "@lodestar/config"; +import {CheckpointWithHex, IForkChoice, ProtoBlock} from "@lodestar/fork-choice"; import { - UintNum64, + BeaconStateAllForks, + CachedBeaconStateAllForks, + EpochShuffling, + Index2PubkeyCache, +} from "@lodestar/state-transition"; +import { + BeaconBlock, + BlindedBeaconBlock, + Epoch, + ExecutionPayload, Root, - phase0, - Slot, RootHex, - Epoch, + SignedBeaconBlock, + Slot, + UintNum64, ValidatorIndex, - deneb, Wei, - capella, altair, - BeaconBlock, - ExecutionPayload, - SignedBeaconBlock, - BlindedBeaconBlock, + capella, + deneb, + phase0, } from "@lodestar/types"; -import { - BeaconStateAllForks, - CachedBeaconStateAllForks, - EpochShuffling, - Index2PubkeyCache, -} from "@lodestar/state-transition"; -import {BeaconConfig} from "@lodestar/config"; import {Logger} from "@lodestar/utils"; -import {CheckpointWithHex, IForkChoice, ProtoBlock} from "@lodestar/fork-choice"; import {IEth1ForBlockProduction} from "../eth1/index.js"; -import {IExecutionEngine, IExecutionBuilder} from "../execution/index.js"; +import {IExecutionBuilder, IExecutionEngine} from "../execution/index.js"; import {Metrics} from "../metrics/metrics.js"; -import {IClock} from "../util/clock.js"; import {BufferPool} from "../util/bufferPool.js"; +import {IClock} from "../util/clock.js"; +import {CheckpointBalancesCache} from "./balancesCache.js"; +import {BeaconProposerCache, ProposerPreparationData} from "./beaconProposerCache.js"; +import {BlockInput, ImportBlockOpts} from "./blocks/types.js"; +import {IBlsVerifier} from "./bls/index.js"; import {ChainEventEmitter} from "./emitter.js"; +import {ForkchoiceCaller} from "./forkChoice/index.js"; +import {LightClientServer} from "./lightClient/index.js"; +import {AggregatedAttestationPool} from "./opPools/aggregatedAttestationPool.js"; +import {AttestationPool, OpPool, SyncCommitteeMessagePool, SyncContributionAndProofPool} from "./opPools/index.js"; +import {IChainOptions} from "./options.js"; +import {AssembledBlockType, BlockAttributes, BlockType} from "./produceBlock/produceBlockBody.js"; import {IStateRegenerator, RegenCaller} from "./regen/index.js"; -import {IBlsVerifier} from "./bls/index.js"; +import {ReprocessController} from "./reprocess.js"; +import {AttestationsRewards} from "./rewards/attestationsRewards.js"; +import {BlockRewards} from "./rewards/blockRewards.js"; +import {SyncCommitteeRewards} from "./rewards/syncCommitteeRewards.js"; import { - SeenAttesters, SeenAggregators, + SeenAttesters, SeenBlockProposers, - SeenSyncCommitteeMessages, SeenContributionAndProof, + SeenSyncCommitteeMessages, } from "./seenCache/index.js"; -import {AttestationPool, OpPool, SyncCommitteeMessagePool, SyncContributionAndProofPool} from "./opPools/index.js"; -import {LightClientServer} from "./lightClient/index.js"; -import {AggregatedAttestationPool} from "./opPools/aggregatedAttestationPool.js"; -import {BlockInput, ImportBlockOpts} from "./blocks/types.js"; -import {ReprocessController} from "./reprocess.js"; +import {SeenGossipBlockInput} from "./seenCache/index.js"; import {SeenAggregatedAttestations} from "./seenCache/seenAggregateAndProof.js"; -import {BeaconProposerCache, ProposerPreparationData} from "./beaconProposerCache.js"; -import {SeenBlockAttesters} from "./seenCache/seenBlockAttesters.js"; -import {CheckpointBalancesCache} from "./balancesCache.js"; -import {IChainOptions} from "./options.js"; -import {AssembledBlockType, BlockAttributes, BlockType} from "./produceBlock/produceBlockBody.js"; import {SeenAttestationDatas} from "./seenCache/seenAttestationData.js"; -import {SeenGossipBlockInput} from "./seenCache/index.js"; +import {SeenBlockAttesters} from "./seenCache/seenBlockAttesters.js"; import {ShufflingCache} from "./shufflingCache.js"; -import {BlockRewards} from "./rewards/blockRewards.js"; -import {AttestationsRewards} from "./rewards/attestationsRewards.js"; -import {SyncCommitteeRewards} from "./rewards/syncCommitteeRewards.js"; -import {ForkchoiceCaller} from "./forkChoice/index.js"; export {BlockType, type AssembledBlockType}; export {type ProposerPreparationData}; diff --git a/packages/beacon-node/src/chain/lightClient/index.ts b/packages/beacon-node/src/chain/lightClient/index.ts index 0a41ea059e73..94dadbd2a646 100644 --- a/packages/beacon-node/src/chain/lightClient/index.ts +++ b/packages/beacon-node/src/chain/lightClient/index.ts @@ -1,6 +1,30 @@ import {BitArray, CompositeViewDU} from "@chainsafe/ssz"; +import {routes} from "@lodestar/api"; +import {ChainForkConfig} from "@lodestar/config"; +import { + LightClientUpdateSummary, + isBetterUpdate, + toLightClientUpdateSummary, + upgradeLightClientHeader, +} from "@lodestar/light-client/spec"; +import { + ForkExecution, + ForkLightClient, + ForkName, + ForkSeq, + MIN_SYNC_COMMITTEE_PARTICIPANTS, + SYNC_COMMITTEE_SIZE, + forkLightClient, + highestFork, +} from "@lodestar/params"; +import { + CachedBeaconStateAltair, + computeStartSlotAtEpoch, + computeSyncPeriodAtEpoch, + computeSyncPeriodAtSlot, + executionPayloadToPayloadHeader, +} from "@lodestar/state-transition"; import { - altair, BeaconBlock, BeaconBlockBody, LightClientBootstrap, @@ -8,54 +32,30 @@ import { LightClientHeader, LightClientOptimisticUpdate, LightClientUpdate, - phase0, Root, RootHex, + SSZTypesFor, Slot, + SyncPeriod, + altair, + phase0, ssz, sszTypesFor, - SSZTypesFor, - SyncPeriod, } from "@lodestar/types"; -import {ChainForkConfig} from "@lodestar/config"; -import { - CachedBeaconStateAltair, - computeStartSlotAtEpoch, - computeSyncPeriodAtEpoch, - computeSyncPeriodAtSlot, - executionPayloadToPayloadHeader, -} from "@lodestar/state-transition"; -import { - isBetterUpdate, - toLightClientUpdateSummary, - LightClientUpdateSummary, - upgradeLightClientHeader, -} from "@lodestar/light-client/spec"; import {Logger, MapDef, pruneSetToMax, toRootHex} from "@lodestar/utils"; -import {routes} from "@lodestar/api"; -import { - MIN_SYNC_COMMITTEE_PARTICIPANTS, - SYNC_COMMITTEE_SIZE, - ForkName, - ForkSeq, - ForkExecution, - ForkLightClient, - highestFork, - forkLightClient, -} from "@lodestar/params"; +import {ZERO_HASH} from "../../constants/index.js"; import {IBeaconDb} from "../../db/index.js"; import {Metrics} from "../../metrics/index.js"; -import {ChainEventEmitter} from "../emitter.js"; import {byteArrayEquals} from "../../util/bytes.js"; -import {ZERO_HASH} from "../../constants/index.js"; +import {ChainEventEmitter} from "../emitter.js"; import {LightClientServerError, LightClientServerErrorCode} from "../errors/lightClientError.js"; import { + getBlockBodyExecutionHeaderProof, + getCurrentSyncCommitteeBranch, + getFinalizedRootProof, getNextSyncCommitteeBranch, getSyncCommitteesWitness, - getFinalizedRootProof, - getCurrentSyncCommitteeBranch, - getBlockBodyExecutionHeaderProof, } from "./proofs.js"; export type LightClientServerOpts = { diff --git a/packages/beacon-node/src/chain/lightClient/proofs.ts b/packages/beacon-node/src/chain/lightClient/proofs.ts index 8d273e30ae5c..d4380e66255f 100644 --- a/packages/beacon-node/src/chain/lightClient/proofs.ts +++ b/packages/beacon-node/src/chain/lightClient/proofs.ts @@ -1,11 +1,11 @@ import {Tree} from "@chainsafe/persistent-merkle-tree"; -import {BeaconStateAllForks, CachedBeaconStateAllForks} from "@lodestar/state-transition"; import { - FINALIZED_ROOT_GINDEX, BLOCK_BODY_EXECUTION_PAYLOAD_GINDEX, - ForkExecution, + FINALIZED_ROOT_GINDEX, FINALIZED_ROOT_GINDEX_ELECTRA, + ForkExecution, } from "@lodestar/params"; +import {BeaconStateAllForks, CachedBeaconStateAllForks} from "@lodestar/state-transition"; import {BeaconBlockBody, SSZTypesFor, ssz} from "@lodestar/types"; import {SyncCommitteeWitness} from "./types.js"; diff --git a/packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts b/packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts index 92d7383b8cad..c4d76db96997 100644 --- a/packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts +++ b/packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts @@ -1,40 +1,40 @@ -import {aggregateSignatures, Signature} from "@chainsafe/blst"; +import {Signature, aggregateSignatures} from "@chainsafe/blst"; import {BitArray} from "@chainsafe/ssz"; +import {ChainForkConfig} from "@lodestar/config"; +import {EpochDifference, IForkChoice} from "@lodestar/fork-choice"; import { ForkName, ForkSeq, - isForkPostElectra, MAX_ATTESTATIONS, MAX_ATTESTATIONS_ELECTRA, MAX_COMMITTEES_PER_SLOT, MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH, + isForkPostElectra, } from "@lodestar/params"; -import { - phase0, - Epoch, - Slot, - ssz, - ValidatorIndex, - RootHex, - electra, - isElectraAttestation, - Attestation, -} from "@lodestar/types"; import { CachedBeaconStateAllForks, - CachedBeaconStatePhase0, CachedBeaconStateAltair, + CachedBeaconStatePhase0, computeEpochAtSlot, computeStartSlotAtEpoch, getBlockRootAtSlot, } from "@lodestar/state-transition"; -import {IForkChoice, EpochDifference} from "@lodestar/fork-choice"; -import {MapDef, toRootHex, assert} from "@lodestar/utils"; -import {ChainForkConfig} from "@lodestar/config"; -import {intersectUint8Arrays, IntersectResult} from "../../util/bitArray.js"; -import {pruneBySlot, signatureFromBytesNoCheck} from "./utils.js"; +import { + Attestation, + Epoch, + RootHex, + Slot, + ValidatorIndex, + electra, + isElectraAttestation, + phase0, + ssz, +} from "@lodestar/types"; +import {assert, MapDef, toRootHex} from "@lodestar/utils"; +import {IntersectResult, intersectUint8Arrays} from "../../util/bitArray.js"; import {InsertOutcome} from "./types.js"; +import {pruneBySlot, signatureFromBytesNoCheck} from "./utils.js"; type DataRootHex = string; diff --git a/packages/beacon-node/src/chain/opPools/attestationPool.ts b/packages/beacon-node/src/chain/opPools/attestationPool.ts index 8d8fbb92c0f1..9809c9c6304a 100644 --- a/packages/beacon-node/src/chain/opPools/attestationPool.ts +++ b/packages/beacon-node/src/chain/opPools/attestationPool.ts @@ -1,9 +1,9 @@ -import {BitArray} from "@chainsafe/ssz"; import {Signature, aggregateSignatures} from "@chainsafe/blst"; -import {Slot, RootHex, isElectraAttestation, Attestation} from "@lodestar/types"; -import {MapDef, assert} from "@lodestar/utils"; -import {isForkPostElectra} from "@lodestar/params"; +import {BitArray} from "@chainsafe/ssz"; import {ChainForkConfig} from "@lodestar/config"; +import {isForkPostElectra} from "@lodestar/params"; +import {Attestation, RootHex, Slot, isElectraAttestation} from "@lodestar/types"; +import {assert, MapDef} from "@lodestar/utils"; import {IClock} from "../../util/clock.js"; import {InsertOutcome, OpPoolError, OpPoolErrorCode} from "./types.js"; import {isElectraAggregate, pruneBySlot, signatureFromBytesNoCheck} from "./utils.js"; diff --git a/packages/beacon-node/src/chain/opPools/opPool.ts b/packages/beacon-node/src/chain/opPools/opPool.ts index f71186c06d35..5eec1597a24e 100644 --- a/packages/beacon-node/src/chain/opPools/opPool.ts +++ b/packages/beacon-node/src/chain/opPools/opPool.ts @@ -1,3 +1,13 @@ +import {Id, Repository} from "@lodestar/db"; +import { + BLS_WITHDRAWAL_PREFIX, + ForkSeq, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTER_SLASHINGS_ELECTRA, + MAX_BLS_TO_EXECUTION_CHANGES, + MAX_PROPOSER_SLASHINGS, + MAX_VOLUNTARY_EXITS, +} from "@lodestar/params"; import { CachedBeaconStateAllForks, computeEpochAtSlot, @@ -5,22 +15,12 @@ import { getAttesterSlashableIndices, isValidVoluntaryExit, } from "@lodestar/state-transition"; -import {Repository, Id} from "@lodestar/db"; -import { - MAX_PROPOSER_SLASHINGS, - MAX_VOLUNTARY_EXITS, - MAX_BLS_TO_EXECUTION_CHANGES, - BLS_WITHDRAWAL_PREFIX, - MAX_ATTESTER_SLASHINGS, - ForkSeq, - MAX_ATTESTER_SLASHINGS_ELECTRA, -} from "@lodestar/params"; +import {AttesterSlashing, Epoch, SignedBeaconBlock, ValidatorIndex, capella, phase0, ssz} from "@lodestar/types"; import {fromHex, toHex, toRootHex} from "@lodestar/utils"; -import {Epoch, phase0, capella, ssz, ValidatorIndex, SignedBeaconBlock, AttesterSlashing} from "@lodestar/types"; import {IBeaconDb} from "../../db/index.js"; +import {Metrics} from "../../metrics/metrics.js"; import {SignedBLSToExecutionChangeVersioned} from "../../util/types.js"; import {BlockType} from "../interface.js"; -import {Metrics} from "../../metrics/metrics.js"; import {BlockProductionStep} from "../produceBlock/produceBlockBody.js"; import {isValidBlsToExecutionChangeForBlockInclusion} from "./utils.js"; diff --git a/packages/beacon-node/src/chain/opPools/syncCommitteeMessagePool.ts b/packages/beacon-node/src/chain/opPools/syncCommitteeMessagePool.ts index 4de11e447231..6551ee625491 100644 --- a/packages/beacon-node/src/chain/opPools/syncCommitteeMessagePool.ts +++ b/packages/beacon-node/src/chain/opPools/syncCommitteeMessagePool.ts @@ -1,7 +1,7 @@ -import {BitArray} from "@chainsafe/ssz"; import {Signature, aggregateSignatures} from "@chainsafe/blst"; +import {BitArray} from "@chainsafe/ssz"; import {SYNC_COMMITTEE_SIZE, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; -import {altair, Root, Slot, SubcommitteeIndex} from "@lodestar/types"; +import {Root, Slot, SubcommitteeIndex, altair} from "@lodestar/types"; import {MapDef, toRootHex} from "@lodestar/utils"; import {IClock} from "../../util/clock.js"; import {InsertOutcome, OpPoolError, OpPoolErrorCode} from "./types.js"; diff --git a/packages/beacon-node/src/chain/opPools/syncContributionAndProofPool.ts b/packages/beacon-node/src/chain/opPools/syncContributionAndProofPool.ts index 81363be218d8..0f25032e1d7e 100644 --- a/packages/beacon-node/src/chain/opPools/syncContributionAndProofPool.ts +++ b/packages/beacon-node/src/chain/opPools/syncContributionAndProofPool.ts @@ -1,8 +1,8 @@ -import {BitArray} from "@chainsafe/ssz"; import {Signature, aggregateSignatures} from "@chainsafe/blst"; +import {BitArray} from "@chainsafe/ssz"; import {SYNC_COMMITTEE_SIZE, SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params"; -import {altair, Slot, Root, ssz} from "@lodestar/types"; import {G2_POINT_AT_INFINITY} from "@lodestar/state-transition"; +import {Root, Slot, altair, ssz} from "@lodestar/types"; import {MapDef, toRootHex} from "@lodestar/utils"; import {InsertOutcome, OpPoolError, OpPoolErrorCode} from "./types.js"; import {pruneBySlot, signatureFromBytesNoCheck} from "./utils.js"; diff --git a/packages/beacon-node/src/chain/options.ts b/packages/beacon-node/src/chain/options.ts index cf83c4432984..f87fffd7b363 100644 --- a/packages/beacon-node/src/chain/options.ts +++ b/packages/beacon-node/src/chain/options.ts @@ -1,5 +1,6 @@ import {SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY} from "@lodestar/params"; import {defaultOptions as defaultValidatorOptions} from "@lodestar/validator"; +import {DEFAULT_STATE_ARCHIVE_MODE} from "./archiver/archiver.js"; import {ArchiverOpts} from "./archiver/interface.js"; import {ForkChoiceOpts} from "./forkChoice/index.js"; import {LightClientServerOpts} from "./lightClient/index.js"; @@ -7,7 +8,6 @@ import {ShufflingCacheOpts} from "./shufflingCache.js"; import {DEFAULT_MAX_BLOCK_STATES, FIFOBlockStateCacheOpts} from "./stateCache/fifoBlockStateCache.js"; import {PersistentCheckpointStateCacheOpts} from "./stateCache/persistentCheckpointsCache.js"; import {DEFAULT_MAX_CP_STATE_EPOCHS_IN_MEMORY} from "./stateCache/persistentCheckpointsCache.js"; -import {DEFAULT_STATE_ARCHIVE_MODE} from "./archiver/archiver.js"; export {StateArchiveMode} from "./archiver/interface.js"; export {DEFAULT_STATE_ARCHIVE_MODE} from "./archiver/archiver.js"; diff --git a/packages/beacon-node/src/chain/prepareNextSlot.ts b/packages/beacon-node/src/chain/prepareNextSlot.ts index bda618758842..40cadb3774c7 100644 --- a/packages/beacon-node/src/chain/prepareNextSlot.ts +++ b/packages/beacon-node/src/chain/prepareNextSlot.ts @@ -1,24 +1,24 @@ +import {routes} from "@lodestar/api"; +import {ChainForkConfig} from "@lodestar/config"; +import {ForkExecution, ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params"; import { - computeEpochAtSlot, - isExecutionStateType, - computeTimeAtSlot, + CachedBeaconStateAllForks, CachedBeaconStateExecutions, StateHashTreeRootSource, - CachedBeaconStateAllForks, + computeEpochAtSlot, + computeTimeAtSlot, + isExecutionStateType, } from "@lodestar/state-transition"; -import {ChainForkConfig} from "@lodestar/config"; -import {ForkSeq, SLOTS_PER_EPOCH, ForkExecution} from "@lodestar/params"; import {Slot} from "@lodestar/types"; -import {Logger, sleep, fromHex, isErrorAborted} from "@lodestar/utils"; -import {routes} from "@lodestar/api"; +import {Logger, fromHex, isErrorAborted, sleep} from "@lodestar/utils"; import {GENESIS_SLOT, ZERO_HASH_HEX} from "../constants/constants.js"; import {Metrics} from "../metrics/index.js"; import {ClockEvent} from "../util/clock.js"; import {isQueueErrorAborted} from "../util/queue/index.js"; -import {prepareExecutionPayload, getPayloadAttributesForSSE} from "./produceBlock/produceBlockBody.js"; +import {ForkchoiceCaller} from "./forkChoice/index.js"; import {IBeaconChain} from "./interface.js"; +import {getPayloadAttributesForSSE, prepareExecutionPayload} from "./produceBlock/produceBlockBody.js"; import {RegenCaller} from "./regen/index.js"; -import {ForkchoiceCaller} from "./forkChoice/index.js"; /* With 12s slot times, this scheduler will run 4s before the start of each slot (`12 / 3 = 4`). */ export const SCHEDULER_LOOKAHEAD_FACTOR = 3; diff --git a/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts b/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts index a353c4e54ff9..d26703050070 100644 --- a/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts +++ b/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts @@ -1,44 +1,44 @@ +import {ChainForkConfig} from "@lodestar/config"; +import {ForkExecution, ForkSeq, isForkExecution} from "@lodestar/params"; +import { + CachedBeaconStateAllForks, + CachedBeaconStateBellatrix, + CachedBeaconStateCapella, + CachedBeaconStateExecutions, + computeEpochAtSlot, + computeTimeAtSlot, + getCurrentEpoch, + getExpectedWithdrawals, + getRandaoMix, + isMergeTransitionComplete, +} from "@lodestar/state-transition"; import { + BLSPubkey, + BLSSignature, + BeaconBlock, + BeaconBlockBody, + BlindedBeaconBlock, + BlindedBeaconBlockBody, Bytes32, + ExecutionPayloadHeader, Root, RootHex, + SSEPayloadAttributes, Slot, - ssz, ValidatorIndex, - BLSPubkey, - BLSSignature, + Wei, capella, deneb, - Wei, - SSEPayloadAttributes, - BeaconBlock, - BeaconBlockBody, - ExecutionPayloadHeader, - BlindedBeaconBlockBody, - BlindedBeaconBlock, - sszTypesFor, electra, + ssz, + sszTypesFor, } from "@lodestar/types"; -import { - CachedBeaconStateAllForks, - CachedBeaconStateCapella, - CachedBeaconStateBellatrix, - CachedBeaconStateExecutions, - computeEpochAtSlot, - computeTimeAtSlot, - getRandaoMix, - getCurrentEpoch, - isMergeTransitionComplete, - getExpectedWithdrawals, -} from "@lodestar/state-transition"; -import {ChainForkConfig} from "@lodestar/config"; -import {ForkSeq, ForkExecution, isForkExecution} from "@lodestar/params"; -import {toHex, sleep, Logger, toRootHex} from "@lodestar/utils"; -import type {BeaconChain} from "../chain.js"; -import {PayloadId, IExecutionEngine, IExecutionBuilder, PayloadAttributes} from "../../execution/index.js"; +import {Logger, sleep, toHex, toRootHex} from "@lodestar/utils"; import {ZERO_HASH, ZERO_HASH_HEX} from "../../constants/index.js"; import {IEth1ForBlockProduction} from "../../eth1/index.js"; import {numToQuantity} from "../../eth1/provider/utils.js"; +import {IExecutionBuilder, IExecutionEngine, PayloadAttributes, PayloadId} from "../../execution/index.js"; +import type {BeaconChain} from "../chain.js"; import {CommonBlockBody} from "../interface.js"; import {validateBlobsAndKzgCommitments} from "./validateBlobsAndKzgCommitments.js"; diff --git a/packages/beacon-node/src/chain/regen/errors.ts b/packages/beacon-node/src/chain/regen/errors.ts index 7c1573b415f8..eb41e8321da3 100644 --- a/packages/beacon-node/src/chain/regen/errors.ts +++ b/packages/beacon-node/src/chain/regen/errors.ts @@ -1,4 +1,4 @@ -import {Root, Slot, RootHex} from "@lodestar/types"; +import {Root, RootHex, Slot} from "@lodestar/types"; export enum RegenErrorCode { BLOCK_NOT_IN_FORKCHOICE = "REGEN_ERROR_BLOCK_NOT_IN_FORKCHOICE", diff --git a/packages/beacon-node/src/chain/regen/interface.ts b/packages/beacon-node/src/chain/regen/interface.ts index 031d19860789..b70fbc059875 100644 --- a/packages/beacon-node/src/chain/regen/interface.ts +++ b/packages/beacon-node/src/chain/regen/interface.ts @@ -1,7 +1,7 @@ -import {phase0, Slot, RootHex, Epoch, BeaconBlock} from "@lodestar/types"; -import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; import {routes} from "@lodestar/api"; import {ProtoBlock} from "@lodestar/fork-choice"; +import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; +import {BeaconBlock, Epoch, RootHex, Slot, phase0} from "@lodestar/types"; import {CheckpointHex} from "../stateCache/index.js"; export enum RegenCaller { diff --git a/packages/beacon-node/src/chain/regen/queued.ts b/packages/beacon-node/src/chain/regen/queued.ts index 694e8635a3b7..7b812c04dc8d 100644 --- a/packages/beacon-node/src/chain/regen/queued.ts +++ b/packages/beacon-node/src/chain/regen/queued.ts @@ -1,15 +1,15 @@ -import {phase0, Slot, RootHex, Epoch, BeaconBlock} from "@lodestar/types"; +import {routes} from "@lodestar/api"; import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice"; import {CachedBeaconStateAllForks, UnfinalizedPubkeyIndexMap, computeEpochAtSlot} from "@lodestar/state-transition"; +import {BeaconBlock, Epoch, RootHex, Slot, phase0} from "@lodestar/types"; import {Logger, toRootHex} from "@lodestar/utils"; -import {routes} from "@lodestar/api"; -import {CheckpointHex, toCheckpointHex} from "../stateCache/index.js"; import {Metrics} from "../../metrics/index.js"; import {JobItemQueue} from "../../util/queue/index.js"; +import {CheckpointHex, toCheckpointHex} from "../stateCache/index.js"; import {BlockStateCache, CheckpointStateCache} from "../stateCache/types.js"; -import {IStateRegenerator, IStateRegeneratorInternal, RegenCaller, RegenFnName, StateCloneOpts} from "./interface.js"; -import {StateRegenerator, RegenModules} from "./regen.js"; import {RegenError, RegenErrorCode} from "./errors.js"; +import {IStateRegenerator, IStateRegeneratorInternal, RegenCaller, RegenFnName, StateCloneOpts} from "./interface.js"; +import {RegenModules, StateRegenerator} from "./regen.js"; const REGEN_QUEUE_MAX_LEN = 256; // TODO: Should this constant be lower than above? 256 feels high diff --git a/packages/beacon-node/src/chain/regen/regen.ts b/packages/beacon-node/src/chain/regen/regen.ts index 7c663c6e0d3d..073556d8162f 100644 --- a/packages/beacon-node/src/chain/regen/regen.ts +++ b/packages/beacon-node/src/chain/regen/regen.ts @@ -1,26 +1,26 @@ -import {phase0, Slot, RootHex, BeaconBlock, SignedBeaconBlock} from "@lodestar/types"; +import {ChainForkConfig} from "@lodestar/config"; +import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice"; +import {SLOTS_PER_EPOCH} from "@lodestar/params"; import { CachedBeaconStateAllForks, + DataAvailableStatus, + ExecutionPayloadStatus, + StateHashTreeRootSource, computeEpochAtSlot, computeStartSlotAtEpoch, - ExecutionPayloadStatus, - DataAvailableStatus, processSlots, stateTransition, - StateHashTreeRootSource, } from "@lodestar/state-transition"; -import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice"; +import {BeaconBlock, RootHex, SignedBeaconBlock, Slot, phase0} from "@lodestar/types"; import {Logger, fromHex, toRootHex} from "@lodestar/utils"; -import {SLOTS_PER_EPOCH} from "@lodestar/params"; -import {ChainForkConfig} from "@lodestar/config"; -import {Metrics} from "../../metrics/index.js"; import {IBeaconDb} from "../../db/index.js"; +import {Metrics} from "../../metrics/index.js"; +import {nextEventLoop} from "../../util/eventLoop.js"; import {getCheckpointFromState} from "../blocks/utils/checkpoint.js"; import {ChainEvent, ChainEventEmitter} from "../emitter.js"; -import {CheckpointStateCache, BlockStateCache} from "../stateCache/types.js"; -import {nextEventLoop} from "../../util/eventLoop.js"; -import {IStateRegeneratorInternal, RegenCaller, StateCloneOpts} from "./interface.js"; +import {BlockStateCache, CheckpointStateCache} from "../stateCache/types.js"; import {RegenError, RegenErrorCode} from "./errors.js"; +import {IStateRegeneratorInternal, RegenCaller, StateCloneOpts} from "./interface.js"; export type RegenModules = { db: IBeaconDb; diff --git a/packages/beacon-node/src/chain/reprocess.ts b/packages/beacon-node/src/chain/reprocess.ts index 4c91ef07ff69..a4d8fa43967d 100644 --- a/packages/beacon-node/src/chain/reprocess.ts +++ b/packages/beacon-node/src/chain/reprocess.ts @@ -1,4 +1,4 @@ -import {Slot, RootHex} from "@lodestar/types"; +import {RootHex, Slot} from "@lodestar/types"; import {MapDef} from "@lodestar/utils"; import {Metrics} from "../metrics/index.js"; diff --git a/packages/beacon-node/src/chain/rewards/attestationsRewards.ts b/packages/beacon-node/src/chain/rewards/attestationsRewards.ts index 588b310f87ea..14f2f1ccbc79 100644 --- a/packages/beacon-node/src/chain/rewards/attestationsRewards.ts +++ b/packages/beacon-node/src/chain/rewards/attestationsRewards.ts @@ -1,4 +1,5 @@ -import {Epoch, ValidatorIndex} from "@lodestar/types"; +import {routes} from "@lodestar/api"; +import {BeaconConfig} from "@lodestar/config"; import { EFFECTIVE_BALANCE_INCREMENT, ForkName, @@ -10,7 +11,6 @@ import { TIMELY_TARGET_FLAG_INDEX, WEIGHT_DENOMINATOR, } from "@lodestar/params"; -import {routes} from "@lodestar/api"; import { CachedBeaconStateAllForks, CachedBeaconStateAltair, @@ -23,7 +23,7 @@ import { hasMarkers, isInInactivityLeak, } from "@lodestar/state-transition"; -import {BeaconConfig} from "@lodestar/config"; +import {Epoch, ValidatorIndex} from "@lodestar/types"; import {fromHex} from "@lodestar/utils"; export type AttestationsRewards = routes.beacon.AttestationsRewards; diff --git a/packages/beacon-node/src/chain/rewards/blockRewards.ts b/packages/beacon-node/src/chain/rewards/blockRewards.ts index 19a59aaa028e..4b9c95de4c3b 100644 --- a/packages/beacon-node/src/chain/rewards/blockRewards.ts +++ b/packages/beacon-node/src/chain/rewards/blockRewards.ts @@ -1,3 +1,5 @@ +import {routes} from "@lodestar/api"; +import {ForkName, WHISTLEBLOWER_REWARD_QUOTIENT} from "@lodestar/params"; import { CachedBeaconStateAllForks, CachedBeaconStateAltair, @@ -6,8 +8,6 @@ import { processAttestationsAltair, } from "@lodestar/state-transition"; import {BeaconBlock, altair, phase0} from "@lodestar/types"; -import {ForkName, WHISTLEBLOWER_REWARD_QUOTIENT} from "@lodestar/params"; -import {routes} from "@lodestar/api"; export type BlockRewards = routes.beacon.BlockRewards; type SubRewardValue = number; // All reward values should be integer diff --git a/packages/beacon-node/src/chain/rewards/syncCommitteeRewards.ts b/packages/beacon-node/src/chain/rewards/syncCommitteeRewards.ts index 71d345e32811..55ab69ec0285 100644 --- a/packages/beacon-node/src/chain/rewards/syncCommitteeRewards.ts +++ b/packages/beacon-node/src/chain/rewards/syncCommitteeRewards.ts @@ -1,7 +1,7 @@ +import {routes} from "@lodestar/api"; +import {ForkName, SYNC_COMMITTEE_SIZE} from "@lodestar/params"; import {CachedBeaconStateAllForks, CachedBeaconStateAltair} from "@lodestar/state-transition"; import {BeaconBlock, ValidatorIndex, altair} from "@lodestar/types"; -import {ForkName, SYNC_COMMITTEE_SIZE} from "@lodestar/params"; -import {routes} from "@lodestar/api"; export type SyncCommitteeRewards = routes.beacon.SyncCommitteeRewards; type BalanceRecord = {val: number}; // Use val for convenient way to increment/decrement balance diff --git a/packages/beacon-node/src/chain/seenCache/seenAttestationData.ts b/packages/beacon-node/src/chain/seenCache/seenAttestationData.ts index a0aa6db35893..8e0dfcb3bd96 100644 --- a/packages/beacon-node/src/chain/seenCache/seenAttestationData.ts +++ b/packages/beacon-node/src/chain/seenCache/seenAttestationData.ts @@ -1,5 +1,5 @@ import {BitArray} from "@chainsafe/ssz"; -import {CommitteeIndex, phase0, RootHex, Slot} from "@lodestar/types"; +import {CommitteeIndex, RootHex, Slot, phase0} from "@lodestar/types"; import {MapDef} from "@lodestar/utils"; import {Metrics} from "../../metrics/metrics.js"; import {InsertOutcome} from "../opPools/types.js"; diff --git a/packages/beacon-node/src/chain/seenCache/seenCommittee.ts b/packages/beacon-node/src/chain/seenCache/seenCommittee.ts index 38d7f67c74a2..9d7e930c94d7 100644 --- a/packages/beacon-node/src/chain/seenCache/seenCommittee.ts +++ b/packages/beacon-node/src/chain/seenCache/seenCommittee.ts @@ -1,4 +1,4 @@ -import {SubcommitteeIndex, Slot, ValidatorIndex, RootHex} from "@lodestar/types"; +import {RootHex, Slot, SubcommitteeIndex, ValidatorIndex} from "@lodestar/types"; import {MapDef} from "@lodestar/utils"; /** diff --git a/packages/beacon-node/src/chain/seenCache/seenGossipBlockInput.ts b/packages/beacon-node/src/chain/seenCache/seenGossipBlockInput.ts index 1c03979b7d77..fd0d396bb0ba 100644 --- a/packages/beacon-node/src/chain/seenCache/seenGossipBlockInput.ts +++ b/packages/beacon-node/src/chain/seenCache/seenGossipBlockInput.ts @@ -1,20 +1,20 @@ -import {deneb, RootHex, SignedBeaconBlock, ssz} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; +import {BLOBSIDECAR_FIXED_SIZE, ForkName, isForkBlobs} from "@lodestar/params"; +import {RootHex, SignedBeaconBlock, deneb, ssz} from "@lodestar/types"; import {pruneSetToMax, toRootHex} from "@lodestar/utils"; -import {BLOBSIDECAR_FIXED_SIZE, isForkBlobs, ForkName} from "@lodestar/params"; +import {Metrics} from "../../metrics/index.js"; import { + BlobsSource, BlockInput, - NullBlockInput, - getBlockInput, - BlockSource, BlockInputDataBlobs, + BlockSource, CachedData, GossipedInputType, + NullBlockInput, + getBlockInput, getBlockInputBlobs, - BlobsSource, } from "../blocks/types.js"; -import {Metrics} from "../../metrics/index.js"; export enum BlockInputAvailabilitySource { GOSSIP = "gossip", diff --git a/packages/beacon-node/src/chain/stateCache/blockStateCacheImpl.ts b/packages/beacon-node/src/chain/stateCache/blockStateCacheImpl.ts index 1cb67cd6cf09..886f6e386309 100644 --- a/packages/beacon-node/src/chain/stateCache/blockStateCacheImpl.ts +++ b/packages/beacon-node/src/chain/stateCache/blockStateCacheImpl.ts @@ -1,6 +1,6 @@ -import {Epoch, RootHex} from "@lodestar/types"; -import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; import {routes} from "@lodestar/api"; +import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; +import {Epoch, RootHex} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; import {Metrics} from "../../metrics/index.js"; import {StateCloneOpts} from "../regen/interface.js"; diff --git a/packages/beacon-node/src/chain/stateCache/fifoBlockStateCache.ts b/packages/beacon-node/src/chain/stateCache/fifoBlockStateCache.ts index 7766daf3c5b3..eec1fce5d6c2 100644 --- a/packages/beacon-node/src/chain/stateCache/fifoBlockStateCache.ts +++ b/packages/beacon-node/src/chain/stateCache/fifoBlockStateCache.ts @@ -1,6 +1,6 @@ -import {RootHex} from "@lodestar/types"; -import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; import {routes} from "@lodestar/api"; +import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; +import {RootHex} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; import {Metrics} from "../../metrics/index.js"; import {LinkedList} from "../../util/array.js"; diff --git a/packages/beacon-node/src/chain/stateCache/inMemoryCheckpointsCache.ts b/packages/beacon-node/src/chain/stateCache/inMemoryCheckpointsCache.ts index 38aeabb97955..4caa6779f697 100644 --- a/packages/beacon-node/src/chain/stateCache/inMemoryCheckpointsCache.ts +++ b/packages/beacon-node/src/chain/stateCache/inMemoryCheckpointsCache.ts @@ -1,11 +1,11 @@ -import {phase0, Epoch, RootHex} from "@lodestar/types"; +import {routes} from "@lodestar/api"; import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; +import {Epoch, RootHex, phase0} from "@lodestar/types"; import {MapDef, toRootHex} from "@lodestar/utils"; -import {routes} from "@lodestar/api"; import {Metrics} from "../../metrics/index.js"; import {StateCloneOpts} from "../regen/interface.js"; import {MapTracker} from "./mapMetrics.js"; -import {CheckpointStateCache, CacheItemType} from "./types.js"; +import {CacheItemType, CheckpointStateCache} from "./types.js"; export type CheckpointHex = {epoch: Epoch; rootHex: RootHex}; const MAX_EPOCHS = 10; diff --git a/packages/beacon-node/src/chain/stateCache/persistentCheckpointsCache.ts b/packages/beacon-node/src/chain/stateCache/persistentCheckpointsCache.ts index 0719efcfd309..4c9a8b0f1265 100644 --- a/packages/beacon-node/src/chain/stateCache/persistentCheckpointsCache.ts +++ b/packages/beacon-node/src/chain/stateCache/persistentCheckpointsCache.ts @@ -1,18 +1,18 @@ -import {phase0, Epoch, RootHex} from "@lodestar/types"; -import {CachedBeaconStateAllForks, computeStartSlotAtEpoch, getBlockRootAtSlot} from "@lodestar/state-transition"; -import {Logger, MapDef, fromHex, sleep, toHex, toRootHex} from "@lodestar/utils"; import {routes} from "@lodestar/api"; -import {loadCachedBeaconState} from "@lodestar/state-transition"; import {INTERVALS_PER_SLOT} from "@lodestar/params"; +import {CachedBeaconStateAllForks, computeStartSlotAtEpoch, getBlockRootAtSlot} from "@lodestar/state-transition"; +import {loadCachedBeaconState} from "@lodestar/state-transition"; +import {Epoch, RootHex, phase0} from "@lodestar/types"; +import {Logger, MapDef, fromHex, sleep, toHex, toRootHex} from "@lodestar/utils"; import {Metrics} from "../../metrics/index.js"; -import {IClock} from "../../util/clock.js"; -import {ShufflingCache} from "../shufflingCache.js"; import {AllocSource, BufferPool, BufferWithKey} from "../../util/bufferPool.js"; +import {IClock} from "../../util/clock.js"; import {StateCloneOpts} from "../regen/interface.js"; import {serializeState} from "../serializeState.js"; -import {MapTracker} from "./mapMetrics.js"; +import {ShufflingCache} from "../shufflingCache.js"; import {CPStateDatastore, DatastoreKey, datastoreKeyToCheckpoint} from "./datastore/index.js"; -import {CheckpointHex, CacheItemType, CheckpointStateCache, BlockStateCache} from "./types.js"; +import {MapTracker} from "./mapMetrics.js"; +import {BlockStateCache, CacheItemType, CheckpointHex, CheckpointStateCache} from "./types.js"; export type PersistentCheckpointStateCacheOpts = { /** Keep max n states in memory, persist the rest to disk */ diff --git a/packages/beacon-node/src/chain/stateCache/types.ts b/packages/beacon-node/src/chain/stateCache/types.ts index 1e8d6bd1bd62..403b469dd352 100644 --- a/packages/beacon-node/src/chain/stateCache/types.ts +++ b/packages/beacon-node/src/chain/stateCache/types.ts @@ -1,6 +1,6 @@ +import {routes} from "@lodestar/api"; import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; import {Epoch, RootHex, phase0} from "@lodestar/types"; -import {routes} from "@lodestar/api"; import {StateCloneOpts} from "../regen/interface.js"; export type CheckpointHex = {epoch: Epoch; rootHex: RootHex}; diff --git a/packages/beacon-node/src/chain/validation/aggregateAndProof.ts b/packages/beacon-node/src/chain/validation/aggregateAndProof.ts index 6d6eab6ec15a..781e63cf623a 100644 --- a/packages/beacon-node/src/chain/validation/aggregateAndProof.ts +++ b/packages/beacon-node/src/chain/validation/aggregateAndProof.ts @@ -1,15 +1,14 @@ import {ForkName, ForkSeq} from "@lodestar/params"; -import {electra, phase0, RootHex, ssz, IndexedAttestation, SignedAggregateAndProof} from "@lodestar/types"; import { computeEpochAtSlot, - isAggregatorFromCommitteeLength, createAggregateSignatureSetFromComponents, + isAggregatorFromCommitteeLength, } from "@lodestar/state-transition"; +import {IndexedAttestation, RootHex, SignedAggregateAndProof, electra, phase0, ssz} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; -import {IBeaconChain} from "../index.js"; import {AttestationError, AttestationErrorCode, GossipAction} from "../errors/index.js"; +import {IBeaconChain} from "../index.js"; import {RegenCaller} from "../regen/index.js"; -import {getSelectionProofSignatureSet, getAggregateAndProofSignatureSet} from "./signatureSets/index.js"; import { getAttestationDataSigningRoot, getCommitteeIndices, @@ -18,6 +17,7 @@ import { verifyHeadBlockAndTargetRoot, verifyPropagationSlotRange, } from "./attestation.js"; +import {getAggregateAndProofSignatureSet, getSelectionProofSignatureSet} from "./signatureSets/index.js"; export type AggregateAndProofValidationResult = { indexedAttestation: IndexedAttestation; diff --git a/packages/beacon-node/src/chain/validation/attestation.ts b/packages/beacon-node/src/chain/validation/attestation.ts index 0b3f490e4129..e49a3f79450c 100644 --- a/packages/beacon-node/src/chain/validation/attestation.ts +++ b/packages/beacon-node/src/chain/validation/attestation.ts @@ -1,54 +1,54 @@ import {BitArray} from "@chainsafe/ssz"; -import { - phase0, - Epoch, - Root, - Slot, - RootHex, - ssz, - electra, - isElectraAttestation, - CommitteeIndex, - Attestation, - IndexedAttestation, -} from "@lodestar/types"; +import {BeaconConfig} from "@lodestar/config"; import {ProtoBlock} from "@lodestar/fork-choice"; import { ATTESTATION_SUBNET_COUNT, - SLOTS_PER_EPOCH, + DOMAIN_BEACON_ATTESTER, ForkName, ForkSeq, - DOMAIN_BEACON_ATTESTER, + SLOTS_PER_EPOCH, isForkPostElectra, } from "@lodestar/params"; import { - computeEpochAtSlot, - createSingleSignatureSetFromComponents, - SingleSignatureSet, EpochCacheError, EpochCacheErrorCode, EpochShuffling, - computeStartSlotAtEpoch, + SingleSignatureSet, + computeEpochAtSlot, computeSigningRoot, + computeStartSlotAtEpoch, + createSingleSignatureSetFromComponents, } from "@lodestar/state-transition"; -import {BeaconConfig} from "@lodestar/config"; +import { + Attestation, + CommitteeIndex, + Epoch, + IndexedAttestation, + Root, + RootHex, + Slot, + electra, + isElectraAttestation, + phase0, + ssz, +} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; -import {AttestationError, AttestationErrorCode, GossipAction} from "../errors/index.js"; import {MAXIMUM_GOSSIP_CLOCK_DISPARITY_SEC} from "../../constants/index.js"; -import {RegenCaller} from "../regen/index.js"; +import {sszDeserializeAttestation} from "../../network/gossip/topic.js"; +import {getShufflingDependentRoot} from "../../util/dependentRoot.js"; import { getAggregationBitsFromAttestationSerialized, getAttDataFromSignedAggregateAndProofElectra, + getAttDataFromSignedAggregateAndProofPhase0, getCommitteeBitsFromAttestationSerialized, getCommitteeBitsFromSignedAggregateAndProofElectra, - getAttDataFromSignedAggregateAndProofPhase0, getSignatureFromAttestationSerialized, } from "../../util/sszBytes.js"; -import {AttestationDataCacheEntry, SeenAttDataKey} from "../seenCache/seenAttestationData.js"; -import {sszDeserializeAttestation} from "../../network/gossip/topic.js"; import {Result, wrapError} from "../../util/wrapError.js"; +import {AttestationError, AttestationErrorCode, GossipAction} from "../errors/index.js"; import {IBeaconChain} from "../interface.js"; -import {getShufflingDependentRoot} from "../../util/dependentRoot.js"; +import {RegenCaller} from "../regen/index.js"; +import {AttestationDataCacheEntry, SeenAttDataKey} from "../seenCache/seenAttestationData.js"; export type BatchResult = { results: Result[]; diff --git a/packages/beacon-node/src/chain/validation/attesterSlashing.ts b/packages/beacon-node/src/chain/validation/attesterSlashing.ts index 5da146a67a86..c097774ecb02 100644 --- a/packages/beacon-node/src/chain/validation/attesterSlashing.ts +++ b/packages/beacon-node/src/chain/validation/attesterSlashing.ts @@ -1,11 +1,11 @@ -import {phase0} from "@lodestar/types"; import { - getAttesterSlashableIndices, assertValidAttesterSlashing, + getAttesterSlashableIndices, getAttesterSlashingSignatureSets, } from "@lodestar/state-transition"; -import {IBeaconChain} from "../index.js"; +import {phase0} from "@lodestar/types"; import {AttesterSlashingError, AttesterSlashingErrorCode, GossipAction} from "../errors/index.js"; +import {IBeaconChain} from "../index.js"; export async function validateApiAttesterSlashing( chain: IBeaconChain, diff --git a/packages/beacon-node/src/chain/validation/blobSidecar.ts b/packages/beacon-node/src/chain/validation/blobSidecar.ts index 4c82d7be153d..3b90972f62b1 100644 --- a/packages/beacon-node/src/chain/validation/blobSidecar.ts +++ b/packages/beacon-node/src/chain/validation/blobSidecar.ts @@ -1,12 +1,12 @@ -import {deneb, Root, Slot, ssz} from "@lodestar/types"; -import {toRootHex, verifyMerkleBranch} from "@lodestar/utils"; -import {computeStartSlotAtEpoch, getBlockHeaderProposerSignatureSet} from "@lodestar/state-transition"; import {KZG_COMMITMENT_INCLUSION_PROOF_DEPTH, KZG_COMMITMENT_SUBTREE_INDEX0} from "@lodestar/params"; +import {computeStartSlotAtEpoch, getBlockHeaderProposerSignatureSet} from "@lodestar/state-transition"; +import {Root, Slot, deneb, ssz} from "@lodestar/types"; +import {toRootHex, verifyMerkleBranch} from "@lodestar/utils"; -import {BlobSidecarGossipError, BlobSidecarErrorCode} from "../errors/blobSidecarError.js"; -import {GossipAction} from "../errors/gossipValidation.js"; -import {ckzg} from "../../util/kzg.js"; import {byteArrayEquals} from "../../util/bytes.js"; +import {ckzg} from "../../util/kzg.js"; +import {BlobSidecarErrorCode, BlobSidecarGossipError} from "../errors/blobSidecarError.js"; +import {GossipAction} from "../errors/gossipValidation.js"; import {IBeaconChain} from "../interface.js"; import {RegenCaller} from "../regen/index.js"; diff --git a/packages/beacon-node/src/chain/validation/block.ts b/packages/beacon-node/src/chain/validation/block.ts index aabc1b14958a..1b5251f77809 100644 --- a/packages/beacon-node/src/chain/validation/block.ts +++ b/packages/beacon-node/src/chain/validation/block.ts @@ -1,18 +1,18 @@ import {ChainForkConfig} from "@lodestar/config"; +import {ForkName} from "@lodestar/params"; import { computeStartSlotAtEpoch, computeTimeAtSlot, + getBlockProposerSignatureSet, isExecutionBlockBodyType, - isExecutionStateType, isExecutionEnabled, - getBlockProposerSignatureSet, + isExecutionStateType, } from "@lodestar/state-transition"; -import {sleep, toRootHex} from "@lodestar/utils"; -import {ForkName} from "@lodestar/params"; import {SignedBeaconBlock} from "@lodestar/types"; +import {sleep, toRootHex} from "@lodestar/utils"; import {MAXIMUM_GOSSIP_CLOCK_DISPARITY} from "../../constants/index.js"; +import {BlockErrorCode, BlockGossipError, GossipAction} from "../errors/index.js"; import {IBeaconChain} from "../interface.js"; -import {BlockGossipError, BlockErrorCode, GossipAction} from "../errors/index.js"; import {RegenCaller} from "../regen/index.js"; export async function validateGossipBlock( diff --git a/packages/beacon-node/src/chain/validation/blsToExecutionChange.ts b/packages/beacon-node/src/chain/validation/blsToExecutionChange.ts index fff399aada50..53e8b6f5d2b6 100644 --- a/packages/beacon-node/src/chain/validation/blsToExecutionChange.ts +++ b/packages/beacon-node/src/chain/validation/blsToExecutionChange.ts @@ -1,11 +1,11 @@ -import {capella} from "@lodestar/types"; import { - isValidBlsToExecutionChange, - getBlsToExecutionChangeSignatureSet, CachedBeaconStateCapella, + getBlsToExecutionChangeSignatureSet, + isValidBlsToExecutionChange, } from "@lodestar/state-transition"; -import {IBeaconChain} from "../index.js"; +import {capella} from "@lodestar/types"; import {BlsToExecutionChangeError, BlsToExecutionChangeErrorCode, GossipAction} from "../errors/index.js"; +import {IBeaconChain} from "../index.js"; export async function validateApiBlsToExecutionChange( chain: IBeaconChain, diff --git a/packages/beacon-node/src/chain/validation/lightClientFinalityUpdate.ts b/packages/beacon-node/src/chain/validation/lightClientFinalityUpdate.ts index 0b19495abde6..e19b3c28da87 100644 --- a/packages/beacon-node/src/chain/validation/lightClientFinalityUpdate.ts +++ b/packages/beacon-node/src/chain/validation/lightClientFinalityUpdate.ts @@ -1,9 +1,9 @@ import {ChainForkConfig} from "@lodestar/config"; import {LightClientFinalityUpdate} from "@lodestar/types"; -import {IBeaconChain} from "../interface.js"; -import {LightClientError, LightClientErrorCode} from "../errors/lightClientError.js"; -import {GossipAction} from "../errors/index.js"; import {assertLightClientServer} from "../../node/utils/lightclient.js"; +import {GossipAction} from "../errors/index.js"; +import {LightClientError, LightClientErrorCode} from "../errors/lightClientError.js"; +import {IBeaconChain} from "../interface.js"; import {updateReceivedTooEarly} from "./lightClientOptimisticUpdate.js"; // https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/p2p-interface.md#light_client_finality_update diff --git a/packages/beacon-node/src/chain/validation/lightClientOptimisticUpdate.ts b/packages/beacon-node/src/chain/validation/lightClientOptimisticUpdate.ts index 7a7dd7f34a91..49bffb3a5305 100644 --- a/packages/beacon-node/src/chain/validation/lightClientOptimisticUpdate.ts +++ b/packages/beacon-node/src/chain/validation/lightClientOptimisticUpdate.ts @@ -1,11 +1,11 @@ import {ChainForkConfig} from "@lodestar/config"; import {computeTimeAtSlot} from "@lodestar/state-transition"; import {LightClientOptimisticUpdate} from "@lodestar/types"; -import {IBeaconChain} from "../interface.js"; -import {LightClientError, LightClientErrorCode} from "../errors/lightClientError.js"; -import {GossipAction} from "../errors/index.js"; import {MAXIMUM_GOSSIP_CLOCK_DISPARITY} from "../../constants/index.js"; import {assertLightClientServer} from "../../node/utils/lightclient.js"; +import {GossipAction} from "../errors/index.js"; +import {LightClientError, LightClientErrorCode} from "../errors/lightClientError.js"; +import {IBeaconChain} from "../interface.js"; // https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update export function validateLightClientOptimisticUpdate( diff --git a/packages/beacon-node/src/chain/validation/proposerSlashing.ts b/packages/beacon-node/src/chain/validation/proposerSlashing.ts index 48fe6db326c9..8d76470bb03b 100644 --- a/packages/beacon-node/src/chain/validation/proposerSlashing.ts +++ b/packages/beacon-node/src/chain/validation/proposerSlashing.ts @@ -1,7 +1,7 @@ -import {phase0} from "@lodestar/types"; import {assertValidProposerSlashing, getProposerSlashingSignatureSets} from "@lodestar/state-transition"; +import {phase0} from "@lodestar/types"; +import {GossipAction, ProposerSlashingError, ProposerSlashingErrorCode} from "../errors/index.js"; import {IBeaconChain} from "../index.js"; -import {ProposerSlashingError, ProposerSlashingErrorCode, GossipAction} from "../errors/index.js"; export async function validateApiProposerSlashing( chain: IBeaconChain, diff --git a/packages/beacon-node/src/chain/validation/signatureSets/aggregateAndProof.ts b/packages/beacon-node/src/chain/validation/signatureSets/aggregateAndProof.ts index 31d931818595..6d171aa0c1f4 100644 --- a/packages/beacon-node/src/chain/validation/signatureSets/aggregateAndProof.ts +++ b/packages/beacon-node/src/chain/validation/signatureSets/aggregateAndProof.ts @@ -1,14 +1,14 @@ import {PublicKey} from "@chainsafe/blst"; +import {BeaconConfig} from "@lodestar/config"; import {DOMAIN_AGGREGATE_AND_PROOF, ForkSeq} from "@lodestar/params"; -import {ssz, SignedAggregateAndProof} from "@lodestar/types"; -import {Epoch} from "@lodestar/types"; import { + ISignatureSet, computeSigningRoot, computeStartSlotAtEpoch, createSingleSignatureSetFromComponents, - ISignatureSet, } from "@lodestar/state-transition"; -import {BeaconConfig} from "@lodestar/config"; +import {SignedAggregateAndProof, ssz} from "@lodestar/types"; +import {Epoch} from "@lodestar/types"; export function getAggregateAndProofSigningRoot( config: BeaconConfig, diff --git a/packages/beacon-node/src/chain/validation/signatureSets/contributionAndProof.ts b/packages/beacon-node/src/chain/validation/signatureSets/contributionAndProof.ts index 21e447b83677..4fe5122c0d3f 100644 --- a/packages/beacon-node/src/chain/validation/signatureSets/contributionAndProof.ts +++ b/packages/beacon-node/src/chain/validation/signatureSets/contributionAndProof.ts @@ -1,11 +1,11 @@ import {DOMAIN_CONTRIBUTION_AND_PROOF} from "@lodestar/params"; -import {altair, ssz} from "@lodestar/types"; import { CachedBeaconStateAllForks, - computeSigningRoot, ISignatureSet, SignatureSetType, + computeSigningRoot, } from "@lodestar/state-transition"; +import {altair, ssz} from "@lodestar/types"; export function getContributionAndProofSignatureSet( state: CachedBeaconStateAllForks, diff --git a/packages/beacon-node/src/chain/validation/signatureSets/selectionProof.ts b/packages/beacon-node/src/chain/validation/signatureSets/selectionProof.ts index 5e129a88aa20..6aa0cffc9b94 100644 --- a/packages/beacon-node/src/chain/validation/signatureSets/selectionProof.ts +++ b/packages/beacon-node/src/chain/validation/signatureSets/selectionProof.ts @@ -1,8 +1,8 @@ import {PublicKey} from "@chainsafe/blst"; -import {DOMAIN_SELECTION_PROOF} from "@lodestar/params"; -import {phase0, Slot, ssz} from "@lodestar/types"; -import {computeSigningRoot, createSingleSignatureSetFromComponents, ISignatureSet} from "@lodestar/state-transition"; import {BeaconConfig} from "@lodestar/config"; +import {DOMAIN_SELECTION_PROOF} from "@lodestar/params"; +import {ISignatureSet, computeSigningRoot, createSingleSignatureSetFromComponents} from "@lodestar/state-transition"; +import {Slot, phase0, ssz} from "@lodestar/types"; export function getSelectionProofSigningRoot(config: BeaconConfig, slot: Slot): Uint8Array { // previously, we call `const selectionProofDomain = config.getDomain(state.slot, DOMAIN_SELECTION_PROOF, slot)` diff --git a/packages/beacon-node/src/chain/validation/signatureSets/syncCommittee.ts b/packages/beacon-node/src/chain/validation/signatureSets/syncCommittee.ts index ce2b2e2484ab..7765e4d89ea0 100644 --- a/packages/beacon-node/src/chain/validation/signatureSets/syncCommittee.ts +++ b/packages/beacon-node/src/chain/validation/signatureSets/syncCommittee.ts @@ -1,11 +1,11 @@ import {DOMAIN_SYNC_COMMITTEE} from "@lodestar/params"; -import {altair, ssz} from "@lodestar/types"; import { CachedBeaconStateAllForks, - computeSigningRoot, ISignatureSet, SignatureSetType, + computeSigningRoot, } from "@lodestar/state-transition"; +import {altair, ssz} from "@lodestar/types"; export function getSyncCommitteeSignatureSet( state: CachedBeaconStateAllForks, diff --git a/packages/beacon-node/src/chain/validation/signatureSets/syncCommitteeContribution.ts b/packages/beacon-node/src/chain/validation/signatureSets/syncCommitteeContribution.ts index 0e1eaefef7c6..f444c48a2103 100644 --- a/packages/beacon-node/src/chain/validation/signatureSets/syncCommitteeContribution.ts +++ b/packages/beacon-node/src/chain/validation/signatureSets/syncCommitteeContribution.ts @@ -1,7 +1,7 @@ import {PublicKey} from "@chainsafe/blst"; -import {altair, ssz} from "@lodestar/types"; import {DOMAIN_SYNC_COMMITTEE} from "@lodestar/params"; -import {CachedBeaconStateAltair, computeSigningRoot, ISignatureSet, SignatureSetType} from "@lodestar/state-transition"; +import {CachedBeaconStateAltair, ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition"; +import {altair, ssz} from "@lodestar/types"; export function getSyncCommitteeContributionSignatureSet( state: CachedBeaconStateAltair, diff --git a/packages/beacon-node/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts b/packages/beacon-node/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts index 14fcfad2b92e..b94ae87b240f 100644 --- a/packages/beacon-node/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +++ b/packages/beacon-node/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts @@ -1,11 +1,11 @@ import {DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF} from "@lodestar/params"; -import {altair, ssz} from "@lodestar/types"; import { CachedBeaconStateAllForks, - computeSigningRoot, ISignatureSet, SignatureSetType, + computeSigningRoot, } from "@lodestar/state-transition"; +import {altair, ssz} from "@lodestar/types"; export function getSyncCommitteeSelectionProofSignatureSet( state: CachedBeaconStateAllForks, diff --git a/packages/beacon-node/src/chain/validation/syncCommittee.ts b/packages/beacon-node/src/chain/validation/syncCommittee.ts index f47aa53a314e..c563bf7cf6be 100644 --- a/packages/beacon-node/src/chain/validation/syncCommittee.ts +++ b/packages/beacon-node/src/chain/validation/syncCommittee.ts @@ -1,5 +1,5 @@ +import {SYNC_COMMITTEE_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params"; import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; -import {SYNC_COMMITTEE_SUBNET_SIZE, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; import {altair} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; import {GossipAction, SyncCommitteeError, SyncCommitteeErrorCode} from "../errors/index.js"; diff --git a/packages/beacon-node/src/chain/validation/syncCommitteeContributionAndProof.ts b/packages/beacon-node/src/chain/validation/syncCommitteeContributionAndProof.ts index 3f9351f2d0d3..611d738b15b6 100644 --- a/packages/beacon-node/src/chain/validation/syncCommitteeContributionAndProof.ts +++ b/packages/beacon-node/src/chain/validation/syncCommitteeContributionAndProof.ts @@ -1,14 +1,14 @@ -import {CachedBeaconStateAltair, isSyncCommitteeAggregator} from "@lodestar/state-transition"; -import {altair, ValidatorIndex} from "@lodestar/types"; import {SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params"; +import {CachedBeaconStateAltair, isSyncCommitteeAggregator} from "@lodestar/state-transition"; +import {ValidatorIndex, altair} from "@lodestar/types"; import {GossipAction, SyncCommitteeError, SyncCommitteeErrorCode} from "../errors/index.js"; import {IBeaconChain} from "../interface.js"; -import {validateGossipSyncCommitteeExceptSig} from "./syncCommittee.js"; import { - getSyncCommitteeSelectionProofSignatureSet, getContributionAndProofSignatureSet, getSyncCommitteeContributionSignatureSet, + getSyncCommitteeSelectionProofSignatureSet, } from "./signatureSets/index.js"; +import {validateGossipSyncCommitteeExceptSig} from "./syncCommittee.js"; /** * Spec v1.1.0-beta.2 diff --git a/packages/beacon-node/src/chain/validation/voluntaryExit.ts b/packages/beacon-node/src/chain/validation/voluntaryExit.ts index 2b38b161423e..79da31084a36 100644 --- a/packages/beacon-node/src/chain/validation/voluntaryExit.ts +++ b/packages/beacon-node/src/chain/validation/voluntaryExit.ts @@ -1,7 +1,7 @@ +import {getVoluntaryExitSignatureSet, isValidVoluntaryExit} from "@lodestar/state-transition"; import {phase0} from "@lodestar/types"; -import {isValidVoluntaryExit, getVoluntaryExitSignatureSet} from "@lodestar/state-transition"; +import {GossipAction, VoluntaryExitError, VoluntaryExitErrorCode} from "../errors/index.js"; import {IBeaconChain} from "../index.js"; -import {VoluntaryExitError, VoluntaryExitErrorCode, GossipAction} from "../errors/index.js"; import {RegenCaller} from "../regen/index.js"; export async function validateApiVoluntaryExit( diff --git a/packages/beacon-node/src/db/beacon.ts b/packages/beacon-node/src/db/beacon.ts index 07cc47fa54d8..1e15aa369141 100644 --- a/packages/beacon-node/src/db/beacon.ts +++ b/packages/beacon-node/src/db/beacon.ts @@ -1,27 +1,27 @@ -import {Db, LevelDbControllerMetrics} from "@lodestar/db"; import {ChainForkConfig} from "@lodestar/config"; +import {Db, LevelDbControllerMetrics} from "@lodestar/db"; import {IBeaconDb} from "./interface.js"; +import {CheckpointStateRepository} from "./repositories/checkpointState.js"; import { AttesterSlashingRepository, + BLSToExecutionChangeRepository, + BackfilledRanges, + BestLightClientUpdateRepository, + BlobSidecarsArchiveRepository, + BlobSidecarsRepository, BlockArchiveRepository, BlockRepository, - DepositEventRepository, + CheckpointHeaderRepository, DepositDataRootRepository, + DepositEventRepository, Eth1DataRepository, ProposerSlashingRepository, StateArchiveRepository, - VoluntaryExitRepository, - BestLightClientUpdateRepository, - CheckpointHeaderRepository, SyncCommitteeRepository, SyncCommitteeWitnessRepository, - BackfilledRanges, - BlobSidecarsRepository, - BlobSidecarsArchiveRepository, - BLSToExecutionChangeRepository, + VoluntaryExitRepository, } from "./repositories/index.js"; import {PreGenesisState, PreGenesisStateLastProcessedBlock} from "./single/index.js"; -import {CheckpointStateRepository} from "./repositories/checkpointState.js"; export type BeaconDbModules = { config: ChainForkConfig; diff --git a/packages/beacon-node/src/db/interface.ts b/packages/beacon-node/src/db/interface.ts index 6ffb8992f635..95336407ef20 100644 --- a/packages/beacon-node/src/db/interface.ts +++ b/packages/beacon-node/src/db/interface.ts @@ -1,25 +1,25 @@ import {LevelDbControllerMetrics} from "@lodestar/db"; +import {CheckpointStateRepository} from "./repositories/checkpointState.js"; import { AttesterSlashingRepository, + BLSToExecutionChangeRepository, + BackfilledRanges, + BestLightClientUpdateRepository, + BlobSidecarsArchiveRepository, + BlobSidecarsRepository, BlockArchiveRepository, BlockRepository, - DepositEventRepository, + CheckpointHeaderRepository, DepositDataRootRepository, + DepositEventRepository, Eth1DataRepository, ProposerSlashingRepository, StateArchiveRepository, - VoluntaryExitRepository, - BestLightClientUpdateRepository, - CheckpointHeaderRepository, SyncCommitteeRepository, SyncCommitteeWitnessRepository, - BackfilledRanges, - BlobSidecarsRepository, - BlobSidecarsArchiveRepository, - BLSToExecutionChangeRepository, + VoluntaryExitRepository, } from "./repositories/index.js"; import {PreGenesisState, PreGenesisStateLastProcessedBlock} from "./single/index.js"; -import {CheckpointStateRepository} from "./repositories/checkpointState.js"; /** * The DB service manages the data layer of the beacon chain diff --git a/packages/beacon-node/src/db/repositories/attesterSlashing.ts b/packages/beacon-node/src/db/repositories/attesterSlashing.ts index a484f605ac15..dd83c25998b6 100644 --- a/packages/beacon-node/src/db/repositories/attesterSlashing.ts +++ b/packages/beacon-node/src/db/repositories/attesterSlashing.ts @@ -1,6 +1,6 @@ -import {phase0, ssz, ValidatorIndex} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; import {Db, Repository} from "@lodestar/db"; +import {ValidatorIndex, phase0, ssz} from "@lodestar/types"; import {Bucket, getBucketNameByValue} from "../buckets.js"; /** diff --git a/packages/beacon-node/src/db/repositories/backfilledRanges.ts b/packages/beacon-node/src/db/repositories/backfilledRanges.ts index f86c20288099..c2958a0e972e 100644 --- a/packages/beacon-node/src/db/repositories/backfilledRanges.ts +++ b/packages/beacon-node/src/db/repositories/backfilledRanges.ts @@ -1,6 +1,6 @@ import {ChainForkConfig} from "@lodestar/config"; -import {Slot, ssz} from "@lodestar/types"; import {DatabaseController, Repository} from "@lodestar/db"; +import {Slot, ssz} from "@lodestar/types"; import {bytesToInt} from "@lodestar/utils"; import {Bucket, getBucketNameByValue} from "../buckets.js"; diff --git a/packages/beacon-node/src/db/repositories/blobSidecars.ts b/packages/beacon-node/src/db/repositories/blobSidecars.ts index e5750ed31b58..aaa16f760dd6 100644 --- a/packages/beacon-node/src/db/repositories/blobSidecars.ts +++ b/packages/beacon-node/src/db/repositories/blobSidecars.ts @@ -1,4 +1,4 @@ -import {ValueOf, ContainerType} from "@chainsafe/ssz"; +import {ContainerType, ValueOf} from "@chainsafe/ssz"; import {ChainForkConfig} from "@lodestar/config"; import {Db, Repository} from "@lodestar/db"; import {ssz} from "@lodestar/types"; diff --git a/packages/beacon-node/src/db/repositories/blobSidecarsArchive.ts b/packages/beacon-node/src/db/repositories/blobSidecarsArchive.ts index 18293fc2924c..4b6c8fbcf046 100644 --- a/packages/beacon-node/src/db/repositories/blobSidecarsArchive.ts +++ b/packages/beacon-node/src/db/repositories/blobSidecarsArchive.ts @@ -3,7 +3,7 @@ import {Db, Repository} from "@lodestar/db"; import {Slot} from "@lodestar/types"; import {bytesToInt} from "@lodestar/utils"; import {Bucket, getBucketNameByValue} from "../buckets.js"; -import {blobSidecarsWrapperSsz, BlobSidecarsWrapper} from "./blobSidecars.js"; +import {BlobSidecarsWrapper, blobSidecarsWrapperSsz} from "./blobSidecars.js"; /** * blobSidecarsWrapper by slot diff --git a/packages/beacon-node/src/db/repositories/blockArchive.ts b/packages/beacon-node/src/db/repositories/blockArchive.ts index 427650a37bc3..12994ceba5db 100644 --- a/packages/beacon-node/src/db/repositories/blockArchive.ts +++ b/packages/beacon-node/src/db/repositories/blockArchive.ts @@ -1,11 +1,11 @@ -import all from "it-all"; import {ChainForkConfig} from "@lodestar/config"; -import {Db, Repository, KeyValue, FilterOptions} from "@lodestar/db"; -import {Slot, Root, ssz, SignedBeaconBlock} from "@lodestar/types"; +import {Db, FilterOptions, KeyValue, Repository} from "@lodestar/db"; +import {Root, SignedBeaconBlock, Slot, ssz} from "@lodestar/types"; import {bytesToInt} from "@lodestar/utils"; +import all from "it-all"; import {getSignedBlockTypeFromBytes} from "../../util/multifork.js"; import {Bucket, getBucketNameByValue} from "../buckets.js"; -import {getRootIndexKey, getParentRootIndexKey} from "./blockArchiveIndex.js"; +import {getParentRootIndexKey, getRootIndexKey} from "./blockArchiveIndex.js"; import {deleteParentRootIndex, deleteRootIndex, storeParentRootIndex, storeRootIndex} from "./blockArchiveIndex.js"; export interface BlockFilterOptions extends FilterOptions { diff --git a/packages/beacon-node/src/db/repositories/blockArchiveIndex.ts b/packages/beacon-node/src/db/repositories/blockArchiveIndex.ts index 8c2785dbe67c..12e133ec9acd 100644 --- a/packages/beacon-node/src/db/repositories/blockArchiveIndex.ts +++ b/packages/beacon-node/src/db/repositories/blockArchiveIndex.ts @@ -1,7 +1,7 @@ import {Db, encodeKey} from "@lodestar/db"; -import {Slot, Root, ssz, SignedBeaconBlock, SSZTypesFor} from "@lodestar/types"; -import {intToBytes} from "@lodestar/utils"; import {ForkAll} from "@lodestar/params"; +import {Root, SSZTypesFor, SignedBeaconBlock, Slot, ssz} from "@lodestar/types"; +import {intToBytes} from "@lodestar/utils"; import {Bucket} from "../buckets.js"; export async function storeRootIndex(db: Db, slot: Slot, blockRoot: Root): Promise { diff --git a/packages/beacon-node/src/db/repositories/blsToExecutionChange.ts b/packages/beacon-node/src/db/repositories/blsToExecutionChange.ts index a1b32403dd14..c9495f8fc9a6 100644 --- a/packages/beacon-node/src/db/repositories/blsToExecutionChange.ts +++ b/packages/beacon-node/src/db/repositories/blsToExecutionChange.ts @@ -1,6 +1,6 @@ -import {ValidatorIndex} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; import {Db, Repository} from "@lodestar/db"; +import {ValidatorIndex} from "@lodestar/types"; import {SignedBLSToExecutionChangeVersioned, signedBLSToExecutionChangeVersionedType} from "../../util/types.js"; import {Bucket, getBucketNameByValue} from "../buckets.js"; diff --git a/packages/beacon-node/src/db/repositories/depositDataRoot.ts b/packages/beacon-node/src/db/repositories/depositDataRoot.ts index 97200ccd0f92..50648655e440 100644 --- a/packages/beacon-node/src/db/repositories/depositDataRoot.ts +++ b/packages/beacon-node/src/db/repositories/depositDataRoot.ts @@ -1,8 +1,8 @@ import {ByteVectorType, CompositeViewDU, ListCompositeType} from "@chainsafe/ssz"; -import {Root, ssz} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; +import {Db, KeyValue, Repository} from "@lodestar/db"; +import {Root, ssz} from "@lodestar/types"; import {bytesToInt} from "@lodestar/utils"; -import {Db, Repository, KeyValue} from "@lodestar/db"; import {Bucket, getBucketNameByValue} from "../buckets.js"; // TODO: Review where is best to put this type diff --git a/packages/beacon-node/src/db/repositories/depositEvent.ts b/packages/beacon-node/src/db/repositories/depositEvent.ts index c1d2dd99047f..f2e180a02c43 100644 --- a/packages/beacon-node/src/db/repositories/depositEvent.ts +++ b/packages/beacon-node/src/db/repositories/depositEvent.ts @@ -1,6 +1,6 @@ import {ChainForkConfig} from "@lodestar/config"; -import {phase0, ssz} from "@lodestar/types"; import {Db, Repository} from "@lodestar/db"; +import {phase0, ssz} from "@lodestar/types"; import {Bucket, getBucketNameByValue} from "../buckets.js"; /** diff --git a/packages/beacon-node/src/db/repositories/eth1Data.ts b/packages/beacon-node/src/db/repositories/eth1Data.ts index f87199a0b80e..5a21e8f7d226 100644 --- a/packages/beacon-node/src/db/repositories/eth1Data.ts +++ b/packages/beacon-node/src/db/repositories/eth1Data.ts @@ -1,7 +1,7 @@ -import {phase0, ssz} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; -import {bytesToInt} from "@lodestar/utils"; import {Db, Repository} from "@lodestar/db"; +import {phase0, ssz} from "@lodestar/types"; +import {bytesToInt} from "@lodestar/utils"; import {Bucket, getBucketNameByValue} from "../buckets.js"; export class Eth1DataRepository extends Repository { diff --git a/packages/beacon-node/src/db/repositories/lightclientBestUpdate.ts b/packages/beacon-node/src/db/repositories/lightclientBestUpdate.ts index 26493e35e408..ad37b1425c58 100644 --- a/packages/beacon-node/src/db/repositories/lightclientBestUpdate.ts +++ b/packages/beacon-node/src/db/repositories/lightclientBestUpdate.ts @@ -1,6 +1,6 @@ import {ChainForkConfig} from "@lodestar/config"; import {DatabaseController, Repository} from "@lodestar/db"; -import {LightClientUpdate, ssz, SyncPeriod} from "@lodestar/types"; +import {LightClientUpdate, SyncPeriod, ssz} from "@lodestar/types"; import {Bucket, getBucketNameByValue} from "../buckets.js"; const SLOT_BYTE_COUNT = 8; diff --git a/packages/beacon-node/src/db/repositories/lightclientCheckpointHeader.ts b/packages/beacon-node/src/db/repositories/lightclientCheckpointHeader.ts index 22d6559792eb..36b7b9c187e7 100644 --- a/packages/beacon-node/src/db/repositories/lightclientCheckpointHeader.ts +++ b/packages/beacon-node/src/db/repositories/lightclientCheckpointHeader.ts @@ -1,8 +1,8 @@ import {ChainForkConfig} from "@lodestar/config"; import {DatabaseController, Repository} from "@lodestar/db"; import {LightClientHeader, ssz} from "@lodestar/types"; -import {Bucket, getBucketNameByValue} from "../buckets.js"; import {getLightClientHeaderTypeFromBytes} from "../../util/multifork.js"; +import {Bucket, getBucketNameByValue} from "../buckets.js"; /** * Block headers by block root. Until finality includes all headers seen by this node. After finality, diff --git a/packages/beacon-node/src/db/repositories/proposerSlashing.ts b/packages/beacon-node/src/db/repositories/proposerSlashing.ts index e599c22a9c32..210d33234d9b 100644 --- a/packages/beacon-node/src/db/repositories/proposerSlashing.ts +++ b/packages/beacon-node/src/db/repositories/proposerSlashing.ts @@ -1,6 +1,6 @@ -import {phase0, ssz, ValidatorIndex} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; import {Db, Repository} from "@lodestar/db"; +import {ValidatorIndex, phase0, ssz} from "@lodestar/types"; import {Bucket, getBucketNameByValue} from "../buckets.js"; export class ProposerSlashingRepository extends Repository { diff --git a/packages/beacon-node/src/db/repositories/stateArchive.ts b/packages/beacon-node/src/db/repositories/stateArchive.ts index b3b3d67fd7a0..638499c5fe01 100644 --- a/packages/beacon-node/src/db/repositories/stateArchive.ts +++ b/packages/beacon-node/src/db/repositories/stateArchive.ts @@ -1,8 +1,8 @@ +import {ChainForkConfig} from "@lodestar/config"; +import {Db, Repository} from "@lodestar/db"; import {BeaconStateAllForks} from "@lodestar/state-transition"; import {Epoch, Root, RootHex, Slot, ssz} from "@lodestar/types"; -import {ChainForkConfig} from "@lodestar/config"; import {bytesToInt, toHex} from "@lodestar/utils"; -import {Db, Repository} from "@lodestar/db"; import {getStateTypeFromBytes} from "../../util/multifork.js"; import {Bucket, getBucketNameByValue} from "../buckets.js"; import {getRootIndexKey, storeRootIndex} from "./stateArchiveIndex.js"; diff --git a/packages/beacon-node/src/db/repositories/stateArchiveIndex.ts b/packages/beacon-node/src/db/repositories/stateArchiveIndex.ts index a088aa2413e9..f119cd245080 100644 --- a/packages/beacon-node/src/db/repositories/stateArchiveIndex.ts +++ b/packages/beacon-node/src/db/repositories/stateArchiveIndex.ts @@ -1,4 +1,4 @@ -import {encodeKey, Db} from "@lodestar/db"; +import {Db, encodeKey} from "@lodestar/db"; import {Root, Slot} from "@lodestar/types"; import {intToBytes} from "@lodestar/utils"; import {Bucket} from "../buckets.js"; diff --git a/packages/beacon-node/src/db/repositories/voluntaryExit.ts b/packages/beacon-node/src/db/repositories/voluntaryExit.ts index ea2dc73a2903..8609725b6337 100644 --- a/packages/beacon-node/src/db/repositories/voluntaryExit.ts +++ b/packages/beacon-node/src/db/repositories/voluntaryExit.ts @@ -1,6 +1,6 @@ -import {phase0, ssz, ValidatorIndex} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; import {Db, Repository} from "@lodestar/db"; +import {ValidatorIndex, phase0, ssz} from "@lodestar/types"; import {Bucket, getBucketNameByValue} from "../buckets.js"; export class VoluntaryExitRepository extends Repository { diff --git a/packages/beacon-node/src/db/single/preGenesisState.ts b/packages/beacon-node/src/db/single/preGenesisState.ts index 3789e19d1a7d..a43a54c0923c 100644 --- a/packages/beacon-node/src/db/single/preGenesisState.ts +++ b/packages/beacon-node/src/db/single/preGenesisState.ts @@ -1,6 +1,6 @@ -import {ForkAll, GENESIS_SLOT} from "@lodestar/params"; import {ChainForkConfig} from "@lodestar/config"; import {Db} from "@lodestar/db"; +import {ForkAll, GENESIS_SLOT} from "@lodestar/params"; import {BeaconStateAllForks} from "@lodestar/state-transition"; import {SSZTypesFor} from "@lodestar/types"; import {Bucket} from "../buckets.js"; diff --git a/packages/beacon-node/src/db/single/preGenesisStateLastProcessedBlock.ts b/packages/beacon-node/src/db/single/preGenesisStateLastProcessedBlock.ts index 37dcb069acc9..c31382ec9ee6 100644 --- a/packages/beacon-node/src/db/single/preGenesisStateLastProcessedBlock.ts +++ b/packages/beacon-node/src/db/single/preGenesisStateLastProcessedBlock.ts @@ -1,7 +1,7 @@ import {UintNumberType} from "@chainsafe/ssz"; -import {ssz} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; import {Db} from "@lodestar/db"; +import {ssz} from "@lodestar/types"; import {Bucket} from "../buckets.js"; export class PreGenesisStateLastProcessedBlock { diff --git a/packages/beacon-node/src/eth1/eth1DepositDataTracker.ts b/packages/beacon-node/src/eth1/eth1DepositDataTracker.ts index 674b6b600f31..815f5aeb8938 100644 --- a/packages/beacon-node/src/eth1/eth1DepositDataTracker.ts +++ b/packages/beacon-node/src/eth1/eth1DepositDataTracker.ts @@ -1,4 +1,3 @@ -import {phase0, ssz} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; import { BeaconStateAllForks, @@ -6,19 +5,20 @@ import { CachedBeaconStateElectra, becomesNewEth1Data, } from "@lodestar/state-transition"; -import {ErrorAborted, TimeoutError, fromHex, Logger, isErrorAborted, sleep} from "@lodestar/utils"; +import {phase0, ssz} from "@lodestar/types"; +import {ErrorAborted, Logger, TimeoutError, fromHex, isErrorAborted, sleep} from "@lodestar/utils"; import {IBeaconDb} from "../db/index.js"; import {Metrics} from "../metrics/index.js"; -import {Eth1DepositsCache} from "./eth1DepositsCache.js"; import {Eth1DataCache} from "./eth1DataCache.js"; -import {getEth1VotesToConsider, pickEth1Vote} from "./utils/eth1Vote.js"; -import {getDeposits} from "./utils/deposits.js"; +import {Eth1DepositsCache} from "./eth1DepositsCache.js"; import {Eth1DataAndDeposits, EthJsonRpcBlockRaw, IEth1Provider} from "./interface.js"; import {Eth1Options} from "./options.js"; -import {HttpRpcError} from "./provider/jsonRpcHttpClient.js"; import {parseEth1Block} from "./provider/eth1Provider.js"; +import {HttpRpcError} from "./provider/jsonRpcHttpClient.js"; import {isJsonRpcTruncatedError} from "./provider/utils.js"; +import {getDeposits} from "./utils/deposits.js"; +import {getEth1VotesToConsider, pickEth1Vote} from "./utils/eth1Vote.js"; const MAX_BLOCKS_PER_BLOCK_QUERY = 1000; const MIN_BLOCKS_PER_BLOCK_QUERY = 10; diff --git a/packages/beacon-node/src/eth1/eth1DepositsCache.ts b/packages/beacon-node/src/eth1/eth1DepositsCache.ts index 13dd29013124..16ed7c95a465 100644 --- a/packages/beacon-node/src/eth1/eth1DepositsCache.ts +++ b/packages/beacon-node/src/eth1/eth1DepositsCache.ts @@ -1,14 +1,14 @@ import {byteArrayEquals} from "@chainsafe/ssz"; -import {phase0, ssz} from "@lodestar/types"; -import {FilterOptions} from "@lodestar/db"; import {ChainForkConfig} from "@lodestar/config"; +import {FilterOptions} from "@lodestar/db"; +import {phase0, ssz} from "@lodestar/types"; import {IBeaconDb} from "../db/index.js"; -import {getEth1DataForBlocks} from "./utils/eth1Data.js"; -import {assertConsecutiveDeposits} from "./utils/eth1DepositEvent.js"; -import {getDepositsWithProofs} from "./utils/deposits.js"; import {Eth1Error, Eth1ErrorCode} from "./errors.js"; import {Eth1Block} from "./interface.js"; +import {getDepositsWithProofs} from "./utils/deposits.js"; +import {getEth1DataForBlocks} from "./utils/eth1Data.js"; +import {assertConsecutiveDeposits} from "./utils/eth1DepositEvent.js"; export class Eth1DepositsCache { unsafeAllowDepositDataOverwrite: boolean; diff --git a/packages/beacon-node/src/eth1/eth1MergeBlockTracker.ts b/packages/beacon-node/src/eth1/eth1MergeBlockTracker.ts index 5bf76625dfe8..ea2d134fe4dd 100644 --- a/packages/beacon-node/src/eth1/eth1MergeBlockTracker.ts +++ b/packages/beacon-node/src/eth1/eth1MergeBlockTracker.ts @@ -1,11 +1,11 @@ import {ChainConfig} from "@lodestar/config"; import {RootHex} from "@lodestar/types"; import {Logger, pruneSetToMax, toRootHex} from "@lodestar/utils"; -import {Metrics} from "../metrics/index.js"; import {ZERO_HASH_HEX} from "../constants/index.js"; +import {Metrics} from "../metrics/index.js"; import {enumToIndexMap} from "../util/enum.js"; -import {IEth1Provider, EthJsonRpcBlockRaw, PowMergeBlock, PowMergeBlockTimestamp, TDProgress} from "./interface.js"; -import {quantityToNum, quantityToBigint, dataToRootHex} from "./provider/utils.js"; +import {EthJsonRpcBlockRaw, IEth1Provider, PowMergeBlock, PowMergeBlockTimestamp, TDProgress} from "./interface.js"; +import {dataToRootHex, quantityToBigint, quantityToNum} from "./provider/utils.js"; export enum StatusCode { STOPPED = "STOPPED", diff --git a/packages/beacon-node/src/eth1/index.ts b/packages/beacon-node/src/eth1/index.ts index 42b82d03a848..f8c28afc5aed 100644 --- a/packages/beacon-node/src/eth1/index.ts +++ b/packages/beacon-node/src/eth1/index.ts @@ -1,9 +1,9 @@ import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; import {Root} from "@lodestar/types"; import {fromHex} from "@lodestar/utils"; -import {IEth1ForBlockProduction, Eth1DataAndDeposits, IEth1Provider, PowMergeBlock, TDProgress} from "./interface.js"; import {Eth1DepositDataTracker, Eth1DepositDataTrackerModules} from "./eth1DepositDataTracker.js"; import {Eth1MergeBlockTracker, Eth1MergeBlockTrackerModules} from "./eth1MergeBlockTracker.js"; +import {Eth1DataAndDeposits, IEth1ForBlockProduction, IEth1Provider, PowMergeBlock, TDProgress} from "./interface.js"; import {Eth1Options} from "./options.js"; import {Eth1Provider} from "./provider/eth1Provider.js"; export {Eth1Provider}; diff --git a/packages/beacon-node/src/eth1/interface.ts b/packages/beacon-node/src/eth1/interface.ts index 54fcdd12492f..ccfd3568e479 100644 --- a/packages/beacon-node/src/eth1/interface.ts +++ b/packages/beacon-node/src/eth1/interface.ts @@ -1,6 +1,6 @@ import {BeaconConfig} from "@lodestar/config"; -import {phase0, Root, RootHex} from "@lodestar/types"; import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; +import {Root, RootHex, phase0} from "@lodestar/types"; export type EthJsonRpcBlockRaw = { /** the block number. null when its pending block. `"0x1b4"` */ diff --git a/packages/beacon-node/src/eth1/provider/eth1Provider.ts b/packages/beacon-node/src/eth1/provider/eth1Provider.ts index d284700ddb1d..8320f1dedac1 100644 --- a/packages/beacon-node/src/eth1/provider/eth1Provider.ts +++ b/packages/beacon-node/src/eth1/provider/eth1Provider.ts @@ -1,16 +1,16 @@ -import {phase0} from "@lodestar/types"; import {ChainConfig} from "@lodestar/config"; -import {fromHex, isErrorAborted, createElapsedTimeTracker, toPrintableUrl, toHex} from "@lodestar/utils"; import {Logger} from "@lodestar/logger"; +import {phase0} from "@lodestar/types"; +import {createElapsedTimeTracker, fromHex, isErrorAborted, toHex, toPrintableUrl} from "@lodestar/utils"; import {FetchError, isFetchError} from "@lodestar/api"; +import {HTTP_CONNECTION_ERROR_CODES, HTTP_FATAL_ERROR_CODES} from "../../execution/engine/utils.js"; +import {isValidAddress} from "../../util/address.js"; import {linspace} from "../../util/numpy.js"; -import {depositEventTopics, parseDepositLog} from "../utils/depositContract.js"; import {Eth1Block, Eth1ProviderState, IEth1Provider} from "../interface.js"; -import {DEFAULT_PROVIDER_URLS, Eth1Options} from "../options.js"; -import {isValidAddress} from "../../util/address.js"; import {EthJsonRpcBlockRaw} from "../interface.js"; -import {HTTP_CONNECTION_ERROR_CODES, HTTP_FATAL_ERROR_CODES} from "../../execution/engine/utils.js"; +import {DEFAULT_PROVIDER_URLS, Eth1Options} from "../options.js"; +import {depositEventTopics, parseDepositLog} from "../utils/depositContract.js"; import { ErrorJsonRpcResponse, HttpRpcError, @@ -19,7 +19,7 @@ import { JsonRpcHttpClientMetrics, ReqOpts, } from "./jsonRpcHttpClient.js"; -import {isJsonRpcTruncatedError, quantityToNum, numToQuantity, dataToBytes} from "./utils.js"; +import {dataToBytes, isJsonRpcTruncatedError, numToQuantity, quantityToNum} from "./utils.js"; /** * Binds return types to Ethereum JSON RPC methods diff --git a/packages/beacon-node/src/eth1/provider/jsonRpcHttpClient.ts b/packages/beacon-node/src/eth1/provider/jsonRpcHttpClient.ts index f2ceae0d8c19..da72d5183d30 100644 --- a/packages/beacon-node/src/eth1/provider/jsonRpcHttpClient.ts +++ b/packages/beacon-node/src/eth1/provider/jsonRpcHttpClient.ts @@ -1,7 +1,7 @@ import {EventEmitter} from "node:events"; -import {StrictEventEmitter} from "strict-event-emitter-types"; import {fetch} from "@lodestar/api"; import {ErrorAborted, Gauge, Histogram, TimeoutError, isValidHttpUrl, retry} from "@lodestar/utils"; +import {StrictEventEmitter} from "strict-event-emitter-types"; import {IJson, RpcPayload} from "../interface.js"; import {JwtClaim, encodeJwtToken} from "./jwt.js"; diff --git a/packages/beacon-node/src/eth1/provider/utils.ts b/packages/beacon-node/src/eth1/provider/utils.ts index 7010e1377ca6..39cb9d4b1849 100644 --- a/packages/beacon-node/src/eth1/provider/utils.ts +++ b/packages/beacon-node/src/eth1/provider/utils.ts @@ -1,5 +1,5 @@ import {RootHex} from "@lodestar/types"; -import {bytesToBigInt, bigIntToBytes, toHex, fromHex} from "@lodestar/utils"; +import {bigIntToBytes, bytesToBigInt, fromHex, toHex} from "@lodestar/utils"; import {ErrorParseJson} from "./jsonRpcHttpClient.js"; /** QUANTITY as defined in ethereum execution layer JSON RPC https://eth.wiki/json-rpc/API */ diff --git a/packages/beacon-node/src/eth1/stream.ts b/packages/beacon-node/src/eth1/stream.ts index 1e8583bb59a9..f4adaf2829f2 100644 --- a/packages/beacon-node/src/eth1/stream.ts +++ b/packages/beacon-node/src/eth1/stream.ts @@ -1,9 +1,9 @@ -import {sleep} from "@lodestar/utils"; import {phase0} from "@lodestar/types"; -import {Eth1Block, BatchDepositEvents, IEth1Provider, IEth1StreamParams} from "./interface.js"; +import {sleep} from "@lodestar/utils"; +import {BatchDepositEvents, Eth1Block, IEth1Provider, IEth1StreamParams} from "./interface.js"; +import {parseEth1Block} from "./provider/eth1Provider.js"; import {groupDepositEventsByBlock} from "./utils/groupDepositEventsByBlock.js"; import {optimizeNextBlockDiffForGenesis} from "./utils/optimizeNextBlockDiffForGenesis.js"; -import {parseEth1Block} from "./provider/eth1Provider.js"; /** * Phase 1 of genesis building. diff --git a/packages/beacon-node/src/eth1/utils/deposits.ts b/packages/beacon-node/src/eth1/utils/deposits.ts index 36f8c331ebc9..803b4f9deadf 100644 --- a/packages/beacon-node/src/eth1/utils/deposits.ts +++ b/packages/beacon-node/src/eth1/utils/deposits.ts @@ -1,11 +1,11 @@ -import {toGindex, Tree} from "@chainsafe/persistent-merkle-tree"; -import {toRootHex} from "@lodestar/utils"; -import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; -import {phase0, ssz} from "@lodestar/types"; +import {Tree, toGindex} from "@chainsafe/persistent-merkle-tree"; import {FilterOptions} from "@lodestar/db"; +import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; import {getEth1DepositCount} from "@lodestar/state-transition"; -import {Eth1Error, Eth1ErrorCode} from "../errors.js"; +import {phase0, ssz} from "@lodestar/types"; +import {toRootHex} from "@lodestar/utils"; import {DepositTree} from "../../db/repositories/depositDataRoot.js"; +import {Eth1Error, Eth1ErrorCode} from "../errors.js"; export type DepositGetter = (indexRange: FilterOptions, eth1Data: phase0.Eth1Data) => Promise; diff --git a/packages/beacon-node/src/eth1/utils/eth1Data.ts b/packages/beacon-node/src/eth1/utils/eth1Data.ts index 2b8e976cac2e..96a7031788ff 100644 --- a/packages/beacon-node/src/eth1/utils/eth1Data.ts +++ b/packages/beacon-node/src/eth1/utils/eth1Data.ts @@ -1,7 +1,7 @@ import {Root, phase0} from "@lodestar/types"; +import {DepositTree} from "../../db/repositories/depositDataRoot.js"; import {binarySearchLte} from "../../util/binarySearch.js"; import {Eth1Error, Eth1ErrorCode} from "../errors.js"; -import {DepositTree} from "../../db/repositories/depositDataRoot.js"; import {Eth1Block} from "../interface.js"; type BlockNumber = number; diff --git a/packages/beacon-node/src/eth1/utils/eth1Vote.ts b/packages/beacon-node/src/eth1/utils/eth1Vote.ts index 84d35ae7d434..e1cd47301c22 100644 --- a/packages/beacon-node/src/eth1/utils/eth1Vote.ts +++ b/packages/beacon-node/src/eth1/utils/eth1Vote.ts @@ -1,7 +1,7 @@ -import {EPOCHS_PER_ETH1_VOTING_PERIOD, SLOTS_PER_EPOCH} from "@lodestar/params"; import {ChainForkConfig} from "@lodestar/config"; -import {phase0, RootHex} from "@lodestar/types"; +import {EPOCHS_PER_ETH1_VOTING_PERIOD, SLOTS_PER_EPOCH} from "@lodestar/params"; import {BeaconStateAllForks, computeTimeAtSlot} from "@lodestar/state-transition"; +import {RootHex, phase0} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; export type Eth1DataGetter = ({ diff --git a/packages/beacon-node/src/execution/builder/http.ts b/packages/beacon-node/src/execution/builder/http.ts index b95cfd6a80b9..12e45412bafc 100644 --- a/packages/beacon-node/src/execution/builder/http.ts +++ b/packages/beacon-node/src/execution/builder/http.ts @@ -1,25 +1,25 @@ +import {WireFormat} from "@lodestar/api"; +import {ApiClient as BuilderApi, getClient} from "@lodestar/api/builder"; +import {ChainForkConfig} from "@lodestar/config"; +import {Logger} from "@lodestar/logger"; +import {ForkExecution, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {parseExecutionPayloadAndBlobsBundle, reconstructFullBlockOrContents} from "@lodestar/state-transition"; import { - bellatrix, - Slot, - Root, BLSPubkey, - deneb, - Wei, + ExecutionPayloadHeader, + Root, SignedBeaconBlockOrContents, SignedBlindedBeaconBlock, - ExecutionPayloadHeader, - electra, + Slot, + Wei, WithOptionalBytes, + bellatrix, + deneb, + electra, } from "@lodestar/types"; -import {parseExecutionPayloadAndBlobsBundle, reconstructFullBlockOrContents} from "@lodestar/state-transition"; -import {ChainForkConfig} from "@lodestar/config"; -import {Logger} from "@lodestar/logger"; -import {getClient, ApiClient as BuilderApi} from "@lodestar/api/builder"; -import {SLOTS_PER_EPOCH, ForkExecution} from "@lodestar/params"; import {toPrintableUrl} from "@lodestar/utils"; import {Metrics} from "../../metrics/metrics.js"; import {IExecutionBuilder} from "./interface.js"; -import {WireFormat} from "@lodestar/api"; export type ExecutionBuilderHttpOpts = { enabled: boolean; diff --git a/packages/beacon-node/src/execution/builder/interface.ts b/packages/beacon-node/src/execution/builder/interface.ts index 19a935a9bf7e..06cdc1da4ed0 100644 --- a/packages/beacon-node/src/execution/builder/interface.ts +++ b/packages/beacon-node/src/execution/builder/interface.ts @@ -1,17 +1,17 @@ +import {ForkExecution} from "@lodestar/params"; import { - bellatrix, - Root, - Slot, BLSPubkey, - deneb, - Wei, - SignedBeaconBlockOrContents, ExecutionPayloadHeader, + Root, + SignedBeaconBlockOrContents, SignedBlindedBeaconBlock, - electra, + Slot, + Wei, WithOptionalBytes, + bellatrix, + deneb, + electra, } from "@lodestar/types"; -import {ForkExecution} from "@lodestar/params"; export interface IExecutionBuilder { /** diff --git a/packages/beacon-node/src/execution/engine/http.ts b/packages/beacon-node/src/execution/engine/http.ts index e5e65746d90f..c5cf61481b67 100644 --- a/packages/beacon-node/src/execution/engine/http.ts +++ b/packages/beacon-node/src/execution/engine/http.ts @@ -1,6 +1,6 @@ -import {ExecutionPayload, ExecutionRequests, Root, RootHex, Wei} from "@lodestar/types"; -import {SLOTS_PER_EPOCH, ForkName, ForkSeq} from "@lodestar/params"; import {Logger} from "@lodestar/logger"; +import {ForkName, ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {ExecutionPayload, ExecutionRequests, Root, RootHex, Wei} from "@lodestar/types"; import { ErrorJsonRpcResponse, HttpRpcError, @@ -8,36 +8,36 @@ import { JsonRpcHttpClientEvent, ReqOpts, } from "../../eth1/provider/jsonRpcHttpClient.js"; +import {numToQuantity} from "../../eth1/provider/utils.js"; import {Metrics} from "../../metrics/index.js"; -import {JobItemQueue} from "../../util/queue/index.js"; import {EPOCHS_PER_BATCH} from "../../sync/constants.js"; -import {numToQuantity} from "../../eth1/provider/utils.js"; import {getLodestarClientVersion} from "../../util/metadata.js"; +import {JobItemQueue} from "../../util/queue/index.js"; import { - ExecutionPayloadStatus, + BlobsBundle, + ClientCode, + ClientVersion, ExecutePayloadResponse, + ExecutionEngineState, + ExecutionPayloadStatus, IExecutionEngine, - PayloadId, PayloadAttributes, - BlobsBundle, + PayloadId, VersionedHashes, - ExecutionEngineState, - ClientVersion, - ClientCode, } from "./interface.js"; import {PayloadIdCache} from "./payloadIdCache.js"; import { EngineApiRpcParamTypes, EngineApiRpcReturnTypes, - parseExecutionPayload, - serializeExecutionPayload, - serializeVersionedHashes, - serializePayloadAttributes, - serializeBeaconBlockRoot, ExecutionPayloadBody, assertReqSizeLimit, deserializeExecutionPayloadBody, + parseExecutionPayload, + serializeBeaconBlockRoot, + serializeExecutionPayload, serializeExecutionRequests, + serializePayloadAttributes, + serializeVersionedHashes, } from "./types.js"; import {getExecutionEngineState} from "./utils.js"; diff --git a/packages/beacon-node/src/execution/engine/index.ts b/packages/beacon-node/src/execution/engine/index.ts index dd2de2017c22..d339276e2cc2 100644 --- a/packages/beacon-node/src/execution/engine/index.ts +++ b/packages/beacon-node/src/execution/engine/index.ts @@ -1,14 +1,14 @@ import {fromHex, toPrintableUrl} from "@lodestar/utils"; import {JsonRpcHttpClient} from "../../eth1/provider/jsonRpcHttpClient.js"; -import {IExecutionEngine} from "./interface.js"; import {ExecutionEngineDisabled} from "./disabled.js"; import { ExecutionEngineHttp, - ExecutionEngineModules, ExecutionEngineHttpOpts, + ExecutionEngineModules, defaultExecutionEngineHttpOpts, } from "./http.js"; -import {ExecutionEngineMockOpts, ExecutionEngineMockBackend} from "./mock.js"; +import {IExecutionEngine} from "./interface.js"; +import {ExecutionEngineMockBackend, ExecutionEngineMockOpts} from "./mock.js"; import {ExecutionEngineMockJsonRpcClient, JsonRpcBackend} from "./utils.js"; export {ExecutionEngineHttp, ExecutionEngineDisabled, defaultExecutionEngineHttpOpts}; diff --git a/packages/beacon-node/src/execution/engine/interface.ts b/packages/beacon-node/src/execution/engine/interface.ts index e6f9cfee526b..7bbf1bb27c1d 100644 --- a/packages/beacon-node/src/execution/engine/interface.ts +++ b/packages/beacon-node/src/execution/engine/interface.ts @@ -1,9 +1,9 @@ import {ForkName} from "@lodestar/params"; -import {KZGCommitment, Blob, KZGProof} from "@lodestar/types/deneb"; -import {Root, RootHex, capella, Wei, ExecutionPayload, ExecutionRequests} from "@lodestar/types"; +import {ExecutionPayload, ExecutionRequests, Root, RootHex, Wei, capella} from "@lodestar/types"; +import {Blob, KZGCommitment, KZGProof} from "@lodestar/types/deneb"; import {DATA} from "../../eth1/provider/utils.js"; -import {PayloadIdCache, PayloadId, WithdrawalV1} from "./payloadIdCache.js"; +import {PayloadId, PayloadIdCache, WithdrawalV1} from "./payloadIdCache.js"; import {ExecutionPayloadBody} from "./types.js"; export {PayloadIdCache, type PayloadId, type WithdrawalV1}; diff --git a/packages/beacon-node/src/execution/engine/mock.ts b/packages/beacon-node/src/execution/engine/mock.ts index 8062b68bf572..2331500624eb 100644 --- a/packages/beacon-node/src/execution/engine/mock.ts +++ b/packages/beacon-node/src/execution/engine/mock.ts @@ -1,30 +1,30 @@ import crypto from "node:crypto"; -import {bellatrix, deneb, RootHex, ssz} from "@lodestar/types"; -import {fromHex, toHex} from "@lodestar/utils"; import { + BLOB_TX_TYPE, BYTES_PER_FIELD_ELEMENT, FIELD_ELEMENTS_PER_BLOB, - ForkSeq, ForkExecution, ForkName, - BLOB_TX_TYPE, + ForkSeq, } from "@lodestar/params"; +import {RootHex, bellatrix, deneb, ssz} from "@lodestar/types"; +import {fromHex, toHex} from "@lodestar/utils"; import {ZERO_HASH_HEX} from "../../constants/index.js"; -import {ckzg} from "../../util/kzg.js"; -import {kzgCommitmentToVersionedHash} from "../../util/blobs.js"; import {quantityToNum} from "../../eth1/provider/utils.js"; +import {kzgCommitmentToVersionedHash} from "../../util/blobs.js"; +import {ckzg} from "../../util/kzg.js"; +import {ClientCode, ExecutionPayloadStatus, PayloadIdCache} from "./interface.js"; import { + BlobsBundleRpc, EngineApiRpcParamTypes, EngineApiRpcReturnTypes, - deserializePayloadAttributes, + ExecutionPayloadBodyRpc, + ExecutionPayloadRpc, PayloadStatus, + deserializePayloadAttributes, serializeBlobsBundle, serializeExecutionPayload, - ExecutionPayloadRpc, - BlobsBundleRpc, - ExecutionPayloadBodyRpc, } from "./types.js"; -import {ClientCode, ExecutionPayloadStatus, PayloadIdCache} from "./interface.js"; import {JsonRpcBackend} from "./utils.js"; const INTEROP_GAS_LIMIT = 30e6; diff --git a/packages/beacon-node/src/execution/engine/payloadIdCache.ts b/packages/beacon-node/src/execution/engine/payloadIdCache.ts index ea37e0922e9c..f6c18ddac6fa 100644 --- a/packages/beacon-node/src/execution/engine/payloadIdCache.ts +++ b/packages/beacon-node/src/execution/engine/payloadIdCache.ts @@ -1,7 +1,7 @@ import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {pruneSetToMax} from "@lodestar/utils"; -import {Metrics} from "../../metrics/index.js"; import {DATA, QUANTITY} from "../../eth1/provider/utils.js"; +import {Metrics} from "../../metrics/index.js"; import {PayloadAttributesRpc} from "./types.js"; // Idealy this only need to be set to the max head reorgs number diff --git a/packages/beacon-node/src/execution/engine/types.ts b/packages/beacon-node/src/execution/engine/types.ts index 52ddb8548629..9af2d8d1ce10 100644 --- a/packages/beacon-node/src/execution/engine/types.ts +++ b/packages/beacon-node/src/execution/engine/types.ts @@ -1,22 +1,22 @@ -import {capella, deneb, electra, Wei, bellatrix, Root, ExecutionPayload, ExecutionRequests, ssz} from "@lodestar/types"; import { + BYTES_PER_FIELD_ELEMENT, BYTES_PER_LOGS_BLOOM, FIELD_ELEMENTS_PER_BLOB, - BYTES_PER_FIELD_ELEMENT, ForkName, ForkSeq, } from "@lodestar/params"; +import {ExecutionPayload, ExecutionRequests, Root, Wei, bellatrix, capella, deneb, electra, ssz} from "@lodestar/types"; import { - bytesToData, - numToQuantity, - dataToBytes, - quantityToNum, DATA, QUANTITY, + bytesToData, + dataToBytes, + numToQuantity, quantityToBigint, + quantityToNum, } from "../../eth1/provider/utils.js"; -import {ExecutionPayloadStatus, BlobsBundle, PayloadAttributes, VersionedHashes} from "./interface.js"; +import {BlobsBundle, ExecutionPayloadStatus, PayloadAttributes, VersionedHashes} from "./interface.js"; import {WithdrawalV1} from "./payloadIdCache.js"; export type EngineApiRpcParamTypes = { diff --git a/packages/beacon-node/src/execution/engine/utils.ts b/packages/beacon-node/src/execution/engine/utils.ts index 4d84eda52c44..1a88edb22cce 100644 --- a/packages/beacon-node/src/execution/engine/utils.ts +++ b/packages/beacon-node/src/execution/engine/utils.ts @@ -2,14 +2,14 @@ import {isFetchError} from "@lodestar/api"; import {isErrorAborted} from "@lodestar/utils"; import {IJson, RpcPayload} from "../../eth1/interface.js"; import { - IJsonRpcHttpClient, ErrorJsonRpcResponse, HttpRpcError, - JsonRpcHttpClientEventEmitter, + IJsonRpcHttpClient, JsonRpcHttpClientEvent, + JsonRpcHttpClientEventEmitter, } from "../../eth1/provider/jsonRpcHttpClient.js"; import {isQueueErrorAborted} from "../../util/queue/errors.js"; -import {ExecutionPayloadStatus, ExecutionEngineState} from "./interface.js"; +import {ExecutionEngineState, ExecutionPayloadStatus} from "./interface.js"; export type JsonRpcBackend = { // biome-ignore lint/suspicious/noExplicitAny: diff --git a/packages/beacon-node/src/metrics/metrics.ts b/packages/beacon-node/src/metrics/metrics.ts index 58a48e34bbd5..ed607c7521ed 100644 --- a/packages/beacon-node/src/metrics/metrics.ts +++ b/packages/beacon-node/src/metrics/metrics.ts @@ -1,13 +1,13 @@ -import {Metric, Registry} from "prom-client"; -import {Logger} from "@lodestar/utils"; -import {BeaconStateAllForks, getCurrentSlot} from "@lodestar/state-transition"; import {ChainForkConfig} from "@lodestar/config"; -import {createBeaconMetrics, BeaconMetrics} from "./metrics/beacon.js"; -import {createLodestarMetrics, LodestarMetrics} from "./metrics/lodestar.js"; +import {BeaconStateAllForks, getCurrentSlot} from "@lodestar/state-transition"; +import {Logger} from "@lodestar/utils"; +import {Metric, Registry} from "prom-client"; +import {BeaconMetrics, createBeaconMetrics} from "./metrics/beacon.js"; +import {LodestarMetrics, createLodestarMetrics} from "./metrics/lodestar.js"; +import {collectNodeJSMetrics} from "./nodeJsMetrics.js"; import {MetricsOptions} from "./options.js"; import {RegistryMetricCreator} from "./utils/registryMetricCreator.js"; -import {createValidatorMonitor, ValidatorMonitor} from "./validatorMonitor.js"; -import {collectNodeJSMetrics} from "./nodeJsMetrics.js"; +import {ValidatorMonitor, createValidatorMonitor} from "./validatorMonitor.js"; export type Metrics = BeaconMetrics & LodestarMetrics & diff --git a/packages/beacon-node/src/metrics/metrics/beacon.ts b/packages/beacon-node/src/metrics/metrics/beacon.ts index b9a02a3b2059..0347aef8957b 100644 --- a/packages/beacon-node/src/metrics/metrics/beacon.ts +++ b/packages/beacon-node/src/metrics/metrics/beacon.ts @@ -1,13 +1,13 @@ -import {ProducedBlockSource} from "@lodestar/types"; -import {NotReorgedReason} from "@lodestar/fork-choice/lib/forkChoice/interface.js"; import {UpdateHeadOpt} from "@lodestar/fork-choice"; -import {RegistryMetricCreator} from "../utils/registryMetricCreator.js"; -import {BlockProductionStep, PayloadPreparationType} from "../../chain/produceBlock/index.js"; +import {NotReorgedReason} from "@lodestar/fork-choice/lib/forkChoice/interface.js"; +import {ProducedBlockSource} from "@lodestar/types"; import { BlockSelectionResult, BuilderBlockSelectionReason, EngineBlockSelectionReason, } from "../../api/impl/validator/index.js"; +import {BlockProductionStep, PayloadPreparationType} from "../../chain/produceBlock/index.js"; +import {RegistryMetricCreator} from "../utils/registryMetricCreator.js"; export type BeaconMetrics = ReturnType; diff --git a/packages/beacon-node/src/metrics/metrics/lodestar.ts b/packages/beacon-node/src/metrics/metrics/lodestar.ts index ac2cca319775..c138a8dfe26a 100644 --- a/packages/beacon-node/src/metrics/metrics/lodestar.ts +++ b/packages/beacon-node/src/metrics/metrics/lodestar.ts @@ -1,6 +1,6 @@ import {EpochTransitionStep, StateCloneSource, StateHashTreeRootSource} from "@lodestar/state-transition"; import {BeaconState} from "@lodestar/types"; -import {BlockSource, BlobsSource} from "../../chain/blocks/types.js"; +import {BlobsSource, BlockSource} from "../../chain/blocks/types.js"; import {JobQueueItemType} from "../../chain/bls/index.js"; import {BlockErrorCode} from "../../chain/errors/index.js"; import {InsertOutcome} from "../../chain/opPools/types.js"; @@ -8,17 +8,17 @@ import {RegenCaller, RegenFnName} from "../../chain/regen/interface.js"; import {ReprocessStatus} from "../../chain/reprocess.js"; import {RejectReason} from "../../chain/seenCache/seenAttestationData.js"; import {BlockInputAvailabilitySource} from "../../chain/seenCache/seenGossipBlockInput.js"; +import {CacheItemType} from "../../chain/stateCache/types.js"; import {ExecutionPayloadStatus} from "../../execution/index.js"; import {GossipType} from "../../network/index.js"; import {CannotAcceptWorkReason, ReprocessRejectReason} from "../../network/processor/index.js"; import {BackfillSyncMethod} from "../../sync/backfill/backfill.js"; import {PendingBlockType} from "../../sync/index.js"; import {PeerSyncType, RangeSyncType} from "../../sync/utils/remoteSyncType.js"; +import {AllocSource} from "../../util/bufferPool.js"; import {LodestarMetadata} from "../options.js"; import {RegistryMetricCreator} from "../utils/registryMetricCreator.js"; import {OpSource} from "../validatorMonitor.js"; -import {CacheItemType} from "../../chain/stateCache/types.js"; -import {AllocSource} from "../../util/bufferPool.js"; export type LodestarMetrics = ReturnType; diff --git a/packages/beacon-node/src/metrics/nodeJsMetrics.ts b/packages/beacon-node/src/metrics/nodeJsMetrics.ts index c565cfc07ba5..c448276e278a 100644 --- a/packages/beacon-node/src/metrics/nodeJsMetrics.ts +++ b/packages/beacon-node/src/metrics/nodeJsMetrics.ts @@ -1,5 +1,5 @@ -import {collectDefaultMetrics, Registry} from "prom-client"; import {gcStats} from "@chainsafe/prometheus-gc-stats"; +import {Registry, collectDefaultMetrics} from "prom-client"; export function collectNodeJSMetrics(register: Registry, prefix?: string): () => void { collectDefaultMetrics({ diff --git a/packages/beacon-node/src/metrics/server/http.ts b/packages/beacon-node/src/metrics/server/http.ts index e197dcfa2a25..5d4fa36998fb 100644 --- a/packages/beacon-node/src/metrics/server/http.ts +++ b/packages/beacon-node/src/metrics/server/http.ts @@ -1,9 +1,9 @@ import http from "node:http"; import {AddressInfo} from "node:net"; -import {Registry} from "prom-client"; import {Logger} from "@lodestar/utils"; -import {wrapError} from "../../util/wrapError.js"; +import {Registry} from "prom-client"; import {HttpActiveSocketsTracker} from "../../api/rest/activeSockets.js"; +import {wrapError} from "../../util/wrapError.js"; import {RegistryMetricCreator} from "../utils/registryMetricCreator.js"; export type HttpMetricsServerOpts = { diff --git a/packages/beacon-node/src/metrics/utils/avgMinMax.ts b/packages/beacon-node/src/metrics/utils/avgMinMax.ts index 709c83ee38d6..8bb5b196141e 100644 --- a/packages/beacon-node/src/metrics/utils/avgMinMax.ts +++ b/packages/beacon-node/src/metrics/utils/avgMinMax.ts @@ -1,5 +1,5 @@ -import {GaugeConfiguration} from "prom-client"; import {AvgMinMax as IAvgMinMax, LabelKeys, LabelsGeneric} from "@lodestar/utils"; +import {GaugeConfiguration} from "prom-client"; import {GaugeExtra} from "./gauge.js"; type GetValuesFn = () => number[]; diff --git a/packages/beacon-node/src/metrics/utils/gauge.ts b/packages/beacon-node/src/metrics/utils/gauge.ts index 1f527adfcb64..a4c5e9966759 100644 --- a/packages/beacon-node/src/metrics/utils/gauge.ts +++ b/packages/beacon-node/src/metrics/utils/gauge.ts @@ -1,5 +1,5 @@ -import {Gauge} from "prom-client"; import {CollectFn, Gauge as IGauge, LabelKeys, LabelsGeneric} from "@lodestar/utils"; +import {Gauge} from "prom-client"; /** * Extends the prom-client Gauge to be able to add multiple collect functions after instantiation diff --git a/packages/beacon-node/src/metrics/utils/registryMetricCreator.ts b/packages/beacon-node/src/metrics/utils/registryMetricCreator.ts index adec6f984702..30de36969456 100644 --- a/packages/beacon-node/src/metrics/utils/registryMetricCreator.ts +++ b/packages/beacon-node/src/metrics/utils/registryMetricCreator.ts @@ -1,4 +1,3 @@ -import {Gauge, Registry, Counter, Histogram} from "prom-client"; import { AvgMinMaxConfig, CounterConfig, @@ -14,6 +13,7 @@ import { NoLabels, StaticConfig, } from "@lodestar/utils"; +import {Counter, Gauge, Histogram, Registry} from "prom-client"; import {AvgMinMax} from "./avgMinMax.js"; import {GaugeExtra} from "./gauge.js"; diff --git a/packages/beacon-node/src/metrics/validatorMonitor.ts b/packages/beacon-node/src/metrics/validatorMonitor.ts index 14a210f62997..401d58af57ff 100644 --- a/packages/beacon-node/src/metrics/validatorMonitor.ts +++ b/packages/beacon-node/src/metrics/validatorMonitor.ts @@ -1,19 +1,19 @@ +import {ChainConfig, ChainForkConfig} from "@lodestar/config"; +import {ForkSeq, INTERVALS_PER_SLOT, MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH} from "@lodestar/params"; import { - computeEpochAtSlot, - parseAttesterFlags, CachedBeaconStateAllForks, CachedBeaconStateAltair, - parseParticipationFlags, + ParticipationFlags, + computeEpochAtSlot, computeStartSlotAtEpoch, getBlockRootAtSlot, - ParticipationFlags, + parseAttesterFlags, + parseParticipationFlags, } from "@lodestar/state-transition"; -import {LogData, LogHandler, LogLevel, Logger, MapDef, MapDefMax, toRootHex} from "@lodestar/utils"; import {BeaconBlock, RootHex, altair, deneb} from "@lodestar/types"; -import {ChainConfig, ChainForkConfig} from "@lodestar/config"; -import {ForkSeq, INTERVALS_PER_SLOT, MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH} from "@lodestar/params"; import {Epoch, Slot, ValidatorIndex} from "@lodestar/types"; import {IndexedAttestation, SignedAggregateAndProof} from "@lodestar/types"; +import {LogData, LogHandler, LogLevel, Logger, MapDef, MapDefMax, toRootHex} from "@lodestar/utils"; import {GENESIS_SLOT} from "../constants/constants.js"; import {LodestarMetrics} from "./metrics/lodestar.js"; diff --git a/packages/beacon-node/src/monitoring/service.ts b/packages/beacon-node/src/monitoring/service.ts index f6a6a2352e02..930fe4a65224 100644 --- a/packages/beacon-node/src/monitoring/service.ts +++ b/packages/beacon-node/src/monitoring/service.ts @@ -1,11 +1,11 @@ -import {Registry} from "prom-client"; import {fetch} from "@lodestar/api"; import {ErrorAborted, Histogram, Logger, TimeoutError} from "@lodestar/utils"; +import {Registry} from "prom-client"; import {RegistryMetricCreator} from "../metrics/index.js"; -import {defaultMonitoringOptions, MonitoringOptions} from "./options.js"; import {createClientStats} from "./clientStats.js"; -import {ClientStats} from "./types.js"; +import {MonitoringOptions, defaultMonitoringOptions} from "./options.js"; import system from "./system.js"; +import {ClientStats} from "./types.js"; type MonitoringData = Record; diff --git a/packages/beacon-node/src/monitoring/system.ts b/packages/beacon-node/src/monitoring/system.ts index 83507443be01..4afcc6064b16 100644 --- a/packages/beacon-node/src/monitoring/system.ts +++ b/packages/beacon-node/src/monitoring/system.ts @@ -2,9 +2,9 @@ /* eslint-disable import/no-named-as-default-member */ import os from "node:os"; import path from "node:path"; +import {Logger} from "@lodestar/utils"; // We want to keep `system` export as it's more readable and easier to understand import system from "systeminformation"; -import {Logger} from "@lodestar/utils"; type MiscOs = "lin" | "win" | "mac" | "unk"; diff --git a/packages/beacon-node/src/network/core/networkCore.ts b/packages/beacon-node/src/network/core/networkCore.ts index d47fcabd4146..718b7c92df7f 100644 --- a/packages/beacon-node/src/network/core/networkCore.ts +++ b/packages/beacon-node/src/network/core/networkCore.ts @@ -1,37 +1,37 @@ -import {Connection, PeerId} from "@libp2p/interface"; -import {multiaddr} from "@multiformats/multiaddr"; -import {PublishOpts} from "@chainsafe/libp2p-gossipsub/types"; -import {PeerScoreStatsDump} from "@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js"; import {ENR} from "@chainsafe/enr"; +import {PeerScoreStatsDump} from "@chainsafe/libp2p-gossipsub/dist/src/score/peer-score.js"; +import {PublishOpts} from "@chainsafe/libp2p-gossipsub/types"; +import {Connection, PeerId} from "@libp2p/interface"; import {routes} from "@lodestar/api"; import {BeaconConfig} from "@lodestar/config"; import type {LoggerNode} from "@lodestar/logger/node"; -import {Epoch, phase0} from "@lodestar/types"; -import {fromHex, withTimeout} from "@lodestar/utils"; import {ForkName} from "@lodestar/params"; import {ResponseIncoming} from "@lodestar/reqresp"; -import {Libp2p} from "../interface.js"; -import {PeerManager} from "../peers/peerManager.js"; -import {ReqRespBeaconNode} from "../reqresp/ReqRespBeaconNode.js"; -import {OutgoingRequestArgs, GetReqRespHandlerFn} from "../reqresp/types.js"; -import {Eth2Gossipsub, getCoreTopicsAtFork} from "../gossip/index.js"; -import {SyncnetsService} from "../subnets/syncnetsService.js"; +import {Epoch, phase0} from "@lodestar/types"; +import {fromHex, withTimeout} from "@lodestar/utils"; +import {multiaddr} from "@multiformats/multiaddr"; +import {formatNodePeer} from "../../api/impl/node/utils.js"; +import {RegistryMetricCreator} from "../../metrics/index.js"; +import {ClockEvent, IClock} from "../../util/clock.js"; +import {peerIdFromString, peerIdToString} from "../../util/peerId.js"; +import {Discv5Worker} from "../discv5/index.js"; +import {NetworkEventBus} from "../events.js"; import {FORK_EPOCH_LOOKAHEAD, getActiveForks} from "../forks.js"; -import {NetworkOptions} from "../options.js"; -import {CommitteeSubscription, IAttnetsService} from "../subnets/interface.js"; -import {MetadataController} from "../metadata.js"; +import {Eth2Gossipsub, getCoreTopicsAtFork} from "../gossip/index.js"; +import {Libp2p} from "../interface.js"; import {createNodeJsLibp2p} from "../libp2p/index.js"; -import {PeersData} from "../peers/peersData.js"; +import {MetadataController} from "../metadata.js"; +import {NetworkOptions} from "../options.js"; import {PeerAction, PeerRpcScoreStore, PeerScoreStats} from "../peers/index.js"; -import {getConnectionsMap} from "../util.js"; -import {IClock, ClockEvent} from "../../util/clock.js"; -import {formatNodePeer} from "../../api/impl/node/utils.js"; -import {NetworkEventBus} from "../events.js"; -import {Discv5Worker} from "../discv5/index.js"; +import {PeerManager} from "../peers/peerManager.js"; +import {PeersData} from "../peers/peersData.js"; +import {ReqRespBeaconNode} from "../reqresp/ReqRespBeaconNode.js"; +import {GetReqRespHandlerFn, OutgoingRequestArgs} from "../reqresp/types.js"; import {LocalStatusCache} from "../statusCache.js"; -import {RegistryMetricCreator} from "../../metrics/index.js"; -import {peerIdFromString, peerIdToString} from "../../util/peerId.js"; import {AttnetsService} from "../subnets/attnetsService.js"; +import {CommitteeSubscription, IAttnetsService} from "../subnets/interface.js"; +import {SyncnetsService} from "../subnets/syncnetsService.js"; +import {getConnectionsMap} from "../util.js"; import {NetworkCoreMetrics, createNetworkCoreMetrics} from "./metrics.js"; import {INetworkCore, MultiaddrStr, PeerIdStr} from "./types.js"; diff --git a/packages/beacon-node/src/network/core/networkCoreWorker.ts b/packages/beacon-node/src/network/core/networkCoreWorker.ts index 5e4b057402d8..a5622bc6a5c1 100644 --- a/packages/beacon-node/src/network/core/networkCoreWorker.ts +++ b/packages/beacon-node/src/network/core/networkCoreWorker.ts @@ -11,11 +11,8 @@ import {AsyncIterableBridgeCaller, AsyncIterableBridgeHandler} from "../../util/ import {Clock} from "../../util/clock.js"; import {peerIdToString} from "../../util/peerId.js"; import {profileNodeJS, writeHeapSnapshot} from "../../util/profile.js"; -import {NetworkEventBus, NetworkEventData, networkEventDirection} from "../events.js"; import {wireEventsOnWorkerThread} from "../../util/workerEvents.js"; -import {getNetworkCoreWorkerMetrics} from "./metrics.js"; -import {NetworkWorkerApi, NetworkWorkerData} from "./types.js"; -import {NetworkCore} from "./networkCore.js"; +import {NetworkEventBus, NetworkEventData, networkEventDirection} from "../events.js"; import { NetworkWorkerThreadEventType, ReqRespBridgeEventBus, @@ -24,6 +21,9 @@ import { getReqRespBridgeRespEvents, reqRespBridgeEventDirection, } from "./events.js"; +import {getNetworkCoreWorkerMetrics} from "./metrics.js"; +import {NetworkCore} from "./networkCore.js"; +import {NetworkWorkerApi, NetworkWorkerData} from "./types.js"; // Cloned data from instantiation const workerData = worker.workerData as NetworkWorkerData; diff --git a/packages/beacon-node/src/network/core/types.ts b/packages/beacon-node/src/network/core/types.ts index 4eeaf96e1903..87feb9da9d21 100644 --- a/packages/beacon-node/src/network/core/types.ts +++ b/packages/beacon-node/src/network/core/types.ts @@ -1,13 +1,13 @@ import {PeerScoreStatsDump} from "@chainsafe/libp2p-gossipsub/score"; import {PublishOpts} from "@chainsafe/libp2p-gossipsub/types"; import {routes} from "@lodestar/api"; +import {LoggerNodeOpts} from "@lodestar/logger/node"; import {ResponseIncoming} from "@lodestar/reqresp"; import {phase0} from "@lodestar/types"; -import {LoggerNodeOpts} from "@lodestar/logger/node"; import {NetworkOptions} from "../options.js"; -import {CommitteeSubscription} from "../subnets/interface.js"; import {PeerAction, PeerScoreStats} from "../peers/index.js"; import {OutgoingRequestArgs} from "../reqresp/types.js"; +import {CommitteeSubscription} from "../subnets/interface.js"; export type MultiaddrStr = string; export type PeerIdStr = string; diff --git a/packages/beacon-node/src/network/discv5/index.ts b/packages/beacon-node/src/network/discv5/index.ts index 745b3171c38d..b010ee1ac670 100644 --- a/packages/beacon-node/src/network/discv5/index.ts +++ b/packages/beacon-node/src/network/discv5/index.ts @@ -1,11 +1,11 @@ import EventEmitter from "node:events"; +import {ENR, ENRData, SignableENR, createPrivateKeyFromPeerId} from "@chainsafe/enr"; +import {Thread, Worker, spawn} from "@chainsafe/threads"; import {PeerId, Secp256k1PeerId} from "@libp2p/interface"; -import {StrictEventEmitter} from "strict-event-emitter-types"; import {exportToProtobuf} from "@libp2p/peer-id-factory"; -import {createPrivateKeyFromPeerId, ENR, ENRData, SignableENR} from "@chainsafe/enr"; -import {spawn, Thread, Worker} from "@chainsafe/threads"; -import {chainConfigFromJson, chainConfigToJson, BeaconConfig} from "@lodestar/config"; +import {BeaconConfig, chainConfigFromJson, chainConfigToJson} from "@lodestar/config"; import {LoggerNode} from "@lodestar/logger/node"; +import {StrictEventEmitter} from "strict-event-emitter-types"; import {NetworkCoreMetrics} from "../core/metrics.js"; import {Discv5WorkerApi, Discv5WorkerData, LodestarDiscv5Opts} from "./types.js"; diff --git a/packages/beacon-node/src/network/discv5/worker.ts b/packages/beacon-node/src/network/discv5/worker.ts index 8e96751d5fe7..49dfc9c2f35d 100644 --- a/packages/beacon-node/src/network/discv5/worker.ts +++ b/packages/beacon-node/src/network/discv5/worker.ts @@ -1,20 +1,20 @@ -import worker from "node:worker_threads"; -import path from "node:path"; import fs from "node:fs"; -import {createFromProtobuf} from "@libp2p/peer-id-factory"; -import {Multiaddr, multiaddr} from "@multiformats/multiaddr"; -import {expose} from "@chainsafe/threads/worker"; -import {Observable, Subject} from "@chainsafe/threads/observable"; +import path from "node:path"; +import worker from "node:worker_threads"; import {Discv5} from "@chainsafe/discv5"; -import {createPrivateKeyFromPeerId, ENR, ENRData, SignableENR, SignableENRData} from "@chainsafe/enr"; +import {ENR, ENRData, SignableENR, SignableENRData, createPrivateKeyFromPeerId} from "@chainsafe/enr"; +import {Observable, Subject} from "@chainsafe/threads/observable"; +import {expose} from "@chainsafe/threads/worker"; +import {createFromProtobuf} from "@libp2p/peer-id-factory"; import {createBeaconConfig} from "@lodestar/config"; import {getNodeLogger} from "@lodestar/logger/node"; import {Gauge} from "@lodestar/utils"; +import {Multiaddr, multiaddr} from "@multiformats/multiaddr"; import {RegistryMetricCreator} from "../../metrics/index.js"; import {collectNodeJSMetrics} from "../../metrics/nodeJsMetrics.js"; import {profileNodeJS, writeHeapSnapshot} from "../../util/profile.js"; import {Discv5WorkerApi, Discv5WorkerData} from "./types.js"; -import {enrRelevance, ENRRelevance} from "./utils.js"; +import {ENRRelevance, enrRelevance} from "./utils.js"; // This discv5 worker will start discv5 on initialization (there is no `start` function to call) // A consumer _should_ call `close` before terminating the worker to cleanly exit discv5 before destroying the thread diff --git a/packages/beacon-node/src/network/events.ts b/packages/beacon-node/src/network/events.ts index a95b52394163..ed3e7ec876ed 100644 --- a/packages/beacon-node/src/network/events.ts +++ b/packages/beacon-node/src/network/events.ts @@ -1,12 +1,12 @@ import {EventEmitter} from "node:events"; import {PeerId, TopicValidatorResult} from "@libp2p/interface"; -import {phase0, RootHex} from "@lodestar/types"; +import {RootHex, phase0} from "@lodestar/types"; import {BlockInput, NullBlockInput} from "../chain/blocks/types.js"; -import {StrictEventEmitterSingleArg} from "../util/strictEvents.js"; import {PeerIdStr} from "../util/peerId.js"; +import {StrictEventEmitterSingleArg} from "../util/strictEvents.js"; import {EventDirection} from "../util/workerEvents.js"; -import {RequestTypedContainer} from "./reqresp/ReqRespBeaconNode.js"; import {PendingGossipsubMessage} from "./processor/types.js"; +import {RequestTypedContainer} from "./reqresp/ReqRespBeaconNode.js"; export enum NetworkEvent { /** A relevant peer has connected or has been re-STATUS'd */ diff --git a/packages/beacon-node/src/network/forks.ts b/packages/beacon-node/src/network/forks.ts index 1c613f4cee94..cad4616c008b 100644 --- a/packages/beacon-node/src/network/forks.ts +++ b/packages/beacon-node/src/network/forks.ts @@ -1,5 +1,5 @@ -import {ForkName} from "@lodestar/params"; import {ChainForkConfig, ForkInfo} from "@lodestar/config"; +import {ForkName} from "@lodestar/params"; import {Epoch} from "@lodestar/types"; /** diff --git a/packages/beacon-node/src/network/gossip/encoding.ts b/packages/beacon-node/src/network/gossip/encoding.ts index f7f733fcd915..f6121bf8af91 100644 --- a/packages/beacon-node/src/network/gossip/encoding.ts +++ b/packages/beacon-node/src/network/gossip/encoding.ts @@ -1,13 +1,13 @@ -import {compress, uncompress} from "snappyjs"; -import xxhashFactory from "xxhash-wasm"; -import {Message} from "@libp2p/interface"; import {digest} from "@chainsafe/as-sha256"; import {RPC} from "@chainsafe/libp2p-gossipsub/message"; import {DataTransform} from "@chainsafe/libp2p-gossipsub/types"; -import {intToBytes} from "@lodestar/utils"; +import {Message} from "@libp2p/interface"; import {ForkName} from "@lodestar/params"; +import {intToBytes} from "@lodestar/utils"; +import {compress, uncompress} from "snappyjs"; +import xxhashFactory from "xxhash-wasm"; import {MESSAGE_DOMAIN_VALID_SNAPPY} from "./constants.js"; -import {getGossipSSZType, GossipTopicCache} from "./topic.js"; +import {GossipTopicCache, getGossipSSZType} from "./topic.js"; // Load WASM const xxhash = await xxhashFactory(); diff --git a/packages/beacon-node/src/network/gossip/gossipsub.ts b/packages/beacon-node/src/network/gossip/gossipsub.ts index 76e1330cd4a1..42f8ba8b114c 100644 --- a/packages/beacon-node/src/network/gossip/gossipsub.ts +++ b/packages/beacon-node/src/network/gossip/gossipsub.ts @@ -1,29 +1,29 @@ import {GossipSub, GossipsubEvents} from "@chainsafe/libp2p-gossipsub"; -import {SignaturePolicy, TopicStr} from "@chainsafe/libp2p-gossipsub/types"; -import {PeerScoreParams} from "@chainsafe/libp2p-gossipsub/score"; import {MetricsRegister, TopicLabel, TopicStrToLabel} from "@chainsafe/libp2p-gossipsub/metrics"; +import {PeerScoreParams} from "@chainsafe/libp2p-gossipsub/score"; +import {SignaturePolicy, TopicStr} from "@chainsafe/libp2p-gossipsub/types"; import {BeaconConfig} from "@lodestar/config"; import {ATTESTATION_SUBNET_COUNT, ForkName, SLOTS_PER_EPOCH, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; import {Logger, Map2d, Map2dArr} from "@lodestar/utils"; -import {RegistryMetricCreator} from "../../metrics/index.js"; -import {PeersData} from "../peers/peersData.js"; -import {ClientKind} from "../peers/client.js"; import {GOSSIP_MAX_SIZE, GOSSIP_MAX_SIZE_BELLATRIX} from "../../constants/network.js"; -import {Libp2p} from "../interface.js"; -import {NetworkEvent, NetworkEventBus, NetworkEventData} from "../events.js"; +import {RegistryMetricCreator} from "../../metrics/index.js"; import {callInNextEventLoop} from "../../util/eventLoop.js"; -import {GossipTopic, GossipType} from "./interface.js"; -import {GossipTopicCache, stringifyGossipTopic, getCoreTopicsAtFork} from "./topic.js"; +import {NetworkEvent, NetworkEventBus, NetworkEventData} from "../events.js"; +import {Libp2p} from "../interface.js"; +import {ClientKind} from "../peers/client.js"; +import {PeersData} from "../peers/peersData.js"; import {DataTransformSnappy, fastMsgIdFn, msgIdFn, msgIdToStrFn} from "./encoding.js"; -import {createEth2GossipsubMetrics, Eth2GossipsubMetrics} from "./metrics.js"; +import {GossipTopic, GossipType} from "./interface.js"; +import {Eth2GossipsubMetrics, createEth2GossipsubMetrics} from "./metrics.js"; +import {GossipTopicCache, getCoreTopicsAtFork, stringifyGossipTopic} from "./topic.js"; import { - computeGossipPeerScoreParams, - gossipScoreThresholds, GOSSIP_D, GOSSIP_D_HIGH, GOSSIP_D_LOW, + computeGossipPeerScoreParams, + gossipScoreThresholds, } from "./scoringParameters.js"; /** As specified in https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md */ diff --git a/packages/beacon-node/src/network/gossip/interface.ts b/packages/beacon-node/src/network/gossip/interface.ts index ff1bfa088c17..9939ed5af657 100644 --- a/packages/beacon-node/src/network/gossip/interface.ts +++ b/packages/beacon-node/src/network/gossip/interface.ts @@ -1,25 +1,25 @@ -import {Libp2p} from "libp2p"; -import {Message, TopicValidatorResult} from "@libp2p/interface"; import {PeerIdStr} from "@chainsafe/libp2p-gossipsub/types"; +import {Message, TopicValidatorResult} from "@libp2p/interface"; +import {BeaconConfig} from "@lodestar/config"; import {ForkName} from "@lodestar/params"; import { - altair, - capella, - deneb, + Attestation, LightClientFinalityUpdate, LightClientOptimisticUpdate, - phase0, + SignedAggregateAndProof, SignedBeaconBlock, Slot, - Attestation, - SignedAggregateAndProof, + altair, + capella, + deneb, + phase0, } from "@lodestar/types"; -import {BeaconConfig} from "@lodestar/config"; import {Logger} from "@lodestar/utils"; -import {IBeaconChain} from "../../chain/index.js"; -import {JobItemQueue} from "../../util/queue/index.js"; +import {Libp2p} from "libp2p"; import {AttestationError, AttestationErrorType} from "../../chain/errors/attestationError.js"; import {GossipActionError} from "../../chain/errors/gossipValidation.js"; +import {IBeaconChain} from "../../chain/index.js"; +import {JobItemQueue} from "../../util/queue/index.js"; export enum GossipType { beacon_block = "beacon_block", diff --git a/packages/beacon-node/src/network/gossip/scoringParameters.ts b/packages/beacon-node/src/network/gossip/scoringParameters.ts index 3ba32614afeb..890fd5acd251 100644 --- a/packages/beacon-node/src/network/gossip/scoringParameters.ts +++ b/packages/beacon-node/src/network/gossip/scoringParameters.ts @@ -1,12 +1,12 @@ import { - defaultTopicScoreParams, PeerScoreParams, - TopicScoreParams, PeerScoreThresholds, + TopicScoreParams, + defaultTopicScoreParams, } from "@chainsafe/libp2p-gossipsub/score"; -import {computeCommitteeCount} from "@lodestar/state-transition"; import {BeaconConfig} from "@lodestar/config"; import {ATTESTATION_SUBNET_COUNT, SLOTS_PER_EPOCH, TARGET_AGGREGATORS_PER_COMMITTEE} from "@lodestar/params"; +import {computeCommitteeCount} from "@lodestar/state-transition"; import {getActiveForks} from "../forks.js"; import {Eth2Context, Eth2GossipsubModules} from "./gossipsub.js"; import {GossipType} from "./interface.js"; diff --git a/packages/beacon-node/src/network/gossip/topic.ts b/packages/beacon-node/src/network/gossip/topic.ts index ed44c8314425..de52860605a9 100644 --- a/packages/beacon-node/src/network/gossip/topic.ts +++ b/packages/beacon-node/src/network/gossip/topic.ts @@ -1,17 +1,17 @@ -import {ssz, Attestation, sszTypesFor} from "@lodestar/types"; import {ForkDigestContext} from "@lodestar/config"; import { ATTESTATION_SUBNET_COUNT, ForkName, ForkSeq, + MAX_BLOBS_PER_BLOCK, SYNC_COMMITTEE_SUBNET_COUNT, isForkLightClient, - MAX_BLOBS_PER_BLOCK, } from "@lodestar/params"; +import {Attestation, ssz, sszTypesFor} from "@lodestar/types"; import {GossipAction, GossipActionError, GossipErrorCode} from "../../chain/errors/gossipValidation.js"; -import {GossipEncoding, GossipTopic, GossipType, GossipTopicTypeMap, SSZTypeOfGossipTopic} from "./interface.js"; import {DEFAULT_ENCODING} from "./constants.js"; +import {GossipEncoding, GossipTopic, GossipTopicTypeMap, GossipType, SSZTypeOfGossipTopic} from "./interface.js"; export interface IGossipTopicCache { getTopic(topicStr: string): GossipTopic; diff --git a/packages/beacon-node/src/network/interface.ts b/packages/beacon-node/src/network/interface.ts index 0d48df42b31e..bf117cc8a743 100644 --- a/packages/beacon-node/src/network/interface.ts +++ b/packages/beacon-node/src/network/interface.ts @@ -1,40 +1,40 @@ -import {Libp2p as ILibp2p} from "libp2p"; +import {Identify} from "@chainsafe/libp2p-identify"; import { - Libp2pEvents, ComponentLogger, - NodeInfo, - ConnectionProtector, ConnectionGater, + ConnectionProtector, ContentRouting, - TypedEventTarget, + Libp2pEvents, Metrics, + NodeInfo, PeerId, PeerRouting, PeerStore, + TypedEventTarget, Upgrader, } from "@libp2p/interface"; import type {AddressManager, ConnectionManager, Registrar, TransportManager} from "@libp2p/interface-internal"; -import type {Datastore} from "interface-datastore"; -import {Identify} from "@chainsafe/libp2p-identify"; import { LightClientFinalityUpdate, LightClientOptimisticUpdate, + SignedAggregateAndProof, SignedBeaconBlock, Slot, SlotRootHex, + WithBytes, altair, capella, deneb, phase0, - SignedAggregateAndProof, - WithBytes, } from "@lodestar/types"; +import type {Datastore} from "interface-datastore"; +import {Libp2p as ILibp2p} from "libp2p"; import {PeerIdStr} from "../util/peerId.js"; -import {INetworkEventBus} from "./events.js"; import {INetworkCorePublic} from "./core/types.js"; +import {INetworkEventBus} from "./events.js"; import {GossipType} from "./gossip/interface.js"; -import {PendingGossipsubMessage} from "./processor/types.js"; import {PeerAction} from "./peers/index.js"; +import {PendingGossipsubMessage} from "./processor/types.js"; /** * The architecture of the network looks like so: diff --git a/packages/beacon-node/src/network/libp2p/index.ts b/packages/beacon-node/src/network/libp2p/index.ts index a0d58033cf2f..3191a63ac85c 100644 --- a/packages/beacon-node/src/network/libp2p/index.ts +++ b/packages/beacon-node/src/network/libp2p/index.ts @@ -1,18 +1,18 @@ -import {PeerId} from "@libp2p/interface"; -import {Registry} from "prom-client"; import {ENR} from "@chainsafe/enr"; // TODO: We should use this fork until https://github.com/libp2p/js-libp2p/pull/2387 import {identify} from "@chainsafe/libp2p-identify"; +import {noise} from "@chainsafe/libp2p-noise"; import {bootstrap} from "@libp2p/bootstrap"; +import {PeerId} from "@libp2p/interface"; import {mdns} from "@libp2p/mdns"; -import {createLibp2p} from "libp2p"; import {mplex} from "@libp2p/mplex"; import {prometheusMetrics} from "@libp2p/prometheus-metrics"; import {tcp} from "@libp2p/tcp"; -import {noise} from "@chainsafe/libp2p-noise"; -import {defaultNetworkOptions, NetworkOptions} from "../options.js"; -import {Eth2PeerDataStore} from "../peers/datastore.js"; +import {createLibp2p} from "libp2p"; +import {Registry} from "prom-client"; import {Libp2p, LodestarComponents} from "../interface.js"; +import {NetworkOptions, defaultNetworkOptions} from "../options.js"; +import {Eth2PeerDataStore} from "../peers/datastore.js"; export type NodeJsLibp2pOpts = { peerStoreDir?: string; diff --git a/packages/beacon-node/src/network/metadata.ts b/packages/beacon-node/src/network/metadata.ts index fab220c1ebf8..7b70775d63c6 100644 --- a/packages/beacon-node/src/network/metadata.ts +++ b/packages/beacon-node/src/network/metadata.ts @@ -1,8 +1,8 @@ import {BitArray} from "@chainsafe/ssz"; +import {BeaconConfig} from "@lodestar/config"; import {ForkSeq} from "@lodestar/params"; import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; -import {altair, Epoch, phase0, ssz} from "@lodestar/types"; -import {BeaconConfig} from "@lodestar/config"; +import {Epoch, altair, phase0, ssz} from "@lodestar/types"; import {FAR_FUTURE_EPOCH} from "../constants/index.js"; import {getCurrentAndNextFork} from "./forks.js"; diff --git a/packages/beacon-node/src/network/network.ts b/packages/beacon-node/src/network/network.ts index 15414fcf9138..2181e21744da 100644 --- a/packages/beacon-node/src/network/network.ts +++ b/packages/beacon-node/src/network/network.ts @@ -1,53 +1,53 @@ -import {PeerId} from "@libp2p/interface"; -import {PublishOpts} from "@chainsafe/libp2p-gossipsub/types"; import {PeerScoreStatsDump} from "@chainsafe/libp2p-gossipsub/score"; +import {PublishOpts} from "@chainsafe/libp2p-gossipsub/types"; +import {PeerId} from "@libp2p/interface"; +import {routes} from "@lodestar/api"; import {BeaconConfig} from "@lodestar/config"; -import {sleep} from "@lodestar/utils"; import {LoggerNode} from "@lodestar/logger/node"; +import {ForkSeq, MAX_BLOBS_PER_BLOCK} from "@lodestar/params"; +import {ResponseIncoming} from "@lodestar/reqresp"; import {computeStartSlotAtEpoch, computeTimeAtSlot} from "@lodestar/state-transition"; import { - phase0, - deneb, - altair, - Root, - capella, - SlotRootHex, - SignedBeaconBlock, LightClientBootstrap, LightClientFinalityUpdate, LightClientOptimisticUpdate, LightClientUpdate, + Root, SignedAggregateAndProof, + SignedBeaconBlock, + SlotRootHex, WithBytes, + altair, + capella, + deneb, + phase0, } from "@lodestar/types"; -import {routes} from "@lodestar/api"; -import {ResponseIncoming} from "@lodestar/reqresp"; -import {ForkSeq, MAX_BLOBS_PER_BLOCK} from "@lodestar/params"; -import {Metrics, RegistryMetricCreator} from "../metrics/index.js"; +import {sleep} from "@lodestar/utils"; import {IBeaconChain} from "../chain/index.js"; import {IBeaconDb} from "../db/interface.js"; -import {PeerIdStr, peerIdToString} from "../util/peerId.js"; +import {Metrics, RegistryMetricCreator} from "../metrics/index.js"; import {IClock} from "../util/clock.js"; -import {NetworkOptions} from "./options.js"; -import {INetwork} from "./interface.js"; -import {ReqRespMethod} from "./reqresp/index.js"; +import {PeerIdStr, peerIdToString} from "../util/peerId.js"; +import {INetworkCore, NetworkCore, WorkerNetworkCore} from "./core/index.js"; +import {INetworkEventBus, NetworkEvent, NetworkEventBus, NetworkEventData} from "./events.js"; +import {getActiveForks} from "./forks.js"; import {GossipHandlers, GossipTopicMap, GossipType, GossipTypeMap} from "./gossip/index.js"; +import {getGossipSSZType, gossipTopicIgnoreDuplicatePublishError, stringifyGossipTopic} from "./gossip/topic.js"; +import {INetwork} from "./interface.js"; +import {NetworkOptions} from "./options.js"; import {PeerAction, PeerScoreStats} from "./peers/index.js"; -import {INetworkEventBus, NetworkEvent, NetworkEventBus, NetworkEventData} from "./events.js"; -import {CommitteeSubscription} from "./subnets/index.js"; -import {isPublishToZeroPeersError} from "./util.js"; +import {AggregatorTracker} from "./processor/aggregatorTracker.js"; import {NetworkProcessor, PendingGossipsubMessage} from "./processor/index.js"; -import {INetworkCore, NetworkCore, WorkerNetworkCore} from "./core/index.js"; +import {ReqRespMethod} from "./reqresp/index.js"; +import {GetReqRespHandlerFn, Version, requestSszTypeByMethod, responseSszTypeByMethod} from "./reqresp/types.js"; import { collectExactOneTyped, collectMaxResponseTyped, collectMaxResponseTypedWithBytes, } from "./reqresp/utils/collect.js"; -import {GetReqRespHandlerFn, Version, requestSszTypeByMethod, responseSszTypeByMethod} from "./reqresp/types.js"; import {collectSequentialBlocksInRange} from "./reqresp/utils/collectSequentialBlocksInRange.js"; -import {getGossipSSZType, gossipTopicIgnoreDuplicatePublishError, stringifyGossipTopic} from "./gossip/topic.js"; -import {AggregatorTracker} from "./processor/aggregatorTracker.js"; -import {getActiveForks} from "./forks.js"; +import {CommitteeSubscription} from "./subnets/index.js"; +import {isPublishToZeroPeersError} from "./util.js"; type NetworkModules = { opts: NetworkOptions; diff --git a/packages/beacon-node/src/network/options.ts b/packages/beacon-node/src/network/options.ts index ebb321584d12..1420be1d58fb 100644 --- a/packages/beacon-node/src/network/options.ts +++ b/packages/beacon-node/src/network/options.ts @@ -1,7 +1,7 @@ import {Eth2GossipsubOpts} from "./gossip/gossipsub.js"; import {PeerManagerOpts, PeerRpcScoreOpts} from "./peers/index.js"; -import {ReqRespBeaconNodeOpts} from "./reqresp/ReqRespBeaconNode.js"; import {NetworkProcessorOpts} from "./processor/index.js"; +import {ReqRespBeaconNodeOpts} from "./reqresp/ReqRespBeaconNode.js"; import {SubnetsServiceOpts} from "./subnets/interface.js"; // Since Network is eventually intended to be run in a separate thread, ensure that all options are cloneable using structuredClone diff --git a/packages/beacon-node/src/network/peers/datastore.ts b/packages/beacon-node/src/network/peers/datastore.ts index 88a7a6f5f2d6..ba5cae92c9a9 100644 --- a/packages/beacon-node/src/network/peers/datastore.ts +++ b/packages/beacon-node/src/network/peers/datastore.ts @@ -1,6 +1,6 @@ import {BaseDatastore} from "datastore-core"; import {LevelDatastore} from "datastore-level"; -import {Key, KeyQuery, Query, Pair} from "interface-datastore"; +import {Key, KeyQuery, Pair, Query} from "interface-datastore"; type MemoryItem = { lastAccessedMs: number; diff --git a/packages/beacon-node/src/network/peers/discover.ts b/packages/beacon-node/src/network/peers/discover.ts index 2b03656064e4..e658fd6378bf 100644 --- a/packages/beacon-node/src/network/peers/discover.ts +++ b/packages/beacon-node/src/network/peers/discover.ts @@ -1,18 +1,18 @@ -import {Multiaddr} from "@multiformats/multiaddr"; -import type {PeerId, PeerInfo} from "@libp2p/interface"; import {ENR} from "@chainsafe/enr"; +import type {PeerId, PeerInfo} from "@libp2p/interface"; import {BeaconConfig} from "@lodestar/config"; -import {pruneSetToMax, sleep} from "@lodestar/utils"; -import {ATTESTATION_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; import {LoggerNode} from "@lodestar/logger/node"; +import {ATTESTATION_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; +import {pruneSetToMax, sleep} from "@lodestar/utils"; +import {Multiaddr} from "@multiformats/multiaddr"; import {NetworkCoreMetrics} from "../core/metrics.js"; +import {Discv5Worker} from "../discv5/index.js"; +import {LodestarDiscv5Opts} from "../discv5/types.js"; import {Libp2p} from "../interface.js"; import {ENRKey, SubnetType} from "../metadata.js"; import {getConnectionsMap, prettyPrintPeerId} from "../util.js"; -import {Discv5Worker} from "../discv5/index.js"; -import {LodestarDiscv5Opts} from "../discv5/types.js"; -import {deserializeEnrSubnets, zeroAttnets, zeroSyncnets} from "./utils/enrSubnetsDeserialize.js"; import {IPeerRpcScoreStore, ScoreState} from "./score/index.js"; +import {deserializeEnrSubnets, zeroAttnets, zeroSyncnets} from "./utils/enrSubnetsDeserialize.js"; /** Max number of cached ENRs after discovering a good peer */ const MAX_CACHED_ENRS = 100; diff --git a/packages/beacon-node/src/network/peers/peerManager.ts b/packages/beacon-node/src/network/peers/peerManager.ts index b8742789d4fb..b8787bcc73a7 100644 --- a/packages/beacon-node/src/network/peers/peerManager.ts +++ b/packages/beacon-node/src/network/peers/peerManager.ts @@ -1,33 +1,33 @@ -import {Connection, PeerId} from "@libp2p/interface"; import {BitArray} from "@chainsafe/ssz"; -import {SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; +import {Connection, PeerId} from "@libp2p/interface"; import {BeaconConfig} from "@lodestar/config"; +import {LoggerNode} from "@lodestar/logger/node"; +import {SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; import {Metadata, altair, phase0} from "@lodestar/types"; import {withTimeout} from "@lodestar/utils"; -import {LoggerNode} from "@lodestar/logger/node"; -import {GoodByeReasonCode, GOODBYE_KNOWN_CODES, Libp2pEvent} from "../../constants/index.js"; +import {GOODBYE_KNOWN_CODES, GoodByeReasonCode, Libp2pEvent} from "../../constants/index.js"; import {IClock} from "../../util/clock.js"; -import {NetworkEvent, INetworkEventBus, NetworkEventData} from "../events.js"; +import {NetworkCoreMetrics} from "../core/metrics.js"; +import {LodestarDiscv5Opts} from "../discv5/types.js"; +import {INetworkEventBus, NetworkEvent, NetworkEventData} from "../events.js"; +import {Eth2Gossipsub} from "../gossip/gossipsub.js"; import {Libp2p} from "../interface.js"; -import {ReqRespMethod} from "../reqresp/ReqRespBeaconNode.js"; -import {getConnection, getConnectionsMap, prettyPrintPeerId} from "../util.js"; -import {SubnetsService} from "../subnets/index.js"; import {SubnetType} from "../metadata.js"; -import {Eth2Gossipsub} from "../gossip/gossipsub.js"; +import {ReqRespMethod} from "../reqresp/ReqRespBeaconNode.js"; import {StatusCache} from "../statusCache.js"; -import {NetworkCoreMetrics} from "../core/metrics.js"; -import {LodestarDiscv5Opts} from "../discv5/types.js"; +import {SubnetsService} from "../subnets/index.js"; +import {getConnection, getConnectionsMap, prettyPrintPeerId} from "../util.js"; +import {ClientKind, getKnownClientFromAgentVersion} from "./client.js"; import {PeerDiscovery, SubnetDiscvQueryMs} from "./discover.js"; -import {PeersData, PeerData} from "./peersData.js"; -import {getKnownClientFromAgentVersion, ClientKind} from "./client.js"; +import {PeerData, PeersData} from "./peersData.js"; +import {IPeerRpcScoreStore, PeerAction, PeerScoreStats, ScoreState, updateGossipsubScores} from "./score/index.js"; import { + assertPeerRelevance, getConnectedPeerIds, hasSomeConnectedPeer, - assertPeerRelevance, prioritizePeers, renderIrrelevantPeerType, } from "./utils/index.js"; -import {IPeerRpcScoreStore, PeerAction, PeerScoreStats, ScoreState, updateGossipsubScores} from "./score/index.js"; /** heartbeat performs regular updates such as updating reputations and performing discovery requests */ const HEARTBEAT_INTERVAL_MS = 30 * 1000; diff --git a/packages/beacon-node/src/network/peers/peersData.ts b/packages/beacon-node/src/network/peers/peersData.ts index 4f96548c73e4..1a2619f202cd 100644 --- a/packages/beacon-node/src/network/peers/peersData.ts +++ b/packages/beacon-node/src/network/peers/peersData.ts @@ -1,6 +1,6 @@ import {PeerId} from "@libp2p/interface"; -import {altair} from "@lodestar/types"; import {Encoding} from "@lodestar/reqresp"; +import {altair} from "@lodestar/types"; import {ClientKind} from "./client.js"; type PeerIdStr = string; diff --git a/packages/beacon-node/src/network/peers/utils/enrSubnetsDeserialize.ts b/packages/beacon-node/src/network/peers/utils/enrSubnetsDeserialize.ts index 0a26cce9b215..a330a8dca3c8 100644 --- a/packages/beacon-node/src/network/peers/utils/enrSubnetsDeserialize.ts +++ b/packages/beacon-node/src/network/peers/utils/enrSubnetsDeserialize.ts @@ -1,6 +1,6 @@ import {getUint8ByteToBitBooleanArray} from "@chainsafe/ssz"; -import {newFilledArray} from "@lodestar/state-transition"; import {ATTESTATION_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; +import {newFilledArray} from "@lodestar/state-transition"; export const zeroAttnets = newFilledArray(ATTESTATION_SUBNET_COUNT, false); export const zeroSyncnets = newFilledArray(SYNC_COMMITTEE_SUBNET_COUNT, false); diff --git a/packages/beacon-node/src/network/peers/utils/prioritizePeers.ts b/packages/beacon-node/src/network/peers/utils/prioritizePeers.ts index b6fe4cb6bc77..545d8a6ca8b0 100644 --- a/packages/beacon-node/src/network/peers/utils/prioritizePeers.ts +++ b/packages/beacon-node/src/network/peers/utils/prioritizePeers.ts @@ -1,7 +1,7 @@ -import {Direction, PeerId} from "@libp2p/interface"; import {BitArray} from "@chainsafe/ssz"; -import {altair, phase0} from "@lodestar/types"; +import {Direction, PeerId} from "@libp2p/interface"; import {ATTESTATION_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; +import {altair, phase0} from "@lodestar/types"; import {MapDef} from "@lodestar/utils"; import {shuffle} from "../../../util/shuffle.js"; import {sortBy} from "../../../util/sortBy.js"; diff --git a/packages/beacon-node/src/network/processor/extractSlotRootFns.ts b/packages/beacon-node/src/network/processor/extractSlotRootFns.ts index d31cb3e2d7f9..57a4861b4cb8 100644 --- a/packages/beacon-node/src/network/processor/extractSlotRootFns.ts +++ b/packages/beacon-node/src/network/processor/extractSlotRootFns.ts @@ -3,8 +3,8 @@ import { getBlockRootFromAttestationSerialized, getBlockRootFromSignedAggregateAndProofSerialized, getSlotFromAttestationSerialized, - getSlotFromSignedAggregateAndProofSerialized, getSlotFromBlobSidecarSerialized, + getSlotFromSignedAggregateAndProofSerialized, getSlotFromSignedBeaconBlockSerialized, } from "../../util/sszBytes.js"; import {GossipType} from "../gossip/index.js"; diff --git a/packages/beacon-node/src/network/processor/gossipHandlers.ts b/packages/beacon-node/src/network/processor/gossipHandlers.ts index dab3af0df8ba..5bec263a45c8 100644 --- a/packages/beacon-node/src/network/processor/gossipHandlers.ts +++ b/packages/beacon-node/src/network/processor/gossipHandlers.ts @@ -1,59 +1,59 @@ +import {routes} from "@lodestar/api"; import {BeaconConfig, ChainForkConfig} from "@lodestar/config"; -import {LogLevel, Logger, prettyBytes, toRootHex} from "@lodestar/utils"; -import {Root, Slot, ssz, deneb, UintNum64, SignedBeaconBlock, sszTypesFor} from "@lodestar/types"; import {ForkName, ForkSeq} from "@lodestar/params"; -import {routes} from "@lodestar/api"; import {computeTimeAtSlot} from "@lodestar/state-transition"; -import {Metrics} from "../../metrics/index.js"; -import {OpSource} from "../../metrics/validatorMonitor.js"; +import {Root, SignedBeaconBlock, Slot, UintNum64, deneb, ssz, sszTypesFor} from "@lodestar/types"; +import {LogLevel, Logger, prettyBytes, toRootHex} from "@lodestar/utils"; +import { + BlobSidecarValidation, + BlockInput, + BlockInputType, + GossipedInputType, + NullBlockInput, +} from "../../chain/blocks/types.js"; import { AttestationError, AttestationErrorCode, + BlobSidecarErrorCode, + BlobSidecarGossipError, BlockError, BlockErrorCode, BlockGossipError, - BlobSidecarErrorCode, - BlobSidecarGossipError, GossipAction, GossipActionError, SyncCommitteeError, } from "../../chain/errors/index.js"; +import {IBeaconChain} from "../../chain/interface.js"; +import {validateGossipBlobSidecar} from "../../chain/validation/blobSidecar.js"; import { - BatchGossipHandlers, - SequentialGossipHandlers, - GossipHandlerParamGeneric, - GossipHandlers, - GossipType, -} from "../gossip/interface.js"; -import { + AggregateAndProofValidationResult, + GossipAttestation, validateGossipAggregateAndProof, + validateGossipAttestationsSameAttData, validateGossipAttesterSlashing, validateGossipBlock, + validateGossipBlsToExecutionChange, validateGossipProposerSlashing, validateGossipSyncCommittee, - validateSyncCommitteeGossipContributionAndProof, validateGossipVoluntaryExit, - validateGossipBlsToExecutionChange, - AggregateAndProofValidationResult, - validateGossipAttestationsSameAttData, - GossipAttestation, + validateSyncCommitteeGossipContributionAndProof, } from "../../chain/validation/index.js"; -import {NetworkEvent, NetworkEventBus} from "../events.js"; -import {PeerAction} from "../peers/index.js"; import {validateLightClientFinalityUpdate} from "../../chain/validation/lightClientFinalityUpdate.js"; import {validateLightClientOptimisticUpdate} from "../../chain/validation/lightClientOptimisticUpdate.js"; -import {validateGossipBlobSidecar} from "../../chain/validation/blobSidecar.js"; +import {Metrics} from "../../metrics/index.js"; +import {OpSource} from "../../metrics/validatorMonitor.js"; +import {INetworkCore} from "../core/index.js"; +import {NetworkEvent, NetworkEventBus} from "../events.js"; import { - BlockInput, - GossipedInputType, - BlobSidecarValidation, - BlockInputType, - NullBlockInput, -} from "../../chain/blocks/types.js"; + BatchGossipHandlers, + GossipHandlerParamGeneric, + GossipHandlers, + GossipType, + SequentialGossipHandlers, +} from "../gossip/interface.js"; import {sszDeserialize} from "../gossip/topic.js"; -import {INetworkCore} from "../core/index.js"; import {INetwork} from "../interface.js"; -import {IBeaconChain} from "../../chain/interface.js"; +import {PeerAction} from "../peers/index.js"; import {AggregatorTracker} from "./aggregatorTracker.js"; /** diff --git a/packages/beacon-node/src/network/processor/gossipQueues/index.ts b/packages/beacon-node/src/network/processor/gossipQueues/index.ts index dfa5b0dd1973..b76ebe2d875d 100644 --- a/packages/beacon-node/src/network/processor/gossipQueues/index.ts +++ b/packages/beacon-node/src/network/processor/gossipQueues/index.ts @@ -1,10 +1,10 @@ import {mapValues} from "@lodestar/utils"; +import {getGossipAttestationIndex} from "../../../util/sszBytes.js"; import {BatchGossipType, GossipType, SequentialGossipType} from "../../gossip/interface.js"; import {PendingGossipsubMessage} from "../types.js"; -import {getGossipAttestationIndex} from "../../../util/sszBytes.js"; +import {IndexedGossipQueueMinSize} from "./indexed.js"; import {LinearGossipQueue} from "./linear.js"; import {DropType, GossipQueue, GossipQueueOpts, QueueType, isIndexedGossipQueueMinSizeOpts} from "./types.js"; -import {IndexedGossipQueueMinSize} from "./indexed.js"; /** * In normal condition, the higher this value the more efficient the signature verification. diff --git a/packages/beacon-node/src/network/processor/gossipQueues/linear.ts b/packages/beacon-node/src/network/processor/gossipQueues/linear.ts index 57a29054d417..f8a06c0d4622 100644 --- a/packages/beacon-node/src/network/processor/gossipQueues/linear.ts +++ b/packages/beacon-node/src/network/processor/gossipQueues/linear.ts @@ -1,5 +1,5 @@ import {LinkedList} from "../../../util/array.js"; -import {LinearGossipQueueOpts, DropType, GossipQueue, QueueType} from "./types.js"; +import {DropType, GossipQueue, LinearGossipQueueOpts, QueueType} from "./types.js"; // Having a drop ratio of 1 will empty the queue which is too severe // Worse case drop 95% of the queue diff --git a/packages/beacon-node/src/network/processor/gossipValidatorFn.ts b/packages/beacon-node/src/network/processor/gossipValidatorFn.ts index e5b276e7c707..6fda29bf4ac4 100644 --- a/packages/beacon-node/src/network/processor/gossipValidatorFn.ts +++ b/packages/beacon-node/src/network/processor/gossipValidatorFn.ts @@ -1,16 +1,16 @@ import {TopicValidatorResult} from "@libp2p/interface"; import {ChainForkConfig} from "@lodestar/config"; import {Logger} from "@lodestar/utils"; +import {AttestationError, GossipAction, GossipActionError} from "../../chain/errors/index.js"; import {Metrics} from "../../metrics/index.js"; import { - GossipValidatorFn, - GossipHandlers, - GossipHandlerFn, - GossipValidatorBatchFn, BatchGossipHandlerFn, + GossipHandlerFn, + GossipHandlers, GossipMessageInfo, + GossipValidatorBatchFn, + GossipValidatorFn, } from "../gossip/interface.js"; -import {GossipActionError, GossipAction, AttestationError} from "../../chain/errors/index.js"; export type ValidatorFnModules = { config: ChainForkConfig; diff --git a/packages/beacon-node/src/network/processor/index.ts b/packages/beacon-node/src/network/processor/index.ts index ec0edf54644f..4bfc4263adc8 100644 --- a/packages/beacon-node/src/network/processor/index.ts +++ b/packages/beacon-node/src/network/processor/index.ts @@ -1,14 +1,15 @@ -import {Logger, MapDef, mapValues, sleep} from "@lodestar/utils"; -import {RootHex, Slot, SlotRootHex} from "@lodestar/types"; import {routes} from "@lodestar/api"; -import {pruneSetToMax} from "@lodestar/utils"; import {ForkSeq} from "@lodestar/params"; import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; -import {IBeaconChain} from "../../chain/interface.js"; +import {RootHex, Slot, SlotRootHex} from "@lodestar/types"; +import {Logger, MapDef, mapValues, sleep} from "@lodestar/utils"; +import {pruneSetToMax} from "@lodestar/utils"; import {GossipErrorCode} from "../../chain/errors/gossipValidation.js"; -import {Metrics} from "../../metrics/metrics.js"; +import {IBeaconChain} from "../../chain/interface.js"; import {IBeaconDb} from "../../db/interface.js"; +import {Metrics} from "../../metrics/metrics.js"; import {ClockEvent} from "../../util/clock.js"; +import {callInNextEventLoop} from "../../util/eventLoop.js"; import {NetworkEvent, NetworkEventBus} from "../events.js"; import { GossipHandlers, @@ -18,12 +19,11 @@ import { GossipValidatorFn, } from "../gossip/interface.js"; import {PeerIdStr} from "../peers/index.js"; -import {callInNextEventLoop} from "../../util/eventLoop.js"; -import {createGossipQueues} from "./gossipQueues/index.js"; -import {PendingGossipsubMessage} from "./types.js"; -import {ValidatorFnsModules, GossipHandlerOpts, getGossipHandlers} from "./gossipHandlers.js"; import {createExtractBlockSlotRootFns} from "./extractSlotRootFns.js"; +import {GossipHandlerOpts, ValidatorFnsModules, getGossipHandlers} from "./gossipHandlers.js"; +import {createGossipQueues} from "./gossipQueues/index.js"; import {ValidatorFnModules, getGossipValidatorBatchFn, getGossipValidatorFn} from "./gossipValidatorFn.js"; +import {PendingGossipsubMessage} from "./types.js"; export * from "./types.js"; diff --git a/packages/beacon-node/src/network/processor/types.ts b/packages/beacon-node/src/network/processor/types.ts index 386b9e8afc37..ec78116bc766 100644 --- a/packages/beacon-node/src/network/processor/types.ts +++ b/packages/beacon-node/src/network/processor/types.ts @@ -1,7 +1,7 @@ import {Message} from "@libp2p/interface"; import {Slot, SlotOptionalRoot} from "@lodestar/types"; -import {GossipTopic, GossipType} from "../gossip/index.js"; import {PeerIdStr} from "../../util/peerId.js"; +import {GossipTopic, GossipType} from "../gossip/index.js"; export type GossipAttestationsWork = { messages: PendingGossipsubMessage[]; diff --git a/packages/beacon-node/src/network/reqresp/ReqRespBeaconNode.ts b/packages/beacon-node/src/network/reqresp/ReqRespBeaconNode.ts index d34b379f4ccd..a2a2ebd657ab 100644 --- a/packages/beacon-node/src/network/reqresp/ReqRespBeaconNode.ts +++ b/packages/beacon-node/src/network/reqresp/ReqRespBeaconNode.ts @@ -1,5 +1,4 @@ import {PeerId} from "@libp2p/interface"; -import {Libp2p} from "libp2p"; import {BeaconConfig} from "@lodestar/config"; import {ForkName, ForkSeq} from "@lodestar/params"; import { @@ -15,13 +14,15 @@ import { } from "@lodestar/reqresp"; import {Metadata, phase0, ssz} from "@lodestar/types"; import {Logger} from "@lodestar/utils"; +import {Libp2p} from "libp2p"; +import {callInNextEventLoop} from "../../util/eventLoop.js"; +import {NetworkCoreMetrics} from "../core/metrics.js"; import {INetworkEventBus, NetworkEvent} from "../events.js"; import {MetadataController} from "../metadata.js"; import {PeersData} from "../peers/peersData.js"; import {IPeerRpcScoreStore, PeerAction} from "../peers/score/index.js"; -import {NetworkCoreMetrics} from "../core/metrics.js"; import {StatusCache} from "../statusCache.js"; -import {callInNextEventLoop} from "../../util/eventLoop.js"; +import * as protocols from "./protocols.js"; import {onOutgoingReqRespError} from "./score.js"; import { GetReqRespHandlerFn, @@ -32,7 +33,6 @@ import { requestSszTypeByMethod, responseSszTypeByMethod, } from "./types.js"; -import * as protocols from "./protocols.js"; import {collectExactOneTyped} from "./utils/collect.js"; export {getReqRespHandlers} from "./handlers/index.js"; diff --git a/packages/beacon-node/src/network/reqresp/beaconBlocksMaybeBlobsByRange.ts b/packages/beacon-node/src/network/reqresp/beaconBlocksMaybeBlobsByRange.ts index 3d71087c8fd8..21d781f11437 100644 --- a/packages/beacon-node/src/network/reqresp/beaconBlocksMaybeBlobsByRange.ts +++ b/packages/beacon-node/src/network/reqresp/beaconBlocksMaybeBlobsByRange.ts @@ -1,9 +1,9 @@ import {ChainForkConfig} from "@lodestar/config"; -import {deneb, Epoch, phase0, SignedBeaconBlock, Slot, WithBytes} from "@lodestar/types"; import {ForkSeq} from "@lodestar/params"; import {computeEpochAtSlot} from "@lodestar/state-transition"; +import {Epoch, SignedBeaconBlock, Slot, WithBytes, deneb, phase0} from "@lodestar/types"; -import {BlobsSource, BlockInput, BlockSource, getBlockInput, BlockInputDataBlobs} from "../../chain/blocks/types.js"; +import {BlobsSource, BlockInput, BlockInputDataBlobs, BlockSource, getBlockInput} from "../../chain/blocks/types.js"; import {PeerIdStr} from "../../util/peerId.js"; import {INetwork} from "../interface.js"; diff --git a/packages/beacon-node/src/network/reqresp/beaconBlocksMaybeBlobsByRoot.ts b/packages/beacon-node/src/network/reqresp/beaconBlocksMaybeBlobsByRoot.ts index 3d121156d8e6..a6919318999d 100644 --- a/packages/beacon-node/src/network/reqresp/beaconBlocksMaybeBlobsByRoot.ts +++ b/packages/beacon-node/src/network/reqresp/beaconBlocksMaybeBlobsByRoot.ts @@ -1,21 +1,21 @@ import {ChainForkConfig} from "@lodestar/config"; -import {phase0, deneb, SignedBeaconBlock} from "@lodestar/types"; import {ForkSeq} from "@lodestar/params"; +import {SignedBeaconBlock, deneb, phase0} from "@lodestar/types"; import {fromHex} from "@lodestar/utils"; import { + BlobsSource, BlockInput, + BlockInputDataBlobs, BlockInputType, BlockSource, - getBlockInputBlobs, - getBlockInput, NullBlockInput, - BlobsSource, - BlockInputDataBlobs, + getBlockInput, + getBlockInputBlobs, } from "../../chain/blocks/types.js"; -import {PeerIdStr} from "../../util/peerId.js"; -import {INetwork} from "../interface.js"; import {BlockInputAvailabilitySource} from "../../chain/seenCache/seenGossipBlockInput.js"; import {Metrics} from "../../metrics/index.js"; +import {PeerIdStr} from "../../util/peerId.js"; +import {INetwork} from "../interface.js"; import {matchBlockWithBlobs} from "./beaconBlocksMaybeBlobsByRange.js"; export async function beaconBlocksMaybeBlobsByRoot( diff --git a/packages/beacon-node/src/network/reqresp/handlers/beaconBlocksByRange.ts b/packages/beacon-node/src/network/reqresp/handlers/beaconBlocksByRange.ts index d1046db9651d..e8c19fb49628 100644 --- a/packages/beacon-node/src/network/reqresp/handlers/beaconBlocksByRange.ts +++ b/packages/beacon-node/src/network/reqresp/handlers/beaconBlocksByRange.ts @@ -1,5 +1,5 @@ import {GENESIS_SLOT, MAX_REQUEST_BLOCKS} from "@lodestar/params"; -import {ResponseError, ResponseOutgoing, RespStatus} from "@lodestar/reqresp"; +import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp"; import {deneb, phase0} from "@lodestar/types"; import {fromHex} from "@lodestar/utils"; import {IBeaconChain} from "../../../chain/index.js"; diff --git a/packages/beacon-node/src/network/reqresp/handlers/blobSidecarsByRange.ts b/packages/beacon-node/src/network/reqresp/handlers/blobSidecarsByRange.ts index e3655cd90c6f..9cac846fdb61 100644 --- a/packages/beacon-node/src/network/reqresp/handlers/blobSidecarsByRange.ts +++ b/packages/beacon-node/src/network/reqresp/handlers/blobSidecarsByRange.ts @@ -1,6 +1,6 @@ -import {GENESIS_SLOT, MAX_REQUEST_BLOCKS_DENEB, BLOBSIDECAR_FIXED_SIZE} from "@lodestar/params"; -import {ResponseError, ResponseOutgoing, RespStatus} from "@lodestar/reqresp"; -import {deneb, Slot} from "@lodestar/types"; +import {BLOBSIDECAR_FIXED_SIZE, GENESIS_SLOT, MAX_REQUEST_BLOCKS_DENEB} from "@lodestar/params"; +import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp"; +import {Slot, deneb} from "@lodestar/types"; import {fromHex} from "@lodestar/utils"; import {IBeaconChain} from "../../../chain/index.js"; import {IBeaconDb} from "../../../db/index.js"; diff --git a/packages/beacon-node/src/network/reqresp/handlers/blobSidecarsByRoot.ts b/packages/beacon-node/src/network/reqresp/handlers/blobSidecarsByRoot.ts index 144d470d7199..f44f9482eeb6 100644 --- a/packages/beacon-node/src/network/reqresp/handlers/blobSidecarsByRoot.ts +++ b/packages/beacon-node/src/network/reqresp/handlers/blobSidecarsByRoot.ts @@ -1,6 +1,6 @@ -import {ResponseError, ResponseOutgoing, RespStatus} from "@lodestar/reqresp"; import {BLOBSIDECAR_FIXED_SIZE} from "@lodestar/params"; -import {deneb, RootHex} from "@lodestar/types"; +import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp"; +import {RootHex, deneb} from "@lodestar/types"; import {fromHex, toRootHex} from "@lodestar/utils"; import {IBeaconChain} from "../../../chain/index.js"; import {IBeaconDb} from "../../../db/index.js"; diff --git a/packages/beacon-node/src/network/reqresp/handlers/index.ts b/packages/beacon-node/src/network/reqresp/handlers/index.ts index 50b8cc870844..a836cbc47769 100644 --- a/packages/beacon-node/src/network/reqresp/handlers/index.ts +++ b/packages/beacon-node/src/network/reqresp/handlers/index.ts @@ -1,12 +1,12 @@ -import {ssz} from "@lodestar/types"; import {ProtocolHandler} from "@lodestar/reqresp"; +import {ssz} from "@lodestar/types"; import {IBeaconChain} from "../../../chain/index.js"; import {IBeaconDb} from "../../../db/index.js"; import {GetReqRespHandlerFn, ReqRespMethod} from "../types.js"; import {onBeaconBlocksByRange} from "./beaconBlocksByRange.js"; import {onBeaconBlocksByRoot} from "./beaconBlocksByRoot.js"; -import {onBlobSidecarsByRoot} from "./blobSidecarsByRoot.js"; import {onBlobSidecarsByRange} from "./blobSidecarsByRange.js"; +import {onBlobSidecarsByRoot} from "./blobSidecarsByRoot.js"; import {onLightClientBootstrap} from "./lightClientBootstrap.js"; import {onLightClientFinalityUpdate} from "./lightClientFinalityUpdate.js"; import {onLightClientOptimisticUpdate} from "./lightClientOptimisticUpdate.js"; diff --git a/packages/beacon-node/src/network/reqresp/handlers/lightClientBootstrap.ts b/packages/beacon-node/src/network/reqresp/handlers/lightClientBootstrap.ts index 3b50304eb50c..ae5b5abf1f80 100644 --- a/packages/beacon-node/src/network/reqresp/handlers/lightClientBootstrap.ts +++ b/packages/beacon-node/src/network/reqresp/handlers/lightClientBootstrap.ts @@ -1,14 +1,14 @@ import { - RespStatus, - ResponseError, LightClientServerError, LightClientServerErrorCode, + RespStatus, + ResponseError, ResponseOutgoing, } from "@lodestar/reqresp"; import {Root} from "@lodestar/types"; import {IBeaconChain} from "../../../chain/index.js"; -import {ReqRespMethod, responseSszTypeByMethod} from "../types.js"; import {assertLightClientServer} from "../../../node/utils/lightclient.js"; +import {ReqRespMethod, responseSszTypeByMethod} from "../types.js"; export async function* onLightClientBootstrap(requestBody: Root, chain: IBeaconChain): AsyncIterable { assertLightClientServer(chain.lightClientServer); diff --git a/packages/beacon-node/src/network/reqresp/handlers/lightClientFinalityUpdate.ts b/packages/beacon-node/src/network/reqresp/handlers/lightClientFinalityUpdate.ts index 4764c6f198f7..26eec4585d79 100644 --- a/packages/beacon-node/src/network/reqresp/handlers/lightClientFinalityUpdate.ts +++ b/packages/beacon-node/src/network/reqresp/handlers/lightClientFinalityUpdate.ts @@ -1,7 +1,7 @@ -import {ResponseOutgoing, RespStatus, ResponseError} from "@lodestar/reqresp"; +import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp"; import {IBeaconChain} from "../../../chain/index.js"; -import {ReqRespMethod, responseSszTypeByMethod} from "../types.js"; import {assertLightClientServer} from "../../../node/utils/lightclient.js"; +import {ReqRespMethod, responseSszTypeByMethod} from "../types.js"; export async function* onLightClientFinalityUpdate(chain: IBeaconChain): AsyncIterable { assertLightClientServer(chain.lightClientServer); diff --git a/packages/beacon-node/src/network/reqresp/handlers/lightClientOptimisticUpdate.ts b/packages/beacon-node/src/network/reqresp/handlers/lightClientOptimisticUpdate.ts index 4c030a8e4174..e8cdb73ee05a 100644 --- a/packages/beacon-node/src/network/reqresp/handlers/lightClientOptimisticUpdate.ts +++ b/packages/beacon-node/src/network/reqresp/handlers/lightClientOptimisticUpdate.ts @@ -1,7 +1,7 @@ -import {ResponseOutgoing, ResponseError, RespStatus} from "@lodestar/reqresp"; +import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp"; import {IBeaconChain} from "../../../chain/index.js"; -import {ReqRespMethod, responseSszTypeByMethod} from "../types.js"; import {assertLightClientServer} from "../../../node/utils/lightclient.js"; +import {ReqRespMethod, responseSszTypeByMethod} from "../types.js"; export async function* onLightClientOptimisticUpdate(chain: IBeaconChain): AsyncIterable { assertLightClientServer(chain.lightClientServer); diff --git a/packages/beacon-node/src/network/reqresp/handlers/lightClientUpdatesByRange.ts b/packages/beacon-node/src/network/reqresp/handlers/lightClientUpdatesByRange.ts index 89466eca6c21..53b701d448cd 100644 --- a/packages/beacon-node/src/network/reqresp/handlers/lightClientUpdatesByRange.ts +++ b/packages/beacon-node/src/network/reqresp/handlers/lightClientUpdatesByRange.ts @@ -1,15 +1,15 @@ -import {altair} from "@lodestar/types"; import {MAX_REQUEST_LIGHT_CLIENT_UPDATES} from "@lodestar/params"; import { - ResponseOutgoing, LightClientServerError, LightClientServerErrorCode, - ResponseError, RespStatus, + ResponseError, + ResponseOutgoing, } from "@lodestar/reqresp"; +import {altair} from "@lodestar/types"; import {IBeaconChain} from "../../../chain/index.js"; -import {ReqRespMethod, responseSszTypeByMethod} from "../types.js"; import {assertLightClientServer} from "../../../node/utils/lightclient.js"; +import {ReqRespMethod, responseSszTypeByMethod} from "../types.js"; export async function* onLightClientUpdatesByRange( requestBody: altair.LightClientUpdatesByRange, diff --git a/packages/beacon-node/src/network/reqresp/handlers/status.ts b/packages/beacon-node/src/network/reqresp/handlers/status.ts index e46c1a268b06..22c342177334 100644 --- a/packages/beacon-node/src/network/reqresp/handlers/status.ts +++ b/packages/beacon-node/src/network/reqresp/handlers/status.ts @@ -1,6 +1,6 @@ +import {ForkName} from "@lodestar/params"; import {ResponseOutgoing} from "@lodestar/reqresp"; import {ssz} from "@lodestar/types"; -import {ForkName} from "@lodestar/params"; import {IBeaconChain} from "../../../chain/index.js"; export async function* onStatus(chain: IBeaconChain): AsyncIterable { diff --git a/packages/beacon-node/src/network/reqresp/protocols.ts b/packages/beacon-node/src/network/reqresp/protocols.ts index e63df4b1341b..b6b9c6c48967 100644 --- a/packages/beacon-node/src/network/reqresp/protocols.ts +++ b/packages/beacon-node/src/network/reqresp/protocols.ts @@ -1,7 +1,7 @@ -import {ContextBytesFactory, ContextBytesType, Encoding} from "@lodestar/reqresp"; import {ForkDigestContext} from "@lodestar/config"; -import {ProtocolNoHandler, ReqRespMethod, Version, requestSszTypeByMethod, responseSszTypeByMethod} from "./types.js"; +import {ContextBytesFactory, ContextBytesType, Encoding} from "@lodestar/reqresp"; import {rateLimitQuotas} from "./rateLimit.js"; +import {ProtocolNoHandler, ReqRespMethod, Version, requestSszTypeByMethod, responseSszTypeByMethod} from "./types.js"; export const Goodbye = toProtocol({ method: ReqRespMethod.Goodbye, diff --git a/packages/beacon-node/src/network/reqresp/rateLimit.ts b/packages/beacon-node/src/network/reqresp/rateLimit.ts index b6dacd6ba8e5..5830b48d2eab 100644 --- a/packages/beacon-node/src/network/reqresp/rateLimit.ts +++ b/packages/beacon-node/src/network/reqresp/rateLimit.ts @@ -1,8 +1,8 @@ import { - MAX_REQUEST_BLOCKS, - MAX_REQUEST_LIGHT_CLIENT_UPDATES, MAX_BLOBS_PER_BLOCK, MAX_REQUEST_BLOB_SIDECARS, + MAX_REQUEST_BLOCKS, + MAX_REQUEST_LIGHT_CLIENT_UPDATES, } from "@lodestar/params"; import {InboundRateLimitQuota} from "@lodestar/reqresp"; import {ReqRespMethod, RequestBodyByMethod} from "./types.js"; diff --git a/packages/beacon-node/src/network/reqresp/utils/collect.ts b/packages/beacon-node/src/network/reqresp/utils/collect.ts index 9818b1921f8e..f79ea2abba07 100644 --- a/packages/beacon-node/src/network/reqresp/utils/collect.ts +++ b/packages/beacon-node/src/network/reqresp/utils/collect.ts @@ -1,5 +1,5 @@ import {Type} from "@chainsafe/ssz"; -import {ResponseIncoming, RequestErrorCode, RequestError} from "@lodestar/reqresp"; +import {RequestError, RequestErrorCode, ResponseIncoming} from "@lodestar/reqresp"; import {WithBytes} from "@lodestar/types"; import {ResponseTypeGetter} from "../types.js"; diff --git a/packages/beacon-node/src/network/reqresp/utils/collectSequentialBlocksInRange.ts b/packages/beacon-node/src/network/reqresp/utils/collectSequentialBlocksInRange.ts index 2709cb3f64a9..2e2bcf772d76 100644 --- a/packages/beacon-node/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +++ b/packages/beacon-node/src/network/reqresp/utils/collectSequentialBlocksInRange.ts @@ -1,6 +1,6 @@ import {ResponseIncoming} from "@lodestar/reqresp"; +import {SignedBeaconBlock, WithBytes, phase0} from "@lodestar/types"; import {LodestarError} from "@lodestar/utils"; -import {phase0, SignedBeaconBlock, WithBytes} from "@lodestar/types"; import {ReqRespMethod, responseSszTypeByMethod} from "../types.js"; import {sszDeserializeResponse} from "./collect.js"; diff --git a/packages/beacon-node/src/network/subnets/attnetsService.ts b/packages/beacon-node/src/network/subnets/attnetsService.ts index 5044bac059cd..ed2f94bd56d8 100644 --- a/packages/beacon-node/src/network/subnets/attnetsService.ts +++ b/packages/beacon-node/src/network/subnets/attnetsService.ts @@ -1,3 +1,4 @@ +import {BeaconConfig} from "@lodestar/config"; import { ATTESTATION_SUBNET_COUNT, EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION, @@ -6,16 +7,15 @@ import { } from "@lodestar/params"; import {Epoch, Slot, ssz} from "@lodestar/types"; import {Logger, MapDef} from "@lodestar/utils"; -import {BeaconConfig} from "@lodestar/config"; import {ClockEvent, IClock} from "../../util/clock.js"; -import {GossipType} from "../gossip/index.js"; -import {MetadataController} from "../metadata.js"; -import {SubnetMap, RequestedSubnet} from "../peers/utils/index.js"; -import {getActiveForks} from "../forks.js"; import {NetworkCoreMetrics} from "../core/metrics.js"; -import {stringifyGossipTopic} from "../gossip/topic.js"; +import {getActiveForks} from "../forks.js"; +import {GossipType} from "../gossip/index.js"; import {GOSSIP_D_LOW} from "../gossip/scoringParameters.js"; -import {IAttnetsService, CommitteeSubscription, SubnetsServiceOpts, GossipSubscriber, NodeId} from "./interface.js"; +import {stringifyGossipTopic} from "../gossip/topic.js"; +import {MetadataController} from "../metadata.js"; +import {RequestedSubnet, SubnetMap} from "../peers/utils/index.js"; +import {CommitteeSubscription, GossipSubscriber, IAttnetsService, NodeId, SubnetsServiceOpts} from "./interface.js"; import {computeSubscribedSubnet} from "./util.js"; const gossipType = GossipType.beacon_attestation; diff --git a/packages/beacon-node/src/network/subnets/interface.ts b/packages/beacon-node/src/network/subnets/interface.ts index 1d036bf9831d..e3b1e2513818 100644 --- a/packages/beacon-node/src/network/subnets/interface.ts +++ b/packages/beacon-node/src/network/subnets/interface.ts @@ -1,7 +1,7 @@ import {ForkName} from "@lodestar/params"; import {Bytes32, Slot, ValidatorIndex} from "@lodestar/types"; -import {RequestedSubnet} from "../peers/utils/index.js"; import {GossipTopic} from "../gossip/interface.js"; +import {RequestedSubnet} from "../peers/utils/index.js"; /** Generic CommitteeSubscription for both beacon attnets subs and syncnets subs */ export type CommitteeSubscription = { diff --git a/packages/beacon-node/src/network/subnets/syncnetsService.ts b/packages/beacon-node/src/network/subnets/syncnetsService.ts index c61b1060899a..8dee6243b39f 100644 --- a/packages/beacon-node/src/network/subnets/syncnetsService.ts +++ b/packages/beacon-node/src/network/subnets/syncnetsService.ts @@ -1,14 +1,14 @@ -import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {BeaconConfig} from "@lodestar/config"; import {ForkName, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; +import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {Epoch, ssz} from "@lodestar/types"; import {Logger} from "@lodestar/utils"; import {ClockEvent, IClock} from "../../util/clock.js"; +import {NetworkCoreMetrics} from "../core/metrics.js"; import {getActiveForks} from "../forks.js"; import {GossipType} from "../gossip/index.js"; import {MetadataController} from "../metadata.js"; import {RequestedSubnet, SubnetMap} from "../peers/utils/index.js"; -import {NetworkCoreMetrics} from "../core/metrics.js"; import {CommitteeSubscription, GossipSubscriber, SubnetsService, SubnetsServiceOpts} from "./interface.js"; const gossipType = GossipType.sync_committee; diff --git a/packages/beacon-node/src/node/nodejs.ts b/packages/beacon-node/src/node/nodejs.ts index 701ab0fde070..ec3a0ef66a5a 100644 --- a/packages/beacon-node/src/node/nodejs.ts +++ b/packages/beacon-node/src/node/nodejs.ts @@ -2,28 +2,28 @@ import {setMaxListeners} from "node:events"; import {Registry} from "prom-client"; import {PeerId} from "@libp2p/interface"; +import {BeaconApiMethods} from "@lodestar/api/beacon/server"; import {BeaconConfig} from "@lodestar/config"; -import {phase0} from "@lodestar/types"; -import {sleep} from "@lodestar/utils"; import type {LoggerNode} from "@lodestar/logger/node"; -import {BeaconApiMethods} from "@lodestar/api/beacon/server"; import {BeaconStateAllForks} from "@lodestar/state-transition"; +import {phase0} from "@lodestar/types"; +import {sleep} from "@lodestar/utils"; import {ProcessShutdownCallback} from "@lodestar/validator"; +import {BeaconRestApiServer, getApi} from "../api/index.js"; +import {HistoricalStateRegen} from "../chain/historicalState/index.js"; +import {BeaconChain, IBeaconChain, initBeaconMetrics} from "../chain/index.js"; import {IBeaconDb} from "../db/index.js"; +import {initializeEth1ForBlockProduction} from "../eth1/index.js"; +import {initializeExecutionBuilder, initializeExecutionEngine} from "../execution/index.js"; +import {HttpMetricsServer, Metrics, createMetrics, getHttpMetricsServer} from "../metrics/index.js"; +import {MonitoringService} from "../monitoring/index.js"; import {Network, getReqRespHandlers} from "../network/index.js"; -import {BeaconSync, IBeaconSync} from "../sync/index.js"; import {BackfillSync} from "../sync/backfill/index.js"; -import {BeaconChain, IBeaconChain, initBeaconMetrics} from "../chain/index.js"; -import {createMetrics, Metrics, HttpMetricsServer, getHttpMetricsServer} from "../metrics/index.js"; -import {MonitoringService} from "../monitoring/index.js"; -import {getApi, BeaconRestApiServer} from "../api/index.js"; -import {initializeExecutionEngine, initializeExecutionBuilder} from "../execution/index.js"; -import {initializeEth1ForBlockProduction} from "../eth1/index.js"; -import {initCKZG, loadEthereumTrustedSetup, TrustedFileMode} from "../util/kzg.js"; -import {HistoricalStateRegen} from "../chain/historicalState/index.js"; -import {IBeaconNodeOptions} from "./options.js"; +import {BeaconSync, IBeaconSync} from "../sync/index.js"; +import {TrustedFileMode, initCKZG, loadEthereumTrustedSetup} from "../util/kzg.js"; import {runNodeNotifier} from "./notifier.js"; +import {IBeaconNodeOptions} from "./options.js"; export * from "./options.js"; diff --git a/packages/beacon-node/src/node/notifier.ts b/packages/beacon-node/src/node/notifier.ts index 20a359a45c49..c0d9354197ae 100644 --- a/packages/beacon-node/src/node/notifier.ts +++ b/packages/beacon-node/src/node/notifier.ts @@ -1,12 +1,12 @@ import {BeaconConfig} from "@lodestar/config"; -import {Epoch} from "@lodestar/types"; -import {CachedBeaconStateAllForks, computeStartSlotAtEpoch} from "@lodestar/state-transition"; -import {ProtoBlock, ExecutionStatus} from "@lodestar/fork-choice"; -import {ErrorAborted, Logger, sleep, prettyBytes, prettyBytesShort} from "@lodestar/utils"; +import {ExecutionStatus, ProtoBlock} from "@lodestar/fork-choice"; import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {CachedBeaconStateAllForks, computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {computeEpochAtSlot, isExecutionCachedStateType, isMergeTransitionComplete} from "@lodestar/state-transition"; -import {ExecutionEngineState} from "../execution/index.js"; +import {Epoch} from "@lodestar/types"; +import {ErrorAborted, Logger, prettyBytes, prettyBytesShort, sleep} from "@lodestar/utils"; import {IBeaconChain} from "../chain/index.js"; +import {ExecutionEngineState} from "../execution/index.js"; import {INetwork} from "../network/index.js"; import {IBeaconSync, SyncState} from "../sync/index.js"; import {prettyTimeDiffSec} from "../util/time.js"; diff --git a/packages/beacon-node/src/node/options.ts b/packages/beacon-node/src/node/options.ts index e587e58ec127..1a440bfd4981 100644 --- a/packages/beacon-node/src/node/options.ts +++ b/packages/beacon-node/src/node/options.ts @@ -1,19 +1,19 @@ -import {defaultApiOptions, ApiOptions} from "../api/options.js"; -import {defaultChainOptions, IChainOptions, StateArchiveMode, DEFAULT_STATE_ARCHIVE_MODE} from "../chain/options.js"; -import {defaultDbOptions, DatabaseOptions} from "../db/options.js"; -import {defaultEth1Options, Eth1Options} from "../eth1/options.js"; -import {defaultMetricsOptions, MetricsOptions} from "../metrics/options.js"; -import {defaultMonitoringOptions, MonitoringOptions} from "../monitoring/options.js"; -import {defaultNetworkOptions, NetworkOptions} from "../network/options.js"; -import {defaultSyncOptions, SyncOptions} from "../sync/options.js"; +import {ApiOptions, defaultApiOptions} from "../api/options.js"; +import {DEFAULT_STATE_ARCHIVE_MODE, IChainOptions, StateArchiveMode, defaultChainOptions} from "../chain/options.js"; +import {DatabaseOptions, defaultDbOptions} from "../db/options.js"; +import {Eth1Options, defaultEth1Options} from "../eth1/options.js"; import { - defaultExecutionEngineOpts, - defaultExecutionEngineHttpOpts, - ExecutionEngineOpts, ExecutionBuilderOpts, - defaultExecutionBuilderOpts, + ExecutionEngineOpts, defaultExecutionBuilderHttpOpts, + defaultExecutionBuilderOpts, + defaultExecutionEngineHttpOpts, + defaultExecutionEngineOpts, } from "../execution/index.js"; +import {MetricsOptions, defaultMetricsOptions} from "../metrics/options.js"; +import {MonitoringOptions, defaultMonitoringOptions} from "../monitoring/options.js"; +import {NetworkOptions, defaultNetworkOptions} from "../network/options.js"; +import {SyncOptions, defaultSyncOptions} from "../sync/options.js"; // Re-export so the CLI doesn't need to depend on lodestar-api export {allNamespaces} from "../api/rest/index.js"; diff --git a/packages/beacon-node/src/node/utils/interop/deposits.ts b/packages/beacon-node/src/node/utils/interop/deposits.ts index 6cce7e883b84..21f78a6ec2be 100644 --- a/packages/beacon-node/src/node/utils/interop/deposits.ts +++ b/packages/beacon-node/src/node/utils/interop/deposits.ts @@ -1,14 +1,14 @@ import {digest} from "@chainsafe/as-sha256"; -import {toGindex, Tree} from "@chainsafe/persistent-merkle-tree"; -import {phase0, ssz} from "@lodestar/types"; +import {Tree, toGindex} from "@chainsafe/persistent-merkle-tree"; import {ChainConfig} from "@lodestar/config"; -import {computeDomain, computeSigningRoot, interopSecretKeys, ZERO_HASH} from "@lodestar/state-transition"; import { BLS_WITHDRAWAL_PREFIX, - ETH1_ADDRESS_WITHDRAWAL_PREFIX, DOMAIN_DEPOSIT, + ETH1_ADDRESS_WITHDRAWAL_PREFIX, MAX_EFFECTIVE_BALANCE, } from "@lodestar/params"; +import {ZERO_HASH, computeDomain, computeSigningRoot, interopSecretKeys} from "@lodestar/state-transition"; +import {phase0, ssz} from "@lodestar/types"; import {DepositTree} from "../../../db/repositories/depositDataRoot.js"; /** diff --git a/packages/beacon-node/src/node/utils/interop/state.ts b/packages/beacon-node/src/node/utils/interop/state.ts index fe26afef2013..ef88fb956e05 100644 --- a/packages/beacon-node/src/node/utils/interop/state.ts +++ b/packages/beacon-node/src/node/utils/interop/state.ts @@ -1,8 +1,8 @@ -import {Bytes32, phase0, ssz, sszTypesFor, TimeSeconds} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; +import {ForkName, GENESIS_SLOT} from "@lodestar/params"; import {BeaconStateAllForks, initializeBeaconStateFromEth1} from "@lodestar/state-transition"; import {createEmptyEpochCacheImmutableData} from "@lodestar/state-transition"; -import {ForkName, GENESIS_SLOT} from "@lodestar/params"; +import {Bytes32, TimeSeconds, phase0, ssz, sszTypesFor} from "@lodestar/types"; import {DepositTree} from "../../../db/repositories/depositDataRoot.js"; diff --git a/packages/beacon-node/src/node/utils/state.ts b/packages/beacon-node/src/node/utils/state.ts index 05da7042eef4..ac0ff8101fb6 100644 --- a/packages/beacon-node/src/node/utils/state.ts +++ b/packages/beacon-node/src/node/utils/state.ts @@ -3,7 +3,7 @@ import {BeaconStateAllForks} from "@lodestar/state-transition"; import {phase0, ssz} from "@lodestar/types"; import {IBeaconDb} from "../../db/index.js"; import {interopDeposits} from "./interop/deposits.js"; -import {getInteropState, InteropStateOpts} from "./interop/state.js"; +import {InteropStateOpts, getInteropState} from "./interop/state.js"; /** * Builds state for `dev` command, for sim testing and some other tests diff --git a/packages/beacon-node/src/sync/backfill/backfill.ts b/packages/beacon-node/src/sync/backfill/backfill.ts index 9612cf23b615..4fedb9d1fd5b 100644 --- a/packages/beacon-node/src/sync/backfill/backfill.ts +++ b/packages/beacon-node/src/sync/backfill/backfill.ts @@ -1,22 +1,22 @@ import {EventEmitter} from "node:events"; -import {StrictEventEmitter} from "strict-event-emitter-types"; -import {BeaconStateAllForks, blockToHeader, computeAnchorCheckpoint} from "@lodestar/state-transition"; import {BeaconConfig, ChainForkConfig} from "@lodestar/config"; -import {phase0, Root, SignedBeaconBlock, Slot, ssz} from "@lodestar/types"; +import {BeaconStateAllForks, blockToHeader, computeAnchorCheckpoint} from "@lodestar/state-transition"; +import {Root, SignedBeaconBlock, Slot, phase0, ssz} from "@lodestar/types"; import {ErrorAborted, Logger, sleep, toRootHex} from "@lodestar/utils"; +import {StrictEventEmitter} from "strict-event-emitter-types"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {IBeaconChain} from "../../chain/index.js"; import {GENESIS_SLOT, ZERO_HASH} from "../../constants/index.js"; import {IBeaconDb} from "../../db/index.js"; +import {Metrics} from "../../metrics/metrics.js"; import {INetwork, NetworkEvent, NetworkEventData, PeerAction} from "../../network/index.js"; +import {byteArrayEquals} from "../../util/bytes.js"; import {ItTrigger} from "../../util/itTrigger.js"; import {PeerIdStr} from "../../util/peerId.js"; import {shuffleOne} from "../../util/shuffle.js"; -import {Metrics} from "../../metrics/metrics.js"; -import {byteArrayEquals} from "../../util/bytes.js"; -import {verifyBlockProposerSignature, verifyBlockSequence, BackfillBlockHeader, BackfillBlock} from "./verify.js"; import {BackfillSyncError, BackfillSyncErrorCode} from "./errors.js"; +import {BackfillBlock, BackfillBlockHeader, verifyBlockProposerSignature, verifyBlockSequence} from "./verify.js"; /** * Timeout in ms to take a break from reading a backfillBatchSize from db, as just yielding * to sync loop gives hardly any. diff --git a/packages/beacon-node/src/sync/backfill/errors.ts b/packages/beacon-node/src/sync/backfill/errors.ts index e62c90407ed5..530507f99f36 100644 --- a/packages/beacon-node/src/sync/backfill/errors.ts +++ b/packages/beacon-node/src/sync/backfill/errors.ts @@ -1,6 +1,6 @@ import {PeerId} from "@libp2p/interface"; -import {LodestarError} from "@lodestar/utils"; import {Root} from "@lodestar/types"; +import {LodestarError} from "@lodestar/utils"; export enum BackfillSyncErrorCode { /** fetched block doesn't connect to anchor block */ diff --git a/packages/beacon-node/src/sync/backfill/verify.ts b/packages/beacon-node/src/sync/backfill/verify.ts index 715cc6621253..9150e17b3e8c 100644 --- a/packages/beacon-node/src/sync/backfill/verify.ts +++ b/packages/beacon-node/src/sync/backfill/verify.ts @@ -1,7 +1,7 @@ -import {CachedBeaconStateAllForks, ISignatureSet, getBlockProposerSignatureSet} from "@lodestar/state-transition"; import {BeaconConfig} from "@lodestar/config"; -import {Root, ssz, Slot, SignedBeaconBlock, WithBytes} from "@lodestar/types"; import {GENESIS_SLOT} from "@lodestar/params"; +import {CachedBeaconStateAllForks, ISignatureSet, getBlockProposerSignatureSet} from "@lodestar/state-transition"; +import {Root, SignedBeaconBlock, Slot, WithBytes, ssz} from "@lodestar/types"; import {IBlsVerifier} from "../../chain/bls/index.js"; import {BackfillSyncError, BackfillSyncErrorCode} from "./errors.js"; diff --git a/packages/beacon-node/src/sync/interface.ts b/packages/beacon-node/src/sync/interface.ts index c1e83cb476fb..88d7138656f3 100644 --- a/packages/beacon-node/src/sync/interface.ts +++ b/packages/beacon-node/src/sync/interface.ts @@ -1,12 +1,12 @@ -import {Logger} from "@lodestar/utils"; -import {RootHex, Slot, phase0} from "@lodestar/types"; -import {BeaconConfig} from "@lodestar/config"; import {routes} from "@lodestar/api"; +import {BeaconConfig} from "@lodestar/config"; +import {RootHex, Slot, phase0} from "@lodestar/types"; +import {Logger} from "@lodestar/utils"; import {BlockInput, BlockInputType, NullBlockInput} from "../chain/blocks/types.js"; -import {INetwork} from "../network/index.js"; import {IBeaconChain} from "../chain/index.js"; -import {Metrics} from "../metrics/index.js"; import {IBeaconDb} from "../db/index.js"; +import {Metrics} from "../metrics/index.js"; +import {INetwork} from "../network/index.js"; import {SyncChainDebugState} from "./range/chain.js"; export type {SyncChainDebugState}; diff --git a/packages/beacon-node/src/sync/range/batch.ts b/packages/beacon-node/src/sync/range/batch.ts index e3e81bc57143..a78febbc5c7f 100644 --- a/packages/beacon-node/src/sync/range/batch.ts +++ b/packages/beacon-node/src/sync/range/batch.ts @@ -1,10 +1,10 @@ -import {Epoch, phase0, RootHex} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; +import {Epoch, RootHex, phase0} from "@lodestar/types"; import {LodestarError} from "@lodestar/utils"; -import {MAX_BATCH_DOWNLOAD_ATTEMPTS, MAX_BATCH_PROCESSING_ATTEMPTS} from "../constants.js"; -import {PeerIdStr} from "../../util/peerId.js"; import {BlockInput} from "../../chain/blocks/types.js"; import {BlockError, BlockErrorCode} from "../../chain/errors/index.js"; +import {PeerIdStr} from "../../util/peerId.js"; +import {MAX_BATCH_DOWNLOAD_ATTEMPTS, MAX_BATCH_PROCESSING_ATTEMPTS} from "../constants.js"; import {getBatchSlotRange, hashBlocks} from "./utils/index.js"; /** diff --git a/packages/beacon-node/src/sync/range/chain.ts b/packages/beacon-node/src/sync/range/chain.ts index 0a2fc1a3f7c3..2a8d76d99785 100644 --- a/packages/beacon-node/src/sync/range/chain.ts +++ b/packages/beacon-node/src/sync/range/chain.ts @@ -1,24 +1,24 @@ +import {ChainForkConfig} from "@lodestar/config"; import {Epoch, Root, Slot, phase0} from "@lodestar/types"; import {ErrorAborted, Logger, toRootHex} from "@lodestar/utils"; -import {ChainForkConfig} from "@lodestar/config"; import {BlockInput, BlockInputType} from "../../chain/blocks/types.js"; import {PeerAction} from "../../network/index.js"; import {ItTrigger} from "../../util/itTrigger.js"; import {PeerIdStr} from "../../util/peerId.js"; import {wrapError} from "../../util/wrapError.js"; -import {RangeSyncType} from "../utils/remoteSyncType.js"; import {BATCH_BUFFER_SIZE, EPOCHS_PER_BATCH} from "../constants.js"; +import {RangeSyncType} from "../utils/remoteSyncType.js"; import {Batch, BatchError, BatchErrorCode, BatchMetadata, BatchStatus} from "./batch.js"; import { - validateBatchesStatus, - getNextBatchToProcess, - toBeDownloadedStartEpoch, - toArr, ChainPeersBalancer, - computeMostCommonTarget, batchStartEpochIsAfterSlot, - isSyncChainDone, + computeMostCommonTarget, getBatchSlotRange, + getNextBatchToProcess, + isSyncChainDone, + toArr, + toBeDownloadedStartEpoch, + validateBatchesStatus, } from "./utils/index.js"; export type SyncChainModules = { diff --git a/packages/beacon-node/src/sync/range/range.ts b/packages/beacon-node/src/sync/range/range.ts index 51e3a5d0f182..8284abd09955 100644 --- a/packages/beacon-node/src/sync/range/range.ts +++ b/packages/beacon-node/src/sync/range/range.ts @@ -1,18 +1,18 @@ import {EventEmitter} from "node:events"; -import {StrictEventEmitter} from "strict-event-emitter-types"; -import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {BeaconConfig} from "@lodestar/config"; +import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {Epoch, phase0} from "@lodestar/types"; import {Logger, toRootHex} from "@lodestar/utils"; +import {StrictEventEmitter} from "strict-event-emitter-types"; +import {AttestationImportOpt, ImportBlockOpts} from "../../chain/blocks/index.js"; import {IBeaconChain} from "../../chain/index.js"; -import {INetwork} from "../../network/index.js"; import {Metrics} from "../../metrics/index.js"; -import {RangeSyncType, rangeSyncTypes, getRangeSyncTarget} from "../utils/remoteSyncType.js"; -import {PeerIdStr} from "../../util/peerId.js"; -import {ImportBlockOpts, AttestationImportOpt} from "../../chain/blocks/index.js"; +import {INetwork} from "../../network/index.js"; import {beaconBlocksMaybeBlobsByRange} from "../../network/reqresp/beaconBlocksMaybeBlobsByRange.js"; +import {PeerIdStr} from "../../util/peerId.js"; +import {RangeSyncType, getRangeSyncTarget, rangeSyncTypes} from "../utils/remoteSyncType.js"; +import {ChainTarget, SyncChain, SyncChainDebugState, SyncChainFns} from "./chain.js"; import {updateChains} from "./utils/index.js"; -import {ChainTarget, SyncChainFns, SyncChain, SyncChainDebugState} from "./chain.js"; export enum RangeSyncEvent { completedChain = "RangeSync-completedChain", diff --git a/packages/beacon-node/src/sync/range/utils/hashBlocks.ts b/packages/beacon-node/src/sync/range/utils/hashBlocks.ts index 986d023d9ca1..9d983fc7278e 100644 --- a/packages/beacon-node/src/sync/range/utils/hashBlocks.ts +++ b/packages/beacon-node/src/sync/range/utils/hashBlocks.ts @@ -1,5 +1,5 @@ -import {RootHex} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; +import {RootHex} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; import {BlockInput} from "../../../chain/blocks/types.js"; diff --git a/packages/beacon-node/src/sync/sync.ts b/packages/beacon-node/src/sync/sync.ts index 94eea73e1ef8..1a4121f4b9f1 100644 --- a/packages/beacon-node/src/sync/sync.ts +++ b/packages/beacon-node/src/sync/sync.ts @@ -1,20 +1,20 @@ -import {Logger} from "@lodestar/utils"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {Slot} from "@lodestar/types"; -import {INetwork, NetworkEvent, NetworkEventData} from "../network/index.js"; -import {isOptimisticBlock} from "../util/forkChoice.js"; -import {Metrics} from "../metrics/index.js"; +import {Logger} from "@lodestar/utils"; import {IBeaconChain} from "../chain/index.js"; -import {ClockEvent} from "../util/clock.js"; import {GENESIS_SLOT} from "../constants/constants.js"; import {ExecutionEngineState} from "../execution/index.js"; -import {IBeaconSync, SyncModules, SyncingStatus} from "./interface.js"; -import {RangeSync, RangeSyncStatus, RangeSyncEvent} from "./range/range.js"; -import {getPeerSyncType, PeerSyncType, peerSyncTypes} from "./utils/remoteSyncType.js"; +import {Metrics} from "../metrics/index.js"; +import {INetwork, NetworkEvent, NetworkEventData} from "../network/index.js"; +import {ClockEvent} from "../util/clock.js"; +import {isOptimisticBlock} from "../util/forkChoice.js"; import {MIN_EPOCH_TO_START_GOSSIP} from "./constants.js"; -import {SyncState, SyncChainDebugState, syncStateMetric} from "./interface.js"; +import {IBeaconSync, SyncModules, SyncingStatus} from "./interface.js"; +import {SyncChainDebugState, SyncState, syncStateMetric} from "./interface.js"; import {SyncOptions} from "./options.js"; +import {RangeSync, RangeSyncEvent, RangeSyncStatus} from "./range/range.js"; import {UnknownBlockSync} from "./unknownBlock.js"; +import {PeerSyncType, getPeerSyncType, peerSyncTypes} from "./utils/remoteSyncType.js"; export class BeaconSync implements IBeaconSync { private readonly logger: Logger; diff --git a/packages/beacon-node/src/sync/unknownBlock.ts b/packages/beacon-node/src/sync/unknownBlock.ts index 003b035a898d..c9652dc6ecd2 100644 --- a/packages/beacon-node/src/sync/unknownBlock.ts +++ b/packages/beacon-node/src/sync/unknownBlock.ts @@ -1,24 +1,24 @@ import {ChainForkConfig} from "@lodestar/config"; -import {Logger, fromHex, pruneSetToMax, toRootHex} from "@lodestar/utils"; -import {Root, RootHex, deneb} from "@lodestar/types"; import {INTERVALS_PER_SLOT} from "@lodestar/params"; +import {Root, RootHex, deneb} from "@lodestar/types"; +import {Logger, fromHex, pruneSetToMax, toRootHex} from "@lodestar/utils"; import {sleep} from "@lodestar/utils"; -import {INetwork, NetworkEvent, NetworkEventData, PeerAction} from "../network/index.js"; -import {PeerIdStr} from "../util/peerId.js"; -import {IBeaconChain} from "../chain/index.js"; import {BlockInput, BlockInputType, NullBlockInput} from "../chain/blocks/types.js"; -import {Metrics} from "../metrics/index.js"; -import {shuffle} from "../util/shuffle.js"; -import {byteArrayEquals} from "../util/bytes.js"; import {BlockError, BlockErrorCode} from "../chain/errors/index.js"; +import {IBeaconChain} from "../chain/index.js"; +import {Metrics} from "../metrics/index.js"; +import {INetwork, NetworkEvent, NetworkEventData, PeerAction} from "../network/index.js"; import { beaconBlocksMaybeBlobsByRoot, unavailableBeaconBlobsByRoot, } from "../network/reqresp/beaconBlocksMaybeBlobsByRoot.js"; +import {byteArrayEquals} from "../util/bytes.js"; +import {PeerIdStr} from "../util/peerId.js"; +import {shuffle} from "../util/shuffle.js"; import {Result, wrapError} from "../util/wrapError.js"; import {PendingBlock, PendingBlockStatus, PendingBlockType} from "./interface.js"; -import {getDescendantBlocks, getAllDescendantBlocks, getUnknownAndAncestorBlocks} from "./utils/pendingBlocksTree.js"; import {SyncOptions} from "./options.js"; +import {getAllDescendantBlocks, getDescendantBlocks, getUnknownAndAncestorBlocks} from "./utils/pendingBlocksTree.js"; const MAX_ATTEMPTS_PER_BLOCK = 5; const MAX_KNOWN_BAD_BLOCKS = 500; diff --git a/packages/beacon-node/src/sync/utils/pendingBlocksTree.ts b/packages/beacon-node/src/sync/utils/pendingBlocksTree.ts index 0feb15862408..deefba91f366 100644 --- a/packages/beacon-node/src/sync/utils/pendingBlocksTree.ts +++ b/packages/beacon-node/src/sync/utils/pendingBlocksTree.ts @@ -1,5 +1,6 @@ import {RootHex} from "@lodestar/types"; import {MapDef} from "@lodestar/utils"; +import {BlockInputType} from "../../chain/blocks/types.js"; import { DownloadedBlock, PendingBlock, @@ -7,7 +8,6 @@ import { UnknownAndAncestorBlocks, UnknownBlock, } from "../interface.js"; -import {BlockInputType} from "../../chain/blocks/types.js"; export function getAllDescendantBlocks(blockRootHex: RootHex, blocks: Map): PendingBlock[] { // Do one pass over all blocks to index by parent diff --git a/packages/beacon-node/src/sync/utils/remoteSyncType.ts b/packages/beacon-node/src/sync/utils/remoteSyncType.ts index 247269ab409a..16f1481a2a83 100644 --- a/packages/beacon-node/src/sync/utils/remoteSyncType.ts +++ b/packages/beacon-node/src/sync/utils/remoteSyncType.ts @@ -1,6 +1,6 @@ import {IForkChoice} from "@lodestar/fork-choice"; import {computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition"; -import {phase0, Slot} from "@lodestar/types"; +import {Slot, phase0} from "@lodestar/types"; import {ChainTarget} from "../range/utils/index.js"; /** The type of peer relative to our current state */ diff --git a/packages/beacon-node/src/util/blobs.ts b/packages/beacon-node/src/util/blobs.ts index fcc31092464f..56f1ab21aae9 100644 --- a/packages/beacon-node/src/util/blobs.ts +++ b/packages/beacon-node/src/util/blobs.ts @@ -1,9 +1,9 @@ import {digest as sha256Digest} from "@chainsafe/as-sha256"; import {Tree} from "@chainsafe/persistent-merkle-tree"; -import {VERSIONED_HASH_VERSION_KZG, KZG_COMMITMENT_GINDEX0, ForkName, ForkAll} from "@lodestar/params"; -import {deneb, ssz, BeaconBlockBody, SignedBeaconBlock, SSZTypesFor} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; +import {ForkAll, ForkName, KZG_COMMITMENT_GINDEX0, VERSIONED_HASH_VERSION_KZG} from "@lodestar/params"; import {signedBlockToSignedHeader} from "@lodestar/state-transition"; +import {BeaconBlockBody, SSZTypesFor, SignedBeaconBlock, deneb, ssz} from "@lodestar/types"; type VersionHash = Uint8Array; diff --git a/packages/beacon-node/src/util/clock.ts b/packages/beacon-node/src/util/clock.ts index 197d17f38281..36eb6f6f7f2c 100644 --- a/packages/beacon-node/src/util/clock.ts +++ b/packages/beacon-node/src/util/clock.ts @@ -1,9 +1,9 @@ import EventEmitter from "node:events"; -import type {StrictEventEmitter} from "strict-event-emitter-types"; -import type {Epoch, Slot} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; -import {ErrorAborted} from "@lodestar/utils"; import {computeEpochAtSlot, computeTimeAtSlot, getCurrentSlot} from "@lodestar/state-transition"; +import type {Epoch, Slot} from "@lodestar/types"; +import {ErrorAborted} from "@lodestar/utils"; +import type {StrictEventEmitter} from "strict-event-emitter-types"; import {MAXIMUM_GOSSIP_CLOCK_DISPARITY} from "../constants/constants.js"; export enum ClockEvent { diff --git a/packages/beacon-node/src/util/kzg.ts b/packages/beacon-node/src/util/kzg.ts index 42224d1ebaa6..36a7d19f8d2b 100644 --- a/packages/beacon-node/src/util/kzg.ts +++ b/packages/beacon-node/src/util/kzg.ts @@ -1,5 +1,5 @@ -import path from "node:path"; import fs from "node:fs"; +import path from "node:path"; import {fileURLToPath} from "node:url"; import {fromHex, toHex} from "@lodestar/utils"; diff --git a/packages/beacon-node/src/util/multifork.ts b/packages/beacon-node/src/util/multifork.ts index 0a00677afadf..952498c5a4d1 100644 --- a/packages/beacon-node/src/util/multifork.ts +++ b/packages/beacon-node/src/util/multifork.ts @@ -1,7 +1,7 @@ import {ChainForkConfig} from "@lodestar/config"; +import {ForkAll, ForkLightClient} from "@lodestar/params"; import {SSZTypesFor, Slot} from "@lodestar/types"; import {bytesToInt} from "@lodestar/utils"; -import {ForkAll, ForkLightClient} from "@lodestar/params"; import {getSlotFromSignedBeaconBlockSerialized} from "./sszBytes.js"; /** diff --git a/packages/beacon-node/src/util/peerId.ts b/packages/beacon-node/src/util/peerId.ts index 2afb9bed390e..6fee7db855da 100644 --- a/packages/beacon-node/src/util/peerId.ts +++ b/packages/beacon-node/src/util/peerId.ts @@ -1,6 +1,6 @@ import {PeerId} from "@libp2p/interface"; -import {base58btc} from "multiformats/bases/base58"; import {peerIdFromString} from "@libp2p/peer-id"; +import {base58btc} from "multiformats/bases/base58"; // Ensure consistent serialization of PeerId to string diff --git a/packages/beacon-node/src/util/queue/fnQueue.ts b/packages/beacon-node/src/util/queue/fnQueue.ts index 80e179f8e8f3..1e4f68b7b9b6 100644 --- a/packages/beacon-node/src/util/queue/fnQueue.ts +++ b/packages/beacon-node/src/util/queue/fnQueue.ts @@ -1,5 +1,5 @@ import {JobItemQueue} from "./itemQueue.js"; -import {QueueMetrics, JobQueueOpts} from "./options.js"; +import {JobQueueOpts, QueueMetrics} from "./options.js"; // biome-ignore lint/suspicious/noExplicitAny: type Fn = (...args: any) => Promise; diff --git a/packages/beacon-node/src/util/queue/itemQueue.ts b/packages/beacon-node/src/util/queue/itemQueue.ts index f380a15f5eaf..8713340ec9a4 100644 --- a/packages/beacon-node/src/util/queue/itemQueue.ts +++ b/packages/beacon-node/src/util/queue/itemQueue.ts @@ -1,7 +1,7 @@ -import {LinkedList} from "../array.js"; import {callInNextEventLoop, nextEventLoop} from "../../util/eventLoop.js"; +import {LinkedList} from "../array.js"; import {QueueError, QueueErrorCode} from "./errors.js"; -import {defaultQueueOpts, QueueMetrics, JobQueueOpts, QueueType} from "./options.js"; +import {JobQueueOpts, QueueMetrics, QueueType, defaultQueueOpts} from "./options.js"; /** * JobQueue that stores arguments in the job array instead of closures. diff --git a/packages/beacon-node/src/util/sszBytes.ts b/packages/beacon-node/src/util/sszBytes.ts index c27df1a0fbf3..cb80d5d1bb4b 100644 --- a/packages/beacon-node/src/util/sszBytes.ts +++ b/packages/beacon-node/src/util/sszBytes.ts @@ -1,5 +1,4 @@ import {BitArray, deserializeUint8ArrayBitListFromBytes} from "@chainsafe/ssz"; -import {BLSSignature, RootHex, Slot} from "@lodestar/types"; import { BYTES_PER_FIELD_ELEMENT, FIELD_ELEMENTS_PER_BLOB, @@ -7,6 +6,7 @@ import { ForkSeq, MAX_COMMITTEES_PER_SLOT, } from "@lodestar/params"; +import {BLSSignature, RootHex, Slot} from "@lodestar/types"; export type BlockRootHex = RootHex; // pre-electra, AttestationData is used to cache attestations diff --git a/packages/beacon-node/test/e2e/api/impl/beacon/block/endpoint.test.ts b/packages/beacon-node/test/e2e/api/impl/beacon/block/endpoint.test.ts index b8939b54c294..16a3dd0c80b0 100644 --- a/packages/beacon-node/test/e2e/api/impl/beacon/block/endpoint.test.ts +++ b/packages/beacon-node/test/e2e/api/impl/beacon/block/endpoint.test.ts @@ -1,6 +1,6 @@ -import {describe, beforeAll, afterAll, it, expect, vi} from "vitest"; -import {createBeaconConfig} from "@lodestar/config"; import {ApiClient, WireFormat, getClient} from "@lodestar/api"; +import {createBeaconConfig} from "@lodestar/config"; +import {ForkName} from "@lodestar/params"; import { SignedBeaconBlock, SignedBlindedBeaconBlock, @@ -8,11 +8,11 @@ import { isExecutionPayload, isExecutionPayloadHeader, } from "@lodestar/types"; -import {ForkName} from "@lodestar/params"; -import {LogLevel, testLogger} from "../../../../../utils/logger.js"; -import {getDevBeaconNode} from "../../../../../utils/node/beacon.js"; +import {afterAll, beforeAll, describe, expect, it, vi} from "vitest"; import {BeaconNode} from "../../../../../../src/node/nodejs.js"; import {getConfig} from "../../../../../utils/config.js"; +import {LogLevel, testLogger} from "../../../../../utils/logger.js"; +import {getDevBeaconNode} from "../../../../../utils/node/beacon.js"; describe("beacon block api", () => { vi.setConfig({testTimeout: 60_000, hookTimeout: 60_000}); diff --git a/packages/beacon-node/test/e2e/api/impl/beacon/node/endpoints.test.ts b/packages/beacon-node/test/e2e/api/impl/beacon/node/endpoints.test.ts index 6dc01870a844..18747fd2f735 100644 --- a/packages/beacon-node/test/e2e/api/impl/beacon/node/endpoints.test.ts +++ b/packages/beacon-node/test/e2e/api/impl/beacon/node/endpoints.test.ts @@ -1,12 +1,12 @@ -import {describe, beforeAll, afterAll, it, expect, vi} from "vitest"; -import {createBeaconConfig} from "@lodestar/config"; -import {chainConfig as chainConfigDef} from "@lodestar/config/default"; import {routes} from "@lodestar/api"; import {ApiClient, getClient} from "@lodestar/api/beacon"; +import {createBeaconConfig} from "@lodestar/config"; +import {chainConfig as chainConfigDef} from "@lodestar/config/default"; import {sleep} from "@lodestar/utils"; +import {afterAll, beforeAll, describe, expect, it, vi} from "vitest"; +import {BeaconNode} from "../../../../../../src/node/nodejs.js"; import {LogLevel, testLogger} from "../../../../../utils/logger.js"; import {getDevBeaconNode} from "../../../../../utils/node/beacon.js"; -import {BeaconNode} from "../../../../../../src/node/nodejs.js"; import {getAndInitDevValidators} from "../../../../../utils/node/validator.js"; describe("beacon node api", () => { diff --git a/packages/beacon-node/test/e2e/api/impl/beacon/state/endpoint.test.ts b/packages/beacon-node/test/e2e/api/impl/beacon/state/endpoint.test.ts index d8c87a3ba6b8..1b2c6b902f20 100644 --- a/packages/beacon-node/test/e2e/api/impl/beacon/state/endpoint.test.ts +++ b/packages/beacon-node/test/e2e/api/impl/beacon/state/endpoint.test.ts @@ -1,12 +1,12 @@ -import {describe, beforeAll, afterAll, it, expect} from "vitest"; -import {SLOTS_PER_EPOCH} from "@lodestar/params"; +import {ApiClient, getClient} from "@lodestar/api"; import {createBeaconConfig} from "@lodestar/config"; import {chainConfig as chainConfigDef} from "@lodestar/config/default"; -import {ApiClient, getClient} from "@lodestar/api"; +import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {computeCommitteeCount} from "@lodestar/state-transition"; +import {afterAll, beforeAll, describe, expect, it} from "vitest"; +import {BeaconNode} from "../../../../../../src/node/nodejs.js"; import {LogLevel, testLogger} from "../../../../../utils/logger.js"; import {getDevBeaconNode} from "../../../../../utils/node/beacon.js"; -import {BeaconNode} from "../../../../../../src/node/nodejs.js"; describe("beacon state api", () => { const restPort = 9596; diff --git a/packages/beacon-node/test/e2e/api/impl/config.test.ts b/packages/beacon-node/test/e2e/api/impl/config.test.ts index 3ffdbc4beb21..a878d41a36f0 100644 --- a/packages/beacon-node/test/e2e/api/impl/config.test.ts +++ b/packages/beacon-node/test/e2e/api/impl/config.test.ts @@ -1,9 +1,9 @@ -import {describe, it} from "vitest"; import {fetch} from "@lodestar/api"; -import {ForkName, activePreset} from "@lodestar/params"; import {chainConfig} from "@lodestar/config/default"; -import {ethereumConsensusSpecsTests} from "../../../spec/specTestVersioning.js"; +import {ForkName, activePreset} from "@lodestar/params"; +import {describe, it} from "vitest"; import {specConstants} from "../../../../src/api/impl/config/constants.js"; +import {ethereumConsensusSpecsTests} from "../../../spec/specTestVersioning.js"; const CONSTANT_NAMES_SKIP_LIST = new Set([ // This constant is an array, so it's skipped due to not being just a string. diff --git a/packages/beacon-node/test/e2e/api/impl/lightclient/endpoint.test.ts b/packages/beacon-node/test/e2e/api/impl/lightclient/endpoint.test.ts index effbed19fc2c..a836024aab01 100644 --- a/packages/beacon-node/test/e2e/api/impl/lightclient/endpoint.test.ts +++ b/packages/beacon-node/test/e2e/api/impl/lightclient/endpoint.test.ts @@ -1,17 +1,17 @@ -import {describe, it, beforeEach, afterEach, expect} from "vitest"; import {aggregateSerializedPublicKeys} from "@chainsafe/blst"; -import {createBeaconConfig, ChainConfig} from "@lodestar/config"; +import {HttpHeader, getClient, routes} from "@lodestar/api"; +import {ChainConfig, createBeaconConfig} from "@lodestar/config"; import {chainConfig as chainConfigDef} from "@lodestar/config/default"; -import {getClient, HttpHeader, routes} from "@lodestar/api"; -import {sleep} from "@lodestar/utils"; import {ForkName, SYNC_COMMITTEE_SIZE} from "@lodestar/params"; -import {Validator} from "@lodestar/validator"; import {phase0, ssz} from "@lodestar/types"; -import {LogLevel, testLogger, TestLoggerOpts} from "../../../../utils/logger.js"; -import {getDevBeaconNode} from "../../../../utils/node/beacon.js"; -import {getAndInitDevValidators} from "../../../../utils/node/validator.js"; +import {sleep} from "@lodestar/utils"; +import {Validator} from "@lodestar/validator"; +import {afterEach, beforeEach, describe, expect, it} from "vitest"; import {BeaconNode} from "../../../../../src/node/nodejs.js"; import {waitForEvent} from "../../../../utils/events/resolver.js"; +import {LogLevel, TestLoggerOpts, testLogger} from "../../../../utils/logger.js"; +import {getDevBeaconNode} from "../../../../utils/node/beacon.js"; +import {getAndInitDevValidators} from "../../../../utils/node/validator.js"; describe("lightclient api", () => { const SECONDS_PER_SLOT = 1; diff --git a/packages/beacon-node/test/e2e/api/lodestar/lodestar.test.ts b/packages/beacon-node/test/e2e/api/lodestar/lodestar.test.ts index bc847b47e9a9..7501460779f3 100644 --- a/packages/beacon-node/test/e2e/api/lodestar/lodestar.test.ts +++ b/packages/beacon-node/test/e2e/api/lodestar/lodestar.test.ts @@ -1,14 +1,14 @@ -import {describe, it, afterEach, expect, vi} from "vitest"; -import {createBeaconConfig, ChainConfig} from "@lodestar/config"; +import {getClient} from "@lodestar/api"; +import {ChainConfig, createBeaconConfig} from "@lodestar/config"; import {chainConfig as chainConfigDef} from "@lodestar/config/default"; -import {phase0} from "@lodestar/types"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; -import {getClient} from "@lodestar/api"; -import {LogLevel, testLogger, TestLoggerOpts} from "../../../utils/logger.js"; -import {getDevBeaconNode} from "../../../utils/node/beacon.js"; -import {waitForEvent} from "../../../utils/events/resolver.js"; -import {ClockEvent} from "../../../../src/util/clock.js"; +import {phase0} from "@lodestar/types"; +import {afterEach, describe, expect, it, vi} from "vitest"; import {BeaconNode} from "../../../../src/index.js"; +import {ClockEvent} from "../../../../src/util/clock.js"; +import {waitForEvent} from "../../../utils/events/resolver.js"; +import {LogLevel, TestLoggerOpts, testLogger} from "../../../utils/logger.js"; +import {getDevBeaconNode} from "../../../utils/node/beacon.js"; describe("api / impl / validator", () => { vi.setConfig({testTimeout: 60_000}); diff --git a/packages/beacon-node/test/e2e/chain/bls/multithread.test.ts b/packages/beacon-node/test/e2e/chain/bls/multithread.test.ts index a544b3231e87..f8c3a47fb824 100644 --- a/packages/beacon-node/test/e2e/chain/bls/multithread.test.ts +++ b/packages/beacon-node/test/e2e/chain/bls/multithread.test.ts @@ -1,9 +1,9 @@ -import {describe, it, beforeAll, expect, beforeEach, afterEach} from "vitest"; import {PublicKey, SecretKey} from "@chainsafe/blst"; import {ISignatureSet, SignatureSetType} from "@lodestar/state-transition"; +import {afterEach, beforeAll, beforeEach, describe, expect, it} from "vitest"; +import {VerifySignatureOpts} from "../../../../src/chain/bls/interface.js"; import {BlsMultiThreadWorkerPool} from "../../../../src/chain/bls/multithread/index.js"; import {testLogger} from "../../../utils/logger.js"; -import {VerifySignatureOpts} from "../../../../src/chain/bls/interface.js"; describe("chain / bls / multithread queue", () => { const logger = testLogger(); diff --git a/packages/beacon-node/test/e2e/chain/lightclient.test.ts b/packages/beacon-node/test/e2e/chain/lightclient.test.ts index ed698f2844a1..2fc983b8d488 100644 --- a/packages/beacon-node/test/e2e/chain/lightclient.test.ts +++ b/packages/beacon-node/test/e2e/chain/lightclient.test.ts @@ -1,18 +1,18 @@ -import {describe, it, expect, afterEach, vi} from "vitest"; -import {JsonPath, toHexString, fromHexString} from "@chainsafe/ssz"; import {CompactMultiProof, computeDescriptor} from "@chainsafe/persistent-merkle-tree"; +import {JsonPath, fromHexString, toHexString} from "@chainsafe/ssz"; +import {ApiClient, getClient, routes} from "@lodestar/api"; import {ChainConfig} from "@lodestar/config"; -import {ssz, altair} from "@lodestar/types"; +import {Lightclient} from "@lodestar/light-client"; +import {LightClientRestTransport} from "@lodestar/light-client/transport"; import {TimestampFormatCode} from "@lodestar/logger"; import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH} from "@lodestar/params"; -import {Lightclient} from "@lodestar/light-client"; import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; -import {LightClientRestTransport} from "@lodestar/light-client/transport"; -import {ApiClient, getClient, routes} from "@lodestar/api"; -import {testLogger, LogLevel, TestLoggerOpts} from "../../utils/logger.js"; +import {altair, ssz} from "@lodestar/types"; +import {afterEach, describe, expect, it, vi} from "vitest"; +import {HeadEventData} from "../../../src/chain/index.js"; +import {LogLevel, TestLoggerOpts, testLogger} from "../../utils/logger.js"; import {getDevBeaconNode} from "../../utils/node/beacon.js"; import {getAndInitDevValidators} from "../../utils/node/validator.js"; -import {HeadEventData} from "../../../src/chain/index.js"; describe("chain / lightclient", () => { vi.setConfig({testTimeout: 600_000}); diff --git a/packages/beacon-node/test/e2e/chain/proposerBoostReorg.test.ts b/packages/beacon-node/test/e2e/chain/proposerBoostReorg.test.ts index fd6af72ad6cb..70f2d87e2456 100644 --- a/packages/beacon-node/test/e2e/chain/proposerBoostReorg.test.ts +++ b/packages/beacon-node/test/e2e/chain/proposerBoostReorg.test.ts @@ -1,16 +1,16 @@ -import {describe, it, afterEach, expect, vi} from "vitest"; -import {SLOTS_PER_EPOCH} from "@lodestar/params"; -import {TimestampFormatCode} from "@lodestar/logger"; +import {routes} from "@lodestar/api"; import {ChainConfig} from "@lodestar/config"; +import {TimestampFormatCode} from "@lodestar/logger"; +import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {RootHex, Slot} from "@lodestar/types"; -import {routes} from "@lodestar/api"; import {toHexString} from "@lodestar/utils"; +import {afterEach, describe, expect, it, vi} from "vitest"; +import {ReorgEventData} from "../../../src/chain/emitter.js"; +import {TimelinessForkChoice} from "../../mocks/fork-choice/timeliness.js"; +import {waitForEvent} from "../../utils/events/resolver.js"; import {LogLevel, TestLoggerOpts, testLogger} from "../../utils/logger.js"; import {getDevBeaconNode} from "../../utils/node/beacon.js"; -import {TimelinessForkChoice} from "../../mocks/fork-choice/timeliness.js"; import {getAndInitDevValidators} from "../../utils/node/validator.js"; -import {waitForEvent} from "../../utils/events/resolver.js"; -import {ReorgEventData} from "../../../src/chain/emitter.js"; describe("proposer boost reorg", () => { vi.setConfig({testTimeout: 60000}); diff --git a/packages/beacon-node/test/e2e/chain/stateCache/nHistoricalStates.test.ts b/packages/beacon-node/test/e2e/chain/stateCache/nHistoricalStates.test.ts index fcac715e1719..875e3fe13b03 100644 --- a/packages/beacon-node/test/e2e/chain/stateCache/nHistoricalStates.test.ts +++ b/packages/beacon-node/test/e2e/chain/stateCache/nHistoricalStates.test.ts @@ -1,18 +1,18 @@ -import {describe, it, afterEach, expect, vi} from "vitest"; -import {Gauge, Histogram} from "prom-client"; +import {routes} from "@lodestar/api"; import {ChainConfig} from "@lodestar/config"; -import {Slot, phase0} from "@lodestar/types"; import {TimestampFormatCode} from "@lodestar/logger"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; -import {routes} from "@lodestar/api"; -import {LogLevel, TestLoggerOpts, testLogger} from "../../../utils/logger.js"; -import {getDevBeaconNode} from "../../../utils/node/beacon.js"; -import {getAndInitDevValidators} from "../../../utils/node/validator.js"; -import {waitForEvent} from "../../../utils/events/resolver.js"; +import {Slot, phase0} from "@lodestar/types"; +import {Gauge, Histogram} from "prom-client"; +import {afterEach, describe, expect, it, vi} from "vitest"; import {ChainEvent, ReorgEventData} from "../../../../src/chain/emitter.js"; -import {connect, onPeerConnect} from "../../../utils/network.js"; import {CacheItemType} from "../../../../src/chain/stateCache/types.js"; import {ReorgedForkChoice} from "../../../mocks/fork-choice/reorg.js"; +import {waitForEvent} from "../../../utils/events/resolver.js"; +import {LogLevel, TestLoggerOpts, testLogger} from "../../../utils/logger.js"; +import {connect, onPeerConnect} from "../../../utils/network.js"; +import {getDevBeaconNode} from "../../../utils/node/beacon.js"; +import {getAndInitDevValidators} from "../../../utils/node/validator.js"; /** * Test different reorg scenarios to make sure the StateCache implementations are correct. diff --git a/packages/beacon-node/test/e2e/db/api/beacon/repositories/blockArchive.test.ts b/packages/beacon-node/test/e2e/db/api/beacon/repositories/blockArchive.test.ts index 3c7a37e52a8b..a08be8922d2a 100644 --- a/packages/beacon-node/test/e2e/db/api/beacon/repositories/blockArchive.test.ts +++ b/packages/beacon-node/test/e2e/db/api/beacon/repositories/blockArchive.test.ts @@ -1,6 +1,6 @@ -import {beforeAll, afterAll, describe, it, expect} from "vitest"; import {config} from "@lodestar/config/default"; import {ssz} from "@lodestar/types"; +import {afterAll, beforeAll, describe, expect, it} from "vitest"; import {BeaconDb} from "../../../../../../src/db/index.js"; import {startTmpBeaconDb} from "../../../../../utils/db.js"; diff --git a/packages/beacon-node/test/e2e/doppelganger/doppelganger.test.ts b/packages/beacon-node/test/e2e/doppelganger/doppelganger.test.ts index 949d0104d641..c83a2896530c 100644 --- a/packages/beacon-node/test/e2e/doppelganger/doppelganger.test.ts +++ b/packages/beacon-node/test/e2e/doppelganger/doppelganger.test.ts @@ -1,18 +1,18 @@ -import {describe, afterEach, it, expect} from "vitest"; import {fromHexString} from "@chainsafe/ssz"; import {routes} from "@lodestar/api/beacon"; -import {BLSPubkey, Epoch, phase0, Slot, ssz} from "@lodestar/types"; import {ChainConfig} from "@lodestar/config"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; +import {BLSPubkey, Epoch, Slot, phase0, ssz} from "@lodestar/types"; import {Validator} from "@lodestar/validator"; import {PubkeyHex} from "@lodestar/validator/src/types"; -import {getAndInitDevValidators} from "../../utils/node/validator.js"; +import {afterEach, describe, expect, it} from "vitest"; +import {BeaconNode} from "../../../src/node/index.js"; import {ClockEvent} from "../../../src/util/clock.js"; +import {waitForEvent} from "../../utils/events/resolver.js"; +import {LogLevel, TestLoggerOpts, testLogger} from "../../utils/logger.js"; import {connect} from "../../utils/network.js"; -import {testLogger, LogLevel, TestLoggerOpts} from "../../utils/logger.js"; import {getDevBeaconNode} from "../../utils/node/beacon.js"; -import {waitForEvent} from "../../utils/events/resolver.js"; -import {BeaconNode} from "../../../src/node/index.js"; +import {getAndInitDevValidators} from "../../utils/node/validator.js"; // TODO: Reconsider this tests latter. // Doppelganger testing can be split in two items: diff --git a/packages/beacon-node/test/e2e/eth1/eth1ForBlockProduction.test.ts b/packages/beacon-node/test/e2e/eth1/eth1ForBlockProduction.test.ts index 21cadeb55d2c..f72be5ed3e94 100644 --- a/packages/beacon-node/test/e2e/eth1/eth1ForBlockProduction.test.ts +++ b/packages/beacon-node/test/e2e/eth1/eth1ForBlockProduction.test.ts @@ -1,18 +1,18 @@ -import {describe, it, beforeAll, afterAll, expect} from "vitest"; import {fromHexString, toHexString} from "@chainsafe/ssz"; -import {sleep} from "@lodestar/utils"; import {LevelDbController} from "@lodestar/db"; +import {sleep} from "@lodestar/utils"; +import {afterAll, beforeAll, describe, expect, it} from "vitest"; import {ssz} from "@lodestar/types"; +import {BeaconDb} from "../../../src/db/index.js"; import {Eth1ForBlockProduction} from "../../../src/eth1/index.js"; import {Eth1Options} from "../../../src/eth1/options.js"; -import {getTestnetConfig, medallaTestnetConfig} from "../../utils/testnet.js"; -import {testLogger} from "../../utils/logger.js"; -import {BeaconDb} from "../../../src/db/index.js"; -import {generateState} from "../../utils/state.js"; import {Eth1Provider} from "../../../src/eth1/provider/eth1Provider.js"; import {getGoerliRpcUrl} from "../../testParams.js"; import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js"; +import {testLogger} from "../../utils/logger.js"; +import {generateState} from "../../utils/state.js"; +import {getTestnetConfig, medallaTestnetConfig} from "../../utils/testnet.js"; const dbLocation = "./.__testdb"; diff --git a/packages/beacon-node/test/e2e/eth1/eth1MergeBlockTracker.test.ts b/packages/beacon-node/test/e2e/eth1/eth1MergeBlockTracker.test.ts index 9423bb716b3f..79ff059e2b82 100644 --- a/packages/beacon-node/test/e2e/eth1/eth1MergeBlockTracker.test.ts +++ b/packages/beacon-node/test/e2e/eth1/eth1MergeBlockTracker.test.ts @@ -1,14 +1,14 @@ -import {describe, it, beforeAll, expect, beforeEach, afterEach} from "vitest"; import {fromHexString} from "@chainsafe/ssz"; import {ChainConfig} from "@lodestar/config"; import {sleep} from "@lodestar/utils"; -import {Eth1Provider, IEth1Provider} from "../../../src/index.js"; +import {afterEach, beforeAll, beforeEach, describe, expect, it} from "vitest"; +import {ZERO_HASH} from "../../../src/constants/index.js"; import {Eth1MergeBlockTracker, StatusCode} from "../../../src/eth1/eth1MergeBlockTracker.js"; import {Eth1Options} from "../../../src/eth1/options.js"; -import {testLogger} from "../../utils/logger.js"; import {quantityToBigint} from "../../../src/eth1/provider/utils.js"; -import {ZERO_HASH} from "../../../src/constants/index.js"; +import {Eth1Provider, IEth1Provider} from "../../../src/index.js"; import {getGoerliRpcUrl} from "../../testParams.js"; +import {testLogger} from "../../utils/logger.js"; // This test is constantly failing. We must unblock PR so this issue is a TODO to debug it and re-enable latter. // It's OKAY to disable temporarily since this functionality is tested indirectly by the sim merge tests. diff --git a/packages/beacon-node/test/e2e/eth1/eth1Provider.test.ts b/packages/beacon-node/test/e2e/eth1/eth1Provider.test.ts index 606845f40337..d571a695c648 100644 --- a/packages/beacon-node/test/e2e/eth1/eth1Provider.test.ts +++ b/packages/beacon-node/test/e2e/eth1/eth1Provider.test.ts @@ -1,11 +1,11 @@ -import {describe, it, expect, beforeEach, afterEach} from "vitest"; import {fromHexString} from "@chainsafe/ssz"; +import {afterEach, beforeEach, describe, expect, it} from "vitest"; +import {Eth1Block} from "../../../src/eth1/interface.js"; import {Eth1Options} from "../../../src/eth1/options.js"; -import {getTestnetConfig} from "../../utils/testnet.js"; -import {goerliTestnetDepositEvents} from "../../utils/testnet.js"; import {Eth1Provider, parseEth1Block} from "../../../src/eth1/provider/eth1Provider.js"; -import {Eth1Block} from "../../../src/eth1/interface.js"; import {getGoerliRpcUrl} from "../../testParams.js"; +import {getTestnetConfig} from "../../utils/testnet.js"; +import {goerliTestnetDepositEvents} from "../../utils/testnet.js"; // https://github.com/ChainSafe/lodestar/issues/5967 describe.skip("eth1 / Eth1Provider", () => { diff --git a/packages/beacon-node/test/e2e/eth1/jsonRpcHttpClient.test.ts b/packages/beacon-node/test/e2e/eth1/jsonRpcHttpClient.test.ts index 91131a89f379..ee2476549737 100644 --- a/packages/beacon-node/test/e2e/eth1/jsonRpcHttpClient.test.ts +++ b/packages/beacon-node/test/e2e/eth1/jsonRpcHttpClient.test.ts @@ -1,11 +1,11 @@ import crypto from "node:crypto"; import http from "node:http"; -import {describe, it, expect, afterEach, vi} from "vitest"; import {FetchError} from "@lodestar/api"; import {sleep} from "@lodestar/utils"; +import {afterEach, describe, expect, it, vi} from "vitest"; +import {RpcPayload} from "../../../src/eth1/interface.js"; import {JsonRpcHttpClient} from "../../../src/eth1/provider/jsonRpcHttpClient.js"; import {getGoerliRpcUrl} from "../../testParams.js"; -import {RpcPayload} from "../../../src/eth1/interface.js"; describe("eth1 / jsonRpcHttpClient", () => { vi.setConfig({testTimeout: 10_000}); diff --git a/packages/beacon-node/test/e2e/eth1/stream.test.ts b/packages/beacon-node/test/e2e/eth1/stream.test.ts index ce65d4353f0e..1ec20608cfd7 100644 --- a/packages/beacon-node/test/e2e/eth1/stream.test.ts +++ b/packages/beacon-node/test/e2e/eth1/stream.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect, beforeEach, afterEach} from "vitest"; -import {getTestnetConfig, medallaTestnetConfig} from "../../utils/testnet.js"; -import {getDepositsStream, getDepositsAndBlockStreamForGenesis} from "../../../src/eth1/stream.js"; +import {afterEach, beforeEach, describe, expect, it} from "vitest"; +import {Eth1Options} from "../../../src/eth1/options.js"; import {Eth1Provider} from "../../../src/eth1/provider/eth1Provider.js"; +import {getDepositsAndBlockStreamForGenesis, getDepositsStream} from "../../../src/eth1/stream.js"; import {getGoerliRpcUrl} from "../../testParams.js"; -import {Eth1Options} from "../../../src/eth1/options.js"; +import {getTestnetConfig, medallaTestnetConfig} from "../../utils/testnet.js"; // https://github.com/ChainSafe/lodestar/issues/5967 describe.skip("Eth1 streams", () => { diff --git a/packages/beacon-node/test/e2e/interop/genesisState.test.ts b/packages/beacon-node/test/e2e/interop/genesisState.test.ts index 739319a4257c..91d67fae91ce 100644 --- a/packages/beacon-node/test/e2e/interop/genesisState.test.ts +++ b/packages/beacon-node/test/e2e/interop/genesisState.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect} from "vitest"; import {toHexString} from "@chainsafe/ssz"; import {config} from "@lodestar/config/default"; import {ssz} from "@lodestar/types"; -import {initDevState} from "../../../src/node/utils/state.js"; +import {describe, expect, it} from "vitest"; import {interopDeposits} from "../../../src/node/utils/interop/deposits.js"; +import {initDevState} from "../../../src/node/utils/state.js"; describe("interop / initDevState", () => { it("Create interop deposits", () => { diff --git a/packages/beacon-node/test/e2e/network/gossipsub.test.ts b/packages/beacon-node/test/e2e/network/gossipsub.test.ts index 29a745455561..e63b26d026db 100644 --- a/packages/beacon-node/test/e2e/network/gossipsub.test.ts +++ b/packages/beacon-node/test/e2e/network/gossipsub.test.ts @@ -1,12 +1,12 @@ -import {describe, it, expect, afterEach, vi} from "vitest"; import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; -import {sleep} from "@lodestar/utils"; import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {ssz} from "@lodestar/types"; +import {sleep} from "@lodestar/utils"; +import {afterEach, describe, expect, it, vi} from "vitest"; +import {GossipHandlerParamGeneric, GossipHandlers, GossipType} from "../../../src/network/gossip/index.js"; import {Network} from "../../../src/network/index.js"; -import {GossipType, GossipHandlers, GossipHandlerParamGeneric} from "../../../src/network/gossip/index.js"; -import {getNetworkForTest} from "../../utils/networkWithMockDb.js"; import {connect, onPeerConnect} from "../../utils/network.js"; +import {getNetworkForTest} from "../../utils/networkWithMockDb.js"; describe("gossipsub / main thread", () => { vi.setConfig({testTimeout: 3000}); diff --git a/packages/beacon-node/test/e2e/network/mdns.test.ts b/packages/beacon-node/test/e2e/network/mdns.test.ts index f8b55d8afae7..f1df1f1e94d6 100644 --- a/packages/beacon-node/test/e2e/network/mdns.test.ts +++ b/packages/beacon-node/test/e2e/network/mdns.test.ts @@ -1,21 +1,21 @@ -import {describe, it, afterEach, beforeEach, expect, vi} from "vitest"; +import {SignableENR} from "@chainsafe/enr"; import {PeerId} from "@libp2p/interface"; -import {multiaddr} from "@multiformats/multiaddr"; import {createSecp256k1PeerId} from "@libp2p/peer-id-factory"; -import {SignableENR} from "@chainsafe/enr"; import {createBeaconConfig} from "@lodestar/config"; import {config} from "@lodestar/config/default"; -import {ssz} from "@lodestar/types"; import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; +import {ssz} from "@lodestar/types"; +import {multiaddr} from "@multiformats/multiaddr"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; +import {GossipHandlers} from "../../../src/network/gossip/index.js"; +import {Network, NetworkInitModules, getReqRespHandlers} from "../../../src/network/index.js"; +import {NetworkOptions, defaultNetworkOptions} from "../../../src/network/options.js"; import {getMockedBeaconChain} from "../../mocks/mockedBeaconChain.js"; import {getMockedBeaconDb} from "../../mocks/mockedBeaconDb.js"; -import {Network, NetworkInitModules, getReqRespHandlers} from "../../../src/network/index.js"; -import {defaultNetworkOptions, NetworkOptions} from "../../../src/network/options.js"; +import {memoOnce} from "../../utils/cache.js"; +import {testLogger} from "../../utils/logger.js"; import {createNetworkModules, onPeerConnect} from "../../utils/network.js"; import {generateState, zeroProtoBlock} from "../../utils/state.js"; -import {testLogger} from "../../utils/logger.js"; -import {GossipHandlers} from "../../../src/network/gossip/index.js"; -import {memoOnce} from "../../utils/cache.js"; let port = 9000; const mu = "/ip4/127.0.0.1/tcp/0"; diff --git a/packages/beacon-node/test/e2e/network/network.test.ts b/packages/beacon-node/test/e2e/network/network.test.ts index 2435b005efa1..fee80d6f48b5 100644 --- a/packages/beacon-node/test/e2e/network/network.test.ts +++ b/packages/beacon-node/test/e2e/network/network.test.ts @@ -1,10 +1,10 @@ -import {describe, it, expect, afterEach, beforeEach, vi} from "vitest"; import {PeerId} from "@libp2p/interface"; import {config} from "@lodestar/config/default"; import {phase0} from "@lodestar/types"; import {sleep} from "@lodestar/utils"; -import {Network, NetworkEvent, ReqRespMethod} from "../../../src/network/index.js"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {GoodByeReasonCode} from "../../../src/constants/index.js"; +import {Network, NetworkEvent, ReqRespMethod} from "../../../src/network/index.js"; import {connect, disconnect, onPeerConnect, onPeerDisconnect} from "../../utils/network.js"; import {getNetworkForTest} from "../../utils/networkWithMockDb.js"; import {getValidPeerId} from "../../utils/peer.js"; diff --git a/packages/beacon-node/test/e2e/network/onWorker/dataSerialization.test.ts b/packages/beacon-node/test/e2e/network/onWorker/dataSerialization.test.ts index 12d9e393af09..e4056ca9671e 100644 --- a/packages/beacon-node/test/e2e/network/onWorker/dataSerialization.test.ts +++ b/packages/beacon-node/test/e2e/network/onWorker/dataSerialization.test.ts @@ -1,12 +1,20 @@ -import {describe, it, beforeAll, afterAll, expect} from "vitest"; -import {TopicValidatorResult} from "@libp2p/interface"; import {BitArray} from "@chainsafe/ssz"; -import {ssz} from "@lodestar/types"; +import {TopicValidatorResult} from "@libp2p/interface"; import {routes} from "@lodestar/api"; import {ForkName} from "@lodestar/params"; -import {getValidPeerId, validPeerIdStr} from "../../../utils/peer.js"; +import {ssz} from "@lodestar/types"; +import {afterAll, beforeAll, describe, expect, it} from "vitest"; +import { + BlockInput, + BlockInputDataBlobs, + BlockInputType, + BlockSource, + CachedData, +} from "../../../../src/chain/blocks/types.js"; +import {ZERO_HASH, ZERO_HASH_HEX} from "../../../../src/constants/constants.js"; import {ReqRespBridgeEventData} from "../../../../src/network/core/events.js"; import {ReqRespBridgeEvent} from "../../../../src/network/core/events.js"; +import {NetworkWorkerApi} from "../../../../src/network/core/index.js"; import { GossipType, NetworkEvent, @@ -15,18 +23,10 @@ import { ReqRespMethod, networkEventDirection, } from "../../../../src/network/index.js"; -import { - BlockInputType, - BlockSource, - BlockInput, - BlockInputDataBlobs, - CachedData, -} from "../../../../src/chain/blocks/types.js"; -import {ZERO_HASH, ZERO_HASH_HEX} from "../../../../src/constants/constants.js"; +import {CommitteeSubscription} from "../../../../src/network/subnets/interface.js"; import {IteratorEventType} from "../../../../src/util/asyncIterableToEvents.js"; -import {NetworkWorkerApi} from "../../../../src/network/core/index.js"; import {EventDirection} from "../../../../src/util/workerEvents.js"; -import {CommitteeSubscription} from "../../../../src/network/subnets/interface.js"; +import {getValidPeerId, validPeerIdStr} from "../../../utils/peer.js"; import {EchoWorker, getEchoWorker} from "./workerEchoHandler.js"; describe("data serialization through worker boundary", () => { diff --git a/packages/beacon-node/test/e2e/network/onWorker/workerEchoHandler.ts b/packages/beacon-node/test/e2e/network/onWorker/workerEchoHandler.ts index b2c0f6b56aa0..f4b5df8189a0 100644 --- a/packages/beacon-node/test/e2e/network/onWorker/workerEchoHandler.ts +++ b/packages/beacon-node/test/e2e/network/onWorker/workerEchoHandler.ts @@ -1,5 +1,5 @@ import workerThreads from "node:worker_threads"; -import {spawn, Worker} from "@chainsafe/threads"; +import {Worker, spawn} from "@chainsafe/threads"; export type EchoWorker = { send(data: T): Promise; diff --git a/packages/beacon-node/test/e2e/network/peers/peerManager.test.ts b/packages/beacon-node/test/e2e/network/peers/peerManager.test.ts index d0b94399c01d..e0b1e6b357fc 100644 --- a/packages/beacon-node/test/e2e/network/peers/peerManager.test.ts +++ b/packages/beacon-node/test/e2e/network/peers/peerManager.test.ts @@ -1,24 +1,24 @@ -import {describe, it, afterEach, expect, vi} from "vitest"; +import {BitArray} from "@chainsafe/ssz"; import {Connection} from "@libp2p/interface"; import {CustomEvent} from "@libp2p/interface"; -import {BitArray} from "@chainsafe/ssz"; +import {createBeaconConfig} from "@lodestar/config"; import {config} from "@lodestar/config/default"; import {altair, phase0, ssz} from "@lodestar/types"; import {sleep} from "@lodestar/utils"; -import {createBeaconConfig} from "@lodestar/config"; -import {ReqRespMethod} from "../../../../src/network/reqresp/ReqRespBeaconNode.js"; -import {PeerRpcScoreStore, PeerManager, IReqRespBeaconNodePeerManager} from "../../../../src/network/peers/index.js"; -import {Eth2Gossipsub, getConnectionsMap, NetworkEvent, NetworkEventBus} from "../../../../src/network/index.js"; +import {afterEach, describe, expect, it, vi} from "vitest"; +import {Eth2Gossipsub, NetworkEvent, NetworkEventBus, getConnectionsMap} from "../../../../src/network/index.js"; +import {IReqRespBeaconNodePeerManager, PeerManager, PeerRpcScoreStore} from "../../../../src/network/peers/index.js"; import {PeersData} from "../../../../src/network/peers/peersData.js"; -import {createNode} from "../../../utils/network.js"; -import {getAttnets, getSyncnets} from "../../../utils/network.js"; -import {generateState} from "../../../utils/state.js"; +import {ReqRespMethod} from "../../../../src/network/reqresp/ReqRespBeaconNode.js"; +import {LocalStatusCache} from "../../../../src/network/statusCache.js"; +import {IAttnetsService} from "../../../../src/network/subnets/index.js"; +import {Clock} from "../../../../src/util/clock.js"; import {waitForEvent} from "../../../utils/events/resolver.js"; import {testLogger} from "../../../utils/logger.js"; +import {createNode} from "../../../utils/network.js"; +import {getAttnets, getSyncnets} from "../../../utils/network.js"; import {getValidPeerId} from "../../../utils/peer.js"; -import {IAttnetsService} from "../../../../src/network/subnets/index.js"; -import {Clock} from "../../../../src/util/clock.js"; -import {LocalStatusCache} from "../../../../src/network/statusCache.js"; +import {generateState} from "../../../utils/state.js"; const logger = testLogger("peerManager"); diff --git a/packages/beacon-node/test/e2e/network/reqresp.test.ts b/packages/beacon-node/test/e2e/network/reqresp.test.ts index b7ab190166e7..854a2a2482ff 100644 --- a/packages/beacon-node/test/e2e/network/reqresp.test.ts +++ b/packages/beacon-node/test/e2e/network/reqresp.test.ts @@ -1,17 +1,17 @@ -import {describe, it, expect, afterEach, beforeEach, vi} from "vitest"; -import {createChainForkConfig, ChainForkConfig} from "@lodestar/config"; +import {ChainForkConfig, createChainForkConfig} from "@lodestar/config"; import {chainConfig} from "@lodestar/config/default"; import {ForkName} from "@lodestar/params"; import {RequestError, RequestErrorCode, ResponseOutgoing} from "@lodestar/reqresp"; -import {altair, phase0, Root, SignedBeaconBlock, ssz} from "@lodestar/types"; +import {Root, SignedBeaconBlock, altair, phase0, ssz} from "@lodestar/types"; import {sleep as _sleep} from "@lodestar/utils"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {Network, ReqRespBeaconNodeOpts} from "../../../src/network/index.js"; +import {GetReqRespHandlerFn, ReqRespMethod} from "../../../src/network/reqresp/types.js"; +import {PeerIdStr} from "../../../src/util/peerId.js"; +import {arrToSource} from "../../unit/network/reqresp/utils.js"; import {expectRejectedWithLodestarError} from "../../utils/errors.js"; import {connect, getPeerIdOf, onPeerConnect} from "../../utils/network.js"; import {getNetworkForTest} from "../../utils/networkWithMockDb.js"; -import {arrToSource} from "../../unit/network/reqresp/utils.js"; -import {GetReqRespHandlerFn, ReqRespMethod} from "../../../src/network/reqresp/types.js"; -import {PeerIdStr} from "../../../src/util/peerId.js"; /* eslint-disable require-yield, @typescript-eslint/naming-convention */ diff --git a/packages/beacon-node/test/e2e/network/reqrespEncode.test.ts b/packages/beacon-node/test/e2e/network/reqrespEncode.test.ts index ae916bdd0ab7..4634870c40fe 100644 --- a/packages/beacon-node/test/e2e/network/reqrespEncode.test.ts +++ b/packages/beacon-node/test/e2e/network/reqrespEncode.test.ts @@ -1,26 +1,26 @@ -import {describe, it, afterEach, expect} from "vitest"; -import all from "it-all"; -import {Libp2p, createLibp2p} from "libp2p"; -import {tcp} from "@libp2p/tcp"; -import {mplex} from "@libp2p/mplex"; -import {Multiaddr, multiaddr} from "@multiformats/multiaddr"; import {noise} from "@chainsafe/libp2p-noise"; -import {ssz} from "@lodestar/types"; +import {mplex} from "@libp2p/mplex"; +import {tcp} from "@libp2p/tcp"; import {createBeaconConfig} from "@lodestar/config"; import {ForkName} from "@lodestar/params"; +import {ssz} from "@lodestar/types"; import {fromHex, sleep, toHex} from "@lodestar/utils"; +import {Multiaddr, multiaddr} from "@multiformats/multiaddr"; +import all from "it-all"; +import {Libp2p, createLibp2p} from "libp2p"; +import {afterEach, describe, expect, it} from "vitest"; +import {ZERO_HASH} from "../../../src/constants/constants.js"; import { NetworkEventBus, PeerRpcScoreStore, ReqRespBeaconNode, ReqRespBeaconNodeModules, } from "../../../src/network/index.js"; -import {PeersData} from "../../../src/network/peers/peersData.js"; -import {ZERO_HASH} from "../../../src/constants/constants.js"; import {MetadataController} from "../../../src/network/metadata.js"; -import {testLogger} from "../../utils/logger.js"; +import {PeersData} from "../../../src/network/peers/peersData.js"; import {GetReqRespHandlerFn} from "../../../src/network/reqresp/types.js"; import {LocalStatusCache} from "../../../src/network/statusCache.js"; +import {testLogger} from "../../utils/logger.js"; /* eslint-disable require-yield */ diff --git a/packages/beacon-node/test/e2e/sync/finalizedSync.test.ts b/packages/beacon-node/test/e2e/sync/finalizedSync.test.ts index ba98f2a1facd..38e3f59adf54 100644 --- a/packages/beacon-node/test/e2e/sync/finalizedSync.test.ts +++ b/packages/beacon-node/test/e2e/sync/finalizedSync.test.ts @@ -1,18 +1,18 @@ -import {describe, it, afterEach, vi} from "vitest"; -import {assert} from "chai"; import {fromHexString} from "@chainsafe/ssz"; +import {routes} from "@lodestar/api"; +import {EventData, EventType} from "@lodestar/api/lib/beacon/routes/events.js"; import {ChainConfig} from "@lodestar/config"; -import {phase0} from "@lodestar/types"; import {TimestampFormatCode} from "@lodestar/logger"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; -import {routes} from "@lodestar/api"; -import {EventData, EventType} from "@lodestar/api/lib/beacon/routes/events.js"; -import {getDevBeaconNode} from "../../utils/node/beacon.js"; -import {waitForEvent} from "../../utils/events/resolver.js"; -import {getAndInitDevValidators} from "../../utils/node/validator.js"; +import {phase0} from "@lodestar/types"; +import {assert} from "chai"; +import {afterEach, describe, it, vi} from "vitest"; import {ChainEvent} from "../../../src/chain/index.js"; +import {waitForEvent} from "../../utils/events/resolver.js"; +import {LogLevel, TestLoggerOpts, testLogger} from "../../utils/logger.js"; import {connect, onPeerConnect} from "../../utils/network.js"; -import {testLogger, LogLevel, TestLoggerOpts} from "../../utils/logger.js"; +import {getDevBeaconNode} from "../../utils/node/beacon.js"; +import {getAndInitDevValidators} from "../../utils/node/validator.js"; describe("sync / finalized sync", () => { // chain is finalized at slot 32, plus 4 slots for genesis delay => ~72s it should sync pretty fast diff --git a/packages/beacon-node/test/e2e/sync/unknownBlockSync.test.ts b/packages/beacon-node/test/e2e/sync/unknownBlockSync.test.ts index 290213d2b1ee..28ec0871b275 100644 --- a/packages/beacon-node/test/e2e/sync/unknownBlockSync.test.ts +++ b/packages/beacon-node/test/e2e/sync/unknownBlockSync.test.ts @@ -1,21 +1,21 @@ -import {describe, it, afterEach, vi} from "vitest"; import {fromHexString} from "@chainsafe/ssz"; +import {routes} from "@lodestar/api"; +import {EventData, EventType} from "@lodestar/api/lib/beacon/routes/events.js"; import {ChainConfig} from "@lodestar/config"; -import {phase0} from "@lodestar/types"; import {config} from "@lodestar/config/default"; import {TimestampFormatCode} from "@lodestar/logger"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; -import {routes} from "@lodestar/api"; -import {EventData, EventType} from "@lodestar/api/lib/beacon/routes/events.js"; -import {getDevBeaconNode} from "../../utils/node/beacon.js"; -import {waitForEvent} from "../../utils/events/resolver.js"; -import {getAndInitDevValidators} from "../../utils/node/validator.js"; +import {phase0} from "@lodestar/types"; +import {afterEach, describe, it, vi} from "vitest"; +import {BlockSource, getBlockInput} from "../../../src/chain/blocks/types.js"; +import {BlockError, BlockErrorCode} from "../../../src/chain/errors/index.js"; import {ChainEvent} from "../../../src/chain/index.js"; import {NetworkEvent} from "../../../src/network/index.js"; +import {waitForEvent} from "../../utils/events/resolver.js"; +import {LogLevel, TestLoggerOpts, testLogger} from "../../utils/logger.js"; import {connect, onPeerConnect} from "../../utils/network.js"; -import {testLogger, LogLevel, TestLoggerOpts} from "../../utils/logger.js"; -import {BlockError, BlockErrorCode} from "../../../src/chain/errors/index.js"; -import {BlockSource, getBlockInput} from "../../../src/chain/blocks/types.js"; +import {getDevBeaconNode} from "../../utils/node/beacon.js"; +import {getAndInitDevValidators} from "../../utils/node/validator.js"; describe("sync / unknown block sync", () => { vi.setConfig({testTimeout: 40_000}); diff --git a/packages/beacon-node/test/globalSetup.ts b/packages/beacon-node/test/globalSetup.ts index f41a7f249b9b..784633baf2c4 100644 --- a/packages/beacon-node/test/globalSetup.ts +++ b/packages/beacon-node/test/globalSetup.ts @@ -1,4 +1,4 @@ -import {setActivePreset, PresetName} from "@lodestar/params/setPreset"; +import {PresetName, setActivePreset} from "@lodestar/params/setPreset"; export async function setup(): Promise { process.env.NODE_ENV = "test"; diff --git a/packages/beacon-node/test/memory/unfinalizedPubkey2Index.ts b/packages/beacon-node/test/memory/unfinalizedPubkey2Index.ts index 1a317a7fe9d3..294dde750865 100644 --- a/packages/beacon-node/test/memory/unfinalizedPubkey2Index.ts +++ b/packages/beacon-node/test/memory/unfinalizedPubkey2Index.ts @@ -1,8 +1,8 @@ import crypto from "node:crypto"; +import {toMemoryEfficientHexStr} from "@lodestar/state-transition/src/cache/pubkeyCache.js"; +import {ValidatorIndex} from "@lodestar/types"; // biome-ignore lint/suspicious/noShadowRestrictedNames: We explicitly want `Map` name to be imported import {Map} from "immutable"; -import {ValidatorIndex} from "@lodestar/types"; -import {toMemoryEfficientHexStr} from "@lodestar/state-transition/src/cache/pubkeyCache.js"; import {testRunnerMemory} from "./testRunnerMemory.js"; // Results in MacOS Nov 2023 diff --git a/packages/beacon-node/test/mocks/clock.ts b/packages/beacon-node/test/mocks/clock.ts index 6f09bd292491..dc06fcd6922a 100644 --- a/packages/beacon-node/test/mocks/clock.ts +++ b/packages/beacon-node/test/mocks/clock.ts @@ -1,7 +1,7 @@ import EventEmitter from "node:events"; -import {Mocked, vi} from "vitest"; import {computeEpochAtSlot} from "@lodestar/state-transition"; import {Epoch, Slot} from "@lodestar/types"; +import {Mocked, vi} from "vitest"; import {IClock} from "../../src/util/clock.js"; /** diff --git a/packages/beacon-node/test/mocks/loggerMock.ts b/packages/beacon-node/test/mocks/loggerMock.ts index ee25ede93475..99984ba87e9f 100644 --- a/packages/beacon-node/test/mocks/loggerMock.ts +++ b/packages/beacon-node/test/mocks/loggerMock.ts @@ -1,5 +1,5 @@ -import {vi, Mocked} from "vitest"; import {Logger} from "@lodestar/logger"; +import {Mocked, vi} from "vitest"; export type MockedLogger = Mocked; diff --git a/packages/beacon-node/test/mocks/mockedBeaconChain.ts b/packages/beacon-node/test/mocks/mockedBeaconChain.ts index a69efc55836c..b274284e3ab1 100644 --- a/packages/beacon-node/test/mocks/mockedBeaconChain.ts +++ b/packages/beacon-node/test/mocks/mockedBeaconChain.ts @@ -1,22 +1,22 @@ -import {vi, Mocked, Mock} from "vitest"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; -import {config as defaultConfig} from "@lodestar/config/default"; import {ChainForkConfig} from "@lodestar/config"; -import {ForkChoice, ProtoBlock, EpochDifference} from "@lodestar/fork-choice"; +import {config as defaultConfig} from "@lodestar/config/default"; +import {EpochDifference, ForkChoice, ProtoBlock} from "@lodestar/fork-choice"; import {Logger} from "@lodestar/utils"; +import {Mock, Mocked, vi} from "vitest"; +import {BeaconProposerCache} from "../../src/chain/beaconProposerCache.js"; import {BeaconChain} from "../../src/chain/chain.js"; import {ChainEventEmitter} from "../../src/chain/emitter.js"; -import {ExecutionEngineHttp} from "../../src/execution/engine/index.js"; -import {ExecutionBuilderHttp} from "../../src/execution/builder/http.js"; -import {Eth1ForBlockProduction} from "../../src/eth1/index.js"; -import {OpPool, AggregatedAttestationPool} from "../../src/chain/opPools/index.js"; -import {BeaconProposerCache} from "../../src/chain/beaconProposerCache.js"; import {LightClientServer} from "../../src/chain/lightClient/index.js"; -import {Clock} from "../../src/util/clock.js"; +import {AggregatedAttestationPool, OpPool} from "../../src/chain/opPools/index.js"; import {QueuedStateRegenerator} from "../../src/chain/regen/index.js"; import {ShufflingCache} from "../../src/chain/shufflingCache.js"; -import {getMockedLogger} from "./loggerMock.js"; +import {Eth1ForBlockProduction} from "../../src/eth1/index.js"; +import {ExecutionBuilderHttp} from "../../src/execution/builder/http.js"; +import {ExecutionEngineHttp} from "../../src/execution/engine/index.js"; +import {Clock} from "../../src/util/clock.js"; import {getMockedClock} from "./clock.js"; +import {getMockedLogger} from "./loggerMock.js"; export type MockedBeaconChain = Mocked & { logger: Mocked; diff --git a/packages/beacon-node/test/mocks/mockedBeaconDb.ts b/packages/beacon-node/test/mocks/mockedBeaconDb.ts index eb209c9b44fb..87404a8965a6 100644 --- a/packages/beacon-node/test/mocks/mockedBeaconDb.ts +++ b/packages/beacon-node/test/mocks/mockedBeaconDb.ts @@ -1,20 +1,20 @@ -import {vi, Mocked} from "vitest"; import {config as minimalConfig} from "@lodestar/config/default"; +import {Mocked, vi} from "vitest"; +import {BeaconDb} from "../../src/db/index.js"; import { AttesterSlashingRepository, + BLSToExecutionChangeRepository, + BlobSidecarsArchiveRepository, + BlobSidecarsRepository, BlockArchiveRepository, BlockRepository, - DepositEventRepository, DepositDataRootRepository, + DepositEventRepository, Eth1DataRepository, ProposerSlashingRepository, StateArchiveRepository, VoluntaryExitRepository, - BLSToExecutionChangeRepository, - BlobSidecarsRepository, - BlobSidecarsArchiveRepository, } from "../../src/db/repositories/index.js"; -import {BeaconDb} from "../../src/db/index.js"; export type MockedBeaconDb = Mocked & { block: Mocked; diff --git a/packages/beacon-node/test/mocks/mockedNetwork.ts b/packages/beacon-node/test/mocks/mockedNetwork.ts index 9258acc9bc1b..27b9c3deaf79 100644 --- a/packages/beacon-node/test/mocks/mockedNetwork.ts +++ b/packages/beacon-node/test/mocks/mockedNetwork.ts @@ -1,5 +1,5 @@ -import {vi, Mocked} from "vitest"; -import {Network, INetwork} from "../../src/network/index.js"; +import {Mocked, vi} from "vitest"; +import {INetwork, Network} from "../../src/network/index.js"; vi.mock("../../src/network/index.js", async (importActual) => { const mod = await importActual(); diff --git a/packages/beacon-node/test/mocks/regenMocks.ts b/packages/beacon-node/test/mocks/regenMocks.ts index 39f7fa382760..f0be21989e83 100644 --- a/packages/beacon-node/test/mocks/regenMocks.ts +++ b/packages/beacon-node/test/mocks/regenMocks.ts @@ -1,4 +1,4 @@ -import {vi, Mocked} from "vitest"; +import {Mocked, vi} from "vitest"; import {QueuedStateRegenerator} from "../../src/chain/regen/index.js"; export type MockedQueuedStateRegenerator = Mocked; diff --git a/packages/beacon-node/test/mocks/shufflingMock.ts b/packages/beacon-node/test/mocks/shufflingMock.ts index 76482f760872..e13d8d6dce5d 100644 --- a/packages/beacon-node/test/mocks/shufflingMock.ts +++ b/packages/beacon-node/test/mocks/shufflingMock.ts @@ -1,4 +1,4 @@ -import {vi, Mocked} from "vitest"; +import {Mocked, vi} from "vitest"; import {ShufflingCache} from "../../src/chain/shufflingCache.js"; export type MockedShufflingCache = Mocked; diff --git a/packages/beacon-node/test/perf/bls/bls.test.ts b/packages/beacon-node/test/perf/bls/bls.test.ts index 9f1f90a4d879..1c6cde5e20ac 100644 --- a/packages/beacon-node/test/perf/bls/bls.test.ts +++ b/packages/beacon-node/test/perf/bls/bls.test.ts @@ -1,5 +1,4 @@ import crypto from "node:crypto"; -import {itBench} from "@dapplion/benchmark"; import { PublicKey, SecretKey, @@ -9,6 +8,7 @@ import { verify, verifyMultipleAggregateSignatures, } from "@chainsafe/blst"; +import {itBench} from "@dapplion/benchmark"; import {linspace} from "../../../src/util/numpy.js"; describe("BLS ops", () => { diff --git a/packages/beacon-node/test/perf/chain/opPools/aggregatedAttestationPool.test.ts b/packages/beacon-node/test/perf/chain/opPools/aggregatedAttestationPool.test.ts index 89bd76f34eb3..28c1f198da28 100644 --- a/packages/beacon-node/test/perf/chain/opPools/aggregatedAttestationPool.test.ts +++ b/packages/beacon-node/test/perf/chain/opPools/aggregatedAttestationPool.test.ts @@ -1,5 +1,7 @@ -import {itBench} from "@dapplion/benchmark"; import {BitArray, toHexString} from "@chainsafe/ssz"; +import {itBench} from "@dapplion/benchmark"; +import {DataAvailabilityStatus, ExecutionStatus, ForkChoice, IForkChoiceStore, ProtoArray} from "@lodestar/fork-choice"; +import {HISTORICAL_ROOTS_LIMIT, SLOTS_PER_EPOCH} from "@lodestar/params"; import { CachedBeaconStateAltair, computeAnchorCheckpoint, @@ -8,8 +10,6 @@ import { getBlockRootAtSlot, newFilledArray, } from "@lodestar/state-transition"; -import {HISTORICAL_ROOTS_LIMIT, SLOTS_PER_EPOCH} from "@lodestar/params"; -import {ExecutionStatus, ForkChoice, IForkChoiceStore, ProtoArray, DataAvailabilityStatus} from "@lodestar/fork-choice"; import {ssz} from "@lodestar/types"; import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; diff --git a/packages/beacon-node/test/perf/chain/opPools/opPool.test.ts b/packages/beacon-node/test/perf/chain/opPools/opPool.test.ts index 9d518c03eec9..d685ec36c6b7 100644 --- a/packages/beacon-node/test/perf/chain/opPools/opPool.test.ts +++ b/packages/beacon-node/test/perf/chain/opPools/opPool.test.ts @@ -8,6 +8,7 @@ import { import {CachedBeaconStateAltair} from "@lodestar/state-transition"; import {ssz} from "@lodestar/types"; import {generatePerfTestCachedStateAltair} from "../../../../../state-transition/test/perf/util.js"; +import {BlockType} from "../../../../src/chain/interface.js"; import {OpPool} from "../../../../src/chain/opPools/opPool.js"; import {generateBlsToExecutionChanges} from "../../../fixtures/capella.js"; import { @@ -15,7 +16,6 @@ import { generateSignedBeaconBlockHeader, generateVoluntaryExits, } from "../../../fixtures/phase0.js"; -import {BlockType} from "../../../../src/chain/interface.js"; describe("opPool", () => { let originalState: CachedBeaconStateAltair; diff --git a/packages/beacon-node/test/perf/chain/produceBlock/produceBlockBody.test.ts b/packages/beacon-node/test/perf/chain/produceBlock/produceBlockBody.test.ts index c08cf64fc974..6d411ca09cd5 100644 --- a/packages/beacon-node/test/perf/chain/produceBlock/produceBlockBody.test.ts +++ b/packages/beacon-node/test/perf/chain/produceBlock/produceBlockBody.test.ts @@ -3,14 +3,14 @@ import {itBench} from "@dapplion/benchmark"; import {config} from "@lodestar/config/default"; import {LevelDbController} from "@lodestar/db"; import {SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY} from "@lodestar/params"; -import {defaultOptions as defaultValidatorOptions} from "@lodestar/validator"; import {CachedBeaconStateAltair} from "@lodestar/state-transition"; +import {defaultOptions as defaultValidatorOptions} from "@lodestar/validator"; import {generatePerfTestCachedStateAltair} from "../../../../../state-transition/test/perf/util.js"; import {BeaconChain} from "../../../../src/chain/index.js"; import {BlockType, produceBlockBody} from "../../../../src/chain/produceBlock/produceBlockBody.js"; import {Eth1ForBlockProductionDisabled} from "../../../../src/eth1/index.js"; import {ExecutionEngineDisabled} from "../../../../src/execution/engine/index.js"; -import {StateArchiveMode, BeaconDb} from "../../../../src/index.js"; +import {BeaconDb, StateArchiveMode} from "../../../../src/index.js"; import {testLogger} from "../../../utils/logger.js"; const logger = testLogger(); diff --git a/packages/beacon-node/test/perf/chain/seenCache/seenAggregateAndProof.test.ts b/packages/beacon-node/test/perf/chain/seenCache/seenAggregateAndProof.test.ts index 49c3123c14dd..b119fccdd562 100644 --- a/packages/beacon-node/test/perf/chain/seenCache/seenAggregateAndProof.test.ts +++ b/packages/beacon-node/test/perf/chain/seenCache/seenAggregateAndProof.test.ts @@ -1,5 +1,5 @@ -import {itBench} from "@dapplion/benchmark"; import {BitArray} from "@chainsafe/ssz"; +import {itBench} from "@dapplion/benchmark"; import {TARGET_AGGREGATORS_PER_COMMITTEE} from "@lodestar/params"; import {SeenAggregatedAttestations} from "../../../../src/chain/seenCache/seenAggregateAndProof.js"; diff --git a/packages/beacon-node/test/perf/chain/stateCache/inMemoryCheckpointsCache.test.ts b/packages/beacon-node/test/perf/chain/stateCache/inMemoryCheckpointsCache.test.ts index 17a46b09af8d..9f3db45cb827 100644 --- a/packages/beacon-node/test/perf/chain/stateCache/inMemoryCheckpointsCache.test.ts +++ b/packages/beacon-node/test/perf/chain/stateCache/inMemoryCheckpointsCache.test.ts @@ -1,8 +1,8 @@ import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; -import {ssz, phase0} from "@lodestar/types"; -import {generateCachedState} from "../../../utils/state.js"; +import {phase0, ssz} from "@lodestar/types"; import {InMemoryCheckpointStateCache, toCheckpointHex} from "../../../../src/chain/stateCache/index.js"; +import {generateCachedState} from "../../../utils/state.js"; describe("InMemoryCheckpointStateCache perf tests", () => { setBenchOpts({noThreshold: true}); 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 a4bdbe9710cb..8009f36c6301 100644 --- a/packages/beacon-node/test/perf/chain/stateCache/updateUnfinalizedPubkeys.test.ts +++ b/packages/beacon-node/test/perf/chain/stateCache/updateUnfinalizedPubkeys.test.ts @@ -1,13 +1,13 @@ -import {itBench, setBenchOpts} from "@dapplion/benchmark"; -import {Map as ImmutableMap} from "immutable"; -import {toBufferBE} from "bigint-buffer"; import {digest} from "@chainsafe/as-sha256"; import {SecretKey} from "@chainsafe/blst"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; -import {ValidatorIndex, ssz} from "@lodestar/types"; +import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {type CachedBeaconStateAllForks, toMemoryEfficientHexStr} from "@lodestar/state-transition"; +import {ValidatorIndex, ssz} from "@lodestar/types"; import {bytesToBigInt, intToBytes} from "@lodestar/utils"; -import {InMemoryCheckpointStateCache, BlockStateCacheImpl} from "../../../../src/chain/stateCache/index.js"; +import {toBufferBE} from "bigint-buffer"; +import {Map as ImmutableMap} from "immutable"; +import {BlockStateCacheImpl, InMemoryCheckpointStateCache} from "../../../../src/chain/stateCache/index.js"; import {BlockStateCache} from "../../../../src/chain/stateCache/types.js"; import {generateCachedElectraState} from "../../../utils/state.js"; diff --git a/packages/beacon-node/test/perf/chain/validation/attestation.test.ts b/packages/beacon-node/test/perf/chain/validation/attestation.test.ts index 696b6bdb1871..4814c59cce9a 100644 --- a/packages/beacon-node/test/perf/chain/validation/attestation.test.ts +++ b/packages/beacon-node/test/perf/chain/validation/attestation.test.ts @@ -1,10 +1,10 @@ import {itBench, setBenchOpts} from "@dapplion/benchmark"; -import {expect} from "chai"; import {ssz} from "@lodestar/types"; +import {expect} from "chai"; import {generateTestCachedBeaconStateOnlyValidators} from "../../../../../state-transition/test/perf/util.js"; import {validateGossipAttestationsSameAttData} from "../../../../src/chain/validation/index.js"; -import {getAttestationValidData} from "../../../utils/validationData/attestation.js"; import {getAttDataFromAttestationSerialized} from "../../../../src/util/sszBytes.js"; +import {getAttestationValidData} from "../../../utils/validationData/attestation.js"; describe("validate gossip attestation", () => { setBenchOpts({ diff --git a/packages/beacon-node/test/perf/chain/verifyImportBlocks.test.ts b/packages/beacon-node/test/perf/chain/verifyImportBlocks.test.ts index 6f1cf2ef3da6..35165aa3c38f 100644 --- a/packages/beacon-node/test/perf/chain/verifyImportBlocks.test.ts +++ b/packages/beacon-node/test/perf/chain/verifyImportBlocks.test.ts @@ -1,19 +1,19 @@ import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {config} from "@lodestar/config/default"; -import {SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY, SLOTS_PER_EPOCH} from "@lodestar/params"; import {LevelDbController} from "@lodestar/db"; +import {SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY, SLOTS_PER_EPOCH} from "@lodestar/params"; import {sleep} from "@lodestar/utils"; import {defaultOptions as defaultValidatorOptions} from "@lodestar/validator"; import {rangeSyncTest} from "../../../../state-transition/test/perf/params.js"; -import {getNetworkCachedState, getNetworkCachedBlock} from "../../../../state-transition/test/utils/testFileCache.js"; import {beforeValue} from "../../../../state-transition/test/utils/beforeValueMocha.js"; +import {getNetworkCachedBlock, getNetworkCachedState} from "../../../../state-transition/test/utils/testFileCache.js"; +import {AttestationImportOpt, BlockSource, getBlockInput} from "../../../src/chain/blocks/types.js"; import {BeaconChain} from "../../../src/chain/index.js"; -import {ExecutionEngineDisabled} from "../../../src/execution/engine/index.js"; import {Eth1ForBlockProductionDisabled} from "../../../src/eth1/index.js"; -import {testLogger} from "../../utils/logger.js"; +import {ExecutionEngineDisabled} from "../../../src/execution/engine/index.js"; +import {BeaconDb, StateArchiveMode} from "../../../src/index.js"; import {linspace} from "../../../src/util/numpy.js"; -import {StateArchiveMode, BeaconDb} from "../../../src/index.js"; -import {getBlockInput, AttestationImportOpt, BlockSource} from "../../../src/chain/blocks/types.js"; +import {testLogger} from "../../utils/logger.js"; // Define this params in `packages/state-transition/test/perf/params.ts` // to trigger Github actions CI cache diff --git a/packages/beacon-node/test/perf/eth1/pickEth1Vote.test.ts b/packages/beacon-node/test/perf/eth1/pickEth1Vote.test.ts index 20efeefe0923..dfc5fb560b27 100644 --- a/packages/beacon-node/test/perf/eth1/pickEth1Vote.test.ts +++ b/packages/beacon-node/test/perf/eth1/pickEth1Vote.test.ts @@ -1,7 +1,7 @@ -import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {ContainerType, ListCompositeType} from "@chainsafe/ssz"; +import {itBench, setBenchOpts} from "@dapplion/benchmark"; +import {BeaconStateAllForks, newFilledArray} from "@lodestar/state-transition"; import {phase0, ssz} from "@lodestar/types"; -import {newFilledArray, BeaconStateAllForks} from "@lodestar/state-transition"; import {fastSerializeEth1Data, pickEth1Vote} from "../../../src/eth1/utils/eth1Vote.js"; describe("eth1 / pickEth1Vote", () => { diff --git a/packages/beacon-node/test/perf/misc/bytesHex.test.ts b/packages/beacon-node/test/perf/misc/bytesHex.test.ts index aa4443a65a61..bb5e2b252960 100644 --- a/packages/beacon-node/test/perf/misc/bytesHex.test.ts +++ b/packages/beacon-node/test/perf/misc/bytesHex.test.ts @@ -1,6 +1,6 @@ import crypto from "node:crypto"; -import {itBench} from "@dapplion/benchmark"; import {toHexString} from "@chainsafe/ssz"; +import {itBench} from "@dapplion/benchmark"; // Results in Linux Dec 2021 // diff --git a/packages/beacon-node/test/perf/network/gossip/fastMsgIdFn.test.ts b/packages/beacon-node/test/perf/network/gossip/fastMsgIdFn.test.ts index 4daeb64f5d79..3b31e38655db 100644 --- a/packages/beacon-node/test/perf/network/gossip/fastMsgIdFn.test.ts +++ b/packages/beacon-node/test/perf/network/gossip/fastMsgIdFn.test.ts @@ -1,7 +1,7 @@ import {randomBytes} from "node:crypto"; -import xxhashFactory from "xxhash-wasm"; -import {itBench} from "@dapplion/benchmark"; import {digest} from "@chainsafe/as-sha256"; +import {itBench} from "@dapplion/benchmark"; +import xxhashFactory from "xxhash-wasm"; const hasher = await xxhashFactory(); diff --git a/packages/beacon-node/test/perf/network/noise/sendData.test.ts b/packages/beacon-node/test/perf/network/noise/sendData.test.ts index 35538a417adf..ee4d734fd5cb 100644 --- a/packages/beacon-node/test/perf/network/noise/sendData.test.ts +++ b/packages/beacon-node/test/perf/network/noise/sendData.test.ts @@ -1,10 +1,10 @@ +import {noise} from "@chainsafe/libp2p-noise"; import {itBench} from "@dapplion/benchmark"; -import {duplexPair} from "it-pair/duplex"; +import {defaultLogger} from "@libp2p/logger"; import {createSecp256k1PeerId} from "@libp2p/peer-id-factory"; -import {pipe} from "it-pipe"; import drain from "it-drain"; -import {defaultLogger} from "@libp2p/logger"; -import {noise} from "@chainsafe/libp2p-noise"; +import {duplexPair} from "it-pair/duplex"; +import {pipe} from "it-pipe"; import {Uint8ArrayList} from "uint8arraylist"; describe("network / noise / sendData", () => { diff --git a/packages/beacon-node/test/perf/network/peers/enrSubnetsDeserialize.test.ts b/packages/beacon-node/test/perf/network/peers/enrSubnetsDeserialize.test.ts index 2507c43bcc9c..ffe22cf5bac5 100644 --- a/packages/beacon-node/test/perf/network/peers/enrSubnetsDeserialize.test.ts +++ b/packages/beacon-node/test/perf/network/peers/enrSubnetsDeserialize.test.ts @@ -1,7 +1,7 @@ import {itBench} from "@dapplion/benchmark"; -import {expect} from "chai"; -import {SYNC_COMMITTEE_SUBNET_COUNT, ATTESTATION_SUBNET_COUNT} from "@lodestar/params"; +import {ATTESTATION_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; import {ssz} from "@lodestar/types"; +import {expect} from "chai"; import {deserializeEnrSubnets} from "../../../../src/network/peers/utils/enrSubnetsDeserialize.js"; /** diff --git a/packages/beacon-node/test/perf/network/peers/util/prioritizePeers.test.ts b/packages/beacon-node/test/perf/network/peers/util/prioritizePeers.test.ts index d5a6b4e9cb25..a8d6365be691 100644 --- a/packages/beacon-node/test/perf/network/peers/util/prioritizePeers.test.ts +++ b/packages/beacon-node/test/perf/network/peers/util/prioritizePeers.test.ts @@ -4,7 +4,7 @@ import {createSecp256k1PeerId} from "@libp2p/peer-id-factory"; import {ATTESTATION_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; import {altair, phase0} from "@lodestar/types"; import {defaultNetworkOptions} from "../../../../../src/network/options.js"; -import {prioritizePeers, RequestedSubnet} from "../../../../../src/network/peers/utils/index.js"; +import {RequestedSubnet, prioritizePeers} from "../../../../../src/network/peers/utils/index.js"; import {getAttnets, getSyncnets} from "../../../../utils/network.js"; describe("prioritizePeers", () => { diff --git a/packages/beacon-node/test/perf/util/bitArray.test.ts b/packages/beacon-node/test/perf/util/bitArray.test.ts index fe421a8f9bd8..fae525def3c4 100644 --- a/packages/beacon-node/test/perf/util/bitArray.test.ts +++ b/packages/beacon-node/test/perf/util/bitArray.test.ts @@ -1,6 +1,6 @@ import crypto from "node:crypto"; -import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {BitArray} from "@chainsafe/ssz"; +import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {intersectUint8Arrays} from "../../../src/util/bitArray.js"; /** diff --git a/packages/beacon-node/test/setupPreset.ts b/packages/beacon-node/test/setupPreset.ts index 968c6e12c668..7d64d1336ed5 100644 --- a/packages/beacon-node/test/setupPreset.ts +++ b/packages/beacon-node/test/setupPreset.ts @@ -1,4 +1,4 @@ -import {setActivePreset, PresetName} from "@lodestar/params/setPreset"; +import {PresetName, setActivePreset} from "@lodestar/params/setPreset"; // Set minimal if (process.env.LODESTAR_PRESET === undefined) { process.env.LODESTAR_PRESET = "minimal"; diff --git a/packages/beacon-node/test/sim/electra-interop.test.ts b/packages/beacon-node/test/sim/electra-interop.test.ts index 20fedd3d4b0f..47b7d127fb42 100644 --- a/packages/beacon-node/test/sim/electra-interop.test.ts +++ b/packages/beacon-node/test/sim/electra-interop.test.ts @@ -1,29 +1,29 @@ -import fs from "node:fs"; import assert from "node:assert"; -import {describe, it, vi, afterAll, afterEach} from "vitest"; +import fs from "node:fs"; +import {afterAll, afterEach, describe, it, vi} from "vitest"; -import {LogLevel, sleep} from "@lodestar/utils"; import {ForkName, SLOTS_PER_EPOCH, UNSET_DEPOSIT_REQUESTS_START_INDEX} from "@lodestar/params"; -import {electra, Epoch, Slot} from "@lodestar/types"; +import {Epoch, Slot, electra} from "@lodestar/types"; +import {LogLevel, sleep} from "@lodestar/utils"; import {ValidatorProposerConfig} from "@lodestar/validator"; import {ChainConfig} from "@lodestar/config"; import {TimestampFormatCode} from "@lodestar/logger"; import {CachedBeaconStateElectra} from "@lodestar/state-transition"; -import {initializeExecutionEngine} from "../../src/execution/index.js"; import {ExecutionPayloadStatus, PayloadAttributes} from "../../src/execution/engine/interface.js"; +import {initializeExecutionEngine} from "../../src/execution/index.js"; -import {testLogger, TestLoggerOpts} from "../utils/logger.js"; -import {runEL, ELStartMode, ELClient, sendRawTransactionBig} from "../utils/runEl.js"; +import {bytesToData} from "../../lib/eth1/provider/utils.js"; +import {BeaconRestApiServerOpts} from "../../src/api/index.js"; +import {dataToBytes} from "../../src/eth1/provider/utils.js"; import {defaultExecutionEngineHttpOpts} from "../../src/execution/engine/http.js"; +import {BeaconNode} from "../../src/index.js"; +import {ClockEvent} from "../../src/util/clock.js"; +import {TestLoggerOpts, testLogger} from "../utils/logger.js"; import {getDevBeaconNode} from "../utils/node/beacon.js"; -import {BeaconRestApiServerOpts} from "../../src/api/index.js"; import {simTestInfoTracker} from "../utils/node/simTest.js"; import {getAndInitDevValidators} from "../utils/node/validator.js"; -import {ClockEvent} from "../../src/util/clock.js"; -import {dataToBytes} from "../../src/eth1/provider/utils.js"; -import {bytesToData} from "../../lib/eth1/provider/utils.js"; -import {BeaconNode} from "../../src/index.js"; +import {ELClient, ELStartMode, runEL, sendRawTransactionBig} from "../utils/runEl.js"; import {logFilesDir} from "./params.js"; import {shell} from "./shell.js"; diff --git a/packages/beacon-node/test/sim/mergemock.test.ts b/packages/beacon-node/test/sim/mergemock.test.ts index 64020b070e11..230856291f64 100644 --- a/packages/beacon-node/test/sim/mergemock.test.ts +++ b/packages/beacon-node/test/sim/mergemock.test.ts @@ -1,23 +1,23 @@ import fs from "node:fs"; -import {describe, it, afterAll, afterEach, vi} from "vitest"; import {fromHexString, toHexString} from "@chainsafe/ssz"; -import {LogLevel, sleep} from "@lodestar/utils"; +import {routes} from "@lodestar/api"; +import {ChainConfig} from "@lodestar/config"; import {TimestampFormatCode} from "@lodestar/logger"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; -import {ChainConfig} from "@lodestar/config"; import {Epoch, SignedBeaconBlock, bellatrix} from "@lodestar/types"; +import {LogLevel, sleep} from "@lodestar/utils"; import {ValidatorProposerConfig} from "@lodestar/validator"; -import {routes} from "@lodestar/api"; +import {afterAll, afterEach, describe, it, vi} from "vitest"; +import {BeaconRestApiServerOpts} from "../../src/api/index.js"; +import {ZERO_HASH} from "../../src/constants/index.js"; +import {Eth1Provider} from "../../src/index.js"; import {ClockEvent} from "../../src/util/clock.js"; -import {testLogger, TestLoggerOpts} from "../utils/logger.js"; +import {TestLoggerOpts, testLogger} from "../utils/logger.js"; import {getDevBeaconNode} from "../utils/node/beacon.js"; -import {BeaconRestApiServerOpts} from "../../src/api/index.js"; import {simTestInfoTracker} from "../utils/node/simTest.js"; import {getAndInitDevValidators} from "../utils/node/validator.js"; -import {Eth1Provider} from "../../src/index.js"; -import {ZERO_HASH} from "../../src/constants/index.js"; -import {runEL, ELStartMode, ELClient} from "../utils/runEl.js"; +import {ELClient, ELStartMode, runEL} from "../utils/runEl.js"; import {logFilesDir} from "./params.js"; import {shell} from "./shell.js"; diff --git a/packages/beacon-node/test/spec/bls/bls.ts b/packages/beacon-node/test/spec/bls/bls.ts index 76c511215b61..61c86e69b47e 100644 --- a/packages/beacon-node/test/spec/bls/bls.ts +++ b/packages/beacon-node/test/spec/bls/bls.ts @@ -2,11 +2,11 @@ import { PublicKey, SecretKey, Signature, + verify as _verify, aggregateSignatures, aggregateVerify, fastAggregateVerify, verifyMultipleAggregateSignatures, - verify as _verify, } from "@chainsafe/blst"; import {fromHexString} from "@chainsafe/ssz"; diff --git a/packages/beacon-node/test/spec/bls/index.test.ts b/packages/beacon-node/test/spec/bls/index.test.ts index 32baa00d9fbc..cf1da723698f 100644 --- a/packages/beacon-node/test/spec/bls/index.test.ts +++ b/packages/beacon-node/test/spec/bls/index.test.ts @@ -1,7 +1,7 @@ import fs from "node:fs"; import path from "node:path"; import jsyaml from "js-yaml"; -import {expect, describe, it} from "vitest"; +import {describe, expect, it} from "vitest"; import {blsSpecTests} from "../specTestVersioning.js"; import {readdirSyncSpec} from "../utils/specTestIterator.js"; import {testFnByType} from "./bls.js"; diff --git a/packages/beacon-node/test/spec/downloadTests.ts b/packages/beacon-node/test/spec/downloadTests.ts index 57efd3ca2183..7790e52ea9e1 100644 --- a/packages/beacon-node/test/spec/downloadTests.ts +++ b/packages/beacon-node/test/spec/downloadTests.ts @@ -1,5 +1,5 @@ import {downloadTests} from "@lodestar/spec-test-util/downloadTests"; -import {ethereumConsensusSpecsTests, blsSpecTests} from "./specTestVersioning.js"; +import {blsSpecTests, ethereumConsensusSpecsTests} from "./specTestVersioning.js"; /* eslint-disable no-console */ diff --git a/packages/beacon-node/test/spec/general/bls.ts b/packages/beacon-node/test/spec/general/bls.ts index 128b5b4f5613..7d4a94481025 100644 --- a/packages/beacon-node/test/spec/general/bls.ts +++ b/packages/beacon-node/test/spec/general/bls.ts @@ -1,14 +1,14 @@ -import {fromHexString} from "@chainsafe/ssz"; import { + aggregateVerify as BLSAggregateVerify, + fastAggregateVerify as BLSFastAggregateVerify, PublicKey, SecretKey, Signature, + verify as _verify, aggregateSerializedPublicKeys, aggregateSignatures, - aggregateVerify as BLSAggregateVerify, - fastAggregateVerify as BLSFastAggregateVerify, - verify as _verify, } from "@chainsafe/blst"; +import {fromHexString} from "@chainsafe/ssz"; import {InputType} from "@lodestar/spec-test-util"; import {TestRunnerFn} from "../utils/types.js"; diff --git a/packages/beacon-node/test/spec/general/index.test.ts b/packages/beacon-node/test/spec/general/index.test.ts index 063f128c3142..c539061d217e 100644 --- a/packages/beacon-node/test/spec/general/index.test.ts +++ b/packages/beacon-node/test/spec/general/index.test.ts @@ -1,7 +1,7 @@ import path from "node:path"; -import {RunnerType} from "../utils/types.js"; -import {SkipOpts, specTestIterator} from "../utils/specTestIterator.js"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; +import {SkipOpts, specTestIterator} from "../utils/specTestIterator.js"; +import {RunnerType} from "../utils/types.js"; import {blsTestRunner} from "./bls.js"; import {sszGeneric} from "./ssz_generic.js"; diff --git a/packages/beacon-node/test/spec/general/ssz_generic.ts b/packages/beacon-node/test/spec/general/ssz_generic.ts index 64e6b4455941..6cfb7686c9e7 100644 --- a/packages/beacon-node/test/spec/general/ssz_generic.ts +++ b/packages/beacon-node/test/spec/general/ssz_generic.ts @@ -1,9 +1,9 @@ import fs from "node:fs"; import path from "node:path"; import {expect, it} from "vitest"; -import {TestRunnerCustom} from "../utils/types.js"; -import {parseSszGenericInvalidTestcase, parseSszGenericValidTestcase} from "../utils/sszTestCaseParser.js"; import {runValidSszTest} from "../utils/runValidSszTest.js"; +import {parseSszGenericInvalidTestcase, parseSszGenericValidTestcase} from "../utils/sszTestCaseParser.js"; +import {TestRunnerCustom} from "../utils/types.js"; import {getTestType} from "./ssz_generic_types.js"; // Mapping of sszGeneric() fn arguments to the path in spec tests diff --git a/packages/beacon-node/test/spec/general/ssz_generic_types.ts b/packages/beacon-node/test/spec/general/ssz_generic_types.ts index fe19f08149b4..2386f770fe60 100644 --- a/packages/beacon-node/test/spec/general/ssz_generic_types.ts +++ b/packages/beacon-node/test/spec/general/ssz_generic_types.ts @@ -1,12 +1,12 @@ import { - Type, - BooleanType, - UintBigintType, - UintNumberType, - BitVectorType, BitListType, + BitVectorType, + BooleanType, ContainerType, ListBasicType, + Type, + UintBigintType, + UintNumberType, VectorBasicType, VectorCompositeType, } from "@chainsafe/ssz"; diff --git a/packages/beacon-node/test/spec/presets/epoch_processing.test.ts b/packages/beacon-node/test/spec/presets/epoch_processing.test.ts index c61aec40fee3..05ce8c4c70e3 100644 --- a/packages/beacon-node/test/spec/presets/epoch_processing.test.ts +++ b/packages/beacon-node/test/spec/presets/epoch_processing.test.ts @@ -1,22 +1,22 @@ import path from "node:path"; -import {expect} from "vitest"; +import {ACTIVE_PRESET} from "@lodestar/params"; import { + BeaconStateAllForks, CachedBeaconStateAllForks, + CachedBeaconStateAltair, EpochTransitionCache, - BeaconStateAllForks, beforeProcessEpoch, - CachedBeaconStateAltair, } from "@lodestar/state-transition"; import * as epochFns from "@lodestar/state-transition/epoch"; import {ssz} from "@lodestar/types"; -import {ACTIVE_PRESET} from "@lodestar/params"; +import {expect} from "vitest"; import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js"; -import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; import {getConfig} from "../../utils/config.js"; -import {RunnerType, TestRunnerFn} from "../utils/types.js"; import {assertCorrectProgressiveBalances} from "../config.js"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; +import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; import {specTestIterator} from "../utils/specTestIterator.js"; +import {RunnerType, TestRunnerFn} from "../utils/types.js"; export type EpochTransitionFn = (state: CachedBeaconStateAllForks, epochTransitionCache: EpochTransitionCache) => void; diff --git a/packages/beacon-node/test/spec/presets/finality.test.ts b/packages/beacon-node/test/spec/presets/finality.test.ts index 1dce91e360e5..a183d7c2197a 100644 --- a/packages/beacon-node/test/spec/presets/finality.test.ts +++ b/packages/beacon-node/test/spec/presets/finality.test.ts @@ -1,4 +1,5 @@ import path from "node:path"; +import {ACTIVE_PRESET, ForkName} from "@lodestar/params"; import { BeaconStateAllForks, DataAvailableStatus, @@ -6,14 +7,13 @@ import { stateTransition, } from "@lodestar/state-transition"; import {altair, bellatrix, ssz} from "@lodestar/types"; -import {ACTIVE_PRESET, ForkName} from "@lodestar/params"; import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js"; -import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; -import {RunnerType, shouldVerify, TestRunnerFn} from "../utils/types.js"; import {getConfig} from "../../utils/config.js"; import {assertCorrectProgressiveBalances} from "../config.js"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; +import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; import {specTestIterator} from "../utils/specTestIterator.js"; +import {RunnerType, TestRunnerFn, shouldVerify} from "../utils/types.js"; const finality: TestRunnerFn = (fork) => { return { diff --git a/packages/beacon-node/test/spec/presets/fork.test.ts b/packages/beacon-node/test/spec/presets/fork.test.ts index 626d6477bcb1..bc66bccb279e 100644 --- a/packages/beacon-node/test/spec/presets/fork.test.ts +++ b/packages/beacon-node/test/spec/presets/fork.test.ts @@ -1,21 +1,21 @@ import path from "node:path"; +import {ChainForkConfig, createChainForkConfig} from "@lodestar/config"; +import {ACTIVE_PRESET, ForkName} from "@lodestar/params"; import { BeaconStateAllForks, - CachedBeaconStateBellatrix, CachedBeaconStateAltair, - CachedBeaconStatePhase0, + CachedBeaconStateBellatrix, CachedBeaconStateCapella, CachedBeaconStateDeneb, + CachedBeaconStatePhase0, } from "@lodestar/state-transition"; import * as slotFns from "@lodestar/state-transition/slot"; import {phase0, ssz} from "@lodestar/types"; -import {ACTIVE_PRESET, ForkName} from "@lodestar/params"; -import {createChainForkConfig, ChainForkConfig} from "@lodestar/config"; -import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js"; -import {RunnerType, TestRunnerFn} from "../utils/types.js"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; +import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; import {specTestIterator} from "../utils/specTestIterator.js"; +import {RunnerType, TestRunnerFn} from "../utils/types.js"; const fork: TestRunnerFn = (forkNext) => { const config = createChainForkConfig({}); 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 72515e703582..a12e6e0ac467 100644 --- a/packages/beacon-node/test/spec/presets/fork_choice.test.ts +++ b/packages/beacon-node/test/spec/presets/fork_choice.test.ts @@ -1,50 +1,50 @@ import path from "node:path"; -import {expect} from "vitest"; import {toHexString} from "@chainsafe/ssz"; -import {BeaconStateAllForks, isExecutionStateType, signedBlockToSignedHeader} from "@lodestar/state-transition"; -import {InputType} from "@lodestar/spec-test-util"; +import {createBeaconConfig} from "@lodestar/config"; import {CheckpointWithHex, ForkChoice} from "@lodestar/fork-choice"; +import {ACTIVE_PRESET, ForkName, ForkSeq, isForkBlobs} from "@lodestar/params"; +import {InputType} from "@lodestar/spec-test-util"; +import {BeaconStateAllForks, isExecutionStateType, signedBlockToSignedHeader} from "@lodestar/state-transition"; import { - bellatrix, - ssz, - RootHex, - deneb, + Attestation, + AttesterSlashing, BeaconBlock, + RootHex, SignedBeaconBlock, + bellatrix, + deneb, + ssz, 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"; -import {BeaconChain, ChainEvent} from "../../../src/chain/index.js"; -import {ClockEvent} from "../../../src/util/clock.js"; -import {computeInclusionProof} from "../../../src/util/blobs.js"; -import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js"; -import {testLogger} from "../../utils/logger.js"; -import {getConfig} from "../../utils/config.js"; -import {RunnerType, TestRunnerFn} from "../utils/types.js"; -import {Eth1ForBlockProductionDisabled} from "../../../src/eth1/index.js"; -import {getExecutionEngineFromBackend} from "../../../src/execution/index.js"; -import {ExecutionPayloadStatus} from "../../../src/execution/engine/interface.js"; -import {ExecutionEngineMockBackend} from "../../../src/execution/engine/mock.js"; -import {defaultChainOptions} from "../../../src/chain/options.js"; -import {getMockedBeaconDb} from "../../mocks/mockedBeaconDb.js"; -import {ClockStopped} from "../../mocks/clock.js"; +import {expect} from "vitest"; import { - getBlockInput, AttestationImportOpt, - BlockSource, BlobSidecarValidation, BlobsSource, + BlockSource, + getBlockInput, } from "../../../src/chain/blocks/types.js"; +import {BeaconChain, ChainEvent} from "../../../src/chain/index.js"; +import {defaultChainOptions} from "../../../src/chain/options.js"; import {ZERO_HASH_HEX} from "../../../src/constants/constants.js"; +import {Eth1ForBlockProductionDisabled} from "../../../src/eth1/index.js"; import {PowMergeBlock} from "../../../src/eth1/interface.js"; -import {assertCorrectProgressiveBalances} from "../config.js"; +import {ExecutionPayloadStatus} from "../../../src/execution/engine/interface.js"; +import {ExecutionEngineMockBackend} from "../../../src/execution/engine/mock.js"; +import {getExecutionEngineFromBackend} from "../../../src/execution/index.js"; +import {computeInclusionProof} from "../../../src/util/blobs.js"; +import {ClockEvent} from "../../../src/util/clock.js"; import {initCKZG, loadEthereumTrustedSetup} from "../../../src/util/kzg.js"; +import {ClockStopped} from "../../mocks/clock.js"; +import {getMockedBeaconDb} from "../../mocks/mockedBeaconDb.js"; +import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js"; +import {getConfig} from "../../utils/config.js"; +import {testLogger} from "../../utils/logger.js"; +import {assertCorrectProgressiveBalances} from "../config.js"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; import {specTestIterator} from "../utils/specTestIterator.js"; +import {RunnerType, TestRunnerFn} from "../utils/types.js"; const ANCHOR_STATE_FILE_NAME = "anchor_state"; const ANCHOR_BLOCK_FILE_NAME = "anchor_block"; diff --git a/packages/beacon-node/test/spec/presets/genesis.test.ts b/packages/beacon-node/test/spec/presets/genesis.test.ts index 140fa3686e67..7b19e205dc05 100644 --- a/packages/beacon-node/test/spec/presets/genesis.test.ts +++ b/packages/beacon-node/test/spec/presets/genesis.test.ts @@ -1,6 +1,5 @@ import path from "node:path"; -import {expect} from "vitest"; -import {phase0, Root, ssz, TimeSeconds, ExecutionPayloadHeader, sszTypesFor} from "@lodestar/types"; +import {ForkName} from "@lodestar/params"; import {InputType} from "@lodestar/spec-test-util"; import { BeaconStateAllForks, @@ -8,17 +7,18 @@ import { initializeBeaconStateFromEth1, isValidGenesisState, } from "@lodestar/state-transition"; +import {ExecutionPayloadHeader, Root, TimeSeconds, phase0, ssz, sszTypesFor} from "@lodestar/types"; import {bnToNum} from "@lodestar/utils"; -import {ForkName} from "@lodestar/params"; +import {expect} from "vitest"; import {ACTIVE_PRESET} from "@lodestar/params"; +import {getConfig} from "../../utils/config.js"; import {expectEqualBeaconState} from "../utils/expectEqualBeaconState.js"; import {TestRunnerFn} from "../utils/types.js"; -import {getConfig} from "../../utils/config.js"; -import {RunnerType} from "../utils/types.js"; -import {specTestIterator} from "../utils/specTestIterator.js"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; +import {specTestIterator} from "../utils/specTestIterator.js"; +import {RunnerType} from "../utils/types.js"; // The aim of the genesis tests is to provide a baseline to test genesis-state initialization and test if the // proposed genesis-validity conditions are working. diff --git a/packages/beacon-node/test/spec/presets/light_client/single_merkle_proof.ts b/packages/beacon-node/test/spec/presets/light_client/single_merkle_proof.ts index 08dcd0ab8acf..3aa73f72ee40 100644 --- a/packages/beacon-node/test/spec/presets/light_client/single_merkle_proof.ts +++ b/packages/beacon-node/test/spec/presets/light_client/single_merkle_proof.ts @@ -1,10 +1,10 @@ -import {expect} from "vitest"; import {Tree} from "@chainsafe/persistent-merkle-tree"; import {TreeViewDU, Type} from "@chainsafe/ssz"; -import {RootHex, ssz} from "@lodestar/types"; -import {InputType} from "@lodestar/spec-test-util"; import {ForkName} from "@lodestar/params"; +import {InputType} from "@lodestar/spec-test-util"; +import {RootHex, ssz} from "@lodestar/types"; import {toHex} from "@lodestar/utils"; +import {expect} from "vitest"; import {TestRunnerFn} from "../../utils/types.js"; // https://github.com/ethereum/consensus-specs/blob/da3f5af919be4abb5a6db5a80b235deb8b4b5cba/tests/formats/light_client/single_merkle_proof.md diff --git a/packages/beacon-node/test/spec/presets/light_client/sync.ts b/packages/beacon-node/test/spec/presets/light_client/sync.ts index 3e82256fab1d..5ac51b95de3b 100644 --- a/packages/beacon-node/test/spec/presets/light_client/sync.ts +++ b/packages/beacon-node/test/spec/presets/light_client/sync.ts @@ -1,13 +1,13 @@ -import {expect} from "vitest"; +import {ChainConfig, createBeaconConfig} from "@lodestar/config"; +import {LightclientSpec, toLightClientUpdateSummary} from "@lodestar/light-client/spec"; import {isForkLightClient} from "@lodestar/params"; -import {altair, phase0, RootHex, Slot, ssz, sszTypesFor} from "@lodestar/types"; import {InputType} from "@lodestar/spec-test-util"; -import {createBeaconConfig, ChainConfig} from "@lodestar/config"; -import {fromHex, toHex} from "@lodestar/utils"; -import {LightclientSpec, toLightClientUpdateSummary} from "@lodestar/light-client/spec"; import {computeSyncPeriodAtSlot} from "@lodestar/state-transition"; -import {TestRunnerFn} from "../../utils/types.js"; +import {RootHex, Slot, altair, phase0, ssz, sszTypesFor} from "@lodestar/types"; +import {fromHex, toHex} from "@lodestar/utils"; +import {expect} from "vitest"; import {testLogger} from "../../../utils/logger.js"; +import {TestRunnerFn} from "../../utils/types.js"; // https://github.com/ethereum/consensus-specs/blob/da3f5af919be4abb5a6db5a80b235deb8b4b5cba/tests/formats/light_client/single_merkle_proof.md type SyncTestCase = { diff --git a/packages/beacon-node/test/spec/presets/light_client/update_ranking.ts b/packages/beacon-node/test/spec/presets/light_client/update_ranking.ts index b51219dd4e54..97cd7639a176 100644 --- a/packages/beacon-node/test/spec/presets/light_client/update_ranking.ts +++ b/packages/beacon-node/test/spec/presets/light_client/update_ranking.ts @@ -1,8 +1,8 @@ -import {expect} from "vitest"; -import {LightClientUpdate, altair, ssz, sszTypesFor} from "@lodestar/types"; +import {LightClientUpdateSummary, isBetterUpdate, toLightClientUpdateSummary} from "@lodestar/light-client/spec"; import {isForkLightClient} from "@lodestar/params"; import {InputType} from "@lodestar/spec-test-util"; -import {isBetterUpdate, LightClientUpdateSummary, toLightClientUpdateSummary} from "@lodestar/light-client/spec"; +import {LightClientUpdate, altair, ssz, sszTypesFor} from "@lodestar/types"; +import {expect} from "vitest"; import {TestRunnerFn} from "../../utils/types.js"; // https://github.com/ethereum/consensus-specs/blob/da3f5af919be4abb5a6db5a80b235deb8b4b5cba/tests/formats/light_client/update_ranking.md diff --git a/packages/beacon-node/test/spec/presets/merkle.test.ts b/packages/beacon-node/test/spec/presets/merkle.test.ts index 71cebdbd0b5b..2bc70374bdf5 100644 --- a/packages/beacon-node/test/spec/presets/merkle.test.ts +++ b/packages/beacon-node/test/spec/presets/merkle.test.ts @@ -1,15 +1,15 @@ import path from "node:path"; -import {expect} from "vitest"; import {ProofType, SingleProof, Tree} from "@chainsafe/persistent-merkle-tree"; import {fromHexString, toHexString} from "@chainsafe/ssz"; -import {ssz} from "@lodestar/types"; -import {BeaconStateAllForks} from "@lodestar/state-transition"; +import {ACTIVE_PRESET} from "@lodestar/params"; import {InputType} from "@lodestar/spec-test-util"; +import {BeaconStateAllForks} from "@lodestar/state-transition"; +import {ssz} from "@lodestar/types"; import {verifyMerkleBranch} from "@lodestar/utils"; -import {ACTIVE_PRESET} from "@lodestar/params"; -import {RunnerType, TestRunnerFn} from "../utils/types.js"; +import {expect} from "vitest"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; import {specTestIterator} from "../utils/specTestIterator.js"; +import {RunnerType, TestRunnerFn} from "../utils/types.js"; const merkle: TestRunnerFn = (fork) => { return { diff --git a/packages/beacon-node/test/spec/presets/operations.test.ts b/packages/beacon-node/test/spec/presets/operations.test.ts index 4c90831ef155..0a9996c0a2b1 100644 --- a/packages/beacon-node/test/spec/presets/operations.test.ts +++ b/packages/beacon-node/test/spec/presets/operations.test.ts @@ -1,4 +1,6 @@ import path from "node:path"; +import {ACTIVE_PRESET, ForkName} from "@lodestar/params"; +import {InputType} from "@lodestar/spec-test-util"; import { BeaconStateAllForks, CachedBeaconStateAllForks, @@ -9,16 +11,14 @@ import { getBlockRootAtSlot, } from "@lodestar/state-transition"; import * as blockFns from "@lodestar/state-transition/block"; -import {ssz, phase0, altair, bellatrix, capella, electra, sszTypesFor} from "@lodestar/types"; -import {InputType} from "@lodestar/spec-test-util"; -import {ACTIVE_PRESET, ForkName} from "@lodestar/params"; +import {altair, bellatrix, capella, electra, phase0, ssz, sszTypesFor} from "@lodestar/types"; import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js"; -import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; import {getConfig} from "../../utils/config.js"; -import {BaseSpecTest, RunnerType, shouldVerify, TestRunnerFn} from "../utils/types.js"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; +import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; import {specTestIterator} from "../utils/specTestIterator.js"; +import {BaseSpecTest, RunnerType, TestRunnerFn, shouldVerify} from "../utils/types.js"; // Define above to re-use in sync_aggregate and sync_aggregate_random const syncAggregate: BlockProcessFn = ( diff --git a/packages/beacon-node/test/spec/presets/rewards.test.ts b/packages/beacon-node/test/spec/presets/rewards.test.ts index df43c8ca612e..299bf208eb62 100644 --- a/packages/beacon-node/test/spec/presets/rewards.test.ts +++ b/packages/beacon-node/test/spec/presets/rewards.test.ts @@ -1,17 +1,17 @@ import path from "node:path"; -import {expect} from "vitest"; import {VectorCompositeType} from "@chainsafe/ssz"; +import {ACTIVE_PRESET} from "@lodestar/params"; import {BeaconStateAllForks, beforeProcessEpoch} from "@lodestar/state-transition"; import {getRewardsAndPenalties} from "@lodestar/state-transition/epoch"; import {ssz} from "@lodestar/types"; -import {ACTIVE_PRESET} from "@lodestar/params"; +import {expect} from "vitest"; import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js"; -import {inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; import {getConfig} from "../../utils/config.js"; -import {RunnerType, TestRunnerFn} from "../utils/types.js"; import {assertCorrectProgressiveBalances} from "../config.js"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; +import {inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; import {specTestIterator} from "../utils/specTestIterator.js"; +import {RunnerType, TestRunnerFn} from "../utils/types.js"; const deltasType = new VectorCompositeType(ssz.phase0.Balances, 2); diff --git a/packages/beacon-node/test/spec/presets/sanity.test.ts b/packages/beacon-node/test/spec/presets/sanity.test.ts index cd266483c7f8..223587d63ccc 100644 --- a/packages/beacon-node/test/spec/presets/sanity.test.ts +++ b/packages/beacon-node/test/spec/presets/sanity.test.ts @@ -1,4 +1,5 @@ import path from "node:path"; +import {ACTIVE_PRESET, ForkName} from "@lodestar/params"; import {InputType} from "@lodestar/spec-test-util"; import { BeaconStateAllForks, @@ -8,15 +9,14 @@ import { stateTransition, } from "@lodestar/state-transition"; import {SignedBeaconBlock, deneb, ssz} from "@lodestar/types"; -import {ACTIVE_PRESET, ForkName} from "@lodestar/params"; import {bnToNum} from "@lodestar/utils"; import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js"; -import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; -import {RunnerType, shouldVerify, TestRunnerFn} from "../utils/types.js"; import {getConfig} from "../../utils/config.js"; import {assertCorrectProgressiveBalances} from "../config.js"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; +import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; import {specTestIterator} from "../utils/specTestIterator.js"; +import {RunnerType, TestRunnerFn, shouldVerify} from "../utils/types.js"; const sanity: TestRunnerFn = (fork, testName, testSuite) => { switch (testName) { diff --git a/packages/beacon-node/test/spec/presets/shuffling.test.ts b/packages/beacon-node/test/spec/presets/shuffling.test.ts index 7b0f38ecf581..ad5fff527bac 100644 --- a/packages/beacon-node/test/spec/presets/shuffling.test.ts +++ b/packages/beacon-node/test/spec/presets/shuffling.test.ts @@ -1,11 +1,11 @@ import path from "node:path"; import {unshuffleList} from "@chainsafe/swap-or-not-shuffle"; +import {ACTIVE_PRESET, SHUFFLE_ROUND_COUNT} from "@lodestar/params"; import {InputType} from "@lodestar/spec-test-util"; import {bnToNum, fromHex} from "@lodestar/utils"; -import {ACTIVE_PRESET, SHUFFLE_ROUND_COUNT} from "@lodestar/params"; -import {RunnerType, TestRunnerFn} from "../utils/types.js"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; import {specTestIterator} from "../utils/specTestIterator.js"; +import {RunnerType, TestRunnerFn} from "../utils/types.js"; const shuffling: TestRunnerFn = () => { return { diff --git a/packages/beacon-node/test/spec/presets/ssz_static.test.ts b/packages/beacon-node/test/spec/presets/ssz_static.test.ts index f5cdcc719b6a..34a252052f65 100644 --- a/packages/beacon-node/test/spec/presets/ssz_static.test.ts +++ b/packages/beacon-node/test/spec/presets/ssz_static.test.ts @@ -1,14 +1,14 @@ import fs from "node:fs"; import path from "node:path"; -import {expect, it, vi} from "vitest"; import {Type} from "@chainsafe/ssz"; -import {ssz, sszTypesFor} from "@lodestar/types"; import {ACTIVE_PRESET, ForkName} from "@lodestar/params"; +import {ssz, sszTypesFor} from "@lodestar/types"; +import {expect, it, vi} from "vitest"; +import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; import {replaceUintTypeWithUintBigintType} from "../utils/replaceUintTypeWithUintBigintType.js"; -import {parseSszStaticTestcase} from "../utils/sszTestCaseParser.js"; import {runValidSszTest} from "../utils/runValidSszTest.js"; -import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; import {specTestIterator} from "../utils/specTestIterator.js"; +import {parseSszStaticTestcase} from "../utils/sszTestCaseParser.js"; import {RunnerType} from "../utils/types.js"; // ssz_static diff --git a/packages/beacon-node/test/spec/presets/transition.test.ts b/packages/beacon-node/test/spec/presets/transition.test.ts index 76ad772f8dfb..0b1aa1b522e5 100644 --- a/packages/beacon-node/test/spec/presets/transition.test.ts +++ b/packages/beacon-node/test/spec/presets/transition.test.ts @@ -1,4 +1,7 @@ import path from "node:path"; +import {ChainConfig, createChainForkConfig} from "@lodestar/config"; +import {config} from "@lodestar/config/default"; +import {ACTIVE_PRESET, ForkName} from "@lodestar/params"; import { BeaconStateAllForks, DataAvailableStatus, @@ -6,16 +9,13 @@ import { stateTransition, } from "@lodestar/state-transition"; import {SignedBeaconBlock, ssz} from "@lodestar/types"; -import {createChainForkConfig, ChainConfig} from "@lodestar/config"; -import {ACTIVE_PRESET, ForkName} from "@lodestar/params"; import {bnToNum} from "@lodestar/utils"; -import {config} from "@lodestar/config/default"; -import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js"; -import {RunnerType, TestRunnerFn} from "../utils/types.js"; import {assertCorrectProgressiveBalances} from "../config.js"; import {ethereumConsensusSpecsTests} from "../specTestVersioning.js"; +import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js"; import {specTestIterator} from "../utils/specTestIterator.js"; +import {RunnerType, TestRunnerFn} from "../utils/types.js"; import {getPreviousFork} from "./fork.test.js"; const transition = diff --git a/packages/beacon-node/test/spec/utils/expectEqualBeaconState.ts b/packages/beacon-node/test/spec/utils/expectEqualBeaconState.ts index 160310160054..a3f6cc149148 100644 --- a/packages/beacon-node/test/spec/utils/expectEqualBeaconState.ts +++ b/packages/beacon-node/test/spec/utils/expectEqualBeaconState.ts @@ -1,8 +1,8 @@ -import {expect} from "vitest"; -import {SSZTypesFor, ssz} from "@lodestar/types"; import {ForkAll, ForkName} from "@lodestar/params"; import {InputType} from "@lodestar/spec-test-util"; import {BeaconStateAllForks} from "@lodestar/state-transition"; +import {SSZTypesFor, ssz} from "@lodestar/types"; +import {expect} from "vitest"; /** Compare each field in BeaconState to help debug failed test easier. */ export function expectEqualBeaconState( diff --git a/packages/beacon-node/test/spec/utils/replaceUintTypeWithUintBigintType.ts b/packages/beacon-node/test/spec/utils/replaceUintTypeWithUintBigintType.ts index 8e0063291d98..356d384e5f6a 100644 --- a/packages/beacon-node/test/spec/utils/replaceUintTypeWithUintBigintType.ts +++ b/packages/beacon-node/test/spec/utils/replaceUintTypeWithUintBigintType.ts @@ -1,12 +1,12 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */ import { - Type, - UintNumberType, - UintBigintType, ContainerType, ListBasicType, ListCompositeType, + Type, + UintBigintType, + UintNumberType, VectorBasicType, VectorCompositeType, } from "@chainsafe/ssz"; diff --git a/packages/beacon-node/test/spec/utils/runValidSszTest.ts b/packages/beacon-node/test/spec/utils/runValidSszTest.ts index a8d3060af08d..03c4e543f276 100644 --- a/packages/beacon-node/test/spec/utils/runValidSszTest.ts +++ b/packages/beacon-node/test/spec/utils/runValidSszTest.ts @@ -1,6 +1,6 @@ -import {expect} from "vitest"; import {Node} from "@chainsafe/persistent-merkle-tree"; -import {Type, CompositeType, fromHexString, toHexString} from "@chainsafe/ssz"; +import {CompositeType, Type, fromHexString, toHexString} from "@chainsafe/ssz"; +import {expect} from "vitest"; type ValidTestCaseData = { root: string; diff --git a/packages/beacon-node/test/spec/utils/specTestIterator.ts b/packages/beacon-node/test/spec/utils/specTestIterator.ts index d8b4f9c0574c..0868183295cf 100644 --- a/packages/beacon-node/test/spec/utils/specTestIterator.ts +++ b/packages/beacon-node/test/spec/utils/specTestIterator.ts @@ -1,8 +1,8 @@ import fs from "node:fs"; import path from "node:path"; -import {describe, it} from "vitest"; import {ForkName} from "@lodestar/params"; import {describeDirectorySpecTest} from "@lodestar/spec-test-util"; +import {describe, it} from "vitest"; import {RunnerType, TestRunner} from "./types.js"; const ARTIFACT_FILENAMES = new Set([ diff --git a/packages/beacon-node/test/spec/utils/sszTestCaseParser.ts b/packages/beacon-node/test/spec/utils/sszTestCaseParser.ts index d4108a2eb011..f594a5b88193 100644 --- a/packages/beacon-node/test/spec/utils/sszTestCaseParser.ts +++ b/packages/beacon-node/test/spec/utils/sszTestCaseParser.ts @@ -1,8 +1,8 @@ -import path from "node:path"; import fs from "node:fs"; -import {uncompress} from "snappyjs"; -import jsyaml from "js-yaml"; +import path from "node:path"; import {loadYaml} from "@lodestar/utils"; +import jsyaml from "js-yaml"; +import {uncompress} from "snappyjs"; /* eslint-disable @typescript-eslint/explicit-function-return-type */ diff --git a/packages/beacon-node/test/unit-mainnet/network/gossip/scoringParameters.test.ts b/packages/beacon-node/test/unit-mainnet/network/gossip/scoringParameters.test.ts index b3137755857f..bf9e92ee2ddd 100644 --- a/packages/beacon-node/test/unit-mainnet/network/gossip/scoringParameters.test.ts +++ b/packages/beacon-node/test/unit-mainnet/network/gossip/scoringParameters.test.ts @@ -1,12 +1,12 @@ -import {describe, it, expect} from "vitest"; import {TopicScoreParams} from "@chainsafe/libp2p-gossipsub/score"; -import {ATTESTATION_SUBNET_COUNT, ForkName, SLOTS_PER_EPOCH} from "@lodestar/params"; import {createBeaconConfig} from "@lodestar/config"; import {mainnetChainConfig} from "@lodestar/config/configs"; +import {ATTESTATION_SUBNET_COUNT, ForkName, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {describe, expect, it} from "vitest"; +import {ZERO_HASH} from "../../../../src/constants/index.js"; import {computeGossipPeerScoreParams, gossipScoreThresholds} from "../../../../src/network/gossip/scoringParameters.js"; import {stringifyGossipTopic} from "../../../../src/network/gossip/topic.js"; import {GossipType} from "../../../../src/network/index.js"; -import {ZERO_HASH} from "../../../../src/constants/index.js"; /** * Refer to Teku tests at diff --git a/packages/beacon-node/test/unit-mainnet/network/subnets/util.test.ts b/packages/beacon-node/test/unit-mainnet/network/subnets/util.test.ts index af12ad3d80e8..5509b51ebd0a 100644 --- a/packages/beacon-node/test/unit-mainnet/network/subnets/util.test.ts +++ b/packages/beacon-node/test/unit-mainnet/network/subnets/util.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {bigIntToBytes} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; import {computeSubscribedSubnet} from "../../../../src/network/subnets/util.js"; describe("computeSubscribedSubnet", () => { diff --git a/packages/beacon-node/test/unit/api/impl/beacon/beacon.test.ts b/packages/beacon-node/test/unit/api/impl/beacon/beacon.test.ts index 99bac5de7ef4..9bfb305b7e7e 100644 --- a/packages/beacon-node/test/unit/api/impl/beacon/beacon.test.ts +++ b/packages/beacon-node/test/unit/api/impl/beacon/beacon.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect, beforeAll} from "vitest"; import {phase0} from "@lodestar/types"; -import {ApiTestModules, getApiTestModules} from "../../../../utils/api.js"; +import {beforeAll, describe, expect, it} from "vitest"; import {getBeaconApi} from "../../../../../src/api/impl/beacon/index.js"; +import {ApiTestModules, getApiTestModules} from "../../../../utils/api.js"; import {Mutable} from "../../../../utils/types.js"; describe("beacon api implementation", () => { diff --git a/packages/beacon-node/test/unit/api/impl/beacon/blocks/getBlockHeaders.test.ts b/packages/beacon-node/test/unit/api/impl/beacon/blocks/getBlockHeaders.test.ts index 5e4e8a31ec7f..ce8d770d86ff 100644 --- a/packages/beacon-node/test/unit/api/impl/beacon/blocks/getBlockHeaders.test.ts +++ b/packages/beacon-node/test/unit/api/impl/beacon/blocks/getBlockHeaders.test.ts @@ -1,11 +1,11 @@ import {toHexString} from "@chainsafe/ssz"; -import {describe, it, expect, beforeEach, vi, afterEach} from "vitest"; -import {when} from "vitest-when"; import {routes} from "@lodestar/api"; import {ssz} from "@lodestar/types"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; +import {when} from "vitest-when"; +import {getBeaconBlockApi} from "../../../../../../src/api/impl/beacon/blocks/index.js"; import {ApiTestModules, getApiTestModules} from "../../../../../utils/api.js"; import {generateProtoBlock, generateSignedBlockAtSlot} from "../../../../../utils/typeGenerator.js"; -import {getBeaconBlockApi} from "../../../../../../src/api/impl/beacon/blocks/index.js"; describe("api - beacon - getBlockHeaders", () => { let modules: ApiTestModules; diff --git a/packages/beacon-node/test/unit/api/impl/beacon/state/utils.test.ts b/packages/beacon-node/test/unit/api/impl/beacon/state/utils.test.ts index 958093ffba6d..149e0236c448 100644 --- a/packages/beacon-node/test/unit/api/impl/beacon/state/utils.test.ts +++ b/packages/beacon-node/test/unit/api/impl/beacon/state/utils.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {toHexString} from "@chainsafe/ssz"; +import {describe, expect, it} from "vitest"; import {getStateValidatorIndex} from "../../../../../../src/api/impl/beacon/state/utils.js"; import {generateCachedAltairState} from "../../../../../utils/state.js"; diff --git a/packages/beacon-node/test/unit/api/impl/config/config.test.ts b/packages/beacon-node/test/unit/api/impl/config/config.test.ts index 7d0adebbea89..8e67d5d6b156 100644 --- a/packages/beacon-node/test/unit/api/impl/config/config.test.ts +++ b/packages/beacon-node/test/unit/api/impl/config/config.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect, beforeEach} from "vitest"; import {routes} from "@lodestar/api"; import {config} from "@lodestar/config/default"; +import {beforeEach, describe, expect, it} from "vitest"; import {getConfigApi, renderJsonSpec} from "../../../../../src/api/impl/config/index.js"; describe("config api implementation", () => { diff --git a/packages/beacon-node/test/unit/api/impl/events/events.test.ts b/packages/beacon-node/test/unit/api/impl/events/events.test.ts index 5b1686d42f57..cd42945830bc 100644 --- a/packages/beacon-node/test/unit/api/impl/events/events.test.ts +++ b/packages/beacon-node/test/unit/api/impl/events/events.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect, beforeEach, afterEach, vi, MockedObject} from "vitest"; import {routes} from "@lodestar/api"; import {config} from "@lodestar/config/default"; import {ssz} from "@lodestar/types"; -import {BeaconChain, ChainEventEmitter, HeadEventData} from "../../../../../src/chain/index.js"; +import {MockedObject, afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {getEventsApi} from "../../../../../src/api/impl/events/index.js"; +import {BeaconChain, ChainEventEmitter, HeadEventData} from "../../../../../src/chain/index.js"; import {ZERO_HASH_HEX} from "../../../../../src/constants/constants.js"; vi.mock("../../../../../src/chain/index.js", async (importActual) => { diff --git a/packages/beacon-node/test/unit/api/impl/swaggerUI.test.ts b/packages/beacon-node/test/unit/api/impl/swaggerUI.test.ts index 7ae2382e6404..1b7aecb0a234 100644 --- a/packages/beacon-node/test/unit/api/impl/swaggerUI.test.ts +++ b/packages/beacon-node/test/unit/api/impl/swaggerUI.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {getFavicon, getLogo} from "../../../../src/api/rest/swaggerUI.js"; describe("swaggerUI", () => { diff --git a/packages/beacon-node/test/unit/api/impl/validator/duties/proposer.test.ts b/packages/beacon-node/test/unit/api/impl/validator/duties/proposer.test.ts index b954f983adcc..66cc4f79407d 100644 --- a/packages/beacon-node/test/unit/api/impl/validator/duties/proposer.test.ts +++ b/packages/beacon-node/test/unit/api/impl/validator/duties/proposer.test.ts @@ -1,17 +1,17 @@ -import {describe, it, expect, beforeEach, afterEach, vi} from "vitest"; import {routes} from "@lodestar/api"; import {config} from "@lodestar/config/default"; import {MAX_EFFECTIVE_BALANCE, SLOTS_PER_EPOCH} from "@lodestar/params"; import {BeaconStateAllForks} from "@lodestar/state-transition"; import {Slot} from "@lodestar/types"; -import {ApiTestModules, getApiTestModules} from "../../../../../utils/api.js"; -import {FAR_FUTURE_EPOCH} from "../../../../../../src/constants/index.js"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {SYNC_TOLERANCE_EPOCHS, getValidatorApi} from "../../../../../../src/api/impl/validator/index.js"; +import {defaultApiOptions} from "../../../../../../src/api/options.js"; +import {FAR_FUTURE_EPOCH} from "../../../../../../src/constants/index.js"; +import {SyncState} from "../../../../../../src/sync/interface.js"; +import {ApiTestModules, getApiTestModules} from "../../../../../utils/api.js"; +import {createCachedBeaconStateTest} from "../../../../../utils/cachedBeaconState.js"; import {generateState, zeroProtoBlock} from "../../../../../utils/state.js"; import {generateValidators} from "../../../../../utils/validator.js"; -import {createCachedBeaconStateTest} from "../../../../../utils/cachedBeaconState.js"; -import {SyncState} from "../../../../../../src/sync/interface.js"; -import {defaultApiOptions} from "../../../../../../src/api/options.js"; describe("get proposers api impl", () => { const currentEpoch = 2; diff --git a/packages/beacon-node/test/unit/api/impl/validator/produceAttestationData.test.ts b/packages/beacon-node/test/unit/api/impl/validator/produceAttestationData.test.ts index fdbfec5ac503..0486c3489800 100644 --- a/packages/beacon-node/test/unit/api/impl/validator/produceAttestationData.test.ts +++ b/packages/beacon-node/test/unit/api/impl/validator/produceAttestationData.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect, beforeEach, vi} from "vitest"; import {ProtoBlock} from "@lodestar/fork-choice"; -import {SyncState} from "../../../../../src/sync/interface.js"; -import {ApiTestModules, getApiTestModules} from "../../../../utils/api.js"; +import {beforeEach, describe, expect, it, vi} from "vitest"; import {getValidatorApi} from "../../../../../src/api/impl/validator/index.js"; import {defaultApiOptions} from "../../../../../src/api/options.js"; +import {SyncState} from "../../../../../src/sync/interface.js"; +import {ApiTestModules, getApiTestModules} from "../../../../utils/api.js"; describe("api - validator - produceAttestationData", () => { let modules: ApiTestModules; diff --git a/packages/beacon-node/test/unit/api/impl/validator/produceBlockV2.test.ts b/packages/beacon-node/test/unit/api/impl/validator/produceBlockV2.test.ts index 306b18481c1f..52f600b7174c 100644 --- a/packages/beacon-node/test/unit/api/impl/validator/produceBlockV2.test.ts +++ b/packages/beacon-node/test/unit/api/impl/validator/produceBlockV2.test.ts @@ -1,20 +1,20 @@ import {fromHexString, toHexString} from "@chainsafe/ssz"; -import {describe, it, expect, beforeEach, afterEach, vi} from "vitest"; -import {ssz} from "@lodestar/types"; import {ProtoBlock} from "@lodestar/fork-choice"; import {ForkName} from "@lodestar/params"; -import {computeTimeAtSlot, CachedBeaconStateBellatrix} from "@lodestar/state-transition"; -import {ApiTestModules, getApiTestModules} from "../../../../utils/api.js"; -import {SyncState} from "../../../../../src/sync/interface.js"; +import {CachedBeaconStateBellatrix, computeTimeAtSlot} from "@lodestar/state-transition"; +import {ssz} from "@lodestar/types"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {getValidatorApi} from "../../../../../src/api/impl/validator/index.js"; +import {defaultApiOptions} from "../../../../../src/api/options.js"; import {BeaconChain} from "../../../../../src/chain/index.js"; -import {generateCachedBellatrixState} from "../../../../utils/state.js"; +import {BlockType, produceBlockBody} from "../../../../../src/chain/produceBlock/produceBlockBody.js"; +import {ZERO_HASH_HEX} from "../../../../../src/constants/index.js"; import {PayloadIdCache} from "../../../../../src/execution/engine/payloadIdCache.js"; +import {SyncState} from "../../../../../src/sync/interface.js"; import {toGraffitiBuffer} from "../../../../../src/util/graffiti.js"; -import {BlockType, produceBlockBody} from "../../../../../src/chain/produceBlock/produceBlockBody.js"; +import {ApiTestModules, getApiTestModules} from "../../../../utils/api.js"; +import {generateCachedBellatrixState} from "../../../../utils/state.js"; import {generateProtoBlock} from "../../../../utils/typeGenerator.js"; -import {ZERO_HASH_HEX} from "../../../../../src/constants/index.js"; -import {defaultApiOptions} from "../../../../../src/api/options.js"; describe("api/validator - produceBlockV2", () => { let api: ReturnType; diff --git a/packages/beacon-node/test/unit/api/impl/validator/produceBlockV3.test.ts b/packages/beacon-node/test/unit/api/impl/validator/produceBlockV3.test.ts index f705e4b38e14..a93529aa4858 100644 --- a/packages/beacon-node/test/unit/api/impl/validator/produceBlockV3.test.ts +++ b/packages/beacon-node/test/unit/api/impl/validator/produceBlockV3.test.ts @@ -1,16 +1,16 @@ -import {describe, it, expect, beforeEach, afterEach, vi} from "vitest"; import {toHexString} from "@chainsafe/ssz"; -import {ssz} from "@lodestar/types"; -import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {routes} from "@lodestar/api"; import {createBeaconConfig, createChainForkConfig, defaultChainConfig} from "@lodestar/config"; import {ProtoBlock} from "@lodestar/fork-choice"; -import {ApiTestModules, getApiTestModules} from "../../../../utils/api.js"; -import {SyncState} from "../../../../../src/sync/interface.js"; +import {SLOTS_PER_EPOCH} from "@lodestar/params"; +import {ssz} from "@lodestar/types"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {getValidatorApi} from "../../../../../src/api/impl/validator/index.js"; +import {defaultApiOptions} from "../../../../../src/api/options.js"; import {CommonBlockBody} from "../../../../../src/chain/interface.js"; +import {SyncState} from "../../../../../src/sync/interface.js"; +import {ApiTestModules, getApiTestModules} from "../../../../utils/api.js"; import {zeroProtoBlock} from "../../../../utils/state.js"; -import {defaultApiOptions} from "../../../../../src/api/options.js"; describe("api/validator - produceBlockV3", () => { let modules: ApiTestModules; diff --git a/packages/beacon-node/test/unit/api/impl/validator/utils.test.ts b/packages/beacon-node/test/unit/api/impl/validator/utils.test.ts index 32ef5be5d213..2579fe3224b1 100644 --- a/packages/beacon-node/test/unit/api/impl/validator/utils.test.ts +++ b/packages/beacon-node/test/unit/api/impl/validator/utils.test.ts @@ -1,7 +1,7 @@ import {toHexString} from "@chainsafe/ssz"; -import {describe, it, expect, beforeAll} from "vitest"; -import {BLSPubkey, ssz, ValidatorIndex} from "@lodestar/types"; import {BeaconStateAllForks} from "@lodestar/state-transition"; +import {BLSPubkey, ValidatorIndex, ssz} from "@lodestar/types"; +import {beforeAll, describe, expect, it} from "vitest"; import {getPubkeysForIndices} from "../../../../../src/api/impl/validator/utils.js"; describe("api / impl / validator / utils", () => { diff --git a/packages/beacon-node/test/unit/chain/archive/blockArchiver.test.ts b/packages/beacon-node/test/unit/chain/archive/blockArchiver.test.ts index dc7c9bb75291..f34e2c85f1a1 100644 --- a/packages/beacon-node/test/unit/chain/archive/blockArchiver.test.ts +++ b/packages/beacon-node/test/unit/chain/archive/blockArchiver.test.ts @@ -1,13 +1,13 @@ import {fromHexString, toHexString} from "@chainsafe/ssz"; -import {describe, it, expect, beforeEach, vi, afterEach} from "vitest"; -import {ssz} from "@lodestar/types"; import {config} from "@lodestar/config/default"; -import {ZERO_HASH_HEX} from "../../../../src/constants/index.js"; -import {generateProtoBlock} from "../../../utils/typeGenerator.js"; -import {testLogger} from "../../../utils/logger.js"; +import {ssz} from "@lodestar/types"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {archiveBlocks} from "../../../../src/chain/archiver/archiveBlocks.js"; -import {MockedBeaconDb, getMockedBeaconDb} from "../../../mocks/mockedBeaconDb.js"; +import {ZERO_HASH_HEX} from "../../../../src/constants/index.js"; import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; +import {MockedBeaconDb, getMockedBeaconDb} from "../../../mocks/mockedBeaconDb.js"; +import {testLogger} from "../../../utils/logger.js"; +import {generateProtoBlock} from "../../../utils/typeGenerator.js"; describe("block archiver task", () => { const logger = testLogger(); diff --git a/packages/beacon-node/test/unit/chain/archive/nonCheckpoint.test.ts b/packages/beacon-node/test/unit/chain/archive/nonCheckpoint.test.ts index c58a873fe1db..c3dc5f031893 100644 --- a/packages/beacon-node/test/unit/chain/archive/nonCheckpoint.test.ts +++ b/packages/beacon-node/test/unit/chain/archive/nonCheckpoint.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect, beforeAll} from "vitest"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {Slot} from "@lodestar/types"; +import {beforeAll, describe, expect, it} from "vitest"; import {getNonCheckpointBlocks} from "../../../../src/chain/archiver/archiveBlocks.js"; describe("chain / archive / getNonCheckpointBlocks", () => { diff --git a/packages/beacon-node/test/unit/chain/archive/stateArchiver.test.ts b/packages/beacon-node/test/unit/chain/archive/stateArchiver.test.ts index cbfba0a362df..80ef6b885ae4 100644 --- a/packages/beacon-node/test/unit/chain/archive/stateArchiver.test.ts +++ b/packages/beacon-node/test/unit/chain/archive/stateArchiver.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; +import {describe, expect, it} from "vitest"; import {computeStateSlotsToDelete} from "../../../../src/chain/archiver/strategies/frequencyStateArchiveStrategy.js"; describe("state archiver task", () => { diff --git a/packages/beacon-node/test/unit/chain/beaconProposerCache.ts b/packages/beacon-node/test/unit/chain/beaconProposerCache.ts index b75bbf546a98..96178d508732 100644 --- a/packages/beacon-node/test/unit/chain/beaconProposerCache.ts +++ b/packages/beacon-node/test/unit/chain/beaconProposerCache.ts @@ -1,4 +1,4 @@ -import {expect, describe, it, beforeEach} from "vitest"; +import {beforeEach, describe, expect, it} from "vitest"; import {BeaconProposerCache} from "../../../src/chain/beaconProposerCache.js"; const suggestedFeeRecipient = "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; diff --git a/packages/beacon-node/test/unit/chain/blocks/rejectFirstInvalidResolveAllValid.test.ts b/packages/beacon-node/test/unit/chain/blocks/rejectFirstInvalidResolveAllValid.test.ts index 2e032f558fe2..5de44a532631 100644 --- a/packages/beacon-node/test/unit/chain/blocks/rejectFirstInvalidResolveAllValid.test.ts +++ b/packages/beacon-node/test/unit/chain/blocks/rejectFirstInvalidResolveAllValid.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {rejectFirstInvalidResolveAllValid} from "../../../../src/chain/blocks/verifyBlocksSignatures.js"; /* eslint-disable @typescript-eslint/explicit-function-return-type */ diff --git a/packages/beacon-node/test/unit/chain/blocks/verifyBlocksSanityChecks.test.ts b/packages/beacon-node/test/unit/chain/blocks/verifyBlocksSanityChecks.test.ts index 1296a79d5eab..48ffe51e4636 100644 --- a/packages/beacon-node/test/unit/chain/blocks/verifyBlocksSanityChecks.test.ts +++ b/packages/beacon-node/test/unit/chain/blocks/verifyBlocksSanityChecks.test.ts @@ -1,17 +1,17 @@ -import {describe, it, expect, beforeEach} from "vitest"; +import {ChainForkConfig} from "@lodestar/config"; import {config} from "@lodestar/config/default"; import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice"; import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; -import {toHex} from "@lodestar/utils"; -import {ChainForkConfig} from "@lodestar/config"; import {SignedBeaconBlock, Slot, ssz} from "@lodestar/types"; +import {toHex} from "@lodestar/utils"; +import {beforeEach, describe, expect, it} from "vitest"; +import {BlockSource, getBlockInput} from "../../../../src/chain/blocks/types.js"; import {verifyBlocksSanityChecks as verifyBlocksImportSanityChecks} from "../../../../src/chain/blocks/verifyBlocksSanityChecks.js"; import {BlockErrorCode} from "../../../../src/chain/errors/index.js"; -import {expectThrowsLodestarError} from "../../../utils/errors.js"; import {IClock} from "../../../../src/util/clock.js"; import {ClockStopped} from "../../../mocks/clock.js"; -import {BlockSource, getBlockInput} from "../../../../src/chain/blocks/types.js"; import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; +import {expectThrowsLodestarError} from "../../../utils/errors.js"; describe("chain / blocks / verifyBlocksSanityChecks", () => { let forkChoice: MockedBeaconChain["forkChoice"]; diff --git a/packages/beacon-node/test/unit/chain/bls/bls.test.ts b/packages/beacon-node/test/unit/chain/bls/bls.test.ts index 137f2c4dd9df..fbc602785a68 100644 --- a/packages/beacon-node/test/unit/chain/bls/bls.test.ts +++ b/packages/beacon-node/test/unit/chain/bls/bls.test.ts @@ -1,8 +1,8 @@ -import {describe, it, expect, beforeEach} from "vitest"; import {PublicKey, SecretKey, Signature} from "@chainsafe/blst"; import {ISignatureSet, SignatureSetType} from "@lodestar/state-transition"; -import {BlsSingleThreadVerifier} from "../../../../src/chain/bls/singleThread.js"; +import {beforeEach, describe, expect, it} from "vitest"; import {BlsMultiThreadWorkerPool} from "../../../../src/chain/bls/multithread/index.js"; +import {BlsSingleThreadVerifier} from "../../../../src/chain/bls/singleThread.js"; import {testLogger} from "../../../utils/logger.js"; describe("BlsVerifier ", () => { diff --git a/packages/beacon-node/test/unit/chain/bls/utils.test.ts b/packages/beacon-node/test/unit/chain/bls/utils.test.ts index d492a36b4d56..5e5259b8649f 100644 --- a/packages/beacon-node/test/unit/chain/bls/utils.test.ts +++ b/packages/beacon-node/test/unit/chain/bls/utils.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {chunkifyMaximizeChunkSize} from "../../../../src/chain/bls/multithread/utils.js"; import {linspace} from "../../../../src/util/numpy.js"; diff --git a/packages/beacon-node/test/unit/chain/forkChoice/forkChoice.test.ts b/packages/beacon-node/test/unit/chain/forkChoice/forkChoice.test.ts index 7cb5d23ba296..017e46f6294b 100644 --- a/packages/beacon-node/test/unit/chain/forkChoice/forkChoice.test.ts +++ b/packages/beacon-node/test/unit/chain/forkChoice/forkChoice.test.ts @@ -1,7 +1,6 @@ import {toHexString} from "@chainsafe/ssz"; -import {describe, it, expect, beforeEach, beforeAll, vi} from "vitest"; import {config} from "@lodestar/config/default"; -import {CheckpointWithHex, ExecutionStatus, ForkChoice, DataAvailabilityStatus} from "@lodestar/fork-choice"; +import {CheckpointWithHex, DataAvailabilityStatus, ExecutionStatus, ForkChoice} from "@lodestar/fork-choice"; import {FAR_FUTURE_EPOCH, MAX_EFFECTIVE_BALANCE} from "@lodestar/params"; import { CachedBeaconStateAllForks, @@ -9,12 +8,13 @@ import { computeEpochAtSlot, getEffectiveBalanceIncrementsZeroed, } from "@lodestar/state-transition"; -import {phase0, Slot, ssz, ValidatorIndex} from "@lodestar/types"; import {getTemporaryBlockHeader, processSlots} from "@lodestar/state-transition"; +import {Slot, ValidatorIndex, phase0, ssz} from "@lodestar/types"; +import {beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; import {ChainEventEmitter, initializeForkChoice} from "../../../../src/chain/index.js"; -import {generateSignedBlockAtSlot} from "../../../utils/typeGenerator.js"; import {createCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js"; import {generateState} from "../../../utils/state.js"; +import {generateSignedBlockAtSlot} from "../../../utils/typeGenerator.js"; import {generateValidators} from "../../../utils/validator.js"; // We mock this package globally diff --git a/packages/beacon-node/test/unit/chain/genesis/genesis.test.ts b/packages/beacon-node/test/unit/chain/genesis/genesis.test.ts index 40570fcd26e1..40c76bb48045 100644 --- a/packages/beacon-node/test/unit/chain/genesis/genesis.test.ts +++ b/packages/beacon-node/test/unit/chain/genesis/genesis.test.ts @@ -1,15 +1,15 @@ -import {toHexString} from "@chainsafe/ssz"; -import {describe, it, expect} from "vitest"; import {PublicKey, SecretKey} from "@chainsafe/blst"; -import {DOMAIN_DEPOSIT, MAX_EFFECTIVE_BALANCE} from "@lodestar/params"; +import {toHexString} from "@chainsafe/ssz"; import {config} from "@lodestar/config/default"; -import {computeDomain, computeSigningRoot, interopSecretKey, ZERO_HASH} from "@lodestar/state-transition"; +import {DOMAIN_DEPOSIT, MAX_EFFECTIVE_BALANCE} from "@lodestar/params"; +import {ZERO_HASH, computeDomain, computeSigningRoot, interopSecretKey} from "@lodestar/state-transition"; import {ValidatorIndex, phase0, ssz} from "@lodestar/types"; import {ErrorAborted} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; import {GenesisBuilder} from "../../../../src/chain/genesis/genesis.js"; -import {testLogger} from "../../../utils/logger.js"; import {ZERO_HASH_HEX} from "../../../../src/constants/index.js"; import {Eth1ProviderState, EthJsonRpcBlockRaw, IEth1Provider} from "../../../../src/eth1/interface.js"; +import {testLogger} from "../../../utils/logger.js"; describe("genesis builder", () => { const logger = testLogger(); diff --git a/packages/beacon-node/test/unit/chain/lightclient/proof.test.ts b/packages/beacon-node/test/unit/chain/lightclient/proof.test.ts index b30e0f9a9ddb..1ae4812ea200 100644 --- a/packages/beacon-node/test/unit/chain/lightclient/proof.test.ts +++ b/packages/beacon-node/test/unit/chain/lightclient/proof.test.ts @@ -1,8 +1,8 @@ -import {describe, it, expect, beforeAll} from "vitest"; -import {BeaconStateAltair} from "@lodestar/state-transition"; import {SYNC_COMMITTEE_SIZE} from "@lodestar/params"; +import {BeaconStateAltair} from "@lodestar/state-transition"; import {altair, ssz} from "@lodestar/types"; -import {verifyMerkleBranch, hash} from "@lodestar/utils"; +import {hash, verifyMerkleBranch} from "@lodestar/utils"; +import {beforeAll, describe, expect, it} from "vitest"; import {getNextSyncCommitteeBranch, getSyncCommitteesWitness} from "../../../../src/chain/lightClient/proofs.js"; const currentSyncCommitteeGindex = 54; diff --git a/packages/beacon-node/test/unit/chain/lightclient/upgradeLightClientHeader.test.ts b/packages/beacon-node/test/unit/chain/lightclient/upgradeLightClientHeader.test.ts index 3c2f5a664c77..9e602040b315 100644 --- a/packages/beacon-node/test/unit/chain/lightclient/upgradeLightClientHeader.test.ts +++ b/packages/beacon-node/test/unit/chain/lightclient/upgradeLightClientHeader.test.ts @@ -1,8 +1,8 @@ -import {describe, it, expect, beforeEach} from "vitest"; -import {LightClientHeader, ssz} from "@lodestar/types"; -import {ForkName, ForkSeq} from "@lodestar/params"; import {createBeaconConfig, createChainForkConfig, defaultChainConfig} from "@lodestar/config"; import {upgradeLightClientHeader} from "@lodestar/light-client/spec"; +import {ForkName, ForkSeq} from "@lodestar/params"; +import {LightClientHeader, ssz} from "@lodestar/types"; +import {beforeEach, describe, expect, it} from "vitest"; describe("UpgradeLightClientHeader", () => { let lcHeaderByFork: Record; 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 8742d7da9147..b5bfe191a9f3 100644 --- a/packages/beacon-node/test/unit/chain/opPools/aggregatedAttestationPool.test.ts +++ b/packages/beacon-node/test/unit/chain/opPools/aggregatedAttestationPool.test.ts @@ -1,7 +1,6 @@ +import {SecretKey, Signature, aggregateSignatures, fastAggregateVerify} from "@chainsafe/blst"; import {BitArray, fromHexString, toHexString} from "@chainsafe/ssz"; -import {describe, it, expect, beforeEach, beforeAll, afterEach, vi} from "vitest"; -import {SecretKey, Signature, fastAggregateVerify, aggregateSignatures} from "@chainsafe/blst"; -import {CachedBeaconStateAllForks, newFilledArray} from "@lodestar/state-transition"; +import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; import { FAR_FUTURE_EPOCH, ForkName, @@ -9,23 +8,24 @@ import { MAX_EFFECTIVE_BALANCE, SLOTS_PER_EPOCH, } from "@lodestar/params"; -import {ssz, phase0} from "@lodestar/types"; +import {CachedBeaconStateAllForks, newFilledArray} from "@lodestar/state-transition"; import {CachedBeaconStateAltair} from "@lodestar/state-transition/src/types.js"; -import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; -import {MockedForkChoice, getMockedForkChoice} from "../../../mocks/mockedBeaconChain.js"; +import {phase0, ssz} from "@lodestar/types"; +import {afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; import { - aggregateConsolidation, AggregatedAttestationPool, - aggregateInto, AttestationsConsolidation, - getNotSeenValidatorsFn, MatchingDataAttestationGroup, + aggregateConsolidation, + aggregateInto, + getNotSeenValidatorsFn, } from "../../../../src/chain/opPools/aggregatedAttestationPool.js"; import {InsertOutcome} from "../../../../src/chain/opPools/types.js"; +import {ZERO_HASH_HEX} from "../../../../src/constants/constants.js"; import {linspace} from "../../../../src/util/numpy.js"; -import {generateCachedAltairState} from "../../../utils/state.js"; +import {MockedForkChoice, getMockedForkChoice} from "../../../mocks/mockedBeaconChain.js"; import {renderBitArray} from "../../../utils/render.js"; -import {ZERO_HASH_HEX} from "../../../../src/constants/constants.js"; +import {generateCachedAltairState} from "../../../utils/state.js"; import {generateProtoBlock} from "../../../utils/typeGenerator.js"; import {generateValidators} from "../../../utils/validator.js"; diff --git a/packages/beacon-node/test/unit/chain/opPools/attestationPool.test.ts b/packages/beacon-node/test/unit/chain/opPools/attestationPool.test.ts index 98453efaa3b6..fd22f9a7c6a5 100644 --- a/packages/beacon-node/test/unit/chain/opPools/attestationPool.test.ts +++ b/packages/beacon-node/test/unit/chain/opPools/attestationPool.test.ts @@ -1,10 +1,10 @@ import {fromHexString, toHexString} from "@chainsafe/ssz"; -import {describe, it, expect, beforeEach, vi} from "vitest"; +import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; import {GENESIS_SLOT, SLOTS_PER_EPOCH} from "@lodestar/params"; import {ssz} from "@lodestar/types"; -import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; -import {InsertOutcome} from "../../../../src/chain/opPools/types.js"; +import {beforeEach, describe, expect, it, vi} from "vitest"; import {AttestationPool} from "../../../../src/chain/opPools/attestationPool.js"; +import {InsertOutcome} from "../../../../src/chain/opPools/types.js"; import {getMockedClock} from "../../../mocks/clock.js"; /** Valid signature of random data to prevent BLS errors */ diff --git a/packages/beacon-node/test/unit/chain/opPools/syncCommittee.test.ts b/packages/beacon-node/test/unit/chain/opPools/syncCommittee.test.ts index e91eaa58aa73..9af19cc84c71 100644 --- a/packages/beacon-node/test/unit/chain/opPools/syncCommittee.test.ts +++ b/packages/beacon-node/test/unit/chain/opPools/syncCommittee.test.ts @@ -1,7 +1,7 @@ -import {toHexString} from "@chainsafe/ssz"; -import {describe, it, expect, beforeEach, beforeAll, afterEach, vi, MockedObject} from "vitest"; import {SecretKey} from "@chainsafe/blst"; +import {toHexString} from "@chainsafe/ssz"; import {altair} from "@lodestar/types"; +import {MockedObject, afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; import {SyncCommitteeMessagePool} from "../../../../src/chain/opPools/index.js"; import {Clock} from "../../../../src/util/clock.js"; diff --git a/packages/beacon-node/test/unit/chain/opPools/syncCommitteeContribution.test.ts b/packages/beacon-node/test/unit/chain/opPools/syncCommitteeContribution.test.ts index e1bd60a2305e..c0a639633f37 100644 --- a/packages/beacon-node/test/unit/chain/opPools/syncCommitteeContribution.test.ts +++ b/packages/beacon-node/test/unit/chain/opPools/syncCommitteeContribution.test.ts @@ -1,14 +1,14 @@ -import {BitArray} from "@chainsafe/ssz"; -import {describe, it, expect, beforeEach, beforeAll} from "vitest"; import {SecretKey, Signature, fastAggregateVerify} from "@chainsafe/blst"; +import {BitArray} from "@chainsafe/ssz"; +import {SYNC_COMMITTEE_SIZE, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; import {newFilledArray} from "@lodestar/state-transition"; import {ssz} from "@lodestar/types"; -import {SYNC_COMMITTEE_SIZE, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; +import {beforeAll, beforeEach, describe, expect, it} from "vitest"; import { - aggregate, - replaceIfBetter, SyncContributionAndProofPool, SyncContributionFast, + aggregate, + replaceIfBetter, } from "../../../../src/chain/opPools/syncContributionAndProofPool.js"; import {InsertOutcome} from "../../../../src/chain/opPools/types.js"; import {EMPTY_SIGNATURE} from "../../../../src/constants/index.js"; diff --git a/packages/beacon-node/test/unit/chain/prepareNextSlot.test.ts b/packages/beacon-node/test/unit/chain/prepareNextSlot.test.ts index c7d0a7801fec..fa95a00eebfd 100644 --- a/packages/beacon-node/test/unit/chain/prepareNextSlot.test.ts +++ b/packages/beacon-node/test/unit/chain/prepareNextSlot.test.ts @@ -1,14 +1,14 @@ -import {describe, it, expect, beforeEach, afterEach, vi, Mock, MockInstance} from "vitest"; -import {config} from "@lodestar/config/default"; -import {ForkName, SLOTS_PER_EPOCH} from "@lodestar/params"; import {routes} from "@lodestar/api"; +import {config} from "@lodestar/config/default"; import {ProtoBlock} from "@lodestar/fork-choice"; -import {MockedBeaconChain, getMockedBeaconChain} from "../../mocks/mockedBeaconChain.js"; -import {MockedLogger, getMockedLogger} from "../../mocks/loggerMock.js"; +import {ForkName, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {Mock, MockInstance, afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {IChainOptions} from "../../../src/chain/options.js"; import {PrepareNextSlotScheduler} from "../../../src/chain/prepareNextSlot.js"; -import {generateCachedBellatrixState, zeroProtoBlock} from "../../utils/state.js"; import {PayloadIdCache} from "../../../src/execution/engine/payloadIdCache.js"; +import {MockedLogger, getMockedLogger} from "../../mocks/loggerMock.js"; +import {MockedBeaconChain, getMockedBeaconChain} from "../../mocks/mockedBeaconChain.js"; +import {generateCachedBellatrixState, zeroProtoBlock} from "../../utils/state.js"; describe("PrepareNextSlot scheduler", () => { const abortController = new AbortController(); diff --git a/packages/beacon-node/test/unit/chain/reprocess.test.ts b/packages/beacon-node/test/unit/chain/reprocess.test.ts index 927e4cf8d05f..339dc20de27f 100644 --- a/packages/beacon-node/test/unit/chain/reprocess.test.ts +++ b/packages/beacon-node/test/unit/chain/reprocess.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, beforeEach} from "vitest"; +import {beforeEach, describe, expect, it} from "vitest"; import {ReprocessController} from "../../../src/chain/reprocess.js"; describe("ReprocessController", () => { diff --git a/packages/beacon-node/test/unit/chain/rewards/blockRewards.test.ts b/packages/beacon-node/test/unit/chain/rewards/blockRewards.test.ts index d417d83e2da9..ec42395641f4 100644 --- a/packages/beacon-node/test/unit/chain/rewards/blockRewards.test.ts +++ b/packages/beacon-node/test/unit/chain/rewards/blockRewards.test.ts @@ -1,17 +1,17 @@ -import {describe, it, expect} from "vitest"; import {SYNC_COMMITTEE_SIZE} from "@lodestar/params"; -import {ssz} from "@lodestar/types"; import { CachedBeaconStateAllForks, DataAvailableStatus, ExecutionPayloadStatus, stateTransition, } from "@lodestar/state-transition"; +import {ssz} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; +import {BlockAltairOpts, getBlockAltair} from "../../../../../state-transition/test/perf/block/util.js"; import { - generatePerfTestCachedStateAltair, cachedStateAltairPopulateCaches, + generatePerfTestCachedStateAltair, } from "../../../../../state-transition/test/perf/util.js"; -import {BlockAltairOpts, getBlockAltair} from "../../../../../state-transition/test/perf/block/util.js"; import {computeBlockRewards} from "../../../../src/chain/rewards/blockRewards.js"; describe("chain / rewards / blockRewards", () => { diff --git a/packages/beacon-node/test/unit/chain/seenCache/aggregateAndProof.test.ts b/packages/beacon-node/test/unit/chain/seenCache/aggregateAndProof.test.ts index d83433a649ca..c69004ac98b9 100644 --- a/packages/beacon-node/test/unit/chain/seenCache/aggregateAndProof.test.ts +++ b/packages/beacon-node/test/unit/chain/seenCache/aggregateAndProof.test.ts @@ -1,9 +1,9 @@ import {BitArray} from "@chainsafe/ssz"; -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { AggregationInfo, - insertDesc, SeenAggregatedAttestations, + insertDesc, } from "../../../../src/chain/seenCache/seenAggregateAndProof.js"; describe("SeenAggregatedAttestations.isKnown", () => { diff --git a/packages/beacon-node/test/unit/chain/seenCache/seenAttestationData.test.ts b/packages/beacon-node/test/unit/chain/seenCache/seenAttestationData.test.ts index b4857226267e..ee5cb94ae959 100644 --- a/packages/beacon-node/test/unit/chain/seenCache/seenAttestationData.test.ts +++ b/packages/beacon-node/test/unit/chain/seenCache/seenAttestationData.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, beforeEach} from "vitest"; +import {beforeEach, describe, expect, it} from "vitest"; import {InsertOutcome} from "../../../../src/chain/opPools/types.js"; import {AttestationDataCacheEntry, SeenAttestationDatas} from "../../../../src/chain/seenCache/seenAttestationData.js"; diff --git a/packages/beacon-node/test/unit/chain/seenCache/seenGossipBlockInput.test.ts b/packages/beacon-node/test/unit/chain/seenCache/seenGossipBlockInput.test.ts index 27b5eadecf11..2af9f40d2de3 100644 --- a/packages/beacon-node/test/unit/chain/seenCache/seenGossipBlockInput.test.ts +++ b/packages/beacon-node/test/unit/chain/seenCache/seenGossipBlockInput.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect} from "vitest"; import {createBeaconConfig, createChainForkConfig, defaultChainConfig} from "@lodestar/config"; import {ssz} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; +import {BlockInput, BlockInputType, GossipedInputType} from "../../../../src/chain/blocks/types.js"; import {SeenGossipBlockInput} from "../../../../src/chain/seenCache/seenGossipBlockInput.js"; -import {BlockInputType, GossipedInputType, BlockInput} from "../../../../src/chain/blocks/types.js"; describe("SeenGossipBlockInput", () => { const chainConfig = createChainForkConfig({ diff --git a/packages/beacon-node/test/unit/chain/seenCache/syncCommittee.test.ts b/packages/beacon-node/test/unit/chain/seenCache/syncCommittee.test.ts index 59c67f9cedc2..a24fcc41443d 100644 --- a/packages/beacon-node/test/unit/chain/seenCache/syncCommittee.test.ts +++ b/packages/beacon-node/test/unit/chain/seenCache/syncCommittee.test.ts @@ -1,7 +1,7 @@ import {BitArray} from "@chainsafe/ssz"; -import {describe, it, expect} from "vitest"; import {ssz} from "@lodestar/types"; -import {SeenSyncCommitteeMessages, SeenContributionAndProof} from "../../../../src/chain/seenCache/index.js"; +import {describe, expect, it} from "vitest"; +import {SeenContributionAndProof, SeenSyncCommitteeMessages} from "../../../../src/chain/seenCache/index.js"; const NUM_SLOTS_IN_CACHE = 3; diff --git a/packages/beacon-node/test/unit/chain/shufflingCache.test.ts b/packages/beacon-node/test/unit/chain/shufflingCache.test.ts index d417e555872c..b8a9602ea6ce 100644 --- a/packages/beacon-node/test/unit/chain/shufflingCache.test.ts +++ b/packages/beacon-node/test/unit/chain/shufflingCache.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, beforeEach} from "vitest"; +import {beforeEach, describe, expect, it} from "vitest"; import {generateTestCachedBeaconStateOnlyValidators} from "../../../../state-transition/test/perf/util.js"; import {ShufflingCache} from "../../../src/chain/shufflingCache.js"; diff --git a/packages/beacon-node/test/unit/chain/stateCache/blockStateCacheImpl.test.ts b/packages/beacon-node/test/unit/chain/stateCache/blockStateCacheImpl.test.ts index 19dc0f3a2c60..50ec0b6fc63d 100644 --- a/packages/beacon-node/test/unit/chain/stateCache/blockStateCacheImpl.test.ts +++ b/packages/beacon-node/test/unit/chain/stateCache/blockStateCacheImpl.test.ts @@ -1,11 +1,11 @@ import {toHexString} from "@chainsafe/ssz"; -import {describe, it, expect, beforeEach} from "vitest"; -import {EpochShuffling} from "@lodestar/state-transition"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; +import {EpochShuffling} from "@lodestar/state-transition"; import {Root} from "@lodestar/types"; +import {beforeEach, describe, expect, it} from "vitest"; import {BlockStateCacheImpl} from "../../../../src/chain/stateCache/index.js"; -import {generateCachedState} from "../../../utils/state.js"; import {ZERO_HASH} from "../../../../src/constants/index.js"; +import {generateCachedState} from "../../../utils/state.js"; describe("BlockStateCacheImpl", () => { let cache: BlockStateCacheImpl; diff --git a/packages/beacon-node/test/unit/chain/stateCache/fifoBlockStateCache.test.ts b/packages/beacon-node/test/unit/chain/stateCache/fifoBlockStateCache.test.ts index 07a8ec12093d..9a341438479d 100644 --- a/packages/beacon-node/test/unit/chain/stateCache/fifoBlockStateCache.test.ts +++ b/packages/beacon-node/test/unit/chain/stateCache/fifoBlockStateCache.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect, beforeEach} from "vitest"; import {toHexString} from "@chainsafe/ssz"; -import {EpochShuffling, CachedBeaconStateAllForks} from "@lodestar/state-transition"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; +import {CachedBeaconStateAllForks, EpochShuffling} from "@lodestar/state-transition"; +import {beforeEach, describe, expect, it} from "vitest"; import {FIFOBlockStateCache} from "../../../../src/chain/stateCache/index.js"; import {generateCachedState} from "../../../utils/state.js"; diff --git a/packages/beacon-node/test/unit/chain/stateCache/inMemoryCheckpointsCache.test.ts b/packages/beacon-node/test/unit/chain/stateCache/inMemoryCheckpointsCache.test.ts index 23a792bef0a8..edfec599b6eb 100644 --- a/packages/beacon-node/test/unit/chain/stateCache/inMemoryCheckpointsCache.test.ts +++ b/packages/beacon-node/test/unit/chain/stateCache/inMemoryCheckpointsCache.test.ts @@ -1,7 +1,7 @@ -import {describe, beforeAll, it, expect, beforeEach} from "vitest"; +import {SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params"; import {CachedBeaconStateAllForks, computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {phase0} from "@lodestar/types"; -import {SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params"; +import {beforeAll, beforeEach, describe, expect, it} from "vitest"; import { CheckpointHex, InMemoryCheckpointStateCache, diff --git a/packages/beacon-node/test/unit/chain/stateCache/persistentCheckpointsCache.test.ts b/packages/beacon-node/test/unit/chain/stateCache/persistentCheckpointsCache.test.ts index f98b180fa983..5ab3da532948 100644 --- a/packages/beacon-node/test/unit/chain/stateCache/persistentCheckpointsCache.test.ts +++ b/packages/beacon-node/test/unit/chain/stateCache/persistentCheckpointsCache.test.ts @@ -1,16 +1,16 @@ -import {describe, it, expect, beforeAll, beforeEach} from "vitest"; import {SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params"; import {CachedBeaconStateAllForks, computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {RootHex, phase0} from "@lodestar/types"; import {mapValues, toHexString} from "@lodestar/utils"; -import {PersistentCheckpointStateCache} from "../../../../src/chain/stateCache/persistentCheckpointsCache.js"; -import {checkpointToDatastoreKey} from "../../../../src/chain/stateCache/datastore/index.js"; -import {generateCachedState} from "../../../utils/state.js"; +import {beforeAll, beforeEach, describe, expect, it} from "vitest"; +import {FIFOBlockStateCache, toCheckpointHex} from "../../../../src/chain/index.js"; import {ShufflingCache} from "../../../../src/chain/shufflingCache.js"; -import {testLogger} from "../../../utils/logger.js"; -import {getTestDatastore} from "../../../utils/chain/stateCache/datastore.js"; +import {checkpointToDatastoreKey} from "../../../../src/chain/stateCache/datastore/index.js"; +import {PersistentCheckpointStateCache} from "../../../../src/chain/stateCache/persistentCheckpointsCache.js"; import {CheckpointHex} from "../../../../src/chain/stateCache/types.js"; -import {FIFOBlockStateCache, toCheckpointHex} from "../../../../src/chain/index.js"; +import {getTestDatastore} from "../../../utils/chain/stateCache/datastore.js"; +import {testLogger} from "../../../utils/logger.js"; +import {generateCachedState} from "../../../utils/state.js"; describe("PersistentCheckpointStateCache", () => { let root0a: Buffer, root0b: Buffer, root1: Buffer, root2: Buffer; diff --git a/packages/beacon-node/test/unit/chain/validation/aggregateAndProof.test.ts b/packages/beacon-node/test/unit/chain/validation/aggregateAndProof.test.ts index e2bc392b4ea2..d9833740a9a5 100644 --- a/packages/beacon-node/test/unit/chain/validation/aggregateAndProof.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/aggregateAndProof.test.ts @@ -1,16 +1,16 @@ import {BitArray, toHexString} from "@chainsafe/ssz"; -import {describe, it} from "vitest"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {phase0, ssz} from "@lodestar/types"; +import {describe, it} from "vitest"; import {generateTestCachedBeaconStateOnlyValidators} from "../../../../../state-transition/test/perf/util.js"; -import {IBeaconChain} from "../../../../src/chain/index.js"; import {AttestationErrorCode} from "../../../../src/chain/errors/index.js"; +import {IBeaconChain} from "../../../../src/chain/index.js"; import {validateApiAggregateAndProof, validateGossipAggregateAndProof} from "../../../../src/chain/validation/index.js"; -import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; import {memoOnce} from "../../../utils/cache.js"; +import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; import { - getAggregateAndProofValidData, AggregateAndProofValidDataOpts, + getAggregateAndProofValidData, } from "../../../utils/validationData/aggregateAndProof.js"; describe("chain / validation / aggregateAndProof", () => { diff --git a/packages/beacon-node/test/unit/chain/validation/attestation/getShufflingForAttestationVerification.test.ts b/packages/beacon-node/test/unit/chain/validation/attestation/getShufflingForAttestationVerification.test.ts index 4ba65270e17a..729c03d9d6e5 100644 --- a/packages/beacon-node/test/unit/chain/validation/attestation/getShufflingForAttestationVerification.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/attestation/getShufflingForAttestationVerification.test.ts @@ -1,11 +1,11 @@ -import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; -// We need to import the mock before the packages -import {MockedBeaconChain, getMockedBeaconChain} from "../../../../mocks/mockedBeaconChain.js"; -import {EpochShuffling, computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {EpochDifference, ProtoBlock} from "@lodestar/fork-choice"; +import {EpochShuffling, computeStartSlotAtEpoch} from "@lodestar/state-transition"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {RegenCaller} from "../../../../../src/chain/regen/interface.js"; import {getShufflingForAttestationVerification} from "../../../../../src/chain/validation/index.js"; import {ZERO_HASH_HEX} from "../../../../../src/constants/constants.js"; +// We need to import the mock before the packages +import {MockedBeaconChain, getMockedBeaconChain} from "../../../../mocks/mockedBeaconChain.js"; describe("getShufflingForAttestationVerification", () => { let chain: MockedBeaconChain; diff --git a/packages/beacon-node/test/unit/chain/validation/attestation/validateAttestation.test.ts b/packages/beacon-node/test/unit/chain/validation/attestation/validateAttestation.test.ts index be9fd3587b7c..1ffbf7696111 100644 --- a/packages/beacon-node/test/unit/chain/validation/attestation/validateAttestation.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/attestation/validateAttestation.test.ts @@ -1,8 +1,8 @@ import {BitArray} from "@chainsafe/ssz"; -import {describe, expect, it} from "vitest"; import {ForkName, SLOTS_PER_EPOCH} from "@lodestar/params"; import {ssz} from "@lodestar/types"; import {LodestarError} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; import {generateTestCachedBeaconStateOnlyValidators} from "../../../../../../state-transition/test/perf/util.js"; import {AttestationErrorCode, GossipErrorCode} from "../../../../../src/chain/errors/index.js"; import {IBeaconChain} from "../../../../../src/chain/index.js"; diff --git a/packages/beacon-node/test/unit/chain/validation/attestation/validateGossipAttestationsSameAttData.test.ts b/packages/beacon-node/test/unit/chain/validation/attestation/validateGossipAttestationsSameAttData.test.ts index 24fae8a03f0b..1b3688fc2e33 100644 --- a/packages/beacon-node/test/unit/chain/validation/attestation/validateGossipAttestationsSameAttData.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/attestation/validateGossipAttestationsSameAttData.test.ts @@ -1,8 +1,8 @@ -import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {PublicKey, SecretKey} from "@chainsafe/blst"; import {ForkName} from "@lodestar/params"; import {SignatureSetType} from "@lodestar/state-transition"; import {ssz} from "@lodestar/types"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {BlsSingleThreadVerifier} from "../../../../../src/chain/bls/singleThread.js"; import {AttestationError, AttestationErrorCode, GossipAction} from "../../../../../src/chain/errors/index.js"; import {IBeaconChain} from "../../../../../src/chain/index.js"; diff --git a/packages/beacon-node/test/unit/chain/validation/attesterSlashing.test.ts b/packages/beacon-node/test/unit/chain/validation/attesterSlashing.test.ts index 629753824669..c9577767f78f 100644 --- a/packages/beacon-node/test/unit/chain/validation/attesterSlashing.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/attesterSlashing.test.ts @@ -1,10 +1,10 @@ -import {describe, it, beforeEach, afterEach, vi} from "vitest"; import {phase0, ssz} from "@lodestar/types"; -import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; -import {generateCachedState} from "../../../utils/state.js"; -import {validateGossipAttesterSlashing} from "../../../../src/chain/validation/attesterSlashing.js"; +import {afterEach, beforeEach, describe, it, vi} from "vitest"; import {AttesterSlashingErrorCode} from "../../../../src/chain/errors/attesterSlashingError.js"; +import {validateGossipAttesterSlashing} from "../../../../src/chain/validation/attesterSlashing.js"; +import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; +import {generateCachedState} from "../../../utils/state.js"; describe("GossipMessageValidator", () => { let chainStub: MockedBeaconChain; diff --git a/packages/beacon-node/test/unit/chain/validation/block.test.ts b/packages/beacon-node/test/unit/chain/validation/block.test.ts index f8a2b7245ef7..4b236181b038 100644 --- a/packages/beacon-node/test/unit/chain/validation/block.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/block.test.ts @@ -1,14 +1,14 @@ -import {Mock, Mocked, beforeEach, describe, it, vi} from "vitest"; import {config} from "@lodestar/config/default"; import {ProtoBlock} from "@lodestar/fork-choice"; import {ForkName} from "@lodestar/params"; import {SignedBeaconBlock, ssz} from "@lodestar/types"; -import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; +import {Mock, Mocked, beforeEach, describe, it, vi} from "vitest"; import {BlockErrorCode} from "../../../../src/chain/errors/index.js"; import {QueuedStateRegenerator} from "../../../../src/chain/regen/index.js"; import {SeenBlockProposers} from "../../../../src/chain/seenCache/index.js"; import {validateGossipBlock} from "../../../../src/chain/validation/index.js"; import {EMPTY_SIGNATURE, ZERO_HASH} from "../../../../src/constants/index.js"; +import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; import {generateCachedState} from "../../../utils/state.js"; diff --git a/packages/beacon-node/test/unit/chain/validation/blsToExecutionChange.test.ts b/packages/beacon-node/test/unit/chain/validation/blsToExecutionChange.test.ts index 8d5032ed3ec7..6c1d1def3d9d 100644 --- a/packages/beacon-node/test/unit/chain/validation/blsToExecutionChange.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/blsToExecutionChange.test.ts @@ -1,24 +1,24 @@ import {digest} from "@chainsafe/as-sha256"; -import {describe, it, beforeEach, afterEach, vi} from "vitest"; import {SecretKey} from "@chainsafe/blst"; +import {createBeaconConfig} from "@lodestar/config"; import {config as defaultConfig} from "@lodestar/config/default"; -import {computeSigningRoot} from "@lodestar/state-transition"; -import {capella, ssz} from "@lodestar/types"; import { BLS_WITHDRAWAL_PREFIX, - ETH1_ADDRESS_WITHDRAWAL_PREFIX, DOMAIN_BLS_TO_EXECUTION_CHANGE, + ETH1_ADDRESS_WITHDRAWAL_PREFIX, FAR_FUTURE_EPOCH, - SLOTS_PER_EPOCH, ForkName, + SLOTS_PER_EPOCH, } from "@lodestar/params"; -import {createBeaconConfig} from "@lodestar/config"; -import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; -import {generateState} from "../../../utils/state.js"; -import {validateGossipBlsToExecutionChange} from "../../../../src/chain/validation/blsToExecutionChange.js"; +import {computeSigningRoot} from "@lodestar/state-transition"; +import {capella, ssz} from "@lodestar/types"; +import {afterEach, beforeEach, describe, it, vi} from "vitest"; import {BlsToExecutionChangeErrorCode} from "../../../../src/chain/errors/blsToExecutionChangeError.js"; -import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; +import {validateGossipBlsToExecutionChange} from "../../../../src/chain/validation/blsToExecutionChange.js"; +import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; import {createCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js"; +import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; +import {generateState} from "../../../utils/state.js"; describe("validate bls to execution change", () => { let chainStub: MockedBeaconChain; diff --git a/packages/beacon-node/test/unit/chain/validation/lightClientFinalityUpdate.test.ts b/packages/beacon-node/test/unit/chain/validation/lightClientFinalityUpdate.test.ts index cbd231c926ce..4288b7f440c9 100644 --- a/packages/beacon-node/test/unit/chain/validation/lightClientFinalityUpdate.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/lightClientFinalityUpdate.test.ts @@ -1,11 +1,11 @@ -import {describe, it, expect, beforeEach, afterEach, vi} from "vitest"; import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; -import {altair, ssz} from "@lodestar/types"; import {computeTimeAtSlot} from "@lodestar/state-transition"; +import {altair, ssz} from "@lodestar/types"; import {RequiredSelective} from "@lodestar/utils"; -import {validateLightClientFinalityUpdate} from "../../../../src/chain/validation/lightClientFinalityUpdate.js"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {LightClientErrorCode} from "../../../../src/chain/errors/lightClientError.js"; import {IBeaconChain} from "../../../../src/chain/index.js"; +import {validateLightClientFinalityUpdate} from "../../../../src/chain/validation/lightClientFinalityUpdate.js"; import {getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; describe("Light Client Finality Update validation", () => { diff --git a/packages/beacon-node/test/unit/chain/validation/lightClientOptimisticUpdate.test.ts b/packages/beacon-node/test/unit/chain/validation/lightClientOptimisticUpdate.test.ts index 7665b4f89179..85a1ebb16330 100644 --- a/packages/beacon-node/test/unit/chain/validation/lightClientOptimisticUpdate.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/lightClientOptimisticUpdate.test.ts @@ -1,11 +1,11 @@ -import {describe, it, expect, beforeEach, afterEach, vi} from "vitest"; import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; -import {altair, ssz} from "@lodestar/types"; import {computeTimeAtSlot} from "@lodestar/state-transition"; +import {altair, ssz} from "@lodestar/types"; import {RequiredSelective} from "@lodestar/utils"; -import {validateLightClientOptimisticUpdate} from "../../../../src/chain/validation/lightClientOptimisticUpdate.js"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {LightClientErrorCode} from "../../../../src/chain/errors/lightClientError.js"; import {IBeaconChain} from "../../../../src/chain/index.js"; +import {validateLightClientOptimisticUpdate} from "../../../../src/chain/validation/lightClientOptimisticUpdate.js"; import {getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; describe("Light Client Optimistic Update validation", () => { diff --git a/packages/beacon-node/test/unit/chain/validation/proposerSlashing.test.ts b/packages/beacon-node/test/unit/chain/validation/proposerSlashing.test.ts index f5eb7310a39c..4d1fcb3f2490 100644 --- a/packages/beacon-node/test/unit/chain/validation/proposerSlashing.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/proposerSlashing.test.ts @@ -1,10 +1,10 @@ -import {describe, it, beforeEach, afterEach, vi} from "vitest"; import {phase0, ssz} from "@lodestar/types"; -import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; -import {generateCachedState} from "../../../utils/state.js"; +import {afterEach, beforeEach, describe, it, vi} from "vitest"; import {ProposerSlashingErrorCode} from "../../../../src/chain/errors/proposerSlashingError.js"; import {validateGossipProposerSlashing} from "../../../../src/chain/validation/proposerSlashing.js"; +import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; +import {generateCachedState} from "../../../utils/state.js"; describe("validate proposer slashing", () => { let chainStub: MockedBeaconChain; diff --git a/packages/beacon-node/test/unit/chain/validation/syncCommittee.test.ts b/packages/beacon-node/test/unit/chain/validation/syncCommittee.test.ts index cbffc2a4ffd9..6ed254254154 100644 --- a/packages/beacon-node/test/unit/chain/validation/syncCommittee.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/syncCommittee.test.ts @@ -1,15 +1,15 @@ import {toHexString} from "@chainsafe/ssz"; -import {describe, it, expect, afterEach, beforeEach, beforeAll, afterAll, vi, Mock} from "vitest"; -import {altair, Epoch, Slot} from "@lodestar/types"; -import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; -import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; +import {SLOTS_PER_EPOCH} from "@lodestar/params"; +import {Epoch, Slot, altair} from "@lodestar/types"; +import {Mock, afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; import {SyncCommitteeErrorCode} from "../../../../src/chain/errors/syncCommitteeError.js"; +import {SeenSyncCommitteeMessages} from "../../../../src/chain/seenCache/index.js"; import {validateGossipSyncCommittee} from "../../../../src/chain/validation/syncCommittee.js"; +import {ZERO_HASH} from "../../../../src/constants/constants.js"; +import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; import {generateCachedAltairState} from "../../../utils/state.js"; -import {SeenSyncCommitteeMessages} from "../../../../src/chain/seenCache/index.js"; -import {ZERO_HASH} from "../../../../src/constants/constants.js"; // https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/altair/p2p-interface.md describe("Sync Committee Signature validation", () => { diff --git a/packages/beacon-node/test/unit/chain/validation/voluntaryExit.test.ts b/packages/beacon-node/test/unit/chain/validation/voluntaryExit.test.ts index d556ff610961..697489b8523d 100644 --- a/packages/beacon-node/test/unit/chain/validation/voluntaryExit.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/voluntaryExit.test.ts @@ -1,21 +1,21 @@ -import {describe, it, beforeEach, beforeAll, vi, afterEach} from "vitest"; import {SecretKey} from "@chainsafe/blst"; +import {createBeaconConfig} from "@lodestar/config"; import {config} from "@lodestar/config/default"; +import {DOMAIN_VOLUNTARY_EXIT, FAR_FUTURE_EPOCH, SLOTS_PER_EPOCH} from "@lodestar/params"; import { CachedBeaconStateAllForks, - computeEpochAtSlot, computeDomain, + computeEpochAtSlot, computeSigningRoot, } from "@lodestar/state-transition"; import {phase0, ssz} from "@lodestar/types"; -import {DOMAIN_VOLUNTARY_EXIT, FAR_FUTURE_EPOCH, SLOTS_PER_EPOCH} from "@lodestar/params"; -import {createBeaconConfig} from "@lodestar/config"; -import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; -import {generateState} from "../../../utils/state.js"; -import {validateGossipVoluntaryExit} from "../../../../src/chain/validation/voluntaryExit.js"; +import {afterEach, beforeAll, beforeEach, describe, it, vi} from "vitest"; import {VoluntaryExitErrorCode} from "../../../../src/chain/errors/voluntaryExitError.js"; -import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; +import {validateGossipVoluntaryExit} from "../../../../src/chain/validation/voluntaryExit.js"; +import {MockedBeaconChain, getMockedBeaconChain} from "../../../mocks/mockedBeaconChain.js"; import {createCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js"; +import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; +import {generateState} from "../../../utils/state.js"; describe("validate voluntary exit", () => { let chainStub: MockedBeaconChain; diff --git a/packages/beacon-node/test/unit/db/api/repositories/blockArchive.test.ts b/packages/beacon-node/test/unit/db/api/repositories/blockArchive.test.ts index b87e9b926fdd..923a143b6766 100644 --- a/packages/beacon-node/test/unit/db/api/repositories/blockArchive.test.ts +++ b/packages/beacon-node/test/unit/db/api/repositories/blockArchive.test.ts @@ -1,13 +1,13 @@ -import {rimraf} from "rimraf"; -import {describe, it, expect, beforeEach, afterEach, vi} from "vitest"; -import {ssz} from "@lodestar/types"; import {config} from "@lodestar/config/default"; -import {intToBytes} from "@lodestar/utils"; import {LevelDbController, encodeKey} from "@lodestar/db"; +import {ssz} from "@lodestar/types"; +import {intToBytes} from "@lodestar/utils"; +import {rimraf} from "rimraf"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; +import {Bucket} from "../../../../../src/db/buckets.js"; import {BlockArchiveRepository} from "../../../../../src/db/repositories/index.js"; import {testLogger} from "../../../../utils/logger.js"; -import {Bucket} from "../../../../../src/db/buckets.js"; describe("block archive repository", () => { const testDir = "./.tmp"; diff --git a/packages/beacon-node/test/unit/db/api/repository.test.ts b/packages/beacon-node/test/unit/db/api/repository.test.ts index 3b2840b3f0be..e2b908bac777 100644 --- a/packages/beacon-node/test/unit/db/api/repository.test.ts +++ b/packages/beacon-node/test/unit/db/api/repository.test.ts @@ -1,9 +1,9 @@ -import all from "it-all"; import {ContainerType} from "@chainsafe/ssz"; -import {describe, it, expect, beforeEach, vi, afterEach, MockedObject} from "vitest"; -import {Bytes32, ssz} from "@lodestar/types"; import {config} from "@lodestar/config/default"; import {Db, LevelDbController, Repository} from "@lodestar/db"; +import {Bytes32, ssz} from "@lodestar/types"; +import all from "it-all"; +import {MockedObject, afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {Bucket} from "../../../../src/db/buckets.js"; vi.mock("@lodestar/db", async (importOriginal) => { diff --git a/packages/beacon-node/test/unit/eth1/eth1DepositDataTracker.test.ts b/packages/beacon-node/test/unit/eth1/eth1DepositDataTracker.test.ts index 40988ed21728..d46e2870fd41 100644 --- a/packages/beacon-node/test/unit/eth1/eth1DepositDataTracker.test.ts +++ b/packages/beacon-node/test/unit/eth1/eth1DepositDataTracker.test.ts @@ -1,12 +1,12 @@ -import {describe, it, expect, beforeEach, afterEach, vi, MockInstance} from "vitest"; import {config} from "@lodestar/config/default"; import {TimeoutError} from "@lodestar/utils"; +import {MockInstance, afterEach, beforeEach, describe, expect, it, vi} from "vitest"; +import {BeaconDb} from "../../../src/db/beacon.js"; import {Eth1DepositDataTracker} from "../../../src/eth1/eth1DepositDataTracker.js"; -import {Eth1Provider} from "../../../src/eth1/provider/eth1Provider.js"; -import {testLogger} from "../../utils/logger.js"; import {defaultEth1Options} from "../../../src/eth1/options.js"; -import {BeaconDb} from "../../../src/db/beacon.js"; +import {Eth1Provider} from "../../../src/eth1/provider/eth1Provider.js"; import {getMockedBeaconDb} from "../../mocks/mockedBeaconDb.js"; +import {testLogger} from "../../utils/logger.js"; describe("Eth1DepositDataTracker", () => { const controller = new AbortController(); diff --git a/packages/beacon-node/test/unit/eth1/eth1MergeBlockTracker.test.ts b/packages/beacon-node/test/unit/eth1/eth1MergeBlockTracker.test.ts index c7f4c8fb7aa4..38ac5dd87fb7 100644 --- a/packages/beacon-node/test/unit/eth1/eth1MergeBlockTracker.test.ts +++ b/packages/beacon-node/test/unit/eth1/eth1MergeBlockTracker.test.ts @@ -1,11 +1,11 @@ import {toHexString} from "@chainsafe/ssz"; -import {describe, it, expect, beforeEach, afterEach} from "vitest"; import {ChainConfig} from "@lodestar/config"; import {sleep} from "@lodestar/utils"; -import {IEth1Provider} from "../../../src/index.js"; +import {afterEach, beforeEach, describe, expect, it} from "vitest"; import {ZERO_HASH} from "../../../src/constants/index.js"; import {Eth1MergeBlockTracker, StatusCode, toPowBlock} from "../../../src/eth1/eth1MergeBlockTracker.js"; import {Eth1ProviderState, EthJsonRpcBlockRaw} from "../../../src/eth1/interface.js"; +import {IEth1Provider} from "../../../src/index.js"; import {testLogger} from "../../utils/logger.js"; describe("eth1 / Eth1MergeBlockTracker", () => { diff --git a/packages/beacon-node/test/unit/eth1/hexEncoding.test.ts b/packages/beacon-node/test/unit/eth1/hexEncoding.test.ts index 5e5dd953cd61..bb2782f2f735 100644 --- a/packages/beacon-node/test/unit/eth1/hexEncoding.test.ts +++ b/packages/beacon-node/test/unit/eth1/hexEncoding.test.ts @@ -1,11 +1,11 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { QUANTITY, + bytesToQuantity, + numToQuantity, + quantityToBigint, quantityToBytes, quantityToNum, - quantityToBigint, - numToQuantity, - bytesToQuantity, } from "../../../src/eth1/provider/utils.js"; describe("eth1 / hex encoding", () => { diff --git a/packages/beacon-node/test/unit/eth1/jwt.test.ts b/packages/beacon-node/test/unit/eth1/jwt.test.ts index 5ebcdc17e355..c96344b37c6a 100644 --- a/packages/beacon-node/test/unit/eth1/jwt.test.ts +++ b/packages/beacon-node/test/unit/eth1/jwt.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {encodeJwtToken, decodeJwtToken} from "../../../src/eth1/provider/jwt.js"; +import {describe, expect, it} from "vitest"; +import {decodeJwtToken, encodeJwtToken} from "../../../src/eth1/provider/jwt.js"; describe("ExecutionEngine / jwt", () => { it("encode/decode correctly", () => { diff --git a/packages/beacon-node/test/unit/eth1/utils/depositContract.test.ts b/packages/beacon-node/test/unit/eth1/utils/depositContract.test.ts index 22ca95765a9a..260cb4fef4bd 100644 --- a/packages/beacon-node/test/unit/eth1/utils/depositContract.test.ts +++ b/packages/beacon-node/test/unit/eth1/utils/depositContract.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {goerliTestnetLogs, goerliTestnetDepositEvents} from "../../../utils/testnet.js"; +import {describe, expect, it} from "vitest"; import {parseDepositLog} from "../../../../src/eth1/utils/depositContract.js"; +import {goerliTestnetDepositEvents, goerliTestnetLogs} from "../../../utils/testnet.js"; describe("eth1 / util / depositContract", () => { it("Should parse a raw deposit log", () => { diff --git a/packages/beacon-node/test/unit/eth1/utils/deposits.test.ts b/packages/beacon-node/test/unit/eth1/utils/deposits.test.ts index 34334d1b3f8b..2853bff0f8dd 100644 --- a/packages/beacon-node/test/unit/eth1/utils/deposits.test.ts +++ b/packages/beacon-node/test/unit/eth1/utils/deposits.test.ts @@ -1,15 +1,15 @@ -import {describe, it, expect} from "vitest"; -import {phase0, ssz} from "@lodestar/types"; +import {createChainForkConfig} from "@lodestar/config"; import {MAX_DEPOSITS, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {phase0, ssz} from "@lodestar/types"; import {verifyMerkleBranch} from "@lodestar/utils"; -import {createChainForkConfig} from "@lodestar/config"; -import {filterBy} from "../../../utils/db.js"; -import {Eth1ErrorCode} from "../../../../src/eth1/errors.js"; -import {generateState} from "../../../utils/state.js"; -import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; -import {getDeposits, getDepositsWithProofs, DepositGetter} from "../../../../src/eth1/utils/deposits.js"; +import {describe, expect, it} from "vitest"; import {DepositTree} from "../../../../src/db/repositories/depositDataRoot.js"; +import {Eth1ErrorCode} from "../../../../src/eth1/errors.js"; +import {DepositGetter, getDeposits, getDepositsWithProofs} from "../../../../src/eth1/utils/deposits.js"; import {createCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js"; +import {filterBy} from "../../../utils/db.js"; +import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; +import {generateState} from "../../../utils/state.js"; describe("eth1 / util / deposits", () => { describe("getDeposits", () => { diff --git a/packages/beacon-node/test/unit/eth1/utils/eth1Data.test.ts b/packages/beacon-node/test/unit/eth1/utils/eth1Data.test.ts index dff98500b293..c4107d06e43e 100644 --- a/packages/beacon-node/test/unit/eth1/utils/eth1Data.test.ts +++ b/packages/beacon-node/test/unit/eth1/utils/eth1Data.test.ts @@ -1,16 +1,16 @@ -import {describe, it, expect} from "vitest"; import {Root, phase0, ssz} from "@lodestar/types"; import {toHex} from "@lodestar/utils"; -import {iteratorFromArray} from "../../../utils/interator.js"; +import {describe, expect, it} from "vitest"; +import {DepositTree} from "../../../../src/db/repositories/depositDataRoot.js"; +import {Eth1ErrorCode} from "../../../../src/eth1/errors.js"; +import {Eth1Block} from "../../../../src/eth1/interface.js"; import { - getEth1DataForBlocks, - getDepositsByBlockNumber, getDepositRootByDepositCount, + getDepositsByBlockNumber, + getEth1DataForBlocks, } from "../../../../src/eth1/utils/eth1Data.js"; -import {Eth1Block} from "../../../../src/eth1/interface.js"; import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; -import {Eth1ErrorCode} from "../../../../src/eth1/errors.js"; -import {DepositTree} from "../../../../src/db/repositories/depositDataRoot.js"; +import {iteratorFromArray} from "../../../utils/interator.js"; describe("eth1 / util / getEth1DataForBlocks", () => { type TestCase = { diff --git a/packages/beacon-node/test/unit/eth1/utils/eth1DepositEvent.test.ts b/packages/beacon-node/test/unit/eth1/utils/eth1DepositEvent.test.ts index ea504464778c..a1de0fa748e3 100644 --- a/packages/beacon-node/test/unit/eth1/utils/eth1DepositEvent.test.ts +++ b/packages/beacon-node/test/unit/eth1/utils/eth1DepositEvent.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {assertConsecutiveDeposits} from "../../../../src/eth1/utils/eth1DepositEvent.js"; describe("eth1 / util / assertConsecutiveDeposits", () => { diff --git a/packages/beacon-node/test/unit/eth1/utils/eth1Vote.test.ts b/packages/beacon-node/test/unit/eth1/utils/eth1Vote.test.ts index e9a9ab5aad24..f8221f76a0f5 100644 --- a/packages/beacon-node/test/unit/eth1/utils/eth1Vote.test.ts +++ b/packages/beacon-node/test/unit/eth1/utils/eth1Vote.test.ts @@ -1,16 +1,16 @@ -import {describe, it, expect} from "vitest"; -import {config} from "@lodestar/config/default"; -import {phase0, ssz} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; +import {config} from "@lodestar/config/default"; import {BeaconStateAllForks} from "@lodestar/state-transition"; -import {generateState} from "../../../utils/state.js"; -import {filterBy} from "../../../utils/db.js"; +import {phase0, ssz} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; import { + Eth1DataGetter, getEth1VotesToConsider, pickEth1Vote, votingPeriodStartTime, - Eth1DataGetter, } from "../../../../src/eth1/utils/eth1Vote.js"; +import {filterBy} from "../../../utils/db.js"; +import {generateState} from "../../../utils/state.js"; describe("eth1 / util / eth1Vote", () => { function generateEth1Vote(i: number): phase0.Eth1Data { diff --git a/packages/beacon-node/test/unit/eth1/utils/groupDepositEventsByBlock.test.ts b/packages/beacon-node/test/unit/eth1/utils/groupDepositEventsByBlock.test.ts index a4e786b3aa68..6c9e9b47c1ae 100644 --- a/packages/beacon-node/test/unit/eth1/utils/groupDepositEventsByBlock.test.ts +++ b/packages/beacon-node/test/unit/eth1/utils/groupDepositEventsByBlock.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {phase0} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; import {groupDepositEventsByBlock} from "../../../../src/eth1/utils/groupDepositEventsByBlock.js"; describe("eth1 / util / groupDepositEventsByBlock", () => { diff --git a/packages/beacon-node/test/unit/eth1/utils/optimizeNextBlockDiffForGenesis.test.ts b/packages/beacon-node/test/unit/eth1/utils/optimizeNextBlockDiffForGenesis.test.ts index 39c4a4d6e773..38a4e6fa83e2 100644 --- a/packages/beacon-node/test/unit/eth1/utils/optimizeNextBlockDiffForGenesis.test.ts +++ b/packages/beacon-node/test/unit/eth1/utils/optimizeNextBlockDiffForGenesis.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {optimizeNextBlockDiffForGenesis} from "../../../../src/eth1/utils/optimizeNextBlockDiffForGenesis.js"; +import {describe, expect, it} from "vitest"; import {Eth1Block} from "../../../../src/eth1/interface.js"; +import {optimizeNextBlockDiffForGenesis} from "../../../../src/eth1/utils/optimizeNextBlockDiffForGenesis.js"; describe("eth1 / utils / optimizeNextBlockDiffForGenesis", () => { it("should return optimized block diff to find genesis time", () => { diff --git a/packages/beacon-node/test/unit/execution/engine/utils.test.ts b/packages/beacon-node/test/unit/execution/engine/utils.test.ts index b81c3e965390..c181166c2aea 100644 --- a/packages/beacon-node/test/unit/execution/engine/utils.test.ts +++ b/packages/beacon-node/test/unit/execution/engine/utils.test.ts @@ -1,14 +1,14 @@ -import {describe, it, expect} from "vitest"; -import {ErrorAborted} from "@lodestar/utils"; import {FetchError} from "@lodestar/api"; -import {ExecutionPayloadStatus, ExecutionEngineState} from "../../../../src/execution/index.js"; +import {ErrorAborted} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; +import {ErrorJsonRpcResponse, HttpRpcError} from "../../../../src/eth1/provider/jsonRpcHttpClient.js"; import { HTTP_CONNECTION_ERROR_CODES, HTTP_FATAL_ERROR_CODES, getExecutionEngineState, } from "../../../../src/execution/engine/utils.js"; +import {ExecutionEngineState, ExecutionPayloadStatus} from "../../../../src/execution/index.js"; import {QueueError, QueueErrorCode} from "../../../../src/util/queue/errors.js"; -import {ErrorJsonRpcResponse, HttpRpcError} from "../../../../src/eth1/provider/jsonRpcHttpClient.js"; describe("execution / engine / utils", () => { describe("getExecutionEngineState", () => { diff --git a/packages/beacon-node/test/unit/executionEngine/http.test.ts b/packages/beacon-node/test/unit/executionEngine/http.test.ts index c9f4ae671e53..5c7078500640 100644 --- a/packages/beacon-node/test/unit/executionEngine/http.test.ts +++ b/packages/beacon-node/test/unit/executionEngine/http.test.ts @@ -1,16 +1,16 @@ -import {fastify} from "fastify"; -import {describe, it, expect, beforeAll, afterAll} from "vitest"; -import {ForkName} from "@lodestar/params"; import {Logger} from "@lodestar/logger"; +import {ForkName} from "@lodestar/params"; +import {fastify} from "fastify"; +import {afterAll, beforeAll, describe, expect, it} from "vitest"; +import {RpcPayload} from "../../../src/eth1/interface.js"; +import {numToQuantity} from "../../../src/eth1/provider/utils.js"; import {defaultExecutionEngineHttpOpts} from "../../../src/execution/engine/http.js"; -import {IExecutionEngine, initializeExecutionEngine} from "../../../src/execution/index.js"; import { parseExecutionPayload, serializeExecutionPayload, serializeExecutionPayloadBody, } from "../../../src/execution/engine/types.js"; -import {RpcPayload} from "../../../src/eth1/interface.js"; -import {numToQuantity} from "../../../src/eth1/provider/utils.js"; +import {IExecutionEngine, initializeExecutionEngine} from "../../../src/execution/index.js"; describe("ExecutionEngine / http", () => { const afterCallbacks: (() => Promise | void)[] = []; diff --git a/packages/beacon-node/test/unit/executionEngine/httpRetry.test.ts b/packages/beacon-node/test/unit/executionEngine/httpRetry.test.ts index b254fc9d8b45..e84a1edd1e4f 100644 --- a/packages/beacon-node/test/unit/executionEngine/httpRetry.test.ts +++ b/packages/beacon-node/test/unit/executionEngine/httpRetry.test.ts @@ -1,11 +1,11 @@ -import {fastify} from "fastify"; import {fromHexString} from "@chainsafe/ssz"; -import {describe, it, expect, beforeAll, afterAll} from "vitest"; -import {ForkName} from "@lodestar/params"; import {Logger} from "@lodestar/logger"; -import {defaultExecutionEngineHttpOpts} from "../../../src/execution/engine/http.js"; +import {ForkName} from "@lodestar/params"; +import {fastify} from "fastify"; +import {afterAll, beforeAll, describe, expect, it} from "vitest"; import {bytesToData, numToQuantity} from "../../../src/eth1/provider/utils.js"; -import {IExecutionEngine, initializeExecutionEngine, PayloadAttributes} from "../../../src/execution/index.js"; +import {defaultExecutionEngineHttpOpts} from "../../../src/execution/engine/http.js"; +import {IExecutionEngine, PayloadAttributes, initializeExecutionEngine} from "../../../src/execution/index.js"; describe("ExecutionEngine / http ", () => { const afterCallbacks: (() => Promise | void)[] = []; diff --git a/packages/beacon-node/test/unit/metrics/beacon.test.ts b/packages/beacon-node/test/unit/metrics/beacon.test.ts index 070ea9064be5..b1d32166fe33 100644 --- a/packages/beacon-node/test/unit/metrics/beacon.test.ts +++ b/packages/beacon-node/test/unit/metrics/beacon.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {createMetricsTest} from "./utils.js"; describe("BeaconMetrics", () => { diff --git a/packages/beacon-node/test/unit/metrics/metrics.test.ts b/packages/beacon-node/test/unit/metrics/metrics.test.ts index 327142a81b5f..f654f97180af 100644 --- a/packages/beacon-node/test/unit/metrics/metrics.test.ts +++ b/packages/beacon-node/test/unit/metrics/metrics.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {createMetricsTest} from "./utils.js"; describe("Metrics", () => { diff --git a/packages/beacon-node/test/unit/metrics/server/http.test.ts b/packages/beacon-node/test/unit/metrics/server/http.test.ts index 623410ccd7ae..4356a2e579e8 100644 --- a/packages/beacon-node/test/unit/metrics/server/http.test.ts +++ b/packages/beacon-node/test/unit/metrics/server/http.test.ts @@ -1,6 +1,6 @@ -import {describe, it, afterAll} from "vitest"; import {fetch} from "@lodestar/api"; -import {getHttpMetricsServer, HttpMetricsServer} from "../../../../src/metrics/index.js"; +import {afterAll, describe, it} from "vitest"; +import {HttpMetricsServer, getHttpMetricsServer} from "../../../../src/metrics/index.js"; import {testLogger} from "../../../utils/logger.js"; import {createMetricsTest} from "../utils.js"; diff --git a/packages/beacon-node/test/unit/metrics/utils.test.ts b/packages/beacon-node/test/unit/metrics/utils.test.ts index 921a549eaf5c..8932d601c273 100644 --- a/packages/beacon-node/test/unit/metrics/utils.test.ts +++ b/packages/beacon-node/test/unit/metrics/utils.test.ts @@ -1,5 +1,5 @@ import {Gauge, Registry} from "prom-client"; -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {GaugeExtra} from "../../../src/metrics/utils/gauge.js"; type MetricValue = { diff --git a/packages/beacon-node/test/unit/metrics/utils.ts b/packages/beacon-node/test/unit/metrics/utils.ts index 53e61826250c..93c635d15b85 100644 --- a/packages/beacon-node/test/unit/metrics/utils.ts +++ b/packages/beacon-node/test/unit/metrics/utils.ts @@ -1,6 +1,6 @@ import {config} from "@lodestar/config/default"; import {ssz} from "@lodestar/types"; -import {createMetrics, Metrics} from "../../../src/metrics/index.js"; +import {Metrics, createMetrics} from "../../../src/metrics/index.js"; import {testLogger} from "../../utils/logger.js"; export function createMetricsTest(): Metrics { diff --git a/packages/beacon-node/test/unit/monitoring/clientStats.test.ts b/packages/beacon-node/test/unit/monitoring/clientStats.test.ts index d14fd88796f2..e4e1e3714a6e 100644 --- a/packages/beacon-node/test/unit/monitoring/clientStats.test.ts +++ b/packages/beacon-node/test/unit/monitoring/clientStats.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {ClientStats} from "../../../src/monitoring/types.js"; +import {describe, expect, it} from "vitest"; import {createClientStats} from "../../../src/monitoring/clientStats.js"; +import {ClientStats} from "../../../src/monitoring/types.js"; import {BEACON_NODE_STATS_SCHEMA, ClientStatsSchema, SYSTEM_STATS_SCHEMA, VALIDATOR_STATS_SCHEMA} from "./schemas.js"; describe("monitoring / clientStats", () => { diff --git a/packages/beacon-node/test/unit/monitoring/properties.test.ts b/packages/beacon-node/test/unit/monitoring/properties.test.ts index 1a2e2c58377a..184617389443 100644 --- a/packages/beacon-node/test/unit/monitoring/properties.test.ts +++ b/packages/beacon-node/test/unit/monitoring/properties.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, beforeAll} from "vitest"; +import {beforeAll, describe, expect, it} from "vitest"; import {Metrics} from "../../../src/metrics/index.js"; import {DynamicProperty, MetricProperty, StaticProperty} from "../../../src/monitoring/properties.js"; import {JsonType} from "../../../src/monitoring/types.js"; diff --git a/packages/beacon-node/test/unit/monitoring/service.test.ts b/packages/beacon-node/test/unit/monitoring/service.test.ts index fed64b9bc553..06fd0d1f511a 100644 --- a/packages/beacon-node/test/unit/monitoring/service.test.ts +++ b/packages/beacon-node/test/unit/monitoring/service.test.ts @@ -1,12 +1,12 @@ -import {describe, it, expect, beforeEach, beforeAll, afterAll, vi, afterEach, MockInstance} from "vitest"; -import {Histogram} from "prom-client"; import {ErrorAborted, TimeoutError} from "@lodestar/utils"; +import {Histogram} from "prom-client"; +import {MockInstance, afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; import {RegistryMetricCreator} from "../../../src/index.js"; -import {MonitoringService} from "../../../src/monitoring/service.js"; import {MonitoringOptions} from "../../../src/monitoring/options.js"; -import {sleep} from "../../utils/sleep.js"; +import {MonitoringService} from "../../../src/monitoring/service.js"; import {MockedLogger, getMockedLogger} from "../../mocks/loggerMock.js"; -import {startRemoteService, remoteServiceRoutes, remoteServiceError} from "./remoteService.js"; +import {sleep} from "../../utils/sleep.js"; +import {remoteServiceError, remoteServiceRoutes, startRemoteService} from "./remoteService.js"; describe("monitoring / service", () => { const endpoint = "https://test.example.com/api/v1/client/metrics"; diff --git a/packages/beacon-node/test/unit/network/beaconBlocksMaybeBlobsByRange.test.ts b/packages/beacon-node/test/unit/network/beaconBlocksMaybeBlobsByRange.test.ts index 2104235e7215..2d9c0967a409 100644 --- a/packages/beacon-node/test/unit/network/beaconBlocksMaybeBlobsByRange.test.ts +++ b/packages/beacon-node/test/unit/network/beaconBlocksMaybeBlobsByRange.test.ts @@ -1,13 +1,13 @@ -import {describe, it, expect, beforeAll} from "vitest"; -import {ssz, deneb} from "@lodestar/types"; -import {ForkName} from "@lodestar/params"; import {createBeaconConfig, createChainForkConfig, defaultChainConfig} from "@lodestar/config"; +import {ForkName} from "@lodestar/params"; +import {deneb, ssz} from "@lodestar/types"; +import {beforeAll, describe, expect, it} from "vitest"; +import {BlobsSource, BlockSource, getBlockInput} from "../../../src/chain/blocks/types.js"; +import {ZERO_HASH} from "../../../src/constants/constants.js"; +import {INetwork} from "../../../src/network/interface.js"; import {beaconBlocksMaybeBlobsByRange} from "../../../src/network/reqresp/index.js"; -import {BlockSource, BlobsSource, getBlockInput} from "../../../src/chain/blocks/types.js"; import {initCKZG, loadEthereumTrustedSetup} from "../../../src/util/kzg.js"; -import {INetwork} from "../../../src/network/interface.js"; -import {ZERO_HASH} from "../../../src/constants/constants.js"; describe("beaconBlocksMaybeBlobsByRange", () => { beforeAll(async () => { diff --git a/packages/beacon-node/test/unit/network/fork.test.ts b/packages/beacon-node/test/unit/network/fork.test.ts index bbe1c0870d30..ed11ce979ef0 100644 --- a/packages/beacon-node/test/unit/network/fork.test.ts +++ b/packages/beacon-node/test/unit/network/fork.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; -import {ForkName, ForkSeq} from "@lodestar/params"; import {BeaconConfig, ForkInfo} from "@lodestar/config"; -import {getCurrentAndNextFork, getActiveForks} from "../../../src/network/forks.js"; +import {ForkName, ForkSeq} from "@lodestar/params"; +import {describe, expect, it} from "vitest"; +import {getActiveForks, getCurrentAndNextFork} from "../../../src/network/forks.js"; function getForkConfig({ phase0, diff --git a/packages/beacon-node/test/unit/network/gossip/topic.test.ts b/packages/beacon-node/test/unit/network/gossip/topic.test.ts index 2a61d8604439..f68c2d737fd6 100644 --- a/packages/beacon-node/test/unit/network/gossip/topic.test.ts +++ b/packages/beacon-node/test/unit/network/gossip/topic.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; import {ForkName} from "@lodestar/params"; -import {GossipType, GossipEncoding, GossipTopicMap} from "../../../../src/network/gossip/index.js"; +import {describe, expect, it} from "vitest"; +import {GossipEncoding, GossipTopicMap, GossipType} from "../../../../src/network/gossip/index.js"; import {parseGossipTopic, stringifyGossipTopic} from "../../../../src/network/gossip/topic.js"; import {config} from "../../../utils/config.js"; diff --git a/packages/beacon-node/test/unit/network/metadata.test.ts b/packages/beacon-node/test/unit/network/metadata.test.ts index 50e4157a29cd..90b75a16df66 100644 --- a/packages/beacon-node/test/unit/network/metadata.test.ts +++ b/packages/beacon-node/test/unit/network/metadata.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {toHex} from "@lodestar/utils"; import {ssz} from "@lodestar/types"; +import {toHex} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; import {getENRForkID} from "../../../src/network/metadata.js"; import {config} from "../../utils/config.js"; diff --git a/packages/beacon-node/test/unit/network/peers/client.test.ts b/packages/beacon-node/test/unit/network/peers/client.test.ts index 44d16ad4bb8f..6d280d82ddcf 100644 --- a/packages/beacon-node/test/unit/network/peers/client.test.ts +++ b/packages/beacon-node/test/unit/network/peers/client.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {getKnownClientFromAgentVersion, ClientKind} from "../../../../src/network/peers/client.js"; +import {describe, expect, it} from "vitest"; +import {ClientKind, getKnownClientFromAgentVersion} from "../../../../src/network/peers/client.js"; describe("clientFromAgentVersion", () => { const testCases: {name: string; agentVersion: string; client: ClientKind | null}[] = [ diff --git a/packages/beacon-node/test/unit/network/peers/datastore.test.ts b/packages/beacon-node/test/unit/network/peers/datastore.test.ts index 6ef60b0962e5..01bdc5b058e5 100644 --- a/packages/beacon-node/test/unit/network/peers/datastore.test.ts +++ b/packages/beacon-node/test/unit/network/peers/datastore.test.ts @@ -1,6 +1,6 @@ import {LevelDatastore} from "datastore-level"; import {Key} from "interface-datastore"; -import {describe, it, expect, beforeEach, afterEach, vi, MockedObject} from "vitest"; +import {MockedObject, afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {Eth2PeerDataStore} from "../../../../src/network/peers/datastore.js"; vi.mock("datastore-level"); diff --git a/packages/beacon-node/test/unit/network/peers/discover.test.ts b/packages/beacon-node/test/unit/network/peers/discover.test.ts index 52e254ec70aa..40614a3c55d1 100644 --- a/packages/beacon-node/test/unit/network/peers/discover.test.ts +++ b/packages/beacon-node/test/unit/network/peers/discover.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {getValidPeerId} from "../../../utils/peer.js"; +import {describe, expect, it} from "vitest"; import {peerIdFromString} from "../../../../src/util/peerId.js"; +import {getValidPeerId} from "../../../utils/peer.js"; describe("network / peers / discover", () => { it("PeerId API", () => { diff --git a/packages/beacon-node/test/unit/network/peers/priorization.test.ts b/packages/beacon-node/test/unit/network/peers/priorization.test.ts index 26f8d8c9e535..168335a4bd31 100644 --- a/packages/beacon-node/test/unit/network/peers/priorization.test.ts +++ b/packages/beacon-node/test/unit/network/peers/priorization.test.ts @@ -1,16 +1,16 @@ +import {BitArray} from "@chainsafe/ssz"; import {PeerId} from "@libp2p/interface"; import {createSecp256k1PeerId} from "@libp2p/peer-id-factory"; -import {BitArray} from "@chainsafe/ssz"; -import {describe, it, expect} from "vitest"; import {ATTESTATION_SUBNET_COUNT} from "@lodestar/params"; +import {describe, expect, it} from "vitest"; +import {RequestedSubnet} from "../../../../src/network/peers/utils/index.js"; import { ExcessPeerDisconnectReason, - prioritizePeers, PrioritizePeersOpts, + prioritizePeers, sortPeersToPrune, } from "../../../../src/network/peers/utils/prioritizePeers.js"; import {getAttnets, getSyncnets} from "../../../utils/network.js"; -import {RequestedSubnet} from "../../../../src/network/peers/utils/index.js"; type Result = ReturnType; diff --git a/packages/beacon-node/test/unit/network/peers/score.test.ts b/packages/beacon-node/test/unit/network/peers/score.test.ts index 8962b282e0ad..2a5c7d51be59 100644 --- a/packages/beacon-node/test/unit/network/peers/score.test.ts +++ b/packages/beacon-node/test/unit/network/peers/score.test.ts @@ -1,13 +1,13 @@ -import {describe, it, expect, beforeEach, afterEach, vi} from "vitest"; import {MapDef} from "@lodestar/utils"; -import {peerIdFromString} from "../../../../src/util/peerId.js"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import { PeerAction, - ScoreState, PeerRpcScoreStore, - updateGossipsubScores, RealScore, + ScoreState, + updateGossipsubScores, } from "../../../../src/network/peers/score/index.js"; +import {peerIdFromString} from "../../../../src/util/peerId.js"; vi.mock("../../../../src/network/peers/score/index.js", async (importActual) => { const mod = await importActual(); diff --git a/packages/beacon-node/test/unit/network/peers/utils/assertPeerRelevance.test.ts b/packages/beacon-node/test/unit/network/peers/utils/assertPeerRelevance.test.ts index 19cf4a9e9c5e..b3ee9e49b3ed 100644 --- a/packages/beacon-node/test/unit/network/peers/utils/assertPeerRelevance.test.ts +++ b/packages/beacon-node/test/unit/network/peers/utils/assertPeerRelevance.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; import {phase0} from "@lodestar/types"; -import {assertPeerRelevance, IrrelevantPeerCode} from "../../../../../src/network/peers/utils/assertPeerRelevance.js"; +import {describe, expect, it} from "vitest"; +import {IrrelevantPeerCode, assertPeerRelevance} from "../../../../../src/network/peers/utils/assertPeerRelevance.js"; describe("network / peers / utils / assertPeerRelevance", () => { const correctForkDigest = Buffer.alloc(4, 0); diff --git a/packages/beacon-node/test/unit/network/peers/utils/enrSubnets.test.ts b/packages/beacon-node/test/unit/network/peers/utils/enrSubnets.test.ts index 1c738c764404..c13cc6152f36 100644 --- a/packages/beacon-node/test/unit/network/peers/utils/enrSubnets.test.ts +++ b/packages/beacon-node/test/unit/network/peers/utils/enrSubnets.test.ts @@ -1,8 +1,8 @@ import {BitArray} from "@chainsafe/ssz"; -import {describe, it, expect} from "vitest"; import {SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params"; import {ssz} from "@lodestar/types"; import {toHex} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; import {deserializeEnrSubnets} from "../../../../../src/network/peers/utils/enrSubnetsDeserialize.js"; describe("ENR syncnets", () => { diff --git a/packages/beacon-node/test/unit/network/processor/aggregatorTracker.test.ts b/packages/beacon-node/test/unit/network/processor/aggregatorTracker.test.ts index da907fd737e9..f211ebbeffae 100644 --- a/packages/beacon-node/test/unit/network/processor/aggregatorTracker.test.ts +++ b/packages/beacon-node/test/unit/network/processor/aggregatorTracker.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, beforeEach} from "vitest"; +import {beforeEach, describe, expect, it} from "vitest"; import {AggregatorTracker} from "../../../../src/network/processor/aggregatorTracker.js"; describe("AggregatorTracker", () => { diff --git a/packages/beacon-node/test/unit/network/processor/gossipQueues/indexed.test.ts b/packages/beacon-node/test/unit/network/processor/gossipQueues/indexed.test.ts index 97f6bb804c99..3776f3e6cfd1 100644 --- a/packages/beacon-node/test/unit/network/processor/gossipQueues/indexed.test.ts +++ b/packages/beacon-node/test/unit/network/processor/gossipQueues/indexed.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, beforeEach, afterEach, vi} from "vitest"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {IndexedGossipQueueMinSize} from "../../../../../src/network/processor/gossipQueues/indexed.js"; type Item = { diff --git a/packages/beacon-node/test/unit/network/processor/gossipQueues/linear.test.ts b/packages/beacon-node/test/unit/network/processor/gossipQueues/linear.test.ts index 5848e1885622..9ad7c8e8b4ad 100644 --- a/packages/beacon-node/test/unit/network/processor/gossipQueues/linear.test.ts +++ b/packages/beacon-node/test/unit/network/processor/gossipQueues/linear.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, beforeEach} from "vitest"; +import {beforeEach, describe, expect, it} from "vitest"; import {LinearGossipQueue} from "../../../../../src/network/processor/gossipQueues/linear.js"; import {DropType} from "../../../../../src/network/processor/gossipQueues/types.js"; import {QueueType} from "../../../../../src/util/queue/index.js"; diff --git a/packages/beacon-node/test/unit/network/processorQueues.test.ts b/packages/beacon-node/test/unit/network/processorQueues.test.ts index 07a10591c0ad..23caae9dd774 100644 --- a/packages/beacon-node/test/unit/network/processorQueues.test.ts +++ b/packages/beacon-node/test/unit/network/processorQueues.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {sleep} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; type ValidateOpts = { skipAsync1: boolean; diff --git a/packages/beacon-node/test/unit/network/reqresp/collectSequentialBlocksInRange.test.ts b/packages/beacon-node/test/unit/network/reqresp/collectSequentialBlocksInRange.test.ts index fa9b47ebf026..79f076c828a7 100644 --- a/packages/beacon-node/test/unit/network/reqresp/collectSequentialBlocksInRange.test.ts +++ b/packages/beacon-node/test/unit/network/reqresp/collectSequentialBlocksInRange.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; -import {SignedBeaconBlock, phase0, ssz} from "@lodestar/types"; -import {ResponseIncoming} from "@lodestar/reqresp"; import {ForkName} from "@lodestar/params"; +import {ResponseIncoming} from "@lodestar/reqresp"; +import {SignedBeaconBlock, phase0, ssz} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; import { BlocksByRangeError, BlocksByRangeErrorCode, diff --git a/packages/beacon-node/test/unit/network/reqresp/utils.ts b/packages/beacon-node/test/unit/network/reqresp/utils.ts index 231bd0cc42fb..01ec743b5258 100644 --- a/packages/beacon-node/test/unit/network/reqresp/utils.ts +++ b/packages/beacon-node/test/unit/network/reqresp/utils.ts @@ -1,9 +1,9 @@ -import {expect} from "vitest"; +import {toHexString} from "@chainsafe/ssz"; import {Direction, ReadStatus, Stream, StreamStatus, WriteStatus} from "@libp2p/interface"; import {logger} from "@libp2p/logger"; -import {Uint8ArrayList} from "uint8arraylist"; -import {toHexString} from "@chainsafe/ssz"; import {Root} from "@lodestar/types"; +import {Uint8ArrayList} from "uint8arraylist"; +import {expect} from "vitest"; export function generateRoots(count: number, offset = 0): Root[] { const roots: Root[] = []; diff --git a/packages/beacon-node/test/unit/network/subnets/attnetsService.test.ts b/packages/beacon-node/test/unit/network/subnets/attnetsService.test.ts index d279a5d759d7..5e7149f4d7f8 100644 --- a/packages/beacon-node/test/unit/network/subnets/attnetsService.test.ts +++ b/packages/beacon-node/test/unit/network/subnets/attnetsService.test.ts @@ -1,6 +1,4 @@ -import {describe, it, expect, beforeEach, vi, MockedObject, afterEach} from "vitest"; import {createBeaconConfig} from "@lodestar/config"; -import {ZERO_HASH} from "@lodestar/state-transition"; import { ATTESTATION_SUBNET_COUNT, EPOCHS_PER_SUBNET_SUBSCRIPTION, @@ -8,14 +6,16 @@ import { SLOTS_PER_EPOCH, SUBNETS_PER_NODE, } from "@lodestar/params"; +import {ZERO_HASH} from "@lodestar/state-transition"; import {getCurrentSlot} from "@lodestar/state-transition"; import {bigIntToBytes} from "@lodestar/utils"; -import {Clock, IClock} from "../../../../src/util/clock.js"; +import {MockedObject, afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {Eth2Gossipsub} from "../../../../src/network/gossip/gossipsub.js"; import {MetadataController} from "../../../../src/network/metadata.js"; -import {testLogger} from "../../../utils/logger.js"; import {AttnetsService} from "../../../../src/network/subnets/attnetsService.js"; import {CommitteeSubscription} from "../../../../src/network/subnets/interface.js"; +import {Clock, IClock} from "../../../../src/util/clock.js"; +import {testLogger} from "../../../utils/logger.js"; vi.mock("../../../../src/network/gossip/gossipsub.js"); diff --git a/packages/beacon-node/test/unit/network/subnets/util.test.ts b/packages/beacon-node/test/unit/network/subnets/util.test.ts index dc2f261d021e..edcc96a772da 100644 --- a/packages/beacon-node/test/unit/network/subnets/util.test.ts +++ b/packages/beacon-node/test/unit/network/subnets/util.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {bigIntToBytes} from "@lodestar/utils"; import {ATTESTATION_SUBNET_PREFIX_BITS, NODE_ID_BITS} from "@lodestar/params"; +import {bigIntToBytes} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; import {getNodeIdPrefix, getNodeOffset} from "../../../../src/network/subnets/util.js"; const nodeIds: string[] = [ diff --git a/packages/beacon-node/test/unit/network/util.test.ts b/packages/beacon-node/test/unit/network/util.test.ts index 70da41bd2c2a..57e18a34a77b 100644 --- a/packages/beacon-node/test/unit/network/util.test.ts +++ b/packages/beacon-node/test/unit/network/util.test.ts @@ -1,8 +1,8 @@ -import {describe, it, expect, afterEach} from "vitest"; import {config} from "@lodestar/config/default"; import {ForkName} from "@lodestar/params"; -import {getDiscv5Multiaddrs} from "../../../src/network/libp2p/index.js"; +import {afterEach, describe, expect, it} from "vitest"; import {getCurrentAndNextFork} from "../../../src/network/forks.js"; +import {getDiscv5Multiaddrs} from "../../../src/network/libp2p/index.js"; describe("getCurrentAndNextFork", () => { const altairEpoch = config.forks.altair.epoch; diff --git a/packages/beacon-node/test/unit/sync/backfill/verify.test.ts b/packages/beacon-node/test/unit/sync/backfill/verify.test.ts index 3197013455e3..fb00e5840317 100644 --- a/packages/beacon-node/test/unit/sync/backfill/verify.test.ts +++ b/packages/beacon-node/test/unit/sync/backfill/verify.test.ts @@ -1,13 +1,13 @@ import fs from "node:fs"; import path from "node:path"; import {fileURLToPath} from "node:url"; -import {describe, it, expect} from "vitest"; import {createBeaconConfig} from "@lodestar/config"; import {config} from "@lodestar/config/default"; -import {phase0, ssz, WithBytes} from "@lodestar/types"; -import {verifyBlockSequence} from "../../../../src/sync/backfill/verify.js"; +import {WithBytes, phase0, ssz} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; import {ZERO_HASH} from "../../../../src/constants/constants.js"; -import {BackfillSyncErrorCode, BackfillSyncError} from "./../../../../src/sync/backfill/errors.js"; +import {verifyBlockSequence} from "../../../../src/sync/backfill/verify.js"; +import {BackfillSyncError, BackfillSyncErrorCode} from "./../../../../src/sync/backfill/errors.js"; // Global variable __dirname no longer available in ES6 modules. // Solutions: https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-js-when-using-es6-modules diff --git a/packages/beacon-node/test/unit/sync/range/batch.test.ts b/packages/beacon-node/test/unit/sync/range/batch.test.ts index 02f49226c11f..2a140760e827 100644 --- a/packages/beacon-node/test/unit/sync/range/batch.test.ts +++ b/packages/beacon-node/test/unit/sync/range/batch.test.ts @@ -1,11 +1,11 @@ -import {describe, it, expect} from "vitest"; -import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {config} from "@lodestar/config/default"; +import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {ssz} from "@lodestar/types"; -import {expectThrowsLodestarError} from "../../../utils/errors.js"; -import {Batch, BatchStatus, BatchErrorCode, BatchError} from "../../../../src/sync/range/batch.js"; -import {EPOCHS_PER_BATCH} from "../../../../src/sync/constants.js"; +import {describe, expect, it} from "vitest"; import {BlockSource, getBlockInput} from "../../../../src/chain/blocks/types.js"; +import {EPOCHS_PER_BATCH} from "../../../../src/sync/constants.js"; +import {Batch, BatchError, BatchErrorCode, BatchStatus} from "../../../../src/sync/range/batch.js"; +import {expectThrowsLodestarError} from "../../../utils/errors.js"; import {validPeerIdStr} from "../../../utils/peer.js"; describe("sync / range / batch", () => { // Common mock data diff --git a/packages/beacon-node/test/unit/sync/range/chain.test.ts b/packages/beacon-node/test/unit/sync/range/chain.test.ts index 658f950b2c18..a761cd3a739a 100644 --- a/packages/beacon-node/test/unit/sync/range/chain.test.ts +++ b/packages/beacon-node/test/unit/sync/range/chain.test.ts @@ -1,16 +1,16 @@ -import {describe, it, afterEach} from "vitest"; import {config} from "@lodestar/config/default"; -import {Logger} from "@lodestar/utils"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; -import {Epoch, phase0, Slot, ssz} from "@lodestar/types"; import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; -import {linspace} from "../../../../src/util/numpy.js"; -import {SyncChain, SyncChainFns, ChainTarget} from "../../../../src/sync/range/chain.js"; -import {RangeSyncType} from "../../../../src/sync/utils/remoteSyncType.js"; +import {Epoch, Slot, phase0, ssz} from "@lodestar/types"; +import {Logger} from "@lodestar/utils"; +import {afterEach, describe, it} from "vitest"; +import {BlockInput, BlockSource, getBlockInput} from "../../../../src/chain/blocks/types.js"; import {ZERO_HASH} from "../../../../src/constants/index.js"; +import {ChainTarget, SyncChain, SyncChainFns} from "../../../../src/sync/range/chain.js"; +import {RangeSyncType} from "../../../../src/sync/utils/remoteSyncType.js"; +import {linspace} from "../../../../src/util/numpy.js"; import {testLogger} from "../../../utils/logger.js"; import {validPeerIdStr} from "../../../utils/peer.js"; -import {BlockInput, BlockSource, getBlockInput} from "../../../../src/chain/blocks/types.js"; describe("sync / range / chain", () => { const testCases: { diff --git a/packages/beacon-node/test/unit/sync/range/utils/batches.test.ts b/packages/beacon-node/test/unit/sync/range/utils/batches.test.ts index c3c6a273dd8d..fcc5f9a1561a 100644 --- a/packages/beacon-node/test/unit/sync/range/utils/batches.test.ts +++ b/packages/beacon-node/test/unit/sync/range/utils/batches.test.ts @@ -1,15 +1,15 @@ -import {describe, it, expect} from "vitest"; import {config} from "@lodestar/config/default"; -import {Epoch, Slot} from "@lodestar/types"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; -import {validPeerIdStr} from "../../../../utils/peer.js"; +import {Epoch, Slot} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; import {Batch, BatchStatus} from "../../../../../src/sync/range/batch.js"; import { - validateBatchesStatus, getNextBatchToProcess, isSyncChainDone, toBeDownloadedStartEpoch, + validateBatchesStatus, } from "../../../../../src/sync/range/utils/batches.js"; +import {validPeerIdStr} from "../../../../utils/peer.js"; describe("sync / range / batches", () => { const peer = validPeerIdStr; diff --git a/packages/beacon-node/test/unit/sync/range/utils/peerBalancer.test.ts b/packages/beacon-node/test/unit/sync/range/utils/peerBalancer.test.ts index a495c41683d6..0eac008d2ecf 100644 --- a/packages/beacon-node/test/unit/sync/range/utils/peerBalancer.test.ts +++ b/packages/beacon-node/test/unit/sync/range/utils/peerBalancer.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {config} from "@lodestar/config/default"; +import {describe, expect, it} from "vitest"; import {Batch} from "../../../../../src/sync/range/batch.js"; import {ChainPeersBalancer} from "../../../../../src/sync/range/utils/peerBalancer.js"; import {getRandPeerIdStr} from "../../../../utils/peer.js"; diff --git a/packages/beacon-node/test/unit/sync/range/utils/updateChains.test.ts b/packages/beacon-node/test/unit/sync/range/utils/updateChains.test.ts index 4ff2da3d4441..cfdad515fb3c 100644 --- a/packages/beacon-node/test/unit/sync/range/utils/updateChains.test.ts +++ b/packages/beacon-node/test/unit/sync/range/utils/updateChains.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {updateChains} from "../../../../../src/sync/range/utils/updateChains.js"; +import {describe, expect, it} from "vitest"; import {SyncChain} from "../../../../../src/sync/range/chain.js"; +import {updateChains} from "../../../../../src/sync/range/utils/updateChains.js"; import {RangeSyncType} from "../../../../../src/sync/utils/remoteSyncType.js"; describe("sync / range / utils / updateChains", () => { diff --git a/packages/beacon-node/test/unit/sync/unknownBlock.test.ts b/packages/beacon-node/test/unit/sync/unknownBlock.test.ts index 0694cb97f4ab..8476d025d4f9 100644 --- a/packages/beacon-node/test/unit/sync/unknownBlock.test.ts +++ b/packages/beacon-node/test/unit/sync/unknownBlock.test.ts @@ -1,23 +1,23 @@ import EventEmitter from "node:events"; import {toHexString} from "@chainsafe/ssz"; -import {describe, it, expect, beforeEach, afterEach, vi} from "vitest"; -import {config as minimalConfig} from "@lodestar/config/default"; import {createChainForkConfig} from "@lodestar/config"; +import {config as minimalConfig} from "@lodestar/config/default"; import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice"; import {ssz} from "@lodestar/types"; import {notNullish, sleep} from "@lodestar/utils"; -import {MockedBeaconChain, getMockedBeaconChain} from "../../mocks/mockedBeaconChain.js"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; +import {BlockSource, getBlockInput} from "../../../src/chain/blocks/types.js"; +import {BlockError, BlockErrorCode} from "../../../src/chain/errors/blockError.js"; import {IBeaconChain} from "../../../src/chain/index.js"; +import {SeenBlockProposers} from "../../../src/chain/seenCache/seenBlockProposers.js"; +import {ZERO_HASH} from "../../../src/constants/constants.js"; import {INetwork, NetworkEvent, NetworkEventBus, PeerAction} from "../../../src/network/index.js"; +import {defaultSyncOptions} from "../../../src/sync/options.js"; import {UnknownBlockSync} from "../../../src/sync/unknownBlock.js"; +import {ClockStopped} from "../../mocks/clock.js"; +import {MockedBeaconChain, getMockedBeaconChain} from "../../mocks/mockedBeaconChain.js"; import {testLogger} from "../../utils/logger.js"; import {getRandPeerIdStr} from "../../utils/peer.js"; -import {BlockSource, getBlockInput} from "../../../src/chain/blocks/types.js"; -import {ClockStopped} from "../../mocks/clock.js"; -import {SeenBlockProposers} from "../../../src/chain/seenCache/seenBlockProposers.js"; -import {BlockError, BlockErrorCode} from "../../../src/chain/errors/blockError.js"; -import {defaultSyncOptions} from "../../../src/sync/options.js"; -import {ZERO_HASH} from "../../../src/constants/constants.js"; describe("sync by UnknownBlockSync", () => { const logger = testLogger(); diff --git a/packages/beacon-node/test/unit/sync/utils/pendingBlocksTree.test.ts b/packages/beacon-node/test/unit/sync/utils/pendingBlocksTree.test.ts index 8e343acc80df..9251c1159c64 100644 --- a/packages/beacon-node/test/unit/sync/utils/pendingBlocksTree.test.ts +++ b/packages/beacon-node/test/unit/sync/utils/pendingBlocksTree.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {RootHex} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; import {PendingBlock, PendingBlockStatus, UnknownAndAncestorBlocks} from "../../../../src/sync/index.js"; import { getAllDescendantBlocks, diff --git a/packages/beacon-node/test/unit/sync/utils/remoteSyncType.test.ts b/packages/beacon-node/test/unit/sync/utils/remoteSyncType.test.ts index 0c74170e8029..7404362d8805 100644 --- a/packages/beacon-node/test/unit/sync/utils/remoteSyncType.test.ts +++ b/packages/beacon-node/test/unit/sync/utils/remoteSyncType.test.ts @@ -1,13 +1,13 @@ import {toHexString} from "@chainsafe/ssz"; -import {describe, it, expect} from "vitest"; import {IForkChoice} from "@lodestar/fork-choice"; import {Root, phase0} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; import {ZERO_HASH} from "../../../../src/constants/index.js"; import { - getPeerSyncType, - getRangeSyncType, PeerSyncType, RangeSyncType, + getPeerSyncType, + getRangeSyncType, } from "../../../../src/sync/utils/remoteSyncType.js"; describe("network / peers / remoteSyncType", () => { diff --git a/packages/beacon-node/test/unit/util/address.test.ts b/packages/beacon-node/test/unit/util/address.test.ts index 27f7eba48e0c..cdc01f52797b 100644 --- a/packages/beacon-node/test/unit/util/address.test.ts +++ b/packages/beacon-node/test/unit/util/address.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {isValidAddress} from "../../../src/util/address.js"; describe("Eth address helper", () => { diff --git a/packages/beacon-node/test/unit/util/array.test.ts b/packages/beacon-node/test/unit/util/array.test.ts index 75d3a1b0856d..343a152bb857 100644 --- a/packages/beacon-node/test/unit/util/array.test.ts +++ b/packages/beacon-node/test/unit/util/array.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect, beforeEach} from "vitest"; -import {findLastIndex, LinkedList} from "../../../src/util/array.js"; +import {beforeEach, describe, expect, it} from "vitest"; +import {LinkedList, findLastIndex} from "../../../src/util/array.js"; describe("findLastIndex", () => { it("should return the last index that matches a predicate", () => { diff --git a/packages/beacon-node/test/unit/util/binarySearch.test.ts b/packages/beacon-node/test/unit/util/binarySearch.test.ts index a64420400c24..cccddbd9ffd8 100644 --- a/packages/beacon-node/test/unit/util/binarySearch.test.ts +++ b/packages/beacon-node/test/unit/util/binarySearch.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {binarySearchLte, ErrorNoValues, ErrorNoValueMinValue} from "../../../src/util/binarySearch.js"; +import {describe, expect, it} from "vitest"; +import {ErrorNoValueMinValue, ErrorNoValues, binarySearchLte} from "../../../src/util/binarySearch.js"; describe("util / binarySearch", () => { describe("binarySearchLte", () => { diff --git a/packages/beacon-node/test/unit/util/bitArray.test.ts b/packages/beacon-node/test/unit/util/bitArray.test.ts index 516b4ae79155..7e569b71a8e2 100644 --- a/packages/beacon-node/test/unit/util/bitArray.test.ts +++ b/packages/beacon-node/test/unit/util/bitArray.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {IntersectResult, intersectUint8Arrays} from "../../../src/util/bitArray.js"; describe("util / bitArray / intersectUint8Arrays", () => { diff --git a/packages/beacon-node/test/unit/util/bufferPool.test.ts b/packages/beacon-node/test/unit/util/bufferPool.test.ts index ff66504ae65f..5c97a05a58e4 100644 --- a/packages/beacon-node/test/unit/util/bufferPool.test.ts +++ b/packages/beacon-node/test/unit/util/bufferPool.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {AllocSource, BufferPool} from "../../../src/util/bufferPool.js"; describe("BufferPool", () => { diff --git a/packages/beacon-node/test/unit/util/bytes.test.ts b/packages/beacon-node/test/unit/util/bytes.test.ts index 1942307cde75..38823939d48b 100644 --- a/packages/beacon-node/test/unit/util/bytes.test.ts +++ b/packages/beacon-node/test/unit/util/bytes.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {fromHexString, toHexString} from "@chainsafe/ssz"; +import {describe, expect, it} from "vitest"; import {byteArrayEquals} from "../../../src/util/bytes.js"; diff --git a/packages/beacon-node/test/unit/util/chunkify.test.ts b/packages/beacon-node/test/unit/util/chunkify.test.ts index 595c5807e1b3..c8af022ccf8e 100644 --- a/packages/beacon-node/test/unit/util/chunkify.test.ts +++ b/packages/beacon-node/test/unit/util/chunkify.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {chunkifyInclusiveRange} from "../../../src/util/chunkify.js"; describe("chunkifyInclusiveRange", () => { diff --git a/packages/beacon-node/test/unit/util/clock.test.ts b/packages/beacon-node/test/unit/util/clock.test.ts index 87955b98182c..cdb4aa39e1aa 100644 --- a/packages/beacon-node/test/unit/util/clock.test.ts +++ b/packages/beacon-node/test/unit/util/clock.test.ts @@ -1,8 +1,8 @@ -import {describe, it, expect, beforeEach, afterEach, vi} from "vitest"; import {config} from "@lodestar/config/default"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; -import {Clock, ClockEvent} from "../../../src/util/clock.js"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {MAXIMUM_GOSSIP_CLOCK_DISPARITY} from "../../../src/constants/index.js"; +import {Clock, ClockEvent} from "../../../src/util/clock.js"; describe("Clock", () => { let abortController: AbortController; diff --git a/packages/beacon-node/test/unit/util/dependentRoot.test.ts b/packages/beacon-node/test/unit/util/dependentRoot.test.ts index c8044f332e34..3961c3e1730b 100644 --- a/packages/beacon-node/test/unit/util/dependentRoot.test.ts +++ b/packages/beacon-node/test/unit/util/dependentRoot.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect, beforeEach, afterEach, vi, Mocked} from "vitest"; -import {EpochDifference, ProtoBlock, ForkChoice} from "@lodestar/fork-choice"; +import {EpochDifference, ForkChoice, ProtoBlock} from "@lodestar/fork-choice"; import {computeEpochAtSlot} from "@lodestar/state-transition"; +import {Mocked, afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {getShufflingDependentRoot} from "../../../src/util/dependentRoot.js"; vi.mock("@lodestar/fork-choice"); diff --git a/packages/beacon-node/test/unit/util/error.test.ts b/packages/beacon-node/test/unit/util/error.test.ts index 61aa4e42d35e..0293acf3f2ba 100644 --- a/packages/beacon-node/test/unit/util/error.test.ts +++ b/packages/beacon-node/test/unit/util/error.test.ts @@ -1,6 +1,6 @@ import v8 from "node:v8"; -import {describe, it, expect} from "vitest"; import {RequestError, RequestErrorCode, RespStatus, ResponseError} from "@lodestar/reqresp"; +import {describe, expect, it} from "vitest"; import {fromThreadBoundaryError, toThreadBoundaryError} from "../../../src/util/error.js"; function structuredClone(value: T): T { diff --git a/packages/beacon-node/test/unit/util/file.test.ts b/packages/beacon-node/test/unit/util/file.test.ts index 6040e14b4263..ad8a1a324fff 100644 --- a/packages/beacon-node/test/unit/util/file.test.ts +++ b/packages/beacon-node/test/unit/util/file.test.ts @@ -1,6 +1,6 @@ import fs from "node:fs"; import path from "node:path"; -import {describe, it, expect, beforeAll, afterAll} from "vitest"; +import {afterAll, beforeAll, describe, expect, it} from "vitest"; import {ensureDir, writeIfNotExist} from "../../../src/util/file.js"; describe("file util", () => { diff --git a/packages/beacon-node/test/unit/util/graffiti.test.ts b/packages/beacon-node/test/unit/util/graffiti.test.ts index 0197e39c5e52..89750d423790 100644 --- a/packages/beacon-node/test/unit/util/graffiti.test.ts +++ b/packages/beacon-node/test/unit/util/graffiti.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {getDefaultGraffiti, toGraffitiBuffer} from "../../../src/util/graffiti.js"; +import {describe, expect, it} from "vitest"; import {ClientCode} from "../../../src/execution/index.js"; +import {getDefaultGraffiti, toGraffitiBuffer} from "../../../src/util/graffiti.js"; describe("Graffiti helper", () => { describe("toGraffitiBuffer", () => { diff --git a/packages/beacon-node/test/unit/util/itTrigger.test.ts b/packages/beacon-node/test/unit/util/itTrigger.test.ts index 942791c118bd..ff76cf13eafa 100644 --- a/packages/beacon-node/test/unit/util/itTrigger.test.ts +++ b/packages/beacon-node/test/unit/util/itTrigger.test.ts @@ -1,5 +1,5 @@ import all from "it-all"; -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ItTrigger} from "../../../src/util/itTrigger.js"; describe("util / itTrigger", () => { diff --git a/packages/beacon-node/test/unit/util/kzg.test.ts b/packages/beacon-node/test/unit/util/kzg.test.ts index 3b1de419ae93..616505268ae1 100644 --- a/packages/beacon-node/test/unit/util/kzg.test.ts +++ b/packages/beacon-node/test/unit/util/kzg.test.ts @@ -1,11 +1,11 @@ -import {describe, it, expect, afterEach, beforeAll} from "vitest"; -import {bellatrix, deneb, ssz} from "@lodestar/types"; -import {BYTES_PER_FIELD_ELEMENT, BLOB_TX_TYPE} from "@lodestar/params"; import {createBeaconConfig, createChainForkConfig, defaultChainConfig} from "@lodestar/config"; -import {getMockedBeaconChain} from "../../mocks/mockedBeaconChain.js"; -import {computeBlobSidecars, kzgCommitmentToVersionedHash} from "../../../src/util/blobs.js"; -import {loadEthereumTrustedSetup, initCKZG, ckzg, FIELD_ELEMENTS_PER_BLOB_MAINNET} from "../../../src/util/kzg.js"; +import {BLOB_TX_TYPE, BYTES_PER_FIELD_ELEMENT} from "@lodestar/params"; +import {bellatrix, deneb, ssz} from "@lodestar/types"; +import {afterEach, beforeAll, describe, expect, it} from "vitest"; import {validateBlobSidecars, validateGossipBlobSidecar} from "../../../src/chain/validation/blobSidecar.js"; +import {computeBlobSidecars, kzgCommitmentToVersionedHash} from "../../../src/util/blobs.js"; +import {FIELD_ELEMENTS_PER_BLOB_MAINNET, ckzg, initCKZG, loadEthereumTrustedSetup} from "../../../src/util/kzg.js"; +import {getMockedBeaconChain} from "../../mocks/mockedBeaconChain.js"; describe("C-KZG", () => { const afterEachCallbacks: (() => Promise | void)[] = []; diff --git a/packages/beacon-node/test/unit/util/map.test.ts b/packages/beacon-node/test/unit/util/map.test.ts index 2d568b89ae3f..f336ac1d3d8e 100644 --- a/packages/beacon-node/test/unit/util/map.test.ts +++ b/packages/beacon-node/test/unit/util/map.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, beforeEach} from "vitest"; +import {beforeEach, describe, expect, it} from "vitest"; import {OrderedMap} from "../../../src/util/map.js"; describe("OrderedMap", () => { diff --git a/packages/beacon-node/test/unit/util/metadata.test.ts b/packages/beacon-node/test/unit/util/metadata.test.ts index 4e732d93e5d0..17e2ba04ce37 100644 --- a/packages/beacon-node/test/unit/util/metadata.test.ts +++ b/packages/beacon-node/test/unit/util/metadata.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {getLodestarClientVersion} from "../../../src/util/metadata.js"; +import {describe, expect, it} from "vitest"; import {ClientCode} from "../../../src/execution/index.js"; +import {getLodestarClientVersion} from "../../../src/util/metadata.js"; describe("util / metadata", () => { describe("getLodestarClientVersion", () => { diff --git a/packages/beacon-node/test/unit/util/peerId.test.ts b/packages/beacon-node/test/unit/util/peerId.test.ts index 92205c5d0334..5014741aa4b9 100644 --- a/packages/beacon-node/test/unit/util/peerId.test.ts +++ b/packages/beacon-node/test/unit/util/peerId.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {peerIdFromString, peerIdToString} from "../../../src/util/peerId.js"; describe("network peerid", () => { diff --git a/packages/beacon-node/test/unit/util/queue.test.ts b/packages/beacon-node/test/unit/util/queue.test.ts index 10c411547c89..3263ec12a0b7 100644 --- a/packages/beacon-node/test/unit/util/queue.test.ts +++ b/packages/beacon-node/test/unit/util/queue.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {sleep} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; import {JobFnQueue, QueueError, QueueErrorCode, QueueType} from "../../../src/util/queue/index.js"; import {expectLodestarError, expectRejectedWithLodestarError} from "../../utils/errors.js"; diff --git a/packages/beacon-node/test/unit/util/set.test.ts b/packages/beacon-node/test/unit/util/set.test.ts index 482819b3b77d..361680d2930c 100644 --- a/packages/beacon-node/test/unit/util/set.test.ts +++ b/packages/beacon-node/test/unit/util/set.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, beforeEach} from "vitest"; +import {beforeEach, describe, expect, it} from "vitest"; import {OrderedSet} from "../../../src/util/set.js"; describe("OrderedSet", () => { diff --git a/packages/beacon-node/test/unit/util/shuffle.test.ts b/packages/beacon-node/test/unit/util/shuffle.test.ts index 2ba879514020..faa99ef67737 100644 --- a/packages/beacon-node/test/unit/util/shuffle.test.ts +++ b/packages/beacon-node/test/unit/util/shuffle.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {shuffle} from "../../../src/util/shuffle.js"; describe("util / shuffle", () => { diff --git a/packages/beacon-node/test/unit/util/sortBy.test.ts b/packages/beacon-node/test/unit/util/sortBy.test.ts index 747327cc2bbd..1c648640ffff 100644 --- a/packages/beacon-node/test/unit/util/sortBy.test.ts +++ b/packages/beacon-node/test/unit/util/sortBy.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {sortBy} from "../../../src/util/sortBy.js"; describe("util / sortBy", () => { diff --git a/packages/beacon-node/test/unit/util/sszBytes.test.ts b/packages/beacon-node/test/unit/util/sszBytes.test.ts index 8b72c31df6c8..8fd6011e6255 100644 --- a/packages/beacon-node/test/unit/util/sszBytes.test.ts +++ b/packages/beacon-node/test/unit/util/sszBytes.test.ts @@ -1,22 +1,22 @@ -import {describe, it, expect} from "vitest"; import {BitArray} from "@chainsafe/ssz"; -import {deneb, electra, Epoch, isElectraAttestation, phase0, RootHex, Slot, ssz} from "@lodestar/types"; -import {fromHex, toHex} from "@lodestar/utils"; import {ForkName, MAX_COMMITTEES_PER_SLOT} from "@lodestar/params"; +import {Epoch, RootHex, Slot, deneb, electra, isElectraAttestation, phase0, ssz} from "@lodestar/types"; +import {fromHex, toHex} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; import { + getAggregationBitsFromAttestationSerialized, getAttDataFromAttestationSerialized, + getAttDataFromSignedAggregateAndProofElectra, getAttDataFromSignedAggregateAndProofPhase0, - getAggregationBitsFromAttestationSerialized, getBlockRootFromAttestationSerialized, getBlockRootFromSignedAggregateAndProofSerialized, + getCommitteeBitsFromAttestationSerialized, + getCommitteeBitsFromSignedAggregateAndProofElectra, + getSignatureFromAttestationSerialized, getSlotFromAttestationSerialized, + getSlotFromBlobSidecarSerialized, getSlotFromSignedAggregateAndProofSerialized, - getSignatureFromAttestationSerialized, getSlotFromSignedBeaconBlockSerialized, - getSlotFromBlobSidecarSerialized, - getCommitteeBitsFromAttestationSerialized, - getCommitteeBitsFromSignedAggregateAndProofElectra, - getAttDataFromSignedAggregateAndProofElectra, } from "../../../src/util/sszBytes.js"; describe("attestation SSZ serialized picking", () => { diff --git a/packages/beacon-node/test/unit/util/time.test.ts b/packages/beacon-node/test/unit/util/time.test.ts index ccf1b9e308c8..2f32729a5225 100644 --- a/packages/beacon-node/test/unit/util/time.test.ts +++ b/packages/beacon-node/test/unit/util/time.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {prettyTimeDiffSec} from "../../../src/util/time.js"; describe("util / time / prettyTimeDiffSec", () => { diff --git a/packages/beacon-node/test/unit/util/timeSeries.test.ts b/packages/beacon-node/test/unit/util/timeSeries.test.ts index b338310c83b1..f273508e885f 100644 --- a/packages/beacon-node/test/unit/util/timeSeries.test.ts +++ b/packages/beacon-node/test/unit/util/timeSeries.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {TimeSeries} from "../../../src/util/timeSeries.js"; // Even with rounding to 3 decimals, the test still breaks sometimes... diff --git a/packages/beacon-node/test/unit/util/wrapError.test.ts b/packages/beacon-node/test/unit/util/wrapError.test.ts index 2a8e5ca15ceb..f972a1bff148 100644 --- a/packages/beacon-node/test/unit/util/wrapError.test.ts +++ b/packages/beacon-node/test/unit/util/wrapError.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {wrapError} from "../../../src/util/wrapError.js"; describe("util / wrapError", () => { diff --git a/packages/beacon-node/test/utils/api.ts b/packages/beacon-node/test/utils/api.ts index 593bae0c2643..17126defc2c2 100644 --- a/packages/beacon-node/test/utils/api.ts +++ b/packages/beacon-node/test/utils/api.ts @@ -1,11 +1,11 @@ -import {Mocked} from "vitest"; import {config} from "@lodestar/config/default"; import {ForkChoice} from "@lodestar/fork-choice"; -import {MockedBeaconChain, MockedBeaconChainOptions, getMockedBeaconChain} from "../mocks/mockedBeaconChain.js"; +import {Mocked} from "vitest"; +import {ApiModules} from "../../src/api/index.js"; import {getMockedBeaconSync} from "../mocks/beaconSyncMock.js"; +import {MockedBeaconChain, MockedBeaconChainOptions, getMockedBeaconChain} from "../mocks/mockedBeaconChain.js"; import {MockedBeaconDb, getMockedBeaconDb} from "../mocks/mockedBeaconDb.js"; import {getMockedNetwork} from "../mocks/mockedNetwork.js"; -import {ApiModules} from "../../src/api/index.js"; type ApiModulesWithoutConfig = Omit; diff --git a/packages/beacon-node/test/utils/cachedBeaconState.ts b/packages/beacon-node/test/utils/cachedBeaconState.ts index 3efb16b6250f..1c092f2ba4a2 100644 --- a/packages/beacon-node/test/utils/cachedBeaconState.ts +++ b/packages/beacon-node/test/utils/cachedBeaconState.ts @@ -1,10 +1,10 @@ +import {ChainForkConfig} from "@lodestar/config"; import { BeaconStateAllForks, BeaconStateCache, createCachedBeaconState, createEmptyEpochCacheImmutableData, } from "@lodestar/state-transition"; -import {ChainForkConfig} from "@lodestar/config"; export function createCachedBeaconStateTest( state: T, diff --git a/packages/beacon-node/test/utils/cliTools/kzgTrustedSetupFromJson.ts b/packages/beacon-node/test/utils/cliTools/kzgTrustedSetupFromJson.ts index 731f44df59c8..d3cb51458c56 100644 --- a/packages/beacon-node/test/utils/cliTools/kzgTrustedSetupFromJson.ts +++ b/packages/beacon-node/test/utils/cliTools/kzgTrustedSetupFromJson.ts @@ -1,5 +1,5 @@ import fs from "node:fs"; -import {TrustedSetupJSON, trustedSetupJsonToBin, TRUSTED_SETUP_BIN_FILEPATH} from "../../../src/util/kzg.js"; +import {TRUSTED_SETUP_BIN_FILEPATH, TrustedSetupJSON, trustedSetupJsonToBin} from "../../../src/util/kzg.js"; // CLI TOOL: Use to transform a JSON trusted setup into .ssz // diff --git a/packages/beacon-node/test/utils/clock.ts b/packages/beacon-node/test/utils/clock.ts index 390d7dd095dd..1e44b1c42551 100644 --- a/packages/beacon-node/test/utils/clock.ts +++ b/packages/beacon-node/test/utils/clock.ts @@ -1,6 +1,6 @@ import EventEmitter from "node:events"; import {computeEpochAtSlot} from "@lodestar/state-transition"; -import {Slot, Epoch} from "@lodestar/types"; +import {Epoch, Slot} from "@lodestar/types"; import {IClock} from "../../src/util/clock.js"; export class ClockStatic extends EventEmitter implements IClock { diff --git a/packages/beacon-node/test/utils/config.ts b/packages/beacon-node/test/utils/config.ts index f5d566560b65..6822b546de1e 100644 --- a/packages/beacon-node/test/utils/config.ts +++ b/packages/beacon-node/test/utils/config.ts @@ -1,5 +1,5 @@ +import {ChainForkConfig, createBeaconConfig, createChainForkConfig} from "@lodestar/config"; import {config as chainConfig} from "@lodestar/config/default"; -import {createBeaconConfig, ChainForkConfig, createChainForkConfig} from "@lodestar/config"; import {ForkName} from "@lodestar/params"; import {ZERO_HASH} from "../../src/constants/index.js"; diff --git a/packages/beacon-node/test/utils/db.ts b/packages/beacon-node/test/utils/db.ts index c44aa7f878dc..88f8de8c0b30 100644 --- a/packages/beacon-node/test/utils/db.ts +++ b/packages/beacon-node/test/utils/db.ts @@ -1,6 +1,6 @@ import childProcess from "node:child_process"; -import {FilterOptions, LevelDbController} from "@lodestar/db"; import {ChainForkConfig} from "@lodestar/config"; +import {FilterOptions, LevelDbController} from "@lodestar/db"; import {BeaconDb} from "../../src/index.js"; import {testLogger} from "./logger.js"; diff --git a/packages/beacon-node/test/utils/errors.ts b/packages/beacon-node/test/utils/errors.ts index 1bf31a2ce9af..7380433292f2 100644 --- a/packages/beacon-node/test/utils/errors.ts +++ b/packages/beacon-node/test/utils/errors.ts @@ -1,5 +1,5 @@ -import {expect} from "vitest"; import {LodestarError, mapValues} from "@lodestar/utils"; +import {expect} from "vitest"; export function expectThrowsLodestarError(fn: () => void, expectedErr: LodestarError | string): void { try { diff --git a/packages/beacon-node/test/utils/logger.ts b/packages/beacon-node/test/utils/logger.ts index 10f27565216f..7d67dd6fbd16 100644 --- a/packages/beacon-node/test/utils/logger.ts +++ b/packages/beacon-node/test/utils/logger.ts @@ -1,6 +1,6 @@ -import {LogLevel} from "@lodestar/utils"; -import {getNodeLogger, LoggerNode, LoggerNodeOpts} from "@lodestar/logger/node"; import {getEnvLogLevel} from "@lodestar/logger/env"; +import {LoggerNode, LoggerNodeOpts, getNodeLogger} from "@lodestar/logger/node"; +import {LogLevel} from "@lodestar/utils"; export {LogLevel}; export type TestLoggerOpts = LoggerNodeOpts; diff --git a/packages/beacon-node/test/utils/networkWithMockDb.ts b/packages/beacon-node/test/utils/networkWithMockDb.ts index 689d332ebbce..d3b7e70e8168 100644 --- a/packages/beacon-node/test/utils/networkWithMockDb.ts +++ b/packages/beacon-node/test/utils/networkWithMockDb.ts @@ -4,6 +4,7 @@ import {ssz} from "@lodestar/types"; import {BeaconChain} from "../../src/chain/chain.js"; import {Eth1ForBlockProductionDisabled} from "../../src/eth1/index.js"; import {ExecutionEngineDisabled} from "../../src/execution/index.js"; +import {StateArchiveMode} from "../../src/index.js"; import {GossipHandlers, Network, NetworkInitModules, getReqRespHandlers} from "../../src/network/index.js"; import {NetworkOptions, defaultNetworkOptions} from "../../src/network/options.js"; import {GetReqRespHandlerFn} from "../../src/network/reqresp/types.js"; @@ -12,7 +13,6 @@ import {createCachedBeaconStateTest} from "./cachedBeaconState.js"; import {ClockStatic} from "./clock.js"; import {testLogger} from "./logger.js"; import {generateState} from "./state.js"; -import {StateArchiveMode} from "../../src/index.js"; export type NetworkForTestOpts = { startSlot?: number; diff --git a/packages/beacon-node/test/utils/node/beacon.ts b/packages/beacon-node/test/utils/node/beacon.ts index 0163fa148102..ea1d7aa3300d 100644 --- a/packages/beacon-node/test/utils/node/beacon.ts +++ b/packages/beacon-node/test/utils/node/beacon.ts @@ -1,24 +1,24 @@ -import deepmerge from "deepmerge"; -import tmp from "tmp"; import {PeerId} from "@libp2p/interface"; import {createSecp256k1PeerId} from "@libp2p/peer-id-factory"; +import {ChainConfig, createBeaconConfig, createChainForkConfig} from "@lodestar/config"; import {config as minimalConfig} from "@lodestar/config/default"; -import {createBeaconConfig, createChainForkConfig, ChainConfig} from "@lodestar/config"; -import {RecursivePartial} from "@lodestar/utils"; import {LevelDbController} from "@lodestar/db"; -import {phase0, ssz} from "@lodestar/types"; +import {LoggerNode} from "@lodestar/logger/node"; import {ForkSeq, GENESIS_SLOT} from "@lodestar/params"; import {BeaconStateAllForks} from "@lodestar/state-transition"; +import {phase0, ssz} from "@lodestar/types"; +import {RecursivePartial} from "@lodestar/utils"; import {isPlainObject} from "@lodestar/utils"; -import {LoggerNode} from "@lodestar/logger/node"; +import deepmerge from "deepmerge"; +import tmp from "tmp"; +import {BeaconDb} from "../../../src/db/index.js"; import {BeaconNode} from "../../../src/index.js"; import {defaultNetworkOptions} from "../../../src/network/options.js"; -import {initDevState, writeDeposits} from "../../../src/node/utils/state.js"; import {IBeaconNodeOptions} from "../../../src/node/options.js"; import {defaultOptions} from "../../../src/node/options.js"; -import {BeaconDb} from "../../../src/db/index.js"; -import {testLogger} from "../logger.js"; import {InteropStateOpts} from "../../../src/node/utils/interop/state.js"; +import {initDevState, writeDeposits} from "../../../src/node/utils/state.js"; +import {testLogger} from "../logger.js"; export async function getDevBeaconNode( opts: { diff --git a/packages/beacon-node/test/utils/node/simTest.ts b/packages/beacon-node/test/utils/node/simTest.ts index 7b771b8534ed..391fc6345b22 100644 --- a/packages/beacon-node/test/utils/node/simTest.ts +++ b/packages/beacon-node/test/utils/node/simTest.ts @@ -1,20 +1,20 @@ import {toHexString} from "@chainsafe/ssz"; +import {routes} from "@lodestar/api"; +import {BeaconConfig} from "@lodestar/config"; +import {SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params"; import { - computeEpochAtSlot, - computeStartSlotAtEpoch, CachedBeaconStateAllForks, beforeProcessEpoch, + computeEpochAtSlot, + computeStartSlotAtEpoch, } from "@lodestar/state-transition"; -import {BeaconConfig} from "@lodestar/config"; -import {SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params"; import {BeaconBlock, Epoch, Slot} from "@lodestar/types"; import {Checkpoint} from "@lodestar/types/phase0"; import {Logger, mapValues} from "@lodestar/utils"; -import {routes} from "@lodestar/api"; -import {BeaconNode} from "../../../src/index.js"; import {ChainEvent, HeadEventData} from "../../../src/chain/index.js"; -import {linspace} from "../../../src/util/numpy.js"; import {RegenCaller} from "../../../src/chain/regen/index.js"; +import {BeaconNode} from "../../../src/index.js"; +import {linspace} from "../../../src/util/numpy.js"; /* eslint-disable no-console */ diff --git a/packages/beacon-node/test/utils/node/validator.ts b/packages/beacon-node/test/utils/node/validator.ts index 285fa13fd01f..f841d0681992 100644 --- a/packages/beacon-node/test/utils/node/validator.ts +++ b/packages/beacon-node/test/utils/node/validator.ts @@ -1,14 +1,14 @@ -import tmp from "tmp"; -import {vi} from "vitest"; import {SecretKey} from "@chainsafe/blst"; +import {ApiClient, ApiError, ApiResponse, HttpStatusCode} from "@lodestar/api"; +import {BeaconApiMethods} from "@lodestar/api/beacon/server"; import {LevelDbController} from "@lodestar/db"; import {interopSecretKey} from "@lodestar/state-transition"; -import {SlashingProtection, Validator, Signer, SignerType, ValidatorProposerConfig} from "@lodestar/validator"; -import {ApiClient, ApiError, HttpStatusCode, ApiResponse} from "@lodestar/api"; -import {BeaconApiMethods} from "@lodestar/api/beacon/server"; import {mapValues} from "@lodestar/utils"; +import {Signer, SignerType, SlashingProtection, Validator, ValidatorProposerConfig} from "@lodestar/validator"; +import tmp from "tmp"; +import {vi} from "vitest"; import {BeaconNode} from "../../../src/index.js"; -import {testLogger, TestLoggerOpts} from "../logger.js"; +import {TestLoggerOpts, testLogger} from "../logger.js"; export async function getAndInitDevValidators({ node, diff --git a/packages/beacon-node/test/utils/peer.ts b/packages/beacon-node/test/utils/peer.ts index 8bd5c6c67be8..81cb83665007 100644 --- a/packages/beacon-node/test/utils/peer.ts +++ b/packages/beacon-node/test/utils/peer.ts @@ -1,6 +1,6 @@ import {PeerId} from "@libp2p/interface"; -import {createSecp256k1PeerId} from "@libp2p/peer-id-factory"; import {peerIdFromBytes} from "@libp2p/peer-id"; +import {createSecp256k1PeerId} from "@libp2p/peer-id-factory"; import {peerIdToString} from "../../src/util/peerId.js"; /** diff --git a/packages/beacon-node/test/utils/runEl.ts b/packages/beacon-node/test/utils/runEl.ts index 9a407f91d414..0cd3189329f8 100644 --- a/packages/beacon-node/test/utils/runEl.ts +++ b/packages/beacon-node/test/utils/runEl.ts @@ -1,10 +1,10 @@ +import {spawn} from "node:child_process"; import fs from "node:fs"; import net from "node:net"; -import {spawn} from "node:child_process"; -import {sleep} from "@lodestar/utils"; import {ChainConfig} from "@lodestar/config"; -import {Eth1Provider} from "../../src/index.js"; +import {sleep} from "@lodestar/utils"; import {ZERO_HASH} from "../../src/constants/index.js"; +import {Eth1Provider} from "../../src/index.js"; import {shell} from "../sim/shell.js"; /* eslint-disable no-console */ diff --git a/packages/beacon-node/test/utils/state.ts b/packages/beacon-node/test/utils/state.ts index 6ad85f3422f7..3e14ccf7630b 100644 --- a/packages/beacon-node/test/utils/state.ts +++ b/packages/beacon-node/test/utils/state.ts @@ -1,23 +1,23 @@ import {SecretKey} from "@chainsafe/blst"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; +import {ChainForkConfig, createBeaconConfig} from "@lodestar/config"; import {config as minimalConfig} from "@lodestar/config/default"; +import {FAR_FUTURE_EPOCH, ForkName, ForkSeq, MAX_EFFECTIVE_BALANCE, SYNC_COMMITTEE_SIZE} from "@lodestar/params"; import { BeaconStateAllForks, + BeaconStateBellatrix, + BeaconStateElectra, CachedBeaconStateAllForks, - createCachedBeaconState, CachedBeaconStateBellatrix, - BeaconStateBellatrix, CachedBeaconStateElectra, - BeaconStateElectra, + createCachedBeaconState, } from "@lodestar/state-transition"; import {BeaconState, altair, bellatrix, electra, ssz} from "@lodestar/types"; -import {createBeaconConfig, ChainForkConfig} from "@lodestar/config"; -import {FAR_FUTURE_EPOCH, ForkName, ForkSeq, MAX_EFFECTIVE_BALANCE, SYNC_COMMITTEE_SIZE} from "@lodestar/params"; -import {ExecutionStatus, ProtoBlock, DataAvailabilityStatus} from "@lodestar/fork-choice"; +import {DataAvailabilityStatus, ExecutionStatus, ProtoBlock} from "@lodestar/fork-choice"; import {ZERO_HASH_HEX} from "../../src/constants/constants.js"; -import {generateValidator, generateValidators} from "./validator.js"; import {getConfig} from "./config.js"; +import {generateValidator, generateValidators} from "./validator.js"; /** * Copy of BeaconState, but all fields are marked optional to allow for swapping out variables as needed. diff --git a/packages/beacon-node/test/utils/testnet.ts b/packages/beacon-node/test/utils/testnet.ts index 0c0c7a8369c8..95abc185b62d 100644 --- a/packages/beacon-node/test/utils/testnet.ts +++ b/packages/beacon-node/test/utils/testnet.ts @@ -1,7 +1,7 @@ import {fromHexString} from "@chainsafe/ssz"; -import {phase0} from "@lodestar/types"; -import {createChainForkConfig, ChainForkConfig} from "@lodestar/config"; +import {ChainForkConfig, createChainForkConfig} from "@lodestar/config"; import {chainConfig} from "@lodestar/config/default"; +import {phase0} from "@lodestar/types"; /** Generic testnet data taken from the Medalla testnet */ export const medallaTestnetConfig = { diff --git a/packages/beacon-node/test/utils/typeGenerator.ts b/packages/beacon-node/test/utils/typeGenerator.ts index dde169ebce26..329060e6eb31 100644 --- a/packages/beacon-node/test/utils/typeGenerator.ts +++ b/packages/beacon-node/test/utils/typeGenerator.ts @@ -1,6 +1,6 @@ +import {DataAvailabilityStatus, ExecutionStatus, ProtoBlock} from "@lodestar/fork-choice"; import {Slot} from "@lodestar/types"; import {phase0} from "@lodestar/types"; -import {ProtoBlock, ExecutionStatus, DataAvailabilityStatus} from "@lodestar/fork-choice"; import {ssz} from "@lodestar/types"; import {fromHex} from "@lodestar/utils"; import {ZERO_HASH_HEX} from "../../src/constants/index.js"; diff --git a/packages/beacon-node/test/utils/validationData/aggregateAndProof.ts b/packages/beacon-node/test/utils/validationData/aggregateAndProof.ts index 462502719134..a8ac5833fbd5 100644 --- a/packages/beacon-node/test/utils/validationData/aggregateAndProof.ts +++ b/packages/beacon-node/test/utils/validationData/aggregateAndProof.ts @@ -1,11 +1,11 @@ -import {computeSigningRoot} from "@lodestar/state-transition"; import {DOMAIN_AGGREGATE_AND_PROOF, DOMAIN_SELECTION_PROOF} from "@lodestar/params"; +import {computeSigningRoot} from "@lodestar/state-transition"; import {phase0, ssz} from "@lodestar/types"; import {getSecretKeyFromIndexCached} from "../../../../state-transition/test/perf/util.js"; import {IBeaconChain} from "../../../src/chain/index.js"; import {SeenAggregators} from "../../../src/chain/seenCache/index.js"; import {signCached} from "../cache.js"; -import {getAttestationValidData, AttestationValidDataOpts} from "./attestation.js"; +import {AttestationValidDataOpts, getAttestationValidData} from "./attestation.js"; export type AggregateAndProofValidDataOpts = AttestationValidDataOpts; diff --git a/packages/beacon-node/test/utils/validationData/attestation.ts b/packages/beacon-node/test/utils/validationData/attestation.ts index 6715512ac667..40dccbd77f18 100644 --- a/packages/beacon-node/test/utils/validationData/attestation.ts +++ b/packages/beacon-node/test/utils/validationData/attestation.ts @@ -1,24 +1,24 @@ import {BitArray, toHexString} from "@chainsafe/ssz"; -import {computeEpochAtSlot, computeSigningRoot, computeStartSlotAtEpoch} from "@lodestar/state-transition"; -import {ProtoBlock, IForkChoice, ExecutionStatus, DataAvailabilityStatus} from "@lodestar/fork-choice"; +import {DataAvailabilityStatus, ExecutionStatus, IForkChoice, ProtoBlock} from "@lodestar/fork-choice"; import {DOMAIN_BEACON_ATTESTER} from "@lodestar/params"; -import {phase0, Slot, ssz} from "@lodestar/types"; +import {computeEpochAtSlot, computeSigningRoot, computeStartSlotAtEpoch} from "@lodestar/state-transition"; +import {Slot, phase0, ssz} from "@lodestar/types"; import { generateTestCachedBeaconStateOnlyValidators, getSecretKeyFromIndexCached, } from "../../../../state-transition/test/perf/util.js"; +import {BlsMultiThreadWorkerPool, BlsSingleThreadVerifier} from "../../../src/chain/bls/index.js"; import {IBeaconChain} from "../../../src/chain/index.js"; +import {defaultChainOptions} from "../../../src/chain/options.js"; import {IStateRegenerator} from "../../../src/chain/regen/index.js"; -import {ZERO_HASH, ZERO_HASH_HEX} from "../../../src/constants/index.js"; import {SeenAttesters} from "../../../src/chain/seenCache/index.js"; -import {BlsMultiThreadWorkerPool, BlsSingleThreadVerifier} from "../../../src/chain/bls/index.js"; -import {signCached} from "../cache.js"; -import {ClockStatic} from "../clock.js"; import {SeenAggregatedAttestations} from "../../../src/chain/seenCache/seenAggregateAndProof.js"; import {SeenAttestationDatas} from "../../../src/chain/seenCache/seenAttestationData.js"; -import {defaultChainOptions} from "../../../src/chain/options.js"; -import {testLogger} from "../logger.js"; import {ShufflingCache} from "../../../src/chain/shufflingCache.js"; +import {ZERO_HASH, ZERO_HASH_HEX} from "../../../src/constants/index.js"; +import {signCached} from "../cache.js"; +import {ClockStatic} from "../clock.js"; +import {testLogger} from "../logger.js"; export type AttestationValidDataOpts = { currentSlot?: Slot; diff --git a/packages/cli/src/applyPreset.ts b/packages/cli/src/applyPreset.ts index 612c5d648c63..06d29d353af8 100644 --- a/packages/cli/src/applyPreset.ts +++ b/packages/cli/src/applyPreset.ts @@ -21,7 +21,7 @@ setHasher(hasher); // set LODESTAR_PRESET manually every time. // IMPORTANT: only import Lodestar code here which does not import any other Lodestar libraries -import {setActivePreset, presetFromJson, PresetName} from "@lodestar/params/setPreset"; +import {PresetName, presetFromJson, setActivePreset} from "@lodestar/params/setPreset"; import {readFile} from "./util/file.js"; const network = valueOfArg("network"); diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index e8f4aeba8ebc..d64661f6ec66 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -1,7 +1,7 @@ +import {registerCommandToYargs} from "@lodestar/utils"; // Must not use `* as yargs`, see https://github.com/yargs/yargs/issues/1131 import yargs from "yargs"; import {hideBin} from "yargs/helpers"; -import {registerCommandToYargs} from "@lodestar/utils"; import {cmds} from "./cmds/index.js"; import {globalOptions, rcConfigOption} from "./options/index.js"; import {getVersionData} from "./util/version.js"; diff --git a/packages/cli/src/cmds/beacon/handler.ts b/packages/cli/src/cmds/beacon/handler.ts index ea424e04824a..389bcea25223 100644 --- a/packages/cli/src/cmds/beacon/handler.ts +++ b/packages/cli/src/cmds/beacon/handler.ts @@ -1,30 +1,30 @@ import path from "node:path"; import {getHeapStatistics} from "node:v8"; -import {ErrorAborted} from "@lodestar/utils"; -import {LevelDbController} from "@lodestar/db"; -import {BeaconNode, BeaconDb} from "@lodestar/beacon-node"; +import {BeaconDb, BeaconNode} from "@lodestar/beacon-node"; import {ChainForkConfig, createBeaconConfig} from "@lodestar/config"; +import {LevelDbController} from "@lodestar/db"; +import {LoggerNode, getNodeLogger} from "@lodestar/logger/node"; import {ACTIVE_PRESET, PresetName} from "@lodestar/params"; +import {ErrorAborted} from "@lodestar/utils"; import {ProcessShutdownCallback} from "@lodestar/validator"; -import {LoggerNode, getNodeLogger} from "@lodestar/logger/node"; -import {GlobalArgs, parseBeaconNodeArgs} from "../../options/index.js"; import {BeaconNodeOptions, getBeaconConfigFromArgs} from "../../config/index.js"; import {getNetworkBootnodes, getNetworkData, isKnownNetworkName, readBootnodes} from "../../networks/index.js"; +import {GlobalArgs, parseBeaconNodeArgs} from "../../options/index.js"; +import {LogArgs} from "../../options/logOptions.js"; import { - onGracefulShutdown, - mkdir, - writeFile600Perm, cleanOldLogFiles, + mkdir, + onGracefulShutdown, parseLoggerArgs, pruneOldFilesInDir, + writeFile600Perm, } from "../../util/index.js"; import {getVersionData} from "../../util/version.js"; -import {LogArgs} from "../../options/logOptions.js"; -import {BeaconArgs} from "./options.js"; -import {getBeaconPaths} from "./paths.js"; import {initBeaconState} from "./initBeaconState.js"; import {initPeerIdAndEnr} from "./initPeerIdAndEnr.js"; +import {BeaconArgs} from "./options.js"; +import {getBeaconPaths} from "./paths.js"; const DEFAULT_RETENTION_SSZ_OBJECTS_HOURS = 15 * 24; const HOURS_TO_MS = 3600 * 1000; diff --git a/packages/cli/src/cmds/beacon/index.ts b/packages/cli/src/cmds/beacon/index.ts index d1d91b9fe424..9746a43d40fb 100644 --- a/packages/cli/src/cmds/beacon/index.ts +++ b/packages/cli/src/cmds/beacon/index.ts @@ -1,7 +1,7 @@ import {CliCommand, CliCommandOptions} from "@lodestar/utils"; import {GlobalArgs} from "../../options/index.js"; -import {beaconOptions, BeaconArgs} from "./options.js"; import {beaconHandler} from "./handler.js"; +import {BeaconArgs, beaconOptions} from "./options.js"; export const beacon: CliCommand = { command: "beacon", diff --git a/packages/cli/src/cmds/beacon/initBeaconState.ts b/packages/cli/src/cmds/beacon/initBeaconState.ts index 8dc9e9317c65..5fc32d63de6b 100644 --- a/packages/cli/src/cmds/beacon/initBeaconState.ts +++ b/packages/cli/src/cmds/beacon/initBeaconState.ts @@ -1,30 +1,30 @@ -import {ssz} from "@lodestar/types"; -import {createBeaconConfig, BeaconConfig, ChainForkConfig} from "@lodestar/config"; -import {Logger, formatBytes} from "@lodestar/utils"; -import { - isWithinWeakSubjectivityPeriod, - ensureWithinWeakSubjectivityPeriod, - BeaconStateAllForks, - loadState, - loadStateAndValidators, -} from "@lodestar/state-transition"; import { IBeaconDb, IBeaconNodeOptions, checkAndPersistAnchorState, - initStateFromEth1, getStateTypeFromBytes, + initStateFromEth1, } from "@lodestar/beacon-node"; +import {BeaconConfig, ChainForkConfig, createBeaconConfig} from "@lodestar/config"; +import { + BeaconStateAllForks, + ensureWithinWeakSubjectivityPeriod, + isWithinWeakSubjectivityPeriod, + loadState, + loadStateAndValidators, +} from "@lodestar/state-transition"; +import {ssz} from "@lodestar/types"; import {Checkpoint} from "@lodestar/types/phase0"; +import {Logger, formatBytes} from "@lodestar/utils"; -import {downloadOrLoadFile, wrapFnError} from "../../util/index.js"; -import {defaultNetwork, GlobalArgs} from "../../options/globalOptions.js"; import { fetchWeakSubjectivityState, getCheckpointFromArg, - getGenesisFileUrl, getCheckpointFromState, + getGenesisFileUrl, } from "../../networks/index.js"; +import {GlobalArgs, defaultNetwork} from "../../options/globalOptions.js"; +import {downloadOrLoadFile, wrapFnError} from "../../util/index.js"; import {BeaconArgs} from "./options.js"; type StateWithBytes = {state: BeaconStateAllForks; stateBytes: Uint8Array}; diff --git a/packages/cli/src/cmds/beacon/initPeerIdAndEnr.ts b/packages/cli/src/cmds/beacon/initPeerIdAndEnr.ts index 3e5963797c3d..cac34d65b194 100644 --- a/packages/cli/src/cmds/beacon/initPeerIdAndEnr.ts +++ b/packages/cli/src/cmds/beacon/initPeerIdAndEnr.ts @@ -1,14 +1,14 @@ import fs from "node:fs"; -import path from "node:path"; import os from "node:os"; +import path from "node:path"; +import {SignableENR, createPrivateKeyFromPeerId} from "@chainsafe/enr"; import type {PeerId} from "@libp2p/interface"; import {createSecp256k1PeerId} from "@libp2p/peer-id-factory"; -import {Multiaddr} from "@multiformats/multiaddr"; -import {createPrivateKeyFromPeerId, SignableENR} from "@chainsafe/enr"; import {Logger} from "@lodestar/utils"; +import {Multiaddr} from "@multiformats/multiaddr"; import {exportToJSON, readPeerId} from "../../config/index.js"; -import {writeFile600Perm} from "../../util/file.js"; import {parseListenArgs} from "../../options/beaconNodeOptions/network.js"; +import {writeFile600Perm} from "../../util/file.js"; import {BeaconArgs} from "./options.js"; /** diff --git a/packages/cli/src/cmds/beacon/options.ts b/packages/cli/src/cmds/beacon/options.ts index 5b57b58e82e2..a623ca99512c 100644 --- a/packages/cli/src/cmds/beacon/options.ts +++ b/packages/cli/src/cmds/beacon/options.ts @@ -1,7 +1,7 @@ import {CliCommandOptions, CliOptionDefinition} from "@lodestar/utils"; -import {beaconNodeOptions, paramsOptions, BeaconNodeArgs} from "../../options/index.js"; +import {BeaconNodeArgs, beaconNodeOptions, paramsOptions} from "../../options/index.js"; import {LogArgs, logOptions} from "../../options/logOptions.js"; -import {defaultBeaconPaths, BeaconPaths} from "./paths.js"; +import {BeaconPaths, defaultBeaconPaths} from "./paths.js"; type BeaconExtraArgs = { forceGenesis?: boolean; diff --git a/packages/cli/src/cmds/beacon/paths.ts b/packages/cli/src/cmds/beacon/paths.ts index f92732b2a94e..9485bc5fca8a 100644 --- a/packages/cli/src/cmds/beacon/paths.ts +++ b/packages/cli/src/cmds/beacon/paths.ts @@ -1,6 +1,6 @@ import path from "node:path"; import {GlobalArgs} from "../../options/index.js"; -import {getGlobalPaths, GlobalPaths} from "../../paths/global.js"; +import {GlobalPaths, getGlobalPaths} from "../../paths/global.js"; export type BeaconPathsPartial = Partial<{ beaconDir: string; diff --git a/packages/cli/src/cmds/bootnode/handler.ts b/packages/cli/src/cmds/bootnode/handler.ts index 8a262d8f12b7..4dc044a87006 100644 --- a/packages/cli/src/cmds/bootnode/handler.ts +++ b/packages/cli/src/cmds/bootnode/handler.ts @@ -1,21 +1,21 @@ import path from "node:path"; -import {Multiaddr, multiaddr} from "@multiformats/multiaddr"; import {Discv5} from "@chainsafe/discv5"; import {ENR} from "@chainsafe/enr"; -import {ErrorAborted} from "@lodestar/utils"; import {HttpMetricsServer, RegistryMetricCreator, getHttpMetricsServer} from "@lodestar/beacon-node"; +import {ErrorAborted} from "@lodestar/utils"; +import {Multiaddr, multiaddr} from "@multiformats/multiaddr"; -import {GlobalArgs} from "../../options/index.js"; import {getBeaconConfigFromArgs} from "../../config/index.js"; import {getNetworkBootnodes, isKnownNetworkName, readBootnodes} from "../../networks/index.js"; -import {onGracefulShutdown, mkdir, writeFile600Perm} from "../../util/index.js"; -import {getVersionData} from "../../util/version.js"; -import {initPeerIdAndEnr} from "../beacon/initPeerIdAndEnr.js"; import {parseArgs as parseMetricsArgs} from "../../options/beaconNodeOptions/metrics.js"; import {parseArgs as parseNetworkArgs} from "../../options/beaconNodeOptions/network.js"; -import {getBeaconPaths} from "../beacon/paths.js"; -import {BeaconArgs} from "../beacon/options.js"; +import {GlobalArgs} from "../../options/index.js"; +import {mkdir, onGracefulShutdown, writeFile600Perm} from "../../util/index.js"; +import {getVersionData} from "../../util/version.js"; import {initLogger} from "../beacon/handler.js"; +import {initPeerIdAndEnr} from "../beacon/initPeerIdAndEnr.js"; +import {BeaconArgs} from "../beacon/options.js"; +import {getBeaconPaths} from "../beacon/paths.js"; import {BootnodeArgs} from "./options.js"; /** diff --git a/packages/cli/src/cmds/bootnode/index.ts b/packages/cli/src/cmds/bootnode/index.ts index 6fc3c01247d6..3143f7a77ba7 100644 --- a/packages/cli/src/cmds/bootnode/index.ts +++ b/packages/cli/src/cmds/bootnode/index.ts @@ -1,7 +1,7 @@ import {CliCommand, CliCommandOptions} from "@lodestar/utils"; import {GlobalArgs} from "../../options/index.js"; -import {bootnodeOptions, BootnodeArgs} from "./options.js"; import {bootnodeHandler} from "./handler.js"; +import {BootnodeArgs, bootnodeOptions} from "./options.js"; export const bootnode: CliCommand = { command: "bootnode", diff --git a/packages/cli/src/cmds/bootnode/options.ts b/packages/cli/src/cmds/bootnode/options.ts index f3422b4029a1..e4e943bfef0c 100644 --- a/packages/cli/src/cmds/bootnode/options.ts +++ b/packages/cli/src/cmds/bootnode/options.ts @@ -1,7 +1,7 @@ -import {CliOptionDefinition, CliCommandOptions} from "@lodestar/utils"; -import {LogArgs, logOptions} from "../../options/logOptions.js"; +import {CliCommandOptions, CliOptionDefinition} from "@lodestar/utils"; import {MetricsArgs, options as metricsOptions} from "../../options/beaconNodeOptions/metrics.js"; import {defaultListenAddress, defaultP2pPort, defaultP2pPort6} from "../../options/beaconNodeOptions/network.js"; +import {LogArgs, logOptions} from "../../options/logOptions.js"; type BootnodeExtraArgs = { listenAddress?: string; diff --git a/packages/cli/src/cmds/dev/files.ts b/packages/cli/src/cmds/dev/files.ts index 9baf0dc845dd..e5b019c4b48e 100644 --- a/packages/cli/src/cmds/dev/files.ts +++ b/packages/cli/src/cmds/dev/files.ts @@ -2,9 +2,9 @@ import fs from "node:fs"; import path from "node:path"; import {Keystore} from "@chainsafe/bls-keystore"; import {nodeUtils} from "@lodestar/beacon-node"; -import {chainConfigToJson, ChainForkConfig} from "@lodestar/config"; -import {dumpYaml} from "@lodestar/utils"; +import {ChainForkConfig, chainConfigToJson} from "@lodestar/config"; import {interopSecretKey} from "@lodestar/state-transition"; +import {dumpYaml} from "@lodestar/utils"; import {PersistedKeysBackend} from "../validator/keymanager/persistedKeys.js"; /* eslint-disable no-console */ diff --git a/packages/cli/src/cmds/dev/handler.ts b/packages/cli/src/cmds/dev/handler.ts index 3018bb8790a6..43fe12435a9a 100644 --- a/packages/cli/src/cmds/dev/handler.ts +++ b/packages/cli/src/cmds/dev/handler.ts @@ -1,16 +1,16 @@ import fs from "node:fs"; -import {rimraf} from "rimraf"; -import {toHex, fromHex} from "@lodestar/utils"; import {nodeUtils} from "@lodestar/beacon-node"; +import {fromHex, toHex} from "@lodestar/utils"; +import {rimraf} from "rimraf"; +import {getBeaconConfigFromArgs} from "../../config/beaconParams.js"; import {GlobalArgs} from "../../options/index.js"; import {mkdir, onGracefulShutdown} from "../../util/index.js"; -import {getBeaconConfigFromArgs} from "../../config/beaconParams.js"; -import {getBeaconPaths} from "../beacon/paths.js"; -import {getValidatorPaths} from "../validator/paths.js"; import {beaconHandler} from "../beacon/handler.js"; +import {getBeaconPaths} from "../beacon/paths.js"; import {validatorHandler} from "../validator/handler.js"; -import {IDevArgs} from "./options.js"; +import {getValidatorPaths} from "../validator/paths.js"; import {writeTestnetFiles} from "./files.js"; +import {IDevArgs} from "./options.js"; /** * Run a beacon node with validator diff --git a/packages/cli/src/cmds/dev/index.ts b/packages/cli/src/cmds/dev/index.ts index 6c0f73327816..b628d116c526 100644 --- a/packages/cli/src/cmds/dev/index.ts +++ b/packages/cli/src/cmds/dev/index.ts @@ -1,7 +1,7 @@ import {CliCommand, CliCommandOptions} from "@lodestar/utils"; import {GlobalArgs} from "../../options/index.js"; -import {devOptions, IDevArgs} from "./options.js"; import {devHandler} from "./handler.js"; +import {IDevArgs, devOptions} from "./options.js"; export const dev: CliCommand = { command: "dev", diff --git a/packages/cli/src/cmds/dev/options.ts b/packages/cli/src/cmds/dev/options.ts index e442b0605cdc..3bbc32f0ab0e 100644 --- a/packages/cli/src/cmds/dev/options.ts +++ b/packages/cli/src/cmds/dev/options.ts @@ -1,7 +1,7 @@ import {CliCommandOptions, CliOptionDefinition} from "@lodestar/utils"; -import {beaconOptions, BeaconArgs} from "../beacon/options.js"; import {NetworkName} from "../../networks/index.js"; import {beaconNodeOptions, globalOptions} from "../../options/index.js"; +import {BeaconArgs, beaconOptions} from "../beacon/options.js"; import {IValidatorCliArgs, validatorOptions} from "../validator/options.js"; type IDevOwnArgs = { diff --git a/packages/cli/src/cmds/index.ts b/packages/cli/src/cmds/index.ts index 7f701379b097..36217ef1b622 100644 --- a/packages/cli/src/cmds/index.ts +++ b/packages/cli/src/cmds/index.ts @@ -1,10 +1,10 @@ import {CliCommand} from "@lodestar/utils"; import {GlobalArgs} from "../options/index.js"; import {beacon} from "./beacon/index.js"; +import {bootnode} from "./bootnode/index.js"; import {dev} from "./dev/index.js"; -import {validator} from "./validator/index.js"; import {lightclient} from "./lightclient/index.js"; -import {bootnode} from "./bootnode/index.js"; +import {validator} from "./validator/index.js"; export const cmds: Required>>["subcommands"] = [ beacon, diff --git a/packages/cli/src/cmds/lightclient/handler.ts b/packages/cli/src/cmds/lightclient/handler.ts index 5af8f84d8959..b51a7227ce4c 100644 --- a/packages/cli/src/cmds/lightclient/handler.ts +++ b/packages/cli/src/cmds/lightclient/handler.ts @@ -5,9 +5,9 @@ import {LightClientRestTransport} from "@lodestar/light-client/transport"; import {getNodeLogger} from "@lodestar/logger/node"; import {fromHex} from "@lodestar/utils"; import {getBeaconConfigFromArgs} from "../../config/beaconParams.js"; +import {GlobalArgs} from "../../options/index.js"; import {getGlobalPaths} from "../../paths/global.js"; import {parseLoggerArgs} from "../../util/logger.js"; -import {GlobalArgs} from "../../options/index.js"; import {ILightClientArgs} from "./options.js"; export async function lightclientHandler(args: ILightClientArgs & GlobalArgs): Promise { diff --git a/packages/cli/src/cmds/lightclient/index.ts b/packages/cli/src/cmds/lightclient/index.ts index bf85df50800f..55c56697bd0a 100644 --- a/packages/cli/src/cmds/lightclient/index.ts +++ b/packages/cli/src/cmds/lightclient/index.ts @@ -1,7 +1,7 @@ import {CliCommand} from "@lodestar/utils"; import {GlobalArgs} from "../../options/index.js"; -import {ILightClientArgs, lightclientOptions} from "./options.js"; import {lightclientHandler} from "./handler.js"; +import {ILightClientArgs, lightclientOptions} from "./options.js"; export const lightclient: CliCommand = { command: "lightclient", diff --git a/packages/cli/src/cmds/validator/blsToExecutionChange.ts b/packages/cli/src/cmds/validator/blsToExecutionChange.ts index 7fbdbb029bf5..2eeaab846589 100644 --- a/packages/cli/src/cmds/validator/blsToExecutionChange.ts +++ b/packages/cli/src/cmds/validator/blsToExecutionChange.ts @@ -1,13 +1,13 @@ import {SecretKey} from "@chainsafe/blst"; -import {computeSigningRoot} from "@lodestar/state-transition"; -import {DOMAIN_BLS_TO_EXECUTION_CHANGE, ForkName} from "@lodestar/params"; -import {createBeaconConfig} from "@lodestar/config"; -import {ssz, capella} from "@lodestar/types"; import {getClient} from "@lodestar/api"; +import {createBeaconConfig} from "@lodestar/config"; +import {DOMAIN_BLS_TO_EXECUTION_CHANGE, ForkName} from "@lodestar/params"; +import {computeSigningRoot} from "@lodestar/state-transition"; +import {capella, ssz} from "@lodestar/types"; import {CliCommand, fromHex} from "@lodestar/utils"; -import {GlobalArgs} from "../../options/index.js"; import {getBeaconConfigFromArgs} from "../../config/index.js"; +import {GlobalArgs} from "../../options/index.js"; import {IValidatorCliArgs} from "./options.js"; /* eslint-disable no-console */ diff --git a/packages/cli/src/cmds/validator/handler.ts b/packages/cli/src/cmds/validator/handler.ts index 66e66400a3fd..6cb48f862bda 100644 --- a/packages/cli/src/cmds/validator/handler.ts +++ b/packages/cli/src/cmds/validator/handler.ts @@ -1,6 +1,14 @@ -import path from "node:path"; import {setMaxListeners} from "node:events"; +import path from "node:path"; +import {WireFormat, routes} from "@lodestar/api"; +import { + MonitoringService, + RegistryMetricCreator, + collectNodeJSMetrics, + getHttpMetricsServer, +} from "@lodestar/beacon-node"; import {LevelDbController} from "@lodestar/db"; +import {getNodeLogger} from "@lodestar/logger/node"; import { ProcessShutdownCallback, SlashingProtection, @@ -8,29 +16,21 @@ import { ValidatorProposerConfig, defaultOptions, } from "@lodestar/validator"; -import {WireFormat, routes} from "@lodestar/api"; import {getMetrics} from "@lodestar/validator"; -import { - RegistryMetricCreator, - collectNodeJSMetrics, - getHttpMetricsServer, - MonitoringService, -} from "@lodestar/beacon-node"; -import {getNodeLogger} from "@lodestar/logger/node"; import {getBeaconConfigFromArgs} from "../../config/index.js"; import {GlobalArgs} from "../../options/index.js"; import {YargsError, cleanOldLogFiles, mkdir, parseLoggerArgs} from "../../util/index.js"; import {onGracefulShutdown, parseFeeRecipient, parseProposerConfig} from "../../util/index.js"; +import {parseBuilderBoostFactor, parseBuilderSelection} from "../../util/proposerConfig.js"; import {getVersionData} from "../../util/version.js"; -import {parseBuilderSelection, parseBuilderBoostFactor} from "../../util/proposerConfig.js"; -import {getAccountPaths, getValidatorPaths} from "./paths.js"; -import {IValidatorCliArgs, validatorMetricsDefaultOptions, validatorMonitoringDefaultOptions} from "./options.js"; -import {getSignersFromArgs} from "./signers/index.js"; -import {logSigners, warnOrExitNoSigners} from "./signers/logSigners.js"; import {KeymanagerApi} from "./keymanager/impl.js"; -import {PersistedKeysBackend} from "./keymanager/persistedKeys.js"; import {IPersistedKeysBackend} from "./keymanager/interface.js"; +import {PersistedKeysBackend} from "./keymanager/persistedKeys.js"; import {KeymanagerRestApiServer} from "./keymanager/server.js"; +import {IValidatorCliArgs, validatorMetricsDefaultOptions, validatorMonitoringDefaultOptions} from "./options.js"; +import {getAccountPaths, getValidatorPaths} from "./paths.js"; +import {getSignersFromArgs} from "./signers/index.js"; +import {logSigners, warnOrExitNoSigners} from "./signers/logSigners.js"; /** * Runs a validator client. diff --git a/packages/cli/src/cmds/validator/import.ts b/packages/cli/src/cmds/validator/import.ts index 48e5205549f1..2c9343cf71e2 100644 --- a/packages/cli/src/cmds/validator/import.ts +++ b/packages/cli/src/cmds/validator/import.ts @@ -1,13 +1,13 @@ import fs from "node:fs"; import {Keystore} from "@chainsafe/bls-keystore"; import {CliCommand} from "@lodestar/utils"; -import {YargsError, getPubkeyHexFromKeystore} from "../../util/index.js"; import {getBeaconConfigFromArgs} from "../../config/beaconParams.js"; import {GlobalArgs} from "../../options/index.js"; -import {validatorOptions, IValidatorCliArgs} from "./options.js"; +import {YargsError, getPubkeyHexFromKeystore} from "../../util/index.js"; +import {PersistedKeysBackend} from "./keymanager/persistedKeys.js"; +import {IValidatorCliArgs, validatorOptions} from "./options.js"; import {getAccountPaths} from "./paths.js"; import {importKeystoreDefinitionsFromExternalDir, readPassphraseOrPrompt} from "./signers/importExternalKeystores.js"; -import {PersistedKeysBackend} from "./keymanager/persistedKeys.js"; /* eslint-disable no-console */ diff --git a/packages/cli/src/cmds/validator/index.ts b/packages/cli/src/cmds/validator/index.ts index d0c7ea86c042..0c41744e49fd 100644 --- a/packages/cli/src/cmds/validator/index.ts +++ b/packages/cli/src/cmds/validator/index.ts @@ -1,13 +1,13 @@ import {CliCommand} from "@lodestar/utils"; import {GlobalArgs} from "../../options/index.js"; -import {getAccountPaths} from "./paths.js"; -import {slashingProtection} from "./slashingProtection/index.js"; +import {blsToExecutionChange} from "./blsToExecutionChange.js"; +import {validatorHandler} from "./handler.js"; import {importCmd} from "./import.js"; import {list} from "./list.js"; +import {IValidatorCliArgs, validatorOptions} from "./options.js"; +import {getAccountPaths} from "./paths.js"; +import {slashingProtection} from "./slashingProtection/index.js"; import {voluntaryExit} from "./voluntaryExit.js"; -import {blsToExecutionChange} from "./blsToExecutionChange.js"; -import {validatorOptions, IValidatorCliArgs} from "./options.js"; -import {validatorHandler} from "./handler.js"; export const validator: CliCommand = { command: "validator", diff --git a/packages/cli/src/cmds/validator/keymanager/decryptKeystoreDefinitions.ts b/packages/cli/src/cmds/validator/keymanager/decryptKeystoreDefinitions.ts index 7cfaa9768494..2c17f70e8255 100644 --- a/packages/cli/src/cmds/validator/keymanager/decryptKeystoreDefinitions.ts +++ b/packages/cli/src/cmds/validator/keymanager/decryptKeystoreDefinitions.ts @@ -1,13 +1,13 @@ import fs from "node:fs"; import path from "node:path"; -import {SecretKey} from "@chainsafe/blst"; import {Keystore} from "@chainsafe/bls-keystore"; -import {SignerLocal, SignerType} from "@lodestar/validator"; +import {SecretKey} from "@chainsafe/blst"; import {LogLevel, Logger} from "@lodestar/utils"; +import {SignerLocal, SignerType} from "@lodestar/validator"; import {lockFilepath, unlockFilepath} from "../../../util/lockfile.js"; +import {DecryptKeystoresThreadPool} from "./decryptKeystores/index.js"; import {LocalKeystoreDefinition} from "./interface.js"; import {clearKeystoreCache, loadKeystoreCache, writeKeystoreCache} from "./keystoreCache.js"; -import {DecryptKeystoresThreadPool} from "./decryptKeystores/index.js"; export type KeystoreDecryptOptions = { ignoreLockFile?: boolean; diff --git a/packages/cli/src/cmds/validator/keymanager/decryptKeystores/threadPool.ts b/packages/cli/src/cmds/validator/keymanager/decryptKeystores/threadPool.ts index 169ddb74ffda..4203e0640e39 100644 --- a/packages/cli/src/cmds/validator/keymanager/decryptKeystores/threadPool.ts +++ b/packages/cli/src/cmds/validator/keymanager/decryptKeystores/threadPool.ts @@ -1,7 +1,7 @@ import path from "node:path"; -import {spawn, Pool, Worker, ModuleThread, QueuedTask} from "@chainsafe/threads"; -import {DecryptKeystoreArgs, DecryptKeystoreWorkerAPI} from "./types.js"; +import {ModuleThread, Pool, QueuedTask, Worker, spawn} from "@chainsafe/threads"; import {maxPoolSize} from "./poolSize.js"; +import {DecryptKeystoreArgs, DecryptKeystoreWorkerAPI} from "./types.js"; // Worker constructor consider the path relative to the current working directory const workerDir = diff --git a/packages/cli/src/cmds/validator/keymanager/decryptKeystores/worker.ts b/packages/cli/src/cmds/validator/keymanager/decryptKeystores/worker.ts index 711ec4f88b00..9ebebb3a73d9 100644 --- a/packages/cli/src/cmds/validator/keymanager/decryptKeystores/worker.ts +++ b/packages/cli/src/cmds/validator/keymanager/decryptKeystores/worker.ts @@ -1,7 +1,7 @@ import fs from "node:fs"; -import {expose} from "@chainsafe/threads/worker"; -import {Transfer, TransferDescriptor} from "@chainsafe/threads"; import {Keystore} from "@chainsafe/bls-keystore"; +import {Transfer, TransferDescriptor} from "@chainsafe/threads"; +import {expose} from "@chainsafe/threads/worker"; import {DecryptKeystoreArgs, DecryptKeystoreWorkerAPI, isLocalKeystoreDefinition} from "./types.js"; /** diff --git a/packages/cli/src/cmds/validator/keymanager/impl.ts b/packages/cli/src/cmds/validator/keymanager/impl.ts index b4233f3162cd..3f04a5127a30 100644 --- a/packages/cli/src/cmds/validator/keymanager/impl.ts +++ b/packages/cli/src/cmds/validator/keymanager/impl.ts @@ -1,26 +1,26 @@ import {Keystore} from "@chainsafe/bls-keystore"; import {SecretKey} from "@chainsafe/blst"; import { + BuilderBoostFactorData, DeleteRemoteKeyStatus, DeletionStatus, + FeeRecipientData, + GasLimitData, + GraffitiData, + ImportRemoteKeyStatus, ImportStatus, - ResponseStatus, KeystoreStr, PubkeyHex, - SlashingProtectionData, - SignerDefinition, RemoteSignerDefinition, - ImportRemoteKeyStatus, - FeeRecipientData, - GraffitiData, - GasLimitData, - BuilderBoostFactorData, + ResponseStatus, + SignerDefinition, + SlashingProtectionData, } from "@lodestar/api/keymanager"; import {KeymanagerApiMethods as Api} from "@lodestar/api/keymanager/server"; -import {Interchange, SignerType, Validator} from "@lodestar/validator"; import {ApiError} from "@lodestar/api/server"; import {Epoch} from "@lodestar/types"; import {fromHex, isValidHttpUrl} from "@lodestar/utils"; +import {Interchange, SignerType, Validator} from "@lodestar/validator"; import {getPubkeyHexFromKeystore, isValidatePubkeyHex} from "../../../util/format.js"; import {parseFeeRecipient} from "../../../util/index.js"; import {DecryptKeystoresThreadPool} from "./decryptKeystores/index.js"; diff --git a/packages/cli/src/cmds/validator/keymanager/keystoreCache.ts b/packages/cli/src/cmds/validator/keymanager/keystoreCache.ts index 2997a6b6b113..1f8643621bdc 100644 --- a/packages/cli/src/cmds/validator/keymanager/keystoreCache.ts +++ b/packages/cli/src/cmds/validator/keymanager/keystoreCache.ts @@ -2,8 +2,8 @@ import fs from "node:fs"; import path from "node:path"; import {Keystore} from "@chainsafe/bls-keystore"; import {SecretKey} from "@chainsafe/blst"; -import {SignerLocal, SignerType} from "@lodestar/validator"; import {fromHex, toHex, toPubkeyHex} from "@lodestar/utils"; +import {SignerLocal, SignerType} from "@lodestar/validator"; import {writeFile600Perm} from "../../../util/file.js"; import {lockFilepath, unlockFilepath} from "../../../util/lockfile.js"; import {LocalKeystoreDefinition} from "./interface.js"; diff --git a/packages/cli/src/cmds/validator/keymanager/persistedKeys.ts b/packages/cli/src/cmds/validator/keymanager/persistedKeys.ts index 6a1324dcbaa2..56d508fa4e2f 100644 --- a/packages/cli/src/cmds/validator/keymanager/persistedKeys.ts +++ b/packages/cli/src/cmds/validator/keymanager/persistedKeys.ts @@ -1,15 +1,15 @@ import fs from "node:fs"; import path from "node:path"; import {Keystore} from "@chainsafe/bls-keystore"; -import {ProposerConfig} from "@lodestar/validator"; import {DeletionStatus, ImportStatus, PubkeyHex, SignerDefinition} from "@lodestar/api/keymanager"; +import {ProposerConfig} from "@lodestar/validator"; import { getPubkeyHexFromKeystore, readPassphraseFile, + readProposerConfigDir, rmdirSyncMaybe, unlinkSyncMaybe, writeFile600Perm, - readProposerConfigDir, } from "../../../util/index.js"; import {lockFilepath} from "../../../util/lockfile.js"; import {IPersistedKeysBackend, LocalKeystoreDefinition} from "./interface.js"; diff --git a/packages/cli/src/cmds/validator/keymanager/server.ts b/packages/cli/src/cmds/validator/keymanager/server.ts index e48c708c96a8..4fec2295f293 100644 --- a/packages/cli/src/cmds/validator/keymanager/server.ts +++ b/packages/cli/src/cmds/validator/keymanager/server.ts @@ -1,8 +1,8 @@ import crypto from "node:crypto"; import fs from "node:fs"; import path from "node:path"; -import {RestApiServer, RestApiServerOpts, RestApiServerModules} from "@lodestar/beacon-node"; import {KeymanagerApiMethods, registerRoutes} from "@lodestar/api/keymanager/server"; +import {RestApiServer, RestApiServerModules, RestApiServerOpts} from "@lodestar/beacon-node"; import {ChainForkConfig} from "@lodestar/config"; import {toHex} from "@lodestar/utils"; import {writeFile600Perm} from "../../../util/index.js"; diff --git a/packages/cli/src/cmds/validator/options.ts b/packages/cli/src/cmds/validator/options.ts index 3beb8197793c..b20caeccb268 100644 --- a/packages/cli/src/cmds/validator/options.ts +++ b/packages/cli/src/cmds/validator/options.ts @@ -1,6 +1,6 @@ import {WireFormat, defaultInit} from "@lodestar/api"; -import {defaultOptions} from "@lodestar/validator"; import {CliCommandOptions} from "@lodestar/utils"; +import {defaultOptions} from "@lodestar/validator"; import {LogArgs, logOptions} from "../../options/logOptions.js"; import {ensure0xPrefix} from "../../util/index.js"; import {keymanagerRestApiServerOptsDefault} from "./keymanager/server.js"; diff --git a/packages/cli/src/cmds/validator/signers/index.ts b/packages/cli/src/cmds/validator/signers/index.ts index 950be2db1cf5..ebe3ed72cdba 100644 --- a/packages/cli/src/cmds/validator/signers/index.ts +++ b/packages/cli/src/cmds/validator/signers/index.ts @@ -2,15 +2,15 @@ import path from "node:path"; import {deriveEth2ValidatorKeys, deriveKeyFromMnemonic} from "@chainsafe/bls-keygen"; import {SecretKey} from "@chainsafe/blst"; import {interopSecretKey} from "@lodestar/state-transition"; -import {externalSignerGetKeys, Signer, SignerType} from "@lodestar/validator"; import {LogLevel, Logger, isValidHttpUrl} from "@lodestar/utils"; -import {defaultNetwork, GlobalArgs} from "../../../options/index.js"; -import {assertValidPubkeysHex, parseRange, YargsError} from "../../../util/index.js"; -import {getAccountPaths} from "../paths.js"; -import {IValidatorCliArgs} from "../options.js"; -import {PersistedKeysBackend} from "../keymanager/persistedKeys.js"; -import {decryptKeystoreDefinitions} from "../keymanager/decryptKeystoreDefinitions.js"; +import {Signer, SignerType, externalSignerGetKeys} from "@lodestar/validator"; +import {GlobalArgs, defaultNetwork} from "../../../options/index.js"; +import {YargsError, assertValidPubkeysHex, parseRange} from "../../../util/index.js"; import {showProgress} from "../../../util/progress.js"; +import {decryptKeystoreDefinitions} from "../keymanager/decryptKeystoreDefinitions.js"; +import {PersistedKeysBackend} from "../keymanager/persistedKeys.js"; +import {IValidatorCliArgs} from "../options.js"; +import {getAccountPaths} from "../paths.js"; import {importKeystoreDefinitionsFromExternalDir, readPassphraseOrPrompt} from "./importExternalKeystores.js"; const KEYSTORE_IMPORT_PROGRESS_MS = 10000; diff --git a/packages/cli/src/cmds/validator/signers/logSigners.ts b/packages/cli/src/cmds/validator/signers/logSigners.ts index d245ee75883a..9f65befb1cc7 100644 --- a/packages/cli/src/cmds/validator/signers/logSigners.ts +++ b/packages/cli/src/cmds/validator/signers/logSigners.ts @@ -1,5 +1,5 @@ -import {Signer, SignerLocal, SignerRemote, SignerType} from "@lodestar/validator"; import {LogLevel, Logger, toPrintableUrl} from "@lodestar/utils"; +import {Signer, SignerLocal, SignerRemote, SignerType} from "@lodestar/validator"; import {YargsError} from "../../../util/errors.js"; import {IValidatorCliArgs} from "../options.js"; diff --git a/packages/cli/src/cmds/validator/slashingProtection/export.ts b/packages/cli/src/cmds/validator/slashingProtection/export.ts index f57f9d3ec0bd..be7caae12e49 100644 --- a/packages/cli/src/cmds/validator/slashingProtection/export.ts +++ b/packages/cli/src/cmds/validator/slashingProtection/export.ts @@ -1,16 +1,16 @@ import path from "node:path"; -import {InterchangeFormatVersion} from "@lodestar/validator"; import {getNodeLogger} from "@lodestar/logger/node"; import {CliCommand, toPubkeyHex} from "@lodestar/utils"; -import {YargsError, ensure0xPrefix, isValidatePubkeyHex, writeFile600Perm} from "../../../util/index.js"; -import {parseLoggerArgs} from "../../../util/logger.js"; +import {InterchangeFormatVersion} from "@lodestar/validator"; +import {getBeaconConfigFromArgs} from "../../../config/index.js"; import {GlobalArgs} from "../../../options/index.js"; import {LogArgs} from "../../../options/logOptions.js"; +import {YargsError, ensure0xPrefix, isValidatePubkeyHex, writeFile600Perm} from "../../../util/index.js"; +import {parseLoggerArgs} from "../../../util/logger.js"; import {AccountValidatorArgs} from "../options.js"; -import {getBeaconConfigFromArgs} from "../../../config/index.js"; import {getValidatorPaths} from "../paths.js"; -import {getGenesisValidatorsRoot, getSlashingProtection} from "./utils.js"; import {ISlashingProtectionArgs} from "./options.js"; +import {getGenesisValidatorsRoot, getSlashingProtection} from "./utils.js"; type ExportArgs = { file: string; diff --git a/packages/cli/src/cmds/validator/slashingProtection/import.ts b/packages/cli/src/cmds/validator/slashingProtection/import.ts index 78be9e6126f7..e0e0cb5744c7 100644 --- a/packages/cli/src/cmds/validator/slashingProtection/import.ts +++ b/packages/cli/src/cmds/validator/slashingProtection/import.ts @@ -1,16 +1,16 @@ import fs from "node:fs"; import path from "node:path"; -import {Interchange} from "@lodestar/validator"; import {getNodeLogger} from "@lodestar/logger/node"; import {CliCommand} from "@lodestar/utils"; -import {parseLoggerArgs} from "../../../util/logger.js"; +import {Interchange} from "@lodestar/validator"; +import {getBeaconConfigFromArgs} from "../../../config/index.js"; import {GlobalArgs} from "../../../options/index.js"; import {LogArgs} from "../../../options/logOptions.js"; +import {parseLoggerArgs} from "../../../util/logger.js"; import {AccountValidatorArgs} from "../options.js"; -import {getBeaconConfigFromArgs} from "../../../config/index.js"; import {getValidatorPaths} from "../paths.js"; -import {getGenesisValidatorsRoot, getSlashingProtection} from "./utils.js"; import {ISlashingProtectionArgs} from "./options.js"; +import {getGenesisValidatorsRoot, getSlashingProtection} from "./utils.js"; type ImportArgs = { file: string; diff --git a/packages/cli/src/cmds/validator/slashingProtection/index.ts b/packages/cli/src/cmds/validator/slashingProtection/index.ts index 9c180c59c378..92d8bba619af 100644 --- a/packages/cli/src/cmds/validator/slashingProtection/index.ts +++ b/packages/cli/src/cmds/validator/slashingProtection/index.ts @@ -1,8 +1,8 @@ import {CliCommand} from "@lodestar/utils"; import {AccountValidatorArgs} from "../options.js"; -import {ISlashingProtectionArgs, slashingProtectionOptions} from "./options.js"; -import {importCmd} from "./import.js"; import {exportCmd} from "./export.js"; +import {importCmd} from "./import.js"; +import {ISlashingProtectionArgs, slashingProtectionOptions} from "./options.js"; export const slashingProtection: CliCommand = { command: "slashing-protection ", diff --git a/packages/cli/src/cmds/validator/slashingProtection/utils.ts b/packages/cli/src/cmds/validator/slashingProtection/utils.ts index fe0af1cb2633..48a25b6d83b9 100644 --- a/packages/cli/src/cmds/validator/slashingProtection/utils.ts +++ b/packages/cli/src/cmds/validator/slashingProtection/utils.ts @@ -1,12 +1,12 @@ -import {Root} from "@lodestar/types"; import {getClient} from "@lodestar/api"; -import {fromHex, Logger} from "@lodestar/utils"; -import {genesisData, NetworkName} from "@lodestar/config/networks"; -import {SlashingProtection, MetaDataRepository} from "@lodestar/validator"; +import {NetworkName, genesisData} from "@lodestar/config/networks"; import {LevelDbController} from "@lodestar/db"; +import {Root} from "@lodestar/types"; +import {Logger, fromHex} from "@lodestar/utils"; +import {MetaDataRepository, SlashingProtection} from "@lodestar/validator"; +import {getBeaconConfigFromArgs} from "../../../config/index.js"; import {GlobalArgs} from "../../../options/index.js"; import {getValidatorPaths} from "../paths.js"; -import {getBeaconConfigFromArgs} from "../../../config/index.js"; import {ISlashingProtectionArgs} from "./options.js"; /** diff --git a/packages/cli/src/cmds/validator/voluntaryExit.ts b/packages/cli/src/cmds/validator/voluntaryExit.ts index 5b4cfdf270f0..9b8b33c8601f 100644 --- a/packages/cli/src/cmds/validator/voluntaryExit.ts +++ b/packages/cli/src/cmds/validator/voluntaryExit.ts @@ -1,19 +1,19 @@ -import inquirer from "inquirer"; import {Signature} from "@chainsafe/blst"; +import {ApiClient, getClient} from "@lodestar/api"; +import {BeaconConfig, createBeaconConfig} from "@lodestar/config"; import { computeEpochAtSlot, computeSigningRoot, computeStartSlotAtEpoch, getCurrentSlot, } from "@lodestar/state-transition"; -import {createBeaconConfig, BeaconConfig} from "@lodestar/config"; -import {phase0, ssz, ValidatorIndex, Epoch} from "@lodestar/types"; +import {Epoch, ValidatorIndex, phase0, ssz} from "@lodestar/types"; import {CliCommand, fromHex, toPubkeyHex} from "@lodestar/utils"; -import {externalSignerPostSignature, SignableMessageType, Signer, SignerType} from "@lodestar/validator"; -import {ApiClient, getClient} from "@lodestar/api"; -import {ensure0xPrefix, YargsError, wrapError} from "../../util/index.js"; -import {GlobalArgs} from "../../options/index.js"; +import {SignableMessageType, Signer, SignerType, externalSignerPostSignature} from "@lodestar/validator"; +import inquirer from "inquirer"; import {getBeaconConfigFromArgs} from "../../config/index.js"; +import {GlobalArgs} from "../../options/index.js"; +import {YargsError, ensure0xPrefix, wrapError} from "../../util/index.js"; import {IValidatorCliArgs} from "./options.js"; import {getSignersFromArgs} from "./signers/index.js"; diff --git a/packages/cli/src/config/beaconNodeOptions.ts b/packages/cli/src/config/beaconNodeOptions.ts index edab28e1ed21..f99ced67d40b 100644 --- a/packages/cli/src/config/beaconNodeOptions.ts +++ b/packages/cli/src/config/beaconNodeOptions.ts @@ -1,6 +1,6 @@ +import {IBeaconNodeOptions, defaultOptions} from "@lodestar/beacon-node"; +import {RecursivePartial, isPlainObject} from "@lodestar/utils"; import deepmerge from "deepmerge"; -import {defaultOptions, IBeaconNodeOptions} from "@lodestar/beacon-node"; -import {isPlainObject, RecursivePartial} from "@lodestar/utils"; export class BeaconNodeOptions { /** diff --git a/packages/cli/src/config/beaconParams.ts b/packages/cli/src/config/beaconParams.ts index 54a4155a3914..7abb0e9a5537 100644 --- a/packages/cli/src/config/beaconParams.ts +++ b/packages/cli/src/config/beaconParams.ts @@ -1,19 +1,19 @@ import { ChainConfig, - createChainForkConfig, - createChainConfig, ChainForkConfig, chainConfigFromJson, + createChainConfig, + createChainForkConfig, } from "@lodestar/config"; -import {readFile} from "../util/index.js"; -import {getNetworkBeaconParams, NetworkName} from "../networks/index.js"; +import {NetworkName, getNetworkBeaconParams} from "../networks/index.js"; import { - parseBeaconParamsArgs, - parseTerminalPowArgs, - ITerminalPowArgs, GlobalArgs, + ITerminalPowArgs, defaultNetwork, + parseBeaconParamsArgs, + parseTerminalPowArgs, } from "../options/index.js"; +import {readFile} from "../util/index.js"; import {IBeaconParamsUnparsed} from "./types.js"; type BeaconParamsArgs = { diff --git a/packages/cli/src/config/peerId.ts b/packages/cli/src/config/peerId.ts index 576a99e6980e..dd45ff408d0c 100644 --- a/packages/cli/src/config/peerId.ts +++ b/packages/cli/src/config/peerId.ts @@ -1,10 +1,10 @@ +import {unmarshalPrivateKey, unmarshalPublicKey} from "@libp2p/crypto/keys"; import type {PeerId} from "@libp2p/interface"; import {peerIdFromBytes} from "@libp2p/peer-id"; import {createFromPrivKey, createFromPubKey} from "@libp2p/peer-id-factory"; -import {unmarshalPrivateKey, unmarshalPublicKey} from "@libp2p/crypto/keys"; import {fromString as uint8ArrayFromString} from "uint8arrays/from-string"; import {toString as uint8ArrayToString} from "uint8arrays/to-string"; -import {writeFile600Perm, readFile} from "../util/index.js"; +import {readFile, writeFile600Perm} from "../util/index.js"; // Peer id to / from JSON taken from peer-id-factory // See https://github.com/libp2p/js-libp2p-peer-id/pull/9 for more details diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 0d509af17ab0..bc232bf0cce3 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -2,8 +2,8 @@ // MUST import first to apply preset from args and set ssz hasher import "./applyPreset.js"; -import {YargsError} from "./util/index.js"; import {getLodestarCli, yarg} from "./cli.js"; +import {YargsError} from "./util/index.js"; import "source-map-support/register.js"; const lodestar = getLodestarCli(); diff --git a/packages/cli/src/networks/dev.ts b/packages/cli/src/networks/dev.ts index 6ce87273b3cb..3ae54051ea37 100644 --- a/packages/cli/src/networks/dev.ts +++ b/packages/cli/src/networks/dev.ts @@ -1,7 +1,7 @@ +import {ChainConfig} from "@lodestar/config"; +import {mainnetChainConfig, minimalChainConfig} from "@lodestar/config/configs"; import {gnosisChainConfig} from "@lodestar/config/networks"; -import {minimalChainConfig, mainnetChainConfig} from "@lodestar/config/configs"; import {ACTIVE_PRESET, PresetName} from "@lodestar/params"; -import {ChainConfig} from "@lodestar/config"; let chainConfig: ChainConfig; switch (ACTIVE_PRESET) { diff --git a/packages/cli/src/networks/index.ts b/packages/cli/src/networks/index.ts index e2fc9dd621b6..56b8e9ff4a02 100644 --- a/packages/cli/src/networks/index.ts +++ b/packages/cli/src/networks/index.ts @@ -1,27 +1,27 @@ import fs from "node:fs"; -import got from "got"; import {ENR} from "@chainsafe/enr"; -import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {HttpHeader, MediaType, WireFormat, getClient} from "@lodestar/api"; import {getStateSlotFromBytes} from "@lodestar/beacon-node"; import {ChainConfig, ChainForkConfig} from "@lodestar/config"; -import {Checkpoint} from "@lodestar/types/phase0"; -import {Slot} from "@lodestar/types"; -import {fromHex, callFnWhenAwait, Logger, formatBytes} from "@lodestar/utils"; +import {SLOTS_PER_EPOCH} from "@lodestar/params"; import { BeaconStateAllForks, - getLatestBlockRoot, computeCheckpointEpochAtStateSlot, + getLatestBlockRoot, loadState, } from "@lodestar/state-transition"; +import {Slot} from "@lodestar/types"; +import {Checkpoint} from "@lodestar/types/phase0"; +import {Logger, callFnWhenAwait, formatBytes, fromHex} from "@lodestar/utils"; +import got from "got"; import {parseBootnodesFile} from "../util/format.js"; -import * as mainnet from "./mainnet.js"; +import * as chiado from "./chiado.js"; import * as dev from "./dev.js"; +import * as ephemery from "./ephemery.js"; import * as gnosis from "./gnosis.js"; -import * as sepolia from "./sepolia.js"; import * as holesky from "./holesky.js"; -import * as chiado from "./chiado.js"; -import * as ephemery from "./ephemery.js"; +import * as mainnet from "./mainnet.js"; +import * as sepolia from "./sepolia.js"; export type NetworkName = "mainnet" | "dev" | "gnosis" | "sepolia" | "holesky" | "chiado" | "ephemery"; export const networkNames: NetworkName[] = [ diff --git a/packages/cli/src/options/beaconNodeOptions/api.ts b/packages/cli/src/options/beaconNodeOptions/api.ts index ea4d4ebccf84..7ee3bd9caa17 100644 --- a/packages/cli/src/options/beaconNodeOptions/api.ts +++ b/packages/cli/src/options/beaconNodeOptions/api.ts @@ -1,4 +1,4 @@ -import {defaultOptions, IBeaconNodeOptions, allNamespaces} from "@lodestar/beacon-node"; +import {IBeaconNodeOptions, allNamespaces, defaultOptions} from "@lodestar/beacon-node"; import {CliCommandOptions} from "@lodestar/utils"; const enabledAll = "*"; diff --git a/packages/cli/src/options/beaconNodeOptions/builder.ts b/packages/cli/src/options/beaconNodeOptions/builder.ts index d0e4089dd81c..01e21125637b 100644 --- a/packages/cli/src/options/beaconNodeOptions/builder.ts +++ b/packages/cli/src/options/beaconNodeOptions/builder.ts @@ -1,4 +1,4 @@ -import {defaultExecutionBuilderHttpOpts, IBeaconNodeOptions} from "@lodestar/beacon-node"; +import {IBeaconNodeOptions, defaultExecutionBuilderHttpOpts} from "@lodestar/beacon-node"; import {CliCommandOptions} from "@lodestar/utils"; import {YargsError} from "../../util/index.js"; diff --git a/packages/cli/src/options/beaconNodeOptions/chain.ts b/packages/cli/src/options/beaconNodeOptions/chain.ts index c5f907804a83..21c05545c43d 100644 --- a/packages/cli/src/options/beaconNodeOptions/chain.ts +++ b/packages/cli/src/options/beaconNodeOptions/chain.ts @@ -1,5 +1,5 @@ import * as path from "node:path"; -import {StateArchiveMode, defaultOptions, IBeaconNodeOptions, DEFAULT_STATE_ARCHIVE_MODE} from "@lodestar/beacon-node"; +import {DEFAULT_STATE_ARCHIVE_MODE, IBeaconNodeOptions, StateArchiveMode, defaultOptions} from "@lodestar/beacon-node"; import {CliCommandOptions} from "@lodestar/utils"; export type ChainArgs = { diff --git a/packages/cli/src/options/beaconNodeOptions/eth1.ts b/packages/cli/src/options/beaconNodeOptions/eth1.ts index f12a1704dec7..cab090a96781 100644 --- a/packages/cli/src/options/beaconNodeOptions/eth1.ts +++ b/packages/cli/src/options/beaconNodeOptions/eth1.ts @@ -1,5 +1,5 @@ import fs from "node:fs"; -import {defaultOptions, IBeaconNodeOptions} from "@lodestar/beacon-node"; +import {IBeaconNodeOptions, defaultOptions} from "@lodestar/beacon-node"; import {CliCommandOptions} from "@lodestar/utils"; import {extractJwtHexSecret} from "../../util/index.js"; import {ExecutionEngineArgs} from "./execution.js"; diff --git a/packages/cli/src/options/beaconNodeOptions/execution.ts b/packages/cli/src/options/beaconNodeOptions/execution.ts index 2d32ee2ae786..79ea4ade98de 100644 --- a/packages/cli/src/options/beaconNodeOptions/execution.ts +++ b/packages/cli/src/options/beaconNodeOptions/execution.ts @@ -1,5 +1,5 @@ import fs from "node:fs"; -import {defaultExecutionEngineHttpOpts, IBeaconNodeOptions} from "@lodestar/beacon-node"; +import {IBeaconNodeOptions, defaultExecutionEngineHttpOpts} from "@lodestar/beacon-node"; import {CliCommandOptions} from "@lodestar/utils"; import {extractJwtHexSecret} from "../../util/index.js"; diff --git a/packages/cli/src/options/beaconNodeOptions/metrics.ts b/packages/cli/src/options/beaconNodeOptions/metrics.ts index ded63b7dc24d..ae4c045fb07c 100644 --- a/packages/cli/src/options/beaconNodeOptions/metrics.ts +++ b/packages/cli/src/options/beaconNodeOptions/metrics.ts @@ -1,4 +1,4 @@ -import {defaultOptions, IBeaconNodeOptions} from "@lodestar/beacon-node"; +import {IBeaconNodeOptions, defaultOptions} from "@lodestar/beacon-node"; import {CliCommandOptions} from "@lodestar/utils"; export type MetricsArgs = { diff --git a/packages/cli/src/options/beaconNodeOptions/monitoring.ts b/packages/cli/src/options/beaconNodeOptions/monitoring.ts index 2143277df2ae..2f35a4a29c5c 100644 --- a/packages/cli/src/options/beaconNodeOptions/monitoring.ts +++ b/packages/cli/src/options/beaconNodeOptions/monitoring.ts @@ -1,4 +1,4 @@ -import {defaultOptions, IBeaconNodeOptions} from "@lodestar/beacon-node"; +import {IBeaconNodeOptions, defaultOptions} from "@lodestar/beacon-node"; import {CliCommandOptions} from "@lodestar/utils"; export type MonitoringArgs = { diff --git a/packages/cli/src/options/beaconNodeOptions/network.ts b/packages/cli/src/options/beaconNodeOptions/network.ts index cfd109bdc50a..56944d90fd0c 100644 --- a/packages/cli/src/options/beaconNodeOptions/network.ts +++ b/packages/cli/src/options/beaconNodeOptions/network.ts @@ -1,7 +1,7 @@ -import {multiaddr} from "@multiformats/multiaddr"; import {ENR} from "@chainsafe/enr"; -import {defaultOptions, IBeaconNodeOptions} from "@lodestar/beacon-node"; +import {IBeaconNodeOptions, defaultOptions} from "@lodestar/beacon-node"; import {CliCommandOptions} from "@lodestar/utils"; +import {multiaddr} from "@multiformats/multiaddr"; import {YargsError} from "../../util/index.js"; export const defaultListenAddress = "0.0.0.0"; diff --git a/packages/cli/src/options/beaconNodeOptions/sync.ts b/packages/cli/src/options/beaconNodeOptions/sync.ts index 789307781ed0..a33fa43db470 100644 --- a/packages/cli/src/options/beaconNodeOptions/sync.ts +++ b/packages/cli/src/options/beaconNodeOptions/sync.ts @@ -1,4 +1,4 @@ -import {defaultOptions, IBeaconNodeOptions} from "@lodestar/beacon-node"; +import {IBeaconNodeOptions, defaultOptions} from "@lodestar/beacon-node"; import {CliCommandOptions} from "@lodestar/utils"; export type SyncArgs = { diff --git a/packages/cli/src/options/globalOptions.ts b/packages/cli/src/options/globalOptions.ts index 52a5090c6794..58ae396b67d1 100644 --- a/packages/cli/src/options/globalOptions.ts +++ b/packages/cli/src/options/globalOptions.ts @@ -2,7 +2,7 @@ import {ACTIVE_PRESET} from "@lodestar/params"; import {CliCommandOptions} from "@lodestar/utils"; import {NetworkName, networkNames} from "../networks/index.js"; import {readFile} from "../util/index.js"; -import {paramsOptions, IParamsArgs} from "./paramsOptions.js"; +import {IParamsArgs, paramsOptions} from "./paramsOptions.js"; type GlobalSingleArgs = { dataDir?: string; diff --git a/packages/cli/src/options/logOptions.ts b/packages/cli/src/options/logOptions.ts index 09eb5b1d56cb..5b8c32c3b796 100644 --- a/packages/cli/src/options/logOptions.ts +++ b/packages/cli/src/options/logOptions.ts @@ -1,5 +1,5 @@ -import {LogLevels, CliCommandOptions} from "@lodestar/utils"; import {LogLevel, logFormats} from "@lodestar/logger"; +import {CliCommandOptions, LogLevels} from "@lodestar/utils"; import {LOG_FILE_DISABLE_KEYWORD} from "../util/logger.js"; export type LogArgs = { diff --git a/packages/cli/src/util/gitData/gitDataPath.ts b/packages/cli/src/util/gitData/gitDataPath.ts index 1ad3104aafc6..b4c7f8c7c62c 100644 --- a/packages/cli/src/util/gitData/gitDataPath.ts +++ b/packages/cli/src/util/gitData/gitDataPath.ts @@ -1,5 +1,5 @@ -import path from "node:path"; import fs from "node:fs"; +import path from "node:path"; import {fileURLToPath} from "node:url"; // Global variable __dirname no longer available in ES6 modules. diff --git a/packages/cli/src/util/gitData/index.ts b/packages/cli/src/util/gitData/index.ts index 0720d39d9e30..c5681660f8ce 100644 --- a/packages/cli/src/util/gitData/index.ts +++ b/packages/cli/src/util/gitData/index.ts @@ -2,7 +2,7 @@ import {execSync} from "node:child_process"; // This file is created in the build step and is distributed through NPM // MUST be in sync with `-/gitDataPath.ts` and `package.json` files. -import {readGitDataFile, GitData} from "./gitDataPath.js"; +import {GitData, readGitDataFile} from "./gitDataPath.js"; /** Reads git data from a persisted file or local git data at build time. */ export function readAndGetGitData(): GitData { diff --git a/packages/cli/src/util/logger.ts b/packages/cli/src/util/logger.ts index 7a394c9ce25f..99504ce5d43b 100644 --- a/packages/cli/src/util/logger.ts +++ b/packages/cli/src/util/logger.ts @@ -1,12 +1,12 @@ -import path from "node:path"; import fs from "node:fs"; +import path from "node:path"; import {ChainForkConfig} from "@lodestar/config"; -import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {LogFormat, TimestampFormatCode, logFormats} from "@lodestar/logger"; import {LoggerNodeOpts} from "@lodestar/logger/node"; +import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {LogLevel} from "@lodestar/utils"; -import {LogArgs} from "../options/logOptions.js"; import {GlobalArgs} from "../options/globalOptions.js"; +import {LogArgs} from "../options/logOptions.js"; export const LOG_FILE_DISABLE_KEYWORD = "none"; diff --git a/packages/cli/src/util/proposerConfig.ts b/packages/cli/src/util/proposerConfig.ts index 2c12ce8f8524..3fe281097021 100644 --- a/packages/cli/src/util/proposerConfig.ts +++ b/packages/cli/src/util/proposerConfig.ts @@ -1,7 +1,7 @@ import fs from "node:fs"; import path from "node:path"; -import {ValidatorProposerConfig} from "@lodestar/validator"; import {routes} from "@lodestar/api"; +import {ValidatorProposerConfig} from "@lodestar/validator"; import {parseFeeRecipient} from "./feeRecipient.js"; diff --git a/packages/cli/test/e2e/blsToExecutionchange.test.ts b/packages/cli/test/e2e/blsToExecutionchange.test.ts index 57f32421d313..ec7322caba00 100644 --- a/packages/cli/test/e2e/blsToExecutionchange.test.ts +++ b/packages/cli/test/e2e/blsToExecutionchange.test.ts @@ -1,11 +1,11 @@ import path from "node:path"; -import {describe, it, vi, onTestFinished} from "vitest"; import {toHexString} from "@chainsafe/ssz"; -import {sleep, retry} from "@lodestar/utils"; import {getClient} from "@lodestar/api"; import {config} from "@lodestar/config/default"; import {interopSecretKey} from "@lodestar/state-transition"; import {execCliCommand, spawnCliCommand, stopChildProcess} from "@lodestar/test-utils"; +import {retry, sleep} from "@lodestar/utils"; +import {describe, it, onTestFinished, vi} from "vitest"; import {testFilesDir} from "../utils.js"; describe("bLSToExecutionChange cmd", () => { diff --git a/packages/cli/test/e2e/importFromFsDirect.test.ts b/packages/cli/test/e2e/importFromFsDirect.test.ts index 6f612e84afe6..b65ebf74fede 100644 --- a/packages/cli/test/e2e/importFromFsDirect.test.ts +++ b/packages/cli/test/e2e/importFromFsDirect.test.ts @@ -1,8 +1,8 @@ import fs from "node:fs"; import path from "node:path"; -import {describe, it, beforeAll, vi} from "vitest"; -import {rimraf} from "rimraf"; import {getKeystoresStr} from "@lodestar/test-utils"; +import {rimraf} from "rimraf"; +import {beforeAll, describe, it, vi} from "vitest"; import {testFilesDir} from "../utils.js"; import {cachedPubkeysHex, cachedSeckeysHex} from "../utils/cachedKeys.js"; import {expectKeys, startValidatorWithKeyManager} from "../utils/validator.js"; diff --git a/packages/cli/test/e2e/importFromFsPreStep.test.ts b/packages/cli/test/e2e/importFromFsPreStep.test.ts index 437180ef07e5..2933b6113a32 100644 --- a/packages/cli/test/e2e/importFromFsPreStep.test.ts +++ b/packages/cli/test/e2e/importFromFsPreStep.test.ts @@ -1,9 +1,9 @@ import fs from "node:fs"; import path from "node:path"; -import {describe, it, expect, beforeAll, vi, onTestFinished} from "vitest"; -import {rimraf} from "rimraf"; import {execCliCommand} from "@lodestar/test-utils"; import {getKeystoresStr} from "@lodestar/test-utils"; +import {rimraf} from "rimraf"; +import {beforeAll, describe, expect, it, onTestFinished, vi} from "vitest"; import {testFilesDir} from "../utils.js"; import {cachedPubkeysHex, cachedSeckeysHex} from "../utils/cachedKeys.js"; import {expectKeys, startValidatorWithKeyManager} from "../utils/validator.js"; diff --git a/packages/cli/test/e2e/importKeystoresFromApi.test.ts b/packages/cli/test/e2e/importKeystoresFromApi.test.ts index 7f71e2977a92..6d15cfe13827 100644 --- a/packages/cli/test/e2e/importKeystoresFromApi.test.ts +++ b/packages/cli/test/e2e/importKeystoresFromApi.test.ts @@ -1,12 +1,12 @@ import path from "node:path"; -import {describe, it, expect, beforeAll, vi, onTestFinished} from "vitest"; -import {rimraf} from "rimraf"; -import {DeletionStatus, getClient, ImportStatus} from "@lodestar/api/keymanager"; -import {config} from "@lodestar/config/default"; -import {Interchange} from "@lodestar/validator"; import {HttpStatusCode} from "@lodestar/api"; +import {DeletionStatus, ImportStatus, getClient} from "@lodestar/api/keymanager"; +import {config} from "@lodestar/config/default"; import {bufferStderr, spawnCliCommand} from "@lodestar/test-utils"; import {getKeystoresStr} from "@lodestar/test-utils"; +import {Interchange} from "@lodestar/validator"; +import {rimraf} from "rimraf"; +import {beforeAll, describe, expect, it, onTestFinished, vi} from "vitest"; import {testFilesDir} from "../utils.js"; import {cachedPubkeysHex, cachedSeckeysHex} from "../utils/cachedKeys.js"; import {expectDeepEquals} from "../utils/runUtils.js"; diff --git a/packages/cli/test/e2e/importRemoteKeysFromApi.test.ts b/packages/cli/test/e2e/importRemoteKeysFromApi.test.ts index b66611cbf4f4..2f3efea9425e 100644 --- a/packages/cli/test/e2e/importRemoteKeysFromApi.test.ts +++ b/packages/cli/test/e2e/importRemoteKeysFromApi.test.ts @@ -1,9 +1,9 @@ import path from "node:path"; -import {describe, it, expect, beforeAll, vi, onTestFinished} from "vitest"; -import {rimraf} from "rimraf"; -import {ApiClient, DeleteRemoteKeyStatus, getClient, ImportRemoteKeyStatus} from "@lodestar/api/keymanager"; -import {config} from "@lodestar/config/default"; import {HttpStatusCode} from "@lodestar/api"; +import {ApiClient, DeleteRemoteKeyStatus, ImportRemoteKeyStatus, getClient} from "@lodestar/api/keymanager"; +import {config} from "@lodestar/config/default"; +import {rimraf} from "rimraf"; +import {beforeAll, describe, expect, it, onTestFinished, vi} from "vitest"; import {testFilesDir} from "../utils.js"; import {cachedPubkeysHex} from "../utils/cachedKeys.js"; import {expectDeepEquals} from "../utils/runUtils.js"; diff --git a/packages/cli/test/e2e/propserConfigfromKeymanager.test.ts b/packages/cli/test/e2e/propserConfigfromKeymanager.test.ts index 2f25c82999a7..26bf3e618c2b 100644 --- a/packages/cli/test/e2e/propserConfigfromKeymanager.test.ts +++ b/packages/cli/test/e2e/propserConfigfromKeymanager.test.ts @@ -1,9 +1,9 @@ import path from "node:path"; -import {describe, it, beforeAll, vi, onTestFinished} from "vitest"; -import {rimraf} from "rimraf"; import {ImportStatus} from "@lodestar/api/keymanager"; -import {Interchange} from "@lodestar/validator"; import {getKeystoresStr} from "@lodestar/test-utils"; +import {Interchange} from "@lodestar/validator"; +import {rimraf} from "rimraf"; +import {beforeAll, describe, it, onTestFinished, vi} from "vitest"; import {testFilesDir} from "../utils.js"; import {cachedPubkeysHex, cachedSeckeysHex} from "../utils/cachedKeys.js"; import {expectDeepEquals} from "../utils/runUtils.js"; diff --git a/packages/cli/test/e2e/runDevCmd.test.ts b/packages/cli/test/e2e/runDevCmd.test.ts index 3beb68393815..e935e5eaf411 100644 --- a/packages/cli/test/e2e/runDevCmd.test.ts +++ b/packages/cli/test/e2e/runDevCmd.test.ts @@ -1,8 +1,8 @@ -import {describe, it, vi, onTestFinished} from "vitest"; import {getClient} from "@lodestar/api"; import {config} from "@lodestar/config/default"; -import {retry} from "@lodestar/utils"; import {spawnCliCommand, stopChildProcess} from "@lodestar/test-utils"; +import {retry} from "@lodestar/utils"; +import {describe, it, onTestFinished, vi} from "vitest"; describe("Run dev command", () => { vi.setConfig({testTimeout: 30_000}); diff --git a/packages/cli/test/e2e/validatorList.test.ts b/packages/cli/test/e2e/validatorList.test.ts index 7f86fb8ef89b..6987006bd26a 100644 --- a/packages/cli/test/e2e/validatorList.test.ts +++ b/packages/cli/test/e2e/validatorList.test.ts @@ -1,13 +1,13 @@ /* eslint-disable no-console */ import fs from "node:fs"; import path from "node:path"; -import {describe, it, beforeAll, vi, expect, afterEach, beforeEach} from "vitest"; -import {rimraf} from "rimraf"; import {Keystore} from "@chainsafe/bls-keystore"; -import {fromHex} from "@lodestar/utils"; import {runCliCommand} from "@lodestar/test-utils"; -import {testFilesDir} from "../utils.js"; +import {fromHex} from "@lodestar/utils"; +import {rimraf} from "rimraf"; +import {afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; import {getLodestarCli} from "../../src/cli.js"; +import {testFilesDir} from "../utils.js"; describe("cmds / validator", () => { vi.setConfig({testTimeout: 30_000}); diff --git a/packages/cli/test/e2e/voluntaryExit.test.ts b/packages/cli/test/e2e/voluntaryExit.test.ts index 0abddcab7652..8c17e8ef8c5b 100644 --- a/packages/cli/test/e2e/voluntaryExit.test.ts +++ b/packages/cli/test/e2e/voluntaryExit.test.ts @@ -1,10 +1,10 @@ import path from "node:path"; -import {describe, it, vi, onTestFinished} from "vitest"; -import {retry} from "@lodestar/utils"; import {getClient} from "@lodestar/api"; import {config} from "@lodestar/config/default"; import {interopSecretKey} from "@lodestar/state-transition"; -import {spawnCliCommand, execCliCommand, stopChildProcess} from "@lodestar/test-utils"; +import {execCliCommand, spawnCliCommand, stopChildProcess} from "@lodestar/test-utils"; +import {retry} from "@lodestar/utils"; +import {describe, it, onTestFinished, vi} from "vitest"; import {testFilesDir} from "../utils.js"; describe("voluntaryExit cmd", () => { diff --git a/packages/cli/test/e2e/voluntaryExitFromApi.test.ts b/packages/cli/test/e2e/voluntaryExitFromApi.test.ts index 97ac06d5fc5c..8421d57658af 100644 --- a/packages/cli/test/e2e/voluntaryExitFromApi.test.ts +++ b/packages/cli/test/e2e/voluntaryExitFromApi.test.ts @@ -1,11 +1,11 @@ import path from "node:path"; -import {describe, it, vi, expect, onTestFinished} from "vitest"; import {getClient} from "@lodestar/api"; import {getClient as getKeymanagerClient} from "@lodestar/api/keymanager"; import {config} from "@lodestar/config/default"; import {interopSecretKey} from "@lodestar/state-transition"; import {spawnCliCommand, stopChildProcess} from "@lodestar/test-utils"; import {retry} from "@lodestar/utils"; +import {describe, expect, it, onTestFinished, vi} from "vitest"; import {testFilesDir} from "../utils.js"; describe("voluntary exit from api", () => { diff --git a/packages/cli/test/e2e/voluntaryExitRemoteSigner.test.ts b/packages/cli/test/e2e/voluntaryExitRemoteSigner.test.ts index 769380f2053f..172f79c5191d 100644 --- a/packages/cli/test/e2e/voluntaryExitRemoteSigner.test.ts +++ b/packages/cli/test/e2e/voluntaryExitRemoteSigner.test.ts @@ -1,17 +1,17 @@ import path from "node:path"; -import {describe, it, beforeAll, afterAll, vi, onTestFinished} from "vitest"; -import {retry} from "@lodestar/utils"; import {getClient} from "@lodestar/api"; import {config} from "@lodestar/config/default"; import {interopSecretKey, interopSecretKeys} from "@lodestar/state-transition"; import { - spawnCliCommand, - execCliCommand, - startExternalSigner, StartedExternalSigner, + execCliCommand, getKeystoresStr, + spawnCliCommand, + startExternalSigner, stopChildProcess, } from "@lodestar/test-utils"; +import {retry} from "@lodestar/utils"; +import {afterAll, beforeAll, describe, it, onTestFinished, vi} from "vitest"; import {testFilesDir} from "../utils.js"; describe("voluntaryExit using remote signer", () => { diff --git a/packages/cli/test/sim/backupEthProvider.test.ts b/packages/cli/test/sim/backupEthProvider.test.ts index 4ccc131a58bc..8b34d57e4d67 100644 --- a/packages/cli/test/sim/backupEthProvider.test.ts +++ b/packages/cli/test/sim/backupEthProvider.test.ts @@ -1,8 +1,8 @@ import path from "node:path"; import {activePreset} from "@lodestar/params"; -import {Simulation} from "../utils/crucible/simulation.js"; import {nodeAssertion} from "../utils/crucible/assertions/nodeAssertion.js"; -import {Match, BeaconClient, ExecutionClient} from "../utils/crucible/interfaces.js"; +import {BeaconClient, ExecutionClient, Match} from "../utils/crucible/interfaces.js"; +import {Simulation} from "../utils/crucible/simulation.js"; import {defineSimTestConfig, logFilesDir, replaceIpFromUrl} from "../utils/crucible/utils/index.js"; import {connectAllNodes, waitForSlot} from "../utils/crucible/utils/network.js"; diff --git a/packages/cli/test/sim/deneb.test.ts b/packages/cli/test/sim/deneb.test.ts index 865540ae7635..8d3bd3064bc2 100644 --- a/packages/cli/test/sim/deneb.test.ts +++ b/packages/cli/test/sim/deneb.test.ts @@ -1,9 +1,9 @@ import path from "node:path"; -import {Simulation} from "../utils/crucible/simulation.js"; +import {createBlobsAssertion} from "../utils/crucible/assertions/blobsAssertion.js"; import {BeaconClient, ExecutionClient, ValidatorClient} from "../utils/crucible/interfaces.js"; +import {Simulation} from "../utils/crucible/simulation.js"; import {defineSimTestConfig, logFilesDir} from "../utils/crucible/utils/index.js"; import {connectAllNodes, waitForSlot} from "../utils/crucible/utils/network.js"; -import {createBlobsAssertion} from "../utils/crucible/assertions/blobsAssertion.js"; import {assertCheckpointSync, assertRangeSync} from "../utils/crucible/utils/syncing.js"; const runTillEpoch = 6; diff --git a/packages/cli/test/sim/endpoints.test.ts b/packages/cli/test/sim/endpoints.test.ts index 308ac6a0053c..b1492865309a 100644 --- a/packages/cli/test/sim/endpoints.test.ts +++ b/packages/cli/test/sim/endpoints.test.ts @@ -1,10 +1,10 @@ -import path from "node:path"; import assert from "node:assert"; +import path from "node:path"; import {toHexString} from "@chainsafe/ssz"; -import {routes, fetch} from "@lodestar/api"; +import {fetch, routes} from "@lodestar/api"; import {ssz} from "@lodestar/types"; -import {Simulation} from "../utils/crucible/simulation.js"; import {BeaconClient, ExecutionClient} from "../utils/crucible/interfaces.js"; +import {Simulation} from "../utils/crucible/simulation.js"; import {defineSimTestConfig, logFilesDir} from "../utils/crucible/utils/index.js"; import {waitForSlot} from "../utils/crucible/utils/network.js"; diff --git a/packages/cli/test/sim/mixedClient.test.ts b/packages/cli/test/sim/mixedClient.test.ts index 45029a1b26b4..5fe786829cf1 100644 --- a/packages/cli/test/sim/mixedClient.test.ts +++ b/packages/cli/test/sim/mixedClient.test.ts @@ -1,7 +1,7 @@ import path from "node:path"; -import {Simulation} from "../utils/crucible/simulation.js"; import {nodeAssertion} from "../utils/crucible/assertions/nodeAssertion.js"; -import {Match, BeaconClient, ExecutionClient, ValidatorClient} from "../utils/crucible/interfaces.js"; +import {BeaconClient, ExecutionClient, Match, ValidatorClient} from "../utils/crucible/interfaces.js"; +import {Simulation} from "../utils/crucible/simulation.js"; import {defineSimTestConfig, logFilesDir} from "../utils/crucible/utils/index.js"; import {connectAllNodes, waitForSlot} from "../utils/crucible/utils/network.js"; diff --git a/packages/cli/test/sim/multiFork.test.ts b/packages/cli/test/sim/multiFork.test.ts index 047d9196239d..83cb8f234646 100644 --- a/packages/cli/test/sim/multiFork.test.ts +++ b/packages/cli/test/sim/multiFork.test.ts @@ -1,14 +1,14 @@ import path from "node:path"; -import {Match, BeaconClient, ExecutionClient, ValidatorClient} from "../utils/crucible/interfaces.js"; -import {Simulation} from "../utils/crucible/simulation.js"; -import {defineSimTestConfig, logFilesDir} from "../utils/crucible/utils/index.js"; -import {connectAllNodes, waitForSlot} from "../utils/crucible/utils/network.js"; -import {nodeAssertion} from "../utils/crucible/assertions/nodeAssertion.js"; -import {mergeAssertion} from "../utils/crucible/assertions/mergeAssertion.js"; -import {createForkAssertion} from "../utils/crucible/assertions/forkAssertion.js"; import {createAccountBalanceAssertion} from "../utils/crucible/assertions/accountBalanceAssertion.js"; import {createExecutionHeadAssertion} from "../utils/crucible/assertions/executionHeadAssertion.js"; +import {createForkAssertion} from "../utils/crucible/assertions/forkAssertion.js"; +import {mergeAssertion} from "../utils/crucible/assertions/mergeAssertion.js"; +import {nodeAssertion} from "../utils/crucible/assertions/nodeAssertion.js"; import {createWithdrawalAssertions} from "../utils/crucible/assertions/withdrawalsAssertion.js"; +import {BeaconClient, ExecutionClient, Match, ValidatorClient} from "../utils/crucible/interfaces.js"; +import {Simulation} from "../utils/crucible/simulation.js"; +import {defineSimTestConfig, logFilesDir} from "../utils/crucible/utils/index.js"; +import {connectAllNodes, waitForSlot} from "../utils/crucible/utils/network.js"; import {assertCheckpointSync, assertRangeSync, assertUnknownBlockSync} from "../utils/crucible/utils/syncing.js"; const altairForkEpoch = 2; diff --git a/packages/cli/test/unit/cmds/beacon.test.ts b/packages/cli/test/unit/cmds/beacon.test.ts index 6e7b7f389a29..a1dac019a7e8 100644 --- a/packages/cli/test/unit/cmds/beacon.test.ts +++ b/packages/cli/test/unit/cmds/beacon.test.ts @@ -1,16 +1,16 @@ -import path from "node:path"; import fs from "node:fs"; -import {describe, it, expect} from "vitest"; +import path from "node:path"; +import {ENR, SignableENR, createPrivateKeyFromPeerId} from "@chainsafe/enr"; import {createFromJSON, createSecp256k1PeerId} from "@libp2p/peer-id-factory"; -import {multiaddr} from "@multiformats/multiaddr"; -import {createPrivateKeyFromPeerId, ENR, SignableENR} from "@chainsafe/enr"; -import {chainConfig} from "@lodestar/config/default"; import {chainConfigToJson} from "@lodestar/config"; +import {chainConfig} from "@lodestar/config/default"; import {LogLevel} from "@lodestar/utils"; -import {exportToJSON} from "../../../src/config/peerId.js"; +import {multiaddr} from "@multiformats/multiaddr"; +import {describe, expect, it} from "vitest"; import {beaconHandlerInit} from "../../../src/cmds/beacon/handler.js"; import {initPeerIdAndEnr, isLocalMultiAddr} from "../../../src/cmds/beacon/initPeerIdAndEnr.js"; import {BeaconArgs} from "../../../src/cmds/beacon/options.js"; +import {exportToJSON} from "../../../src/config/peerId.js"; import {GlobalArgs} from "../../../src/options/globalOptions.js"; import {testFilesDir, testLogger} from "../../utils.js"; diff --git a/packages/cli/test/unit/cmds/initPeerIdAndEnr.test.ts b/packages/cli/test/unit/cmds/initPeerIdAndEnr.test.ts index a207e0c0f59d..a7b7ed64e743 100644 --- a/packages/cli/test/unit/cmds/initPeerIdAndEnr.test.ts +++ b/packages/cli/test/unit/cmds/initPeerIdAndEnr.test.ts @@ -1,6 +1,6 @@ import fs from "node:fs"; -import {describe, it, expect, beforeEach, afterEach} from "vitest"; import tmp from "tmp"; +import {afterEach, beforeEach, describe, expect, it} from "vitest"; import {initPeerIdAndEnr} from "../../../src/cmds/beacon/initPeerIdAndEnr.js"; import {BeaconArgs} from "../../../src/cmds/beacon/options.js"; import {testLogger} from "../../utils.js"; diff --git a/packages/cli/test/unit/cmds/validator/keymanager/keystoreCache.test.ts b/packages/cli/test/unit/cmds/validator/keymanager/keystoreCache.test.ts index 8d3dbb989b5d..a313455f7d8c 100644 --- a/packages/cli/test/unit/cmds/validator/keymanager/keystoreCache.test.ts +++ b/packages/cli/test/unit/cmds/validator/keymanager/keystoreCache.test.ts @@ -1,13 +1,13 @@ -import fs from "node:fs"; import {randomBytes} from "node:crypto"; -import {describe, it, expect, beforeEach, vi} from "vitest"; -import tmp from "tmp"; +import fs from "node:fs"; import {Keystore} from "@chainsafe/bls-keystore"; import {SecretKey} from "@chainsafe/blst"; import {interopSecretKey} from "@lodestar/state-transition"; import {SignerLocal, SignerType} from "@lodestar/validator"; -import {loadKeystoreCache, writeKeystoreCache} from "../../../../../src/cmds/validator/keymanager/keystoreCache.js"; +import tmp from "tmp"; +import {beforeEach, describe, expect, it, vi} from "vitest"; import {LocalKeystoreDefinition} from "../../../../../src/cmds/validator/keymanager/interface.js"; +import {loadKeystoreCache, writeKeystoreCache} from "../../../../../src/cmds/validator/keymanager/keystoreCache.js"; const numberOfSigners = 10; diff --git a/packages/cli/test/unit/config/beaconNodeOptions.test.ts b/packages/cli/test/unit/config/beaconNodeOptions.test.ts index d35cf06ad1a4..cb21a15ce0af 100644 --- a/packages/cli/test/unit/config/beaconNodeOptions.test.ts +++ b/packages/cli/test/unit/config/beaconNodeOptions.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {defaultOptions} from "@lodestar/beacon-node"; +import {describe, expect, it} from "vitest"; import {BeaconNodeOptions} from "../../../src/config/index.js"; describe("config / beaconNodeOptions", () => { diff --git a/packages/cli/test/unit/config/beaconParams.test.ts b/packages/cli/test/unit/config/beaconParams.test.ts index 2a78d498bf89..1d24cda5dda9 100644 --- a/packages/cli/test/unit/config/beaconParams.test.ts +++ b/packages/cli/test/unit/config/beaconParams.test.ts @@ -1,9 +1,9 @@ import fs from "node:fs"; -import {describe, it, expect, beforeAll, afterAll} from "vitest"; -import yaml from "js-yaml"; import {toHexString} from "@chainsafe/ssz"; -import {getTestdirPath} from "../../utils.js"; +import yaml from "js-yaml"; +import {afterAll, beforeAll, describe, expect, it} from "vitest"; import {getBeaconParams} from "../../../src/config/index.js"; +import {getTestdirPath} from "../../utils.js"; describe("config / beaconParams", () => { const GENESIS_FORK_VERSION_MAINNET = "0x00000000"; diff --git a/packages/cli/test/unit/config/peerId.test.ts b/packages/cli/test/unit/config/peerId.test.ts index c0cdc8cff1a9..a85aaf1a5a5c 100644 --- a/packages/cli/test/unit/config/peerId.test.ts +++ b/packages/cli/test/unit/config/peerId.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; import {createSecp256k1PeerId} from "@libp2p/peer-id-factory"; +import {describe, expect, it} from "vitest"; +import {readPeerId, writePeerId} from "../../../src/config/index.js"; import {getTestdirPath} from "../../utils.js"; -import {writePeerId, readPeerId} from "../../../src/config/index.js"; describe("config / peerId", () => { const peerIdFilepath = getTestdirPath("./test-peer-id.json"); diff --git a/packages/cli/test/unit/options/beaconNodeOptions.test.ts b/packages/cli/test/unit/options/beaconNodeOptions.test.ts index 8d295197b541..a94079ee0544 100644 --- a/packages/cli/test/unit/options/beaconNodeOptions.test.ts +++ b/packages/cli/test/unit/options/beaconNodeOptions.test.ts @@ -1,8 +1,8 @@ import fs from "node:fs"; -import {describe, it, expect} from "vitest"; -import {StateArchiveMode, IBeaconNodeOptions} from "@lodestar/beacon-node"; +import {IBeaconNodeOptions, StateArchiveMode} from "@lodestar/beacon-node"; import {RecursivePartial} from "@lodestar/utils"; -import {parseBeaconNodeArgs, BeaconNodeArgs} from "../../../src/options/beaconNodeOptions/index.js"; +import {describe, expect, it} from "vitest"; +import {BeaconNodeArgs, parseBeaconNodeArgs} from "../../../src/options/beaconNodeOptions/index.js"; import {getTestdirPath} from "../../utils.js"; describe("options / beaconNodeOptions", () => { diff --git a/packages/cli/test/unit/options/paramsOptions.test.ts b/packages/cli/test/unit/options/paramsOptions.test.ts index d6563203e652..13b3b6e41c6b 100644 --- a/packages/cli/test/unit/options/paramsOptions.test.ts +++ b/packages/cli/test/unit/options/paramsOptions.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {parseBeaconParamsArgs} from "../../../src/options/paramsOptions.js"; +import {describe, expect, it} from "vitest"; import {IBeaconParamsUnparsed} from "../../../src/config/types.js"; +import {parseBeaconParamsArgs} from "../../../src/options/paramsOptions.js"; describe("options / paramsOptions", () => { it("Should parse BeaconParams", () => { diff --git a/packages/cli/test/unit/paths/globalPaths.test.ts b/packages/cli/test/unit/paths/globalPaths.test.ts index 0d301bb56ffb..67655600c25b 100644 --- a/packages/cli/test/unit/paths/globalPaths.test.ts +++ b/packages/cli/test/unit/paths/globalPaths.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {getGlobalPaths} from "../../../src/paths/global.js"; describe("paths / global", () => { diff --git a/packages/cli/test/unit/util/extractJwtHexSecret.test.ts b/packages/cli/test/unit/util/extractJwtHexSecret.test.ts index bb7032390208..9f8543c2b9a1 100644 --- a/packages/cli/test/unit/util/extractJwtHexSecret.test.ts +++ b/packages/cli/test/unit/util/extractJwtHexSecret.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {extractJwtHexSecret} from "../../../src/util/index.js"; describe("parseJwtHexSecret", () => { diff --git a/packages/cli/test/unit/util/format.test.ts b/packages/cli/test/unit/util/format.test.ts index 194cc1dcbde7..f113d400860c 100644 --- a/packages/cli/test/unit/util/format.test.ts +++ b/packages/cli/test/unit/util/format.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {isValidatePubkeyHex, parseRange} from "../../../src/util/index.js"; describe("util / format / parseRange", () => { diff --git a/packages/cli/test/unit/util/gitData.test.ts b/packages/cli/test/unit/util/gitData.test.ts index 9e15fc2f4956..fe1827e58df2 100644 --- a/packages/cli/test/unit/util/gitData.test.ts +++ b/packages/cli/test/unit/util/gitData.test.ts @@ -1,8 +1,8 @@ import fs from "node:fs"; import path from "node:path"; import {fileURLToPath} from "node:url"; -import {describe, it, expect} from "vitest"; import {findUpSync} from "find-up"; +import {describe, expect, it} from "vitest"; import {gitDataPath, readGitDataFile} from "../../../src/util/gitData/gitDataPath.js"; import {getGitData} from "../../../src/util/index.js"; diff --git a/packages/cli/test/unit/util/logger.test.ts b/packages/cli/test/unit/util/logger.test.ts index fa17218bfd1c..dba3a72fda6c 100644 --- a/packages/cli/test/unit/util/logger.test.ts +++ b/packages/cli/test/unit/util/logger.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, vi, beforeEach, afterEach} from "vitest"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {shouldDeleteLogFile} from "../../../src/util/logger.js"; describe("shouldDeleteLogFile", () => { diff --git a/packages/cli/test/unit/util/parseBootnodesFile.test.ts b/packages/cli/test/unit/util/parseBootnodesFile.test.ts index 07338192bc68..87af3c994fb5 100644 --- a/packages/cli/test/unit/util/parseBootnodesFile.test.ts +++ b/packages/cli/test/unit/util/parseBootnodesFile.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {parseBootnodesFile} from "../../../src/util/index.js"; describe("config / bootnodes / parsing", () => { diff --git a/packages/cli/test/unit/util/progress.test.ts b/packages/cli/test/unit/util/progress.test.ts index d04d959d7422..11f443d35678 100644 --- a/packages/cli/test/unit/util/progress.test.ts +++ b/packages/cli/test/unit/util/progress.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, vi, beforeEach, afterEach} from "vitest"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {showProgress} from "../../../src/util/progress.js"; describe("progress", () => { diff --git a/packages/cli/test/unit/util/pruneOldFilesInDir.test.ts b/packages/cli/test/unit/util/pruneOldFilesInDir.test.ts index 76285afff081..a50c59547688 100644 --- a/packages/cli/test/unit/util/pruneOldFilesInDir.test.ts +++ b/packages/cli/test/unit/util/pruneOldFilesInDir.test.ts @@ -1,7 +1,7 @@ import fs from "node:fs"; import path from "node:path"; -import {describe, it, expect, beforeEach, afterEach} from "vitest"; import {rimraf} from "rimraf"; +import {afterEach, beforeEach, describe, expect, it} from "vitest"; import {pruneOldFilesInDir} from "../../../src/util/index.js"; import {testFilesDir} from "../../utils.js"; diff --git a/packages/cli/test/unit/util/stripOffNewlines.test.ts b/packages/cli/test/unit/util/stripOffNewlines.test.ts index 3a5a5a1f3523..0a118a499e34 100644 --- a/packages/cli/test/unit/util/stripOffNewlines.test.ts +++ b/packages/cli/test/unit/util/stripOffNewlines.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {stripOffNewlines} from "../../../src/util/index.js"; describe("stripOffNewlines", () => { diff --git a/packages/cli/test/unit/validator/decryptKeystoreDefinitions.test.ts b/packages/cli/test/unit/validator/decryptKeystoreDefinitions.test.ts index 10f6b34bd152..5bf19c635139 100644 --- a/packages/cli/test/unit/validator/decryptKeystoreDefinitions.test.ts +++ b/packages/cli/test/unit/validator/decryptKeystoreDefinitions.test.ts @@ -1,16 +1,16 @@ import fs from "node:fs"; import path from "node:path"; -import {describe, it, expect, beforeEach, vi} from "vitest"; -import {rimraf} from "rimraf"; import {getKeystoresStr} from "@lodestar/test-utils"; -import {cachedSeckeysHex} from "../../utils/cachedKeys.js"; -import {testFilesDir} from "../../utils.js"; +import {rimraf} from "rimraf"; +import {beforeEach, describe, expect, it, vi} from "vitest"; import { - decryptKeystoreDefinitions, KeystoreDecryptOptions, + decryptKeystoreDefinitions, } from "../../../src/cmds/validator/keymanager/decryptKeystoreDefinitions.js"; import {LocalKeystoreDefinition} from "../../../src/cmds/validator/keymanager/interface.js"; import {LockfileError, unlockFilepath} from "../../../src/util/lockfile.js"; +import {testFilesDir} from "../../utils.js"; +import {cachedSeckeysHex} from "../../utils/cachedKeys.js"; describe("decryptKeystoreDefinitions", () => { vi.setConfig({testTimeout: 100_000, hookTimeout: 50_000}); diff --git a/packages/cli/test/unit/validator/keys.test.ts b/packages/cli/test/unit/validator/keys.test.ts index 6902d17b3883..589e68db7f0d 100644 --- a/packages/cli/test/unit/validator/keys.test.ts +++ b/packages/cli/test/unit/validator/keys.test.ts @@ -1,6 +1,6 @@ import fs from "node:fs"; import path from "node:path"; -import {describe, it, expect, afterEach} from "vitest"; +import {afterEach, describe, expect, it} from "vitest"; import {importKeystoreDefinitionsFromExternalDir} from "../../../src/cmds/validator/signers/importExternalKeystores.js"; describe("validator / signers / importKeystoreDefinitionsFromExternalDir", () => { diff --git a/packages/cli/test/unit/validator/options.test.ts b/packages/cli/test/unit/validator/options.test.ts index 627ee8f59818..85aa0b3f21f7 100644 --- a/packages/cli/test/unit/validator/options.test.ts +++ b/packages/cli/test/unit/validator/options.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {parseFeeRecipient} from "../../../src/util/index.js"; const feeRecipient = Buffer.from(Array.from({length: 20}, () => Math.round(Math.random() * 255))); diff --git a/packages/cli/test/unit/validator/parseProposerConfig.test.ts b/packages/cli/test/unit/validator/parseProposerConfig.test.ts index 83c8c63ef877..5b510339b375 100644 --- a/packages/cli/test/unit/validator/parseProposerConfig.test.ts +++ b/packages/cli/test/unit/validator/parseProposerConfig.test.ts @@ -1,7 +1,7 @@ import path from "node:path"; import {fileURLToPath} from "node:url"; -import {describe, it, expect} from "vitest"; import {routes} from "@lodestar/api"; +import {describe, expect, it} from "vitest"; import {parseProposerConfig} from "../../../src/util/index.js"; diff --git a/packages/cli/test/utils.ts b/packages/cli/test/utils.ts index 81136c0a18d4..7c20ec0b9c2d 100644 --- a/packages/cli/test/utils.ts +++ b/packages/cli/test/utils.ts @@ -1,9 +1,9 @@ import fs from "node:fs"; import path from "node:path"; -import tmp from "tmp"; import {getEnvLogLevel} from "@lodestar/logger/env"; import {LoggerNode, LoggerNodeOpts, getNodeLogger} from "@lodestar/logger/node"; import {LogLevel} from "@lodestar/utils"; +import tmp from "tmp"; export const networkDev = "dev"; diff --git a/packages/cli/test/utils/crucible/assertions/accountBalanceAssertion.ts b/packages/cli/test/utils/crucible/assertions/accountBalanceAssertion.ts index e6c4f4c744eb..e237bba69dcb 100644 --- a/packages/cli/test/utils/crucible/assertions/accountBalanceAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/accountBalanceAssertion.ts @@ -1,5 +1,5 @@ import {EL_GENESIS_ACCOUNT} from "../constants.js"; -import {Match, AssertionResult, NodePair, Assertion} from "../interfaces.js"; +import {Assertion, AssertionResult, Match, NodePair} from "../interfaces.js"; const transactionAmount = BigInt(2441406250); diff --git a/packages/cli/test/utils/crucible/assertions/blobsAssertion.ts b/packages/cli/test/utils/crucible/assertions/blobsAssertion.ts index 50c9ed13f972..9bea3f1ca1f5 100644 --- a/packages/cli/test/utils/crucible/assertions/blobsAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/blobsAssertion.ts @@ -1,7 +1,7 @@ import {randomBytes} from "node:crypto"; import {fromHex, toHex} from "@lodestar/utils"; -import {Assertion, Match, AssertionResult, NodePair} from "../interfaces.js"; import {EL_GENESIS_ACCOUNT, EL_GENESIS_SECRET_KEY, SIM_ENV_CHAIN_ID} from "../constants.js"; +import {Assertion, AssertionResult, Match, NodePair} from "../interfaces.js"; import {generateBlobsForTransaction} from "../utils/blobs.js"; import {BlobsEIP4844Transaction} from "../web3js/blobsEIP4844Transaction.js"; diff --git a/packages/cli/test/utils/crucible/assertions/defaults/attestationCountAssertion.ts b/packages/cli/test/utils/crucible/assertions/defaults/attestationCountAssertion.ts index 922ce80ae329..2d0715051fa5 100644 --- a/packages/cli/test/utils/crucible/assertions/defaults/attestationCountAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/defaults/attestationCountAssertion.ts @@ -1,6 +1,6 @@ import {MAX_COMMITTEES_PER_SLOT} from "@lodestar/params"; -import {Match, AssertionResult, Assertion} from "../../interfaces.js"; -import {inclusionDelayAssertion, expectedMaxInclusionDelay} from "./inclusionDelayAssertion.js"; +import {Assertion, AssertionResult, Match} from "../../interfaces.js"; +import {expectedMaxInclusionDelay, inclusionDelayAssertion} from "./inclusionDelayAssertion.js"; export const expectedMinAttestationCount = MAX_COMMITTEES_PER_SLOT - 1; diff --git a/packages/cli/test/utils/crucible/assertions/defaults/attestationParticipationAssertion.ts b/packages/cli/test/utils/crucible/assertions/defaults/attestationParticipationAssertion.ts index 01cd6d29d09a..5715392758f1 100644 --- a/packages/cli/test/utils/crucible/assertions/defaults/attestationParticipationAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/defaults/attestationParticipationAssertion.ts @@ -1,7 +1,7 @@ import {TIMELY_HEAD_FLAG_INDEX, TIMELY_SOURCE_FLAG_INDEX, TIMELY_TARGET_FLAG_INDEX} from "@lodestar/params"; import {isActiveValidator} from "@lodestar/state-transition"; import {altair} from "@lodestar/types"; -import {Match, AssertionResult, Assertion} from "../../interfaces.js"; +import {Assertion, AssertionResult, Match} from "../../interfaces.js"; const TIMELY_HEAD = 1 << TIMELY_HEAD_FLAG_INDEX; const TIMELY_SOURCE = 1 << TIMELY_SOURCE_FLAG_INDEX; diff --git a/packages/cli/test/utils/crucible/assertions/defaults/connectedPeerCountAssertion.ts b/packages/cli/test/utils/crucible/assertions/defaults/connectedPeerCountAssertion.ts index 83f308e62789..5304731ee8fc 100644 --- a/packages/cli/test/utils/crucible/assertions/defaults/connectedPeerCountAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/defaults/connectedPeerCountAssertion.ts @@ -1,4 +1,4 @@ -import {AssertionResult, Assertion} from "../../interfaces.js"; +import {Assertion, AssertionResult} from "../../interfaces.js"; import {everySlotMatcher} from "../matchers.js"; export const connectedPeerCountAssertion: Assertion<"connectedPeerCount", number> = { diff --git a/packages/cli/test/utils/crucible/assertions/defaults/finalizedAssertion.ts b/packages/cli/test/utils/crucible/assertions/defaults/finalizedAssertion.ts index f03fc41eb8e9..89998fd87627 100644 --- a/packages/cli/test/utils/crucible/assertions/defaults/finalizedAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/defaults/finalizedAssertion.ts @@ -1,5 +1,5 @@ import {Slot} from "@lodestar/types"; -import {AssertionResult, Assertion} from "../../interfaces.js"; +import {Assertion, AssertionResult} from "../../interfaces.js"; import {everySlotMatcher} from "../matchers.js"; export const finalizedAssertion: Assertion<"finalized", Slot> = { diff --git a/packages/cli/test/utils/crucible/assertions/defaults/headAssertion.ts b/packages/cli/test/utils/crucible/assertions/defaults/headAssertion.ts index 6464067d5d7d..3a3f910a4489 100644 --- a/packages/cli/test/utils/crucible/assertions/defaults/headAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/defaults/headAssertion.ts @@ -1,6 +1,6 @@ import {RootHex, Slot} from "@lodestar/types"; import {toHexString} from "@lodestar/utils"; -import {AssertionResult, Assertion} from "../../interfaces.js"; +import {Assertion, AssertionResult} from "../../interfaces.js"; import {everySlotMatcher} from "../matchers.js"; export interface HeadSummary { diff --git a/packages/cli/test/utils/crucible/assertions/defaults/inclusionDelayAssertion.ts b/packages/cli/test/utils/crucible/assertions/defaults/inclusionDelayAssertion.ts index e3ec467099ba..f0f08c92f202 100644 --- a/packages/cli/test/utils/crucible/assertions/defaults/inclusionDelayAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/defaults/inclusionDelayAssertion.ts @@ -1,4 +1,4 @@ -import {AssertionResult, Assertion} from "../../interfaces.js"; +import {Assertion, AssertionResult} from "../../interfaces.js"; import {avg} from "../../utils/index.js"; import {everySlotMatcher} from "../matchers.js"; diff --git a/packages/cli/test/utils/crucible/assertions/defaults/missedBlocksAssertion.ts b/packages/cli/test/utils/crucible/assertions/defaults/missedBlocksAssertion.ts index 1209a6469ca3..8c8d96451f5e 100644 --- a/packages/cli/test/utils/crucible/assertions/defaults/missedBlocksAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/defaults/missedBlocksAssertion.ts @@ -1,5 +1,5 @@ import {isNullish} from "../../../../utils.js"; -import {Match, AssertionResult, Assertion} from "../../interfaces.js"; +import {Assertion, AssertionResult, Match} from "../../interfaces.js"; import {arrayEquals} from "../../utils/index.js"; import {headAssertion} from "./headAssertion.js"; diff --git a/packages/cli/test/utils/crucible/assertions/defaults/syncCommitteeParticipationAssertion.ts b/packages/cli/test/utils/crucible/assertions/defaults/syncCommitteeParticipationAssertion.ts index 83b945da0b0a..a0d6f8328187 100644 --- a/packages/cli/test/utils/crucible/assertions/defaults/syncCommitteeParticipationAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/defaults/syncCommitteeParticipationAssertion.ts @@ -1,6 +1,6 @@ import {ForkName} from "@lodestar/params"; import {altair} from "@lodestar/types"; -import {Match, AssertionResult, Assertion} from "../../interfaces.js"; +import {Assertion, AssertionResult, Match} from "../../interfaces.js"; import {avg} from "../../utils/index.js"; // Until we identity and fix the following issue, reducing the expected sync committee participation rate from 0.9 to 0.75 diff --git a/packages/cli/test/utils/crucible/assertions/executionHeadAssertion.ts b/packages/cli/test/utils/crucible/assertions/executionHeadAssertion.ts index 8ea0be1b445c..3f6fedd139fd 100644 --- a/packages/cli/test/utils/crucible/assertions/executionHeadAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/executionHeadAssertion.ts @@ -1,6 +1,6 @@ -import {toHex} from "@lodestar/utils"; import {bellatrix} from "@lodestar/types"; -import {Match, AssertionResult, Assertion} from "../interfaces.js"; +import {toHex} from "@lodestar/utils"; +import {Assertion, AssertionResult, Match} from "../interfaces.js"; export function createExecutionHeadAssertion({ checkForSlot, diff --git a/packages/cli/test/utils/crucible/assertions/forkAssertion.ts b/packages/cli/test/utils/crucible/assertions/forkAssertion.ts index 8f6372f856f6..aeddff9ab13c 100644 --- a/packages/cli/test/utils/crucible/assertions/forkAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/forkAssertion.ts @@ -1,7 +1,7 @@ import {ForkName} from "@lodestar/params"; import {Epoch} from "@lodestar/types"; import {toHexString} from "@lodestar/utils"; -import {Match, AssertionResult, Assertion} from "../interfaces.js"; +import {Assertion, AssertionResult, Match} from "../interfaces.js"; export function createForkAssertion(fork: ForkName, epoch: Epoch): Assertion { return { diff --git a/packages/cli/test/utils/crucible/assertions/lighthousePeerScoreAssertion.ts b/packages/cli/test/utils/crucible/assertions/lighthousePeerScoreAssertion.ts index 29fa36220b3d..d9dd4e0adc55 100644 --- a/packages/cli/test/utils/crucible/assertions/lighthousePeerScoreAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/lighthousePeerScoreAssertion.ts @@ -1,4 +1,4 @@ -import {AssertionResult, BeaconClient, LighthouseAPI, NodePair, Assertion} from "../interfaces.js"; +import {Assertion, AssertionResult, BeaconClient, LighthouseAPI, NodePair} from "../interfaces.js"; import {neverMatcher} from "./matchers.js"; const MIN_GOSSIPSUB_SCORE = 10; diff --git a/packages/cli/test/utils/crucible/assertions/mergeAssertion.ts b/packages/cli/test/utils/crucible/assertions/mergeAssertion.ts index acd686c87bf7..6e0c1a63d7af 100644 --- a/packages/cli/test/utils/crucible/assertions/mergeAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/mergeAssertion.ts @@ -1,5 +1,5 @@ import {BeaconStateAllForks, isExecutionStateType, isMergeTransitionComplete} from "@lodestar/state-transition"; -import {AssertionResult, Assertion} from "../interfaces.js"; +import {Assertion, AssertionResult} from "../interfaces.js"; import {neverMatcher} from "./matchers.js"; export const mergeAssertion: Assertion<"merge", string> = { diff --git a/packages/cli/test/utils/crucible/assertions/nodeAssertion.ts b/packages/cli/test/utils/crucible/assertions/nodeAssertion.ts index 04c9b393d245..6b94f2e701a9 100644 --- a/packages/cli/test/utils/crucible/assertions/nodeAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/nodeAssertion.ts @@ -1,7 +1,7 @@ import {SecretKey} from "@chainsafe/blst"; import {routes} from "@lodestar/api/beacon"; import {toHex} from "@lodestar/utils"; -import {AssertionResult, ValidatorClientKeys, Assertion, ValidatorClient} from "../interfaces.js"; +import {Assertion, AssertionResult, ValidatorClient, ValidatorClientKeys} from "../interfaces.js"; import {arrayEquals} from "../utils/index.js"; import {neverMatcher} from "./matchers.js"; diff --git a/packages/cli/test/utils/crucible/assertions/withdrawalsAssertion.ts b/packages/cli/test/utils/crucible/assertions/withdrawalsAssertion.ts index be256a0b696d..020684682858 100644 --- a/packages/cli/test/utils/crucible/assertions/withdrawalsAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/withdrawalsAssertion.ts @@ -1,6 +1,6 @@ -import {capella} from "@lodestar/types"; import {MAX_WITHDRAWALS_PER_PAYLOAD} from "@lodestar/params"; -import {Match, AssertionResult, Assertion} from "../interfaces.js"; +import {capella} from "@lodestar/types"; +import {Assertion, AssertionResult, Match} from "../interfaces.js"; type WithdrawalsData = { withdrawalCount: number; diff --git a/packages/cli/test/utils/crucible/clients/beacon/lighthouse.ts b/packages/cli/test/utils/crucible/clients/beacon/lighthouse.ts index 515418f7e558..725c08389105 100644 --- a/packages/cli/test/utils/crucible/clients/beacon/lighthouse.ts +++ b/packages/cli/test/utils/crucible/clients/beacon/lighthouse.ts @@ -1,9 +1,9 @@ import {writeFile} from "node:fs/promises"; import path from "node:path"; -import got, {RequestError} from "got"; -import yaml from "js-yaml"; import {getClient} from "@lodestar/api/beacon"; import {chainConfigToJson} from "@lodestar/config"; +import got, {RequestError} from "got"; +import yaml from "js-yaml"; import {BeaconClient, BeaconNodeGenerator, LighthouseAPI, RunnerType} from "../../interfaces.js"; import {getNodeMountedPaths} from "../../utils/paths.js"; import {getNodePorts} from "../../utils/ports.js"; diff --git a/packages/cli/test/utils/crucible/clients/beacon/lodestar.ts b/packages/cli/test/utils/crucible/clients/beacon/lodestar.ts index 2bc7c27ead41..320b9c1fd224 100644 --- a/packages/cli/test/utils/crucible/clients/beacon/lodestar.ts +++ b/packages/cli/test/utils/crucible/clients/beacon/lodestar.ts @@ -1,9 +1,9 @@ import {writeFile} from "node:fs/promises"; import path from "node:path"; -import got from "got"; import {getClient} from "@lodestar/api/beacon"; import {chainConfigToJson} from "@lodestar/config"; import {LogLevel} from "@lodestar/utils"; +import got from "got"; import {BeaconArgs} from "../../../../../src/cmds/beacon/options.js"; import {GlobalArgs} from "../../../../../src/options/globalOptions.js"; import {LODESTAR_BINARY_PATH} from "../../constants.js"; diff --git a/packages/cli/test/utils/crucible/clients/execution/geth.ts b/packages/cli/test/utils/crucible/clients/execution/geth.ts index ca3dee2dcb86..4daa008f0c54 100644 --- a/packages/cli/test/utils/crucible/clients/execution/geth.ts +++ b/packages/cli/test/utils/crucible/clients/execution/geth.ts @@ -9,10 +9,10 @@ import { SHARED_JWT_SECRET, SIM_ENV_NETWORK_ID, } from "../../constants.js"; -import {registerWeb3JsPlugins} from "../../web3js/plugins/index.js"; import {ExecutionClient, ExecutionNodeGenerator, ExecutionStartMode, JobOptions, RunnerType} from "../../interfaces.js"; import {getNodeMountedPaths} from "../../utils/paths.js"; import {getNodePorts} from "../../utils/ports.js"; +import {registerWeb3JsPlugins} from "../../web3js/plugins/index.js"; export const generateGethNode: ExecutionNodeGenerator = (opts, runner) => { if (!process.env.GETH_BINARY_DIR && !process.env.GETH_DOCKER_IMAGE) { diff --git a/packages/cli/test/utils/crucible/clients/execution/index.ts b/packages/cli/test/utils/crucible/clients/execution/index.ts index db6510a7a7d6..b7e83813ce3d 100644 --- a/packages/cli/test/utils/crucible/clients/execution/index.ts +++ b/packages/cli/test/utils/crucible/clients/execution/index.ts @@ -1,5 +1,5 @@ import {writeFile} from "node:fs/promises"; -import {SHARED_JWT_SECRET, CLIQUE_SEALING_PERIOD} from "../../constants.js"; +import {CLIQUE_SEALING_PERIOD, SHARED_JWT_SECRET} from "../../constants.js"; import { AtLeast, ExecutionClient, @@ -8,8 +8,8 @@ import { ExecutionNode, ExecutionStartMode, } from "../../interfaces.js"; -import {getEstimatedForkTime} from "../../utils/index.js"; import {getGethGenesisBlock} from "../../utils/executionGenesis.js"; +import {getEstimatedForkTime} from "../../utils/index.js"; import {ensureDirectories} from "../../utils/paths.js"; import {generateGethNode} from "./geth.js"; import {generateMockNode} from "./mock.js"; diff --git a/packages/cli/test/utils/crucible/clients/execution/nethermind.ts b/packages/cli/test/utils/crucible/clients/execution/nethermind.ts index 1c991afa6189..a59f7e55ece6 100644 --- a/packages/cli/test/utils/crucible/clients/execution/nethermind.ts +++ b/packages/cli/test/utils/crucible/clients/execution/nethermind.ts @@ -2,12 +2,12 @@ import {writeFile} from "node:fs/promises"; import path from "node:path"; import got from "got"; import {Web3} from "web3"; -import {registerWeb3JsPlugins} from "../../web3js/plugins/index.js"; +import {SHARED_JWT_SECRET} from "../../constants.js"; import {ExecutionClient, ExecutionNodeGenerator, JobOptions, RunnerType} from "../../interfaces.js"; import {getNethermindChainSpec} from "../../utils/executionGenesis.js"; import {getNodeMountedPaths} from "../../utils/paths.js"; -import {SHARED_JWT_SECRET} from "../../constants.js"; import {getNodePorts} from "../../utils/ports.js"; +import {registerWeb3JsPlugins} from "../../web3js/plugins/index.js"; export const generateNethermindNode: ExecutionNodeGenerator = (opts, runner) => { if (!process.env.NETHERMIND_DOCKER_IMAGE) { diff --git a/packages/cli/test/utils/crucible/clients/validator/index.ts b/packages/cli/test/utils/crucible/clients/validator/index.ts index 677deca23ff0..74f9734c767a 100644 --- a/packages/cli/test/utils/crucible/clients/validator/index.ts +++ b/packages/cli/test/utils/crucible/clients/validator/index.ts @@ -1,11 +1,11 @@ import {writeFile} from "node:fs/promises"; -import {SHARED_JWT_SECRET, SHARED_VALIDATOR_PASSWORD, BN_REST_BASE_PORT} from "../../constants.js"; +import {BN_REST_BASE_PORT, SHARED_JWT_SECRET, SHARED_VALIDATOR_PASSWORD} from "../../constants.js"; import {AtLeast, BeaconClient, ValidatorClient, ValidatorGeneratorOptions, ValidatorNode} from "../../interfaces.js"; import {makeUniqueArray} from "../../utils/index.js"; import {createKeystores} from "../../utils/keys.js"; import {ensureDirectories} from "../../utils/paths.js"; -import {generateLodestarValidatorNode} from "./lodestar.js"; import {generateLighthouseValidatorNode} from "./lighthouse.js"; +import {generateLodestarValidatorNode} from "./lodestar.js"; export async function createValidatorNode( client: V, diff --git a/packages/cli/test/utils/crucible/clients/validator/lighthouse.ts b/packages/cli/test/utils/crucible/clients/validator/lighthouse.ts index f99310dc7907..a5f137a861d5 100644 --- a/packages/cli/test/utils/crucible/clients/validator/lighthouse.ts +++ b/packages/cli/test/utils/crucible/clients/validator/lighthouse.ts @@ -1,9 +1,9 @@ -import path from "node:path"; import {writeFile} from "node:fs/promises"; -import got, {RequestError} from "got"; -import yaml from "js-yaml"; +import path from "node:path"; import {getClient as keyManagerGetClient} from "@lodestar/api/keymanager"; import {chainConfigToJson} from "@lodestar/config"; +import got, {RequestError} from "got"; +import yaml from "js-yaml"; import {RunnerType, ValidatorClient, ValidatorNodeGenerator} from "../../interfaces.js"; import {updateKeystoresPath} from "../../utils/keys.js"; import {getNodeMountedPaths} from "../../utils/paths.js"; diff --git a/packages/cli/test/utils/crucible/clients/validator/lodestar.ts b/packages/cli/test/utils/crucible/clients/validator/lodestar.ts index a2b928c0a2d5..4e2e88b71cc5 100644 --- a/packages/cli/test/utils/crucible/clients/validator/lodestar.ts +++ b/packages/cli/test/utils/crucible/clients/validator/lodestar.ts @@ -1,10 +1,10 @@ import {writeFile} from "node:fs/promises"; import path from "node:path"; -import got from "got"; import {getClient as keyManagerGetClient} from "@lodestar/api/keymanager"; import {chainConfigToJson} from "@lodestar/config"; import {LogLevel} from "@lodestar/utils"; import {defaultOptions} from "@lodestar/validator"; +import got from "got"; import {IValidatorCliArgs} from "../../../../../src/cmds/validator/options.js"; import {GlobalArgs} from "../../../../../src/options/globalOptions.js"; import {LODESTAR_BINARY_PATH} from "../../constants.js"; diff --git a/packages/cli/test/utils/crucible/externalSignerServer.ts b/packages/cli/test/utils/crucible/externalSignerServer.ts index 4282f1761db9..29789432a0d5 100644 --- a/packages/cli/test/utils/crucible/externalSignerServer.ts +++ b/packages/cli/test/utils/crucible/externalSignerServer.ts @@ -1,6 +1,6 @@ -import {fromHexString} from "@chainsafe/ssz"; -import {fastify, FastifyInstance} from "fastify"; import {SecretKey} from "@chainsafe/blst"; +import {fromHexString} from "@chainsafe/ssz"; +import {FastifyInstance, fastify} from "fastify"; import {EXTERNAL_SIGNER_BASE_PORT} from "./constants.js"; /* eslint-disable no-console */ diff --git a/packages/cli/test/utils/crucible/interfaces.ts b/packages/cli/test/utils/crucible/interfaces.ts index 84b5043ba983..13c56dd5012b 100644 --- a/packages/cli/test/utils/crucible/interfaces.ts +++ b/packages/cli/test/utils/crucible/interfaces.ts @@ -1,12 +1,12 @@ import {ChildProcess} from "node:child_process"; -import {Web3} from "web3"; import {SecretKey} from "@chainsafe/blst"; import {ApiClient} from "@lodestar/api"; import {ApiClient as KeyManagerApi} from "@lodestar/api/keymanager"; import {ChainForkConfig} from "@lodestar/config"; -import {ForkName} from "@lodestar/params"; -import {Slot, Epoch, SignedBeaconBlock} from "@lodestar/types"; import {LogLevel, Logger} from "@lodestar/logger"; +import {ForkName} from "@lodestar/params"; +import {Epoch, SignedBeaconBlock, Slot} from "@lodestar/types"; +import {Web3} from "web3"; import {BeaconArgs} from "../../../src/cmds/beacon/options.js"; import {IValidatorCliArgs} from "../../../src/cmds/validator/options.js"; import {GlobalArgs} from "../../../src/options/index.js"; diff --git a/packages/cli/test/utils/crucible/runner/childProcessRunner.ts b/packages/cli/test/utils/crucible/runner/childProcessRunner.ts index 4c2041d0860f..199d815cc8c3 100644 --- a/packages/cli/test/utils/crucible/runner/childProcessRunner.ts +++ b/packages/cli/test/utils/crucible/runner/childProcessRunner.ts @@ -1,6 +1,6 @@ import {ChildProcess} from "node:child_process"; -import {spawnChildProcess, stopChildProcess, SpawnChildProcessOptions, ChildProcessResolve} from "@lodestar/test-utils"; import {Logger} from "@lodestar/logger"; +import {ChildProcessResolve, SpawnChildProcessOptions, spawnChildProcess, stopChildProcess} from "@lodestar/test-utils"; import {Job, JobOptions, RunnerEnv, RunnerType} from "../interfaces.js"; export class ChildProcessRunner implements RunnerEnv { diff --git a/packages/cli/test/utils/crucible/runner/dockerRunner.ts b/packages/cli/test/utils/crucible/runner/dockerRunner.ts index bc5b97811cf4..33adb5aebbe0 100644 --- a/packages/cli/test/utils/crucible/runner/dockerRunner.ts +++ b/packages/cli/test/utils/crucible/runner/dockerRunner.ts @@ -1,7 +1,7 @@ import {ChildProcess} from "node:child_process"; import {Logger} from "@lodestar/logger"; +import {ChildProcessResolve, SpawnChildProcessOptions, execChildProcess, spawnChildProcess} from "@lodestar/test-utils"; import {sleep} from "@lodestar/utils"; -import {SpawnChildProcessOptions, execChildProcess, spawnChildProcess, ChildProcessResolve} from "@lodestar/test-utils"; import {Job, JobOptions, RunnerEnv, RunnerType} from "../interfaces.js"; const dockerNetworkIpRange = "192.168.0"; diff --git a/packages/cli/test/utils/crucible/simulation.ts b/packages/cli/test/utils/crucible/simulation.ts index c6e58095474a..e9674e5193e2 100644 --- a/packages/cli/test/utils/crucible/simulation.ts +++ b/packages/cli/test/utils/crucible/simulation.ts @@ -1,36 +1,36 @@ import fs from "node:fs"; import {mkdir, writeFile} from "node:fs/promises"; import path from "node:path"; -import tmp from "tmp"; import {fromHexString} from "@chainsafe/ssz"; import {nodeUtils} from "@lodestar/beacon-node"; -import {loadEthereumTrustedSetup, initCKZG} from "@lodestar/beacon-node/util"; +import {initCKZG, loadEthereumTrustedSetup} from "@lodestar/beacon-node/util"; import {ChainForkConfig} from "@lodestar/config"; +import {LogLevel, TimestampFormatCode} from "@lodestar/logger"; +import {LoggerNode, getNodeLogger} from "@lodestar/logger/node"; import {activePreset} from "@lodestar/params"; import {BeaconStateAllForks, interopSecretKey} from "@lodestar/state-transition"; import {prettyMsToTime} from "@lodestar/utils"; -import {LogLevel, TimestampFormatCode} from "@lodestar/logger"; -import {getNodeLogger, LoggerNode} from "@lodestar/logger/node"; -import {EpochClock, MS_IN_SEC} from "./epochClock.js"; -import {ExternalSignerServer} from "./externalSignerServer.js"; -import {SimulationTracker} from "./simulationTracker.js"; +import tmp from "tmp"; import {createBeaconNode} from "./clients/beacon/index.js"; +import {createExecutionNode} from "./clients/execution/index.js"; import {createValidatorNode, getValidatorForBeaconNode} from "./clients/validator/index.js"; import {MOCK_ETH1_GENESIS_HASH} from "./constants.js"; -import {createExecutionNode} from "./clients/execution/index.js"; +import {EpochClock, MS_IN_SEC} from "./epochClock.js"; +import {ExternalSignerServer} from "./externalSignerServer.js"; import { BeaconClient, - ValidatorClientKeys, ExecutionClient, + GeneratorOptions, IRunner, NodePair, NodePairDefinition, SimulationInitOptions, SimulationOptions, ValidatorClient, - GeneratorOptions, + ValidatorClientKeys, } from "./interfaces.js"; import {Runner} from "./runner/index.js"; +import {SimulationTracker} from "./simulationTracker.js"; import {registerProcessHandler, replaceIpFromUrl} from "./utils/index.js"; import {getNodePaths} from "./utils/paths.js"; diff --git a/packages/cli/test/utils/crucible/simulationTracker.ts b/packages/cli/test/utils/crucible/simulationTracker.ts index 778a7ad2a771..3e714ca8950f 100644 --- a/packages/cli/test/utils/crucible/simulationTracker.ts +++ b/packages/cli/test/utils/crucible/simulationTracker.ts @@ -1,25 +1,25 @@ import EventEmitter from "node:events"; -import path from "node:path"; import fs from "node:fs/promises"; -import createDebug from "debug"; +import path from "node:path"; import {routes} from "@lodestar/api/beacon"; import {ChainForkConfig} from "@lodestar/config"; -import {Epoch, Slot} from "@lodestar/types"; import {LoggerNode} from "@lodestar/logger/node"; +import {Epoch, Slot} from "@lodestar/types"; +import createDebug from "debug"; import {isNullish} from "../../utils.js"; +import {defaultAssertions} from "./assertions/defaults/index.js"; import {EpochClock} from "./epochClock.js"; import { - Match, + Assertion, + AssertionError, AtLeast, + Match, NodeId, NodePair, - Assertion, - AssertionError, SimulationReporter, StoreType, StoreTypes, } from "./interfaces.js"; -import {defaultAssertions} from "./assertions/defaults/index.js"; import {TableReporter} from "./tableReporter.js"; import {fetchBlock} from "./utils/network.js"; diff --git a/packages/cli/test/utils/crucible/utils/executionGenesis.ts b/packages/cli/test/utils/crucible/utils/executionGenesis.ts index bd3da4ba7662..02f7d553df16 100644 --- a/packages/cli/test/utils/crucible/utils/executionGenesis.ts +++ b/packages/cli/test/utils/crucible/utils/executionGenesis.ts @@ -1,5 +1,5 @@ import {SIM_ENV_CHAIN_ID, SIM_ENV_NETWORK_ID} from "../constants.js"; -import {ExecutionGenesisOptions, ExecutionStartMode, Eth1GenesisBlock} from "../interfaces.js"; +import {Eth1GenesisBlock, ExecutionGenesisOptions, ExecutionStartMode} from "../interfaces.js"; export const getGethGenesisBlock = ( mode: ExecutionStartMode, diff --git a/packages/cli/test/utils/crucible/utils/index.ts b/packages/cli/test/utils/crucible/utils/index.ts index 0e016778cdce..13b26cfd9318 100644 --- a/packages/cli/test/utils/crucible/utils/index.ts +++ b/packages/cli/test/utils/crucible/utils/index.ts @@ -1,7 +1,7 @@ +import {ChainConfig, ChainForkConfig, createChainForkConfig} from "@lodestar/config"; /* eslint-disable no-console */ import {activePreset} from "@lodestar/params"; import {Epoch} from "@lodestar/types"; -import {ChainConfig, ChainForkConfig, createChainForkConfig} from "@lodestar/config"; import { CLIQUE_SEALING_PERIOD, ETH_TTD_INCREMENT, diff --git a/packages/cli/test/utils/crucible/utils/keys.ts b/packages/cli/test/utils/crucible/utils/keys.ts index 8915e85b529e..1a4da9ffec65 100644 --- a/packages/cli/test/utils/crucible/utils/keys.ts +++ b/packages/cli/test/utils/crucible/utils/keys.ts @@ -1,7 +1,7 @@ import {readFile, writeFile} from "node:fs/promises"; import path from "node:path"; -import yaml from "js-yaml"; import {Keystore} from "@chainsafe/bls-keystore"; +import yaml from "js-yaml"; import {SHARED_VALIDATOR_PASSWORD} from "../constants.js"; import {ValidatorClientKeys, ValidatorPaths} from "../interfaces.js"; diff --git a/packages/cli/test/utils/crucible/utils/paths.ts b/packages/cli/test/utils/crucible/utils/paths.ts index 4ff149d6f308..06ef1bf7fe1f 100644 --- a/packages/cli/test/utils/crucible/utils/paths.ts +++ b/packages/cli/test/utils/crucible/utils/paths.ts @@ -1,6 +1,6 @@ -import path from "node:path"; import fs from "node:fs"; import {mkdir} from "node:fs/promises"; +import path from "node:path"; import { BeaconClient, BeaconPaths, diff --git a/packages/cli/test/utils/crucible/utils/ports.ts b/packages/cli/test/utils/crucible/utils/ports.ts index be430598895e..3b6f51ad1429 100644 --- a/packages/cli/test/utils/crucible/utils/ports.ts +++ b/packages/cli/test/utils/crucible/utils/ports.ts @@ -1,10 +1,10 @@ import { BN_P2P_BASE_PORT, BN_REST_BASE_PORT, - KEY_MANAGER_BASE_PORT, - EL_P2P_BASE_PORT, - EL_ETH_BASE_PORT, EL_ENGINE_BASE_PORT, + EL_ETH_BASE_PORT, + EL_P2P_BASE_PORT, + KEY_MANAGER_BASE_PORT, } from "../constants.js"; export const getNodePorts = ( diff --git a/packages/cli/test/utils/crucible/utils/syncing.ts b/packages/cli/test/utils/crucible/utils/syncing.ts index b720c6bf6ccc..e0232ae7b5ba 100644 --- a/packages/cli/test/utils/crucible/utils/syncing.ts +++ b/packages/cli/test/utils/crucible/utils/syncing.ts @@ -1,9 +1,9 @@ import {routes} from "@lodestar/api"; +import {ForkBlobs} from "@lodestar/params"; import {SignedBeaconBlock, Slot} from "@lodestar/types"; import {sleep, toHex} from "@lodestar/utils"; -import {ForkBlobs} from "@lodestar/params"; -import type {Simulation} from "../simulation.js"; import {BeaconClient, ExecutionClient, NodePair} from "../interfaces.js"; +import type {Simulation} from "../simulation.js"; import {connectNewCLNode, connectNewELNode, connectNewNode, waitForHead, waitForSlot} from "./network.js"; export async function assertRangeSync(env: Simulation): Promise { diff --git a/packages/cli/test/utils/crucible/web3js/blobsEIP4844Transaction.ts b/packages/cli/test/utils/crucible/web3js/blobsEIP4844Transaction.ts index a5dbf9408b7d..b61814e6ae1e 100644 --- a/packages/cli/test/utils/crucible/web3js/blobsEIP4844Transaction.ts +++ b/packages/cli/test/utils/crucible/web3js/blobsEIP4844Transaction.ts @@ -1,4 +1,5 @@ import {RLP} from "@ethereumjs/rlp"; +import {fromHex} from "@lodestar/utils"; import {keccak256} from "ethereum-cryptography/keccak.js"; import { FeeMarketEIP1559Transaction, @@ -7,7 +8,6 @@ import { bigIntToUnpaddedUint8Array, uint8ArrayToBigInt, } from "web3-eth-accounts"; -import {fromHex} from "@lodestar/utils"; function uint8ArrayConcat(...arrays: Uint8Array[]): Uint8Array { const totalLength = arrays.reduce((acc, arr) => acc + arr.length, 0); diff --git a/packages/cli/test/utils/mockBeaconApiServer.ts b/packages/cli/test/utils/mockBeaconApiServer.ts index e7e80338686f..24b8b9c7473b 100644 --- a/packages/cli/test/utils/mockBeaconApiServer.ts +++ b/packages/cli/test/utils/mockBeaconApiServer.ts @@ -1,6 +1,6 @@ -import {RestApiServer, RestApiServerOpts, RestApiServerModules} from "@lodestar/beacon-node"; -import {BeaconApiMethods, registerRoutes} from "@lodestar/api/beacon/server"; import {allNamespaces} from "@lodestar/api"; +import {BeaconApiMethods, registerRoutes} from "@lodestar/api/beacon/server"; +import {RestApiServer, RestApiServerModules, RestApiServerOpts} from "@lodestar/beacon-node"; import {ChainForkConfig} from "@lodestar/config"; import {config} from "@lodestar/config/default"; import {ssz} from "@lodestar/types"; diff --git a/packages/cli/test/utils/validator.ts b/packages/cli/test/utils/validator.ts index 139683d5dd6b..fbecf6900d28 100644 --- a/packages/cli/test/utils/validator.ts +++ b/packages/cli/test/utils/validator.ts @@ -1,8 +1,8 @@ import childProcess from "node:child_process"; -import {retry} from "@lodestar/utils"; import {ApiClient, getClient} from "@lodestar/api/keymanager"; import {config} from "@lodestar/config/default"; -import {spawnCliCommand, gracefullyStopChildProcess} from "@lodestar/test-utils"; +import {gracefullyStopChildProcess, spawnCliCommand} from "@lodestar/test-utils"; +import {retry} from "@lodestar/utils"; import {getMockBeaconApiServer} from "./mockBeaconApiServer.js"; import {expectDeepEqualsUnordered, findApiToken} from "./runUtils.js"; diff --git a/packages/config/src/beaconConfig.ts b/packages/config/src/beaconConfig.ts index 634bdc8b5047..7c84dbaeeb8d 100644 --- a/packages/config/src/beaconConfig.ts +++ b/packages/config/src/beaconConfig.ts @@ -1,6 +1,6 @@ import {Root} from "@lodestar/types"; -import {createChainConfig, ChainConfig} from "./chainConfig/index.js"; -import {createForkConfig, ForkConfig} from "./forkConfig/index.js"; +import {ChainConfig, createChainConfig} from "./chainConfig/index.js"; +import {ForkConfig, createForkConfig} from "./forkConfig/index.js"; import {createCachedGenesis} from "./genesisConfig/index.js"; import {CachedGenesis} from "./genesisConfig/types.js"; diff --git a/packages/config/src/chainConfig/configs/mainnet.ts b/packages/config/src/chainConfig/configs/mainnet.ts index 5da5f8d2acb0..4a01d9d062b1 100644 --- a/packages/config/src/chainConfig/configs/mainnet.ts +++ b/packages/config/src/chainConfig/configs/mainnet.ts @@ -1,5 +1,5 @@ -import {fromHex as b} from "@lodestar/utils"; import {PresetName} from "@lodestar/params"; +import {fromHex as b} from "@lodestar/utils"; import {ChainConfig} from "../types.js"; // Mainnet config diff --git a/packages/config/src/chainConfig/configs/minimal.ts b/packages/config/src/chainConfig/configs/minimal.ts index f1a52e956f4d..f0e116a553ab 100644 --- a/packages/config/src/chainConfig/configs/minimal.ts +++ b/packages/config/src/chainConfig/configs/minimal.ts @@ -1,5 +1,5 @@ -import {fromHex as b} from "@lodestar/utils"; import {PresetName} from "@lodestar/params"; +import {fromHex as b} from "@lodestar/utils"; import {ChainConfig} from "../types.js"; // Minimal config diff --git a/packages/config/src/chainConfig/default.ts b/packages/config/src/chainConfig/default.ts index ef2b9743a1d2..8f8acc37a9f3 100644 --- a/packages/config/src/chainConfig/default.ts +++ b/packages/config/src/chainConfig/default.ts @@ -1,7 +1,7 @@ import {ACTIVE_PRESET, PresetName} from "@lodestar/params"; -import {ChainConfig} from "./types.js"; import {chainConfig as mainnet} from "./configs/mainnet.js"; import {chainConfig as minimal} from "./configs/minimal.js"; +import {ChainConfig} from "./types.js"; let defaultChainConfig: ChainConfig; diff --git a/packages/config/src/chainConfig/index.ts b/packages/config/src/chainConfig/index.ts index b202021b0337..cd7d2d9c29f0 100644 --- a/packages/config/src/chainConfig/index.ts +++ b/packages/config/src/chainConfig/index.ts @@ -1,6 +1,6 @@ import {ACTIVE_PRESET} from "@lodestar/params"; -import {ChainConfig} from "./types.js"; import {defaultChainConfig} from "./default.js"; +import {ChainConfig} from "./types.js"; export {chainConfigToJson, chainConfigFromJson, specValuesToJson} from "./json.js"; export * from "./types.js"; diff --git a/packages/config/src/chainConfig/json.ts b/packages/config/src/chainConfig/json.ts index 78db9230c836..de5214d96416 100644 --- a/packages/config/src/chainConfig/json.ts +++ b/packages/config/src/chainConfig/json.ts @@ -1,5 +1,5 @@ import {fromHex, toHex} from "@lodestar/utils"; -import {ChainConfig, chainConfigTypes, SpecValue, SpecValueTypeName} from "./types.js"; +import {ChainConfig, SpecValue, SpecValueTypeName, chainConfigTypes} from "./types.js"; const MAX_UINT64_JSON = "18446744073709551615"; diff --git a/packages/config/src/chainConfig/networks/ephemery.ts b/packages/config/src/chainConfig/networks/ephemery.ts index d1c17c36f0ab..f6349afe1e9a 100644 --- a/packages/config/src/chainConfig/networks/ephemery.ts +++ b/packages/config/src/chainConfig/networks/ephemery.ts @@ -1,6 +1,6 @@ import {fromHex as b} from "@lodestar/utils"; -import {ChainConfig} from "../types.js"; import {chainConfig as mainnet} from "../configs/mainnet.js"; +import {ChainConfig} from "../types.js"; // Ephemery dynamic beacon chain config: // https://github.com/ephemery-testnet/ephemery-genesis/blob/master/cl-config.yaml diff --git a/packages/config/src/chainConfig/networks/gnosis.ts b/packages/config/src/chainConfig/networks/gnosis.ts index a25162ae5028..a3b2679bd080 100644 --- a/packages/config/src/chainConfig/networks/gnosis.ts +++ b/packages/config/src/chainConfig/networks/gnosis.ts @@ -1,7 +1,7 @@ -import {fromHex as b} from "@lodestar/utils"; import {PresetName} from "@lodestar/params"; -import {ChainConfig} from "../types.js"; +import {fromHex as b} from "@lodestar/utils"; import {chainConfig as mainnet} from "../configs/mainnet.js"; +import {ChainConfig} from "../types.js"; // Gnosis beacon chain config: // https://github.com/gnosischain/configs/blob/main/mainnet/config.yaml diff --git a/packages/config/src/chainConfig/networks/holesky.ts b/packages/config/src/chainConfig/networks/holesky.ts index 46c32606931f..18f356d6bc03 100644 --- a/packages/config/src/chainConfig/networks/holesky.ts +++ b/packages/config/src/chainConfig/networks/holesky.ts @@ -1,6 +1,6 @@ import {fromHex as b} from "@lodestar/utils"; -import {ChainConfig} from "../types.js"; import {chainConfig as mainnet} from "../configs/mainnet.js"; +import {ChainConfig} from "../types.js"; // Holesky beacon chain config: // https://github.com/eth-clients/holesky/blob/main/metadata/config.yaml diff --git a/packages/config/src/chainConfig/networks/mainnet.ts b/packages/config/src/chainConfig/networks/mainnet.ts index 13225b463da9..d10e3209243b 100644 --- a/packages/config/src/chainConfig/networks/mainnet.ts +++ b/packages/config/src/chainConfig/networks/mainnet.ts @@ -1,6 +1,6 @@ import {fromHex as b} from "@lodestar/utils"; -import {ChainConfig} from "../types.js"; import {chainConfig as mainnet} from "../configs/mainnet.js"; +import {ChainConfig} from "../types.js"; export const mainnetChainConfig: ChainConfig = { ...mainnet, diff --git a/packages/config/src/chainConfig/networks/sepolia.ts b/packages/config/src/chainConfig/networks/sepolia.ts index e7e5dc76f691..f47d73436702 100644 --- a/packages/config/src/chainConfig/networks/sepolia.ts +++ b/packages/config/src/chainConfig/networks/sepolia.ts @@ -1,6 +1,6 @@ import {fromHex as b} from "@lodestar/utils"; -import {ChainConfig} from "../types.js"; import {chainConfig as mainnet} from "../configs/mainnet.js"; +import {ChainConfig} from "../types.js"; // Sepolia beacon chain config: // https://github.com/eth-clients/sepolia/blob/main/metadata/config.yaml diff --git a/packages/config/src/forkConfig/index.ts b/packages/config/src/forkConfig/index.ts index 513cd7559ee3..725e0a3af572 100644 --- a/packages/config/src/forkConfig/index.ts +++ b/packages/config/src/forkConfig/index.ts @@ -1,17 +1,17 @@ import { - GENESIS_EPOCH, + ForkAll, + ForkBlobs, + ForkExecution, + ForkLightClient, ForkName, - SLOTS_PER_EPOCH, ForkSeq, - isForkLightClient, - isForkExecution, + GENESIS_EPOCH, + SLOTS_PER_EPOCH, isForkBlobs, - ForkExecution, - ForkAll, - ForkLightClient, - ForkBlobs, + isForkExecution, + isForkLightClient, } from "@lodestar/params"; -import {Slot, Version, SSZTypesFor, sszTypesFor, Epoch} from "@lodestar/types"; +import {Epoch, SSZTypesFor, Slot, Version, sszTypesFor} from "@lodestar/types"; import {ChainConfig} from "../chainConfig/index.js"; import {ForkConfig, ForkInfo} from "./types.js"; diff --git a/packages/config/src/genesisConfig/index.ts b/packages/config/src/genesisConfig/index.ts index d2dfae2a8e08..dad79df1a98d 100644 --- a/packages/config/src/genesisConfig/index.ts +++ b/packages/config/src/genesisConfig/index.ts @@ -1,8 +1,8 @@ -import {ForkName, SLOTS_PER_EPOCH, DOMAIN_VOLUNTARY_EXIT} from "@lodestar/params"; -import {DomainType, ForkDigest, phase0, Root, Slot, ssz, Version} from "@lodestar/types"; +import {DOMAIN_VOLUNTARY_EXIT, ForkName, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {DomainType, ForkDigest, Root, Slot, Version, phase0, ssz} from "@lodestar/types"; import {toHex} from "@lodestar/utils"; import {ChainForkConfig} from "../beaconConfig.js"; -import {ForkDigestHex, CachedGenesis} from "./types.js"; +import {CachedGenesis, ForkDigestHex} from "./types.js"; export type {ForkDigestContext} from "./types.js"; export function createCachedGenesis(chainForkConfig: ChainForkConfig, genesisValidatorsRoot: Root): CachedGenesis { diff --git a/packages/config/src/networks.ts b/packages/config/src/networks.ts index 819c02b995b0..dffa50956650 100644 --- a/packages/config/src/networks.ts +++ b/packages/config/src/networks.ts @@ -1,10 +1,10 @@ import {ChainConfig} from "./chainConfig/index.js"; -import {mainnetChainConfig} from "./chainConfig/networks/mainnet.js"; -import {gnosisChainConfig} from "./chainConfig/networks/gnosis.js"; -import {sepoliaChainConfig} from "./chainConfig/networks/sepolia.js"; -import {holeskyChainConfig} from "./chainConfig/networks/holesky.js"; import {chiadoChainConfig} from "./chainConfig/networks/chiado.js"; import {ephemeryChainConfig} from "./chainConfig/networks/ephemery.js"; +import {gnosisChainConfig} from "./chainConfig/networks/gnosis.js"; +import {holeskyChainConfig} from "./chainConfig/networks/holesky.js"; +import {mainnetChainConfig} from "./chainConfig/networks/mainnet.js"; +import {sepoliaChainConfig} from "./chainConfig/networks/sepolia.js"; export { mainnetChainConfig, diff --git a/packages/config/test/unit/index.test.ts b/packages/config/test/unit/index.test.ts index bde31f6b1477..9c6e94978504 100644 --- a/packages/config/test/unit/index.test.ts +++ b/packages/config/test/unit/index.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; import {toHexString} from "@chainsafe/ssz"; import {ForkName} from "@lodestar/params"; -import {config, chainConfig} from "../../src/default.js"; +import {describe, expect, it} from "vitest"; +import {chainConfig, config} from "../../src/default.js"; import {createForkConfig} from "../../src/index.js"; describe("forks", () => { diff --git a/packages/config/test/unit/json.test.ts b/packages/config/test/unit/json.test.ts index 96ffd050a088..970a40048540 100644 --- a/packages/config/test/unit/json.test.ts +++ b/packages/config/test/unit/json.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {chainConfigFromJson, chainConfigToJson} from "../../src/index.js"; +import {describe, expect, it} from "vitest"; import {chainConfig} from "../../src/default.js"; +import {chainConfigFromJson, chainConfigToJson} from "../../src/index.js"; describe("chainConfig JSON", () => { it("Convert to and from JSON", () => { diff --git a/packages/db/src/controller/level.ts b/packages/db/src/controller/level.ts index 82fbf631f7ae..ac3688a161ab 100644 --- a/packages/db/src/controller/level.ts +++ b/packages/db/src/controller/level.ts @@ -1,6 +1,6 @@ -import {ClassicLevel} from "classic-level"; import {Logger} from "@lodestar/utils"; -import {DbReqOpts, DatabaseController, DatabaseOptions, FilterOptions, KeyValue} from "./interface.js"; +import {ClassicLevel} from "classic-level"; +import {DatabaseController, DatabaseOptions, DbReqOpts, FilterOptions, KeyValue} from "./interface.js"; import {LevelDbControllerMetrics} from "./metrics.js"; enum Status { diff --git a/packages/db/test/unit/controller/level.test.ts b/packages/db/test/unit/controller/level.test.ts index 16f20e770c93..af9de5a04e46 100644 --- a/packages/db/test/unit/controller/level.test.ts +++ b/packages/db/test/unit/controller/level.test.ts @@ -1,8 +1,8 @@ import {execSync} from "node:child_process"; import os from "node:os"; -import {describe, it, expect, beforeAll, afterAll} from "vitest"; -import all from "it-all"; import {getEnvLogger} from "@lodestar/logger/env"; +import all from "it-all"; +import {afterAll, beforeAll, describe, expect, it} from "vitest"; import {LevelDbController} from "../../../src/controller/index.js"; describe("LevelDB controller", () => { diff --git a/packages/db/test/unit/schema.test.ts b/packages/db/test/unit/schema.test.ts index c72611453e4f..7488e9f5aaef 100644 --- a/packages/db/test/unit/schema.test.ts +++ b/packages/db/test/unit/schema.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {intToBytes} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; import {BUCKET_LENGTH, encodeKey} from "../../src/index.js"; describe("encodeKey", () => { diff --git a/packages/flare/src/cli.ts b/packages/flare/src/cli.ts index 91c4ef83ca09..9b29d22629de 100644 --- a/packages/flare/src/cli.ts +++ b/packages/flare/src/cli.ts @@ -1,7 +1,7 @@ +import {registerCommandToYargs} from "@lodestar/utils"; // Must not use `* as yargs`, see https://github.com/yargs/yargs/issues/1131 import yargs from "yargs"; import {hideBin} from "yargs/helpers"; -import {registerCommandToYargs} from "@lodestar/utils"; import {cmds} from "./cmds/index.js"; const topBanner = `Beacon chain multi-purpose and debugging tool. diff --git a/packages/flare/src/cmds/index.ts b/packages/flare/src/cmds/index.ts index 63e1f316b3b6..58d882040e8a 100644 --- a/packages/flare/src/cmds/index.ts +++ b/packages/flare/src/cmds/index.ts @@ -1,6 +1,6 @@ import {CliCommand} from "@lodestar/utils"; -import {selfSlashProposer} from "./selfSlashProposer.js"; import {selfSlashAttester} from "./selfSlashAttester.js"; +import {selfSlashProposer} from "./selfSlashProposer.js"; export const cmds: Required, Record>>["subcommands"] = [ selfSlashProposer, diff --git a/packages/flare/src/cmds/selfSlashAttester.ts b/packages/flare/src/cmds/selfSlashAttester.ts index 174535ba2e7d..78c10b6451a3 100644 --- a/packages/flare/src/cmds/selfSlashAttester.ts +++ b/packages/flare/src/cmds/selfSlashAttester.ts @@ -1,12 +1,12 @@ import {SecretKey, aggregateSignatures} from "@chainsafe/blst"; import {getClient} from "@lodestar/api"; -import {AttesterSlashing, phase0, ssz} from "@lodestar/types"; +import {BeaconConfig, createBeaconConfig} from "@lodestar/config"; import {config as chainConfig} from "@lodestar/config/default"; -import {createBeaconConfig, BeaconConfig} from "@lodestar/config"; import {DOMAIN_BEACON_ATTESTER, MAX_VALIDATORS_PER_COMMITTEE} from "@lodestar/params"; -import {CliCommand, toPubkeyHex} from "@lodestar/utils"; import {computeSigningRoot} from "@lodestar/state-transition"; -import {deriveSecretKeys, SecretKeysArgs, secretKeysOptions} from "../util/deriveSecretKeys.js"; +import {AttesterSlashing, phase0, ssz} from "@lodestar/types"; +import {CliCommand, toPubkeyHex} from "@lodestar/utils"; +import {SecretKeysArgs, deriveSecretKeys, secretKeysOptions} from "../util/deriveSecretKeys.js"; /* eslint-disable no-console */ diff --git a/packages/flare/src/cmds/selfSlashProposer.ts b/packages/flare/src/cmds/selfSlashProposer.ts index dd9580232e71..83992aae7d82 100644 --- a/packages/flare/src/cmds/selfSlashProposer.ts +++ b/packages/flare/src/cmds/selfSlashProposer.ts @@ -1,12 +1,12 @@ import {SecretKey} from "@chainsafe/blst"; import {getClient} from "@lodestar/api"; -import {phase0, ssz} from "@lodestar/types"; +import {BeaconConfig, createBeaconConfig} from "@lodestar/config"; import {config as chainConfig} from "@lodestar/config/default"; -import {createBeaconConfig, BeaconConfig} from "@lodestar/config"; import {DOMAIN_BEACON_PROPOSER} from "@lodestar/params"; -import {CliCommand, toPubkeyHex} from "@lodestar/utils"; import {computeSigningRoot} from "@lodestar/state-transition"; -import {deriveSecretKeys, SecretKeysArgs, secretKeysOptions} from "../util/deriveSecretKeys.js"; +import {phase0, ssz} from "@lodestar/types"; +import {CliCommand, toPubkeyHex} from "@lodestar/utils"; +import {SecretKeysArgs, deriveSecretKeys, secretKeysOptions} from "../util/deriveSecretKeys.js"; /* eslint-disable no-console */ diff --git a/packages/flare/src/index.ts b/packages/flare/src/index.ts index 5f3b85b459c1..b2ef85ce4c10 100644 --- a/packages/flare/src/index.ts +++ b/packages/flare/src/index.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node -import {YargsError} from "./util/errors.js"; import {getCli, yarg} from "./cli.js"; +import {YargsError} from "./util/errors.js"; import "source-map-support/register.js"; const flare = getCli(); diff --git a/packages/flare/test/unit/utils/format.test.ts b/packages/flare/test/unit/utils/format.test.ts index c6ef8805fe7b..846793175d9d 100644 --- a/packages/flare/test/unit/utils/format.test.ts +++ b/packages/flare/test/unit/utils/format.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {parseRange} from "../../../src/util/format.js"; describe("utils / format", () => { diff --git a/packages/fork-choice/src/forkChoice/errors.ts b/packages/fork-choice/src/forkChoice/errors.ts index 43d209106eed..cd0e0cd25274 100644 --- a/packages/fork-choice/src/forkChoice/errors.ts +++ b/packages/fork-choice/src/forkChoice/errors.ts @@ -1,4 +1,4 @@ -import {Slot, Epoch, RootHex} from "@lodestar/types"; +import {Epoch, RootHex, Slot} from "@lodestar/types"; import {LodestarError} from "@lodestar/utils"; export enum InvalidBlockCode { diff --git a/packages/fork-choice/src/forkChoice/forkChoice.ts b/packages/fork-choice/src/forkChoice/forkChoice.ts index dcc76441865e..2b803c3553a4 100644 --- a/packages/fork-choice/src/forkChoice/forkChoice.ts +++ b/packages/fork-choice/src/forkChoice/forkChoice.ts @@ -1,47 +1,47 @@ -import {Logger, MapDef, fromHex, toRootHex} from "@lodestar/utils"; -import {SLOTS_PER_HISTORICAL_ROOT, SLOTS_PER_EPOCH, INTERVALS_PER_SLOT} from "@lodestar/params"; -import {bellatrix, Slot, ValidatorIndex, phase0, ssz, RootHex, Epoch, Root, BeaconBlock} from "@lodestar/types"; +import {ChainConfig, ChainForkConfig} from "@lodestar/config"; +import {INTERVALS_PER_SLOT, SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params"; import { + CachedBeaconStateAllForks, + EffectiveBalanceIncrements, + ZERO_HASH, + computeEpochAtSlot, computeSlotsSinceEpochStart, computeStartSlotAtEpoch, - computeEpochAtSlot, - ZERO_HASH, - EffectiveBalanceIncrements, - CachedBeaconStateAllForks, + getAttesterSlashableIndices, isExecutionBlockBodyType, - isExecutionStateType, isExecutionEnabled, - getAttesterSlashableIndices, + isExecutionStateType, } from "@lodestar/state-transition"; import {computeUnrealizedCheckpoints} from "@lodestar/state-transition/epoch"; -import {ChainConfig, ChainForkConfig} from "@lodestar/config"; +import {BeaconBlock, Epoch, Root, RootHex, Slot, ValidatorIndex, bellatrix, phase0, ssz} from "@lodestar/types"; +import {Logger, MapDef, fromHex, toRootHex} from "@lodestar/utils"; import {computeDeltas} from "../protoArray/computeDeltas.js"; +import {ProtoArrayError, ProtoArrayErrorCode} from "../protoArray/errors.js"; import { - HEX_ZERO_HASH, - VoteTracker, - ProtoBlock, + DataAvailabilityStatus, ExecutionStatus, - MaybeValidExecutionStatus, + HEX_ZERO_HASH, LVHExecResponse, + MaybeValidExecutionStatus, + ProtoBlock, ProtoNode, - DataAvailabilityStatus, + VoteTracker, } from "../protoArray/interface.js"; import {ProtoArray} from "../protoArray/protoArray.js"; -import {ProtoArrayError, ProtoArrayErrorCode} from "../protoArray/errors.js"; -import {ForkChoiceError, ForkChoiceErrorCode, InvalidBlockCode, InvalidAttestationCode} from "./errors.js"; +import {ForkChoiceError, ForkChoiceErrorCode, InvalidAttestationCode, InvalidBlockCode} from "./errors.js"; import { - IForkChoice, - LatestMessage, - PowBlockHex, - EpochDifference, AncestorResult, AncestorStatus, + EpochDifference, ForkChoiceMetrics, + IForkChoice, + LatestMessage, NotReorgedReason, + PowBlockHex, } from "./interface.js"; -import {IForkChoiceStore, CheckpointWithHex, toCheckpointWithHex, JustifiedBalances} from "./store.js"; +import {CheckpointWithHex, IForkChoiceStore, JustifiedBalances, toCheckpointWithHex} from "./store.js"; export type ForkChoiceOpts = { proposerBoost?: boolean; diff --git a/packages/fork-choice/src/forkChoice/interface.ts b/packages/fork-choice/src/forkChoice/interface.ts index 9ac8cdfac81b..05c803b50dc8 100644 --- a/packages/fork-choice/src/forkChoice/interface.ts +++ b/packages/fork-choice/src/forkChoice/interface.ts @@ -1,15 +1,15 @@ import {EffectiveBalanceIncrements} from "@lodestar/state-transition"; import {CachedBeaconStateAllForks} from "@lodestar/state-transition"; -import {Epoch, Slot, ValidatorIndex, phase0, Root, RootHex, BeaconBlock, IndexedAttestation} from "@lodestar/types"; +import {BeaconBlock, Epoch, IndexedAttestation, Root, RootHex, Slot, ValidatorIndex, phase0} from "@lodestar/types"; import { - ProtoBlock, - MaybeValidExecutionStatus, + DataAvailabilityStatus, LVHExecResponse, + MaybeValidExecutionStatus, + ProtoBlock, ProtoNode, - DataAvailabilityStatus, } from "../protoArray/interface.js"; -import {CheckpointWithHex} from "./store.js"; import {UpdateAndGetHeadOpt} from "./forkChoice.js"; +import {CheckpointWithHex} from "./store.js"; export type CheckpointHex = { epoch: Epoch; diff --git a/packages/fork-choice/src/forkChoice/store.ts b/packages/fork-choice/src/forkChoice/store.ts index 2cd4da512870..fda01689f96c 100644 --- a/packages/fork-choice/src/forkChoice/store.ts +++ b/packages/fork-choice/src/forkChoice/store.ts @@ -1,7 +1,7 @@ +import {CachedBeaconStateAllForks, EffectiveBalanceIncrements} from "@lodestar/state-transition"; +import {RootHex, Slot, ValidatorIndex, phase0} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; -import {EffectiveBalanceIncrements, CachedBeaconStateAllForks} from "@lodestar/state-transition"; -import {phase0, Slot, RootHex, ValidatorIndex} from "@lodestar/types"; -import {CheckpointHexWithTotalBalance, CheckpointHexWithBalance} from "./interface.js"; +import {CheckpointHexWithBalance, CheckpointHexWithTotalBalance} from "./interface.js"; /** * Stores checkpoints in a hybrid format: diff --git a/packages/fork-choice/src/protoArray/computeDeltas.ts b/packages/fork-choice/src/protoArray/computeDeltas.ts index c921e12f751e..928cef8487cb 100644 --- a/packages/fork-choice/src/protoArray/computeDeltas.ts +++ b/packages/fork-choice/src/protoArray/computeDeltas.ts @@ -1,7 +1,7 @@ -import {ValidatorIndex} from "@lodestar/types"; import {EffectiveBalanceIncrements} from "@lodestar/state-transition"; -import {VoteTracker} from "./interface.js"; +import {ValidatorIndex} from "@lodestar/types"; import {ProtoArrayError, ProtoArrayErrorCode} from "./errors.js"; +import {VoteTracker} from "./interface.js"; // reuse arrays to avoid memory reallocation and gc const deltas = new Array(); diff --git a/packages/fork-choice/src/protoArray/interface.ts b/packages/fork-choice/src/protoArray/interface.ts index d60305a6ff72..5e36593697f6 100644 --- a/packages/fork-choice/src/protoArray/interface.ts +++ b/packages/fork-choice/src/protoArray/interface.ts @@ -1,4 +1,4 @@ -import {Epoch, Slot, RootHex, UintNum64} from "@lodestar/types"; +import {Epoch, RootHex, Slot, UintNum64} from "@lodestar/types"; // RootHex is a root as a hex string // Used for lightweight and easy comparison diff --git a/packages/fork-choice/src/protoArray/protoArray.ts b/packages/fork-choice/src/protoArray/protoArray.ts index 82a8b2620880..e1cbf4970920 100644 --- a/packages/fork-choice/src/protoArray/protoArray.ts +++ b/packages/fork-choice/src/protoArray/protoArray.ts @@ -1,11 +1,11 @@ -import {Epoch, RootHex, Slot} from "@lodestar/types"; -import {computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {GENESIS_EPOCH} from "@lodestar/params"; +import {computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition"; +import {Epoch, RootHex, Slot} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; import {ForkChoiceError, ForkChoiceErrorCode} from "../forkChoice/errors.js"; -import {ProtoBlock, ProtoNode, HEX_ZERO_HASH, ExecutionStatus, LVHExecResponse} from "./interface.js"; -import {ProtoArrayError, ProtoArrayErrorCode, LVHExecError, LVHExecErrorCode} from "./errors.js"; +import {LVHExecError, LVHExecErrorCode, ProtoArrayError, ProtoArrayErrorCode} from "./errors.js"; +import {ExecutionStatus, HEX_ZERO_HASH, LVHExecResponse, ProtoBlock, ProtoNode} from "./interface.js"; export const DEFAULT_PRUNE_THRESHOLD = 0; type ProposerBoost = {root: RootHex; score: number}; diff --git a/packages/fork-choice/test/perf/forkChoice/onAttestation.test.ts b/packages/fork-choice/test/perf/forkChoice/onAttestation.test.ts index ae3b10b45d63..db344de96c57 100644 --- a/packages/fork-choice/test/perf/forkChoice/onAttestation.test.ts +++ b/packages/fork-choice/test/perf/forkChoice/onAttestation.test.ts @@ -1,9 +1,9 @@ -import {itBench} from "@dapplion/benchmark"; import {fromHexString, toHexString} from "@chainsafe/ssz"; -import {AttestationData, IndexedAttestation} from "@lodestar/types/phase0"; +import {itBench} from "@dapplion/benchmark"; import {ATTESTATION_SUBNET_COUNT} from "@lodestar/params"; -import {ssz} from "@lodestar/types"; import {computeEpochAtSlot} from "@lodestar/state-transition"; +import {ssz} from "@lodestar/types"; +import {AttestationData, IndexedAttestation} from "@lodestar/types/phase0"; import {initializeForkChoice} from "./util.js"; describe("ForkChoice onAttestation", () => { diff --git a/packages/fork-choice/test/perf/forkChoice/updateHead.test.ts b/packages/fork-choice/test/perf/forkChoice/updateHead.test.ts index 850215f5a844..892135b4eb34 100644 --- a/packages/fork-choice/test/perf/forkChoice/updateHead.test.ts +++ b/packages/fork-choice/test/perf/forkChoice/updateHead.test.ts @@ -1,7 +1,7 @@ import {itBench} from "@dapplion/benchmark"; import {computeEpochAtSlot} from "@lodestar/state-transition"; import {ForkChoice, ProtoBlock} from "../../../src/index.js"; -import {initializeForkChoice, Opts} from "./util.js"; +import {Opts, initializeForkChoice} from "./util.js"; describe("forkchoice updateHead", () => { for (const initialValidatorCount of [100_000, 600_000, 1_000_000]) { diff --git a/packages/fork-choice/test/perf/forkChoice/util.ts b/packages/fork-choice/test/perf/forkChoice/util.ts index 6c04ac817fb2..4376ce047727 100644 --- a/packages/fork-choice/test/perf/forkChoice/util.ts +++ b/packages/fork-choice/test/perf/forkChoice/util.ts @@ -1,14 +1,14 @@ import {fromHexString} from "@chainsafe/ssz"; import {config} from "@lodestar/config/default"; +import {computeTotalBalance} from "../../../src/forkChoice/store.js"; import { + DataAvailabilityStatus, ExecutionStatus, ForkChoice, IForkChoiceStore, - ProtoBlock, ProtoArray, - DataAvailabilityStatus, + ProtoBlock, } from "../../../src/index.js"; -import {computeTotalBalance} from "../../../src/forkChoice/store.js"; const genesisSlot = 0; const genesisEpoch = 0; diff --git a/packages/fork-choice/test/perf/protoArray/computeDeltas.test.ts b/packages/fork-choice/test/perf/protoArray/computeDeltas.test.ts index 9b51f640d949..cb99d8b566d4 100644 --- a/packages/fork-choice/test/perf/protoArray/computeDeltas.test.ts +++ b/packages/fork-choice/test/perf/protoArray/computeDeltas.test.ts @@ -1,7 +1,7 @@ import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {EffectiveBalanceIncrements, getEffectiveBalanceIncrementsZeroed} from "@lodestar/state-transition"; -import {VoteTracker} from "../../../src/protoArray/interface.js"; import {computeDeltas} from "../../../src/protoArray/computeDeltas.js"; +import {VoteTracker} from "../../../src/protoArray/interface.js"; describe("computeDeltas", () => { let oldBalances: EffectiveBalanceIncrements; diff --git a/packages/fork-choice/test/unit/forkChoice/forkChoice.test.ts b/packages/fork-choice/test/unit/forkChoice/forkChoice.test.ts index f47849136bff..db7482f30cde 100644 --- a/packages/fork-choice/test/unit/forkChoice/forkChoice.test.ts +++ b/packages/fork-choice/test/unit/forkChoice/forkChoice.test.ts @@ -1,18 +1,18 @@ -import {describe, it, expect, beforeEach, beforeAll} from "vitest"; import {fromHexString} from "@chainsafe/ssz"; import {config} from "@lodestar/config/default"; +import {SLOTS_PER_EPOCH} from "@lodestar/params"; +import {computeEpochAtSlot} from "@lodestar/state-transition"; import {RootHex, Slot} from "@lodestar/types"; import {toHex} from "@lodestar/utils"; -import {computeEpochAtSlot} from "@lodestar/state-transition"; -import {SLOTS_PER_EPOCH} from "@lodestar/params"; +import {beforeAll, beforeEach, describe, expect, it} from "vitest"; import { + DataAvailabilityStatus, + EpochDifference, + ExecutionStatus, ForkChoice, IForkChoiceStore, - ProtoBlock, ProtoArray, - ExecutionStatus, - EpochDifference, - DataAvailabilityStatus, + ProtoBlock, } from "../../../src/index.js"; import {getBlockRoot, getStateRoot} from "../../utils/index.js"; diff --git a/packages/fork-choice/test/unit/forkChoice/getProposerHead.test.ts b/packages/fork-choice/test/unit/forkChoice/getProposerHead.test.ts index 187834e6d63a..ba225756733d 100644 --- a/packages/fork-choice/test/unit/forkChoice/getProposerHead.test.ts +++ b/packages/fork-choice/test/unit/forkChoice/getProposerHead.test.ts @@ -1,18 +1,18 @@ -import {describe, it, expect, beforeEach} from "vitest"; import {fromHexString} from "@chainsafe/ssz"; import {config} from "@lodestar/config/default"; +import {INTERVALS_PER_SLOT, SLOTS_PER_EPOCH} from "@lodestar/params"; import {Slot} from "@lodestar/types"; import {toHex} from "@lodestar/utils"; -import {INTERVALS_PER_SLOT, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {beforeEach, describe, expect, it} from "vitest"; +import {NotReorgedReason} from "../../../src/forkChoice/interface.js"; import { + DataAvailabilityStatus, + ExecutionStatus, ForkChoice, IForkChoiceStore, ProtoArray, - ExecutionStatus, ProtoBlock, - DataAvailabilityStatus, } from "../../../src/index.js"; -import {NotReorgedReason} from "../../../src/forkChoice/interface.js"; import {getBlockRoot, getStateRoot} from "../../utils/index.js"; type ProtoBlockWithWeight = ProtoBlock & {weight: number}; // weight of the block itself diff --git a/packages/fork-choice/test/unit/forkChoice/utils.test.ts b/packages/fork-choice/test/unit/forkChoice/utils.test.ts index 44b0eb8b719b..b3bea1020544 100644 --- a/packages/fork-choice/test/unit/forkChoice/utils.test.ts +++ b/packages/fork-choice/test/unit/forkChoice/utils.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; import {createChainForkConfig} from "@lodestar/config"; import {ssz} from "@lodestar/types"; -import {assertValidTerminalPowBlock, ExecutionStatus} from "../../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {ExecutionStatus, assertValidTerminalPowBlock} from "../../../src/index.js"; describe("assertValidTerminalPowBlock", () => { const config = createChainForkConfig({TERMINAL_TOTAL_DIFFICULTY: BigInt(10)}); diff --git a/packages/fork-choice/test/unit/protoArray/computeDeltas.test.ts b/packages/fork-choice/test/unit/protoArray/computeDeltas.test.ts index 4428807bd13d..af5d42f834b9 100644 --- a/packages/fork-choice/test/unit/protoArray/computeDeltas.test.ts +++ b/packages/fork-choice/test/unit/protoArray/computeDeltas.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {getEffectiveBalanceIncrementsZeroed} from "@lodestar/state-transition"; +import {describe, expect, it} from "vitest"; import {computeDeltas} from "../../../src/protoArray/computeDeltas.js"; diff --git a/packages/fork-choice/test/unit/protoArray/executionStatusUpdates.test.ts b/packages/fork-choice/test/unit/protoArray/executionStatusUpdates.test.ts index cefb2b07df02..4fcc6c79d190 100644 --- a/packages/fork-choice/test/unit/protoArray/executionStatusUpdates.test.ts +++ b/packages/fork-choice/test/unit/protoArray/executionStatusUpdates.test.ts @@ -1,10 +1,10 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { - ProtoBlock, - ProtoArray, + BlockExtraMeta, ExecutionStatus, MaybeValidExecutionStatus, - BlockExtraMeta, + ProtoArray, + ProtoBlock, } from "../../../src/index.js"; import {LVHExecErrorCode} from "../../../src/protoArray/errors.js"; import {DataAvailabilityStatus} from "../../../src/protoArray/interface.js"; diff --git a/packages/fork-choice/test/unit/protoArray/getCommonAncestor.test.ts b/packages/fork-choice/test/unit/protoArray/getCommonAncestor.test.ts index b9b7f9c37b43..3bc322112332 100644 --- a/packages/fork-choice/test/unit/protoArray/getCommonAncestor.test.ts +++ b/packages/fork-choice/test/unit/protoArray/getCommonAncestor.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {ProtoArray, ExecutionStatus, DataAvailabilityStatus} from "../../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {DataAvailabilityStatus, ExecutionStatus, ProtoArray} from "../../../src/index.js"; describe("getCommonAncestor", () => { const blocks: {slot: number; root: string; parent: string}[] = [ diff --git a/packages/fork-choice/test/unit/protoArray/protoArray.test.ts b/packages/fork-choice/test/unit/protoArray/protoArray.test.ts index 92dfc61d61b2..5e87504dc455 100644 --- a/packages/fork-choice/test/unit/protoArray/protoArray.test.ts +++ b/packages/fork-choice/test/unit/protoArray/protoArray.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; import {RootHex} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; -import {ProtoArray, ExecutionStatus, DataAvailabilityStatus} from "../../../src/index.js"; +import {DataAvailabilityStatus, ExecutionStatus, ProtoArray} from "../../../src/index.js"; describe("ProtoArray", () => { it("finalized descendant", () => { diff --git a/packages/light-client/src/index.ts b/packages/light-client/src/index.ts index 098ea18adc31..7dd4601ab837 100644 --- a/packages/light-client/src/index.ts +++ b/packages/light-client/src/index.ts @@ -1,4 +1,4 @@ -import mitt from "mitt"; +import {BeaconConfig, ChainForkConfig, createBeaconConfig} from "@lodestar/config"; import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD} from "@lodestar/params"; import { LightClientBootstrap, @@ -6,22 +6,22 @@ import { LightClientHeader, LightClientOptimisticUpdate, LightClientUpdate, - phase0, RootHex, Slot, SyncPeriod, + phase0, } from "@lodestar/types"; -import {createBeaconConfig, BeaconConfig, ChainForkConfig} from "@lodestar/config"; import {fromHex, isErrorAborted, sleep, toRootHex} from "@lodestar/utils"; -import {getCurrentSlot, slotWithFutureTolerance, timeUntilNextEpoch} from "./utils/clock.js"; -import {chunkifyInclusiveRange} from "./utils/chunkify.js"; +import mitt from "mitt"; import {LightclientEmitter, LightclientEvent} from "./events.js"; -import {getConsoleLogger, ILcLogger} from "./utils/logger.js"; -import {computeSyncPeriodAtEpoch, computeSyncPeriodAtSlot, computeEpochAtSlot} from "./utils/clock.js"; import {LightclientSpec} from "./spec/index.js"; -import {validateLightClientBootstrap} from "./spec/validateLightClientBootstrap.js"; import {ProcessUpdateOpts} from "./spec/processLightClientUpdate.js"; +import {validateLightClientBootstrap} from "./spec/validateLightClientBootstrap.js"; import {LightClientTransport} from "./transport/interface.js"; +import {chunkifyInclusiveRange} from "./utils/chunkify.js"; +import {getCurrentSlot, slotWithFutureTolerance, timeUntilNextEpoch} from "./utils/clock.js"; +import {computeEpochAtSlot, computeSyncPeriodAtEpoch, computeSyncPeriodAtSlot} from "./utils/clock.js"; +import {ILcLogger, getConsoleLogger} from "./utils/logger.js"; // Re-export types export {LightclientEvent} from "./events.js"; @@ -327,8 +327,8 @@ export class Lightclient { } } +import * as transport from "./transport.js"; // To export these name spaces to the bundle JS import * as utils from "./utils.js"; import * as validation from "./validation.js"; -import * as transport from "./transport.js"; export {utils, validation, transport}; diff --git a/packages/light-client/src/spec/index.ts b/packages/light-client/src/spec/index.ts index 0934e15b1c17..ff4fe22b28b0 100644 --- a/packages/light-client/src/spec/index.ts +++ b/packages/light-client/src/spec/index.ts @@ -8,7 +8,7 @@ import { Slot, } from "@lodestar/types"; import {computeSyncPeriodAtSlot} from "../utils/index.js"; -import {getSyncCommitteeAtPeriod, processLightClientUpdate, ProcessUpdateOpts} from "./processLightClientUpdate.js"; +import {ProcessUpdateOpts, getSyncCommitteeAtPeriod, processLightClientUpdate} from "./processLightClientUpdate.js"; import {ILightClientStore, LightClientStore, LightClientStoreEvents} from "./store.js"; import {ZERO_FINALITY_BRANCH, ZERO_HEADER, ZERO_SYNC_COMMITTEE, getZeroSyncCommitteeBranch} from "./utils.js"; diff --git a/packages/light-client/src/spec/processLightClientUpdate.ts b/packages/light-client/src/spec/processLightClientUpdate.ts index 644a956ab4b0..1c5483b499ab 100644 --- a/packages/light-client/src/spec/processLightClientUpdate.ts +++ b/packages/light-client/src/spec/processLightClientUpdate.ts @@ -1,9 +1,9 @@ +import {ChainForkConfig} from "@lodestar/config"; import {SYNC_COMMITTEE_SIZE} from "@lodestar/params"; import {LightClientUpdate, Slot, SyncPeriod} from "@lodestar/types"; -import {ChainForkConfig} from "@lodestar/config"; import {pruneSetToMax} from "@lodestar/utils"; import {computeSyncPeriodAtSlot, deserializeSyncCommittee, sumBits} from "../utils/index.js"; -import {isBetterUpdate, LightClientUpdateSummary, toLightClientUpdateSummary} from "./isBetterUpdate.js"; +import {LightClientUpdateSummary, isBetterUpdate, toLightClientUpdateSummary} from "./isBetterUpdate.js"; import {ILightClientStore, MAX_SYNC_PERIODS_CACHE, SyncCommitteeFast} from "./store.js"; import {getSafetyThreshold, isSyncCommitteeUpdate} from "./utils.js"; import {validateLightClientUpdate} from "./validateLightClientUpdate.js"; diff --git a/packages/light-client/src/spec/utils.ts b/packages/light-client/src/spec/utils.ts index 36bc7098fcc5..cd0c03fd5b0d 100644 --- a/packages/light-client/src/spec/utils.ts +++ b/packages/light-client/src/spec/utils.ts @@ -1,30 +1,30 @@ import {BitArray, byteArrayEquals} from "@chainsafe/ssz"; +import {ChainForkConfig} from "@lodestar/config"; import { - FINALIZED_ROOT_DEPTH, - NEXT_SYNC_COMMITTEE_DEPTH, - ForkSeq, - ForkName, BLOCK_BODY_EXECUTION_PAYLOAD_DEPTH as EXECUTION_PAYLOAD_DEPTH, BLOCK_BODY_EXECUTION_PAYLOAD_INDEX as EXECUTION_PAYLOAD_INDEX, + FINALIZED_ROOT_DEPTH, + FINALIZED_ROOT_DEPTH_ELECTRA, + ForkName, + ForkSeq, + NEXT_SYNC_COMMITTEE_DEPTH, NEXT_SYNC_COMMITTEE_DEPTH_ELECTRA, isForkPostElectra, - FINALIZED_ROOT_DEPTH_ELECTRA, } from "@lodestar/params"; import { - ssz, - Slot, + BeaconBlockHeader, LightClientFinalityUpdate, LightClientHeader, LightClientOptimisticUpdate, LightClientUpdate, - BeaconBlockHeader, + Slot, SyncCommittee, isElectraLightClientUpdate, + ssz, } from "@lodestar/types"; -import {ChainForkConfig} from "@lodestar/config"; -import {isValidMerkleBranch, computeEpochAtSlot, computeSyncPeriodAtSlot} from "../utils/index.js"; +import {computeEpochAtSlot, computeSyncPeriodAtSlot, isValidMerkleBranch} from "../utils/index.js"; import {normalizeMerkleBranch} from "../utils/normalizeMerkleBranch.js"; import {LightClientStore} from "./store.js"; diff --git a/packages/light-client/src/spec/validateLightClientBootstrap.ts b/packages/light-client/src/spec/validateLightClientBootstrap.ts index 2eafea0791f0..79c1f7a68fff 100644 --- a/packages/light-client/src/spec/validateLightClientBootstrap.ts +++ b/packages/light-client/src/spec/validateLightClientBootstrap.ts @@ -1,8 +1,8 @@ import {byteArrayEquals} from "@chainsafe/ssz"; -import {LightClientBootstrap, Root, ssz} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; -import {toHex} from "@lodestar/utils"; import {isForkPostElectra} from "@lodestar/params"; +import {LightClientBootstrap, Root, ssz} from "@lodestar/types"; +import {toHex} from "@lodestar/utils"; import {isValidMerkleBranch} from "../utils/verifyMerkleBranch.js"; import {isValidLightClientHeader} from "./utils.js"; diff --git a/packages/light-client/src/spec/validateLightClientUpdate.ts b/packages/light-client/src/spec/validateLightClientUpdate.ts index 9a5ea1985f16..ce2791f1a9da 100644 --- a/packages/light-client/src/spec/validateLightClientUpdate.ts +++ b/packages/light-client/src/spec/validateLightClientUpdate.ts @@ -1,32 +1,32 @@ import bls from "@chainsafe/bls"; import type {PublicKey, Signature} from "@chainsafe/bls/types"; -import {LightClientUpdate, Root, isElectraLightClientUpdate, ssz} from "@lodestar/types"; import {ChainForkConfig} from "@lodestar/config"; import { - FINALIZED_ROOT_INDEX, - FINALIZED_ROOT_DEPTH, - NEXT_SYNC_COMMITTEE_DEPTH, - MIN_SYNC_COMMITTEE_PARTICIPANTS, DOMAIN_SYNC_COMMITTEE, + FINALIZED_ROOT_DEPTH, + FINALIZED_ROOT_DEPTH_ELECTRA, + FINALIZED_ROOT_INDEX, + FINALIZED_ROOT_INDEX_ELECTRA, GENESIS_SLOT, + MIN_SYNC_COMMITTEE_PARTICIPANTS, + NEXT_SYNC_COMMITTEE_DEPTH, NEXT_SYNC_COMMITTEE_DEPTH_ELECTRA, - NEXT_SYNC_COMMITTEE_INDEX_ELECTRA, NEXT_SYNC_COMMITTEE_INDEX, - FINALIZED_ROOT_DEPTH_ELECTRA, - FINALIZED_ROOT_INDEX_ELECTRA, + NEXT_SYNC_COMMITTEE_INDEX_ELECTRA, } from "@lodestar/params"; -import {getParticipantPubkeys, sumBits} from "../utils/utils.js"; -import {isValidMerkleBranch} from "../utils/index.js"; +import {LightClientUpdate, Root, isElectraLightClientUpdate, ssz} from "@lodestar/types"; import {SyncCommitteeFast} from "../types.js"; +import {isValidMerkleBranch} from "../utils/index.js"; +import {getParticipantPubkeys, sumBits} from "../utils/utils.js"; +import {ILightClientStore} from "./store.js"; import { + ZERO_HASH, isFinalityUpdate, isSyncCommitteeUpdate, + isValidLightClientHeader, isZeroedHeader, isZeroedSyncCommittee, - ZERO_HASH, - isValidLightClientHeader, } from "./utils.js"; -import {ILightClientStore} from "./store.js"; export function validateLightClientUpdate( config: ChainForkConfig, diff --git a/packages/light-client/src/transport/interface.ts b/packages/light-client/src/transport/interface.ts index dc9c697c00be..816336a6fa04 100644 --- a/packages/light-client/src/transport/interface.ts +++ b/packages/light-client/src/transport/interface.ts @@ -1,3 +1,4 @@ +import {ForkName} from "@lodestar/params"; import { LightClientBootstrap, LightClientFinalityUpdate, @@ -5,7 +6,6 @@ import { LightClientUpdate, SyncPeriod, } from "@lodestar/types"; -import {ForkName} from "@lodestar/params"; export interface LightClientTransport { getUpdates( diff --git a/packages/light-client/src/transport/rest.ts b/packages/light-client/src/transport/rest.ts index c260e1aaeee3..aaffa090ade0 100644 --- a/packages/light-client/src/transport/rest.ts +++ b/packages/light-client/src/transport/rest.ts @@ -1,4 +1,5 @@ -import mitt from "mitt"; +import {type ApiClient, routes} from "@lodestar/api"; +import {type ForkName} from "@lodestar/params"; import { LightClientBootstrap, LightClientFinalityUpdate, @@ -6,8 +7,7 @@ import { LightClientUpdate, type SyncPeriod, } from "@lodestar/types"; -import {type ApiClient, routes} from "@lodestar/api"; -import {type ForkName} from "@lodestar/params"; +import mitt from "mitt"; import {MittEmitter} from "../events.js"; import {type LightClientTransport} from "./interface.js"; diff --git a/packages/light-client/src/utils/api.ts b/packages/light-client/src/utils/api.ts index 6ccb187052e1..31846270ca40 100644 --- a/packages/light-client/src/utils/api.ts +++ b/packages/light-client/src/utils/api.ts @@ -1,4 +1,4 @@ -import {getClient, ApiClient, ApiRequestInit} from "@lodestar/api"; +import {ApiClient, ApiRequestInit, getClient} from "@lodestar/api"; import {ChainForkConfig, createChainForkConfig} from "@lodestar/config"; import {NetworkName, networksChainConfig} from "@lodestar/config/networks"; diff --git a/packages/light-client/src/utils/domain.ts b/packages/light-client/src/utils/domain.ts index 90923ed8c9fc..d9bef6bb511c 100644 --- a/packages/light-client/src/utils/domain.ts +++ b/packages/light-client/src/utils/domain.ts @@ -1,7 +1,7 @@ // Only used by processDeposit + lightclient import {Type} from "@chainsafe/ssz"; -import {Epoch, Version, Root, DomainType, phase0, ssz, Domain} from "@lodestar/types"; +import {Domain, DomainType, Epoch, Root, Version, phase0, ssz} from "@lodestar/types"; /** * Return the domain for the [[domainType]] and [[forkVersion]]. diff --git a/packages/light-client/src/utils/utils.ts b/packages/light-client/src/utils/utils.ts index 5a298d81d37b..a4a697f0420d 100644 --- a/packages/light-client/src/utils/utils.ts +++ b/packages/light-client/src/utils/utils.ts @@ -2,7 +2,7 @@ import bls from "@chainsafe/bls"; import type {PublicKey} from "@chainsafe/bls/types"; import {BitArray} from "@chainsafe/ssz"; import {ApiClient} from "@lodestar/api"; -import {altair, Bytes32, Root, ssz} from "@lodestar/types"; +import {Bytes32, Root, altair, ssz} from "@lodestar/types"; import {BeaconBlockHeader} from "@lodestar/types/phase0"; import {GenesisData} from "../index.js"; import {SyncCommitteeFast} from "../types.js"; diff --git a/packages/light-client/src/utils/verifyMerkleBranch.ts b/packages/light-client/src/utils/verifyMerkleBranch.ts index 87b1d660eb32..a9a5b8643783 100644 --- a/packages/light-client/src/utils/verifyMerkleBranch.ts +++ b/packages/light-client/src/utils/verifyMerkleBranch.ts @@ -1,5 +1,5 @@ -import {byteArrayEquals} from "@chainsafe/ssz"; import {hasher} from "@chainsafe/persistent-merkle-tree"; +import {byteArrayEquals} from "@chainsafe/ssz"; export const SYNC_COMMITTEES_DEPTH = 4; export const SYNC_COMMITTEES_INDEX = 11; diff --git a/packages/light-client/src/validation.ts b/packages/light-client/src/validation.ts index c756d612f3e7..22cbf700ed16 100644 --- a/packages/light-client/src/validation.ts +++ b/packages/light-client/src/validation.ts @@ -1,30 +1,30 @@ import bls from "@chainsafe/bls"; import type {PublicKey, Signature} from "@chainsafe/bls/types"; +import {BeaconConfig} from "@lodestar/config"; +import { + DOMAIN_SYNC_COMMITTEE, + FINALIZED_ROOT_DEPTH, + FINALIZED_ROOT_DEPTH_ELECTRA, + FINALIZED_ROOT_INDEX, + MIN_SYNC_COMMITTEE_PARTICIPANTS, + NEXT_SYNC_COMMITTEE_DEPTH, + NEXT_SYNC_COMMITTEE_DEPTH_ELECTRA, + NEXT_SYNC_COMMITTEE_INDEX, + NEXT_SYNC_COMMITTEE_INDEX_ELECTRA, +} from "@lodestar/params"; import { - altair, - isElectraLightClientUpdate, LightClientFinalityUpdate, LightClientUpdate, Root, Slot, + altair, + isElectraLightClientUpdate, ssz, } from "@lodestar/types"; -import { - FINALIZED_ROOT_INDEX, - FINALIZED_ROOT_DEPTH, - NEXT_SYNC_COMMITTEE_INDEX, - NEXT_SYNC_COMMITTEE_DEPTH, - MIN_SYNC_COMMITTEE_PARTICIPANTS, - DOMAIN_SYNC_COMMITTEE, - NEXT_SYNC_COMMITTEE_DEPTH_ELECTRA, - FINALIZED_ROOT_DEPTH_ELECTRA, - NEXT_SYNC_COMMITTEE_INDEX_ELECTRA, -} from "@lodestar/params"; -import {BeaconConfig} from "@lodestar/config"; -import {isValidMerkleBranch} from "./utils/verifyMerkleBranch.js"; -import {assertZeroHashes, getParticipantPubkeys, isEmptyHeader} from "./utils/utils.js"; import {SyncCommitteeFast} from "./types.js"; import {computeSyncPeriodAtSlot} from "./utils/clock.js"; +import {assertZeroHashes, getParticipantPubkeys, isEmptyHeader} from "./utils/utils.js"; +import {isValidMerkleBranch} from "./utils/verifyMerkleBranch.js"; /** * diff --git a/packages/light-client/test/mocks/BeaconChainLcMock.ts b/packages/light-client/test/mocks/BeaconChainLcMock.ts index b6813662649e..f08cb55e808c 100644 --- a/packages/light-client/test/mocks/BeaconChainLcMock.ts +++ b/packages/light-client/test/mocks/BeaconChainLcMock.ts @@ -1,6 +1,6 @@ import {toHexString} from "@chainsafe/ssz"; import {BeaconStateAltair} from "@lodestar/state-transition"; -import {altair, Root, ssz} from "@lodestar/types"; +import {Root, altair, ssz} from "@lodestar/types"; import {IBeaconChainLc} from "../utils/prepareUpdateNaive.js"; /** diff --git a/packages/light-client/test/mocks/LightclientServerApiMock.ts b/packages/light-client/test/mocks/LightclientServerApiMock.ts index faf33ad260c8..ce23d785183a 100644 --- a/packages/light-client/test/mocks/LightclientServerApiMock.ts +++ b/packages/light-client/test/mocks/LightclientServerApiMock.ts @@ -1,11 +1,11 @@ -import {concat} from "uint8arrays/concat"; import {digest} from "@chainsafe/as-sha256"; -import {CompactMultiProof, createProof, ProofType} from "@chainsafe/persistent-merkle-tree"; +import {CompactMultiProof, ProofType, createProof} from "@chainsafe/persistent-merkle-tree"; import {routes} from "@lodestar/api"; import {ApplicationMethods} from "@lodestar/api/server"; -import {altair, RootHex, SyncPeriod} from "@lodestar/types"; -import {notNullish} from "@lodestar/utils"; import {ForkName} from "@lodestar/params"; +import {RootHex, SyncPeriod, altair} from "@lodestar/types"; +import {notNullish} from "@lodestar/utils"; +import {concat} from "uint8arrays/concat"; import {BeaconStateAltair} from "../utils/types.js"; type ProofApi = ApplicationMethods; diff --git a/packages/light-client/test/unit/isValidLightClientHeader.test.ts b/packages/light-client/test/unit/isValidLightClientHeader.test.ts index 2bbbd1250961..1782f1853296 100644 --- a/packages/light-client/test/unit/isValidLightClientHeader.test.ts +++ b/packages/light-client/test/unit/isValidLightClientHeader.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; import {fromHexString} from "@chainsafe/ssz"; -import {LightClientHeader, ssz} from "@lodestar/types"; import {createBeaconConfig, createChainForkConfig, defaultChainConfig} from "@lodestar/config"; +import {LightClientHeader, ssz} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; import {isValidLightClientHeader} from "../../src/spec/utils.js"; describe("isValidLightClientHeader", () => { diff --git a/packages/light-client/test/unit/sync.node.test.ts b/packages/light-client/test/unit/sync.node.test.ts index 52afd05760d7..f373b006584f 100644 --- a/packages/light-client/test/unit/sync.node.test.ts +++ b/packages/light-client/test/unit/sync.node.test.ts @@ -1,27 +1,27 @@ -import {describe, it, expect, afterEach, vi} from "vitest"; -import {JsonPath, toHexString} from "@chainsafe/ssz"; import {CompactMultiProof, computeDescriptor} from "@chainsafe/persistent-merkle-tree"; +import {JsonPath, toHexString} from "@chainsafe/ssz"; +import {ApiClient, getClient, routes} from "@lodestar/api"; +import {ChainConfig, createBeaconConfig} from "@lodestar/config"; +import {chainConfig as chainConfigDef} from "@lodestar/config/default"; import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH} from "@lodestar/params"; import {BeaconStateAllForks, BeaconStateAltair} from "@lodestar/state-transition"; import {altair, ssz} from "@lodestar/types"; -import {routes, getClient, ApiClient} from "@lodestar/api"; -import {chainConfig as chainConfigDef} from "@lodestar/config/default"; -import {createBeaconConfig, ChainConfig} from "@lodestar/config"; +import {afterEach, describe, expect, it, vi} from "vitest"; import {Lightclient, LightclientEvent} from "../../src/index.js"; -import {LightclientServerApiMock, ProofServerApiMock} from "../mocks/LightclientServerApiMock.js"; +import {LightClientRestTransport} from "../../src/transport/rest.js"; +import {computeSyncPeriodAtSlot} from "../../src/utils/clock.js"; import {EventsServerApiMock} from "../mocks/EventsServerApiMock.js"; +import {LightclientServerApiMock, ProofServerApiMock} from "../mocks/LightclientServerApiMock.js"; +import {ServerOpts, startServer} from "../utils/server.js"; import { - computeLightclientUpdate, + committeeUpdateToLatestFinalizedHeadUpdate, + committeeUpdateToLatestHeadUpdate, computeLightClientSnapshot, + computeLightclientUpdate, getInteropSyncCommittee, - testLogger, - committeeUpdateToLatestHeadUpdate, - committeeUpdateToLatestFinalizedHeadUpdate, lastInMap, + testLogger, } from "../utils/utils.js"; -import {startServer, ServerOpts} from "../utils/server.js"; -import {computeSyncPeriodAtSlot} from "../../src/utils/clock.js"; -import {LightClientRestTransport} from "../../src/transport/rest.js"; const SOME_HASH = Buffer.alloc(32, 0xff); diff --git a/packages/light-client/test/unit/syncInMemory.test.ts b/packages/light-client/test/unit/syncInMemory.test.ts index 6118a1b4e61a..3f3b04cc7baf 100644 --- a/packages/light-client/test/unit/syncInMemory.test.ts +++ b/packages/light-client/test/unit/syncInMemory.test.ts @@ -1,14 +1,14 @@ -import {describe, it, expect, beforeAll, vi} from "vitest"; import bls from "@chainsafe/bls"; import {createBeaconConfig} from "@lodestar/config"; import {chainConfig} from "@lodestar/config/default"; import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH} from "@lodestar/params"; -import {altair, ssz, SyncPeriod} from "@lodestar/types"; +import {SyncPeriod, altair, ssz} from "@lodestar/types"; +import {beforeAll, describe, expect, it, vi} from "vitest"; import {LightClientStoreFast} from "../../src/types.js"; import {BeaconChainLcMock} from "../mocks/BeaconChainLcMock.js"; import {processLightClientUpdate} from "../utils/naive/update.js"; import {IBeaconChainLc, prepareUpdateNaive} from "../utils/prepareUpdateNaive.js"; -import {getInteropSyncCommittee, getSyncAggregateSigningRoot, SyncCommitteeKeys} from "../utils/utils.js"; +import {SyncCommitteeKeys, getInteropSyncCommittee, getSyncAggregateSigningRoot} from "../utils/utils.js"; function getSyncCommittee( syncCommitteesKeys: Map, diff --git a/packages/light-client/test/unit/utils.test.ts b/packages/light-client/test/unit/utils.test.ts index 9913c6c462a4..18df5aee076a 100644 --- a/packages/light-client/test/unit/utils.test.ts +++ b/packages/light-client/test/unit/utils.test.ts @@ -1,8 +1,8 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; +import {ZERO_HASH} from "../../src/spec/utils.js"; +import {normalizeMerkleBranch} from "../../src/utils/normalizeMerkleBranch.js"; import {isValidMerkleBranch} from "../../src/utils/verifyMerkleBranch.js"; import {computeMerkleBranch} from "../utils/utils.js"; -import {normalizeMerkleBranch} from "../../src/utils/normalizeMerkleBranch.js"; -import {ZERO_HASH} from "../../src/spec/utils.js"; describe("utils", () => { it("constructMerkleBranch", () => { diff --git a/packages/light-client/test/unit/utils/chunkify.test.ts b/packages/light-client/test/unit/utils/chunkify.test.ts index 297637fd70b0..585dce5c670e 100644 --- a/packages/light-client/test/unit/utils/chunkify.test.ts +++ b/packages/light-client/test/unit/utils/chunkify.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {chunkifyInclusiveRange} from "../../../src/utils/chunkify.js"; describe("utils / chunkifyInclusiveRange", () => { diff --git a/packages/light-client/test/unit/validation.test.ts b/packages/light-client/test/unit/validation.test.ts index 6ed3b714a690..222277993216 100644 --- a/packages/light-client/test/unit/validation.test.ts +++ b/packages/light-client/test/unit/validation.test.ts @@ -1,9 +1,7 @@ -import {describe, it, expect, beforeAll, vi} from "vitest"; import bls from "@chainsafe/bls"; import {Tree} from "@chainsafe/persistent-merkle-tree"; -import {altair, ssz} from "@lodestar/types"; -import {chainConfig} from "@lodestar/config/default"; import {createBeaconConfig} from "@lodestar/config"; +import {chainConfig} from "@lodestar/config/default"; import { EPOCHS_PER_SYNC_COMMITTEE_PERIOD, FINALIZED_ROOT_GINDEX, @@ -11,8 +9,10 @@ import { SLOTS_PER_EPOCH, SYNC_COMMITTEE_SIZE, } from "@lodestar/params"; -import {assertValidLightClientUpdate} from "../../src/validation.js"; +import {altair, ssz} from "@lodestar/types"; +import {beforeAll, describe, expect, it, vi} from "vitest"; import {LightClientSnapshotFast, SyncCommitteeFast} from "../../src/types.js"; +import {assertValidLightClientUpdate} from "../../src/validation.js"; import {defaultBeaconBlockHeader, getSyncAggregateSigningRoot, signAndAggregate} from "../utils/utils.js"; describe("validation", () => { diff --git a/packages/light-client/test/unit/webEsmBundle.browser.test.ts b/packages/light-client/test/unit/webEsmBundle.browser.test.ts index defc421d7071..9940342e28b2 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 */ -import {expect, describe, it, vi, beforeAll} from "vitest"; import {sleep} from "@lodestar/utils"; -import {Lightclient, LightclientEvent, utils, transport} from "../../dist/lightclient.min.mjs"; +/* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call */ +import {beforeAll, describe, expect, it, vi} from "vitest"; +import {Lightclient, LightclientEvent, transport, utils} from "../../dist/lightclient.min.mjs"; describe("web bundle for lightclient", () => { vi.setConfig({testTimeout: 20_000}); diff --git a/packages/light-client/test/utils/naive/update.ts b/packages/light-client/test/utils/naive/update.ts index b2e0ecf47a8a..01eaf35e1ad8 100644 --- a/packages/light-client/test/utils/naive/update.ts +++ b/packages/light-client/test/utils/naive/update.ts @@ -1,10 +1,10 @@ -import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH} from "@lodestar/params"; -import {altair, Slot} from "@lodestar/types"; import {BeaconConfig} from "@lodestar/config"; +import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {Slot, altair} from "@lodestar/types"; import {LightClientSnapshotFast, LightClientStoreFast} from "../../../src/types.js"; -import {assertValidLightClientUpdate} from "../../../src/validation.js"; -import {deserializeSyncCommittee, isEmptyHeader, sumBits} from "../../../src/utils/utils.js"; import {computeSyncPeriodAtSlot} from "../../../src/utils/clock.js"; +import {deserializeSyncCommittee, isEmptyHeader, sumBits} from "../../../src/utils/utils.js"; +import {assertValidLightClientUpdate} from "../../../src/validation.js"; // // A lightclient has two types of syncing: diff --git a/packages/light-client/test/utils/prepareUpdateNaive.ts b/packages/light-client/test/utils/prepareUpdateNaive.ts index 3d0653c97263..17900ef7df56 100644 --- a/packages/light-client/test/utils/prepareUpdateNaive.ts +++ b/packages/light-client/test/utils/prepareUpdateNaive.ts @@ -1,7 +1,7 @@ -import {CompositeViewDU} from "@chainsafe/ssz"; import {Tree} from "@chainsafe/persistent-merkle-tree"; -import {altair, Root, ssz} from "@lodestar/types"; +import {CompositeViewDU} from "@chainsafe/ssz"; import {FINALIZED_ROOT_GINDEX, NEXT_SYNC_COMMITTEE_GINDEX, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params"; +import {Root, altair, ssz} from "@lodestar/types"; export interface IBeaconChainLc { getBlockHeaderByRoot(blockRoot: Root): Promise; diff --git a/packages/light-client/test/utils/server.ts b/packages/light-client/test/utils/server.ts index 6cc55e03cee4..4c6f22e06a31 100644 --- a/packages/light-client/test/utils/server.ts +++ b/packages/light-client/test/utils/server.ts @@ -1,10 +1,10 @@ -import {parse as parseQueryString} from "qs"; -import {FastifyInstance, fastify} from "fastify"; import {fastifyCors} from "@fastify/cors"; import {Endpoints} from "@lodestar/api"; -import {ApplicationMethods, addSszContentTypeParser} from "@lodestar/api/server"; import {BeaconApiMethods, registerRoutes} from "@lodestar/api/beacon/server"; +import {ApplicationMethods, addSszContentTypeParser} from "@lodestar/api/server"; import {ChainForkConfig} from "@lodestar/config"; +import {FastifyInstance, fastify} from "fastify"; +import {parse as parseQueryString} from "qs"; export type ServerOpts = { port: number; diff --git a/packages/light-client/test/utils/utils.ts b/packages/light-client/test/utils/utils.ts index 8364bcc7fc85..f497bac0541e 100644 --- a/packages/light-client/test/utils/utils.ts +++ b/packages/light-client/test/utils/utils.ts @@ -1,6 +1,6 @@ import bls from "@chainsafe/bls"; import {PointFormat, PublicKey, SecretKey} from "@chainsafe/bls/types"; -import {hasher, Tree} from "@chainsafe/persistent-merkle-tree"; +import {Tree, hasher} from "@chainsafe/persistent-merkle-tree"; import {BitArray, fromHexString} from "@chainsafe/ssz"; import {BeaconConfig} from "@lodestar/config"; import { @@ -11,7 +11,7 @@ import { SLOTS_PER_EPOCH, SYNC_COMMITTEE_SIZE, } from "@lodestar/params"; -import {altair, LightClientBootstrap, phase0, Slot, ssz, SyncPeriod} from "@lodestar/types"; +import {LightClientBootstrap, Slot, SyncPeriod, altair, phase0, ssz} from "@lodestar/types"; import {SyncCommitteeFast} from "../../src/types.js"; import {computeSigningRoot} from "../../src/utils/domain.js"; import {getConsoleLogger} from "../../src/utils/logger.js"; diff --git a/packages/logger/src/browser.ts b/packages/logger/src/browser.ts index 7f4972111459..60e756079377 100644 --- a/packages/logger/src/browser.ts +++ b/packages/logger/src/browser.ts @@ -1,8 +1,8 @@ +import {LogLevel, Logger} from "@lodestar/utils"; import winston from "winston"; import Transport from "winston-transport"; -import {LogLevel, Logger} from "@lodestar/utils"; -import {createWinstonLogger} from "./winston.js"; import {LEVEL, MESSAGE, TimestampFormat, WinstonLogInfo} from "./interface.js"; +import {createWinstonLogger} from "./winston.js"; export type BrowserLoggerOpts = { /** diff --git a/packages/logger/src/interface.ts b/packages/logger/src/interface.ts index e3ba8483a458..30b219874248 100644 --- a/packages/logger/src/interface.ts +++ b/packages/logger/src/interface.ts @@ -1,5 +1,5 @@ +import {LogData, LogHandler, LogLevel, Logger} from "@lodestar/utils"; import {LEVEL, MESSAGE} from "triple-beam"; -import {LogLevel, Logger, LogHandler, LogData} from "@lodestar/utils"; export {LogLevel, LEVEL, MESSAGE}; export type {Logger, LogHandler, LogData}; diff --git a/packages/logger/src/node.ts b/packages/logger/src/node.ts index fcd9c535dd9e..21786f21c27c 100644 --- a/packages/logger/src/node.ts +++ b/packages/logger/src/node.ts @@ -1,11 +1,11 @@ import path from "node:path"; -import DailyRotateFile from "winston-daily-rotate-file"; -import TransportStream from "winston-transport"; // We want to keep `winston` export as it's more readable and easier to understand /* eslint-disable import/no-named-as-default-member */ import winston from "winston"; import type {Logger as Winston} from "winston"; -import {Logger, LogLevel, TimestampFormat} from "./interface.js"; +import DailyRotateFile from "winston-daily-rotate-file"; +import TransportStream from "winston-transport"; +import {LogLevel, Logger, TimestampFormat} from "./interface.js"; import {ConsoleDynamicLevel} from "./utils/consoleTransport.js"; import {WinstonLogger} from "./winston.js"; diff --git a/packages/logger/src/utils/format.ts b/packages/logger/src/utils/format.ts index 4e657c0040af..8688016b63c9 100644 --- a/packages/logger/src/utils/format.ts +++ b/packages/logger/src/utils/format.ts @@ -1,7 +1,7 @@ -import winston, {format} from "winston"; import {LodestarError, isEmptyObject} from "@lodestar/utils"; +import winston, {format} from "winston"; import {LoggerOptions, TimestampFormatCode} from "../interface.js"; -import {logCtxToJson, logCtxToString, LogData} from "./json.js"; +import {LogData, logCtxToJson, logCtxToString} from "./json.js"; import {formatEpochSlotTime} from "./timeFormat.js"; type Format = ReturnType; diff --git a/packages/logger/src/winston.ts b/packages/logger/src/winston.ts index b886894e6aba..184f27e31335 100644 --- a/packages/logger/src/winston.ts +++ b/packages/logger/src/winston.ts @@ -2,7 +2,7 @@ /* eslint-disable import/no-named-as-default-member */ import winston from "winston"; import type {Logger as Winston} from "winston"; -import {Logger, LoggerOptions, LogLevel, logLevelNum} from "./interface.js"; +import {LogLevel, Logger, LoggerOptions, logLevelNum} from "./interface.js"; import {getFormat} from "./utils/format.js"; import {LogData} from "./utils/json.js"; diff --git a/packages/logger/test/e2e/logger/workerLoggerHandler.ts b/packages/logger/test/e2e/logger/workerLoggerHandler.ts index ab2097171af0..07a2dd6d2287 100644 --- a/packages/logger/test/e2e/logger/workerLoggerHandler.ts +++ b/packages/logger/test/e2e/logger/workerLoggerHandler.ts @@ -1,5 +1,5 @@ import workerThreads from "node:worker_threads"; -import {spawn, Worker} from "@chainsafe/threads"; +import {Worker, spawn} from "@chainsafe/threads"; export type LoggerWorker = { log(data: string): void; diff --git a/packages/logger/test/e2e/logger/workerLogs.test.ts b/packages/logger/test/e2e/logger/workerLogs.test.ts index 01ede8f6e4ec..13b8247e7dc1 100644 --- a/packages/logger/test/e2e/logger/workerLogs.test.ts +++ b/packages/logger/test/e2e/logger/workerLogs.test.ts @@ -1,8 +1,8 @@ -import path from "node:path"; import fs from "node:fs"; +import path from "node:path"; import {fileURLToPath} from "node:url"; -import {describe, it, expect, vi, beforeEach, afterEach} from "vitest"; import {sleep} from "@lodestar/utils"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {LoggerWorker, getLoggerWorker} from "./workerLoggerHandler.js"; // Global variable __dirname no longer available in ES6 modules. diff --git a/packages/logger/test/unit/browser.test.ts b/packages/logger/test/unit/browser.test.ts index 591437450c2d..e415ef79b3be 100644 --- a/packages/logger/test/unit/browser.test.ts +++ b/packages/logger/test/unit/browser.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect} from "vitest"; -import {LogLevel} from "@lodestar/utils"; import {stubLoggerForConsole} from "@lodestar/test-utils/doubles"; +import {LogLevel} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; +import {getBrowserLogger} from "../../src/browser.js"; import {TimestampFormatCode, logFormats} from "../../src/index.js"; import {formatsTestCases} from "../fixtures/loggerFormats.js"; -import {getBrowserLogger} from "../../src/browser.js"; describe("browser logger", () => { describe("format and options", () => { diff --git a/packages/logger/test/unit/env.node.test.ts b/packages/logger/test/unit/env.node.test.ts index 4bd4df689adf..c1f39424eb0a 100644 --- a/packages/logger/test/unit/env.node.test.ts +++ b/packages/logger/test/unit/env.node.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect} from "vitest"; -import {LogLevel} from "@lodestar/utils"; import {stubLoggerForConsole} from "@lodestar/test-utils/doubles"; +import {LogLevel} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; +import {getEnvLogger} from "../../src/env.js"; import {TimestampFormatCode, logFormats} from "../../src/index.js"; import {formatsTestCases} from "../fixtures/loggerFormats.js"; -import {getEnvLogger} from "../../src/env.js"; describe("env logger", () => { describe("format and options", () => { diff --git a/packages/logger/test/unit/node.node.test.ts b/packages/logger/test/unit/node.node.test.ts index b7c882a1e3bd..998c7e42e2fb 100644 --- a/packages/logger/test/unit/node.node.test.ts +++ b/packages/logger/test/unit/node.node.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect, vi, afterEach, Mock} from "vitest"; import {LogLevel} from "@lodestar/utils"; +import {Mock, afterEach, describe, expect, it, vi} from "vitest"; import {TimestampFormatCode, logFormats} from "../../src/index.js"; import {getNodeLogger} from "../../src/node.js"; import {formatsTestCases} from "../fixtures/loggerFormats.js"; diff --git a/packages/logger/test/unit/utils/json.test.ts b/packages/logger/test/unit/utils/json.test.ts index 7ca5604edf00..68e3f827e241 100644 --- a/packages/logger/test/unit/utils/json.test.ts +++ b/packages/logger/test/unit/utils/json.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; import {fromHexString, toHexString} from "@chainsafe/ssz"; import {LodestarError} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; import {logCtxToJson, logCtxToString} from "../../../src/utils/json.js"; describe("Json helper", () => { diff --git a/packages/logger/test/unit/utils/timeFormat.test.ts b/packages/logger/test/unit/utils/timeFormat.test.ts index fc374a0f6c7f..12c0ea97f167 100644 --- a/packages/logger/test/unit/utils/timeFormat.test.ts +++ b/packages/logger/test/unit/utils/timeFormat.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {formatEpochSlotTime} from "../../../src/utils/timeFormat.js"; describe("logger / util / formatEpochSlotTime", () => { diff --git a/packages/logger/test/unit/winston.node.test.ts b/packages/logger/test/unit/winston.node.test.ts index e4cfca2b041a..0db86a18fab9 100644 --- a/packages/logger/test/unit/winston.node.test.ts +++ b/packages/logger/test/unit/winston.node.test.ts @@ -1,7 +1,7 @@ import fs from "node:fs"; import path from "node:path"; -import {describe, it, expect, beforeAll, afterAll, afterEach, vi, Mock} from "vitest"; import {LogLevel} from "@lodestar/utils"; +import {Mock, afterAll, afterEach, beforeAll, describe, expect, it, vi} from "vitest"; import {TimestampFormatCode} from "../../src/index.js"; import {getNodeLogger} from "../../src/node.js"; import {readFileWhenExists} from "../utils/files.js"; diff --git a/packages/params/src/index.ts b/packages/params/src/index.ts index 544113e3f8e1..82ffa491daa3 100644 --- a/packages/params/src/index.ts +++ b/packages/params/src/index.ts @@ -1,9 +1,9 @@ import {PresetName} from "./presetName.js"; +import {presetStatus} from "./presetStatus.js"; +import {gnosisPreset} from "./presets/gnosis.js"; import {mainnetPreset} from "./presets/mainnet.js"; import {minimalPreset} from "./presets/minimal.js"; -import {gnosisPreset} from "./presets/gnosis.js"; -import {presetStatus} from "./presetStatus.js"; -import {userSelectedPreset, userOverrides} from "./setPreset.js"; +import {userOverrides, userSelectedPreset} from "./setPreset.js"; export type {BeaconPreset} from "./types.js"; export * from "./forkName.js"; diff --git a/packages/params/src/setPreset.ts b/packages/params/src/setPreset.ts index 61836d86a241..1f2a962a868b 100644 --- a/packages/params/src/setPreset.ts +++ b/packages/params/src/setPreset.ts @@ -1,7 +1,7 @@ +import {presetFromJson} from "./json.js"; import {PresetName} from "./presetName.js"; import {presetStatus} from "./presetStatus.js"; import {BeaconPreset} from "./types.js"; -import {presetFromJson} from "./json.js"; export {PresetName, presetFromJson}; diff --git a/packages/params/test/e2e/ensure-config-is-synced.test.ts b/packages/params/test/e2e/ensure-config-is-synced.test.ts index c54b0d4d44f8..ab34c16201c8 100644 --- a/packages/params/test/e2e/ensure-config-is-synced.test.ts +++ b/packages/params/test/e2e/ensure-config-is-synced.test.ts @@ -1,8 +1,8 @@ -import {describe, it, expect, vi} from "vitest"; import axios from "axios"; +import {describe, expect, it, vi} from "vitest"; +import {BeaconPreset, ForkName} from "../../src/index.js"; import {mainnetPreset} from "../../src/presets/mainnet.js"; import {minimalPreset} from "../../src/presets/minimal.js"; -import {ForkName, BeaconPreset} from "../../src/index.js"; import {loadConfigYaml} from "../yaml.js"; // Not e2e, but slow. Run with e2e tests diff --git a/packages/params/test/e2e/overridePreset.test.ts b/packages/params/test/e2e/overridePreset.test.ts index df7afbbf84da..aa609b5e8f75 100644 --- a/packages/params/test/e2e/overridePreset.test.ts +++ b/packages/params/test/e2e/overridePreset.test.ts @@ -1,8 +1,8 @@ -import path from "node:path"; -import util from "node:util"; import child from "node:child_process"; +import path from "node:path"; import {fileURLToPath} from "node:url"; -import {describe, it, expect, vi} from "vitest"; +import util from "node:util"; +import {describe, expect, it, vi} from "vitest"; const scriptNames = { ok: "overridePresetOk.ts", diff --git a/packages/params/test/e2e/overridePresetError.ts b/packages/params/test/e2e/overridePresetError.ts index 869f521d33b5..aeb544115c61 100644 --- a/packages/params/test/e2e/overridePresetError.ts +++ b/packages/params/test/e2e/overridePresetError.ts @@ -3,6 +3,6 @@ // 1. Import from not only @lodestar/params/setPreset will trigger an error import "../../lib/index.js"; -import {setActivePreset, PresetName} from "../../lib/setPreset.js"; +import {PresetName, setActivePreset} from "../../lib/setPreset.js"; // This line should throw setActivePreset(PresetName.minimal, {SLOTS_PER_EPOCH: 2}); diff --git a/packages/params/test/e2e/overridePresetOk.ts b/packages/params/test/e2e/overridePresetOk.ts index 8887155b5400..f82d9eb42eb3 100644 --- a/packages/params/test/e2e/overridePresetOk.ts +++ b/packages/params/test/e2e/overridePresetOk.ts @@ -5,7 +5,7 @@ import assert from "node:assert"; // It demonstrates how to properly change the Lodestar preset safely // 1. Import from @lodestar/params/setPreset only -import {setActivePreset, PresetName} from "../../src/setPreset.js"; +import {PresetName, setActivePreset} from "../../src/setPreset.js"; setActivePreset(PresetName.minimal, {SLOTS_PER_EPOCH: 2}); // 2. Import from any other @lodestar/params paths diff --git a/packages/params/test/e2e/setPreset.test.ts b/packages/params/test/e2e/setPreset.test.ts index 2108a4f23342..d75cf9861869 100644 --- a/packages/params/test/e2e/setPreset.test.ts +++ b/packages/params/test/e2e/setPreset.test.ts @@ -1,8 +1,8 @@ -import path from "node:path"; -import util from "node:util"; import child from "node:child_process"; +import path from "node:path"; import {fileURLToPath} from "node:url"; -import {describe, it, expect, vi} from "vitest"; +import util from "node:util"; +import {describe, expect, it, vi} from "vitest"; const scriptNames = { ok: "setPresetOk.ts", diff --git a/packages/params/test/e2e/setPresetError.ts b/packages/params/test/e2e/setPresetError.ts index debbb47f013d..362e7da5ce46 100644 --- a/packages/params/test/e2e/setPresetError.ts +++ b/packages/params/test/e2e/setPresetError.ts @@ -3,6 +3,6 @@ // 1. Import from not only @lodestar/params/setPreset will trigger an error import "../../lib/index.js"; -import {setActivePreset, PresetName} from "../../lib/setPreset.js"; +import {PresetName, setActivePreset} from "../../lib/setPreset.js"; // This line should throw setActivePreset(PresetName.minimal); diff --git a/packages/params/test/e2e/setPresetOk.ts b/packages/params/test/e2e/setPresetOk.ts index 5e76149b293a..a5b291db0047 100644 --- a/packages/params/test/e2e/setPresetOk.ts +++ b/packages/params/test/e2e/setPresetOk.ts @@ -3,7 +3,7 @@ // It demostrates how to properly change the Lodestar preset safely // 1. Import from @lodestar/params/setPreset only -import {setActivePreset, PresetName} from "../../src/setPreset.js"; +import {PresetName, setActivePreset} from "../../src/setPreset.js"; setActivePreset(PresetName.minimal); // 2. Import from any other @lodestar/params paths diff --git a/packages/params/test/unit/activePreset.test.ts b/packages/params/test/unit/activePreset.test.ts index 3aeee69672a1..7035053a9efc 100644 --- a/packages/params/test/unit/activePreset.test.ts +++ b/packages/params/test/unit/activePreset.test.ts @@ -1,8 +1,8 @@ -import {describe, it, expect, beforeAll} from "vitest"; +import {beforeAll, describe, expect, it} from "vitest"; +import {ACTIVE_PRESET, PresetName} from "../../src/index.js"; +import {gnosisPreset as gnosisParams} from "../../src/presets/gnosis.js"; import {mainnetPreset} from "../../src/presets/mainnet.js"; import {minimalPreset} from "../../src/presets/minimal.js"; -import {gnosisPreset as gnosisParams} from "../../src/presets/gnosis.js"; -import {ACTIVE_PRESET, PresetName} from "../../src/index.js"; import {setActivePreset} from "../../src/setPreset.js"; import {setActivePreset as setActivePresetLib} from "../../src/setPreset.js"; diff --git a/packages/params/test/unit/applicationDomains.test.ts b/packages/params/test/unit/applicationDomains.test.ts index f78e9aa22f07..8192de56dc1a 100644 --- a/packages/params/test/unit/applicationDomains.test.ts +++ b/packages/params/test/unit/applicationDomains.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {DOMAIN_APPLICATION_MASK, DOMAIN_APPLICATION_BUILDER} from "../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {DOMAIN_APPLICATION_BUILDER, DOMAIN_APPLICATION_MASK} from "../../src/index.js"; describe("validate application domains", () => { [{name: "builder domain", domain: DOMAIN_APPLICATION_BUILDER}].map(({name, domain}) => { diff --git a/packages/params/test/unit/forkName.test.ts b/packages/params/test/unit/forkName.test.ts index 4385c1e10d8a..70e3b6d38411 100644 --- a/packages/params/test/unit/forkName.test.ts +++ b/packages/params/test/unit/forkName.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { ForkName, forkAll, diff --git a/packages/params/test/yaml.ts b/packages/params/test/yaml.ts index f56016a4dbc0..a5eac0ed4320 100644 --- a/packages/params/test/yaml.ts +++ b/packages/params/test/yaml.ts @@ -1,4 +1,4 @@ -import {load, FAILSAFE_SCHEMA, Type} from "js-yaml"; +import {FAILSAFE_SCHEMA, Type, load} from "js-yaml"; export function loadConfigYaml(configYaml: string): Record { return load(configYaml, {schema}) as Record; diff --git a/packages/prover/src/cli/applyPreset.ts b/packages/prover/src/cli/applyPreset.ts index f0c3d83c7751..4c1cfbaf757c 100644 --- a/packages/prover/src/cli/applyPreset.ts +++ b/packages/prover/src/cli/applyPreset.ts @@ -21,7 +21,7 @@ setHasher(hasher); // set LODESTAR_PRESET manually every time. // IMPORTANT: only import Lodestar code here which does not import any other Lodestar libraries -import {setActivePreset, presetFromJson, PresetName} from "@lodestar/params/setPreset"; +import {PresetName, presetFromJson, setActivePreset} from "@lodestar/params/setPreset"; import {readFile} from "../utils/file.js"; const network = valueOfArg("network"); diff --git a/packages/prover/src/cli/cli.ts b/packages/prover/src/cli/cli.ts index 5e084a551536..fcd26b2c7b49 100644 --- a/packages/prover/src/cli/cli.ts +++ b/packages/prover/src/cli/cli.ts @@ -1,7 +1,7 @@ +import {registerCommandToYargs} from "@lodestar/utils"; // Must not use `* as yargs`, see https://github.com/yargs/yargs/issues/1131 import yargs from "yargs"; import {hideBin} from "yargs/helpers"; -import {registerCommandToYargs} from "@lodestar/utils"; import {getVersionData} from "../utils/version.js"; import {cmds, proverProxyStartCommand} from "./cmds/index.js"; import {globalOptions} from "./options.js"; diff --git a/packages/prover/src/cli/cmds/start/handler.ts b/packages/prover/src/cli/cmds/start/handler.ts index 92922f1a45a4..e5fa5d402dfd 100644 --- a/packages/prover/src/cli/cmds/start/handler.ts +++ b/packages/prover/src/cli/cmds/start/handler.ts @@ -1,8 +1,8 @@ import {ChainConfig, chainConfigFromJson} from "@lodestar/config"; import {readFile} from "../../../utils/file.js"; -import {createVerifiedExecutionProxy, VerifiedProxyOptions} from "../../../web3_proxy.js"; +import {VerifiedProxyOptions, createVerifiedExecutionProxy} from "../../../web3_proxy.js"; import {GlobalArgs, parseGlobalArgs} from "../../options.js"; -import {parseStartArgs, StartArgs} from "./options.js"; +import {StartArgs, parseStartArgs} from "./options.js"; /** * Runs a beacon node. diff --git a/packages/prover/src/cli/options.ts b/packages/prover/src/cli/options.ts index c37250070056..36ab331ceb78 100644 --- a/packages/prover/src/cli/options.ts +++ b/packages/prover/src/cli/options.ts @@ -1,6 +1,6 @@ import {NetworkName, networksChainConfig} from "@lodestar/config/networks"; -import {CliCommandOptions, LogLevel, LogLevels} from "@lodestar/utils"; import {ACTIVE_PRESET} from "@lodestar/params"; +import {CliCommandOptions, LogLevel, LogLevels} from "@lodestar/utils"; import {YargsError} from "../utils/errors.js"; export type GlobalArgs = { diff --git a/packages/prover/src/interfaces.ts b/packages/prover/src/interfaces.ts index 9a67b47ea3b3..c62d17e7f0f5 100644 --- a/packages/prover/src/interfaces.ts +++ b/packages/prover/src/interfaces.ts @@ -1,6 +1,6 @@ import {ChainConfig} from "@lodestar/config"; import {NetworkName} from "@lodestar/config/networks"; -import {Logger, LogLevel} from "@lodestar/utils"; +import {LogLevel, Logger} from "@lodestar/utils"; import {ProofProvider} from "./proof_provider/proof_provider.js"; import {JsonRpcRequest, JsonRpcRequestOrBatch, JsonRpcResponse, JsonRpcResponseOrBatch} from "./types.js"; import {ELRpcProvider} from "./utils/rpc_provider.js"; diff --git a/packages/prover/src/proof_provider/payload_store.ts b/packages/prover/src/proof_provider/payload_store.ts index c891cb994da1..4cf5dff36ac6 100644 --- a/packages/prover/src/proof_provider/payload_store.ts +++ b/packages/prover/src/proof_provider/payload_store.ts @@ -1,7 +1,7 @@ import {ApiClient} from "@lodestar/api"; -import {Logger} from "@lodestar/utils"; -import {ExecutionPayload, LightClientHeader} from "@lodestar/types"; import {ForkName} from "@lodestar/params"; +import {ExecutionPayload, LightClientHeader} from "@lodestar/types"; +import {Logger} from "@lodestar/utils"; import {MAX_PAYLOAD_HISTORY} from "../constants.js"; import {fetchBlock, getExecutionPayloadForBlockNumber} from "../utils/consensus.js"; import {bufferToHex, hexToNumber} from "../utils/conversion.js"; diff --git a/packages/prover/src/proof_provider/proof_provider.ts b/packages/prover/src/proof_provider/proof_provider.ts index 3a95b0e4e604..fbf025c377ad 100644 --- a/packages/prover/src/proof_provider/proof_provider.ts +++ b/packages/prover/src/proof_provider/proof_provider.ts @@ -4,8 +4,8 @@ import {NetworkName, networksChainConfig} from "@lodestar/config/networks"; import {Lightclient, LightclientEvent, RunStatusCode} from "@lodestar/light-client"; import {LightClientRestTransport} from "@lodestar/light-client/transport"; import {ForkName, isForkWithdrawals} from "@lodestar/params"; -import {Logger} from "@lodestar/utils"; import {ExecutionPayload, LightClientHeader} from "@lodestar/types"; +import {Logger} from "@lodestar/utils"; import {LCTransport, RootProviderInitOptions} from "../interfaces.js"; import {assertLightClient} from "../utils/assertion.js"; import { diff --git a/packages/prover/src/utils/consensus.ts b/packages/prover/src/utils/consensus.ts index ac8fd24d139f..d157bf1cf15c 100644 --- a/packages/prover/src/utils/consensus.ts +++ b/packages/prover/src/utils/consensus.ts @@ -1,6 +1,6 @@ import {ApiClient} from "@lodestar/api/beacon"; -import {Bytes32, ExecutionPayload, capella} from "@lodestar/types"; import {GenesisData, Lightclient} from "@lodestar/light-client"; +import {Bytes32, ExecutionPayload, capella} from "@lodestar/types"; import {Logger} from "@lodestar/utils"; import {MAX_PAYLOAD_HISTORY} from "../constants.js"; import {hexToBuffer} from "./conversion.js"; diff --git a/packages/prover/src/utils/evm.ts b/packages/prover/src/utils/evm.ts index 40950647b8f3..391dd302c7ad 100644 --- a/packages/prover/src/utils/evm.ts +++ b/packages/prover/src/utils/evm.ts @@ -1,19 +1,19 @@ +import {Block, BlockHeader} from "@ethereumjs/block"; import {Blockchain} from "@ethereumjs/blockchain"; -import {Account, Address} from "@ethereumjs/util"; -import {VM, RunTxResult} from "@ethereumjs/vm"; import {TransactionFactory} from "@ethereumjs/tx"; -import {Block, BlockHeader} from "@ethereumjs/block"; +import {Account, Address} from "@ethereumjs/util"; +import {RunTxResult, VM} from "@ethereumjs/vm"; import {NetworkName} from "@lodestar/config/networks"; -import {Logger} from "@lodestar/utils"; import {ExecutionPayload} from "@lodestar/types"; +import {Logger} from "@lodestar/utils"; import {ZERO_ADDRESS} from "../constants.js"; import {ProofProvider} from "../proof_provider/proof_provider.js"; import {ELBlock, ELProof, ELTransaction, JsonRpcVersion} from "../types.js"; import {bufferToHex, chunkIntoN, cleanObject, hexToBigInt, hexToBuffer, numberToHex, padLeft} from "./conversion.js"; import {getChainCommon, getTxType} from "./execution.js"; import {isValidResponse} from "./json_rpc.js"; -import {isNullish, isValidAccount, isValidCodeHash, isValidStorageKeys} from "./validation.js"; import {ELRpcProvider} from "./rpc_provider.js"; +import {isNullish, isValidAccount, isValidCodeHash, isValidStorageKeys} from "./validation.js"; export async function createVM({proofProvider}: {proofProvider: ProofProvider}): Promise { const common = getChainCommon(proofProvider.config.PRESET_BASE as string); diff --git a/packages/prover/src/utils/execution.ts b/packages/prover/src/utils/execution.ts index 91d5f8d625ff..8ce9d71857f3 100644 --- a/packages/prover/src/utils/execution.ts +++ b/packages/prover/src/utils/execution.ts @@ -1,8 +1,8 @@ import {Common, CustomChain, Hardfork} from "@ethereumjs/common"; import {ELApiParams, ELApiReturn, ELTransaction} from "../types.js"; import {isValidResponse} from "./json_rpc.js"; -import {isBlockNumber, isPresent} from "./validation.js"; import {ELRpcProvider} from "./rpc_provider.js"; +import {isBlockNumber, isPresent} from "./validation.js"; export type Optional = Omit & {[P in keyof T]?: T[P] | undefined}; diff --git a/packages/prover/src/utils/gitData/gitDataPath.ts b/packages/prover/src/utils/gitData/gitDataPath.ts index 1ad3104aafc6..b4c7f8c7c62c 100644 --- a/packages/prover/src/utils/gitData/gitDataPath.ts +++ b/packages/prover/src/utils/gitData/gitDataPath.ts @@ -1,5 +1,5 @@ -import path from "node:path"; import fs from "node:fs"; +import path from "node:path"; import {fileURLToPath} from "node:url"; // Global variable __dirname no longer available in ES6 modules. diff --git a/packages/prover/src/utils/gitData/index.ts b/packages/prover/src/utils/gitData/index.ts index 0720d39d9e30..c5681660f8ce 100644 --- a/packages/prover/src/utils/gitData/index.ts +++ b/packages/prover/src/utils/gitData/index.ts @@ -2,7 +2,7 @@ import {execSync} from "node:child_process"; // This file is created in the build step and is distributed through NPM // MUST be in sync with `-/gitDataPath.ts` and `package.json` files. -import {readGitDataFile, GitData} from "./gitDataPath.js"; +import {GitData, readGitDataFile} from "./gitDataPath.js"; /** Reads git data from a persisted file or local git data at build time. */ export function readAndGetGitData(): GitData { diff --git a/packages/prover/src/utils/json_rpc.ts b/packages/prover/src/utils/json_rpc.ts index 74727c198122..d0d2bc850fd0 100644 --- a/packages/prover/src/utils/json_rpc.ts +++ b/packages/prover/src/utils/json_rpc.ts @@ -1,17 +1,17 @@ import {Logger} from "@lodestar/logger"; import {VERIFICATION_FAILED_RESPONSE_CODE} from "../constants.js"; import { + JsonRpcBatchRequest, + JsonRpcBatchResponse, JsonRpcErrorPayload, JsonRpcNotificationPayload, - JsonRpcRequestPayload, JsonRpcRequest, + JsonRpcRequestOrBatch, + JsonRpcRequestPayload, JsonRpcResponse, + JsonRpcResponseOrBatch, JsonRpcResponseWithErrorPayload, JsonRpcResponseWithResultPayload, - JsonRpcResponseOrBatch, - JsonRpcBatchResponse, - JsonRpcRequestOrBatch, - JsonRpcBatchRequest, } from "../types.js"; import {isNullish} from "./validation.js"; diff --git a/packages/prover/src/utils/process.ts b/packages/prover/src/utils/process.ts index 75bb79516609..b8464edd7ac8 100644 --- a/packages/prover/src/utils/process.ts +++ b/packages/prover/src/utils/process.ts @@ -1,17 +1,17 @@ import {Logger} from "@lodestar/logger"; import {ELVerifiedRequestHandler} from "../interfaces.js"; import {ProofProvider} from "../proof_provider/proof_provider.js"; -import {JsonRpcRequestOrBatch, JsonRpcBatchRequest, JsonRpcResponseOrBatch, JsonRpcBatchResponse} from "../types.js"; +import {JsonRpcBatchRequest, JsonRpcBatchResponse, JsonRpcRequestOrBatch, JsonRpcResponseOrBatch} from "../types.js"; +import {eth_call} from "../verified_requests/eth_call.js"; +import {eth_estimateGas} from "../verified_requests/eth_estimateGas.js"; import {eth_getBalance} from "../verified_requests/eth_getBalance.js"; -import {eth_getTransactionCount} from "../verified_requests/eth_getTransactionCount.js"; import {eth_getBlockByHash} from "../verified_requests/eth_getBlockByHash.js"; import {eth_getBlockByNumber} from "../verified_requests/eth_getBlockByNumber.js"; import {eth_getCode} from "../verified_requests/eth_getCode.js"; -import {eth_call} from "../verified_requests/eth_call.js"; -import {eth_estimateGas} from "../verified_requests/eth_estimateGas.js"; +import {eth_getTransactionCount} from "../verified_requests/eth_getTransactionCount.js"; import {getResponseForRequest, isBatchRequest, isRequest} from "./json_rpc.js"; -import {isNullish} from "./validation.js"; import {ELRpcProvider} from "./rpc_provider.js"; +import {isNullish} from "./validation.js"; // biome-ignore lint/suspicious/noExplicitAny: export const verifiableMethodHandlers: Record> = { diff --git a/packages/prover/src/utils/validation.ts b/packages/prover/src/utils/validation.ts index 3adc37571db5..085798c875bc 100644 --- a/packages/prover/src/utils/validation.ts +++ b/packages/prover/src/utils/validation.ts @@ -2,10 +2,10 @@ import {Block} from "@ethereumjs/block"; import {RLP} from "@ethereumjs/rlp"; import {Trie} from "@ethereumjs/trie"; import {Account, KECCAK256_NULL_S} from "@ethereumjs/util"; -import {keccak256} from "ethereum-cryptography/keccak.js"; +import {ChainForkConfig} from "@lodestar/config"; import {Bytes32, ExecutionPayload} from "@lodestar/types"; import {Logger} from "@lodestar/utils"; -import {ChainForkConfig} from "@lodestar/config"; +import {keccak256} from "ethereum-cryptography/keccak.js"; import {ELBlock, ELProof, ELStorageProof, HexString} from "../types.js"; import {blockDataFromELBlock, bufferToHex, hexToBuffer, padLeft} from "./conversion.js"; import {getChainCommon} from "./execution.js"; diff --git a/packages/prover/src/utils/verification.ts b/packages/prover/src/utils/verification.ts index a468bf277eba..fb304bf34936 100644 --- a/packages/prover/src/utils/verification.ts +++ b/packages/prover/src/utils/verification.ts @@ -3,8 +3,8 @@ import {ProofProvider} from "../proof_provider/proof_provider.js"; import {ELBlock, ELProof, HexString, JsonRpcRequest} from "../types.js"; import {bufferToHex} from "./conversion.js"; import {getELBlock, getELCode, getELProof} from "./execution.js"; -import {isValidAccount, isValidBlock, isValidCodeHash, isValidStorageKeys} from "./validation.js"; import {ELRpcProvider} from "./rpc_provider.js"; +import {isValidAccount, isValidBlock, isValidCodeHash, isValidStorageKeys} from "./validation.js"; type VerificationResult = {data: T; valid: true} | {valid: false; data?: undefined}; diff --git a/packages/prover/src/verified_requests/eth_call.ts b/packages/prover/src/verified_requests/eth_call.ts index eea7ba146c3f..2b28f699fb5b 100644 --- a/packages/prover/src/verified_requests/eth_call.ts +++ b/packages/prover/src/verified_requests/eth_call.ts @@ -3,8 +3,8 @@ import {ELApiParams, ELApiReturn} from "../types.js"; import {bufferToHex} from "../utils/conversion.js"; import {createVM, executeVMCall, getVMWithState} from "../utils/evm.js"; import { - getResponseForRequest, getErrorResponseForRequestWithFailedVerification, + getResponseForRequest, getVerificationFailedMessage, } from "../utils/json_rpc.js"; diff --git a/packages/prover/src/verified_requests/eth_getBalance.ts b/packages/prover/src/verified_requests/eth_getBalance.ts index 0c03b23be788..c1e1749bebf8 100644 --- a/packages/prover/src/verified_requests/eth_getBalance.ts +++ b/packages/prover/src/verified_requests/eth_getBalance.ts @@ -1,10 +1,10 @@ import {ELVerifiedRequestHandler} from "../interfaces.js"; -import {verifyAccount} from "../utils/verification.js"; import { getErrorResponseForRequestWithFailedVerification, getResponseForRequest, getVerificationFailedMessage, } from "../utils/json_rpc.js"; +import {verifyAccount} from "../utils/verification.js"; export const eth_getBalance: ELVerifiedRequestHandler<[address: string, block?: number | string], string> = async ({ rpc, diff --git a/packages/prover/src/verified_requests/eth_getBlockByHash.ts b/packages/prover/src/verified_requests/eth_getBlockByHash.ts index 00a110c01e9a..b1374865aa34 100644 --- a/packages/prover/src/verified_requests/eth_getBlockByHash.ts +++ b/packages/prover/src/verified_requests/eth_getBlockByHash.ts @@ -1,11 +1,11 @@ import {ELVerifiedRequestHandler} from "../interfaces.js"; import {ELBlock} from "../types.js"; -import {verifyBlock} from "../utils/verification.js"; import { getErrorResponseForRequestWithFailedVerification, getResponseForRequest, getVerificationFailedMessage, } from "../utils/json_rpc.js"; +import {verifyBlock} from "../utils/verification.js"; export const eth_getBlockByHash: ELVerifiedRequestHandler<[block: string, hydrated: boolean], ELBlock> = async ({ rpc, diff --git a/packages/prover/src/verified_requests/eth_getBlockByNumber.ts b/packages/prover/src/verified_requests/eth_getBlockByNumber.ts index 23e0fa2ca863..c54c219be91f 100644 --- a/packages/prover/src/verified_requests/eth_getBlockByNumber.ts +++ b/packages/prover/src/verified_requests/eth_getBlockByNumber.ts @@ -1,11 +1,11 @@ import {ELVerifiedRequestHandler} from "../interfaces.js"; import {ELBlock} from "../types.js"; -import {verifyBlock} from "../utils/verification.js"; import { getErrorResponseForRequestWithFailedVerification, getResponseForRequest, getVerificationFailedMessage, } from "../utils/json_rpc.js"; +import {verifyBlock} from "../utils/verification.js"; export const eth_getBlockByNumber: ELVerifiedRequestHandler< [block: string | number, hydrated: boolean], diff --git a/packages/prover/src/verified_requests/eth_getCode.ts b/packages/prover/src/verified_requests/eth_getCode.ts index f94ae8c1c8bd..1132ec089b24 100644 --- a/packages/prover/src/verified_requests/eth_getCode.ts +++ b/packages/prover/src/verified_requests/eth_getCode.ts @@ -1,10 +1,10 @@ import {ELVerifiedRequestHandler} from "../interfaces.js"; -import {verifyAccount, verifyCode} from "../utils/verification.js"; import { getErrorResponseForRequestWithFailedVerification, getResponseForRequest, getVerificationFailedMessage, } from "../utils/json_rpc.js"; +import {verifyAccount, verifyCode} from "../utils/verification.js"; export const eth_getCode: ELVerifiedRequestHandler<[address: string, block?: number | string], string> = async ({ rpc, diff --git a/packages/prover/src/verified_requests/eth_getTransactionCount.ts b/packages/prover/src/verified_requests/eth_getTransactionCount.ts index aeef67e96e74..ceb7c0797a81 100644 --- a/packages/prover/src/verified_requests/eth_getTransactionCount.ts +++ b/packages/prover/src/verified_requests/eth_getTransactionCount.ts @@ -1,10 +1,10 @@ import {ELVerifiedRequestHandler} from "../interfaces.js"; -import {verifyAccount} from "../utils/verification.js"; import { - getResponseForRequest, getErrorResponseForRequestWithFailedVerification, + getResponseForRequest, getVerificationFailedMessage, } from "../utils/json_rpc.js"; +import {verifyAccount} from "../utils/verification.js"; export const eth_getTransactionCount: ELVerifiedRequestHandler< [address: string, block?: number | string], diff --git a/packages/prover/src/web3_provider.ts b/packages/prover/src/web3_provider.ts index b42c349d1017..a28d43fa0b7b 100644 --- a/packages/prover/src/web3_provider.ts +++ b/packages/prover/src/web3_provider.ts @@ -3,9 +3,9 @@ import {getBrowserLogger} from "@lodestar/logger/browser"; import {Logger} from "@lodestar/utils"; import {AnyWeb3Provider, ELRequestHandler, VerifiedExecutionInitOptions} from "./interfaces.js"; import {ProofProvider} from "./proof_provider/proof_provider.js"; +import {processAndVerifyRequest} from "./utils/process.js"; import {ELRpcProvider} from "./utils/rpc_provider.js"; import {Web3ProviderInspector} from "./web3_provider_inspector.js"; -import {processAndVerifyRequest} from "./utils/process.js"; export type Web3ProviderTypeHandler = ( provider: T, diff --git a/packages/prover/src/web3_provider_inspector.ts b/packages/prover/src/web3_provider_inspector.ts index 154a860d0922..4cbcb221fc64 100644 --- a/packages/prover/src/web3_provider_inspector.ts +++ b/packages/prover/src/web3_provider_inspector.ts @@ -1,10 +1,10 @@ import {Logger} from "@lodestar/logger"; import {AnyWeb3Provider, Web3ProviderType} from "./interfaces.js"; -import web3jsProviderType from "./provider_types/web3_js_provider_type.js"; -import ethersProviderType from "./provider_types/ethers_provider_type.js"; import eip1193ProviderType from "./provider_types/eip1193_provider_type.js"; +import ethersProviderType from "./provider_types/ethers_provider_type.js"; import legacyProviderType from "./provider_types/legacy_provider_type.js"; +import web3jsProviderType from "./provider_types/web3_js_provider_type.js"; export class Web3ProviderInspector { protected providerTypes: Web3ProviderType[] = []; diff --git a/packages/prover/src/web3_proxy.ts b/packages/prover/src/web3_proxy.ts index 273508852adf..d74eb1319e60 100644 --- a/packages/prover/src/web3_proxy.ts +++ b/packages/prover/src/web3_proxy.ts @@ -1,15 +1,15 @@ import http from "node:http"; import https from "node:https"; import url from "node:url"; -import httpProxy from "http-proxy"; -import {getNodeLogger} from "@lodestar/logger/node"; import {LogLevel} from "@lodestar/logger"; +import {getNodeLogger} from "@lodestar/logger/node"; +import httpProxy from "http-proxy"; import {ELRequestHandler, VerifiedExecutionInitOptions} from "./interfaces.js"; import {ProofProvider} from "./proof_provider/proof_provider.js"; import {JsonRpcRequestOrBatch, JsonRpcRequestPayload, JsonRpcResponseOrBatch} from "./types.js"; import {getResponseForRequest, isBatchRequest} from "./utils/json_rpc.js"; -import {fetchRequestPayload, fetchResponseBody} from "./utils/req_resp.js"; import {processAndVerifyRequest} from "./utils/process.js"; +import {fetchRequestPayload, fetchResponseBody} from "./utils/req_resp.js"; import {ELRpcProvider} from "./utils/rpc_provider.js"; export type VerifiedProxyOptions = Exclude, "mutateProvider" | "providerTypes"> & { diff --git a/packages/prover/test/e2e/cli/cmds/start.test.ts b/packages/prover/test/e2e/cli/cmds/start.test.ts index 75773ac02d36..ffdad63f1bd7 100644 --- a/packages/prover/test/e2e/cli/cmds/start.test.ts +++ b/packages/prover/test/e2e/cli/cmds/start.test.ts @@ -1,13 +1,13 @@ import childProcess from "node:child_process"; -import {writeFile, mkdir} from "node:fs/promises"; +import {mkdir, writeFile} from "node:fs/promises"; import path from "node:path"; -import {describe, it, expect, beforeAll, afterAll} from "vitest"; -import {Web3} from "web3"; +import {ChainConfig, chainConfigToJson} from "@lodestar/config"; import {runCliCommand, spawnCliCommand, stopChildProcess} from "@lodestar/test-utils"; import {sleep} from "@lodestar/utils"; -import {ChainConfig, chainConfigToJson} from "@lodestar/config"; +import {afterAll, beforeAll, describe, expect, it} from "vitest"; +import {Web3} from "web3"; import {getLodestarProverCli} from "../../../../src/cli/cli.js"; -import {rpcUrl, beaconUrl, proxyPort, proxyUrl, chainId, waitForCapellaFork, config} from "../../../utils/e2e_env.js"; +import {beaconUrl, chainId, config, proxyPort, proxyUrl, rpcUrl, waitForCapellaFork} from "../../../utils/e2e_env.js"; const cli = getLodestarProverCli(); diff --git a/packages/prover/test/e2e/web3_batch_request.test.ts b/packages/prover/test/e2e/web3_batch_request.test.ts index 6dae04a9c36d..ea265057ef8d 100644 --- a/packages/prover/test/e2e/web3_batch_request.test.ts +++ b/packages/prover/test/e2e/web3_batch_request.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect, beforeAll, vi} from "vitest"; +import {beforeAll, describe, expect, it, vi} from "vitest"; import {Web3} from "web3"; import {LCTransport} from "../../src/interfaces.js"; -import {createVerifiedExecutionProvider} from "../../src/web3_provider.js"; -import {rpcUrl, beaconUrl, config, waitForCapellaFork, minCapellaTimeMs} from "../utils/e2e_env.js"; import {getVerificationFailedMessage} from "../../src/utils/json_rpc.js"; +import {createVerifiedExecutionProvider} from "../../src/web3_provider.js"; +import {beaconUrl, config, minCapellaTimeMs, rpcUrl, waitForCapellaFork} from "../utils/e2e_env.js"; describe("web3_batch_requests", () => { vi.setConfig({hookTimeout: minCapellaTimeMs}); diff --git a/packages/prover/test/e2e/web3_provider.test.ts b/packages/prover/test/e2e/web3_provider.test.ts index edb3bb09e2fb..7f11a6ca1619 100644 --- a/packages/prover/test/e2e/web3_provider.test.ts +++ b/packages/prover/test/e2e/web3_provider.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect, beforeAll, vi} from "vitest"; -import {Web3} from "web3"; import {ethers} from "ethers"; +import {beforeAll, describe, expect, it, vi} from "vitest"; +import {Web3} from "web3"; import {LCTransport} from "../../src/interfaces.js"; import {createVerifiedExecutionProvider} from "../../src/web3_provider.js"; -import {waitForCapellaFork, minCapellaTimeMs, rpcUrl, beaconUrl, config} from "../utils/e2e_env.js"; +import {beaconUrl, config, minCapellaTimeMs, rpcUrl, waitForCapellaFork} from "../utils/e2e_env.js"; describe("web3_provider", () => { vi.setConfig({hookTimeout: minCapellaTimeMs}); diff --git a/packages/prover/test/mocks/request_handler.ts b/packages/prover/test/mocks/request_handler.ts index edde1e59a3fe..2b37cc134a36 100644 --- a/packages/prover/test/mocks/request_handler.ts +++ b/packages/prover/test/mocks/request_handler.ts @@ -1,10 +1,10 @@ -import {vi, expect} from "vitest"; -import {when} from "vitest-when"; -import deepmerge from "deepmerge"; -import {NetworkName} from "@lodestar/config/networks"; import {ForkConfig} from "@lodestar/config"; -import {PresetName} from "@lodestar/params"; +import {NetworkName} from "@lodestar/config/networks"; import {getEmptyLogger} from "@lodestar/logger/empty"; +import {PresetName} from "@lodestar/params"; +import deepmerge from "deepmerge"; +import {expect, vi} from "vitest"; +import {when} from "vitest-when"; import {ELVerifiedRequestHandlerOpts} from "../../src/interfaces.js"; import {ProofProvider} from "../../src/proof_provider/proof_provider.js"; import { @@ -18,8 +18,8 @@ import { JsonRpcResponseOrBatch, JsonRpcVersion, } from "../../src/types.js"; -import {isNullish} from "../../src/utils/validation.js"; import {isBatchRequest, mergeBatchReqResp} from "../../src/utils/json_rpc.js"; +import {isNullish} from "../../src/utils/validation.js"; type Writeable = { -readonly [K in keyof T]?: T[K] extends object ? Writeable : T[K]; diff --git a/packages/prover/test/unit/proof_provider/orderd_map.test.ts b/packages/prover/test/unit/proof_provider/orderd_map.test.ts index 309c4de71568..eadf76af8b59 100644 --- a/packages/prover/test/unit/proof_provider/orderd_map.test.ts +++ b/packages/prover/test/unit/proof_provider/orderd_map.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {OrderedMap} from "../../../src/proof_provider/ordered_map.js"; describe("proof_provider/ordered_map", () => { diff --git a/packages/prover/test/unit/proof_provider/payload_store.test.ts b/packages/prover/test/unit/proof_provider/payload_store.test.ts index 6bc1e4265205..76007f2a1e22 100644 --- a/packages/prover/test/unit/proof_provider/payload_store.test.ts +++ b/packages/prover/test/unit/proof_provider/payload_store.test.ts @@ -1,13 +1,13 @@ -import {describe, it, expect, beforeEach, vi, MockedObject} from "vitest"; -import {when} from "vitest-when"; import {ApiClient, ApiResponse, HttpStatusCode, routes} from "@lodestar/api"; -import {hash} from "@lodestar/utils"; import {Logger} from "@lodestar/logger"; +import {ForkName} from "@lodestar/params"; import {ExecutionPayload, SignedBeaconBlock, capella} from "@lodestar/types"; +import {hash} from "@lodestar/utils"; import {toHexString} from "@lodestar/utils"; -import {ForkName} from "@lodestar/params"; -import {PayloadStore} from "../../../src/proof_provider/payload_store.js"; +import {MockedObject, beforeEach, describe, expect, it, vi} from "vitest"; +import {when} from "vitest-when"; import {MAX_PAYLOAD_HISTORY} from "../../../src/constants.js"; +import {PayloadStore} from "../../../src/proof_provider/payload_store.js"; const slotNumber = 10; const createHash = (input: string): Uint8Array => hash(Buffer.from(input, "utf8")); diff --git a/packages/prover/test/unit/provider_types/ethers_provider_type.test.ts b/packages/prover/test/unit/provider_types/ethers_provider_type.test.ts index c24252d9548f..b35106d493cb 100644 --- a/packages/prover/test/unit/provider_types/ethers_provider_type.test.ts +++ b/packages/prover/test/unit/provider_types/ethers_provider_type.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {ethers} from "ethers"; +import {describe, expect, it} from "vitest"; import {Web3} from "web3"; import ethersProviderType from "../../../src/provider_types/ethers_provider_type.js"; diff --git a/packages/prover/test/unit/provider_types/legacy_provider_type.test.ts b/packages/prover/test/unit/provider_types/legacy_provider_type.test.ts index 37ffc18e58ab..bdb532788845 100644 --- a/packages/prover/test/unit/provider_types/legacy_provider_type.test.ts +++ b/packages/prover/test/unit/provider_types/legacy_provider_type.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {ethers} from "ethers"; +import {describe, expect, it} from "vitest"; import {Web3} from "web3"; import legacyProviderType from "../../../src/provider_types/legacy_provider_type.js"; diff --git a/packages/prover/test/unit/provider_types/web3js_provider_type.test.ts b/packages/prover/test/unit/provider_types/web3js_provider_type.test.ts index 54da395bca25..badb066c0bc1 100644 --- a/packages/prover/test/unit/provider_types/web3js_provider_type.test.ts +++ b/packages/prover/test/unit/provider_types/web3js_provider_type.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {ethers} from "ethers"; +import {describe, expect, it} from "vitest"; import {Web3} from "web3"; import web3jsProviderType from "../../../src/provider_types/web3_js_provider_type.js"; diff --git a/packages/prover/test/unit/utils/conversion.test.ts b/packages/prover/test/unit/utils/conversion.test.ts index ee9c16b9cb94..8b0c1476b5ac 100644 --- a/packages/prover/test/unit/utils/conversion.test.ts +++ b/packages/prover/test/unit/utils/conversion.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {chunkIntoN} from "../../../src/utils/conversion.js"; describe("utils/conversion", () => { diff --git a/packages/prover/test/unit/utils/execution.test.ts b/packages/prover/test/unit/utils/execution.test.ts index 9219b5ec0c03..5b9443c95bb4 100644 --- a/packages/prover/test/unit/utils/execution.test.ts +++ b/packages/prover/test/unit/utils/execution.test.ts @@ -1,11 +1,11 @@ -import {describe, it, expect} from "vitest"; -import deepmerge from "deepmerge"; import {getEnvLogger} from "@lodestar/logger/env"; +import deepmerge from "deepmerge"; +import {describe, expect, it} from "vitest"; import {ELProof, ELStorageProof} from "../../../src/types.js"; +import {hexToBuffer} from "../../../src/utils/conversion.js"; import {isValidAccount, isValidStorageKeys} from "../../../src/utils/validation.js"; import {invalidStorageProof, validStorageProof} from "../../fixtures/index.js"; import eoaProof from "../../fixtures/sepolia/eth_getBalance_eoa.json" assert {type: "json"}; -import {hexToBuffer} from "../../../src/utils/conversion.js"; const address = eoaProof.request.params[0] as string; const validAccountProof = eoaProof.dependentRequests[0].response.result as unknown as ELProof; diff --git a/packages/prover/test/unit/verified_requests/eth_call.test.ts b/packages/prover/test/unit/verified_requests/eth_call.test.ts index e76b3fe4ed83..74e998910505 100644 --- a/packages/prover/test/unit/verified_requests/eth_call.test.ts +++ b/packages/prover/test/unit/verified_requests/eth_call.test.ts @@ -1,13 +1,13 @@ -import {describe, it, expect} from "vitest"; import {createForkConfig} from "@lodestar/config"; import {NetworkName, networksChainConfig} from "@lodestar/config/networks"; +import {describe, expect, it} from "vitest"; import {ELTransaction} from "../../../lib/types.js"; import {VERIFICATION_FAILED_RESPONSE_CODE} from "../../../src/constants.js"; +import {JsonRpcRequest, JsonRpcResponseWithResultPayload} from "../../../src/types.js"; +import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; import {eth_call} from "../../../src/verified_requests/eth_call.js"; import ethCallCase1 from "../../fixtures/mainnet/eth_call.json" assert {type: "json"}; import {cloneTestFixture, generateReqHandlerOptionsMock} from "../../mocks/request_handler.js"; -import {JsonRpcRequest, JsonRpcResponseWithResultPayload} from "../../../src/types.js"; -import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; const testCases = [ethCallCase1]; diff --git a/packages/prover/test/unit/verified_requests/eth_estimateGas.test.ts b/packages/prover/test/unit/verified_requests/eth_estimateGas.test.ts index 27fbfb98a1b3..55ac3a74e581 100644 --- a/packages/prover/test/unit/verified_requests/eth_estimateGas.test.ts +++ b/packages/prover/test/unit/verified_requests/eth_estimateGas.test.ts @@ -1,14 +1,14 @@ -import {describe, it, expect} from "vitest"; import {createForkConfig} from "@lodestar/config"; import {NetworkName, networksChainConfig} from "@lodestar/config/networks"; +import {describe, expect, it} from "vitest"; import {ELTransaction} from "../../../lib/types.js"; import {VERIFICATION_FAILED_RESPONSE_CODE} from "../../../src/constants.js"; +import {JsonRpcRequest, JsonRpcResponseWithResultPayload} from "../../../src/types.js"; +import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; import {eth_estimateGas} from "../../../src/verified_requests/eth_estimateGas.js"; -import ethEstimateGasCase1 from "../../fixtures/mainnet/eth_estimateGas_simple_transfer.json" assert {type: "json"}; import ethEstimateGasCase2 from "../../fixtures/mainnet/eth_estimateGas_contract_call.json" assert {type: "json"}; +import ethEstimateGasCase1 from "../../fixtures/mainnet/eth_estimateGas_simple_transfer.json" assert {type: "json"}; import {TestFixture, cloneTestFixture, generateReqHandlerOptionsMock} from "../../mocks/request_handler.js"; -import {JsonRpcRequest, JsonRpcResponseWithResultPayload} from "../../../src/types.js"; -import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; const testCases = [ethEstimateGasCase1, ethEstimateGasCase2] as TestFixture[]; diff --git a/packages/prover/test/unit/verified_requests/eth_getBalance.test.ts b/packages/prover/test/unit/verified_requests/eth_getBalance.test.ts index 4032f4c25f19..f5f5470e385f 100644 --- a/packages/prover/test/unit/verified_requests/eth_getBalance.test.ts +++ b/packages/prover/test/unit/verified_requests/eth_getBalance.test.ts @@ -1,12 +1,12 @@ -import {describe, it, expect} from "vitest"; import {createForkConfig} from "@lodestar/config"; import {NetworkName, networksChainConfig} from "@lodestar/config/networks"; +import {describe, expect, it} from "vitest"; import {VERIFICATION_FAILED_RESPONSE_CODE} from "../../../src/constants.js"; +import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; import {eth_getBalance} from "../../../src/verified_requests/eth_getBalance.js"; -import ethGetBalanceEoa from "../../fixtures/sepolia/eth_getBalance_eoa.json" assert {type: "json"}; import ethGetBalanceContract from "../../fixtures/sepolia/eth_getBalance_contract.json" assert {type: "json"}; +import ethGetBalanceEoa from "../../fixtures/sepolia/eth_getBalance_eoa.json" assert {type: "json"}; import {cloneTestFixture, generateReqHandlerOptionsMock} from "../../mocks/request_handler.js"; -import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; const testCases = [ethGetBalanceEoa, ethGetBalanceContract]; diff --git a/packages/prover/test/unit/verified_requests/eth_getBlockByHash.test.ts b/packages/prover/test/unit/verified_requests/eth_getBlockByHash.test.ts index 3175bdd6d60c..265863680712 100644 --- a/packages/prover/test/unit/verified_requests/eth_getBlockByHash.test.ts +++ b/packages/prover/test/unit/verified_requests/eth_getBlockByHash.test.ts @@ -1,7 +1,9 @@ -import {describe, it, expect} from "vitest"; import {createForkConfig} from "@lodestar/config"; import {NetworkName, networksChainConfig} from "@lodestar/config/networks"; +import {describe, expect, it} from "vitest"; import {VERIFICATION_FAILED_RESPONSE_CODE} from "../../../src/constants.js"; +import {ELBlock} from "../../../src/types.js"; +import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; import {eth_getBlockByHash} from "../../../src/verified_requests/eth_getBlockByHash.js"; import ethGetBlockWithContractCreation from "../../fixtures/sepolia/eth_getBlock_with_contractCreation.json" assert { type: "json", @@ -10,8 +12,6 @@ import ethGetBlockWithNoAccessList from "../../fixtures/sepolia/eth_getBlock_wit type: "json", }; import {TestFixture, cloneTestFixture, generateReqHandlerOptionsMock} from "../../mocks/request_handler.js"; -import {ELBlock} from "../../../src/types.js"; -import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; const testCases = [ethGetBlockWithNoAccessList, ethGetBlockWithContractCreation] as [ TestFixture, diff --git a/packages/prover/test/unit/verified_requests/eth_getBlockByNumber.test.ts b/packages/prover/test/unit/verified_requests/eth_getBlockByNumber.test.ts index cc1389128ec0..9b59d39db771 100644 --- a/packages/prover/test/unit/verified_requests/eth_getBlockByNumber.test.ts +++ b/packages/prover/test/unit/verified_requests/eth_getBlockByNumber.test.ts @@ -1,8 +1,9 @@ -import {describe, it, expect} from "vitest"; import {createForkConfig} from "@lodestar/config"; import {NetworkName, networksChainConfig} from "@lodestar/config/networks"; +import {describe, expect, it} from "vitest"; import {VERIFICATION_FAILED_RESPONSE_CODE} from "../../../src/constants.js"; import {ELBlock} from "../../../src/types.js"; +import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; import {eth_getBlockByNumber} from "../../../src/verified_requests/eth_getBlockByNumber.js"; import ethGetBlockWithContractCreation from "../../fixtures/sepolia/eth_getBlock_with_contractCreation.json" assert { type: "json", @@ -11,7 +12,6 @@ import ethGetBlockWithNoAccessList from "../../fixtures/sepolia/eth_getBlock_wit type: "json", }; import {TestFixture, cloneTestFixture, generateReqHandlerOptionsMock} from "../../mocks/request_handler.js"; -import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; const testCases = [ethGetBlockWithNoAccessList, ethGetBlockWithContractCreation] as [ TestFixture, diff --git a/packages/prover/test/unit/verified_requests/eth_getCode.test.ts b/packages/prover/test/unit/verified_requests/eth_getCode.test.ts index 51cf0c153857..aeef17cb6ced 100644 --- a/packages/prover/test/unit/verified_requests/eth_getCode.test.ts +++ b/packages/prover/test/unit/verified_requests/eth_getCode.test.ts @@ -1,11 +1,11 @@ -import {describe, it, expect} from "vitest"; import {createForkConfig} from "@lodestar/config"; import {NetworkName, networksChainConfig} from "@lodestar/config/networks"; +import {describe, expect, it} from "vitest"; import {VERIFICATION_FAILED_RESPONSE_CODE} from "../../../src/constants.js"; +import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; import {eth_getCode} from "../../../src/verified_requests/eth_getCode.js"; import ethGetCodeCase1 from "../../fixtures/sepolia/eth_getCode.json" assert {type: "json"}; -import {generateReqHandlerOptionsMock, cloneTestFixture} from "../../mocks/request_handler.js"; -import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; +import {cloneTestFixture, generateReqHandlerOptionsMock} from "../../mocks/request_handler.js"; const testCases = [ethGetCodeCase1]; diff --git a/packages/prover/test/unit/verified_requests/eth_getTransactionCount.test.ts b/packages/prover/test/unit/verified_requests/eth_getTransactionCount.test.ts index 8baf8fd7976b..e72bfd4dbf96 100644 --- a/packages/prover/test/unit/verified_requests/eth_getTransactionCount.test.ts +++ b/packages/prover/test/unit/verified_requests/eth_getTransactionCount.test.ts @@ -1,11 +1,11 @@ -import {describe, it, expect} from "vitest"; import {createForkConfig} from "@lodestar/config"; import {NetworkName, networksChainConfig} from "@lodestar/config/networks"; +import {describe, expect, it} from "vitest"; import {VERIFICATION_FAILED_RESPONSE_CODE} from "../../../src/constants.js"; +import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; import {eth_getTransactionCount} from "../../../src/verified_requests/eth_getTransactionCount.js"; import getTransactionCountCase1 from "../../fixtures/sepolia/eth_getTransactionCount.json" assert {type: "json"}; -import {generateReqHandlerOptionsMock, cloneTestFixture} from "../../mocks/request_handler.js"; -import {getVerificationFailedMessage} from "../../../src/utils/json_rpc.js"; +import {cloneTestFixture, generateReqHandlerOptionsMock} from "../../mocks/request_handler.js"; const testCases = [getTransactionCountCase1]; diff --git a/packages/prover/test/unit/web3_provider.node.test.ts b/packages/prover/test/unit/web3_provider.node.test.ts index d1f281175b56..10f0fee3387d 100644 --- a/packages/prover/test/unit/web3_provider.node.test.ts +++ b/packages/prover/test/unit/web3_provider.node.test.ts @@ -1,11 +1,11 @@ -import {describe, it, expect, afterEach, vi} from "vitest"; -import {Web3} from "web3"; import {ethers} from "ethers"; -import {createVerifiedExecutionProvider} from "../../src/web3_provider.js"; -import {ELRpcProvider} from "../../src/utils/rpc_provider.js"; -import {ProofProvider} from "../../src/proof_provider/proof_provider.js"; +import {afterEach, describe, expect, it, vi} from "vitest"; +import {Web3} from "web3"; import {LCTransport, Web3ProviderType} from "../../src/interfaces.js"; +import {ProofProvider} from "../../src/proof_provider/proof_provider.js"; import {JsonRpcRequest, JsonRpcRequestOrBatch, JsonRpcResponse} from "../../src/types.js"; +import {ELRpcProvider} from "../../src/utils/rpc_provider.js"; +import {createVerifiedExecutionProvider} from "../../src/web3_provider.js"; describe("web3_provider", () => { afterEach(() => { diff --git a/packages/prover/test/unit/web3_provider_inspector.test.ts b/packages/prover/test/unit/web3_provider_inspector.test.ts index 95df8a0d760e..53da2c7c8482 100644 --- a/packages/prover/test/unit/web3_provider_inspector.test.ts +++ b/packages/prover/test/unit/web3_provider_inspector.test.ts @@ -1,9 +1,9 @@ -import {describe, it, beforeEach, expect} from "vitest"; -import {getEnvLogger} from "@lodestar/logger/env"; import {LogLevel} from "@lodestar/logger"; -import {Web3ProviderInspector} from "../../src/web3_provider_inspector.js"; +import {getEnvLogger} from "@lodestar/logger/env"; +import {beforeEach, describe, expect, it} from "vitest"; import {AnyWeb3Provider, Web3ProviderType} from "../../src/interfaces.js"; import web3JsProviderType from "../../src/provider_types/web3_js_provider_type.js"; +import {Web3ProviderInspector} from "../../src/web3_provider_inspector.js"; describe("Web3ProviderInspector", () => { let inspector: Web3ProviderInspector; diff --git a/packages/reqresp/src/ReqResp.ts b/packages/reqresp/src/ReqResp.ts index dc1459d87497..fadf99476156 100644 --- a/packages/reqresp/src/ReqResp.ts +++ b/packages/reqresp/src/ReqResp.ts @@ -1,21 +1,21 @@ import {setMaxListeners} from "node:events"; import {Connection, PeerId, Stream} from "@libp2p/interface"; -import type {Libp2p} from "libp2p"; import {Logger, MetricsRegister} from "@lodestar/utils"; -import {getMetrics, Metrics} from "./metrics.js"; -import {RequestError, RequestErrorCode, sendRequest, SendRequestOpts} from "./request/index.js"; +import type {Libp2p} from "libp2p"; +import {Metrics, getMetrics} from "./metrics.js"; +import {ReqRespRateLimiter} from "./rate_limiter/ReqRespRateLimiter.js"; +import {RequestError, RequestErrorCode, SendRequestOpts, sendRequest} from "./request/index.js"; import {handleRequest} from "./response/index.js"; import { DialOnlyProtocol, Encoding, MixedProtocol, - ReqRespRateLimiterOpts, Protocol, ProtocolDescriptor, + ReqRespRateLimiterOpts, ResponseIncoming, } from "./types.js"; import {formatProtocolID} from "./utils/protocolId.js"; -import {ReqRespRateLimiter} from "./rate_limiter/ReqRespRateLimiter.js"; type ProtocolID = string; diff --git a/packages/reqresp/src/encoders/requestDecode.ts b/packages/reqresp/src/encoders/requestDecode.ts index e91462ab7602..d50f1ee37b5b 100644 --- a/packages/reqresp/src/encoders/requestDecode.ts +++ b/packages/reqresp/src/encoders/requestDecode.ts @@ -1,8 +1,8 @@ import type {Sink} from "it-stream-types"; import {Uint8ArrayList} from "uint8arraylist"; +import {readEncodedPayload} from "../encodingStrategies/index.js"; import {MixedProtocol} from "../types.js"; import {BufferedSource} from "../utils/index.js"; -import {readEncodedPayload} from "../encodingStrategies/index.js"; const EMPTY_DATA = new Uint8Array(); diff --git a/packages/reqresp/src/encoders/requestEncode.ts b/packages/reqresp/src/encoders/requestEncode.ts index 7ea20664bc8b..752924c10118 100644 --- a/packages/reqresp/src/encoders/requestEncode.ts +++ b/packages/reqresp/src/encoders/requestEncode.ts @@ -1,5 +1,5 @@ -import {MixedProtocol} from "../types.js"; import {writeEncodedPayload} from "../encodingStrategies/index.js"; +import {MixedProtocol} from "../types.js"; /** * Yields byte chunks for a `` diff --git a/packages/reqresp/src/encoders/responseDecode.ts b/packages/reqresp/src/encoders/responseDecode.ts index 0dde5bcdc95e..23799037a3d2 100644 --- a/packages/reqresp/src/encoders/responseDecode.ts +++ b/packages/reqresp/src/encoders/responseDecode.ts @@ -1,16 +1,16 @@ -import {Uint8ArrayList} from "uint8arraylist"; import {ForkName} from "@lodestar/params"; -import {BufferedSource, decodeErrorMessage} from "../utils/index.js"; +import {Uint8ArrayList} from "uint8arraylist"; import {readEncodedPayload} from "../encodingStrategies/index.js"; +import {RespStatus} from "../interface.js"; import {ResponseError} from "../response/index.js"; import { - ContextBytesType, CONTEXT_BYTES_FORK_DIGEST_LENGTH, ContextBytesFactory, + ContextBytesType, MixedProtocol, ResponseIncoming, } from "../types.js"; -import {RespStatus} from "../interface.js"; +import {BufferedSource, decodeErrorMessage} from "../utils/index.js"; /** * Internal helper type to signal stream ended early diff --git a/packages/reqresp/src/encoders/responseEncode.ts b/packages/reqresp/src/encoders/responseEncode.ts index c5320ffc1ce9..9a1f9251c008 100644 --- a/packages/reqresp/src/encoders/responseEncode.ts +++ b/packages/reqresp/src/encoders/responseEncode.ts @@ -1,7 +1,7 @@ import {writeEncodedPayload} from "../encodingStrategies/index.js"; -import {encodeErrorMessage} from "../utils/index.js"; -import {ContextBytesType, ContextBytesFactory, MixedProtocol, Protocol, ResponseOutgoing} from "../types.js"; import {RespStatus, RpcResponseStatusError} from "../interface.js"; +import {ContextBytesFactory, ContextBytesType, MixedProtocol, Protocol, ResponseOutgoing} from "../types.js"; +import {encodeErrorMessage} from "../utils/index.js"; const SUCCESS_BUFFER = Buffer.from([RespStatus.SUCCESS]); diff --git a/packages/reqresp/src/encodingStrategies/sszSnappy/decode.ts b/packages/reqresp/src/encodingStrategies/sszSnappy/decode.ts index 9ebe52876cfe..9104104a0aa8 100644 --- a/packages/reqresp/src/encodingStrategies/sszSnappy/decode.ts +++ b/packages/reqresp/src/encodingStrategies/sszSnappy/decode.ts @@ -1,10 +1,10 @@ import {decode as varintDecode, encodingLength as varintEncodingLength} from "uint8-varint"; import {Uint8ArrayList} from "uint8arraylist"; -import {BufferedSource} from "../../utils/index.js"; import {TypeSizes} from "../../types.js"; +import {BufferedSource} from "../../utils/index.js"; +import {SszSnappyError, SszSnappyErrorCode} from "./errors.js"; import {SnappyFramesUncompress} from "./snappyFrames/uncompress.js"; import {maxEncodedLen} from "./utils.js"; -import {SszSnappyError, SszSnappyErrorCode} from "./errors.js"; export const MAX_VARINT_BYTES = 10; diff --git a/packages/reqresp/src/encodingStrategies/sszSnappy/snappyFrames/compress.ts b/packages/reqresp/src/encodingStrategies/sszSnappy/snappyFrames/compress.ts index e1c3887eaa70..98ae4053e90c 100644 --- a/packages/reqresp/src/encodingStrategies/sszSnappy/snappyFrames/compress.ts +++ b/packages/reqresp/src/encodingStrategies/sszSnappy/snappyFrames/compress.ts @@ -1,5 +1,5 @@ -import snappy from "snappy"; import crc32c from "@chainsafe/fast-crc32c"; +import snappy from "snappy"; import {ChunkType, IDENTIFIER_FRAME} from "./common.js"; // The logic in this file is largely copied (in simplified form) from https://github.com/ChainSafe/node-snappy-stream/ diff --git a/packages/reqresp/src/request/errors.ts b/packages/reqresp/src/request/errors.ts index ba3904e563ed..6795d9440a89 100644 --- a/packages/reqresp/src/request/errors.ts +++ b/packages/reqresp/src/request/errors.ts @@ -1,6 +1,6 @@ import {LodestarError, LodestarErrorObject} from "@lodestar/utils"; -import {ResponseError} from "../response/index.js"; import {RespStatus, RpcResponseStatusError} from "../interface.js"; +import {ResponseError} from "../response/index.js"; export enum RequestErrorCode { // Declaring specific values of RpcResponseStatusError for error clarity downstream diff --git a/packages/reqresp/src/request/index.ts b/packages/reqresp/src/request/index.ts index 9a374db3b8be..edd3b25eedbf 100644 --- a/packages/reqresp/src/request/index.ts +++ b/packages/reqresp/src/request/index.ts @@ -1,14 +1,14 @@ -import {pipe} from "it-pipe"; import {PeerId} from "@libp2p/interface"; +import {ErrorAborted, Logger, TimeoutError, withTimeout} from "@lodestar/utils"; +import {pipe} from "it-pipe"; import type {Libp2p} from "libp2p"; import {Uint8ArrayList} from "uint8arraylist"; -import {ErrorAborted, Logger, withTimeout, TimeoutError} from "@lodestar/utils"; -import {MixedProtocol, ResponseIncoming} from "../types.js"; -import {prettyPrintPeerId, abortableSource} from "../utils/index.js"; -import {Metrics} from "../metrics.js"; -import {ResponseError} from "../response/index.js"; import {requestEncode} from "../encoders/requestEncode.js"; import {responseDecode} from "../encoders/responseDecode.js"; +import {Metrics} from "../metrics.js"; +import {ResponseError} from "../response/index.js"; +import {MixedProtocol, ResponseIncoming} from "../types.js"; +import {abortableSource, prettyPrintPeerId} from "../utils/index.js"; import {RequestError, RequestErrorCode, responseStatusErrorToRequestError} from "./errors.js"; export {RequestError, RequestErrorCode}; diff --git a/packages/reqresp/src/response/index.ts b/packages/reqresp/src/response/index.ts index d9f0e1b1806a..265d5418d655 100644 --- a/packages/reqresp/src/response/index.ts +++ b/packages/reqresp/src/response/index.ts @@ -1,15 +1,15 @@ -import {pipe} from "it-pipe"; import {PeerId, Stream} from "@libp2p/interface"; -import {Uint8ArrayList} from "uint8arraylist"; import {Logger, TimeoutError, withTimeout} from "@lodestar/utils"; -import {prettyPrintPeerId} from "../utils/index.js"; -import {Protocol, ReqRespRequest} from "../types.js"; +import {pipe} from "it-pipe"; +import {Uint8ArrayList} from "uint8arraylist"; import {requestDecode} from "../encoders/requestDecode.js"; import {responseEncodeError, responseEncodeSuccess} from "../encoders/responseEncode.js"; import {RespStatus} from "../interface.js"; -import {RequestError, RequestErrorCode} from "../request/errors.js"; -import {ReqRespRateLimiter} from "../rate_limiter/ReqRespRateLimiter.js"; import {Metrics} from "../metrics.js"; +import {ReqRespRateLimiter} from "../rate_limiter/ReqRespRateLimiter.js"; +import {RequestError, RequestErrorCode} from "../request/errors.js"; +import {Protocol, ReqRespRequest} from "../types.js"; +import {prettyPrintPeerId} from "../utils/index.js"; import {ResponseError} from "./errors.js"; export {ResponseError}; diff --git a/packages/reqresp/src/utils/collectExactOne.ts b/packages/reqresp/src/utils/collectExactOne.ts index 962616135cdf..ab1edea6478a 100644 --- a/packages/reqresp/src/utils/collectExactOne.ts +++ b/packages/reqresp/src/utils/collectExactOne.ts @@ -1,4 +1,4 @@ -import {RequestErrorCode, RequestError} from "../request/errors.js"; +import {RequestError, RequestErrorCode} from "../request/errors.js"; /** * Sink for `*`, from diff --git a/packages/reqresp/test/fixtures/encodingStrategies.ts b/packages/reqresp/test/fixtures/encodingStrategies.ts index 7bf183d8714c..58652a4d6b92 100644 --- a/packages/reqresp/test/fixtures/encodingStrategies.ts +++ b/packages/reqresp/test/fixtures/encodingStrategies.ts @@ -1,9 +1,9 @@ import fs from "node:fs"; import path from "node:path"; import {fileURLToPath} from "node:url"; -import {encode as varintEncode} from "uint8-varint"; -import {ssz} from "@lodestar/types"; import {ForkName} from "@lodestar/params"; +import {ssz} from "@lodestar/types"; +import {encode as varintEncode} from "uint8-varint"; import {SszSnappyErrorCode} from "../../src/encodingStrategies/sszSnappy/errors.js"; import {ResponseOutgoing, TypeSizes} from "../../src/types.js"; import { diff --git a/packages/reqresp/test/fixtures/messages.ts b/packages/reqresp/test/fixtures/messages.ts index a243a05b221b..4fa6c69e2865 100644 --- a/packages/reqresp/test/fixtures/messages.ts +++ b/packages/reqresp/test/fixtures/messages.ts @@ -1,8 +1,8 @@ import {fromHexString} from "@chainsafe/ssz"; import {createBeaconConfig} from "@lodestar/config"; import {chainConfig} from "@lodestar/config/default"; -import {ssz} from "@lodestar/types"; import {ForkName, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {ssz} from "@lodestar/types"; import {ResponseIncoming, TypeSizes} from "../../src/types.js"; import {ZERO_HASH} from "../utils/index.js"; diff --git a/packages/reqresp/test/fixtures/protocols.ts b/packages/reqresp/test/fixtures/protocols.ts index 19e8936fc376..0afd6300fb1c 100644 --- a/packages/reqresp/test/fixtures/protocols.ts +++ b/packages/reqresp/test/fixtures/protocols.ts @@ -1,7 +1,7 @@ -import {ContainerType, UintNumberType, ListBasicType, ValueOf} from "@chainsafe/ssz"; -import {ssz} from "@lodestar/types"; +import {ContainerType, ListBasicType, UintNumberType, ValueOf} from "@chainsafe/ssz"; import {ForkName} from "@lodestar/params"; -import {ContextBytesType, DialOnlyProtocol, Encoding, ProtocolHandler, Protocol} from "../../src/types.js"; +import {ssz} from "@lodestar/types"; +import {ContextBytesType, DialOnlyProtocol, Encoding, Protocol, ProtocolHandler} from "../../src/types.js"; import {getEmptyHandler} from "./messages.js"; import {beaconConfig} from "./messages.js"; diff --git a/packages/reqresp/test/unit/ReqResp.test.ts b/packages/reqresp/test/unit/ReqResp.test.ts index 8d78a46f292f..b9e9fe3e9e60 100644 --- a/packages/reqresp/test/unit/ReqResp.test.ts +++ b/packages/reqresp/test/unit/ReqResp.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect, beforeEach, afterEach, vi} from "vitest"; -import {Libp2p} from "libp2p"; -import {Logger} from "@lodestar/utils"; import {getEmptyLogger} from "@lodestar/logger/empty"; -import {RespStatus} from "../../src/interface.js"; +import {Logger} from "@lodestar/utils"; +import {Libp2p} from "libp2p"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {ReqResp} from "../../src/ReqResp.js"; +import {RespStatus} from "../../src/interface.js"; import {getEmptyHandler, sszSnappyPing} from "../fixtures/messages.js"; import {numberToStringProtocol, numberToStringProtocolDialOnly, pingProtocol} from "../fixtures/protocols.js"; import {MockLibP2pStream} from "../utils/index.js"; diff --git a/packages/reqresp/test/unit/encoders/reqestEncode.test.ts b/packages/reqresp/test/unit/encoders/reqestEncode.test.ts index 221dc8237e19..8771e26913cd 100644 --- a/packages/reqresp/test/unit/encoders/reqestEncode.test.ts +++ b/packages/reqresp/test/unit/encoders/reqestEncode.test.ts @@ -1,6 +1,6 @@ -import {describe, it} from "vitest"; import all from "it-all"; import {pipe} from "it-pipe"; +import {describe, it} from "vitest"; import {requestEncode} from "../../../src/encoders/requestEncode.js"; import {requestEncodersCases} from "../../fixtures/encoders.js"; import {expectEqualByteChunks} from "../../utils/index.js"; diff --git a/packages/reqresp/test/unit/encoders/requestDecode.test.ts b/packages/reqresp/test/unit/encoders/requestDecode.test.ts index 462bc3bb7378..cd8c7bc303e6 100644 --- a/packages/reqresp/test/unit/encoders/requestDecode.test.ts +++ b/packages/reqresp/test/unit/encoders/requestDecode.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {pipe} from "it-pipe"; +import {describe, expect, it} from "vitest"; import {requestDecode} from "../../../src/encoders/requestDecode.js"; import {requestEncodersCases, requestEncodersErrorCases} from "../../fixtures/encoders.js"; import {expectRejectedWithLodestarError} from "../../utils/errors.js"; diff --git a/packages/reqresp/test/unit/encoders/responseDecode.test.ts b/packages/reqresp/test/unit/encoders/responseDecode.test.ts index 8fc919c46313..9c6cf9a32361 100644 --- a/packages/reqresp/test/unit/encoders/responseDecode.test.ts +++ b/packages/reqresp/test/unit/encoders/responseDecode.test.ts @@ -1,12 +1,12 @@ -import {describe, it, expect} from "vitest"; +import {LodestarError} from "@lodestar/utils"; import all from "it-all"; import {pipe} from "it-pipe"; -import {LodestarError} from "@lodestar/utils"; +import {describe, expect, it} from "vitest"; import {responseDecode} from "../../../src/encoders/responseDecode.js"; +import {ResponseIncoming} from "../../../src/types.js"; import {responseEncodersErrorTestCases, responseEncodersTestCases} from "../../fixtures/encoders.js"; import {expectRejectedWithLodestarError} from "../../utils/errors.js"; import {arrToSource, onlySuccessResp} from "../../utils/index.js"; -import {ResponseIncoming} from "../../../src/types.js"; describe("encoders / responseDecode", () => { describe("valid cases", () => { diff --git a/packages/reqresp/test/unit/encoders/responseEncode.test.ts b/packages/reqresp/test/unit/encoders/responseEncode.test.ts index b9b5f3f8ee11..9580d0b2fcd8 100644 --- a/packages/reqresp/test/unit/encoders/responseEncode.test.ts +++ b/packages/reqresp/test/unit/encoders/responseEncode.test.ts @@ -1,10 +1,10 @@ -import {describe, it} from "vitest"; import all from "it-all"; import {pipe} from "it-pipe"; +import {describe, it} from "vitest"; import {Protocol} from "../../../src/types.js"; import {responseEncodersTestCases} from "../../fixtures/encoders.js"; -import {responseEncode} from "../../utils/response.js"; import {expectEqualByteChunks} from "../../utils/index.js"; +import {responseEncode} from "../../utils/response.js"; describe("encoders / responseEncode", () => { describe("valid cases", () => { diff --git a/packages/reqresp/test/unit/encodingStrategies/sszSnappy/decode.test.ts b/packages/reqresp/test/unit/encodingStrategies/sszSnappy/decode.test.ts index bfa597e42519..f315cc26316b 100644 --- a/packages/reqresp/test/unit/encodingStrategies/sszSnappy/decode.test.ts +++ b/packages/reqresp/test/unit/encodingStrategies/sszSnappy/decode.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {Uint8ArrayList} from "uint8arraylist"; import {encode as varintEncode} from "uint8-varint"; +import {Uint8ArrayList} from "uint8arraylist"; +import {describe, expect, it} from "vitest"; import {readSszSnappyPayload} from "../../../../src/encodingStrategies/sszSnappy/index.js"; import {BufferedSource} from "../../../../src/utils/index.js"; import { diff --git a/packages/reqresp/test/unit/encodingStrategies/sszSnappy/encode.test.ts b/packages/reqresp/test/unit/encodingStrategies/sszSnappy/encode.test.ts index 6ec27d1e6b16..68f5c4e5299d 100644 --- a/packages/reqresp/test/unit/encodingStrategies/sszSnappy/encode.test.ts +++ b/packages/reqresp/test/unit/encodingStrategies/sszSnappy/encode.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; import all from "it-all"; import {pipe} from "it-pipe"; import {encode as varintEncode} from "uint8-varint"; +import {describe, expect, it} from "vitest"; import {writeSszSnappyPayload} from "../../../../src/encodingStrategies/sszSnappy/encode.js"; import {encodingStrategiesMainnetTestCases, encodingStrategiesTestCases} from "../../../fixtures/index.js"; import {expectEqualByteChunks} from "../../../utils/index.js"; diff --git a/packages/reqresp/test/unit/encodingStrategies/sszSnappy/snappyFrames/uncompress.test.ts b/packages/reqresp/test/unit/encodingStrategies/sszSnappy/snappyFrames/uncompress.test.ts index dc01a1952142..66d4f3548b9f 100644 --- a/packages/reqresp/test/unit/encodingStrategies/sszSnappy/snappyFrames/uncompress.test.ts +++ b/packages/reqresp/test/unit/encodingStrategies/sszSnappy/snappyFrames/uncompress.test.ts @@ -1,8 +1,8 @@ -import {describe, it, expect} from "vitest"; -import {Uint8ArrayList} from "uint8arraylist"; import {pipe} from "it-pipe"; -import {SnappyFramesUncompress} from "../../../../../src/encodingStrategies/sszSnappy/snappyFrames/uncompress.js"; +import {Uint8ArrayList} from "uint8arraylist"; +import {describe, expect, it} from "vitest"; import {encodeSnappy} from "../../../../../src/encodingStrategies/sszSnappy/snappyFrames/compress.js"; +import {SnappyFramesUncompress} from "../../../../../src/encodingStrategies/sszSnappy/snappyFrames/uncompress.js"; describe("encodingStrategies / sszSnappy / snappy frames / uncompress", () => { it("should work with short input", () => diff --git a/packages/reqresp/test/unit/encodingStrategies/sszSnappy/utils.test.ts b/packages/reqresp/test/unit/encodingStrategies/sszSnappy/utils.test.ts index a494b4acab9a..34e40967bf00 100644 --- a/packages/reqresp/test/unit/encodingStrategies/sszSnappy/utils.test.ts +++ b/packages/reqresp/test/unit/encodingStrategies/sszSnappy/utils.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {maxEncodedLen} from "../../../../src/encodingStrategies/sszSnappy/utils.js"; describe("encodingStrategies / sszSnappy / utils", () => { diff --git a/packages/reqresp/test/unit/rate_limiter/rateLimiterGRCA.test.ts b/packages/reqresp/test/unit/rate_limiter/rateLimiterGRCA.test.ts index a8cbb6e0d3a6..e74eb9a25e0b 100644 --- a/packages/reqresp/test/unit/rate_limiter/rateLimiterGRCA.test.ts +++ b/packages/reqresp/test/unit/rate_limiter/rateLimiterGRCA.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, vi, beforeEach, afterEach} from "vitest"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {RateLimiterGRCA} from "../../../src/rate_limiter/rateLimiterGRCA.js"; describe("rateLimiterGRCA", () => { diff --git a/packages/reqresp/test/unit/request/index.test.ts b/packages/reqresp/test/unit/request/index.test.ts index 888520457bb2..4d9a8bfabbd3 100644 --- a/packages/reqresp/test/unit/request/index.test.ts +++ b/packages/reqresp/test/unit/request/index.test.ts @@ -1,19 +1,19 @@ -import {describe, it, expect, vi, beforeEach, afterEach} from "vitest"; import {PeerId} from "@libp2p/interface"; +import {getEmptyLogger} from "@lodestar/logger/empty"; +import {LodestarError, sleep} from "@lodestar/utils"; import all from "it-all"; import {pipe} from "it-pipe"; import {Libp2p} from "libp2p"; -import {getEmptyLogger} from "@lodestar/logger/empty"; -import {LodestarError, sleep} from "@lodestar/utils"; -import {RequestError, RequestErrorCode, sendRequest, SendRequestOpts} from "../../../src/request/index.js"; -import {Protocol, MixedProtocol, ResponseIncoming} from "../../../src/types.js"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; +import {RespStatus} from "../../../src/interface.js"; +import {RequestError, RequestErrorCode, SendRequestOpts, sendRequest} from "../../../src/request/index.js"; +import {MixedProtocol, Protocol, ResponseIncoming} from "../../../src/types.js"; import {getEmptyHandler, sszSnappyPing} from "../../fixtures/messages.js"; -import {getValidPeerId} from "../../utils/peer.js"; +import {pingProtocol} from "../../fixtures/protocols.js"; +import {expectRejectedWithLodestarError} from "../../utils/errors.js"; import {MockLibP2pStream} from "../../utils/index.js"; +import {getValidPeerId} from "../../utils/peer.js"; import {responseEncode} from "../../utils/response.js"; -import {RespStatus} from "../../../src/interface.js"; -import {expectRejectedWithLodestarError} from "../../utils/errors.js"; -import {pingProtocol} from "../../fixtures/protocols.js"; describe("request / sendRequest", () => { const logger = getEmptyLogger(); diff --git a/packages/reqresp/test/unit/response/index.test.ts b/packages/reqresp/test/unit/response/index.test.ts index 62a8e63f3fe0..4433f44faeeb 100644 --- a/packages/reqresp/test/unit/response/index.test.ts +++ b/packages/reqresp/test/unit/response/index.test.ts @@ -1,15 +1,15 @@ -import {describe, it, expect, beforeEach, afterEach} from "vitest"; import {PeerId} from "@libp2p/interface"; -import {LodestarError, fromHex} from "@lodestar/utils"; import {getEmptyLogger} from "@lodestar/logger/empty"; +import {LodestarError, fromHex} from "@lodestar/utils"; +import {afterEach, beforeEach, describe, expect, it} from "vitest"; import {Protocol, RespStatus} from "../../../src/index.js"; import {ReqRespRateLimiter} from "../../../src/rate_limiter/ReqRespRateLimiter.js"; import {handleRequest} from "../../../src/response/index.js"; import {sszSnappyPing} from "../../fixtures/messages.js"; +import {pingProtocol} from "../../fixtures/protocols.js"; import {expectRejectedWithLodestarError} from "../../utils/errors.js"; import {MockLibP2pStream, expectEqualByteChunks} from "../../utils/index.js"; import {getValidPeerId} from "../../utils/peer.js"; -import {pingProtocol} from "../../fixtures/protocols.js"; const testCases: { id: string; diff --git a/packages/reqresp/test/unit/utils/protocolId.test.ts b/packages/reqresp/test/unit/utils/protocolId.test.ts index 04cd93222045..047c4a0272fa 100644 --- a/packages/reqresp/test/unit/utils/protocolId.test.ts +++ b/packages/reqresp/test/unit/utils/protocolId.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {Encoding, ProtocolAttributes} from "../../../src/index.js"; import {formatProtocolID, parseProtocolID as reqrespParseProtocolID} from "../../../src/utils/index.js"; diff --git a/packages/reqresp/test/utils/errors.ts b/packages/reqresp/test/utils/errors.ts index e4697a6d97d5..b882b1c63e71 100644 --- a/packages/reqresp/test/utils/errors.ts +++ b/packages/reqresp/test/utils/errors.ts @@ -1,5 +1,5 @@ -import {expect} from "vitest"; import {LodestarError, mapValues} from "@lodestar/utils"; +import {expect} from "vitest"; export function expectThrowsLodestarError(fn: () => void, expectedErr: LodestarError | string): void { try { diff --git a/packages/reqresp/test/utils/index.ts b/packages/reqresp/test/utils/index.ts index afddace8328d..77c05c1739a4 100644 --- a/packages/reqresp/test/utils/index.ts +++ b/packages/reqresp/test/utils/index.ts @@ -1,10 +1,10 @@ +import {toHexString} from "@chainsafe/ssz"; import {Direction, ReadStatus, Stream, StreamStatus, WriteStatus} from "@libp2p/interface"; import {logger} from "@libp2p/logger"; -import {expect} from "vitest"; -import {Uint8ArrayList} from "uint8arraylist"; -import {toHexString} from "@chainsafe/ssz"; import {fromHex} from "@lodestar/utils"; -import {ResponseIncoming, RespStatus} from "../../src/index.js"; +import {Uint8ArrayList} from "uint8arraylist"; +import {expect} from "vitest"; +import {RespStatus, ResponseIncoming} from "../../src/index.js"; import {ResponseChunk} from "../fixtures/index.js"; /** diff --git a/packages/spec-test-util/src/downloadTests.ts b/packages/spec-test-util/src/downloadTests.ts index bca6a8ac52c9..53113e716eea 100644 --- a/packages/spec-test-util/src/downloadTests.ts +++ b/packages/spec-test-util/src/downloadTests.ts @@ -3,10 +3,10 @@ import fs from "node:fs"; import path from "node:path"; import stream from "node:stream"; import {promisify} from "node:util"; -import {rimraf} from "rimraf"; +import {retry} from "@lodestar/utils"; import axios from "axios"; +import {rimraf} from "rimraf"; import {x as extractTar} from "tar"; -import {retry} from "@lodestar/utils"; export const defaultSpecTestsRepoUrl = "https://github.com/ethereum/consensus-spec-tests"; diff --git a/packages/spec-test-util/src/single.ts b/packages/spec-test-util/src/single.ts index 888c87e3ffa8..476ac8e1eebf 100644 --- a/packages/spec-test-util/src/single.ts +++ b/packages/spec-test-util/src/single.ts @@ -1,8 +1,8 @@ import fs from "node:fs"; import path from "node:path"; -import {describe, it, vi, expect} from "vitest"; -import {uncompress} from "snappyjs"; import {loadYaml} from "@lodestar/utils"; +import {uncompress} from "snappyjs"; +import {describe, expect, it, vi} from "vitest"; /* eslint-disable @typescript-eslint/no-unsafe-assignment, diff --git a/packages/spec-test-util/src/sszGeneric.ts b/packages/spec-test-util/src/sszGeneric.ts index e932b897a90c..590b97151f17 100644 --- a/packages/spec-test-util/src/sszGeneric.ts +++ b/packages/spec-test-util/src/sszGeneric.ts @@ -1,7 +1,7 @@ -import path from "node:path"; import fs from "node:fs"; -import {uncompress} from "snappyjs"; +import path from "node:path"; import {loadYaml} from "@lodestar/utils"; +import {uncompress} from "snappyjs"; /* eslint-disable @typescript-eslint/explicit-function-return-type */ diff --git a/packages/spec-test-util/test/e2e/single/index.test.ts b/packages/spec-test-util/test/e2e/single/index.test.ts index 2dbefbb9cd22..8e7c90182e7a 100644 --- a/packages/spec-test-util/test/e2e/single/index.test.ts +++ b/packages/spec-test-util/test/e2e/single/index.test.ts @@ -1,10 +1,10 @@ import fs from "node:fs"; import path from "node:path"; import {fileURLToPath} from "node:url"; -import {beforeAll, afterAll} from "vitest"; import {ContainerType, Type} from "@chainsafe/ssz"; import {ssz} from "@lodestar/types"; -import {describeDirectorySpecTest, InputType, loadYamlFile} from "../../../src/single.js"; +import {afterAll, beforeAll} from "vitest"; +import {InputType, describeDirectorySpecTest, loadYamlFile} from "../../../src/single.js"; // Global variable __dirname no longer available in ES6 modules. // Solutions: https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-js-when-using-es6-modules diff --git a/packages/state-transition/src/block/index.ts b/packages/state-transition/src/block/index.ts index 3857511292c8..8004a2657556 100644 --- a/packages/state-transition/src/block/index.ts +++ b/packages/state-transition/src/block/index.ts @@ -1,15 +1,15 @@ import {ForkSeq} from "@lodestar/params"; import {BeaconBlock, BlindedBeaconBlock, altair, capella} from "@lodestar/types"; +import {CachedBeaconStateAllForks, CachedBeaconStateBellatrix, CachedBeaconStateCapella} from "../types.js"; import {getFullOrBlindedPayload, isExecutionEnabled} from "../util/execution.js"; -import {CachedBeaconStateAllForks, CachedBeaconStateCapella, CachedBeaconStateBellatrix} from "../types.js"; -import {processExecutionPayload} from "./processExecutionPayload.js"; -import {processSyncAggregate} from "./processSyncCommittee.js"; +import {BlockExternalData, DataAvailableStatus} from "./externalData.js"; +import {processBlobKzgCommitments} from "./processBlobKzgCommitments.js"; import {processBlockHeader} from "./processBlockHeader.js"; import {processEth1Data} from "./processEth1Data.js"; +import {processExecutionPayload} from "./processExecutionPayload.js"; import {processOperations} from "./processOperations.js"; import {processRandao} from "./processRandao.js"; -import {processBlobKzgCommitments} from "./processBlobKzgCommitments.js"; -import {BlockExternalData, DataAvailableStatus} from "./externalData.js"; +import {processSyncAggregate} from "./processSyncCommittee.js"; import {processWithdrawals} from "./processWithdrawals.js"; import {ProcessBlockOpts} from "./types.js"; diff --git a/packages/state-transition/src/block/isValidIndexedAttestation.ts b/packages/state-transition/src/block/isValidIndexedAttestation.ts index 8c7502ceedb5..fdb005484733 100644 --- a/packages/state-transition/src/block/isValidIndexedAttestation.ts +++ b/packages/state-transition/src/block/isValidIndexedAttestation.ts @@ -1,8 +1,8 @@ import {ForkSeq, MAX_COMMITTEES_PER_SLOT, MAX_VALIDATORS_PER_COMMITTEE} from "@lodestar/params"; import {phase0} from "@lodestar/types"; +import {getIndexedAttestationBigintSignatureSet, getIndexedAttestationSignatureSet} from "../signatureSets/index.js"; import {CachedBeaconStateAllForks} from "../types.js"; import {verifySignatureSet} from "../util/index.js"; -import {getIndexedAttestationBigintSignatureSet, getIndexedAttestationSignatureSet} from "../signatureSets/index.js"; /** * Check if `indexedAttestation` has sorted and unique indices and a valid aggregate signature. diff --git a/packages/state-transition/src/block/processAttestationPhase0.ts b/packages/state-transition/src/block/processAttestationPhase0.ts index e2b32bbbbee8..ab57bd27c80d 100644 --- a/packages/state-transition/src/block/processAttestationPhase0.ts +++ b/packages/state-transition/src/block/processAttestationPhase0.ts @@ -1,9 +1,9 @@ +import {ForkSeq, MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {Attestation, Slot, electra, phase0, ssz} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; -import {Slot, Attestation, electra, phase0, ssz} from "@lodestar/types"; -import {MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH, ForkSeq} from "@lodestar/params"; import {assert} from "@lodestar/utils"; +import {CachedBeaconStateAllForks, CachedBeaconStatePhase0} from "../types.js"; import {computeEpochAtSlot} from "../util/index.js"; -import {CachedBeaconStatePhase0, CachedBeaconStateAllForks} from "../types.js"; import {isValidIndexedAttestation} from "./index.js"; /** diff --git a/packages/state-transition/src/block/processAttestations.ts b/packages/state-transition/src/block/processAttestations.ts index 844bda768570..09b8cd7584f2 100644 --- a/packages/state-transition/src/block/processAttestations.ts +++ b/packages/state-transition/src/block/processAttestations.ts @@ -1,5 +1,5 @@ -import {Attestation} from "@lodestar/types"; import {ForkSeq} from "@lodestar/params"; +import {Attestation} from "@lodestar/types"; import {CachedBeaconStateAllForks, CachedBeaconStateAltair, CachedBeaconStatePhase0} from "../types.js"; import {processAttestationPhase0} from "./processAttestationPhase0.js"; import {processAttestationsAltair} from "./processAttestationsAltair.js"; diff --git a/packages/state-transition/src/block/processAttestationsAltair.ts b/packages/state-transition/src/block/processAttestationsAltair.ts index 046a23d7dc27..0157f4e997a1 100644 --- a/packages/state-transition/src/block/processAttestationsAltair.ts +++ b/packages/state-transition/src/block/processAttestationsAltair.ts @@ -1,8 +1,9 @@ import {byteArrayEquals} from "@chainsafe/ssz"; -import {Epoch, Attestation, phase0} from "@lodestar/types"; +import {Attestation, Epoch, phase0} from "@lodestar/types"; import {intSqrt} from "@lodestar/utils"; import { + ForkSeq, MIN_ATTESTATION_INCLUSION_DELAY, PROPOSER_WEIGHT, SLOTS_PER_EPOCH, @@ -13,12 +14,11 @@ import { TIMELY_TARGET_FLAG_INDEX, TIMELY_TARGET_WEIGHT, WEIGHT_DENOMINATOR, - ForkSeq, } from "@lodestar/params"; -import {increaseBalance, verifySignatureSet} from "../util/index.js"; +import {getAttestationWithIndicesSignatureSet} from "../signatureSets/indexedAttestation.js"; import {CachedBeaconStateAltair} from "../types.js"; +import {increaseBalance, verifySignatureSet} from "../util/index.js"; import {RootCache} from "../util/rootCache.js"; -import {getAttestationWithIndicesSignatureSet} from "../signatureSets/indexedAttestation.js"; import {checkpointToStr, isTimelyTarget, validateAttestation} from "./processAttestationPhase0.js"; const PROPOSER_REWARD_DOMINATOR = ((WEIGHT_DENOMINATOR - PROPOSER_WEIGHT) * WEIGHT_DENOMINATOR) / PROPOSER_WEIGHT; diff --git a/packages/state-transition/src/block/processAttesterSlashing.ts b/packages/state-transition/src/block/processAttesterSlashing.ts index 0f635e33fce2..5470082a7c2b 100644 --- a/packages/state-transition/src/block/processAttesterSlashing.ts +++ b/packages/state-transition/src/block/processAttesterSlashing.ts @@ -1,10 +1,10 @@ -import {phase0} from "@lodestar/types"; import {ForkSeq} from "@lodestar/params"; +import {phase0} from "@lodestar/types"; -import {isSlashableValidator, isSlashableAttestationData, getAttesterSlashableIndices} from "../util/index.js"; import {CachedBeaconStateAllForks} from "../types.js"; -import {slashValidator} from "./slashValidator.js"; +import {getAttesterSlashableIndices, isSlashableAttestationData, isSlashableValidator} from "../util/index.js"; import {isValidIndexedAttestationBigint} from "./isValidIndexedAttestation.js"; +import {slashValidator} from "./slashValidator.js"; /** * Process an AttesterSlashing operation. Initiates the exit of a validator, decreases the balance of the slashed diff --git a/packages/state-transition/src/block/processBlockHeader.ts b/packages/state-transition/src/block/processBlockHeader.ts index da3e389fb507..b4e07ffd5f73 100644 --- a/packages/state-transition/src/block/processBlockHeader.ts +++ b/packages/state-transition/src/block/processBlockHeader.ts @@ -1,8 +1,8 @@ import {byteArrayEquals} from "@chainsafe/ssz"; import {BeaconBlock, BlindedBeaconBlock, ssz} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; -import {CachedBeaconStateAllForks} from "../types.js"; import {ZERO_HASH} from "../constants/index.js"; +import {CachedBeaconStateAllForks} from "../types.js"; import {blindedOrFullBlockToHeader} from "../util/index.js"; /** * Converts a Deposit record (created by the eth-execution deposit contract) into a Validator object that goes into the eth-consensus state. diff --git a/packages/state-transition/src/block/processBlsToExecutionChange.ts b/packages/state-transition/src/block/processBlsToExecutionChange.ts index be79f06f3f21..04be6371fe6d 100644 --- a/packages/state-transition/src/block/processBlsToExecutionChange.ts +++ b/packages/state-transition/src/block/processBlsToExecutionChange.ts @@ -1,7 +1,7 @@ -import {byteArrayEquals} from "@chainsafe/ssz"; import {digest} from "@chainsafe/as-sha256"; -import {capella} from "@lodestar/types"; +import {byteArrayEquals} from "@chainsafe/ssz"; import {BLS_WITHDRAWAL_PREFIX, ETH1_ADDRESS_WITHDRAWAL_PREFIX} from "@lodestar/params"; +import {capella} from "@lodestar/types"; import {toHex} from "@lodestar/utils"; import {verifyBlsToExecutionChangeSignature} from "../signatureSets/index.js"; diff --git a/packages/state-transition/src/block/processConsolidationRequest.ts b/packages/state-transition/src/block/processConsolidationRequest.ts index c14612579c58..d0650135d0c6 100644 --- a/packages/state-transition/src/block/processConsolidationRequest.ts +++ b/packages/state-transition/src/block/processConsolidationRequest.ts @@ -1,11 +1,11 @@ -import {electra, ssz} from "@lodestar/types"; import {FAR_FUTURE_EPOCH, MIN_ACTIVATION_BALANCE, PENDING_CONSOLIDATIONS_LIMIT} from "@lodestar/params"; +import {electra, ssz} from "@lodestar/types"; import {CachedBeaconStateElectra} from "../types.js"; -import {getConsolidationChurnLimit, isActiveValidator} from "../util/validator.js"; +import {hasEth1WithdrawalCredential} from "../util/capella.js"; import {hasExecutionWithdrawalCredential, switchToCompoundingValidator} from "../util/electra.js"; import {computeConsolidationEpochAndUpdateChurn} from "../util/epoch.js"; -import {hasEth1WithdrawalCredential} from "../util/capella.js"; +import {getConsolidationChurnLimit, isActiveValidator} from "../util/validator.js"; // TODO Electra: Clean up necessary as there is a lot of overlap with isValidSwitchToCompoundRequest export function processConsolidationRequest( diff --git a/packages/state-transition/src/block/processDeposit.ts b/packages/state-transition/src/block/processDeposit.ts index b7e9827c4cd7..23c5e6c9b26d 100644 --- a/packages/state-transition/src/block/processDeposit.ts +++ b/packages/state-transition/src/block/processDeposit.ts @@ -12,12 +12,12 @@ import { MAX_EFFECTIVE_BALANCE, } from "@lodestar/params"; -import {DepositData} from "@lodestar/types/lib/phase0/types.js"; -import {DepositRequest} from "@lodestar/types/lib/electra/types.js"; import {BeaconConfig} from "@lodestar/config"; +import {DepositRequest} from "@lodestar/types/lib/electra/types.js"; +import {DepositData} from "@lodestar/types/lib/phase0/types.js"; import {ZERO_HASH} from "../constants/index.js"; -import {computeDomain, computeSigningRoot, getMaxEffectiveBalance, increaseBalance} from "../util/index.js"; import {CachedBeaconStateAllForks, CachedBeaconStateAltair, CachedBeaconStateElectra} from "../types.js"; +import {computeDomain, computeSigningRoot, getMaxEffectiveBalance, increaseBalance} from "../util/index.js"; /** * Process a Deposit operation. Potentially adds a new validator to the registry. Mutates the validators and balances diff --git a/packages/state-transition/src/block/processDepositRequest.ts b/packages/state-transition/src/block/processDepositRequest.ts index 7c6ea4928f54..8a8b6c08eed8 100644 --- a/packages/state-transition/src/block/processDepositRequest.ts +++ b/packages/state-transition/src/block/processDepositRequest.ts @@ -1,5 +1,5 @@ -import {electra, ssz} from "@lodestar/types"; import {ForkSeq, UNSET_DEPOSIT_REQUESTS_START_INDEX} from "@lodestar/params"; +import {electra, ssz} from "@lodestar/types"; import {CachedBeaconStateElectra} from "../types.js"; diff --git a/packages/state-transition/src/block/processExecutionPayload.ts b/packages/state-transition/src/block/processExecutionPayload.ts index 3d70e46d40fd..3900583956ba 100644 --- a/packages/state-transition/src/block/processExecutionPayload.ts +++ b/packages/state-transition/src/block/processExecutionPayload.ts @@ -1,14 +1,14 @@ import {byteArrayEquals} from "@chainsafe/ssz"; -import {BeaconBlockBody, BlindedBeaconBlockBody, deneb, isExecutionPayload} from "@lodestar/types"; import {ForkSeq, MAX_BLOBS_PER_BLOCK} from "@lodestar/params"; +import {BeaconBlockBody, BlindedBeaconBlockBody, deneb, isExecutionPayload} from "@lodestar/types"; import {toHex, toRootHex} from "@lodestar/utils"; import {CachedBeaconStateBellatrix, CachedBeaconStateCapella} from "../types.js"; -import {getRandaoMix} from "../util/index.js"; import { - isMergeTransitionComplete, - getFullOrBlindedPayloadFromBody, executionPayloadToPayloadHeader, + getFullOrBlindedPayloadFromBody, + isMergeTransitionComplete, } from "../util/execution.js"; +import {getRandaoMix} from "../util/index.js"; import {BlockExternalData, ExecutionPayloadStatus} from "./externalData.js"; export function processExecutionPayload( diff --git a/packages/state-transition/src/block/processOperations.ts b/packages/state-transition/src/block/processOperations.ts index d611581584c1..165dcd10d4e2 100644 --- a/packages/state-transition/src/block/processOperations.ts +++ b/packages/state-transition/src/block/processOperations.ts @@ -1,18 +1,18 @@ -import {BeaconBlockBody, capella, electra} from "@lodestar/types"; import {ForkSeq} from "@lodestar/params"; +import {BeaconBlockBody, capella, electra} from "@lodestar/types"; import {CachedBeaconStateAllForks, CachedBeaconStateCapella, CachedBeaconStateElectra} from "../types.js"; import {getEth1DepositCount} from "../util/deposit.js"; import {processAttestations} from "./processAttestations.js"; -import {processProposerSlashing} from "./processProposerSlashing.js"; import {processAttesterSlashing} from "./processAttesterSlashing.js"; +import {processBlsToExecutionChange} from "./processBlsToExecutionChange.js"; +import {processConsolidationRequest} from "./processConsolidationRequest.js"; import {processDeposit} from "./processDeposit.js"; +import {processDepositRequest} from "./processDepositRequest.js"; +import {processProposerSlashing} from "./processProposerSlashing.js"; import {processVoluntaryExit} from "./processVoluntaryExit.js"; -import {processBlsToExecutionChange} from "./processBlsToExecutionChange.js"; import {processWithdrawalRequest} from "./processWithdrawalRequest.js"; -import {processDepositRequest} from "./processDepositRequest.js"; import {ProcessBlockOpts} from "./types.js"; -import {processConsolidationRequest} from "./processConsolidationRequest.js"; export { processProposerSlashing, diff --git a/packages/state-transition/src/block/processProposerSlashing.ts b/packages/state-transition/src/block/processProposerSlashing.ts index 70bd37092f98..c65fd567aa24 100644 --- a/packages/state-transition/src/block/processProposerSlashing.ts +++ b/packages/state-transition/src/block/processProposerSlashing.ts @@ -1,9 +1,9 @@ -import {phase0, ssz} from "@lodestar/types"; import {ForkSeq} from "@lodestar/params"; +import {phase0, ssz} from "@lodestar/types"; +import {getProposerSlashingSignatureSets} from "../signatureSets/index.js"; +import {CachedBeaconStateAllForks} from "../types.js"; import {isSlashableValidator} from "../util/index.js"; import {verifySignatureSet} from "../util/signatureSets.js"; -import {CachedBeaconStateAllForks} from "../types.js"; -import {getProposerSlashingSignatureSets} from "../signatureSets/index.js"; import {slashValidator} from "./slashValidator.js"; /** diff --git a/packages/state-transition/src/block/processRandao.ts b/packages/state-transition/src/block/processRandao.ts index 65bcd60f52f6..b32ec43b6768 100644 --- a/packages/state-transition/src/block/processRandao.ts +++ b/packages/state-transition/src/block/processRandao.ts @@ -1,9 +1,9 @@ import {digest} from "@chainsafe/as-sha256"; -import {BeaconBlock} from "@lodestar/types"; import {EPOCHS_PER_HISTORICAL_VECTOR} from "@lodestar/params"; -import {getRandaoMix} from "../util/index.js"; +import {BeaconBlock} from "@lodestar/types"; import {verifyRandaoSignature} from "../signatureSets/index.js"; import {CachedBeaconStateAllForks} from "../types.js"; +import {getRandaoMix} from "../util/index.js"; /** * Commit a randao reveal to generate pseudorandomness seeds diff --git a/packages/state-transition/src/block/processSyncCommittee.ts b/packages/state-transition/src/block/processSyncCommittee.ts index 5f81a984b677..eaa98ac72a8d 100644 --- a/packages/state-transition/src/block/processSyncCommittee.ts +++ b/packages/state-transition/src/block/processSyncCommittee.ts @@ -1,9 +1,9 @@ import {byteArrayEquals} from "@chainsafe/ssz"; -import {altair, ssz} from "@lodestar/types"; import {DOMAIN_SYNC_COMMITTEE, SYNC_COMMITTEE_SIZE} from "@lodestar/params"; -import {computeSigningRoot, ISignatureSet, SignatureSetType, verifySignatureSet} from "../util/index.js"; -import {CachedBeaconStateAllForks} from "../types.js"; +import {altair, ssz} from "@lodestar/types"; import {G2_POINT_AT_INFINITY} from "../constants/index.js"; +import {CachedBeaconStateAllForks} from "../types.js"; +import {ISignatureSet, SignatureSetType, computeSigningRoot, verifySignatureSet} from "../util/index.js"; import {decreaseBalance, increaseBalance} from "../util/index.js"; export function processSyncAggregate( diff --git a/packages/state-transition/src/block/processVoluntaryExit.ts b/packages/state-transition/src/block/processVoluntaryExit.ts index b08aa7800884..a0a0271a0d1e 100644 --- a/packages/state-transition/src/block/processVoluntaryExit.ts +++ b/packages/state-transition/src/block/processVoluntaryExit.ts @@ -1,8 +1,8 @@ import {FAR_FUTURE_EPOCH, ForkSeq} from "@lodestar/params"; import {phase0} from "@lodestar/types"; -import {getPendingBalanceToWithdraw, isActiveValidator} from "../util/index.js"; -import {CachedBeaconStateAllForks, CachedBeaconStateElectra} from "../types.js"; import {verifyVoluntaryExitSignature} from "../signatureSets/index.js"; +import {CachedBeaconStateAllForks, CachedBeaconStateElectra} from "../types.js"; +import {getPendingBalanceToWithdraw, isActiveValidator} from "../util/index.js"; import {initiateValidatorExit} from "./index.js"; /** diff --git a/packages/state-transition/src/block/processWithdrawalRequest.ts b/packages/state-transition/src/block/processWithdrawalRequest.ts index e8a64ec63e41..573c0a49dfc8 100644 --- a/packages/state-transition/src/block/processWithdrawalRequest.ts +++ b/packages/state-transition/src/block/processWithdrawalRequest.ts @@ -1,17 +1,17 @@ -import {electra, phase0, ssz} from "@lodestar/types"; import { FAR_FUTURE_EPOCH, - MIN_ACTIVATION_BALANCE, - PENDING_PARTIAL_WITHDRAWALS_LIMIT, FULL_EXIT_REQUEST_AMOUNT, ForkSeq, + MIN_ACTIVATION_BALANCE, + PENDING_PARTIAL_WITHDRAWALS_LIMIT, } from "@lodestar/params"; +import {electra, phase0, ssz} from "@lodestar/types"; import {toHex} from "@lodestar/utils"; import {CachedBeaconStateElectra} from "../types.js"; import {hasCompoundingWithdrawalCredential, hasExecutionWithdrawalCredential} from "../util/electra.js"; -import {getPendingBalanceToWithdraw, isActiveValidator} from "../util/validator.js"; import {computeExitEpochAndUpdateChurn} from "../util/epoch.js"; +import {getPendingBalanceToWithdraw, isActiveValidator} from "../util/validator.js"; import {initiateValidatorExit} from "./initiateValidatorExit.js"; export function processWithdrawalRequest( diff --git a/packages/state-transition/src/block/processWithdrawals.ts b/packages/state-transition/src/block/processWithdrawals.ts index 610a2ed62b41..ab1df570eb30 100644 --- a/packages/state-transition/src/block/processWithdrawals.ts +++ b/packages/state-transition/src/block/processWithdrawals.ts @@ -1,14 +1,14 @@ import {byteArrayEquals} from "@chainsafe/ssz"; -import {ssz, capella} from "@lodestar/types"; import { - MAX_WITHDRAWALS_PER_PAYLOAD, - MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP, + FAR_FUTURE_EPOCH, ForkSeq, + MAX_EFFECTIVE_BALANCE, MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP, - FAR_FUTURE_EPOCH, + MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP, + MAX_WITHDRAWALS_PER_PAYLOAD, MIN_ACTIVATION_BALANCE, - MAX_EFFECTIVE_BALANCE, } from "@lodestar/params"; +import {capella, ssz} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; import {CachedBeaconStateCapella, CachedBeaconStateElectra} from "../types.js"; diff --git a/packages/state-transition/src/block/slashValidator.ts b/packages/state-transition/src/block/slashValidator.ts index c4b7d5f848ea..2e1decec1e99 100644 --- a/packages/state-transition/src/block/slashValidator.ts +++ b/packages/state-transition/src/block/slashValidator.ts @@ -1,4 +1,3 @@ -import {ValidatorIndex} from "@lodestar/types"; import { EFFECTIVE_BALANCE_INCREMENT, EPOCHS_PER_SLASHINGS_VECTOR, @@ -14,9 +13,10 @@ import { WHISTLEBLOWER_REWARD_QUOTIENT, WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA, } from "@lodestar/params"; +import {ValidatorIndex} from "@lodestar/types"; -import {decreaseBalance, increaseBalance} from "../util/index.js"; import {CachedBeaconStateAllForks, CachedBeaconStateAltair} from "../types.js"; +import {decreaseBalance, increaseBalance} from "../util/index.js"; import {initiateValidatorExit} from "./initiateValidatorExit.js"; /** Same to https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.5/specs/altair/beacon-chain.md#has_flag */ diff --git a/packages/state-transition/src/cache/epochCache.ts b/packages/state-transition/src/cache/epochCache.ts index 66ce12b82d18..207267dff4f4 100644 --- a/packages/state-transition/src/cache/epochCache.ts +++ b/packages/state-transition/src/cache/epochCache.ts @@ -1,20 +1,6 @@ import {PublicKey} from "@chainsafe/blst"; -import * as immutable from "immutable"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; -import { - BLSSignature, - CommitteeIndex, - Epoch, - Slot, - ValidatorIndex, - phase0, - RootHex, - SyncPeriod, - Attestation, - IndexedAttestation, - electra, -} from "@lodestar/types"; -import {createBeaconConfig, BeaconConfig, ChainConfig} from "@lodestar/config"; +import {BeaconConfig, ChainConfig, createBeaconConfig} from "@lodestar/config"; import { ATTESTATION_SUBNET_COUNT, DOMAIN_BEACON_PROPOSER, @@ -26,47 +12,61 @@ import { SLOTS_PER_EPOCH, WEIGHT_DENOMINATOR, } from "@lodestar/params"; +import { + Attestation, + BLSSignature, + CommitteeIndex, + Epoch, + IndexedAttestation, + RootHex, + Slot, + SyncPeriod, + ValidatorIndex, + electra, + phase0, +} from "@lodestar/types"; import {LodestarError, fromHex} from "@lodestar/utils"; +import * as immutable from "immutable"; +import {getTotalSlashingsByIncrement} from "../epoch/processSlashings.js"; +import {EpochCacheMetrics} from "../metrics.js"; +import {AttesterDuty, calculateCommitteeAssignments} from "../util/calculateCommitteeAssignments.js"; +import { + EpochShuffling, + IShufflingCache, + calculateShufflingDecisionRoot, + computeEpochShuffling, +} from "../util/epochShuffling.js"; import { computeActivationExitEpoch, computeEpochAtSlot, + computeProposers, computeStartSlotAtEpoch, + computeSyncPeriodAtEpoch, + getActivationChurnLimit, getChurnLimit, + getSeed, isActiveValidator, isAggregatorFromCommitteeLength, - computeSyncPeriodAtEpoch, - getSeed, - computeProposers, - getActivationChurnLimit, } from "../util/index.js"; -import { - computeEpochShuffling, - EpochShuffling, - calculateShufflingDecisionRoot, - IShufflingCache, -} from "../util/epochShuffling.js"; import {computeBaseRewardPerIncrement, computeSyncParticipantReward} from "../util/syncCommittee.js"; import {sumTargetUnslashedBalanceIncrements} from "../util/targetUnslashedBalance.js"; -import {getTotalSlashingsByIncrement} from "../epoch/processSlashings.js"; -import {AttesterDuty, calculateCommitteeAssignments} from "../util/calculateCommitteeAssignments.js"; -import {EpochCacheMetrics} from "../metrics.js"; import {EffectiveBalanceIncrements, getEffectiveBalanceIncrementsWithLen} from "./effectiveBalanceIncrements.js"; -import {BeaconStateAllForks, BeaconStateAltair} from "./types.js"; import { Index2PubkeyCache, + PubkeyHex, UnfinalizedPubkeyIndexMap, + newUnfinalizedPubkeyIndexMap, syncPubkeys, toMemoryEfficientHexStr, - PubkeyHex, - newUnfinalizedPubkeyIndexMap, } from "./pubkeyCache.js"; +import {CachedBeaconStateAllForks} from "./stateCache.js"; import { - computeSyncCommitteeCache, - getSyncCommitteeCache, SyncCommitteeCache, SyncCommitteeCacheEmpty, + computeSyncCommitteeCache, + getSyncCommitteeCache, } from "./syncCommitteeCache.js"; -import {CachedBeaconStateAllForks} from "./stateCache.js"; +import {BeaconStateAllForks, BeaconStateAltair} from "./types.js"; /** `= PROPOSER_WEIGHT / (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT)` */ export const PROPOSER_WEIGHT_FACTOR = PROPOSER_WEIGHT / (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT); diff --git a/packages/state-transition/src/cache/epochTransitionCache.ts b/packages/state-transition/src/cache/epochTransitionCache.ts index 2a35317fbc93..d86431c72eee 100644 --- a/packages/state-transition/src/cache/epochTransitionCache.ts +++ b/packages/state-transition/src/cache/epochTransitionCache.ts @@ -1,27 +1,27 @@ -import {phase0, Epoch, RootHex, ValidatorIndex} from "@lodestar/types"; -import {intDiv, toRootHex} from "@lodestar/utils"; import { EPOCHS_PER_SLASHINGS_VECTOR, FAR_FUTURE_EPOCH, ForkSeq, - SLOTS_PER_HISTORICAL_ROOT, MIN_ACTIVATION_BALANCE, + SLOTS_PER_HISTORICAL_ROOT, } from "@lodestar/params"; +import {Epoch, RootHex, ValidatorIndex, phase0} from "@lodestar/types"; +import {intDiv, toRootHex} from "@lodestar/utils"; +import {processPendingAttestations} from "../epoch/processPendingAttestations.js"; +import {CachedBeaconStateAllForks, CachedBeaconStateAltair, CachedBeaconStatePhase0} from "../index.js"; +import {computeBaseRewardPerIncrement} from "../util/altair.js"; import { - hasMarkers, - FLAG_UNSLASHED, + FLAG_CURR_HEAD_ATTESTER, + FLAG_CURR_SOURCE_ATTESTER, + FLAG_CURR_TARGET_ATTESTER, FLAG_ELIGIBLE_ATTESTER, + FLAG_PREV_HEAD_ATTESTER, FLAG_PREV_SOURCE_ATTESTER, FLAG_PREV_TARGET_ATTESTER, - FLAG_PREV_HEAD_ATTESTER, - FLAG_CURR_SOURCE_ATTESTER, - FLAG_CURR_TARGET_ATTESTER, - FLAG_CURR_HEAD_ATTESTER, + FLAG_UNSLASHED, + hasMarkers, } from "../util/attesterStatus.js"; -import {CachedBeaconStateAllForks, CachedBeaconStateAltair, CachedBeaconStatePhase0} from "../index.js"; -import {computeBaseRewardPerIncrement} from "../util/altair.js"; -import {processPendingAttestations} from "../epoch/processPendingAttestations.js"; export type EpochTransitionCacheOpts = { /** diff --git a/packages/state-transition/src/cache/pubkeyCache.ts b/packages/state-transition/src/cache/pubkeyCache.ts index f96436ec14f4..16c8f3de6787 100644 --- a/packages/state-transition/src/cache/pubkeyCache.ts +++ b/packages/state-transition/src/cache/pubkeyCache.ts @@ -1,7 +1,7 @@ import {PublicKey} from "@chainsafe/blst"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; -import * as immutable from "immutable"; import {ValidatorIndex, phase0} from "@lodestar/types"; +import * as immutable from "immutable"; export type Index2PubkeyCache = PublicKey[]; /** diff --git a/packages/state-transition/src/cache/stateCache.ts b/packages/state-transition/src/cache/stateCache.ts index 3eeeb285b660..6690f8f5c3db 100644 --- a/packages/state-transition/src/cache/stateCache.ts +++ b/packages/state-transition/src/cache/stateCache.ts @@ -2,17 +2,17 @@ import {PublicKey} from "@chainsafe/blst"; import {BeaconConfig} from "@lodestar/config"; import {loadState} from "../util/loadState/loadState.js"; import {EpochCache, EpochCacheImmutableData, EpochCacheOpts} from "./epochCache.js"; +import {RewardCache, createEmptyRewardCache} from "./rewardCache.js"; import { BeaconStateAllForks, - BeaconStateExecutions, - BeaconStatePhase0, BeaconStateAltair, BeaconStateBellatrix, BeaconStateCapella, BeaconStateDeneb, BeaconStateElectra, + BeaconStateExecutions, + BeaconStatePhase0, } from "./types.js"; -import {RewardCache, createEmptyRewardCache} from "./rewardCache.js"; export type BeaconStateCache = { config: BeaconConfig; diff --git a/packages/state-transition/src/cache/syncCommitteeCache.ts b/packages/state-transition/src/cache/syncCommitteeCache.ts index b9a65302c3e2..3f79a45f3573 100644 --- a/packages/state-transition/src/cache/syncCommitteeCache.ts +++ b/packages/state-transition/src/cache/syncCommitteeCache.ts @@ -1,6 +1,6 @@ -import {CompositeViewDU} from "@chainsafe/ssz"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; -import {ssz, ValidatorIndex} from "@lodestar/types"; +import {CompositeViewDU} from "@chainsafe/ssz"; +import {ValidatorIndex, ssz} from "@lodestar/types"; import {toPubkeyHex} from "@lodestar/utils"; type SyncComitteeValidatorIndexMap = Map; diff --git a/packages/state-transition/src/cache/types.ts b/packages/state-transition/src/cache/types.ts index b3fe6fc8ed5b..625e47270782 100644 --- a/packages/state-transition/src/cache/types.ts +++ b/packages/state-transition/src/cache/types.ts @@ -1,6 +1,6 @@ import {CompositeViewDU} from "@chainsafe/ssz"; -import {Epoch, RootHex, SSZTypesFor} from "@lodestar/types"; import {ForkAll, ForkExecution, ForkName} from "@lodestar/params"; +import {Epoch, RootHex, SSZTypesFor} from "@lodestar/types"; import {EpochShuffling} from "../util/epochShuffling.js"; export type BeaconStatePhase0 = CompositeViewDU>; diff --git a/packages/state-transition/src/epoch/computeUnrealizedCheckpoints.ts b/packages/state-transition/src/epoch/computeUnrealizedCheckpoints.ts index 3baed0f42cbe..d93b4e4f6d10 100644 --- a/packages/state-transition/src/epoch/computeUnrealizedCheckpoints.ts +++ b/packages/state-transition/src/epoch/computeUnrealizedCheckpoints.ts @@ -1,10 +1,10 @@ import {ForkSeq, GENESIS_EPOCH} from "@lodestar/params"; import {phase0} from "@lodestar/types"; -import {CachedBeaconStateAllForks} from "../types.js"; import {beforeProcessEpoch} from "../cache/epochTransitionCache.js"; +import {CachedBeaconStateAllForks} from "../types.js"; import { - weighJustificationAndFinalization, processJustificationAndFinalization, + weighJustificationAndFinalization, } from "./processJustificationAndFinalization.js"; /** diff --git a/packages/state-transition/src/epoch/getAttestationDeltas.ts b/packages/state-transition/src/epoch/getAttestationDeltas.ts index dd69738a55b5..d9172fd69702 100644 --- a/packages/state-transition/src/epoch/getAttestationDeltas.ts +++ b/packages/state-transition/src/epoch/getAttestationDeltas.ts @@ -1,4 +1,3 @@ -import {bigIntSqrt, bnToNum} from "@lodestar/utils"; import { BASE_REWARD_FACTOR, EFFECTIVE_BALANCE_INCREMENT, @@ -6,10 +5,11 @@ import { MIN_EPOCHS_TO_INACTIVITY_PENALTY, PROPOSER_REWARD_QUOTIENT, } from "@lodestar/params"; +import {bigIntSqrt, bnToNum} from "@lodestar/utils"; import {BASE_REWARDS_PER_EPOCH as BASE_REWARDS_PER_EPOCH_CONST} from "../constants/index.js"; -import {newZeroedArray} from "../util/index.js"; -import {EpochTransitionCache, CachedBeaconStatePhase0} from "../types.js"; +import {CachedBeaconStatePhase0, EpochTransitionCache} from "../types.js"; import {hasMarkers} from "../util/attesterStatus.js"; +import {newZeroedArray} from "../util/index.js"; /** * Redefine constants in attesterStatus to improve performance diff --git a/packages/state-transition/src/epoch/getRewardsAndPenalties.ts b/packages/state-transition/src/epoch/getRewardsAndPenalties.ts index bf766fe4666a..c7619873c202 100644 --- a/packages/state-transition/src/epoch/getRewardsAndPenalties.ts +++ b/packages/state-transition/src/epoch/getRewardsAndPenalties.ts @@ -1,5 +1,6 @@ import { EFFECTIVE_BALANCE_INCREMENT, + ForkSeq, INACTIVITY_PENALTY_QUOTIENT_ALTAIR, INACTIVITY_PENALTY_QUOTIENT_BELLATRIX, PARTICIPATION_FLAG_WEIGHTS, @@ -7,7 +8,6 @@ import { TIMELY_SOURCE_FLAG_INDEX, TIMELY_TARGET_FLAG_INDEX, WEIGHT_DENOMINATOR, - ForkSeq, } from "@lodestar/params"; import {CachedBeaconStateAltair, EpochTransitionCache} from "../types.js"; import { diff --git a/packages/state-transition/src/epoch/index.ts b/packages/state-transition/src/epoch/index.ts index b0b1651321d5..50118f5d4949 100644 --- a/packages/state-transition/src/epoch/index.ts +++ b/packages/state-transition/src/epoch/index.ts @@ -5,15 +5,15 @@ import { MAX_VALIDATORS_PER_COMMITTEE, SLOTS_PER_EPOCH, } from "@lodestar/params"; +import {BeaconStateTransitionMetrics} from "../metrics.js"; import { CachedBeaconStateAllForks, - CachedBeaconStateCapella, CachedBeaconStateAltair, + CachedBeaconStateCapella, + CachedBeaconStateElectra, CachedBeaconStatePhase0, EpochTransitionCache, - CachedBeaconStateElectra, } from "../types.js"; -import {BeaconStateTransitionMetrics} from "../metrics.js"; import {processEffectiveBalanceUpdates} from "./processEffectiveBalanceUpdates.js"; import {processEth1DataReset} from "./processEth1DataReset.js"; import {processHistoricalRootsUpdate} from "./processHistoricalRootsUpdate.js"; @@ -22,14 +22,14 @@ import {processInactivityUpdates} from "./processInactivityUpdates.js"; import {processJustificationAndFinalization} from "./processJustificationAndFinalization.js"; import {processParticipationFlagUpdates} from "./processParticipationFlagUpdates.js"; import {processParticipationRecordUpdates} from "./processParticipationRecordUpdates.js"; +import {processPendingConsolidations} from "./processPendingConsolidations.js"; +import {processPendingDeposits} from "./processPendingDeposits.js"; import {processRandaoMixesReset} from "./processRandaoMixesReset.js"; import {processRegistryUpdates} from "./processRegistryUpdates.js"; import {processRewardsAndPenalties} from "./processRewardsAndPenalties.js"; import {processSlashings} from "./processSlashings.js"; import {processSlashingsReset} from "./processSlashingsReset.js"; import {processSyncCommitteeUpdates} from "./processSyncCommitteeUpdates.js"; -import {processPendingDeposits} from "./processPendingDeposits.js"; -import {processPendingConsolidations} from "./processPendingConsolidations.js"; // For spec tests export {getRewardsAndPenalties} from "./processRewardsAndPenalties.js"; diff --git a/packages/state-transition/src/epoch/processEffectiveBalanceUpdates.ts b/packages/state-transition/src/epoch/processEffectiveBalanceUpdates.ts index 1fe5c92eea1a..d55f37aba178 100644 --- a/packages/state-transition/src/epoch/processEffectiveBalanceUpdates.ts +++ b/packages/state-transition/src/epoch/processEffectiveBalanceUpdates.ts @@ -7,7 +7,7 @@ import { MAX_EFFECTIVE_BALANCE, TIMELY_TARGET_FLAG_INDEX, } from "@lodestar/params"; -import {EpochTransitionCache, CachedBeaconStateAllForks, BeaconStateAltair} from "../types.js"; +import {BeaconStateAltair, CachedBeaconStateAllForks, EpochTransitionCache} from "../types.js"; import {getMaxEffectiveBalance} from "../util/validator.js"; /** Same to https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.5/specs/altair/beacon-chain.md#has_flag */ diff --git a/packages/state-transition/src/epoch/processEth1DataReset.ts b/packages/state-transition/src/epoch/processEth1DataReset.ts index a16f865fdc07..d783389e2f24 100644 --- a/packages/state-transition/src/epoch/processEth1DataReset.ts +++ b/packages/state-transition/src/epoch/processEth1DataReset.ts @@ -1,6 +1,6 @@ import {EPOCHS_PER_ETH1_VOTING_PERIOD} from "@lodestar/params"; import {ssz} from "@lodestar/types"; -import {EpochTransitionCache, CachedBeaconStateAllForks} from "../types.js"; +import {CachedBeaconStateAllForks, EpochTransitionCache} from "../types.js"; /** * Reset eth1DataVotes tree every `EPOCHS_PER_ETH1_VOTING_PERIOD`. diff --git a/packages/state-transition/src/epoch/processHistoricalRootsUpdate.ts b/packages/state-transition/src/epoch/processHistoricalRootsUpdate.ts index e649e1c9678b..a396738fc840 100644 --- a/packages/state-transition/src/epoch/processHistoricalRootsUpdate.ts +++ b/packages/state-transition/src/epoch/processHistoricalRootsUpdate.ts @@ -1,7 +1,7 @@ import {SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params"; import {ssz} from "@lodestar/types"; import {intDiv} from "@lodestar/utils"; -import {EpochTransitionCache, CachedBeaconStateAllForks} from "../types.js"; +import {CachedBeaconStateAllForks, EpochTransitionCache} from "../types.js"; /** * Persist blockRoots and stateRoots to historicalRoots. diff --git a/packages/state-transition/src/epoch/processHistoricalSummariesUpdate.ts b/packages/state-transition/src/epoch/processHistoricalSummariesUpdate.ts index 17da010dfa91..38bdc591ef32 100644 --- a/packages/state-transition/src/epoch/processHistoricalSummariesUpdate.ts +++ b/packages/state-transition/src/epoch/processHistoricalSummariesUpdate.ts @@ -1,7 +1,7 @@ import {SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params"; import {ssz} from "@lodestar/types"; import {intDiv} from "@lodestar/utils"; -import {EpochTransitionCache, CachedBeaconStateCapella} from "../types.js"; +import {CachedBeaconStateCapella, EpochTransitionCache} from "../types.js"; /** * Persist blockRoots and stateRoots to historicalSummaries. diff --git a/packages/state-transition/src/epoch/processJustificationAndFinalization.ts b/packages/state-transition/src/epoch/processJustificationAndFinalization.ts index 8526b7f3a749..845a98337be7 100644 --- a/packages/state-transition/src/epoch/processJustificationAndFinalization.ts +++ b/packages/state-transition/src/epoch/processJustificationAndFinalization.ts @@ -1,8 +1,8 @@ import {BitArray} from "@chainsafe/ssz"; import {GENESIS_EPOCH} from "@lodestar/params"; import {ssz} from "@lodestar/types"; -import {computeEpochAtSlot, getBlockRoot} from "../util/index.js"; import {CachedBeaconStateAllForks, EpochTransitionCache} from "../types.js"; +import {computeEpochAtSlot, getBlockRoot} from "../util/index.js"; /** * Update justified and finalized checkpoints depending on network participation. diff --git a/packages/state-transition/src/epoch/processPendingDeposits.ts b/packages/state-transition/src/epoch/processPendingDeposits.ts index 53af3ab38763..866dcc2510ad 100644 --- a/packages/state-transition/src/epoch/processPendingDeposits.ts +++ b/packages/state-transition/src/epoch/processPendingDeposits.ts @@ -1,10 +1,10 @@ import {FAR_FUTURE_EPOCH, ForkSeq, GENESIS_SLOT, MAX_PENDING_DEPOSITS_PER_EPOCH} from "@lodestar/params"; import {PendingDeposit} from "@lodestar/types/lib/electra/types.js"; +import {addValidatorToRegistry, isValidDepositSignature} from "../block/processDeposit.js"; import {CachedBeaconStateElectra, EpochTransitionCache} from "../types.js"; import {increaseBalance} from "../util/balance.js"; -import {getActivationExitChurnLimit} from "../util/validator.js"; import {computeStartSlotAtEpoch} from "../util/epoch.js"; -import {addValidatorToRegistry, isValidDepositSignature} from "../block/processDeposit.js"; +import {getActivationExitChurnLimit} from "../util/validator.js"; /** * Starting from Electra: diff --git a/packages/state-transition/src/epoch/processRandaoMixesReset.ts b/packages/state-transition/src/epoch/processRandaoMixesReset.ts index afb45ba39d19..d50ae1261778 100644 --- a/packages/state-transition/src/epoch/processRandaoMixesReset.ts +++ b/packages/state-transition/src/epoch/processRandaoMixesReset.ts @@ -1,5 +1,5 @@ import {EPOCHS_PER_HISTORICAL_VECTOR} from "@lodestar/params"; -import {EpochTransitionCache, CachedBeaconStateAllForks} from "../types.js"; +import {CachedBeaconStateAllForks, EpochTransitionCache} from "../types.js"; /** * Write next randaoMix diff --git a/packages/state-transition/src/epoch/processRegistryUpdates.ts b/packages/state-transition/src/epoch/processRegistryUpdates.ts index d2e93632dabe..05b3b2c8f9ed 100644 --- a/packages/state-transition/src/epoch/processRegistryUpdates.ts +++ b/packages/state-transition/src/epoch/processRegistryUpdates.ts @@ -1,7 +1,7 @@ import {ForkSeq} from "@lodestar/params"; -import {computeActivationExitEpoch} from "../util/index.js"; import {initiateValidatorExit} from "../block/index.js"; -import {EpochTransitionCache, CachedBeaconStateAllForks} from "../types.js"; +import {CachedBeaconStateAllForks, EpochTransitionCache} from "../types.js"; +import {computeActivationExitEpoch} from "../util/index.js"; /** * Update validator registry for validators that activate + exit diff --git a/packages/state-transition/src/epoch/processSlashings.ts b/packages/state-transition/src/epoch/processSlashings.ts index 23ee815cabb3..09b93b21042d 100644 --- a/packages/state-transition/src/epoch/processSlashings.ts +++ b/packages/state-transition/src/epoch/processSlashings.ts @@ -6,8 +6,8 @@ import { PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX, } from "@lodestar/params"; -import {decreaseBalance} from "../util/index.js"; import {BeaconStateAllForks, CachedBeaconStateAllForks, EpochTransitionCache} from "../types.js"; +import {decreaseBalance} from "../util/index.js"; /** * Update validator registry for validators that activate + exit diff --git a/packages/state-transition/src/epoch/processSlashingsReset.ts b/packages/state-transition/src/epoch/processSlashingsReset.ts index 6ab22d47526c..68857b266db7 100644 --- a/packages/state-transition/src/epoch/processSlashingsReset.ts +++ b/packages/state-transition/src/epoch/processSlashingsReset.ts @@ -1,5 +1,5 @@ import {EFFECTIVE_BALANCE_INCREMENT, EPOCHS_PER_SLASHINGS_VECTOR} from "@lodestar/params"; -import {EpochTransitionCache, CachedBeaconStateAllForks} from "../types.js"; +import {CachedBeaconStateAllForks, EpochTransitionCache} from "../types.js"; /** * Reset the next slashings balance accumulator diff --git a/packages/state-transition/src/epoch/processSyncCommitteeUpdates.ts b/packages/state-transition/src/epoch/processSyncCommitteeUpdates.ts index f01f2055420a..4d8106328958 100644 --- a/packages/state-transition/src/epoch/processSyncCommitteeUpdates.ts +++ b/packages/state-transition/src/epoch/processSyncCommitteeUpdates.ts @@ -1,8 +1,8 @@ import {aggregateSerializedPublicKeys} from "@chainsafe/blst"; import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, ForkSeq} from "@lodestar/params"; import {ssz} from "@lodestar/types"; -import {getNextSyncCommitteeIndices} from "../util/seed.js"; import {CachedBeaconStateAltair} from "../types.js"; +import {getNextSyncCommitteeIndices} from "../util/seed.js"; /** * Rotate nextSyncCommittee to currentSyncCommittee if sync committee period is over. diff --git a/packages/state-transition/src/metrics.ts b/packages/state-transition/src/metrics.ts index ac558a1be139..fee20de1d565 100644 --- a/packages/state-transition/src/metrics.ts +++ b/packages/state-transition/src/metrics.ts @@ -1,8 +1,8 @@ import {Epoch} from "@lodestar/types"; import {Gauge, Histogram} from "@lodestar/utils"; -import {CachedBeaconStateAllForks} from "./types.js"; -import {StateCloneSource, StateHashTreeRootSource} from "./stateTransition.js"; import {EpochTransitionStep} from "./epoch/index.js"; +import {StateCloneSource, StateHashTreeRootSource} from "./stateTransition.js"; +import {CachedBeaconStateAllForks} from "./types.js"; export type BeaconStateTransitionMetrics = { epochTransitionTime: Histogram; diff --git a/packages/state-transition/src/signatureSets/attesterSlashings.ts b/packages/state-transition/src/signatureSets/attesterSlashings.ts index 36f31d97e083..b053bb497805 100644 --- a/packages/state-transition/src/signatureSets/attesterSlashings.ts +++ b/packages/state-transition/src/signatureSets/attesterSlashings.ts @@ -1,7 +1,7 @@ -import {SignedBeaconBlock, ssz, AttesterSlashing, IndexedAttestationBigint} from "@lodestar/types"; import {DOMAIN_BEACON_ATTESTER} from "@lodestar/params"; -import {computeSigningRoot, computeStartSlotAtEpoch, ISignatureSet, SignatureSetType} from "../util/index.js"; +import {AttesterSlashing, IndexedAttestationBigint, SignedBeaconBlock, ssz} from "@lodestar/types"; import {CachedBeaconStateAllForks} from "../types.js"; +import {ISignatureSet, SignatureSetType, computeSigningRoot, computeStartSlotAtEpoch} from "../util/index.js"; /** Get signature sets from all AttesterSlashing objects in a block */ export function getAttesterSlashingsSignatureSets( diff --git a/packages/state-transition/src/signatureSets/blsToExecutionChange.ts b/packages/state-transition/src/signatureSets/blsToExecutionChange.ts index 672ad546dfc8..22a5826c4a3a 100644 --- a/packages/state-transition/src/signatureSets/blsToExecutionChange.ts +++ b/packages/state-transition/src/signatureSets/blsToExecutionChange.ts @@ -1,10 +1,10 @@ import {PublicKey} from "@chainsafe/blst"; +import {BeaconConfig} from "@lodestar/config"; import {DOMAIN_BLS_TO_EXECUTION_CHANGE, ForkName} from "@lodestar/params"; import {capella, ssz} from "@lodestar/types"; -import {BeaconConfig} from "@lodestar/config"; -import {computeSigningRoot, ISignatureSet, SignatureSetType, verifySignatureSet} from "../util/index.js"; import {CachedBeaconStateAllForks} from "../types.js"; +import {ISignatureSet, SignatureSetType, computeSigningRoot, verifySignatureSet} from "../util/index.js"; export function verifyBlsToExecutionChangeSignature( state: CachedBeaconStateAllForks, diff --git a/packages/state-transition/src/signatureSets/index.ts b/packages/state-transition/src/signatureSets/index.ts index c883bb0587f8..ac10abef6b34 100644 --- a/packages/state-transition/src/signatureSets/index.ts +++ b/packages/state-transition/src/signatureSets/index.ts @@ -1,15 +1,15 @@ import {ForkSeq} from "@lodestar/params"; import {SignedBeaconBlock, altair, capella} from "@lodestar/types"; -import {ISignatureSet} from "../util/index.js"; -import {CachedBeaconStateAllForks, CachedBeaconStateAltair} from "../types.js"; import {getSyncCommitteeSignatureSet} from "../block/processSyncCommittee.js"; -import {getProposerSlashingsSignatureSets} from "./proposerSlashings.js"; +import {CachedBeaconStateAllForks, CachedBeaconStateAltair} from "../types.js"; +import {ISignatureSet} from "../util/index.js"; import {getAttesterSlashingsSignatureSets} from "./attesterSlashings.js"; +import {getBlsToExecutionChangeSignatureSets} from "./blsToExecutionChange.js"; import {getAttestationsSignatureSets} from "./indexedAttestation.js"; import {getBlockProposerSignatureSet} from "./proposer.js"; +import {getProposerSlashingsSignatureSets} from "./proposerSlashings.js"; import {getRandaoRevealSignatureSet} from "./randao.js"; import {getVoluntaryExitsSignatureSets} from "./voluntaryExits.js"; -import {getBlsToExecutionChangeSignatureSets} from "./blsToExecutionChange.js"; export * from "./attesterSlashings.js"; export * from "./indexedAttestation.js"; diff --git a/packages/state-transition/src/signatureSets/indexedAttestation.ts b/packages/state-transition/src/signatureSets/indexedAttestation.ts index 86535fece8b8..2a0765ee60c1 100644 --- a/packages/state-transition/src/signatureSets/indexedAttestation.ts +++ b/packages/state-transition/src/signatureSets/indexedAttestation.ts @@ -1,12 +1,12 @@ import {DOMAIN_BEACON_ATTESTER} from "@lodestar/params"; import {SignedBeaconBlock, phase0, ssz} from "@lodestar/types"; +import {CachedBeaconStateAllForks} from "../types.js"; import { + ISignatureSet, computeSigningRoot, computeStartSlotAtEpoch, createAggregateSignatureSetFromComponents, - ISignatureSet, } from "../util/index.js"; -import {CachedBeaconStateAllForks} from "../types.js"; export function getAttestationDataSigningRoot( state: CachedBeaconStateAllForks, diff --git a/packages/state-transition/src/signatureSets/proposer.ts b/packages/state-transition/src/signatureSets/proposer.ts index e5ae7fd1f6f1..dd662931815f 100644 --- a/packages/state-transition/src/signatureSets/proposer.ts +++ b/packages/state-transition/src/signatureSets/proposer.ts @@ -1,8 +1,8 @@ import {DOMAIN_BEACON_PROPOSER} from "@lodestar/params"; import {SignedBeaconBlock, SignedBlindedBeaconBlock, isBlindedBeaconBlock, phase0, ssz} from "@lodestar/types"; +import {CachedBeaconStateAllForks} from "../types.js"; import {computeSigningRoot} from "../util/index.js"; import {ISignatureSet, SignatureSetType, verifySignatureSet} from "../util/signatureSets.js"; -import {CachedBeaconStateAllForks} from "../types.js"; export function verifyProposerSignature( state: CachedBeaconStateAllForks, diff --git a/packages/state-transition/src/signatureSets/proposerSlashings.ts b/packages/state-transition/src/signatureSets/proposerSlashings.ts index b0c1aa465bd5..d21c0906c511 100644 --- a/packages/state-transition/src/signatureSets/proposerSlashings.ts +++ b/packages/state-transition/src/signatureSets/proposerSlashings.ts @@ -1,7 +1,7 @@ import {DOMAIN_BEACON_PROPOSER} from "@lodestar/params"; import {SignedBeaconBlock, phase0, ssz} from "@lodestar/types"; -import {computeSigningRoot, ISignatureSet, SignatureSetType} from "../util/index.js"; import {CachedBeaconStateAllForks} from "../types.js"; +import {ISignatureSet, SignatureSetType, computeSigningRoot} from "../util/index.js"; /** * Extract signatures to allow validating all block signatures at once diff --git a/packages/state-transition/src/signatureSets/randao.ts b/packages/state-transition/src/signatureSets/randao.ts index 41422a9c1d00..495212f6aa2f 100644 --- a/packages/state-transition/src/signatureSets/randao.ts +++ b/packages/state-transition/src/signatureSets/randao.ts @@ -1,13 +1,13 @@ import {DOMAIN_RANDAO} from "@lodestar/params"; import {BeaconBlock, ssz} from "@lodestar/types"; +import {CachedBeaconStateAllForks} from "../types.js"; import { - computeEpochAtSlot, - computeSigningRoot, ISignatureSet, SignatureSetType, + computeEpochAtSlot, + computeSigningRoot, verifySignatureSet, } from "../util/index.js"; -import {CachedBeaconStateAllForks} from "../types.js"; export function verifyRandaoSignature(state: CachedBeaconStateAllForks, block: BeaconBlock): boolean { return verifySignatureSet(getRandaoRevealSignatureSet(state, block)); diff --git a/packages/state-transition/src/signatureSets/voluntaryExits.ts b/packages/state-transition/src/signatureSets/voluntaryExits.ts index 51dd20d671b6..9fae3f920da0 100644 --- a/packages/state-transition/src/signatureSets/voluntaryExits.ts +++ b/packages/state-transition/src/signatureSets/voluntaryExits.ts @@ -1,12 +1,12 @@ import {SignedBeaconBlock, phase0, ssz} from "@lodestar/types"; +import {CachedBeaconStateAllForks} from "../types.js"; import { - computeSigningRoot, - computeStartSlotAtEpoch, ISignatureSet, SignatureSetType, + computeSigningRoot, + computeStartSlotAtEpoch, verifySignatureSet, } from "../util/index.js"; -import {CachedBeaconStateAllForks} from "../types.js"; export function verifyVoluntaryExitSignature( state: CachedBeaconStateAllForks, diff --git a/packages/state-transition/src/slot/index.ts b/packages/state-transition/src/slot/index.ts index b05bd7ac93f2..0f2fa471f2f0 100644 --- a/packages/state-transition/src/slot/index.ts +++ b/packages/state-transition/src/slot/index.ts @@ -1,7 +1,7 @@ import {byteArrayEquals} from "@chainsafe/ssz"; import {SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params"; -import {CachedBeaconStateAllForks} from "../types.js"; import {ZERO_HASH} from "../constants/index.js"; +import {CachedBeaconStateAllForks} from "../types.js"; export {upgradeStateToAltair} from "./upgradeStateToAltair.js"; export {upgradeStateToBellatrix} from "./upgradeStateToBellatrix.js"; diff --git a/packages/state-transition/src/slot/upgradeStateToAltair.ts b/packages/state-transition/src/slot/upgradeStateToAltair.ts index 22ab8b13882c..ec6661d0d7ad 100644 --- a/packages/state-transition/src/slot/upgradeStateToAltair.ts +++ b/packages/state-transition/src/slot/upgradeStateToAltair.ts @@ -1,12 +1,12 @@ import {CompositeViewDU} from "@chainsafe/ssz"; -import {ssz} from "@lodestar/types"; import {ForkSeq} from "@lodestar/params"; -import {CachedBeaconStatePhase0, CachedBeaconStateAltair} from "../types.js"; -import {newZeroedArray, RootCache} from "../util/index.js"; +import {ssz} from "@lodestar/types"; +import {getAttestationParticipationStatus} from "../block/processAttestationsAltair.js"; +import {getCachedBeaconState} from "../cache/stateCache.js"; +import {CachedBeaconStateAltair, CachedBeaconStatePhase0} from "../types.js"; +import {RootCache, newZeroedArray} from "../util/index.js"; import {getNextSyncCommittee} from "../util/syncCommittee.js"; import {sumTargetUnslashedBalanceIncrements} from "../util/targetUnslashedBalance.js"; -import {getCachedBeaconState} from "../cache/stateCache.js"; -import {getAttestationParticipationStatus} from "../block/processAttestationsAltair.js"; /** * Upgrade a state from phase0 to altair. diff --git a/packages/state-transition/src/slot/upgradeStateToBellatrix.ts b/packages/state-transition/src/slot/upgradeStateToBellatrix.ts index abcaed50a749..969357279d4a 100644 --- a/packages/state-transition/src/slot/upgradeStateToBellatrix.ts +++ b/packages/state-transition/src/slot/upgradeStateToBellatrix.ts @@ -1,6 +1,6 @@ import {ssz} from "@lodestar/types"; -import {CachedBeaconStateAltair, CachedBeaconStateBellatrix} from "../types.js"; import {getCachedBeaconState} from "../cache/stateCache.js"; +import {CachedBeaconStateAltair, CachedBeaconStateBellatrix} from "../types.js"; /** * Upgrade a state from altair to bellatrix. diff --git a/packages/state-transition/src/slot/upgradeStateToCapella.ts b/packages/state-transition/src/slot/upgradeStateToCapella.ts index 30a0701e58e8..06f30ec0360a 100644 --- a/packages/state-transition/src/slot/upgradeStateToCapella.ts +++ b/packages/state-transition/src/slot/upgradeStateToCapella.ts @@ -1,6 +1,6 @@ import {ssz} from "@lodestar/types"; -import {CachedBeaconStateBellatrix, CachedBeaconStateCapella} from "../types.js"; import {getCachedBeaconState} from "../cache/stateCache.js"; +import {CachedBeaconStateBellatrix, CachedBeaconStateCapella} from "../types.js"; /** * Upgrade a state from bellatrix to capella. diff --git a/packages/state-transition/src/slot/upgradeStateToDeneb.ts b/packages/state-transition/src/slot/upgradeStateToDeneb.ts index 2344a8d4e08e..158b66db4e71 100644 --- a/packages/state-transition/src/slot/upgradeStateToDeneb.ts +++ b/packages/state-transition/src/slot/upgradeStateToDeneb.ts @@ -1,6 +1,6 @@ import {ssz} from "@lodestar/types"; -import {CachedBeaconStateDeneb} from "../types.js"; import {getCachedBeaconState} from "../cache/stateCache.js"; +import {CachedBeaconStateDeneb} from "../types.js"; import {CachedBeaconStateCapella} from "../types.js"; /** diff --git a/packages/state-transition/src/slot/upgradeStateToElectra.ts b/packages/state-transition/src/slot/upgradeStateToElectra.ts index a3c8981ab13f..f030f9d572fe 100644 --- a/packages/state-transition/src/slot/upgradeStateToElectra.ts +++ b/packages/state-transition/src/slot/upgradeStateToElectra.ts @@ -1,11 +1,11 @@ -import {Epoch, ValidatorIndex, ssz} from "@lodestar/types"; import {FAR_FUTURE_EPOCH, GENESIS_SLOT, UNSET_DEPOSIT_REQUESTS_START_INDEX} from "@lodestar/params"; -import {CachedBeaconStateDeneb} from "../types.js"; +import {Epoch, ValidatorIndex, ssz} from "@lodestar/types"; import {CachedBeaconStateElectra, getCachedBeaconState} from "../cache/stateCache.js"; +import {G2_POINT_AT_INFINITY} from "../constants/constants.js"; +import {CachedBeaconStateDeneb} from "../types.js"; import {hasCompoundingWithdrawalCredential, queueExcessActiveBalance} from "../util/electra.js"; import {computeActivationExitEpoch} from "../util/epoch.js"; import {getActivationExitChurnLimit, getConsolidationChurnLimit} from "../util/validator.js"; -import {G2_POINT_AT_INFINITY} from "../constants/constants.js"; /** * Upgrade a state from Deneb to Electra. diff --git a/packages/state-transition/src/stateTransition.ts b/packages/state-transition/src/stateTransition.ts index f025c685b1a6..929a37468c6e 100644 --- a/packages/state-transition/src/stateTransition.ts +++ b/packages/state-transition/src/stateTransition.ts @@ -1,17 +1,12 @@ -import {SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, ssz} from "@lodestar/types"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; +import {SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, ssz} from "@lodestar/types"; import {toRootHex} from "@lodestar/utils"; +import {BlockExternalData, DataAvailableStatus, ExecutionPayloadStatus} from "./block/externalData.js"; +import {processBlock} from "./block/index.js"; +import {ProcessBlockOpts} from "./block/types.js"; +import {EpochTransitionCache, EpochTransitionCacheOpts, beforeProcessEpoch} from "./cache/epochTransitionCache.js"; +import {EpochTransitionStep, processEpoch} from "./epoch/index.js"; import {BeaconStateTransitionMetrics, onPostStateMetrics, onStateCloneMetrics} from "./metrics.js"; -import {beforeProcessEpoch, EpochTransitionCache, EpochTransitionCacheOpts} from "./cache/epochTransitionCache.js"; -import { - CachedBeaconStateAllForks, - CachedBeaconStatePhase0, - CachedBeaconStateAltair, - CachedBeaconStateBellatrix, - CachedBeaconStateCapella, - CachedBeaconStateDeneb, -} from "./types.js"; -import {computeEpochAtSlot} from "./util/index.js"; import {verifyProposerSignature} from "./signatureSets/index.js"; import { processSlot, @@ -21,10 +16,15 @@ import { upgradeStateToDeneb, upgradeStateToElectra, } from "./slot/index.js"; -import {processBlock} from "./block/index.js"; -import {EpochTransitionStep, processEpoch} from "./epoch/index.js"; -import {BlockExternalData, DataAvailableStatus, ExecutionPayloadStatus} from "./block/externalData.js"; -import {ProcessBlockOpts} from "./block/types.js"; +import { + CachedBeaconStateAllForks, + CachedBeaconStateAltair, + CachedBeaconStateBellatrix, + CachedBeaconStateCapella, + CachedBeaconStateDeneb, + CachedBeaconStatePhase0, +} from "./types.js"; +import {computeEpochAtSlot} from "./util/index.js"; // Multifork capable state transition diff --git a/packages/state-transition/src/util/aggregator.ts b/packages/state-transition/src/util/aggregator.ts index 02afda67cc42..dc4e140bb4cd 100644 --- a/packages/state-transition/src/util/aggregator.ts +++ b/packages/state-transition/src/util/aggregator.ts @@ -1,12 +1,12 @@ import {digest} from "@chainsafe/as-sha256"; -import {BLSSignature} from "@lodestar/types"; -import {intDiv, bytesToBigInt} from "@lodestar/utils"; import { - TARGET_AGGREGATORS_PER_COMMITTEE, SYNC_COMMITTEE_SIZE, SYNC_COMMITTEE_SUBNET_COUNT, + TARGET_AGGREGATORS_PER_COMMITTEE, TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE, } from "@lodestar/params"; +import {BLSSignature} from "@lodestar/types"; +import {bytesToBigInt, intDiv} from "@lodestar/utils"; const ZERO_BIGINT = BigInt(0); diff --git a/packages/state-transition/src/util/attestation.ts b/packages/state-transition/src/util/attestation.ts index cfa8f512e7d5..f45011b1e838 100644 --- a/packages/state-transition/src/util/attestation.ts +++ b/packages/state-transition/src/util/attestation.ts @@ -1,5 +1,5 @@ import {MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH} from "@lodestar/params"; -import {phase0, Slot, ssz, ValidatorIndex} from "@lodestar/types"; +import {Slot, ValidatorIndex, phase0, ssz} from "@lodestar/types"; /** * Check if [[data1]] and [[data2]] are slashable according to Casper FFG rules. diff --git a/packages/state-transition/src/util/blindedBlock.ts b/packages/state-transition/src/util/blindedBlock.ts index 1793ff37255e..7d25fb25e22c 100644 --- a/packages/state-transition/src/util/blindedBlock.ts +++ b/packages/state-transition/src/util/blindedBlock.ts @@ -1,20 +1,20 @@ import {ChainForkConfig} from "@lodestar/config"; import {ForkExecution, ForkSeq} from "@lodestar/params"; import { - Root, - isBlindedBeaconBlock, - isExecutionPayloadAndBlobsBundle, BeaconBlock, BeaconBlockHeader, - SignedBeaconBlock, + BlindedBeaconBlock, + BlobsBundle, + Contents, ExecutionPayload, ExecutionPayloadAndBlobsBundle, - BlobsBundle, + ExecutionPayloadHeader, + Root, + SignedBeaconBlock, SignedBeaconBlockOrContents, - Contents, SignedBlindedBeaconBlock, - BlindedBeaconBlock, - ExecutionPayloadHeader, + isBlindedBeaconBlock, + isExecutionPayloadAndBlobsBundle, } from "@lodestar/types"; import {executionPayloadToPayloadHeader} from "./execution.js"; diff --git a/packages/state-transition/src/util/blockRoot.ts b/packages/state-transition/src/util/blockRoot.ts index 54d96885e675..c446c9dec386 100644 --- a/packages/state-transition/src/util/blockRoot.ts +++ b/packages/state-transition/src/util/blockRoot.ts @@ -1,14 +1,14 @@ +import {ChainForkConfig} from "@lodestar/config"; +import {SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params"; import { + BeaconBlock, + BeaconBlockHeader, Epoch, - Slot, Root, - BeaconBlock, SignedBeaconBlock, - BeaconBlockHeader, SignedBeaconBlockHeader, + Slot, } from "@lodestar/types"; -import {ChainForkConfig} from "@lodestar/config"; -import {SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params"; import {ZERO_HASH} from "../constants/index.js"; import {BeaconStateAllForks} from "../types.js"; import {computeStartSlotAtEpoch} from "./epoch.js"; diff --git a/packages/state-transition/src/util/calculateCommitteeAssignments.ts b/packages/state-transition/src/util/calculateCommitteeAssignments.ts index 992c5efbdaaa..008161afa04b 100644 --- a/packages/state-transition/src/util/calculateCommitteeAssignments.ts +++ b/packages/state-transition/src/util/calculateCommitteeAssignments.ts @@ -1,5 +1,5 @@ -import {CommitteeIndex, Slot, ValidatorIndex} from "@lodestar/types"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; +import {CommitteeIndex, Slot, ValidatorIndex} from "@lodestar/types"; import {EpochShuffling} from "./epochShuffling.js"; // Copied from lodestar-api package to avoid depending on the package diff --git a/packages/state-transition/src/util/computeAnchorCheckpoint.ts b/packages/state-transition/src/util/computeAnchorCheckpoint.ts index e37ffc2c632d..1edb2ac57ca2 100644 --- a/packages/state-transition/src/util/computeAnchorCheckpoint.ts +++ b/packages/state-transition/src/util/computeAnchorCheckpoint.ts @@ -1,6 +1,6 @@ import {ChainForkConfig} from "@lodestar/config"; -import {ssz, phase0} from "@lodestar/types"; import {GENESIS_SLOT, ZERO_HASH} from "@lodestar/params"; +import {phase0, ssz} from "@lodestar/types"; import {BeaconStateAllForks} from "../types.js"; import {blockToHeader} from "./blockRoot.js"; import {computeCheckpointEpochAtStateSlot} from "./epoch.js"; diff --git a/packages/state-transition/src/util/domain.ts b/packages/state-transition/src/util/domain.ts index b84e5bca44f4..1368834aaa2f 100644 --- a/packages/state-transition/src/util/domain.ts +++ b/packages/state-transition/src/util/domain.ts @@ -1,4 +1,4 @@ -import {Epoch, Version, Root, DomainType, phase0, ssz} from "@lodestar/types"; +import {DomainType, Epoch, Root, Version, phase0, ssz} from "@lodestar/types"; // Only used by processDeposit + lightclient /** diff --git a/packages/state-transition/src/util/electra.ts b/packages/state-transition/src/util/electra.ts index f1082c6d4603..f5b899eadcab 100644 --- a/packages/state-transition/src/util/electra.ts +++ b/packages/state-transition/src/util/electra.ts @@ -1,7 +1,7 @@ import {COMPOUNDING_WITHDRAWAL_PREFIX, GENESIS_SLOT, MIN_ACTIVATION_BALANCE} from "@lodestar/params"; import {ValidatorIndex, ssz} from "@lodestar/types"; -import {CachedBeaconStateElectra} from "../types.js"; import {G2_POINT_AT_INFINITY} from "../constants/constants.js"; +import {CachedBeaconStateElectra} from "../types.js"; import {hasEth1WithdrawalCredential} from "./capella.js"; export function hasCompoundingWithdrawalCredential(withdrawalCredentials: Uint8Array): boolean { diff --git a/packages/state-transition/src/util/epoch.ts b/packages/state-transition/src/util/epoch.ts index 7fed5e53f1f3..cc95d0d192f6 100644 --- a/packages/state-transition/src/util/epoch.ts +++ b/packages/state-transition/src/util/epoch.ts @@ -1,5 +1,5 @@ import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, GENESIS_EPOCH, MAX_SEED_LOOKAHEAD, SLOTS_PER_EPOCH} from "@lodestar/params"; -import {BeaconState, Epoch, Slot, SyncPeriod, Gwei} from "@lodestar/types"; +import {BeaconState, Epoch, Gwei, Slot, SyncPeriod} from "@lodestar/types"; import {CachedBeaconStateElectra} from "../types.js"; import {getActivationExitChurnLimit, getConsolidationChurnLimit} from "./validator.js"; diff --git a/packages/state-transition/src/util/epochShuffling.ts b/packages/state-transition/src/util/epochShuffling.ts index 6f63a2f4f5f8..6d0acbd32455 100644 --- a/packages/state-transition/src/util/epochShuffling.ts +++ b/packages/state-transition/src/util/epochShuffling.ts @@ -1,20 +1,20 @@ import {asyncUnshuffleList, unshuffleList} from "@chainsafe/swap-or-not-shuffle"; -import {Epoch, RootHex, ssz, ValidatorIndex} from "@lodestar/types"; -import {GaugeExtra, intDiv, Logger, NoLabels, toRootHex} from "@lodestar/utils"; +import {BeaconConfig} from "@lodestar/config"; import { DOMAIN_BEACON_ATTESTER, GENESIS_SLOT, MAX_COMMITTEES_PER_SLOT, + SHUFFLE_ROUND_COUNT, SLOTS_PER_EPOCH, TARGET_COMMITTEE_SIZE, - SHUFFLE_ROUND_COUNT, } from "@lodestar/params"; -import {BeaconConfig} from "@lodestar/config"; +import {Epoch, RootHex, ValidatorIndex, ssz} from "@lodestar/types"; +import {GaugeExtra, Logger, NoLabels, intDiv, toRootHex} from "@lodestar/utils"; import {BeaconStateAllForks} from "../types.js"; -import {getSeed} from "./seed.js"; -import {computeStartSlotAtEpoch} from "./epoch.js"; import {getBlockRootAtSlot} from "./blockRoot.js"; import {computeAnchorCheckpoint} from "./computeAnchorCheckpoint.js"; +import {computeStartSlotAtEpoch} from "./epoch.js"; +import {getSeed} from "./seed.js"; export interface ShufflingBuildProps { state: BeaconStateAllForks; diff --git a/packages/state-transition/src/util/execution.ts b/packages/state-transition/src/util/execution.ts index deed64bd6c51..9d70790f74a6 100644 --- a/packages/state-transition/src/util/execution.ts +++ b/packages/state-transition/src/util/execution.ts @@ -1,23 +1,23 @@ +import {ForkExecution, ForkName, ForkSeq} from "@lodestar/params"; import { + BeaconBlock, + BeaconBlockBody, + BlindedBeaconBlock, + BlindedBeaconBlockBody, + ExecutionPayload, + ExecutionPayloadHeader, bellatrix, capella, deneb, isBlindedBeaconBlockBody, - ssz, - BeaconBlock, - BeaconBlockBody, - ExecutionPayload, isExecutionPayload, - ExecutionPayloadHeader, - BlindedBeaconBlockBody, - BlindedBeaconBlock, + ssz, } from "@lodestar/types"; -import {ForkExecution, ForkName, ForkSeq} from "@lodestar/params"; import { + BeaconStateAllForks, BeaconStateBellatrix, BeaconStateCapella, - BeaconStateAllForks, BeaconStateExecutions, CachedBeaconStateAllForks, CachedBeaconStateExecutions, diff --git a/packages/state-transition/src/util/genesis.ts b/packages/state-transition/src/util/genesis.ts index aca81258a47a..27f7aee00460 100644 --- a/packages/state-transition/src/util/genesis.ts +++ b/packages/state-transition/src/util/genesis.ts @@ -10,18 +10,18 @@ import { MAX_EFFECTIVE_BALANCE, UNSET_DEPOSIT_REQUESTS_START_INDEX, } from "@lodestar/params"; -import {Bytes32, phase0, Root, ssz, TimeSeconds} from "@lodestar/types"; +import {Bytes32, Root, TimeSeconds, phase0, ssz} from "@lodestar/types"; -import {CachedBeaconStateAllForks, BeaconStateAllForks, CachedBeaconStateElectra} from "../types.js"; -import {createCachedBeaconState} from "../cache/stateCache.js"; -import {EpochCacheImmutableData} from "../cache/epochCache.js"; import {processDeposit} from "../block/processDeposit.js"; +import {EpochCacheImmutableData} from "../cache/epochCache.js"; +import {createCachedBeaconState} from "../cache/stateCache.js"; import {increaseBalance} from "../index.js"; -import {computeEpochAtSlot} from "./epoch.js"; -import {getActiveValidatorIndices, getMaxEffectiveBalance} from "./validator.js"; -import {getTemporaryBlockHeader} from "./blockRoot.js"; +import {BeaconStateAllForks, CachedBeaconStateAllForks, CachedBeaconStateElectra} from "../types.js"; import {newFilledArray} from "./array.js"; +import {getTemporaryBlockHeader} from "./blockRoot.js"; +import {computeEpochAtSlot} from "./epoch.js"; import {getNextSyncCommittee} from "./syncCommittee.js"; +import {getActiveValidatorIndices, getMaxEffectiveBalance} from "./validator.js"; type DepositDataRootListType = ListCompositeType; type DepositDataRootViewDU = CompositeViewDU; diff --git a/packages/state-transition/src/util/interop.ts b/packages/state-transition/src/util/interop.ts index e99799da127d..de7ba31d5a63 100644 --- a/packages/state-transition/src/util/interop.ts +++ b/packages/state-transition/src/util/interop.ts @@ -1,7 +1,7 @@ -import {toBufferBE} from "bigint-buffer"; import {digest} from "@chainsafe/as-sha256"; import {SecretKey} from "@chainsafe/blst"; import {bytesToBigInt, intToBytes} from "@lodestar/utils"; +import {toBufferBE} from "bigint-buffer"; let curveOrder: bigint; function getCurveOrder(): bigint { diff --git a/packages/state-transition/src/util/loadState/loadState.ts b/packages/state-transition/src/util/loadState/loadState.ts index 6e3e9c6719fa..b8254f8a5edc 100644 --- a/packages/state-transition/src/util/loadState/loadState.ts +++ b/packages/state-transition/src/util/loadState/loadState.ts @@ -1,10 +1,10 @@ -import {deserializeContainerIgnoreFields, ssz} from "@lodestar/types"; -import {ForkSeq} from "@lodestar/params"; import {ChainForkConfig} from "@lodestar/config"; +import {ForkSeq} from "@lodestar/params"; +import {deserializeContainerIgnoreFields, ssz} from "@lodestar/types"; import {BeaconStateAllForks, BeaconStateAltair} from "../../types.js"; import {VALIDATOR_BYTES_SIZE, getForkFromStateBytes, getStateTypeFromBytes} from "../sszBytes.js"; -import {findModifiedValidators} from "./findModifiedValidators.js"; import {findModifiedInactivityScores} from "./findModifiedInactivityScores.js"; +import {findModifiedValidators} from "./findModifiedValidators.js"; import {loadValidator} from "./loadValidator.js"; type MigrateStateOutput = {state: BeaconStateAllForks; modifiedValidators: number[]}; diff --git a/packages/state-transition/src/util/rootCache.ts b/packages/state-transition/src/util/rootCache.ts index f3fc5b52ff52..ada841dbbb9f 100644 --- a/packages/state-transition/src/util/rootCache.ts +++ b/packages/state-transition/src/util/rootCache.ts @@ -1,4 +1,4 @@ -import {Epoch, phase0, Root, Slot} from "@lodestar/types"; +import {Epoch, Root, Slot, phase0} from "@lodestar/types"; import {CachedBeaconStateAllForks} from "../types.js"; import {getBlockRoot, getBlockRootAtSlot} from "./blockRoot.js"; diff --git a/packages/state-transition/src/util/seed.ts b/packages/state-transition/src/util/seed.ts index 4131d4d9481f..129cf6bfaf72 100644 --- a/packages/state-transition/src/util/seed.ts +++ b/packages/state-transition/src/util/seed.ts @@ -1,6 +1,4 @@ import {digest} from "@chainsafe/as-sha256"; -import {Epoch, Bytes32, DomainType, ValidatorIndex} from "@lodestar/types"; -import {assert, bytesToBigInt, intToBytes} from "@lodestar/utils"; import { DOMAIN_SYNC_COMMITTEE, EFFECTIVE_BALANCE_INCREMENT, @@ -13,8 +11,10 @@ import { SLOTS_PER_EPOCH, SYNC_COMMITTEE_SIZE, } from "@lodestar/params"; -import {BeaconStateAllForks} from "../types.js"; +import {Bytes32, DomainType, Epoch, ValidatorIndex} from "@lodestar/types"; +import {assert, bytesToBigInt, intToBytes} from "@lodestar/utils"; import {EffectiveBalanceIncrements} from "../cache/effectiveBalanceIncrements.js"; +import {BeaconStateAllForks} from "../types.js"; import {computeStartSlotAtEpoch} from "./epoch.js"; import {computeEpochAtSlot} from "./epoch.js"; diff --git a/packages/state-transition/src/util/slot.ts b/packages/state-transition/src/util/slot.ts index 495a350ca11f..3cf145367a1d 100644 --- a/packages/state-transition/src/util/slot.ts +++ b/packages/state-transition/src/util/slot.ts @@ -1,7 +1,7 @@ import {ChainConfig} from "@lodestar/config"; import {GENESIS_SLOT, INTERVALS_PER_SLOT} from "@lodestar/params"; -import {Slot, Epoch, TimeSeconds} from "@lodestar/types"; -import {computeStartSlotAtEpoch, computeEpochAtSlot} from "./epoch.js"; +import {Epoch, Slot, TimeSeconds} from "@lodestar/types"; +import {computeEpochAtSlot, computeStartSlotAtEpoch} from "./epoch.js"; export function getSlotsSinceGenesis(config: ChainConfig, genesisTime: TimeSeconds): Slot { const diffInSeconds = Date.now() / 1000 - genesisTime; diff --git a/packages/state-transition/src/util/syncCommittee.ts b/packages/state-transition/src/util/syncCommittee.ts index c1f53632e521..a0731cf8d6ac 100644 --- a/packages/state-transition/src/util/syncCommittee.ts +++ b/packages/state-transition/src/util/syncCommittee.ts @@ -8,10 +8,10 @@ import { SYNC_REWARD_WEIGHT, WEIGHT_DENOMINATOR, } from "@lodestar/params"; -import {altair, ValidatorIndex} from "@lodestar/types"; +import {ValidatorIndex, altair} from "@lodestar/types"; import {bigIntSqrt} from "@lodestar/utils"; -import {BeaconStateAllForks} from "../types.js"; import {EffectiveBalanceIncrements} from "../cache/effectiveBalanceIncrements.js"; +import {BeaconStateAllForks} from "../types.js"; import {getNextSyncCommitteeIndices} from "./seed.js"; /** diff --git a/packages/state-transition/src/util/validator.ts b/packages/state-transition/src/util/validator.ts index 4906a9349402..555b8a09b614 100644 --- a/packages/state-transition/src/util/validator.ts +++ b/packages/state-transition/src/util/validator.ts @@ -1,5 +1,3 @@ -import {Epoch, phase0, ValidatorIndex} from "@lodestar/types"; -import {intDiv} from "@lodestar/utils"; import {ChainForkConfig} from "@lodestar/config"; import { EFFECTIVE_BALANCE_INCREMENT, @@ -7,6 +5,8 @@ import { MAX_EFFECTIVE_BALANCE_ELECTRA, MIN_ACTIVATION_BALANCE, } from "@lodestar/params"; +import {Epoch, ValidatorIndex, phase0} from "@lodestar/types"; +import {intDiv} from "@lodestar/utils"; import {BeaconStateAllForks, CachedBeaconStateElectra, EpochCache} from "../types.js"; import {hasCompoundingWithdrawalCredential} from "./electra.js"; diff --git a/packages/state-transition/src/util/weakSubjectivity.ts b/packages/state-transition/src/util/weakSubjectivity.ts index 8d7c82842496..fc2b485aea9f 100644 --- a/packages/state-transition/src/util/weakSubjectivity.ts +++ b/packages/state-transition/src/util/weakSubjectivity.ts @@ -6,7 +6,7 @@ import {Checkpoint} from "@lodestar/types/phase0"; import {toRootHex} from "@lodestar/utils"; import {ZERO_HASH} from "../constants/constants.js"; import {BeaconStateAllForks, CachedBeaconStateAllForks} from "../types.js"; -import {computeEpochAtSlot, getCurrentEpoch, computeCheckpointEpochAtStateSlot} from "./epoch.js"; +import {computeCheckpointEpochAtStateSlot, computeEpochAtSlot, getCurrentEpoch} from "./epoch.js"; import {getCurrentSlot} from "./slot.js"; import {getActiveValidatorIndices, getChurnLimit} from "./validator.js"; diff --git a/packages/state-transition/test/perf/analyzeEpochs.ts b/packages/state-transition/test/perf/analyzeEpochs.ts index ebad63ccf0ad..1141f488dba1 100644 --- a/packages/state-transition/test/perf/analyzeEpochs.ts +++ b/packages/state-transition/test/perf/analyzeEpochs.ts @@ -4,10 +4,10 @@ import {config} from "@lodestar/config/default"; import {NetworkName} from "@lodestar/config/networks.js"; import {phase0, ssz} from "@lodestar/types"; import { - computeEpochAtSlot, - computeStartSlotAtEpoch, AttesterFlags, beforeProcessEpoch, + computeEpochAtSlot, + computeStartSlotAtEpoch, parseAttesterFlags, processSlots, } from "../../src/index.js"; diff --git a/packages/state-transition/test/perf/block/processAttestation.test.ts b/packages/state-transition/test/perf/block/processAttestation.test.ts index 673b0e17430f..25528b2458e4 100644 --- a/packages/state-transition/test/perf/block/processAttestation.test.ts +++ b/packages/state-transition/test/perf/block/processAttestation.test.ts @@ -11,8 +11,8 @@ import { SYNC_COMMITTEE_SIZE, } from "@lodestar/params"; import {phase0} from "@lodestar/types"; -import {CachedBeaconStateAllForks, CachedBeaconStateAltair} from "../../../src/index.js"; import {processAttestationsAltair} from "../../../src/block/processAttestationsAltair.js"; +import {CachedBeaconStateAllForks, CachedBeaconStateAltair} from "../../../src/index.js"; import {generatePerfTestCachedStateAltair, perfStateId} from "../util.js"; import {BlockAltairOpts, getBlockAltair} from "./util.js"; diff --git a/packages/state-transition/test/perf/block/processBlockAltair.test.ts b/packages/state-transition/test/perf/block/processBlockAltair.test.ts index cf0898946ab6..60ad8b50afa6 100644 --- a/packages/state-transition/test/perf/block/processBlockAltair.test.ts +++ b/packages/state-transition/test/perf/block/processBlockAltair.test.ts @@ -1,5 +1,4 @@ import {itBench} from "@dapplion/benchmark"; -import {ssz} from "@lodestar/types"; import { ACTIVE_PRESET, MAX_ATTESTATIONS, @@ -10,14 +9,15 @@ import { PresetName, SYNC_COMMITTEE_SIZE, } from "@lodestar/params"; +import {ssz} from "@lodestar/types"; import { CachedBeaconStateAltair, DataAvailableStatus, ExecutionPayloadStatus, stateTransition, } from "../../../src/index.js"; -import {cachedStateAltairPopulateCaches, generatePerfTestCachedStateAltair, perfStateId} from "../util.js"; import {StateBlock} from "../types.js"; +import {cachedStateAltairPopulateCaches, generatePerfTestCachedStateAltair, perfStateId} from "../util.js"; import {BlockAltairOpts, getBlockAltair} from "./util.js"; // As of Jun 12 2021 diff --git a/packages/state-transition/test/perf/block/processBlockPhase0.test.ts b/packages/state-transition/test/perf/block/processBlockPhase0.test.ts index 92d8630a58ac..980586f6326b 100644 --- a/packages/state-transition/test/perf/block/processBlockPhase0.test.ts +++ b/packages/state-transition/test/perf/block/processBlockPhase0.test.ts @@ -9,8 +9,8 @@ import { PresetName, } from "@lodestar/params"; import {DataAvailableStatus, ExecutionPayloadStatus, stateTransition} from "../../../src/index.js"; -import {generatePerfTestCachedStatePhase0, perfStateId} from "../util.js"; import {StateBlock} from "../types.js"; +import {generatePerfTestCachedStatePhase0, perfStateId} from "../util.js"; import {BlockOpts, getBlockPhase0} from "./util.js"; // As of Jun 12 2021 diff --git a/packages/state-transition/test/perf/block/processEth1Data.test.ts b/packages/state-transition/test/perf/block/processEth1Data.test.ts index 45dc8aa631d7..ba7cb0b5ba1d 100644 --- a/packages/state-transition/test/perf/block/processEth1Data.test.ts +++ b/packages/state-transition/test/perf/block/processEth1Data.test.ts @@ -1,8 +1,8 @@ import {itBench} from "@dapplion/benchmark"; import {ACTIVE_PRESET, PresetName, SYNC_COMMITTEE_SIZE} from "@lodestar/params"; import {phase0} from "@lodestar/types"; -import {CachedBeaconStateAllForks} from "../../../src/index.js"; import {processEth1Data} from "../../../src/block/processEth1Data.js"; +import {CachedBeaconStateAllForks} from "../../../src/index.js"; import {generatePerfTestCachedStateAltair, perfStateId} from "../util.js"; import {getBlockAltair} from "./util.js"; diff --git a/packages/state-transition/test/perf/block/processWithdrawals.test.ts b/packages/state-transition/test/perf/block/processWithdrawals.test.ts index 66d624b39bfd..23f76825225d 100644 --- a/packages/state-transition/test/perf/block/processWithdrawals.test.ts +++ b/packages/state-transition/test/perf/block/processWithdrawals.test.ts @@ -1,9 +1,9 @@ import {itBench} from "@dapplion/benchmark"; import {ForkSeq} from "@lodestar/params"; -import {CachedBeaconStateCapella} from "../../../src/index.js"; import {getExpectedWithdrawals} from "../../../src/block/processWithdrawals.js"; +import {CachedBeaconStateCapella} from "../../../src/index.js"; +import {WithdrawalOpts, getExpectedWithdrawalsTestData} from "../../utils/capella.js"; import {numValidators} from "../util.js"; -import {getExpectedWithdrawalsTestData, WithdrawalOpts} from "../../utils/capella.js"; // PERF: Fixed cost for MAX_WITHDRAWALS_PER_PAYLOAD probes // + cost 'proportional' to $VALIDATOR_COUNT with balances under MAX_EFFECTIVE_BALANCE or diff --git a/packages/state-transition/test/perf/block/util.ts b/packages/state-transition/test/perf/block/util.ts index baa86dcac6a5..7b95d1621f5a 100644 --- a/packages/state-transition/test/perf/block/util.ts +++ b/packages/state-transition/test/perf/block/util.ts @@ -1,16 +1,16 @@ -import {toGindex, Tree} from "@chainsafe/persistent-merkle-tree"; -import {BitArray} from "@chainsafe/ssz"; import {SecretKey} from "@chainsafe/blst"; -import {altair, phase0, ssz} from "@lodestar/types"; -import {DOMAIN_DEPOSIT, SYNC_COMMITTEE_SIZE} from "@lodestar/params"; +import {Tree, toGindex} from "@chainsafe/persistent-merkle-tree"; +import {BitArray} from "@chainsafe/ssz"; import {config} from "@lodestar/config/default"; +import {DOMAIN_DEPOSIT, SYNC_COMMITTEE_SIZE} from "@lodestar/params"; +import {altair, phase0, ssz} from "@lodestar/types"; import { + CachedBeaconStateAllForks, + CachedBeaconStateAltair, + ZERO_HASH, computeDomain, computeEpochAtSlot, computeSigningRoot, - ZERO_HASH, - CachedBeaconStateAllForks, - CachedBeaconStateAltair, } from "../../../src/index.js"; import {getBlockRoot, getBlockRootAtSlot} from "../../../src/index.js"; diff --git a/packages/state-transition/test/perf/dataStructures/arrayish.test.ts b/packages/state-transition/test/perf/dataStructures/arrayish.test.ts index 353f81951aa7..ebeefacbd27e 100644 --- a/packages/state-transition/test/perf/dataStructures/arrayish.test.ts +++ b/packages/state-transition/test/perf/dataStructures/arrayish.test.ts @@ -1,5 +1,5 @@ +import {LeafNode, Tree, toGindex, zeroNode} from "@chainsafe/persistent-merkle-tree"; import {itBench, setBenchOpts} from "@dapplion/benchmark"; -import {LeafNode, toGindex, Tree, zeroNode} from "@chainsafe/persistent-merkle-tree"; // Understand the cost of each array-ish data structure to: // - Get one element diff --git a/packages/state-transition/test/perf/epoch/epochAltair.test.ts b/packages/state-transition/test/perf/epoch/epochAltair.test.ts index 5a10fd4d8bbd..aa08619250dd 100644 --- a/packages/state-transition/test/perf/epoch/epochAltair.test.ts +++ b/packages/state-transition/test/perf/epoch/epochAltair.test.ts @@ -1,28 +1,28 @@ import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {ForkSeq} from "@lodestar/params"; +import {processEpoch} from "../../../src/epoch/index.js"; +import {processEffectiveBalanceUpdates} from "../../../src/epoch/processEffectiveBalanceUpdates.js"; +import {processEth1DataReset} from "../../../src/epoch/processEth1DataReset.js"; +import {processHistoricalRootsUpdate} from "../../../src/epoch/processHistoricalRootsUpdate.js"; +import {processInactivityUpdates} from "../../../src/epoch/processInactivityUpdates.js"; +import {processJustificationAndFinalization} from "../../../src/epoch/processJustificationAndFinalization.js"; +import {processParticipationFlagUpdates} from "../../../src/epoch/processParticipationFlagUpdates.js"; +import {processRandaoMixesReset} from "../../../src/epoch/processRandaoMixesReset.js"; +import {processRegistryUpdates} from "../../../src/epoch/processRegistryUpdates.js"; +import {processRewardsAndPenalties} from "../../../src/epoch/processRewardsAndPenalties.js"; +import {processSlashings} from "../../../src/epoch/processSlashings.js"; +import {processSlashingsReset} from "../../../src/epoch/processSlashingsReset.js"; +import {processSyncCommitteeUpdates} from "../../../src/epoch/processSyncCommitteeUpdates.js"; import { - computeStartSlotAtEpoch, CachedBeaconStateAllForks, CachedBeaconStateAltair, beforeProcessEpoch, + computeStartSlotAtEpoch, } from "../../../src/index.js"; -import {beforeValue, LazyValue} from "../../utils/beforeValueMocha.js"; +import {LazyValue, beforeValue} from "../../utils/beforeValueMocha.js"; import {getNetworkCachedState} from "../../utils/testFileCache.js"; -import {StateEpoch} from "../types.js"; import {altairState} from "../params.js"; -import {processJustificationAndFinalization} from "../../../src/epoch/processJustificationAndFinalization.js"; -import {processInactivityUpdates} from "../../../src/epoch/processInactivityUpdates.js"; -import {processRewardsAndPenalties} from "../../../src/epoch/processRewardsAndPenalties.js"; -import {processRegistryUpdates} from "../../../src/epoch/processRegistryUpdates.js"; -import {processSlashings} from "../../../src/epoch/processSlashings.js"; -import {processEth1DataReset} from "../../../src/epoch/processEth1DataReset.js"; -import {processEffectiveBalanceUpdates} from "../../../src/epoch/processEffectiveBalanceUpdates.js"; -import {processSlashingsReset} from "../../../src/epoch/processSlashingsReset.js"; -import {processRandaoMixesReset} from "../../../src/epoch/processRandaoMixesReset.js"; -import {processHistoricalRootsUpdate} from "../../../src/epoch/processHistoricalRootsUpdate.js"; -import {processParticipationFlagUpdates} from "../../../src/epoch/processParticipationFlagUpdates.js"; -import {processSyncCommitteeUpdates} from "../../../src/epoch/processSyncCommitteeUpdates.js"; -import {processEpoch} from "../../../src/epoch/index.js"; +import {StateEpoch} from "../types.js"; const slot = computeStartSlotAtEpoch(altairState.epoch) - 1; const stateId = `${altairState.network}_e${altairState.epoch}`; diff --git a/packages/state-transition/test/perf/epoch/epochCapella.test.ts b/packages/state-transition/test/perf/epoch/epochCapella.test.ts index a4daf308aaa0..1376fd61d965 100644 --- a/packages/state-transition/test/perf/epoch/epochCapella.test.ts +++ b/packages/state-transition/test/perf/epoch/epochCapella.test.ts @@ -1,28 +1,28 @@ import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {ForkSeq} from "@lodestar/params"; +import {processEpoch} from "../../../src/epoch/index.js"; +import {processEffectiveBalanceUpdates} from "../../../src/epoch/processEffectiveBalanceUpdates.js"; +import {processEth1DataReset} from "../../../src/epoch/processEth1DataReset.js"; +import {processHistoricalRootsUpdate} from "../../../src/epoch/processHistoricalRootsUpdate.js"; +import {processInactivityUpdates} from "../../../src/epoch/processInactivityUpdates.js"; +import {processJustificationAndFinalization} from "../../../src/epoch/processJustificationAndFinalization.js"; +import {processParticipationFlagUpdates} from "../../../src/epoch/processParticipationFlagUpdates.js"; +import {processRandaoMixesReset} from "../../../src/epoch/processRandaoMixesReset.js"; +import {processRegistryUpdates} from "../../../src/epoch/processRegistryUpdates.js"; +import {processRewardsAndPenalties} from "../../../src/epoch/processRewardsAndPenalties.js"; +import {processSlashings} from "../../../src/epoch/processSlashings.js"; +import {processSlashingsReset} from "../../../src/epoch/processSlashingsReset.js"; import { - computeStartSlotAtEpoch, CachedBeaconStateAllForks, - CachedBeaconStateCapella, CachedBeaconStateAltair, + CachedBeaconStateCapella, beforeProcessEpoch, + computeStartSlotAtEpoch, } from "../../../src/index.js"; -import {beforeValue, LazyValue} from "../../utils/beforeValueMocha.js"; +import {LazyValue, beforeValue} from "../../utils/beforeValueMocha.js"; import {getNetworkCachedState} from "../../utils/testFileCache.js"; -import {StateEpoch} from "../types.js"; import {capellaState} from "../params.js"; -import {processJustificationAndFinalization} from "../../../src/epoch/processJustificationAndFinalization.js"; -import {processInactivityUpdates} from "../../../src/epoch/processInactivityUpdates.js"; -import {processRewardsAndPenalties} from "../../../src/epoch/processRewardsAndPenalties.js"; -import {processRegistryUpdates} from "../../../src/epoch/processRegistryUpdates.js"; -import {processSlashings} from "../../../src/epoch/processSlashings.js"; -import {processEth1DataReset} from "../../../src/epoch/processEth1DataReset.js"; -import {processEffectiveBalanceUpdates} from "../../../src/epoch/processEffectiveBalanceUpdates.js"; -import {processSlashingsReset} from "../../../src/epoch/processSlashingsReset.js"; -import {processRandaoMixesReset} from "../../../src/epoch/processRandaoMixesReset.js"; -import {processHistoricalRootsUpdate} from "../../../src/epoch/processHistoricalRootsUpdate.js"; -import {processParticipationFlagUpdates} from "../../../src/epoch/processParticipationFlagUpdates.js"; -import {processEpoch} from "../../../src/epoch/index.js"; +import {StateEpoch} from "../types.js"; const slot = computeStartSlotAtEpoch(capellaState.epoch) - 1; const stateId = `${capellaState.network}_e${capellaState.epoch}`; diff --git a/packages/state-transition/test/perf/epoch/epochPhase0.test.ts b/packages/state-transition/test/perf/epoch/epochPhase0.test.ts index 5c19b347af62..cca93b045cae 100644 --- a/packages/state-transition/test/perf/epoch/epochPhase0.test.ts +++ b/packages/state-transition/test/perf/epoch/epochPhase0.test.ts @@ -1,26 +1,26 @@ import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {ForkSeq} from "@lodestar/params"; +import {processEpoch} from "../../../src/epoch/index.js"; +import {processEffectiveBalanceUpdates} from "../../../src/epoch/processEffectiveBalanceUpdates.js"; +import {processEth1DataReset} from "../../../src/epoch/processEth1DataReset.js"; +import {processHistoricalRootsUpdate} from "../../../src/epoch/processHistoricalRootsUpdate.js"; +import {processJustificationAndFinalization} from "../../../src/epoch/processJustificationAndFinalization.js"; +import {processParticipationRecordUpdates} from "../../../src/epoch/processParticipationRecordUpdates.js"; +import {processRandaoMixesReset} from "../../../src/epoch/processRandaoMixesReset.js"; +import {processRegistryUpdates} from "../../../src/epoch/processRegistryUpdates.js"; +import {processRewardsAndPenalties} from "../../../src/epoch/processRewardsAndPenalties.js"; +import {processSlashings} from "../../../src/epoch/processSlashings.js"; +import {processSlashingsReset} from "../../../src/epoch/processSlashingsReset.js"; import { - computeStartSlotAtEpoch, CachedBeaconStateAllForks, CachedBeaconStatePhase0, beforeProcessEpoch, + computeStartSlotAtEpoch, } from "../../../src/index.js"; -import {beforeValue, LazyValue} from "../../utils/beforeValueMocha.js"; +import {LazyValue, beforeValue} from "../../utils/beforeValueMocha.js"; import {getNetworkCachedState} from "../../utils/testFileCache.js"; -import {StateEpoch} from "../types.js"; import {phase0State} from "../params.js"; -import {processEpoch} from "../../../src/epoch/index.js"; -import {processParticipationRecordUpdates} from "../../../src/epoch/processParticipationRecordUpdates.js"; -import {processJustificationAndFinalization} from "../../../src/epoch/processJustificationAndFinalization.js"; -import {processRewardsAndPenalties} from "../../../src/epoch/processRewardsAndPenalties.js"; -import {processRegistryUpdates} from "../../../src/epoch/processRegistryUpdates.js"; -import {processSlashings} from "../../../src/epoch/processSlashings.js"; -import {processEth1DataReset} from "../../../src/epoch/processEth1DataReset.js"; -import {processEffectiveBalanceUpdates} from "../../../src/epoch/processEffectiveBalanceUpdates.js"; -import {processSlashingsReset} from "../../../src/epoch/processSlashingsReset.js"; -import {processRandaoMixesReset} from "../../../src/epoch/processRandaoMixesReset.js"; -import {processHistoricalRootsUpdate} from "../../../src/epoch/processHistoricalRootsUpdate.js"; +import {StateEpoch} from "../types.js"; const slot = computeStartSlotAtEpoch(phase0State.epoch) - 1; const stateId = `${phase0State.network}_e${phase0State.epoch}`; diff --git a/packages/state-transition/test/perf/epoch/processEffectiveBalanceUpdates.test.ts b/packages/state-transition/test/perf/epoch/processEffectiveBalanceUpdates.test.ts index 19f18df86c2e..fe2fabd2dd4d 100644 --- a/packages/state-transition/test/perf/epoch/processEffectiveBalanceUpdates.test.ts +++ b/packages/state-transition/test/perf/epoch/processEffectiveBalanceUpdates.test.ts @@ -1,12 +1,12 @@ import {itBench} from "@dapplion/benchmark"; -import {ssz} from "@lodestar/types"; import {config} from "@lodestar/config/default"; import {ForkSeq} from "@lodestar/params"; -import {beforeProcessEpoch, CachedBeaconStateAllForks, EpochTransitionCache} from "../../../src/index.js"; +import {ssz} from "@lodestar/types"; import {processEffectiveBalanceUpdates} from "../../../src/epoch/processEffectiveBalanceUpdates.js"; -import {numValidators} from "../util.js"; -import {StateEpoch} from "../types.js"; +import {CachedBeaconStateAllForks, EpochTransitionCache, beforeProcessEpoch} from "../../../src/index.js"; import {createCachedBeaconStateTest} from "../../utils/state.js"; +import {StateEpoch} from "../types.js"; +import {numValidators} from "../util.js"; // PERF: Cost 'proportional' to $VALIDATOR_COUNT, to iterate over all balances. Then cost is proportional to the amount // of validators whose effectiveBalance changed. Worst case is a massive network leak or a big slashing event which diff --git a/packages/state-transition/test/perf/epoch/processRegistryUpdates.test.ts b/packages/state-transition/test/perf/epoch/processRegistryUpdates.test.ts index 588fe9ec0213..b02c2aa3c9a2 100644 --- a/packages/state-transition/test/perf/epoch/processRegistryUpdates.test.ts +++ b/packages/state-transition/test/perf/epoch/processRegistryUpdates.test.ts @@ -1,9 +1,9 @@ import {itBench} from "@dapplion/benchmark"; import {ForkSeq} from "@lodestar/params"; -import {beforeProcessEpoch, CachedBeaconStateAllForks, EpochTransitionCache} from "../../../src/index.js"; import {processRegistryUpdates} from "../../../src/epoch/processRegistryUpdates.js"; -import {generatePerfTestCachedStatePhase0, numValidators} from "../util.js"; +import {CachedBeaconStateAllForks, EpochTransitionCache, beforeProcessEpoch} from "../../../src/index.js"; import {StateEpoch} from "../types.js"; +import {generatePerfTestCachedStatePhase0, numValidators} from "../util.js"; // PERF: Cost 'proportional' to only validators that active + exit. For mainnet conditions: // - indicesEligibleForActivationQueue: Maxing deposits triggers 512 validator mutations diff --git a/packages/state-transition/test/perf/epoch/processRewardsAndPenalties.test.ts b/packages/state-transition/test/perf/epoch/processRewardsAndPenalties.test.ts index 03644ebca0f3..b4c157942584 100644 --- a/packages/state-transition/test/perf/epoch/processRewardsAndPenalties.test.ts +++ b/packages/state-transition/test/perf/epoch/processRewardsAndPenalties.test.ts @@ -1,9 +1,9 @@ import {itBench} from "@dapplion/benchmark"; import {processRewardsAndPenalties} from "../../../src/epoch/processRewardsAndPenalties.js"; -import {generatePerfTestCachedStateAltair, numValidators} from "../util.js"; import {StateAltairEpoch} from "../types.js"; -import {FlagFactors, generateBalanceDeltasEpochTransitionCache} from "./utilPhase0.js"; +import {generatePerfTestCachedStateAltair, numValidators} from "../util.js"; import {mutateInactivityScores} from "./util.js"; +import {FlagFactors, generateBalanceDeltasEpochTransitionCache} from "./utilPhase0.js"; // PERF: Cost = 'proportional' to $VALIDATOR_COUNT. Extra work is done per validator the more status flags are set diff --git a/packages/state-transition/test/perf/epoch/processRewardsAndPenaltiesPhase0.test.ts b/packages/state-transition/test/perf/epoch/processRewardsAndPenaltiesPhase0.test.ts index e39b5962ea18..c5e747502e76 100644 --- a/packages/state-transition/test/perf/epoch/processRewardsAndPenaltiesPhase0.test.ts +++ b/packages/state-transition/test/perf/epoch/processRewardsAndPenaltiesPhase0.test.ts @@ -1,7 +1,7 @@ import {itBench} from "@dapplion/benchmark"; import {getAttestationDeltas} from "../../../src/epoch/getAttestationDeltas.js"; -import {generatePerfTestCachedStatePhase0, numValidators} from "../util.js"; import {StatePhase0Epoch} from "../types.js"; +import {generatePerfTestCachedStatePhase0, numValidators} from "../util.js"; import {FlagFactors, generateBalanceDeltasEpochTransitionCache} from "./utilPhase0.js"; // - On normal mainnet conditions diff --git a/packages/state-transition/test/perf/epoch/processSlashingsAllForks.test.ts b/packages/state-transition/test/perf/epoch/processSlashingsAllForks.test.ts index 3b0bfa623fb2..6a590e3c632f 100644 --- a/packages/state-transition/test/perf/epoch/processSlashingsAllForks.test.ts +++ b/packages/state-transition/test/perf/epoch/processSlashingsAllForks.test.ts @@ -1,14 +1,14 @@ import {itBench} from "@dapplion/benchmark"; import {MAX_EFFECTIVE_BALANCE} from "@lodestar/params"; +import {processSlashings} from "../../../src/epoch/processSlashings.js"; import { - beforeProcessEpoch, - CachedBeaconStatePhase0, CachedBeaconStateAllForks, + CachedBeaconStatePhase0, EpochTransitionCache, + beforeProcessEpoch, } from "../../../src/index.js"; -import {processSlashings} from "../../../src/epoch/processSlashings.js"; -import {generatePerfTestCachedStatePhase0, numValidators} from "../util.js"; import {StateEpoch} from "../types.js"; +import {generatePerfTestCachedStatePhase0, numValidators} from "../util.js"; // PERF: Cost 'proportional' to only validators that are slashed. For mainnet conditions: // - indicesToSlash: max len is 8704. But it's very unlikely since it would require all validators on the same diff --git a/packages/state-transition/test/perf/epoch/utilPhase0.ts b/packages/state-transition/test/perf/epoch/utilPhase0.ts index 41c7d9780e01..78e27563835b 100644 --- a/packages/state-transition/test/perf/epoch/utilPhase0.ts +++ b/packages/state-transition/test/perf/epoch/utilPhase0.ts @@ -1,5 +1,5 @@ import {AttesterFlags, toAttesterFlags} from "../../../src/index.js"; -import {CachedBeaconStatePhase0, CachedBeaconStateAltair, EpochTransitionCache} from "../../../src/types.js"; +import {CachedBeaconStateAltair, CachedBeaconStatePhase0, EpochTransitionCache} from "../../../src/types.js"; /** * Generate an incomplete EpochTransitionCache to simulate any network condition relevant to getAttestationDeltas diff --git a/packages/state-transition/test/perf/hashing.test.ts b/packages/state-transition/test/perf/hashing.test.ts index 26bfd935c08a..d0a651cc8824 100644 --- a/packages/state-transition/test/perf/hashing.test.ts +++ b/packages/state-transition/test/perf/hashing.test.ts @@ -1,7 +1,7 @@ -import {itBench} from "@dapplion/benchmark"; import {unshuffleList} from "@chainsafe/swap-or-not-shuffle"; -import {ssz} from "@lodestar/types"; +import {itBench} from "@dapplion/benchmark"; import {SHUFFLE_ROUND_COUNT} from "@lodestar/params"; +import {ssz} from "@lodestar/types"; import {generatePerfTestCachedStatePhase0, numValidators} from "./util.js"; // Test cost of hashing state after some modifications diff --git a/packages/state-transition/test/perf/misc/aggregationBits.test.ts b/packages/state-transition/test/perf/misc/aggregationBits.test.ts index a0578970dfe9..6beade2d11f4 100644 --- a/packages/state-transition/test/perf/misc/aggregationBits.test.ts +++ b/packages/state-transition/test/perf/misc/aggregationBits.test.ts @@ -1,5 +1,5 @@ -import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {BitArray} from "@chainsafe/ssz"; +import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {MAX_VALIDATORS_PER_COMMITTEE} from "@lodestar/params"; import {ssz} from "@lodestar/types"; diff --git a/packages/state-transition/test/perf/misc/byteArrayEquals.test.ts b/packages/state-transition/test/perf/misc/byteArrayEquals.test.ts index 64057a26d103..b8b34eda6721 100644 --- a/packages/state-transition/test/perf/misc/byteArrayEquals.test.ts +++ b/packages/state-transition/test/perf/misc/byteArrayEquals.test.ts @@ -1,6 +1,6 @@ import crypto from "node:crypto"; -import {itBench} from "@dapplion/benchmark"; import {byteArrayEquals} from "@chainsafe/ssz"; +import {itBench} from "@dapplion/benchmark"; import {generateState} from "../../utils/state.js"; import {generateValidators} from "../../utils/validator.js"; diff --git a/packages/state-transition/test/perf/misc/rootEquals.test.ts b/packages/state-transition/test/perf/misc/rootEquals.test.ts index f941e764c26b..39ec15c8de9f 100644 --- a/packages/state-transition/test/perf/misc/rootEquals.test.ts +++ b/packages/state-transition/test/perf/misc/rootEquals.test.ts @@ -1,5 +1,5 @@ -import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {byteArrayEquals, fromHexString} from "@chainsafe/ssz"; +import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {ssz} from "@lodestar/types"; // As of Sep 2023 diff --git a/packages/state-transition/test/perf/sanityCheck.test.ts b/packages/state-transition/test/perf/sanityCheck.test.ts index 834e118d0f76..26902622f6e4 100644 --- a/packages/state-transition/test/perf/sanityCheck.test.ts +++ b/packages/state-transition/test/perf/sanityCheck.test.ts @@ -1,5 +1,5 @@ -import {expect} from "chai"; import {ACTIVE_PRESET, EFFECTIVE_BALANCE_INCREMENT, PresetName} from "@lodestar/params"; +import {expect} from "chai"; import {beforeProcessEpoch} from "../../src/index.js"; import {generatePerfTestCachedStateAltair, generatePerfTestCachedStatePhase0, perfStateId} from "./util.js"; diff --git a/packages/state-transition/test/perf/slot/slots.test.ts b/packages/state-transition/test/perf/slot/slots.test.ts index 4f436876d9b0..8a1e9836ae22 100644 --- a/packages/state-transition/test/perf/slot/slots.test.ts +++ b/packages/state-transition/test/perf/slot/slots.test.ts @@ -1,7 +1,7 @@ import {itBench} from "@dapplion/benchmark"; import {processSlot} from "../../../src/slot/index.js"; -import {generatePerfTestCachedStatePhase0} from "../util.js"; import {State} from "../types.js"; +import {generatePerfTestCachedStatePhase0} from "../util.js"; // Test advancing through an empty slot, without any epoch transition diff --git a/packages/state-transition/test/perf/types.ts b/packages/state-transition/test/perf/types.ts index 8f4914238dba..2e494e263214 100644 --- a/packages/state-transition/test/perf/types.ts +++ b/packages/state-transition/test/perf/types.ts @@ -1,5 +1,5 @@ import {SignedBeaconBlock} from "@lodestar/types"; -import {CachedBeaconStateAllForks, CachedBeaconStatePhase0, CachedBeaconStateAltair} from "../../src/index.js"; +import {CachedBeaconStateAllForks, CachedBeaconStateAltair, CachedBeaconStatePhase0} from "../../src/index.js"; import {EpochTransitionCache} from "../../src/types.js"; // Type aliases to typesafe itBench() calls diff --git a/packages/state-transition/test/perf/util.ts b/packages/state-transition/test/perf/util.ts index 0f47c241f8f9..7dc5daeff754 100644 --- a/packages/state-transition/test/perf/util.ts +++ b/packages/state-transition/test/perf/util.ts @@ -1,9 +1,8 @@ -import {BitArray, fromHexString} from "@chainsafe/ssz"; import {PublicKey, SecretKey} from "@chainsafe/blst"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; -import {phase0, ssz, Slot, BeaconState} from "@lodestar/types"; -import {config} from "@lodestar/config/default"; +import {BitArray, fromHexString} from "@chainsafe/ssz"; import {createBeaconConfig, createChainForkConfig} from "@lodestar/config"; +import {config} from "@lodestar/config/default"; import { EPOCHS_PER_ETH1_VOTING_PERIOD, EPOCHS_PER_HISTORICAL_VECTOR, @@ -14,25 +13,26 @@ import { SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT, } from "@lodestar/params"; +import {BeaconState, Slot, phase0, ssz} from "@lodestar/types"; +import {getEffectiveBalanceIncrements} from "../../src/cache/effectiveBalanceIncrements.js"; import { - interopSecretKey, + computeCommitteeCount, computeEpochAtSlot, + createCachedBeaconState, getActiveValidatorIndices, + interopSecretKey, newFilledArray, - createCachedBeaconState, - computeCommitteeCount, } from "../../src/index.js"; +import {processSlots} from "../../src/index.js"; import { + BeaconStateAltair, + BeaconStatePhase0, CachedBeaconStateAllForks, - CachedBeaconStatePhase0, CachedBeaconStateAltair, - BeaconStatePhase0, - BeaconStateAltair, + CachedBeaconStatePhase0, } from "../../src/types.js"; -import {interopPubkeysCached} from "../utils/interop.js"; import {getNextSyncCommittee} from "../../src/util/syncCommittee.js"; -import {getEffectiveBalanceIncrements} from "../../src/cache/effectiveBalanceIncrements.js"; -import {processSlots} from "../../src/index.js"; +import {interopPubkeysCached} from "../utils/interop.js"; let phase0State: BeaconStatePhase0 | null = null; let phase0CachedState23637: CachedBeaconStatePhase0 | null = null; diff --git a/packages/state-transition/test/perf/util/balance.test.ts b/packages/state-transition/test/perf/util/balance.test.ts index 4103b3b5517f..a8d4f5157a6e 100644 --- a/packages/state-transition/test/perf/util/balance.test.ts +++ b/packages/state-transition/test/perf/util/balance.test.ts @@ -1,7 +1,7 @@ import {itBench} from "@dapplion/benchmark"; -import {generatePerfTestCachedStatePhase0, perfStateId} from "../util.js"; -import {State} from "../types.js"; import {getEffectiveBalanceIncrementsZeroInactive} from "../../../src/util/index.js"; +import {State} from "../types.js"; +import {generatePerfTestCachedStatePhase0, perfStateId} from "../util.js"; describe("getEffectiveBalanceIncrementsZeroInactive", () => { itBench({ diff --git a/packages/state-transition/test/perf/util/epochContext.test.ts b/packages/state-transition/test/perf/util/epochContext.test.ts index 9ae478d4161b..2f49d8bfa09b 100644 --- a/packages/state-transition/test/perf/util/epochContext.test.ts +++ b/packages/state-transition/test/perf/util/epochContext.test.ts @@ -1,6 +1,6 @@ import {itBench} from "@dapplion/benchmark"; import {Epoch} from "@lodestar/types"; -import {computeEpochAtSlot, CachedBeaconStateAllForks} from "../../../src/index.js"; +import {CachedBeaconStateAllForks, computeEpochAtSlot} from "../../../src/index.js"; import {generatePerfTestCachedStatePhase0, numValidators} from "../util.js"; // Current implementation scales very well with number of requested validators diff --git a/packages/state-transition/test/perf/util/loadState/findModifiedValidators.test.ts b/packages/state-transition/test/perf/util/loadState/findModifiedValidators.test.ts index 4028104f0bdc..6cd8650f3afc 100644 --- a/packages/state-transition/test/perf/util/loadState/findModifiedValidators.test.ts +++ b/packages/state-transition/test/perf/util/loadState/findModifiedValidators.test.ts @@ -1,12 +1,12 @@ -import {expect} from "chai"; -import {itBench} from "@dapplion/benchmark"; import {CompositeViewDU} from "@chainsafe/ssz"; +import {itBench} from "@dapplion/benchmark"; import {ssz} from "@lodestar/types"; import {bytesToInt} from "@lodestar/utils"; +import {expect} from "chai"; import {findModifiedValidators} from "../../../../src/util/loadState/findModifiedValidators.js"; import {VALIDATOR_BYTES_SIZE} from "../../../../src/util/sszBytes.js"; -import {generateValidators} from "../../../utils/validator.js"; import {generateState} from "../../../utils/state.js"; +import {generateValidators} from "../../../utils/validator.js"; /** * find modified validators by different ways. This proves that findModifiedValidators() leveraging Buffer.compare() is the fastest way. diff --git a/packages/state-transition/test/perf/util/loadState/loadState.test.ts b/packages/state-transition/test/perf/util/loadState/loadState.test.ts index 9f6175e95684..e41e4f6be7af 100644 --- a/packages/state-transition/test/perf/util/loadState/loadState.test.ts +++ b/packages/state-transition/test/perf/util/loadState/loadState.test.ts @@ -1,9 +1,9 @@ -import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {PublicKey} from "@chainsafe/blst"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; -import {loadState} from "../../../../src/util/loadState/loadState.js"; -import {createCachedBeaconState} from "../../../../src/cache/stateCache.js"; +import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {Index2PubkeyCache} from "../../../../src/cache/pubkeyCache.js"; +import {createCachedBeaconState} from "../../../../src/cache/stateCache.js"; +import {loadState} from "../../../../src/util/loadState/loadState.js"; import {generatePerfTestCachedStateAltair} from "../../util.js"; /** diff --git a/packages/state-transition/test/perf/util/rootCache.test.ts b/packages/state-transition/test/perf/util/rootCache.test.ts index 59edd2ebcb4e..2d0ba33004f5 100644 --- a/packages/state-transition/test/perf/util/rootCache.test.ts +++ b/packages/state-transition/test/perf/util/rootCache.test.ts @@ -1,7 +1,7 @@ import {itBench} from "@dapplion/benchmark"; -import {generatePerfTestCachedStatePhase0, perfStateId, perfStateEpoch} from "../util.js"; +import {RootCache, computeStartSlotAtEpoch, getBlockRootAtSlot} from "../../../src/util/index.js"; import {State} from "../types.js"; -import {computeStartSlotAtEpoch, getBlockRootAtSlot, RootCache} from "../../../src/util/index.js"; +import {generatePerfTestCachedStatePhase0, perfStateEpoch, perfStateId} from "../util.js"; const slot = computeStartSlotAtEpoch(perfStateEpoch) - 1; diff --git a/packages/state-transition/test/perf/util/shufflings.test.ts b/packages/state-transition/test/perf/util/shufflings.test.ts index 41767c184349..95afa1ca9849 100644 --- a/packages/state-transition/test/perf/util/shufflings.test.ts +++ b/packages/state-transition/test/perf/util/shufflings.test.ts @@ -1,12 +1,12 @@ import {itBench} from "@dapplion/benchmark"; -import {Epoch} from "@lodestar/types"; import {DOMAIN_BEACON_PROPOSER} from "@lodestar/params"; +import {Epoch} from "@lodestar/types"; import { - computeEpochAtSlot, CachedBeaconStateAllForks, + computeEpochAtSlot, computeEpochShuffling, - getNextSyncCommittee, computeProposers, + getNextSyncCommittee, getSeed, } from "../../../src/index.js"; import {generatePerfTestCachedStatePhase0, numValidators} from "../util.js"; diff --git a/packages/state-transition/test/perf/util/signingRoot.test.ts b/packages/state-transition/test/perf/util/signingRoot.test.ts index 1d308c2e3e43..b39ef44a15e7 100644 --- a/packages/state-transition/test/perf/util/signingRoot.test.ts +++ b/packages/state-transition/test/perf/util/signingRoot.test.ts @@ -1,6 +1,6 @@ -import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {digest} from "@chainsafe/as-sha256"; import {fromHexString, toHexString} from "@chainsafe/ssz"; +import {itBench, setBenchOpts} from "@dapplion/benchmark"; import {phase0, ssz} from "@lodestar/types"; import {computeSigningRoot} from "../../../src/util/signingRoot.js"; diff --git a/packages/state-transition/test/unit/block/isValidIndexedAttestation.test.ts b/packages/state-transition/test/unit/block/isValidIndexedAttestation.test.ts index c219943b940f..c54457c0ad09 100644 --- a/packages/state-transition/test/unit/block/isValidIndexedAttestation.test.ts +++ b/packages/state-transition/test/unit/block/isValidIndexedAttestation.test.ts @@ -1,11 +1,11 @@ -import {describe, it, expect} from "vitest"; import {config} from "@lodestar/config/default"; import {FAR_FUTURE_EPOCH, MAX_EFFECTIVE_BALANCE} from "@lodestar/params"; import {phase0, ssz} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; +import {isValidIndexedAttestation} from "../../../src/block/isValidIndexedAttestation.js"; import {EMPTY_SIGNATURE} from "../../../src/index.js"; import {generateCachedState} from "../../utils/state.js"; import {generateValidators} from "../../utils/validator.js"; -import {isValidIndexedAttestation} from "../../../src/block/isValidIndexedAttestation.js"; describe("validate indexed attestation", () => { const state = generateCachedState(config, { diff --git a/packages/state-transition/test/unit/block/processWithdrawals.test.ts b/packages/state-transition/test/unit/block/processWithdrawals.test.ts index 7b708d108a7b..7cfdfc6d58bb 100644 --- a/packages/state-transition/test/unit/block/processWithdrawals.test.ts +++ b/packages/state-transition/test/unit/block/processWithdrawals.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect} from "vitest"; import {ForkSeq} from "@lodestar/params"; +import {describe, expect, it} from "vitest"; import {getExpectedWithdrawals} from "../../../src/block/processWithdrawals.js"; import {numValidators} from "../../perf/util.js"; -import {getExpectedWithdrawalsTestData, WithdrawalOpts} from "../../utils/capella.js"; import {beforeValue} from "../../utils/beforeValue.js"; +import {WithdrawalOpts, getExpectedWithdrawalsTestData} from "../../utils/capella.js"; describe("getExpectedWithdrawals", () => { const vc = numValidators; diff --git a/packages/state-transition/test/unit/cachedBeaconState.test.ts b/packages/state-transition/test/unit/cachedBeaconState.test.ts index 668f22e13a1e..de2ba5893b02 100644 --- a/packages/state-transition/test/unit/cachedBeaconState.test.ts +++ b/packages/state-transition/test/unit/cachedBeaconState.test.ts @@ -1,14 +1,14 @@ -import {fromHexString} from "@chainsafe/ssz"; -import {describe, it, expect} from "vitest"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; +import {fromHexString} from "@chainsafe/ssz"; +import {createBeaconConfig, createChainForkConfig} from "@lodestar/config"; +import {config as defaultConfig} from "@lodestar/config/default"; import {ssz} from "@lodestar/types"; import {toHexString} from "@lodestar/utils"; -import {config as defaultConfig} from "@lodestar/config/default"; -import {createBeaconConfig, createChainForkConfig} from "@lodestar/config"; -import {createCachedBeaconStateTest} from "../utils/state.js"; +import {describe, expect, it} from "vitest"; import {createCachedBeaconState, loadCachedBeaconState} from "../../src/cache/stateCache.js"; -import {interopPubkeysCached} from "../utils/interop.js"; import {modifyStateSameValidator, newStateWithValidators} from "../utils/capella.js"; +import {interopPubkeysCached} from "../utils/interop.js"; +import {createCachedBeaconStateTest} from "../utils/state.js"; describe("CachedBeaconState", () => { it("Clone and mutate", () => { diff --git a/packages/state-transition/test/unit/constants.test.ts b/packages/state-transition/test/unit/constants.test.ts index 1cb17472218b..29b50fcb9c04 100644 --- a/packages/state-transition/test/unit/constants.test.ts +++ b/packages/state-transition/test/unit/constants.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import * as blst from "@chainsafe/blst"; +import {describe, expect, it} from "vitest"; import {G2_POINT_AT_INFINITY} from "../../src/index.js"; describe("constants", () => { diff --git a/packages/state-transition/test/unit/signatureSets/signatureSets.test.ts b/packages/state-transition/test/unit/signatureSets/signatureSets.test.ts index 353b68195636..ca9096ea8009 100644 --- a/packages/state-transition/test/unit/signatureSets/signatureSets.test.ts +++ b/packages/state-transition/test/unit/signatureSets/signatureSets.test.ts @@ -1,10 +1,10 @@ import crypto from "node:crypto"; -import {describe, it, expect} from "vitest"; -import {BitArray} from "@chainsafe/ssz"; import {SecretKey} from "@chainsafe/blst"; +import {BitArray} from "@chainsafe/ssz"; import {config} from "@lodestar/config/default"; -import {phase0, capella, ValidatorIndex, BLSSignature, ssz} from "@lodestar/types"; import {FAR_FUTURE_EPOCH, MAX_EFFECTIVE_BALANCE} from "@lodestar/params"; +import {BLSSignature, ValidatorIndex, capella, phase0, ssz} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; import {ZERO_HASH} from "../../../src/constants/index.js"; import {getBlockSignatureSets} from "../../../src/signatureSets/index.js"; import {generateCachedState} from "../../utils/state.js"; diff --git a/packages/state-transition/test/unit/upgradeState.test.ts b/packages/state-transition/test/unit/upgradeState.test.ts index 19a7d5c186f8..9923463b46be 100644 --- a/packages/state-transition/test/unit/upgradeState.test.ts +++ b/packages/state-transition/test/unit/upgradeState.test.ts @@ -1,13 +1,13 @@ -import {expect, describe, it} from "vitest"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; -import {ssz} from "@lodestar/types"; -import {ForkName} from "@lodestar/params"; -import {createBeaconConfig, ChainForkConfig, createChainForkConfig} from "@lodestar/config"; +import {ChainForkConfig, createBeaconConfig, createChainForkConfig} from "@lodestar/config"; import {config as chainConfig} from "@lodestar/config/default"; +import {ForkName} from "@lodestar/params"; +import {ssz} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; +import {createCachedBeaconState} from "../../src/cache/stateCache.js"; import {upgradeStateToDeneb} from "../../src/slot/upgradeStateToDeneb.js"; import {upgradeStateToElectra} from "../../src/slot/upgradeStateToElectra.js"; -import {createCachedBeaconState} from "../../src/cache/stateCache.js"; describe("upgradeState", () => { it("upgradeStateToDeneb", () => { diff --git a/packages/state-transition/test/unit/util/aggregator.test.ts b/packages/state-transition/test/unit/util/aggregator.test.ts index 58c2b0afbf58..ae4f1d0408f8 100644 --- a/packages/state-transition/test/unit/util/aggregator.test.ts +++ b/packages/state-transition/test/unit/util/aggregator.test.ts @@ -1,11 +1,11 @@ -import {describe, it, expect, beforeAll} from "vitest"; import {fromHexString} from "@chainsafe/ssz"; import { SYNC_COMMITTEE_SIZE, SYNC_COMMITTEE_SUBNET_COUNT, - TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE, TARGET_AGGREGATORS_PER_COMMITTEE, + TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE, } from "@lodestar/params"; +import {beforeAll, describe, expect, it} from "vitest"; import {isAggregatorFromCommitteeLength, isSyncCommitteeAggregator} from "../../../src/util/aggregator.js"; describe("isAttestationAggregator", () => { diff --git a/packages/state-transition/test/unit/util/balance.test.ts b/packages/state-transition/test/unit/util/balance.test.ts index 5b666cb0524e..2436c74a4e3c 100644 --- a/packages/state-transition/test/unit/util/balance.test.ts +++ b/packages/state-transition/test/unit/util/balance.test.ts @@ -1,14 +1,14 @@ -import {describe, it, expect} from "vitest"; import {config as minimalConfig} from "@lodestar/config/default"; +import {describe, expect, it} from "vitest"; import {EFFECTIVE_BALANCE_INCREMENT} from "@lodestar/params"; import {ValidatorIndex} from "@lodestar/types"; -import {increaseBalance, decreaseBalance, getTotalBalance, isActiveValidator} from "../../../src/util/index.js"; -import {getEffectiveBalanceIncrementsZeroed, getEffectiveBalanceIncrementsZeroInactive} from "../../../src/index.js"; +import {getEffectiveBalanceIncrementsZeroInactive, getEffectiveBalanceIncrementsZeroed} from "../../../src/index.js"; +import {decreaseBalance, getTotalBalance, increaseBalance, isActiveValidator} from "../../../src/util/index.js"; -import {generateValidators} from "../../utils/validator.js"; import {generateCachedState, generateState} from "../../utils/state.js"; +import {generateValidators} from "../../utils/validator.js"; describe("getTotalBalance", () => { it("should return correct balances - 500 validators", () => { diff --git a/packages/state-transition/test/unit/util/cachedBeaconState.test.ts b/packages/state-transition/test/unit/util/cachedBeaconState.test.ts index c85a8c7a2ffd..cd7a161d5355 100644 --- a/packages/state-transition/test/unit/util/cachedBeaconState.test.ts +++ b/packages/state-transition/test/unit/util/cachedBeaconState.test.ts @@ -1,8 +1,8 @@ -import {describe, it} from "vitest"; import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; import {createBeaconConfig} from "@lodestar/config"; import {config} from "@lodestar/config/default"; import {ssz} from "@lodestar/types"; +import {describe, it} from "vitest"; import {createCachedBeaconState} from "../../../src/index.js"; describe("CachedBeaconState", () => { diff --git a/packages/state-transition/test/unit/util/deposit.test.ts b/packages/state-transition/test/unit/util/deposit.test.ts index a682b4e993ed..de73015c1f71 100644 --- a/packages/state-transition/test/unit/util/deposit.test.ts +++ b/packages/state-transition/test/unit/util/deposit.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; -import {ssz} from "@lodestar/types"; import {createChainForkConfig} from "@lodestar/config"; import {MAX_DEPOSITS} from "@lodestar/params"; +import {ssz} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; import {getEth1DepositCount} from "../../../src/index.js"; import {createCachedBeaconStateTest} from "../../utils/state.js"; diff --git a/packages/state-transition/test/unit/util/epoch.test.ts b/packages/state-transition/test/unit/util/epoch.test.ts index e86a41875e1d..cc11688ef080 100644 --- a/packages/state-transition/test/unit/util/epoch.test.ts +++ b/packages/state-transition/test/unit/util/epoch.test.ts @@ -1,12 +1,12 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {GENESIS_SLOT, MAX_SEED_LOOKAHEAD} from "@lodestar/params"; import {Epoch, Slot} from "@lodestar/types"; import { - computeStartSlotAtEpoch, - getPreviousEpoch, computeActivationExitEpoch, computeEpochAtSlot, + computeStartSlotAtEpoch, + getPreviousEpoch, } from "../../../src/util/index.js"; import {generateState} from "../../utils/state.js"; diff --git a/packages/state-transition/test/unit/util/flags.test.ts b/packages/state-transition/test/unit/util/flags.test.ts index 07a8ce3fe097..58e40ff38586 100644 --- a/packages/state-transition/test/unit/util/flags.test.ts +++ b/packages/state-transition/test/unit/util/flags.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; describe("Altair status flags", () => { for (let prev = 0b000; prev <= 0b111; prev++) { diff --git a/packages/state-transition/test/unit/util/loadState.test.ts b/packages/state-transition/test/unit/util/loadState.test.ts index 97a792a28adb..4955c707e8ff 100644 --- a/packages/state-transition/test/unit/util/loadState.test.ts +++ b/packages/state-transition/test/unit/util/loadState.test.ts @@ -1,8 +1,8 @@ -import {describe, it, expect} from "vitest"; -import {ssz} from "@lodestar/types"; -import {mainnetChainConfig} from "@lodestar/config/networks"; import {createChainForkConfig} from "@lodestar/config"; +import {mainnetChainConfig} from "@lodestar/config/networks"; import {ForkName, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {ssz} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; import {loadStateAndValidators} from "../../../src/util/loadState/loadState.js"; describe("loadStateAndValidators", () => { diff --git a/packages/state-transition/test/unit/util/loadState/findModifiedInactivityScores.test.ts b/packages/state-transition/test/unit/util/loadState/findModifiedInactivityScores.test.ts index 85697af2b7c1..77301b3aef58 100644 --- a/packages/state-transition/test/unit/util/loadState/findModifiedInactivityScores.test.ts +++ b/packages/state-transition/test/unit/util/loadState/findModifiedInactivityScores.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { INACTIVITY_SCORE_SIZE, findModifiedInactivityScores, diff --git a/packages/state-transition/test/unit/util/loadState/findModifiedValidators.test.ts b/packages/state-transition/test/unit/util/loadState/findModifiedValidators.test.ts index 25c6233d2738..29c2b974a7a9 100644 --- a/packages/state-transition/test/unit/util/loadState/findModifiedValidators.test.ts +++ b/packages/state-transition/test/unit/util/loadState/findModifiedValidators.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {fromHexString} from "@chainsafe/ssz"; +import {describe, expect, it} from "vitest"; import {findModifiedValidators} from "../../../../src/util/loadState/findModifiedValidators.js"; import {generateState} from "../../../utils/state.js"; import {generateValidators} from "../../../utils/validator.js"; diff --git a/packages/state-transition/test/unit/util/loadState/loadValidator.test.ts b/packages/state-transition/test/unit/util/loadState/loadValidator.test.ts index 9a2094531813..9295df4f9797 100644 --- a/packages/state-transition/test/unit/util/loadState/loadValidator.test.ts +++ b/packages/state-transition/test/unit/util/loadState/loadValidator.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; import {CompositeViewDU} from "@chainsafe/ssz"; import {phase0, ssz} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; import {loadValidator} from "../../../../src/util/loadState/loadValidator.js"; describe("loadValidator", () => { diff --git a/packages/state-transition/test/unit/util/misc.test.ts b/packages/state-transition/test/unit/util/misc.test.ts index 5651da5ac5d1..ae6387137a3f 100644 --- a/packages/state-transition/test/unit/util/misc.test.ts +++ b/packages/state-transition/test/unit/util/misc.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; -import {toBigIntLE} from "bigint-buffer"; import {GENESIS_SLOT, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params"; +import {toBigIntLE} from "bigint-buffer"; import {getBlockRoot} from "../../../src/util/index.js"; import {generateState} from "../../utils/state.js"; diff --git a/packages/state-transition/test/unit/util/seed.test.ts b/packages/state-transition/test/unit/util/seed.test.ts index 7f7c0e1f8bc7..e0f9e5d8ae67 100644 --- a/packages/state-transition/test/unit/util/seed.test.ts +++ b/packages/state-transition/test/unit/util/seed.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {toHexString} from "@chainsafe/ssz"; import {GENESIS_EPOCH, GENESIS_SLOT, SLOTS_PER_EPOCH} from "@lodestar/params"; diff --git a/packages/state-transition/test/unit/util/shuffling.test.ts b/packages/state-transition/test/unit/util/shuffling.test.ts index f4039b472f5c..ed8eb1775db6 100644 --- a/packages/state-transition/test/unit/util/shuffling.test.ts +++ b/packages/state-transition/test/unit/util/shuffling.test.ts @@ -1,8 +1,8 @@ -import {describe, it, expect} from "vitest"; import {ssz} from "@lodestar/types"; -import {generateState} from "../../utils/state.js"; -import {computeEpochShuffling, computeEpochShufflingAsync} from "../../../src/util/epochShuffling.js"; +import {describe, expect, it} from "vitest"; import {computeEpochAtSlot} from "../../../src/index.js"; +import {computeEpochShuffling, computeEpochShufflingAsync} from "../../../src/util/epochShuffling.js"; +import {generateState} from "../../utils/state.js"; describe("EpochShuffling", () => { it("async and sync versions should be identical", async () => { diff --git a/packages/state-transition/test/unit/util/slashing.test.ts b/packages/state-transition/test/unit/util/slashing.test.ts index 49a7b6454c25..fbae1abbce84 100644 --- a/packages/state-transition/test/unit/util/slashing.test.ts +++ b/packages/state-transition/test/unit/util/slashing.test.ts @@ -1,4 +1,4 @@ -import {expect, it, describe} from "vitest"; +import {describe, expect, it} from "vitest"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {Epoch, phase0, ssz} from "@lodestar/types"; diff --git a/packages/state-transition/test/unit/util/slot.test.ts b/packages/state-transition/test/unit/util/slot.test.ts index c9546ad60043..aa76498b366f 100644 --- a/packages/state-transition/test/unit/util/slot.test.ts +++ b/packages/state-transition/test/unit/util/slot.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {Slot} from "@lodestar/types"; import {computeSlotsSinceEpochStart} from "../../../src/util/index.js"; diff --git a/packages/state-transition/test/unit/util/validator.test.ts b/packages/state-transition/test/unit/util/validator.test.ts index 203adf9d8ba3..9c571f87c029 100644 --- a/packages/state-transition/test/unit/util/validator.test.ts +++ b/packages/state-transition/test/unit/util/validator.test.ts @@ -1,12 +1,12 @@ -import {describe, it, expect, beforeEach} from "vitest"; +import {beforeEach, describe, expect, it} from "vitest"; import {phase0, ssz} from "@lodestar/types"; import {getActiveValidatorIndices, isActiveValidator, isSlashableValidator} from "../../../src/util/index.js"; import {randBetween} from "../../utils/misc.js"; -import {generateValidator} from "../../utils/validator.js"; import {generateState} from "../../utils/state.js"; +import {generateValidator} from "../../utils/validator.js"; describe("getActiveValidatorIndices", () => { it("empty list of validators should return no indices (empty list)", () => { diff --git a/packages/state-transition/test/unit/util/weakSubjectivity.test.ts b/packages/state-transition/test/unit/util/weakSubjectivity.test.ts index ce9f02b5ed2f..3db06f86a191 100644 --- a/packages/state-transition/test/unit/util/weakSubjectivity.test.ts +++ b/packages/state-transition/test/unit/util/weakSubjectivity.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; import {config} from "@lodestar/config/default"; -import {computeWeakSubjectivityPeriodFromConstituents} from "../../../src/util/weakSubjectivity.js"; +import {describe, expect, it} from "vitest"; import {getChurnLimit} from "../../../src/util/validator.js"; +import {computeWeakSubjectivityPeriodFromConstituents} from "../../../src/util/weakSubjectivity.js"; describe("weak subjectivity tests", () => { describe("computeWeakSubjectivityPeriodFromConstituents", () => { diff --git a/packages/state-transition/test/utils/capella.ts b/packages/state-transition/test/utils/capella.ts index 7ef9248a5675..249053e2a22a 100644 --- a/packages/state-transition/test/utils/capella.ts +++ b/packages/state-transition/test/utils/capella.ts @@ -1,5 +1,4 @@ import crypto from "node:crypto"; -import {ssz} from "@lodestar/types"; import {config} from "@lodestar/config/default"; import { BLS_WITHDRAWAL_PREFIX, @@ -7,10 +6,11 @@ import { SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT, } from "@lodestar/params"; +import {ssz} from "@lodestar/types"; import {BeaconStateCapella, CachedBeaconStateCapella} from "../../src/index.js"; -import {createCachedBeaconStateTest} from "./state.js"; -import {mulberry32} from "./rand.js"; import {interopPubkeysCached} from "./interop.js"; +import {mulberry32} from "./rand.js"; +import {createCachedBeaconStateTest} from "./state.js"; export interface WithdrawalOpts { excessBalance: number; diff --git a/packages/state-transition/test/utils/state.ts b/packages/state-transition/test/utils/state.ts index 9a79faf74480..23cd90e05469 100644 --- a/packages/state-transition/test/utils/state.ts +++ b/packages/state-transition/test/utils/state.ts @@ -1,5 +1,6 @@ import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map"; import {config as minimalConfig} from "@lodestar/config/default"; +import {config} from "@lodestar/config/default"; import { EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, @@ -8,20 +9,19 @@ import { SLOTS_PER_HISTORICAL_ROOT, } from "@lodestar/params"; import {phase0, ssz} from "@lodestar/types"; -import {config} from "@lodestar/config/default"; -import {createBeaconConfig, ChainForkConfig} from "@lodestar/config"; +import {ChainForkConfig, createBeaconConfig} from "@lodestar/config"; import {ZERO_HASH} from "../../src/constants/index.js"; import {newZeroedArray} from "../../src/util/index.js"; +import {EpochCacheOpts} from "../../src/cache/epochCache.js"; +import {BeaconStateCache} from "../../src/cache/stateCache.js"; import { + BeaconStateAllForks, BeaconStatePhase0, CachedBeaconStateAllForks, - BeaconStateAllForks, createCachedBeaconState, } from "../../src/index.js"; -import {BeaconStateCache} from "../../src/cache/stateCache.js"; -import {EpochCacheOpts} from "../../src/cache/epochCache.js"; /** * Copy of BeaconState, but all fields are marked optional to allow for swapping out variables as needed. diff --git a/packages/state-transition/test/utils/testFileCache.ts b/packages/state-transition/test/utils/testFileCache.ts index 5283a6f87fa1..dff164bcec44 100644 --- a/packages/state-transition/test/utils/testFileCache.ts +++ b/packages/state-transition/test/utils/testFileCache.ts @@ -1,10 +1,10 @@ import fs from "node:fs"; import path from "node:path"; -import got from "got"; import {getClient} from "@lodestar/api"; +import {ChainForkConfig, createChainForkConfig} from "@lodestar/config"; import {NetworkName, networksChainConfig} from "@lodestar/config/networks"; -import {createChainForkConfig, ChainForkConfig} from "@lodestar/config"; import {SignedBeaconBlock} from "@lodestar/types"; +import got from "got"; import {CachedBeaconStateAllForks} from "../../src/index.js"; import {testCachePath} from "../cache.js"; import {createCachedBeaconStateTest} from "../utils/state.js"; diff --git a/packages/test-utils/src/childProcess.ts b/packages/test-utils/src/childProcess.ts index d8b86b83ee48..62262c1c7756 100644 --- a/packages/test-utils/src/childProcess.ts +++ b/packages/test-utils/src/childProcess.ts @@ -1,9 +1,9 @@ /* eslint-disable no-console */ import childProcess, {ChildProcess, ChildProcessWithoutNullStreams} from "node:child_process"; -import stream from "node:stream"; import fs from "node:fs"; import path from "node:path"; -import {prettyMsToTime, retry, sleep, Logger} from "@lodestar/utils"; +import stream from "node:stream"; +import {Logger, prettyMsToTime, retry, sleep} from "@lodestar/utils"; export type ChildProcessLogOptions = { /** diff --git a/packages/test-utils/src/cli.ts b/packages/test-utils/src/cli.ts index a7b2a248bc7e..bdc87df96ac2 100644 --- a/packages/test-utils/src/cli.ts +++ b/packages/test-utils/src/cli.ts @@ -1,13 +1,13 @@ import childProcess from "node:child_process"; import type {Argv} from "yargs"; -import {wrapTimeout} from "./timeout.js"; -import {nodeJsBinaryPath, repoRootPath} from "./path.js"; import { ExecChildProcessOptions, SpawnChildProcessOptions, execChildProcess, spawnChildProcess, } from "./childProcess.js"; +import {nodeJsBinaryPath, repoRootPath} from "./path.js"; +import {wrapTimeout} from "./timeout.js"; // We need to make it easy for the user to pass the args for the CLI // yargs treat `["--preset minimal"] as a single arg, so we need to split it ["--preset", "minimal"] diff --git a/packages/test-utils/src/doubles.ts b/packages/test-utils/src/doubles.ts index 171c55824996..0e2b4aeb1e7f 100644 --- a/packages/test-utils/src/doubles.ts +++ b/packages/test-utils/src/doubles.ts @@ -1,5 +1,5 @@ -import {vi, MockInstance} from "vitest"; import {Logger} from "@lodestar/utils"; +import {MockInstance, vi} from "vitest"; type Callback = () => void; type Handler = (cb: Callback) => void; diff --git a/packages/test-utils/src/externalSigner.ts b/packages/test-utils/src/externalSigner.ts index 1e48e6af8d40..cdfbe484e72e 100644 --- a/packages/test-utils/src/externalSigner.ts +++ b/packages/test-utils/src/externalSigner.ts @@ -1,8 +1,8 @@ import fs from "node:fs"; import path from "node:path"; -import {dirSync as tmpDirSync} from "tmp"; -import {GenericContainer, Wait, StartedTestContainer} from "testcontainers"; import {ForkSeq} from "@lodestar/params"; +import {GenericContainer, StartedTestContainer, Wait} from "testcontainers"; +import {dirSync as tmpDirSync} from "tmp"; const web3signerVersion = "24.2.0"; diff --git a/packages/test-utils/src/http.ts b/packages/test-utils/src/http.ts index 85b64c110cab..1821cebd4112 100644 --- a/packages/test-utils/src/http.ts +++ b/packages/test-utils/src/http.ts @@ -1,5 +1,5 @@ -import axios from "axios"; import {sleep} from "@lodestar/utils"; +import axios from "axios"; type Method = "GET" | "POST" | "PUT"; diff --git a/packages/types/src/altair/index.ts b/packages/types/src/altair/index.ts index 981b2015e02a..31c28a0d3690 100644 --- a/packages/types/src/altair/index.ts +++ b/packages/types/src/altair/index.ts @@ -1,4 +1,4 @@ export * from "./types.js"; -import * as ts from "./types.js"; import * as ssz from "./sszTypes.js"; +import * as ts from "./types.js"; export {ts, ssz}; diff --git a/packages/types/src/altair/sszTypes.ts b/packages/types/src/altair/sszTypes.ts index 8998571a9f0d..61671825c840 100644 --- a/packages/types/src/altair/sszTypes.ts +++ b/packages/types/src/altair/sszTypes.ts @@ -1,13 +1,13 @@ import {BitVectorType, ContainerType, ListBasicType, ListCompositeType, VectorCompositeType} from "@chainsafe/ssz"; import { + EPOCHS_PER_SYNC_COMMITTEE_PERIOD, FINALIZED_ROOT_DEPTH, + HISTORICAL_ROOTS_LIMIT, NEXT_SYNC_COMMITTEE_DEPTH, - SYNC_COMMITTEE_SUBNET_COUNT, + SLOTS_PER_EPOCH, SYNC_COMMITTEE_SIZE, - HISTORICAL_ROOTS_LIMIT, + SYNC_COMMITTEE_SUBNET_COUNT, VALIDATOR_REGISTRY_LIMIT, - EPOCHS_PER_SYNC_COMMITTEE_PERIOD, - SLOTS_PER_EPOCH, } from "@lodestar/params"; import * as phase0Ssz from "../phase0/sszTypes.js"; import * as primitiveSsz from "../primitive/sszTypes.js"; diff --git a/packages/types/src/bellatrix/index.ts b/packages/types/src/bellatrix/index.ts index 981b2015e02a..31c28a0d3690 100644 --- a/packages/types/src/bellatrix/index.ts +++ b/packages/types/src/bellatrix/index.ts @@ -1,4 +1,4 @@ export * from "./types.js"; -import * as ts from "./types.js"; import * as ssz from "./sszTypes.js"; +import * as ts from "./types.js"; export {ts, ssz}; diff --git a/packages/types/src/bellatrix/sszTypes.ts b/packages/types/src/bellatrix/sszTypes.ts index 53e6d436c012..08560552d112 100644 --- a/packages/types/src/bellatrix/sszTypes.ts +++ b/packages/types/src/bellatrix/sszTypes.ts @@ -2,13 +2,13 @@ import {ByteListType, ByteVectorType, ContainerType, ListCompositeType} from "@c import { BYTES_PER_LOGS_BLOOM, HISTORICAL_ROOTS_LIMIT, - MAX_TRANSACTIONS_PER_PAYLOAD, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, + MAX_TRANSACTIONS_PER_PAYLOAD, } from "@lodestar/params"; -import {ssz as primitiveSsz} from "../primitive/index.js"; -import {ssz as phase0Ssz} from "../phase0/index.js"; import {ssz as altairSsz} from "../altair/index.js"; +import {ssz as phase0Ssz} from "../phase0/index.js"; +import {ssz as primitiveSsz} from "../primitive/index.js"; import {stringType} from "../utils/stringType.js"; const { diff --git a/packages/types/src/capella/index.ts b/packages/types/src/capella/index.ts index 981b2015e02a..31c28a0d3690 100644 --- a/packages/types/src/capella/index.ts +++ b/packages/types/src/capella/index.ts @@ -1,4 +1,4 @@ export * from "./types.js"; -import * as ts from "./types.js"; import * as ssz from "./sszTypes.js"; +import * as ts from "./types.js"; export {ts, ssz}; diff --git a/packages/types/src/capella/sszTypes.ts b/packages/types/src/capella/sszTypes.ts index d7cc444e77af..3110e59111d9 100644 --- a/packages/types/src/capella/sszTypes.ts +++ b/packages/types/src/capella/sszTypes.ts @@ -1,16 +1,16 @@ import {ContainerType, ListCompositeType, VectorCompositeType} from "@chainsafe/ssz"; import { + EPOCHS_PER_SYNC_COMMITTEE_PERIOD, + BLOCK_BODY_EXECUTION_PAYLOAD_DEPTH as EXECUTION_PAYLOAD_DEPTH, HISTORICAL_ROOTS_LIMIT, - MAX_WITHDRAWALS_PER_PAYLOAD, MAX_BLS_TO_EXECUTION_CHANGES, - BLOCK_BODY_EXECUTION_PAYLOAD_DEPTH as EXECUTION_PAYLOAD_DEPTH, - EPOCHS_PER_SYNC_COMMITTEE_PERIOD, + MAX_WITHDRAWALS_PER_PAYLOAD, SLOTS_PER_EPOCH, } from "@lodestar/params"; -import {ssz as primitiveSsz} from "../primitive/index.js"; -import {ssz as phase0Ssz} from "../phase0/index.js"; import {ssz as altairSsz} from "../altair/index.js"; import {ssz as bellatrixSsz} from "../bellatrix/index.js"; +import {ssz as phase0Ssz} from "../phase0/index.js"; +import {ssz as primitiveSsz} from "../primitive/index.js"; const { UintNum64, diff --git a/packages/types/src/deneb/index.ts b/packages/types/src/deneb/index.ts index 981b2015e02a..31c28a0d3690 100644 --- a/packages/types/src/deneb/index.ts +++ b/packages/types/src/deneb/index.ts @@ -1,4 +1,4 @@ export * from "./types.js"; -import * as ts from "./types.js"; import * as ssz from "./sszTypes.js"; +import * as ts from "./types.js"; export {ts, ssz}; diff --git a/packages/types/src/deneb/sszTypes.ts b/packages/types/src/deneb/sszTypes.ts index 076973bba579..6dc18c8f8b02 100644 --- a/packages/types/src/deneb/sszTypes.ts +++ b/packages/types/src/deneb/sszTypes.ts @@ -1,19 +1,19 @@ -import {ContainerType, ListCompositeType, ByteVectorType, VectorCompositeType} from "@chainsafe/ssz"; +import {ByteVectorType, ContainerType, ListCompositeType, VectorCompositeType} from "@chainsafe/ssz"; import { + BYTES_PER_FIELD_ELEMENT, + EPOCHS_PER_SYNC_COMMITTEE_PERIOD, + FIELD_ELEMENTS_PER_BLOB, HISTORICAL_ROOTS_LIMIT, + KZG_COMMITMENT_INCLUSION_PROOF_DEPTH, MAX_BLOB_COMMITMENTS_PER_BLOCK, - FIELD_ELEMENTS_PER_BLOB, MAX_REQUEST_BLOB_SIDECARS, - BYTES_PER_FIELD_ELEMENT, - EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH, - KZG_COMMITMENT_INCLUSION_PROOF_DEPTH, } from "@lodestar/params"; -import {ssz as primitiveSsz} from "../primitive/index.js"; -import {ssz as phase0Ssz} from "../phase0/index.js"; import {ssz as altairSsz} from "../altair/index.js"; import {ssz as bellatrixSsz} from "../bellatrix/index.js"; import {ssz as capellaSsz} from "../capella/index.js"; +import {ssz as phase0Ssz} from "../phase0/index.js"; +import {ssz as primitiveSsz} from "../primitive/index.js"; const {UintNum64, Slot, Root, BLSSignature, UintBn64, UintBn256, Bytes32, Bytes48, Bytes96, BLSPubkey, BlobIndex} = primitiveSsz; diff --git a/packages/types/src/electra/index.ts b/packages/types/src/electra/index.ts index 981b2015e02a..31c28a0d3690 100644 --- a/packages/types/src/electra/index.ts +++ b/packages/types/src/electra/index.ts @@ -1,4 +1,4 @@ export * from "./types.js"; -import * as ts from "./types.js"; import * as ssz from "./sszTypes.js"; +import * as ts from "./types.js"; export {ts, ssz}; diff --git a/packages/types/src/electra/sszTypes.ts b/packages/types/src/electra/sszTypes.ts index 079af08352ec..f6b6c745803e 100644 --- a/packages/types/src/electra/sszTypes.ts +++ b/packages/types/src/electra/sszTypes.ts @@ -7,28 +7,28 @@ import { VectorCompositeType, } from "@chainsafe/ssz"; import { - HISTORICAL_ROOTS_LIMIT, EPOCHS_PER_SYNC_COMMITTEE_PERIOD, - SLOTS_PER_EPOCH, - MAX_DEPOSIT_REQUESTS_PER_PAYLOAD, - MAX_VALIDATORS_PER_COMMITTEE, - MAX_COMMITTEES_PER_SLOT, + FINALIZED_ROOT_DEPTH_ELECTRA, + HISTORICAL_ROOTS_LIMIT, MAX_ATTESTATIONS_ELECTRA, MAX_ATTESTER_SLASHINGS_ELECTRA, - MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD, + MAX_COMMITTEES_PER_SLOT, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD, + MAX_DEPOSIT_REQUESTS_PER_PAYLOAD, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD, + NEXT_SYNC_COMMITTEE_DEPTH_ELECTRA, + PENDING_CONSOLIDATIONS_LIMIT, PENDING_DEPOSITS_LIMIT, PENDING_PARTIAL_WITHDRAWALS_LIMIT, - PENDING_CONSOLIDATIONS_LIMIT, - FINALIZED_ROOT_DEPTH_ELECTRA, - NEXT_SYNC_COMMITTEE_DEPTH_ELECTRA, + SLOTS_PER_EPOCH, } from "@lodestar/params"; -import {ssz as primitiveSsz} from "../primitive/index.js"; -import {ssz as phase0Ssz} from "../phase0/index.js"; import {ssz as altairSsz} from "../altair/index.js"; import {ssz as bellatrixSsz} from "../bellatrix/index.js"; import {ssz as capellaSsz} from "../capella/index.js"; import {ssz as denebSsz} from "../deneb/index.js"; +import {ssz as phase0Ssz} from "../phase0/index.js"; +import {ssz as primitiveSsz} from "../primitive/index.js"; const { Epoch, diff --git a/packages/types/src/phase0/index.ts b/packages/types/src/phase0/index.ts index 981b2015e02a..31c28a0d3690 100644 --- a/packages/types/src/phase0/index.ts +++ b/packages/types/src/phase0/index.ts @@ -1,4 +1,4 @@ export * from "./types.js"; -import * as ts from "./types.js"; import * as ssz from "./sszTypes.js"; +import * as ts from "./types.js"; export {ts, ssz}; diff --git a/packages/types/src/phase0/sszTypes.ts b/packages/types/src/phase0/sszTypes.ts index 4a04701b789d..2f9eead77608 100644 --- a/packages/types/src/phase0/sszTypes.ts +++ b/packages/types/src/phase0/sszTypes.ts @@ -4,8 +4,8 @@ import { ContainerType, ListBasicType, ListCompositeType, - VectorBasicType, ListUintNum64Type, + VectorBasicType, VectorCompositeType, } from "@chainsafe/ssz"; import { diff --git a/packages/types/src/primitive/index.ts b/packages/types/src/primitive/index.ts index b68df6795375..2e5e6adc9753 100644 --- a/packages/types/src/primitive/index.ts +++ b/packages/types/src/primitive/index.ts @@ -1,3 +1,3 @@ -import * as ts from "./types.js"; import * as ssz from "./sszTypes.js"; +import * as ts from "./types.js"; export {ts, ssz}; diff --git a/packages/types/src/primitive/sszTypes.ts b/packages/types/src/primitive/sszTypes.ts index 0b5156eaf24d..40806aa40f4a 100644 --- a/packages/types/src/primitive/sszTypes.ts +++ b/packages/types/src/primitive/sszTypes.ts @@ -1,4 +1,4 @@ -import {ByteVectorType, UintNumberType, UintBigintType, BooleanType} from "@chainsafe/ssz"; +import {BooleanType, ByteVectorType, UintBigintType, UintNumberType} from "@chainsafe/ssz"; import {ExecutionAddressType} from "../utils/executionAddress.js"; // biome-ignore lint/suspicious/noShadowRestrictedNames: We explicitly want this name for variable diff --git a/packages/types/src/sszTypes.ts b/packages/types/src/sszTypes.ts index 55218574be76..2a8666f3e243 100644 --- a/packages/types/src/sszTypes.ts +++ b/packages/types/src/sszTypes.ts @@ -1,11 +1,11 @@ import {CompositeType, CompositeView, CompositeViewDU, ContainerType, ValueOf} from "@chainsafe/ssz"; import {ForkName} from "@lodestar/params"; -import {ssz as phase0} from "./phase0/index.js"; import {ssz as altair} from "./altair/index.js"; import {ssz as bellatrix} from "./bellatrix/index.js"; import {ssz as capella} from "./capella/index.js"; import {ssz as deneb} from "./deneb/index.js"; import {ssz as electra} from "./electra/index.js"; +import {ssz as phase0} from "./phase0/index.js"; export * from "./primitive/sszTypes.js"; export {phase0, altair, bellatrix, capella, deneb, electra}; diff --git a/packages/types/src/types.ts b/packages/types/src/types.ts index b1919c2f0842..badb1f1f2333 100644 --- a/packages/types/src/types.ts +++ b/packages/types/src/types.ts @@ -7,12 +7,12 @@ import { ForkPostElectra, ForkPreBlobs, } from "@lodestar/params"; -import {ts as phase0} from "./phase0/index.js"; import {ts as altair} from "./altair/index.js"; import {ts as bellatrix} from "./bellatrix/index.js"; import {ts as capella} from "./capella/index.js"; import {ts as deneb} from "./deneb/index.js"; import {ts as electra} from "./electra/index.js"; +import {ts as phase0} from "./phase0/index.js"; import {Slot} from "./primitive/types.js"; export * from "./primitive/types.js"; diff --git a/packages/types/src/utils/executionAddress.ts b/packages/types/src/utils/executionAddress.ts index 9d555c016f04..ea1856405443 100644 --- a/packages/types/src/utils/executionAddress.ts +++ b/packages/types/src/utils/executionAddress.ts @@ -1,5 +1,5 @@ -import {keccak256} from "ethereum-cryptography/keccak.js"; import {ByteVectorType} from "@chainsafe/ssz"; +import {keccak256} from "ethereum-cryptography/keccak.js"; export type ByteVector = Uint8Array; diff --git a/packages/types/src/utils/typeguards.ts b/packages/types/src/utils/typeguards.ts index a892c3a0c9c0..d4a27e23d1d6 100644 --- a/packages/types/src/utils/typeguards.ts +++ b/packages/types/src/utils/typeguards.ts @@ -1,20 +1,20 @@ import {FINALIZED_ROOT_DEPTH_ELECTRA, ForkBlobs, ForkExecution, ForkPostElectra} from "@lodestar/params"; import { + Attestation, + BeaconBlock, + BeaconBlockBody, + BeaconBlockOrContents, + BlindedBeaconBlock, + BlindedBeaconBlockBody, BlockContents, - SignedBeaconBlock, ExecutionPayload, ExecutionPayloadAndBlobsBundle, - BeaconBlockBody, - BeaconBlockOrContents, - SignedBeaconBlockOrContents, ExecutionPayloadHeader, - BlindedBeaconBlock, + LightClientUpdate, + SignedBeaconBlock, + SignedBeaconBlockOrContents, SignedBlindedBeaconBlock, - BlindedBeaconBlockBody, SignedBlockContents, - BeaconBlock, - Attestation, - LightClientUpdate, } from "../types.js"; export function isExecutionPayload( diff --git a/packages/types/test/constants/blobs.test.ts b/packages/types/test/constants/blobs.test.ts index 4b145161d292..66927d4b6040 100644 --- a/packages/types/test/constants/blobs.test.ts +++ b/packages/types/test/constants/blobs.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import * as constants from "@lodestar/params"; +import {describe, expect, it} from "vitest"; import {ssz} from "../../src/index.js"; // NOTE: This test is here and not in lodestar-params, to prevent lodestar-params depending on SSZ diff --git a/packages/types/test/constants/lightclient.test.ts b/packages/types/test/constants/lightclient.test.ts index 567cc7c3bd17..9e87fcadca42 100644 --- a/packages/types/test/constants/lightclient.test.ts +++ b/packages/types/test/constants/lightclient.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import * as constants from "@lodestar/params"; +import {describe, expect, it} from "vitest"; import {ssz} from "../../src/index.js"; // NOTE: This test is here and not in lodestar-params, to prevent lodestar-params depending on SSZ diff --git a/packages/types/test/unit/blinded.test.ts b/packages/types/test/unit/blinded.test.ts index 3d087b610b2d..1024707705fe 100644 --- a/packages/types/test/unit/blinded.test.ts +++ b/packages/types/test/unit/blinded.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; import {ForkName, isForkExecution} from "@lodestar/params"; +import {describe, expect, it} from "vitest"; import {ssz} from "../../src/index.js"; describe("blinded data structures", () => { diff --git a/packages/types/test/unit/executionAddress.test.ts b/packages/types/test/unit/executionAddress.test.ts index 841cd52468f5..00f47fefba0c 100644 --- a/packages/types/test/unit/executionAddress.test.ts +++ b/packages/types/test/unit/executionAddress.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {toChecksumAddress} from "../../src/utils/executionAddress.js"; describe("toChecksumAddress", () => { diff --git a/packages/types/test/unit/phase0/sszTypes.test.ts b/packages/types/test/unit/phase0/sszTypes.test.ts index 4bdb2031e5ea..473adae31aea 100644 --- a/packages/types/test/unit/phase0/sszTypes.test.ts +++ b/packages/types/test/unit/phase0/sszTypes.test.ts @@ -1,5 +1,5 @@ import {ContainerType} from "@chainsafe/ssz"; -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ssz} from "../../../src/index.js"; import {ValidatorType} from "../../../src/phase0/validator.js"; diff --git a/packages/types/test/unit/ssz.test.ts b/packages/types/test/unit/ssz.test.ts index 41e4e0bbd23b..1cc249a17a3e 100644 --- a/packages/types/test/unit/ssz.test.ts +++ b/packages/types/test/unit/ssz.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {ssz} from "../../src/index.js"; describe("size", () => { diff --git a/packages/types/test/unit/validatorStatus.test.ts b/packages/types/test/unit/validatorStatus.test.ts index b5bd34004bdc..70189a29ee11 100644 --- a/packages/types/test/unit/validatorStatus.test.ts +++ b/packages/types/test/unit/validatorStatus.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {getValidatorStatus} from "../../src/utils/validatorStatus.js"; +import {describe, expect, it} from "vitest"; import {phase0} from "../../src/types.js"; +import {getValidatorStatus} from "../../src/utils/validatorStatus.js"; describe("getValidatorStatus", () => { it("should return PENDING_INITIALIZED", () => { diff --git a/packages/utils/src/bytes.ts b/packages/utils/src/bytes.ts index c290232ce8db..195157d7c132 100644 --- a/packages/utils/src/bytes.ts +++ b/packages/utils/src/bytes.ts @@ -1,4 +1,4 @@ -import {toBufferLE, toBigIntLE, toBufferBE, toBigIntBE} from "bigint-buffer"; +import {toBigIntBE, toBigIntLE, toBufferBE, toBufferLE} from "bigint-buffer"; type Endianness = "le" | "be"; diff --git a/packages/utils/src/bytes/index.ts b/packages/utils/src/bytes/index.ts index a079764738b7..762a33bf5237 100644 --- a/packages/utils/src/bytes/index.ts +++ b/packages/utils/src/bytes/index.ts @@ -1,14 +1,14 @@ import { - toHex as browserToHex, - toRootHex as browserToRootHex, fromHex as browserFromHex, + toHex as browserToHex, toPubkeyHex as browserToPubkeyHex, + toRootHex as browserToRootHex, } from "./browser.js"; import { - toHex as nodeToHex, - toRootHex as nodeToRootHex, fromHex as nodeFromHex, + toHex as nodeToHex, toPubkeyHex as nodeToPubkeyHex, + toRootHex as nodeToRootHex, } from "./nodejs.js"; let toHex = browserToHex; diff --git a/packages/utils/src/command.ts b/packages/utils/src/command.ts index 2e62ba5a9648..13bf5850c8de 100644 --- a/packages/utils/src/command.ts +++ b/packages/utils/src/command.ts @@ -1,4 +1,4 @@ -import type {Options, Argv} from "yargs"; +import type {Argv, Options} from "yargs"; export interface CliExample { command: string; diff --git a/packages/utils/test/perf/bytes.test.ts b/packages/utils/test/perf/bytes.test.ts index 6a1e96ab1579..9c67745ed9a3 100644 --- a/packages/utils/test/perf/bytes.test.ts +++ b/packages/utils/test/perf/bytes.test.ts @@ -1,7 +1,7 @@ import {itBench} from "@dapplion/benchmark"; -import {toHex, toRootHex} from "../../src/bytes/nodejs.js"; -import {toHex as browserToHex, toRootHex as browserToRootHex} from "../../src/bytes/browser.js"; import {toHexString} from "../../src/bytes.js"; +import {toHex as browserToHex, toRootHex as browserToRootHex} from "../../src/bytes/browser.js"; +import {toHex, toRootHex} from "../../src/bytes/nodejs.js"; describe("bytes utils", () => { const runsFactor = 1000; diff --git a/packages/utils/test/types/metrics.test-d.ts b/packages/utils/test/types/metrics.test-d.ts index 2f008618e648..c6ad53e976c8 100644 --- a/packages/utils/test/types/metrics.test-d.ts +++ b/packages/utils/test/types/metrics.test-d.ts @@ -1,5 +1,5 @@ -import {describe, it, expectTypeOf} from "vitest"; import {Counter as PromCounter, Gauge as PromGauge, Histogram as PromHistogram} from "prom-client"; +import {describe, expectTypeOf, it} from "vitest"; import {Counter, Gauge, Histogram, MetricsRegister} from "../../src/metrics.js"; describe("Metric types", () => { diff --git a/packages/utils/test/unit/assert.test.ts b/packages/utils/test/unit/assert.test.ts index 3b413efa11be..536c84effd97 100644 --- a/packages/utils/test/unit/assert.test.ts +++ b/packages/utils/test/unit/assert.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {assert} from "../../src/index.js"; describe("assert", () => { diff --git a/packages/utils/test/unit/base64.test.ts b/packages/utils/test/unit/base64.test.ts index 7c68e84f4c3e..97a1a4d6c9b5 100644 --- a/packages/utils/test/unit/base64.test.ts +++ b/packages/utils/test/unit/base64.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {toBase64, fromBase64} from "../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {fromBase64, toBase64} from "../../src/index.js"; describe("toBase64", () => { it("should encode UTF-8 string as base64 string", () => { diff --git a/packages/utils/test/unit/bytes.test.ts b/packages/utils/test/unit/bytes.test.ts index af4df6652f13..3877ad81e120 100644 --- a/packages/utils/test/unit/bytes.test.ts +++ b/packages/utils/test/unit/bytes.test.ts @@ -1,13 +1,13 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { - intToBytes, bytesToInt, - toHex, + formatBytes, fromHex, + intToBytes, + toHex, toHexString, - toRootHex, toPubkeyHex, - formatBytes, + toRootHex, } from "../../src/index.js"; describe("intToBytes", () => { diff --git a/packages/utils/test/unit/err.test.ts b/packages/utils/test/unit/err.test.ts index 7a08ebbc4319..e344e2fb88c7 100644 --- a/packages/utils/test/unit/err.test.ts +++ b/packages/utils/test/unit/err.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {Err, isErr, mapOkResults, mapOkResultsAsync, Result} from "../../src/err.js"; +import {describe, expect, it} from "vitest"; +import {Err, Result, isErr, mapOkResults, mapOkResultsAsync} from "../../src/err.js"; describe("Result Err", () => { describe("isErr works with any type", () => { diff --git a/packages/utils/test/unit/format.test.ts b/packages/utils/test/unit/format.test.ts index 11e8b89cb7a1..2ca679f32a79 100644 --- a/packages/utils/test/unit/format.test.ts +++ b/packages/utils/test/unit/format.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {formatBigDecimal} from "../../src/format.js"; describe("format", () => { diff --git a/packages/utils/test/unit/math.test.ts b/packages/utils/test/unit/math.test.ts index e324714600b1..98a995b24ed8 100644 --- a/packages/utils/test/unit/math.test.ts +++ b/packages/utils/test/unit/math.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {bigIntMin, bigIntMax, intDiv, intSqrt, bigIntSqrt} from "../../src/index.js"; +import {describe, expect, it} from "vitest"; +import {bigIntMax, bigIntMin, bigIntSqrt, intDiv, intSqrt} from "../../src/index.js"; describe("util/maths", () => { describe("bigIntMin", () => { diff --git a/packages/utils/test/unit/objects.test.ts b/packages/utils/test/unit/objects.test.ts index a94ed9213390..59f2024e09d6 100644 --- a/packages/utils/test/unit/objects.test.ts +++ b/packages/utils/test/unit/objects.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {isPlainObject, objectToExpectedCase} from "../../src/index.js"; describe("Objects helper", () => { diff --git a/packages/utils/test/unit/promise.node.test.ts b/packages/utils/test/unit/promise.node.test.ts index 55cbad36b211..d2e7a6e4cc22 100644 --- a/packages/utils/test/unit/promise.node.test.ts +++ b/packages/utils/test/unit/promise.node.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, vi, beforeEach, afterEach} from "vitest"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {callFnWhenAwait} from "../../src/promise.js"; // TODO: Need to debug why vi.useFakeTimers() is not working for the browsers diff --git a/packages/utils/test/unit/promise.test.ts b/packages/utils/test/unit/promise.test.ts index c76e72f70a22..56df4d88ecf1 100644 --- a/packages/utils/test/unit/promise.test.ts +++ b/packages/utils/test/unit/promise.test.ts @@ -1,7 +1,7 @@ /* Causing this error on usage of expect.any(Number) */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import {describe, it, expect} from "vitest"; -import {wrapPromise, PromiseRejectedResult, PromiseFulfilledResult} from "../../src/promise.js"; +import {describe, expect, it} from "vitest"; +import {PromiseFulfilledResult, PromiseRejectedResult, wrapPromise} from "../../src/promise.js"; describe("promise", () => { describe("wrapPromise", () => { diff --git a/packages/utils/test/unit/promiserace.test.ts b/packages/utils/test/unit/promiserace.test.ts index 4b20f19f9fba..5aa5886c9848 100644 --- a/packages/utils/test/unit/promiserace.test.ts +++ b/packages/utils/test/unit/promiserace.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {resolveOrRacePromises, PromiseResult} from "../../src/promise.js"; +import {describe, expect, it} from "vitest"; +import {PromiseResult, resolveOrRacePromises} from "../../src/promise.js"; import {NonEmptyArray} from "../../src/types.js"; describe("resolveOrRacePromises", () => { diff --git a/packages/utils/test/unit/retry.test.ts b/packages/utils/test/unit/retry.test.ts index bd77c499a364..5e5793664e3b 100644 --- a/packages/utils/test/unit/retry.test.ts +++ b/packages/utils/test/unit/retry.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect} from "vitest"; -import {retry, RetryOptions} from "../../src/retry.js"; +import {describe, expect, it} from "vitest"; +import {RetryOptions, retry} from "../../src/retry.js"; describe("retry", () => { type TestCase = { diff --git a/packages/utils/test/unit/sleep.test.ts b/packages/utils/test/unit/sleep.test.ts index ef632fd34f64..40dd699a5a06 100644 --- a/packages/utils/test/unit/sleep.test.ts +++ b/packages/utils/test/unit/sleep.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {sleep} from "../../src/sleep.js"; +import {describe, expect, it} from "vitest"; import {ErrorAborted} from "../../src/errors.js"; +import {sleep} from "../../src/sleep.js"; describe("sleep", () => { it("Should resolve timeout", async () => { diff --git a/packages/utils/test/unit/timeout.test.ts b/packages/utils/test/unit/timeout.test.ts index 7b4b1eb883be..7568983daa8d 100644 --- a/packages/utils/test/unit/timeout.test.ts +++ b/packages/utils/test/unit/timeout.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect, afterEach} from "vitest"; -import {withTimeout} from "../../src/timeout.js"; +import {afterEach, describe, expect, it} from "vitest"; import {ErrorAborted, TimeoutError} from "../../src/errors.js"; +import {withTimeout} from "../../src/timeout.js"; describe("withTimeout", () => { const data = "DATA"; diff --git a/packages/utils/test/unit/waitFor.test.ts b/packages/utils/test/unit/waitFor.test.ts index 412c06f888ed..844b0d157c61 100644 --- a/packages/utils/test/unit/waitFor.test.ts +++ b/packages/utils/test/unit/waitFor.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect} from "vitest"; -import {waitFor, createElapsedTimeTracker} from "../../src/waitFor.js"; +import {describe, expect, it} from "vitest"; import {ErrorAborted, TimeoutError} from "../../src/errors.js"; import {sleep} from "../../src/sleep.js"; +import {createElapsedTimeTracker, waitFor} from "../../src/waitFor.js"; describe("waitFor", () => { const interval = 10; diff --git a/packages/validator/src/genesis.ts b/packages/validator/src/genesis.ts index 7fc3e20673bc..9e947f89c949 100644 --- a/packages/validator/src/genesis.ts +++ b/packages/validator/src/genesis.ts @@ -1,6 +1,6 @@ +import {ApiClient} from "@lodestar/api"; import {Genesis} from "@lodestar/types/phase0"; import {Logger, sleep} from "@lodestar/utils"; -import {ApiClient} from "@lodestar/api"; /** The time between polls when waiting for genesis */ const WAITING_FOR_GENESIS_POLL_MS = 12 * 1000; diff --git a/packages/validator/src/repositories/metaDataRepository.ts b/packages/validator/src/repositories/metaDataRepository.ts index 0ba1565a6651..263ad9f8c6f3 100644 --- a/packages/validator/src/repositories/metaDataRepository.ts +++ b/packages/validator/src/repositories/metaDataRepository.ts @@ -1,8 +1,8 @@ -import {encodeKey, DbReqOpts} from "@lodestar/db"; +import {DbReqOpts, encodeKey} from "@lodestar/db"; import {Root, UintNum64} from "@lodestar/types"; import {ssz} from "@lodestar/types"; -import {LodestarValidatorDatabaseController} from "../types.js"; import {Bucket, getBucketNameByValue} from "../buckets.js"; +import {LodestarValidatorDatabaseController} from "../types.js"; const GENESIS_VALIDATORS_ROOT = Buffer.from("GENESIS_VALIDATORS_ROOT"); const GENESIS_TIME = Buffer.from("GENESIS_TIME"); diff --git a/packages/validator/src/services/attestation.ts b/packages/validator/src/services/attestation.ts index 7f0dffa3e970..514ecbbd613d 100644 --- a/packages/validator/src/services/attestation.ts +++ b/packages/validator/src/services/attestation.ts @@ -1,18 +1,18 @@ -import {BLSSignature, phase0, Slot, ssz, Attestation, SignedAggregateAndProof} from "@lodestar/types"; +import {ApiClient, routes} from "@lodestar/api"; +import {ChainForkConfig} from "@lodestar/config"; import {ForkSeq} from "@lodestar/params"; import {computeEpochAtSlot, isAggregatorFromCommitteeLength} from "@lodestar/state-transition"; +import {Attestation, BLSSignature, SignedAggregateAndProof, Slot, phase0, ssz} from "@lodestar/types"; import {prettyBytes, sleep, toRootHex} from "@lodestar/utils"; -import {ApiClient, routes} from "@lodestar/api"; -import {ChainForkConfig} from "@lodestar/config"; -import {IClock, LoggerVc} from "../util/index.js"; -import {PubkeyHex} from "../types.js"; import {Metrics} from "../metrics.js"; -import {ValidatorStore} from "./validatorStore.js"; -import {AttestationDutiesService, AttDutyAndProof} from "./attestationDuties.js"; -import {groupAttDutiesByCommitteeIndex} from "./utils.js"; +import {PubkeyHex} from "../types.js"; +import {IClock, LoggerVc} from "../util/index.js"; +import {AttDutyAndProof, AttestationDutiesService} from "./attestationDuties.js"; import {ChainHeaderTracker} from "./chainHeaderTracker.js"; -import {SyncingStatusTracker} from "./syncingStatusTracker.js"; import {ValidatorEventEmitter} from "./emitter.js"; +import {SyncingStatusTracker} from "./syncingStatusTracker.js"; +import {groupAttDutiesByCommitteeIndex} from "./utils.js"; +import {ValidatorStore} from "./validatorStore.js"; export type AttestationServiceOpts = { afterBlockDelaySlotFraction?: number; diff --git a/packages/validator/src/services/attestationDuties.ts b/packages/validator/src/services/attestationDuties.ts index 83838afe1492..b57b163b78b8 100644 --- a/packages/validator/src/services/attestationDuties.ts +++ b/packages/validator/src/services/attestationDuties.ts @@ -1,14 +1,14 @@ +import {ApiClient, routes} from "@lodestar/api"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; -import {sleep, toPubkeyHex} from "@lodestar/utils"; import {computeEpochAtSlot, isAggregatorFromCommitteeLength, isStartSlotOfEpoch} from "@lodestar/state-transition"; -import {BLSSignature, Epoch, Slot, ValidatorIndex, RootHex} from "@lodestar/types"; -import {ApiClient, routes} from "@lodestar/api"; -import {batchItems, IClock, LoggerVc} from "../util/index.js"; -import {PubkeyHex} from "../types.js"; +import {BLSSignature, Epoch, RootHex, Slot, ValidatorIndex} from "@lodestar/types"; +import {sleep, toPubkeyHex} from "@lodestar/utils"; import {Metrics} from "../metrics.js"; -import {ValidatorStore} from "./validatorStore.js"; +import {PubkeyHex} from "../types.js"; +import {IClock, LoggerVc, batchItems} from "../util/index.js"; import {ChainHeaderTracker, HeadEventData} from "./chainHeaderTracker.js"; import {SyncingStatusTracker} from "./syncingStatusTracker.js"; +import {ValidatorStore} from "./validatorStore.js"; /** Only retain `HISTORICAL_DUTIES_EPOCHS` duties prior to the current epoch. */ const HISTORICAL_DUTIES_EPOCHS = 2; diff --git a/packages/validator/src/services/block.ts b/packages/validator/src/services/block.ts index cb295450e96b..a27b5abe4b79 100644 --- a/packages/validator/src/services/block.ts +++ b/packages/validator/src/services/block.ts @@ -1,26 +1,26 @@ +import {ApiClient, routes} from "@lodestar/api"; +import {ChainForkConfig} from "@lodestar/config"; +import {ForkBlobs, ForkExecution, ForkName, ForkPreBlobs, ForkSeq} from "@lodestar/params"; import { BLSPubkey, - Slot, BLSSignature, - ProducedBlockSource, - deneb, - isBlockContents, BeaconBlock, BeaconBlockOrContents, - isBlindedSignedBeaconBlock, BlindedBeaconBlock, + ProducedBlockSource, SignedBeaconBlock, SignedBlindedBeaconBlock, + Slot, + deneb, + isBlindedSignedBeaconBlock, + isBlockContents, } from "@lodestar/types"; -import {ChainForkConfig} from "@lodestar/config"; -import {ForkPreBlobs, ForkBlobs, ForkSeq, ForkExecution, ForkName} from "@lodestar/params"; import {extendError, prettyBytes, prettyWeiToEth, toPubkeyHex} from "@lodestar/utils"; -import {ApiClient, routes} from "@lodestar/api"; -import {IClock, LoggerVc} from "../util/index.js"; -import {PubkeyHex} from "../types.js"; import {Metrics} from "../metrics.js"; -import {ValidatorStore} from "./validatorStore.js"; +import {PubkeyHex} from "../types.js"; +import {IClock, LoggerVc} from "../util/index.js"; import {BlockDutiesService, GENESIS_SLOT} from "./blockDuties.js"; +import {ValidatorStore} from "./validatorStore.js"; // The following combination of blocks and blobs can be produced // i) a full block pre deneb diff --git a/packages/validator/src/services/blockDuties.ts b/packages/validator/src/services/blockDuties.ts index d0e16f60e816..c9fc1712513d 100644 --- a/packages/validator/src/services/blockDuties.ts +++ b/packages/validator/src/services/blockDuties.ts @@ -1,11 +1,11 @@ +import {ApiClient, routes} from "@lodestar/api"; +import {ChainConfig} from "@lodestar/config"; import {computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {BLSPubkey, Epoch, RootHex, Slot} from "@lodestar/types"; -import {ApiClient, routes} from "@lodestar/api"; import {sleep, toPubkeyHex} from "@lodestar/utils"; -import {ChainConfig} from "@lodestar/config"; -import {IClock, differenceHex, LoggerVc} from "../util/index.js"; -import {PubkeyHex} from "../types.js"; import {Metrics} from "../metrics.js"; +import {PubkeyHex} from "../types.js"; +import {IClock, LoggerVc, differenceHex} from "../util/index.js"; import {ValidatorStore} from "./validatorStore.js"; /** This polls block duties 1s before the next epoch */ diff --git a/packages/validator/src/services/chainHeaderTracker.ts b/packages/validator/src/services/chainHeaderTracker.ts index 1c0b0d9a56d8..730d5b201ed3 100644 --- a/packages/validator/src/services/chainHeaderTracker.ts +++ b/packages/validator/src/services/chainHeaderTracker.ts @@ -1,7 +1,7 @@ import {ApiClient, routes} from "@lodestar/api"; -import {Logger, fromHex} from "@lodestar/utils"; -import {Slot, Root, RootHex} from "@lodestar/types"; import {GENESIS_SLOT} from "@lodestar/params"; +import {Root, RootHex, Slot} from "@lodestar/types"; +import {Logger, fromHex} from "@lodestar/utils"; import {ValidatorEvent, ValidatorEventEmitter} from "./emitter.js"; const {EventType} = routes.events; diff --git a/packages/validator/src/services/doppelgangerService.ts b/packages/validator/src/services/doppelgangerService.ts index aa43d7bba55b..33001970ee61 100644 --- a/packages/validator/src/services/doppelgangerService.ts +++ b/packages/validator/src/services/doppelgangerService.ts @@ -1,11 +1,11 @@ -import {Epoch, ValidatorIndex} from "@lodestar/types"; import {ApiClient, routes} from "@lodestar/api"; -import {Logger, fromHex, sleep, truncBytes} from "@lodestar/utils"; import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; +import {Epoch, ValidatorIndex} from "@lodestar/types"; +import {Logger, fromHex, sleep, truncBytes} from "@lodestar/utils"; +import {Metrics} from "../metrics.js"; import {ISlashingProtection} from "../slashingProtection/index.js"; import {ProcessShutdownCallback, PubkeyHex} from "../types.js"; import {IClock} from "../util/index.js"; -import {Metrics} from "../metrics.js"; import {IndicesService} from "./indices.js"; // The number of epochs that must be checked before we assume that there are diff --git a/packages/validator/src/services/emitter.ts b/packages/validator/src/services/emitter.ts index 2072acba6219..5c27189d02cb 100644 --- a/packages/validator/src/services/emitter.ts +++ b/packages/validator/src/services/emitter.ts @@ -1,6 +1,6 @@ import {EventEmitter} from "node:events"; -import {StrictEventEmitter} from "strict-event-emitter-types"; import {Slot} from "@lodestar/types"; +import {StrictEventEmitter} from "strict-event-emitter-types"; import {HeadEventData} from "./chainHeaderTracker.js"; export enum ValidatorEvent { diff --git a/packages/validator/src/services/externalSignerSync.ts b/packages/validator/src/services/externalSignerSync.ts index 2f6828d9e09b..dfccfa942ee6 100644 --- a/packages/validator/src/services/externalSignerSync.ts +++ b/packages/validator/src/services/externalSignerSync.ts @@ -3,8 +3,8 @@ import {ChainForkConfig} from "@lodestar/config"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; import {fromHex, toPrintableUrl} from "@lodestar/utils"; -import {LoggerVc} from "../util/index.js"; import {externalSignerGetKeys} from "../util/externalSignerClient.js"; +import {LoggerVc} from "../util/index.js"; import {SignerType, ValidatorStore} from "./validatorStore.js"; export type ExternalSignerOptions = { diff --git a/packages/validator/src/services/indices.ts b/packages/validator/src/services/indices.ts index ff8d1d46ab26..0a409fe3315d 100644 --- a/packages/validator/src/services/indices.ts +++ b/packages/validator/src/services/indices.ts @@ -1,8 +1,8 @@ +import {ApiClient, routes} from "@lodestar/api"; import {ValidatorIndex} from "@lodestar/types"; import {Logger, MapDef, toPubkeyHex} from "@lodestar/utils"; -import {ApiClient, routes} from "@lodestar/api"; -import {batchItems} from "../util/index.js"; import {Metrics} from "../metrics.js"; +import {batchItems} from "../util/index.js"; /** * This is to prevent the "Request body is too large" issue for http post. diff --git a/packages/validator/src/services/prepareBeaconProposer.ts b/packages/validator/src/services/prepareBeaconProposer.ts index 6ae4b0a83870..51057f7f72da 100644 --- a/packages/validator/src/services/prepareBeaconProposer.ts +++ b/packages/validator/src/services/prepareBeaconProposer.ts @@ -1,10 +1,10 @@ -import {Epoch, bellatrix} from "@lodestar/types"; import {ApiClient, routes} from "@lodestar/api"; import {BeaconConfig} from "@lodestar/config"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; +import {Epoch, bellatrix} from "@lodestar/types"; -import {IClock, LoggerVc, batchItems} from "../util/index.js"; import {Metrics} from "../metrics.js"; +import {IClock, LoggerVc, batchItems} from "../util/index.js"; import {ValidatorStore} from "./validatorStore.js"; const REGISTRATION_CHUNK_SIZE = 512; diff --git a/packages/validator/src/services/syncCommittee.ts b/packages/validator/src/services/syncCommittee.ts index c960adc6986b..fb0aa74238d2 100644 --- a/packages/validator/src/services/syncCommittee.ts +++ b/packages/validator/src/services/syncCommittee.ts @@ -1,17 +1,17 @@ +import {ApiClient, routes} from "@lodestar/api"; import {ChainForkConfig} from "@lodestar/config"; -import {Slot, CommitteeIndex, altair, Root, BLSSignature} from "@lodestar/types"; -import {sleep} from "@lodestar/utils"; import {computeEpochAtSlot, isSyncCommitteeAggregator} from "@lodestar/state-transition"; -import {ApiClient, routes} from "@lodestar/api"; -import {IClock, LoggerVc} from "../util/index.js"; -import {PubkeyHex} from "../types.js"; +import {BLSSignature, CommitteeIndex, Root, Slot, altair} from "@lodestar/types"; +import {sleep} from "@lodestar/utils"; import {Metrics} from "../metrics.js"; -import {ValidatorStore} from "./validatorStore.js"; -import {SyncCommitteeDutiesService, SyncDutyAndProofs} from "./syncCommitteeDuties.js"; -import {groupSyncDutiesBySubcommitteeIndex, SubcommitteeDuty} from "./utils.js"; +import {PubkeyHex} from "../types.js"; +import {IClock, LoggerVc} from "../util/index.js"; import {ChainHeaderTracker} from "./chainHeaderTracker.js"; import {ValidatorEventEmitter} from "./emitter.js"; +import {SyncCommitteeDutiesService, SyncDutyAndProofs} from "./syncCommitteeDuties.js"; import {SyncingStatusTracker} from "./syncingStatusTracker.js"; +import {SubcommitteeDuty, groupSyncDutiesBySubcommitteeIndex} from "./utils.js"; +import {ValidatorStore} from "./validatorStore.js"; export type SyncCommitteeServiceOpts = { scAfterBlockDelaySlotFraction?: number; diff --git a/packages/validator/src/services/syncCommitteeDuties.ts b/packages/validator/src/services/syncCommitteeDuties.ts index ea448add15ec..218169e1dcea 100644 --- a/packages/validator/src/services/syncCommitteeDuties.ts +++ b/packages/validator/src/services/syncCommitteeDuties.ts @@ -1,3 +1,5 @@ +import {ApiClient, routes} from "@lodestar/api"; +import {ChainForkConfig} from "@lodestar/config"; import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params"; import { computeEpochAtSlot, @@ -6,16 +8,14 @@ import { isStartSlotOfEpoch, isSyncCommitteeAggregator, } from "@lodestar/state-transition"; -import {ChainForkConfig} from "@lodestar/config"; import {BLSSignature, Epoch, Slot, SyncPeriod, ValidatorIndex} from "@lodestar/types"; -import {ApiClient, routes} from "@lodestar/api"; import {toPubkeyHex} from "@lodestar/utils"; -import {IClock, LoggerVc} from "../util/index.js"; -import {PubkeyHex} from "../types.js"; import {Metrics} from "../metrics.js"; -import {ValidatorStore} from "./validatorStore.js"; -import {syncCommitteeIndicesToSubnets} from "./utils.js"; +import {PubkeyHex} from "../types.js"; +import {IClock, LoggerVc} from "../util/index.js"; import {SyncingStatusTracker} from "./syncingStatusTracker.js"; +import {syncCommitteeIndicesToSubnets} from "./utils.js"; +import {ValidatorStore} from "./validatorStore.js"; /** Only retain `HISTORICAL_DUTIES_PERIODS` duties prior to the current periods. */ const HISTORICAL_DUTIES_PERIODS = 2; diff --git a/packages/validator/src/services/syncingStatusTracker.ts b/packages/validator/src/services/syncingStatusTracker.ts index 4c38e670092d..bd8a8b78fc7c 100644 --- a/packages/validator/src/services/syncingStatusTracker.ts +++ b/packages/validator/src/services/syncingStatusTracker.ts @@ -1,8 +1,8 @@ import {ApiClient, routes} from "@lodestar/api"; -import {Logger} from "@lodestar/utils"; import {Slot} from "@lodestar/types"; -import {IClock} from "../util/clock.js"; +import {Logger} from "@lodestar/utils"; import {BeaconHealth, Metrics} from "../metrics.js"; +import {IClock} from "../util/clock.js"; export type SyncingStatus = routes.node.SyncingStatus; diff --git a/packages/validator/src/services/validatorStore.ts b/packages/validator/src/services/validatorStore.ts index dfd856b18d13..9253457d1b7f 100644 --- a/packages/validator/src/services/validatorStore.ts +++ b/packages/validator/src/services/validatorStore.ts @@ -1,16 +1,10 @@ -import {BitArray} from "@chainsafe/ssz"; import {SecretKey} from "@chainsafe/blst"; -import { - computeEpochAtSlot, - computeSigningRoot, - computeStartSlotAtEpoch, - computeDomain, - ZERO_HASH, - blindedOrFullBlockHashTreeRoot, -} from "@lodestar/state-transition"; +import {BitArray} from "@chainsafe/ssz"; +import {routes} from "@lodestar/api"; import {BeaconConfig} from "@lodestar/config"; import { DOMAIN_AGGREGATE_AND_PROOF, + DOMAIN_APPLICATION_BUILDER, DOMAIN_BEACON_ATTESTER, DOMAIN_BEACON_PROPOSER, DOMAIN_CONTRIBUTION_AND_PROOF, @@ -18,39 +12,45 @@ import { DOMAIN_SELECTION_PROOF, DOMAIN_SYNC_COMMITTEE, DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF, - DOMAIN_APPLICATION_BUILDER, ForkSeq, MAX_COMMITTEES_PER_SLOT, } from "@lodestar/params"; import { - altair, - BeaconBlock, - bellatrix, - BlindedBeaconBlock, + ZERO_HASH, + blindedOrFullBlockHashTreeRoot, + computeDomain, + computeEpochAtSlot, + computeSigningRoot, + computeStartSlotAtEpoch, +} from "@lodestar/state-transition"; +import { + AggregateAndProof, + Attestation, BLSPubkey, BLSSignature, + BeaconBlock, + BlindedBeaconBlock, Epoch, - phase0, Root, + SignedAggregateAndProof, SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, - ssz, ValidatorIndex, - Attestation, - AggregateAndProof, - SignedAggregateAndProof, + altair, + bellatrix, + phase0, + ssz, } from "@lodestar/types"; -import {routes} from "@lodestar/api"; import {fromHex, toPubkeyHex, toRootHex} from "@lodestar/utils"; +import {Metrics} from "../metrics.js"; import {ISlashingProtection} from "../slashingProtection/index.js"; import {PubkeyHex} from "../types.js"; -import {externalSignerPostSignature, SignableMessageType, SignableMessage} from "../util/externalSignerClient.js"; -import {Metrics} from "../metrics.js"; +import {SignableMessage, SignableMessageType, externalSignerPostSignature} from "../util/externalSignerClient.js"; import {isValidatePubkeyHex} from "../util/format.js"; import {LoggerVc} from "../util/logger.js"; -import {IndicesService} from "./indices.js"; import {DoppelgangerService} from "./doppelgangerService.js"; +import {IndicesService} from "./indices.js"; type BLSPubkeyMaybeHex = BLSPubkey | PubkeyHex; type Eth1Address = string; diff --git a/packages/validator/src/slashingProtection/attestation/attestationByTargetRepository.ts b/packages/validator/src/slashingProtection/attestation/attestationByTargetRepository.ts index 61c13bb17ce2..e97ff5f96fad 100644 --- a/packages/validator/src/slashingProtection/attestation/attestationByTargetRepository.ts +++ b/packages/validator/src/slashingProtection/attestation/attestationByTargetRepository.ts @@ -1,11 +1,11 @@ import {ContainerType, Type} from "@chainsafe/ssz"; -import {BLSPubkey, Epoch, ssz} from "@lodestar/types"; -import {intToBytes, bytesToInt} from "@lodestar/utils"; import {DB_PREFIX_LENGTH, DbReqOpts, encodeKey, uintLen} from "@lodestar/db"; +import {BLSPubkey, Epoch, ssz} from "@lodestar/types"; +import {bytesToInt, intToBytes} from "@lodestar/utils"; +import {Bucket, getBucketNameByValue} from "../../buckets.js"; import {LodestarValidatorDatabaseController} from "../../types.js"; import {SlashingProtectionAttestation} from "../types.js"; import {blsPubkeyLen, uniqueVectorArr} from "../utils.js"; -import {Bucket, getBucketNameByValue} from "../../buckets.js"; /** * Manages validator db storage of attestations. diff --git a/packages/validator/src/slashingProtection/attestation/attestationLowerBoundRepository.ts b/packages/validator/src/slashingProtection/attestation/attestationLowerBoundRepository.ts index 84a4e7032a70..3cd6deab8881 100644 --- a/packages/validator/src/slashingProtection/attestation/attestationLowerBoundRepository.ts +++ b/packages/validator/src/slashingProtection/attestation/attestationLowerBoundRepository.ts @@ -1,8 +1,8 @@ import {ContainerType, Type} from "@chainsafe/ssz"; +import {DbReqOpts, encodeKey} from "@lodestar/db"; import {BLSPubkey, Epoch, ssz} from "@lodestar/types"; -import {encodeKey, DbReqOpts} from "@lodestar/db"; -import {LodestarValidatorDatabaseController} from "../../types.js"; import {Bucket, getBucketNameByValue} from "../../buckets.js"; +import {LodestarValidatorDatabaseController} from "../../types.js"; // Only used locally here export interface SlashingProtectionLowerBound { diff --git a/packages/validator/src/slashingProtection/attestation/index.ts b/packages/validator/src/slashingProtection/attestation/index.ts index f0d3a0bca172..8b2fec1bccab 100644 --- a/packages/validator/src/slashingProtection/attestation/index.ts +++ b/packages/validator/src/slashingProtection/attestation/index.ts @@ -1,10 +1,10 @@ import {BLSPubkey, Epoch} from "@lodestar/types"; -import {isEqualNonZeroRoot, minEpoch} from "../utils.js"; import {MinMaxSurround, SurroundAttestationError, SurroundAttestationErrorCode} from "../minMaxSurround/index.js"; import {SlashingProtectionAttestation} from "../types.js"; -import {InvalidAttestationError, InvalidAttestationErrorCode} from "./errors.js"; +import {isEqualNonZeroRoot, minEpoch} from "../utils.js"; import {AttestationByTargetRepository} from "./attestationByTargetRepository.js"; import {AttestationLowerBoundRepository} from "./attestationLowerBoundRepository.js"; +import {InvalidAttestationError, InvalidAttestationErrorCode} from "./errors.js"; export { AttestationByTargetRepository, AttestationLowerBoundRepository, diff --git a/packages/validator/src/slashingProtection/block/blockBySlotRepository.ts b/packages/validator/src/slashingProtection/block/blockBySlotRepository.ts index eb1ae092cf3f..2a1e86fcce23 100644 --- a/packages/validator/src/slashingProtection/block/blockBySlotRepository.ts +++ b/packages/validator/src/slashingProtection/block/blockBySlotRepository.ts @@ -1,9 +1,9 @@ import {ContainerType, Type} from "@chainsafe/ssz"; -import {BLSPubkey, Slot, ssz} from "@lodestar/types"; -import {intToBytes, bytesToInt} from "@lodestar/utils"; import {DB_PREFIX_LENGTH, DbReqOpts, encodeKey, uintLen} from "@lodestar/db"; -import {LodestarValidatorDatabaseController} from "../../types.js"; +import {BLSPubkey, Slot, ssz} from "@lodestar/types"; +import {bytesToInt, intToBytes} from "@lodestar/utils"; import {Bucket, getBucketNameByValue} from "../../buckets.js"; +import {LodestarValidatorDatabaseController} from "../../types.js"; import {SlashingProtectionBlock} from "../types.js"; import {blsPubkeyLen, uniqueVectorArr} from "../utils.js"; diff --git a/packages/validator/src/slashingProtection/block/index.ts b/packages/validator/src/slashingProtection/block/index.ts index 385575e82a0a..44a06d3ef01d 100644 --- a/packages/validator/src/slashingProtection/block/index.ts +++ b/packages/validator/src/slashingProtection/block/index.ts @@ -1,8 +1,8 @@ import {BLSPubkey} from "@lodestar/types"; -import {isEqualNonZeroRoot} from "../utils.js"; import {SlashingProtectionBlock} from "../types.js"; -import {InvalidBlockError, InvalidBlockErrorCode} from "./errors.js"; +import {isEqualNonZeroRoot} from "../utils.js"; import {BlockBySlotRepository} from "./blockBySlotRepository.js"; +import {InvalidBlockError, InvalidBlockErrorCode} from "./errors.js"; export {BlockBySlotRepository, InvalidBlockError, InvalidBlockErrorCode}; enum SafeStatus { diff --git a/packages/validator/src/slashingProtection/index.ts b/packages/validator/src/slashingProtection/index.ts index bc57b0e51c13..388744f95449 100644 --- a/packages/validator/src/slashingProtection/index.ts +++ b/packages/validator/src/slashingProtection/index.ts @@ -1,23 +1,23 @@ import {BLSPubkey, Epoch, Root} from "@lodestar/types"; import {Logger, toPubkeyHex} from "@lodestar/utils"; -import {LodestarValidatorDatabaseController} from "../types.js"; import {uniqueVectorArr} from "../slashingProtection/utils.js"; -import {BlockBySlotRepository, SlashingProtectionBlockService} from "./block/index.js"; +import {LodestarValidatorDatabaseController} from "../types.js"; import { AttestationByTargetRepository, AttestationLowerBoundRepository, SlashingProtectionAttestationService, } from "./attestation/index.js"; -import {ISlashingProtection} from "./interface.js"; +import {BlockBySlotRepository, SlashingProtectionBlockService} from "./block/index.js"; import { - InterchangeLodestar, Interchange, InterchangeFormatVersion, + InterchangeLodestar, parseInterchange, serializeInterchange, } from "./interchange/index.js"; -import {MinMaxSurround, DistanceStoreRepository} from "./minMaxSurround/index.js"; -import {SlashingProtectionBlock, SlashingProtectionAttestation} from "./types.js"; +import {ISlashingProtection} from "./interface.js"; +import {DistanceStoreRepository, MinMaxSurround} from "./minMaxSurround/index.js"; +import {SlashingProtectionAttestation, SlashingProtectionBlock} from "./types.js"; export {InvalidAttestationError, InvalidAttestationErrorCode} from "./attestation/index.js"; export {InvalidBlockError, InvalidBlockErrorCode} from "./block/index.js"; diff --git a/packages/validator/src/slashingProtection/interchange/formats/completeV4.ts b/packages/validator/src/slashingProtection/interchange/formats/completeV4.ts index 26210390a272..9cc514acd854 100644 --- a/packages/validator/src/slashingProtection/interchange/formats/completeV4.ts +++ b/packages/validator/src/slashingProtection/interchange/formats/completeV4.ts @@ -1,6 +1,6 @@ import {fromHex, toPubkeyHex, toRootHex} from "@lodestar/utils"; -import {InterchangeLodestar} from "../types.js"; import {fromOptionalHexString, numToString, toOptionalHexString} from "../../utils.js"; +import {InterchangeLodestar} from "../types.js"; /** * A complete record of all blocks and attestations signed by a set of validators diff --git a/packages/validator/src/slashingProtection/interchange/formats/v5.ts b/packages/validator/src/slashingProtection/interchange/formats/v5.ts index 88e2ce70fe07..5059fa1917bf 100644 --- a/packages/validator/src/slashingProtection/interchange/formats/v5.ts +++ b/packages/validator/src/slashingProtection/interchange/formats/v5.ts @@ -1,6 +1,6 @@ import {fromHex, toPubkeyHex, toRootHex} from "@lodestar/utils"; -import {InterchangeLodestar} from "../types.js"; import {fromOptionalHexString, numToString, toOptionalHexString} from "../../utils.js"; +import {InterchangeLodestar} from "../types.js"; /** * A complete record of all blocks and attestations signed by a set of validators diff --git a/packages/validator/src/slashingProtection/interchange/parseInterchange.ts b/packages/validator/src/slashingProtection/interchange/parseInterchange.ts index 117cd11b5f2b..ec6b3c1ee6d6 100644 --- a/packages/validator/src/slashingProtection/interchange/parseInterchange.ts +++ b/packages/validator/src/slashingProtection/interchange/parseInterchange.ts @@ -1,9 +1,9 @@ import {Root} from "@lodestar/types"; import {isEqualRoot} from "../utils.js"; import {InterchangeError, InterchangeErrorErrorCode} from "./errors.js"; -import {Interchange, InterchangeLodestar} from "./types.js"; import {InterchangeCompleteV4, parseInterchangeCompleteV4} from "./formats/completeV4.js"; import {InterchangeV5, parseInterchangeV5} from "./formats/v5.js"; +import {Interchange, InterchangeLodestar} from "./types.js"; export function parseInterchange(interchange: Interchange, expectedGenesisValidatorsRoot: Root): InterchangeLodestar { const format = (interchange as InterchangeCompleteV4)?.metadata?.interchange_format; diff --git a/packages/validator/src/slashingProtection/interchange/serializeInterchange.ts b/packages/validator/src/slashingProtection/interchange/serializeInterchange.ts index a99fb3f3d172..4abb03b23d23 100644 --- a/packages/validator/src/slashingProtection/interchange/serializeInterchange.ts +++ b/packages/validator/src/slashingProtection/interchange/serializeInterchange.ts @@ -1,7 +1,7 @@ import {InterchangeError, InterchangeErrorErrorCode} from "./errors.js"; -import {Interchange, InterchangeFormatVersion, InterchangeLodestar} from "./types.js"; import {serializeInterchangeCompleteV4} from "./formats/completeV4.js"; import {serializeInterchangeV5} from "./formats/v5.js"; +import {Interchange, InterchangeFormatVersion, InterchangeLodestar} from "./types.js"; export function serializeInterchange( interchangeLodestar: InterchangeLodestar, diff --git a/packages/validator/src/slashingProtection/interface.ts b/packages/validator/src/slashingProtection/interface.ts index c2a790c98a65..11efa98d20f9 100644 --- a/packages/validator/src/slashingProtection/interface.ts +++ b/packages/validator/src/slashingProtection/interface.ts @@ -1,7 +1,7 @@ import {BLSPubkey, Epoch, Root} from "@lodestar/types"; import {Logger} from "@lodestar/utils"; import {Interchange, InterchangeFormatVersion} from "./interchange/types.js"; -import {SlashingProtectionBlock, SlashingProtectionAttestation} from "./types.js"; +import {SlashingProtectionAttestation, SlashingProtectionBlock} from "./types.js"; export interface ISlashingProtection { /** diff --git a/packages/validator/src/slashingProtection/minMaxSurround/distanceStoreRepository.ts b/packages/validator/src/slashingProtection/minMaxSurround/distanceStoreRepository.ts index 45315bf95b03..556eaf5374ba 100644 --- a/packages/validator/src/slashingProtection/minMaxSurround/distanceStoreRepository.ts +++ b/packages/validator/src/slashingProtection/minMaxSurround/distanceStoreRepository.ts @@ -1,5 +1,5 @@ import {Type} from "@chainsafe/ssz"; -import {encodeKey, DbReqOpts} from "@lodestar/db"; +import {DbReqOpts, encodeKey} from "@lodestar/db"; import {BLSPubkey, Epoch, ssz} from "@lodestar/types"; import {intToBytes} from "@lodestar/utils"; import {Bucket, getBucketNameByValue} from "../../buckets.js"; diff --git a/packages/validator/src/slashingProtection/minMaxSurround/minMaxSurround.ts b/packages/validator/src/slashingProtection/minMaxSurround/minMaxSurround.ts index 446c3cd763e7..87976f734ba6 100644 --- a/packages/validator/src/slashingProtection/minMaxSurround/minMaxSurround.ts +++ b/packages/validator/src/slashingProtection/minMaxSurround/minMaxSurround.ts @@ -1,6 +1,6 @@ import {BLSPubkey} from "@lodestar/types"; -import {IMinMaxSurround, DistanceEntry, IDistanceStore, MinMaxSurroundAttestation} from "./interface.js"; import {SurroundAttestationError, SurroundAttestationErrorCode} from "./errors.js"; +import {DistanceEntry, IDistanceStore, IMinMaxSurround, MinMaxSurroundAttestation} from "./interface.js"; // surround vote checking with min-max surround // https://github.com/protolambda/eth2-surround#min-max-surround diff --git a/packages/validator/src/types.ts b/packages/validator/src/types.ts index dd44fd49c61e..a765a7960b3f 100644 --- a/packages/validator/src/types.ts +++ b/packages/validator/src/types.ts @@ -1,6 +1,6 @@ import {SecretKey} from "@chainsafe/blst"; -import {BLSPubkey} from "@lodestar/types"; import {DatabaseController} from "@lodestar/db"; +import {BLSPubkey} from "@lodestar/types"; export type GenesisInfo = { startTime: number; diff --git a/packages/validator/src/util/clock.ts b/packages/validator/src/util/clock.ts index 4b3fc45cd803..6b7e0868233a 100644 --- a/packages/validator/src/util/clock.ts +++ b/packages/validator/src/util/clock.ts @@ -1,8 +1,8 @@ -import {ErrorAborted, Logger, isErrorAborted, sleep} from "@lodestar/utils"; -import {GENESIS_SLOT, SLOTS_PER_EPOCH} from "@lodestar/params"; import {ChainForkConfig} from "@lodestar/config"; -import {Epoch, Slot, TimeSeconds} from "@lodestar/types"; +import {GENESIS_SLOT, SLOTS_PER_EPOCH} from "@lodestar/params"; import {computeEpochAtSlot, getCurrentSlot} from "@lodestar/state-transition"; +import {Epoch, Slot, TimeSeconds} from "@lodestar/types"; +import {ErrorAborted, Logger, isErrorAborted, sleep} from "@lodestar/utils"; type RunEveryFn = (slot: Slot, signal: AbortSignal) => Promise; diff --git a/packages/validator/src/util/externalSignerClient.ts b/packages/validator/src/util/externalSignerClient.ts index 54c0c16946ad..ab5849cf1a6b 100644 --- a/packages/validator/src/util/externalSignerClient.ts +++ b/packages/validator/src/util/externalSignerClient.ts @@ -1,23 +1,23 @@ import {ContainerType, ValueOf} from "@chainsafe/ssz"; import {fetch} from "@lodestar/api"; +import {BeaconConfig} from "@lodestar/config"; +import {ForkPreExecution, ForkSeq} from "@lodestar/params"; +import {blindedOrFullBlockToHeader, computeEpochAtSlot} from "@lodestar/state-transition"; import { - phase0, - altair, - capella, + AggregateAndProof, BeaconBlock, BlindedBeaconBlock, - AggregateAndProof, - sszTypesFor, - ssz, - Slot, Epoch, - RootHex, Root, + RootHex, + Slot, + altair, + capella, + phase0, + ssz, + sszTypesFor, } from "@lodestar/types"; -import {ForkPreExecution, ForkSeq} from "@lodestar/params"; import {ValidatorRegistrationV1} from "@lodestar/types/bellatrix"; -import {BeaconConfig} from "@lodestar/config"; -import {computeEpochAtSlot, blindedOrFullBlockToHeader} from "@lodestar/state-transition"; import {toHex, toRootHex} from "@lodestar/utils"; import {PubkeyHex} from "../types.js"; diff --git a/packages/validator/src/util/params.ts b/packages/validator/src/util/params.ts index 16374af2b837..53ccd759a5c1 100644 --- a/packages/validator/src/util/params.ts +++ b/packages/validator/src/util/params.ts @@ -1,5 +1,5 @@ import {ChainConfig, chainConfigToJson} from "@lodestar/config"; -import {activePreset, BeaconPreset, presetToJson} from "@lodestar/params"; +import {BeaconPreset, activePreset, presetToJson} from "@lodestar/params"; export class NotEqualParamsError extends Error {} diff --git a/packages/validator/src/validator.ts b/packages/validator/src/validator.ts index 09a3a80062da..ecb8bb4a161e 100644 --- a/packages/validator/src/validator.ts +++ b/packages/validator/src/validator.ts @@ -1,27 +1,27 @@ +import {ApiClient, ApiRequestInit, defaultInit, getClient, routes} from "@lodestar/api"; +import {BeaconConfig, ChainForkConfig, createBeaconConfig} from "@lodestar/config"; +import {computeEpochAtSlot, getCurrentSlot} from "@lodestar/state-transition"; import {BLSPubkey, phase0, ssz} from "@lodestar/types"; -import {createBeaconConfig, BeaconConfig, ChainForkConfig} from "@lodestar/config"; import {Genesis} from "@lodestar/types/phase0"; import {Logger, toPrintableUrl, toRootHex} from "@lodestar/utils"; -import {getClient, ApiClient, routes, ApiRequestInit, defaultInit} from "@lodestar/api"; -import {computeEpochAtSlot, getCurrentSlot} from "@lodestar/state-transition"; -import {Clock, IClock} from "./util/clock.js"; import {waitForGenesis} from "./genesis.js"; -import {BlockProposingService} from "./services/block.js"; +import {Metrics} from "./metrics.js"; +import {MetaDataRepository} from "./repositories/metaDataRepository.js"; import {AttestationService} from "./services/attestation.js"; +import {BlockProposingService} from "./services/block.js"; +import {ChainHeaderTracker} from "./services/chainHeaderTracker.js"; +import {DoppelgangerService} from "./services/doppelgangerService.js"; +import {ValidatorEventEmitter} from "./services/emitter.js"; +import {ExternalSignerOptions, pollExternalSignerPubkeys} from "./services/externalSignerSync.js"; import {IndicesService} from "./services/indices.js"; +import {pollBuilderValidatorRegistration, pollPrepareBeaconProposer} from "./services/prepareBeaconProposer.js"; import {SyncCommitteeService} from "./services/syncCommittee.js"; -import {pollPrepareBeaconProposer, pollBuilderValidatorRegistration} from "./services/prepareBeaconProposer.js"; -import {ExternalSignerOptions, pollExternalSignerPubkeys} from "./services/externalSignerSync.js"; -import {Interchange, InterchangeFormatVersion, ISlashingProtection} from "./slashingProtection/index.js"; -import {assertEqualParams, getLoggerVc, NotEqualParamsError} from "./util/index.js"; -import {ChainHeaderTracker} from "./services/chainHeaderTracker.js"; import {SyncingStatusTracker} from "./services/syncingStatusTracker.js"; -import {ValidatorEventEmitter} from "./services/emitter.js"; -import {ValidatorStore, Signer, ValidatorProposerConfig, defaultOptions} from "./services/validatorStore.js"; +import {Signer, ValidatorProposerConfig, ValidatorStore, defaultOptions} from "./services/validatorStore.js"; +import {ISlashingProtection, Interchange, InterchangeFormatVersion} from "./slashingProtection/index.js"; import {LodestarValidatorDatabaseController, ProcessShutdownCallback, PubkeyHex} from "./types.js"; -import {Metrics} from "./metrics.js"; -import {MetaDataRepository} from "./repositories/metaDataRepository.js"; -import {DoppelgangerService} from "./services/doppelgangerService.js"; +import {Clock, IClock} from "./util/clock.js"; +import {NotEqualParamsError, assertEqualParams, getLoggerVc} from "./util/index.js"; export type ValidatorModules = { opts: ValidatorOptions; diff --git a/packages/validator/test/e2e/web3signer.test.ts b/packages/validator/test/e2e/web3signer.test.ts index 855b3dd9f754..32a95276a102 100644 --- a/packages/validator/test/e2e/web3signer.test.ts +++ b/packages/validator/test/e2e/web3signer.test.ts @@ -1,14 +1,14 @@ -import {expect, describe, it, vi, beforeAll, afterAll} from "vitest"; -import {fromHex, toHex} from "@lodestar/utils"; -import {config} from "@lodestar/config/default"; -import {computeStartSlotAtEpoch, interopSecretKey, interopSecretKeys} from "@lodestar/state-transition"; +import {getClient, routes} from "@lodestar/api"; import {createBeaconConfig} from "@lodestar/config"; +import {config} from "@lodestar/config/default"; import {genesisData} from "@lodestar/config/networks"; -import {getClient, routes} from "@lodestar/api"; -import {ssz, sszTypesFor} from "@lodestar/types"; import {ForkSeq} from "@lodestar/params"; -import {getKeystoresStr, StartedExternalSigner, startExternalSigner} from "@lodestar/test-utils"; -import {Interchange, ISlashingProtection, Signer, SignerType, ValidatorStore} from "../../src/index.js"; +import {computeStartSlotAtEpoch, interopSecretKey, interopSecretKeys} from "@lodestar/state-transition"; +import {StartedExternalSigner, getKeystoresStr, startExternalSigner} from "@lodestar/test-utils"; +import {ssz, sszTypesFor} from "@lodestar/types"; +import {fromHex, toHex} from "@lodestar/utils"; +import {afterAll, beforeAll, describe, expect, it, vi} from "vitest"; +import {ISlashingProtection, Interchange, Signer, SignerType, ValidatorStore} from "../../src/index.js"; import {IndicesService} from "../../src/services/indices.js"; import {testLogger} from "../utils/logger.js"; diff --git a/packages/validator/test/spec/downloadTests.ts b/packages/validator/test/spec/downloadTests.ts index 7aede8425b19..aa360df38a0c 100644 --- a/packages/validator/test/spec/downloadTests.ts +++ b/packages/validator/test/spec/downloadTests.ts @@ -1,5 +1,5 @@ import {downloadGenericSpecTests} from "@lodestar/spec-test-util/downloadTests"; -import {SPEC_TEST_LOCATION, SPEC_TEST_VERSION, SPEC_TEST_REPO_URL, TESTS_TO_DOWNLOAD} from "./params.js"; +import {SPEC_TEST_LOCATION, SPEC_TEST_REPO_URL, SPEC_TEST_VERSION, TESTS_TO_DOWNLOAD} from "./params.js"; /* eslint-disable no-console */ diff --git a/packages/validator/test/spec/index.test.ts b/packages/validator/test/spec/index.test.ts index bd6ff947ca41..457b8589a0eb 100644 --- a/packages/validator/test/spec/index.test.ts +++ b/packages/validator/test/spec/index.test.ts @@ -1,12 +1,12 @@ -import {expect, describe, it, beforeAll, afterAll} from "vitest"; -import {rimraf} from "rimraf"; import {LevelDbController} from "@lodestar/db"; +import {rimraf} from "rimraf"; +import {afterAll, beforeAll, describe, expect, it} from "vitest"; import { + InvalidAttestationError, + InvalidBlockError, SlashingProtection, - SlashingProtectionBlock, SlashingProtectionAttestation, - InvalidBlockError, - InvalidAttestationError, + SlashingProtectionBlock, } from "../../src/slashingProtection/index.js"; import {testLogger} from "../utils/logger.js"; diff --git a/packages/validator/test/spec/spec.test.ts b/packages/validator/test/spec/spec.test.ts index 41b094473c66..18c58bd84fa7 100644 --- a/packages/validator/test/spec/spec.test.ts +++ b/packages/validator/test/spec/spec.test.ts @@ -1,16 +1,16 @@ import path from "node:path"; -import {describe, it, beforeAll, beforeEach, afterAll, expect} from "vitest"; -import {rimraf} from "rimraf"; import {fromHexString} from "@chainsafe/ssz"; import {LevelDbController} from "@lodestar/db"; import {ZERO_HASH} from "@lodestar/state-transition"; +import {rimraf} from "rimraf"; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from "vitest"; import { - SlashingProtection, InterchangeError, InvalidAttestationError, InvalidBlockError, - SlashingProtectionBlock, + SlashingProtection, SlashingProtectionAttestation, + SlashingProtectionBlock, } from "../../src/slashingProtection/index.js"; import {testLogger} from "../utils/logger.js"; import {loadTestCases} from "../utils/spec.js"; diff --git a/packages/validator/test/unit/services/attestation.test.ts b/packages/validator/test/unit/services/attestation.test.ts index 1652af83c5d1..e3a6f0771d62 100644 --- a/packages/validator/test/unit/services/attestation.test.ts +++ b/packages/validator/test/unit/services/attestation.test.ts @@ -1,20 +1,20 @@ -import {describe, it, expect, beforeAll, beforeEach, afterEach, vi} from "vitest"; -import {toHexString} from "@chainsafe/ssz"; import {SecretKey} from "@chainsafe/blst"; -import {ssz} from "@lodestar/types"; +import {toHexString} from "@chainsafe/ssz"; import {routes} from "@lodestar/api"; import {ChainConfig, createChainForkConfig} from "@lodestar/config"; import {config as defaultConfig} from "@lodestar/config/default"; import {ForkName} from "@lodestar/params"; +import {ssz} from "@lodestar/types"; +import {afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; import {AttestationService, AttestationServiceOpts} from "../../../src/services/attestation.js"; import {AttDutyAndProof} from "../../../src/services/attestationDuties.js"; +import {ChainHeaderTracker} from "../../../src/services/chainHeaderTracker.js"; +import {ValidatorEventEmitter} from "../../../src/services/emitter.js"; +import {SyncingStatusTracker} from "../../../src/services/syncingStatusTracker.js"; import {ValidatorStore} from "../../../src/services/validatorStore.js"; import {getApiClientStub, mockApiResponse} from "../../utils/apiStub.js"; -import {loggerVc} from "../../utils/logger.js"; import {ClockMock} from "../../utils/clock.js"; -import {ChainHeaderTracker} from "../../../src/services/chainHeaderTracker.js"; -import {SyncingStatusTracker} from "../../../src/services/syncingStatusTracker.js"; -import {ValidatorEventEmitter} from "../../../src/services/emitter.js"; +import {loggerVc} from "../../utils/logger.js"; import {ZERO_HASH, ZERO_HASH_HEX} from "../../utils/types.js"; vi.mock("../../../src/services/validatorStore.js"); diff --git a/packages/validator/test/unit/services/attestationDuties.test.ts b/packages/validator/test/unit/services/attestationDuties.test.ts index fafccf209777..93a7aa0a83f7 100644 --- a/packages/validator/test/unit/services/attestationDuties.test.ts +++ b/packages/validator/test/unit/services/attestationDuties.test.ts @@ -1,20 +1,20 @@ -import {describe, it, expect, beforeAll, vi, Mocked, beforeEach, afterEach} from "vitest"; -import {toBufferBE} from "bigint-buffer"; -import {toHexString} from "@chainsafe/ssz"; import {SecretKey} from "@chainsafe/blst"; -import {chainConfig} from "@lodestar/config/default"; +import {toHexString} from "@chainsafe/ssz"; import {routes} from "@lodestar/api"; -import {ssz} from "@lodestar/types"; +import {chainConfig} from "@lodestar/config/default"; import {computeEpochAtSlot} from "@lodestar/state-transition"; +import {ssz} from "@lodestar/types"; +import {toBufferBE} from "bigint-buffer"; +import {Mocked, afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; import {AttestationDutiesService} from "../../../src/services/attestationDuties.js"; +import {ChainHeaderTracker} from "../../../src/services/chainHeaderTracker.js"; +import {SyncingStatusTracker} from "../../../src/services/syncingStatusTracker.js"; import {ValidatorStore} from "../../../src/services/validatorStore.js"; import {getApiClientStub, mockApiResponse} from "../../utils/apiStub.js"; -import {loggerVc} from "../../utils/logger.js"; import {ClockMock} from "../../utils/clock.js"; -import {initValidatorStore} from "../../utils/validatorStore.js"; -import {ChainHeaderTracker} from "../../../src/services/chainHeaderTracker.js"; -import {SyncingStatusTracker} from "../../../src/services/syncingStatusTracker.js"; +import {loggerVc} from "../../utils/logger.js"; import {ZERO_HASH_HEX} from "../../utils/types.js"; +import {initValidatorStore} from "../../utils/validatorStore.js"; vi.mock("../../../src/services/chainHeaderTracker.js"); diff --git a/packages/validator/test/unit/services/block.test.ts b/packages/validator/test/unit/services/block.test.ts index dc89f1169d92..6c80bea4ffd2 100644 --- a/packages/validator/test/unit/services/block.test.ts +++ b/packages/validator/test/unit/services/block.test.ts @@ -1,17 +1,17 @@ -import {describe, it, expect, beforeAll, beforeEach, afterEach, vi} from "vitest"; -import {toHexString} from "@chainsafe/ssz"; import {SecretKey} from "@chainsafe/blst"; +import {toHexString} from "@chainsafe/ssz"; +import {routes} from "@lodestar/api"; import {createChainForkConfig} from "@lodestar/config"; import {config as mainnetConfig} from "@lodestar/config/default"; -import {sleep} from "@lodestar/utils"; -import {ssz, ProducedBlockSource} from "@lodestar/types"; -import {routes} from "@lodestar/api"; import {ForkName} from "@lodestar/params"; +import {ProducedBlockSource, ssz} from "@lodestar/types"; +import {sleep} from "@lodestar/utils"; +import {afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; import {BlockProposingService} from "../../../src/services/block.js"; import {ValidatorStore} from "../../../src/services/validatorStore.js"; import {getApiClientStub, mockApiResponse} from "../../utils/apiStub.js"; -import {loggerVc} from "../../utils/logger.js"; import {ClockMock} from "../../utils/clock.js"; +import {loggerVc} from "../../utils/logger.js"; import {ZERO_HASH_HEX} from "../../utils/types.js"; vi.mock("../../../src/services/validatorStore.js"); diff --git a/packages/validator/test/unit/services/blockDuties.test.ts b/packages/validator/test/unit/services/blockDuties.test.ts index 51ced2cd70de..3150155d030a 100644 --- a/packages/validator/test/unit/services/blockDuties.test.ts +++ b/packages/validator/test/unit/services/blockDuties.test.ts @@ -1,17 +1,17 @@ -import {describe, it, expect, beforeAll, beforeEach, afterEach, vi} from "vitest"; -import {toBufferBE} from "bigint-buffer"; -import {toHexString} from "@chainsafe/ssz"; import {SecretKey} from "@chainsafe/blst"; +import {toHexString} from "@chainsafe/ssz"; import {routes} from "@lodestar/api"; import {chainConfig} from "@lodestar/config/default"; import {toHex} from "@lodestar/utils"; +import {toBufferBE} from "bigint-buffer"; +import {afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; import {BlockDutiesService} from "../../../src/services/blockDuties.js"; import {ValidatorStore} from "../../../src/services/validatorStore.js"; import {getApiClientStub, mockApiResponse} from "../../utils/apiStub.js"; -import {loggerVc} from "../../utils/logger.js"; import {ClockMock} from "../../utils/clock.js"; -import {initValidatorStore} from "../../utils/validatorStore.js"; +import {loggerVc} from "../../utils/logger.js"; import {ZERO_HASH_HEX} from "../../utils/types.js"; +import {initValidatorStore} from "../../utils/validatorStore.js"; describe("BlockDutiesService", () => { const api = getApiClientStub(); diff --git a/packages/validator/test/unit/services/doppelganger.test.ts b/packages/validator/test/unit/services/doppelganger.test.ts index 943f0c08a9d3..ba112245b0d2 100644 --- a/packages/validator/test/unit/services/doppelganger.test.ts +++ b/packages/validator/test/unit/services/doppelganger.test.ts @@ -1,14 +1,14 @@ -import {describe, it, expect} from "vitest"; +import {ApiClient} from "@lodestar/api"; +import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; import {Epoch, Slot, ValidatorIndex} from "@lodestar/types"; import {sleep} from "@lodestar/utils"; -import {computeStartSlotAtEpoch} from "@lodestar/state-transition"; -import {ApiClient} from "@lodestar/api"; +import {describe, expect, it} from "vitest"; import {DoppelgangerService, DoppelgangerStatus} from "../../../src/services/doppelgangerService.js"; import {IndicesService} from "../../../src/services/indices.js"; -import {SlashingProtectionMock} from "../../utils/slashingProtectionMock.js"; import {mockApiResponse} from "../../utils/apiStub.js"; -import {testLogger} from "../../utils/logger.js"; import {ClockMock} from "../../utils/clock.js"; +import {testLogger} from "../../utils/logger.js"; +import {SlashingProtectionMock} from "../../utils/slashingProtectionMock.js"; // At genesis start validating immediately diff --git a/packages/validator/test/unit/services/externalSignerSync.test.ts b/packages/validator/test/unit/services/externalSignerSync.test.ts index 8dc7bff7e469..4a0ca5338bcb 100644 --- a/packages/validator/test/unit/services/externalSignerSync.test.ts +++ b/packages/validator/test/unit/services/externalSignerSync.test.ts @@ -1,14 +1,14 @@ -import {MockedFunction, afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; -import {toBufferBE} from "bigint-buffer"; import {SecretKey} from "@chainsafe/blst"; import {createChainForkConfig} from "@lodestar/config"; import {chainConfig} from "@lodestar/config/default"; +import {toBufferBE} from "bigint-buffer"; +import {MockedFunction, afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; import {ExternalSignerOptions, pollExternalSignerPubkeys} from "../../../src/services/externalSignerSync.js"; import {SignerRemote, SignerType, ValidatorStore} from "../../../src/services/validatorStore.js"; import {externalSignerGetKeys} from "../../../src/util/externalSignerClient.js"; -import {initValidatorStore} from "../../utils/validatorStore.js"; import {getApiClientStub} from "../../utils/apiStub.js"; import {loggerVc} from "../../utils/logger.js"; +import {initValidatorStore} from "../../utils/validatorStore.js"; vi.mock("../../../src/util/externalSignerClient.js"); diff --git a/packages/validator/test/unit/services/indicesService.test.ts b/packages/validator/test/unit/services/indicesService.test.ts index d4619aa65b94..91624ca36415 100644 --- a/packages/validator/test/unit/services/indicesService.test.ts +++ b/packages/validator/test/unit/services/indicesService.test.ts @@ -1,10 +1,10 @@ -import {describe, it, expect, beforeAll} from "vitest"; -import {toBufferBE} from "bigint-buffer"; -import {toHexString} from "@chainsafe/ssz"; import {SecretKey} from "@chainsafe/blst"; +import {toHexString} from "@chainsafe/ssz"; +import {toBufferBE} from "bigint-buffer"; +import {beforeAll, describe, expect, it} from "vitest"; +import {IndicesService} from "../../../src/services/indices.js"; import {getApiClientStub} from "../../utils/apiStub.js"; import {testLogger} from "../../utils/logger.js"; -import {IndicesService} from "../../../src/services/indices.js"; describe("IndicesService", () => { const logger = testLogger(); diff --git a/packages/validator/test/unit/services/syncCommitteDuties.test.ts b/packages/validator/test/unit/services/syncCommitteDuties.test.ts index 27a86d31f901..e7f0c46932ad 100644 --- a/packages/validator/test/unit/services/syncCommitteDuties.test.ts +++ b/packages/validator/test/unit/services/syncCommitteDuties.test.ts @@ -1,24 +1,24 @@ -import {describe, it, expect, beforeAll, beforeEach, afterEach, vi} from "vitest"; -import {when} from "vitest-when"; -import {toBufferBE} from "bigint-buffer"; -import {toHexString} from "@chainsafe/ssz"; import {SecretKey} from "@chainsafe/blst"; +import {toHexString} from "@chainsafe/ssz"; +import {routes} from "@lodestar/api"; import {createChainForkConfig} from "@lodestar/config"; import {config as mainnetConfig} from "@lodestar/config/default"; -import {routes} from "@lodestar/api"; import {ssz} from "@lodestar/types"; +import {toBufferBE} from "bigint-buffer"; +import {afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; +import {when} from "vitest-when"; import { SyncCommitteeDutiesService, SyncDutyAndProofs, SyncDutySubnet, } from "../../../src/services/syncCommitteeDuties.js"; -import {ValidatorStore} from "../../../src/services/validatorStore.js"; import {SyncingStatusTracker} from "../../../src/services/syncingStatusTracker.js"; +import {syncCommitteeIndicesToSubnets} from "../../../src/services/utils.js"; +import {ValidatorStore} from "../../../src/services/validatorStore.js"; import {getApiClientStub, mockApiResponse} from "../../utils/apiStub.js"; -import {loggerVc} from "../../utils/logger.js"; import {ClockMock} from "../../utils/clock.js"; +import {loggerVc} from "../../utils/logger.js"; import {initValidatorStore} from "../../utils/validatorStore.js"; -import {syncCommitteeIndicesToSubnets} from "../../../src/services/utils.js"; describe("SyncCommitteeDutiesService", () => { const api = getApiClientStub(); diff --git a/packages/validator/test/unit/services/syncCommittee.test.ts b/packages/validator/test/unit/services/syncCommittee.test.ts index 84c7f14d73b1..10ce3af44a20 100644 --- a/packages/validator/test/unit/services/syncCommittee.test.ts +++ b/packages/validator/test/unit/services/syncCommittee.test.ts @@ -1,20 +1,20 @@ -import {describe, it, expect, beforeAll, beforeEach, afterEach, vi} from "vitest"; -import {toHexString} from "@chainsafe/ssz"; import {SecretKey} from "@chainsafe/blst"; +import {toHexString} from "@chainsafe/ssz"; +import {routes} from "@lodestar/api"; import {createChainForkConfig} from "@lodestar/config"; import {config as mainnetConfig} from "@lodestar/config/default"; import {ssz} from "@lodestar/types"; -import {routes} from "@lodestar/api"; +import {afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; +import {ChainHeaderTracker} from "../../../src/services/chainHeaderTracker.js"; +import {ValidatorEventEmitter} from "../../../src/services/emitter.js"; import {SyncCommitteeService, SyncCommitteeServiceOpts} from "../../../src/services/syncCommittee.js"; import {SyncDutyAndProofs} from "../../../src/services/syncCommitteeDuties.js"; +import {SyncingStatusTracker} from "../../../src/services/syncingStatusTracker.js"; import {ValidatorStore} from "../../../src/services/validatorStore.js"; import {getApiClientStub, mockApiResponse} from "../../utils/apiStub.js"; -import {loggerVc} from "../../utils/logger.js"; import {ClockMock} from "../../utils/clock.js"; -import {ChainHeaderTracker} from "../../../src/services/chainHeaderTracker.js"; -import {SyncingStatusTracker} from "../../../src/services/syncingStatusTracker.js"; +import {loggerVc} from "../../utils/logger.js"; import {ZERO_HASH} from "../../utils/types.js"; -import {ValidatorEventEmitter} from "../../../src/services/emitter.js"; vi.mock("../../../src/services/validatorStore.js"); vi.mock("../../../src/services/emitter.js"); diff --git a/packages/validator/test/unit/services/syncingStatusTracker.test.ts b/packages/validator/test/unit/services/syncingStatusTracker.test.ts index 07364847e345..eccb00bc51ab 100644 --- a/packages/validator/test/unit/services/syncingStatusTracker.test.ts +++ b/packages/validator/test/unit/services/syncingStatusTracker.test.ts @@ -1,8 +1,8 @@ -import {describe, it, expect, vi, beforeEach, afterEach, MockedFunction} from "vitest"; +import {MockedFunction, afterEach, beforeEach, describe, expect, it, vi} from "vitest"; +import {SyncingStatus, SyncingStatusTracker} from "../../../src/services/syncingStatusTracker.js"; import {getApiClientStub, mockApiResponse} from "../../utils/apiStub.js"; -import {getMockedLogger} from "../../utils/logger.js"; import {ClockMock} from "../../utils/clock.js"; -import {SyncingStatus, SyncingStatusTracker} from "../../../src/services/syncingStatusTracker.js"; +import {getMockedLogger} from "../../utils/logger.js"; describe("SyncingStatusTracker", () => { const api = getApiClientStub(); diff --git a/packages/validator/test/unit/services/utils.test.ts b/packages/validator/test/unit/services/utils.test.ts index f4bb9e57cd04..bd78f36543c5 100644 --- a/packages/validator/test/unit/services/utils.test.ts +++ b/packages/validator/test/unit/services/utils.test.ts @@ -1,5 +1,5 @@ -import {describe, it, expect, beforeAll} from "vitest"; import {SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params"; +import {beforeAll, describe, expect, it} from "vitest"; import {syncCommitteeIndicesToSubnets} from "../../../src/services/utils.js"; describe("services / utils / syncCommitteeIndicesToSubnets", () => { diff --git a/packages/validator/test/unit/slashingProtection/interchange/index.test.ts b/packages/validator/test/unit/slashingProtection/interchange/index.test.ts index 4038c6d1d4c5..92b994605df3 100644 --- a/packages/validator/test/unit/slashingProtection/interchange/index.test.ts +++ b/packages/validator/test/unit/slashingProtection/interchange/index.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; import {toHexString} from "@chainsafe/ssz"; import {Root, ssz} from "@lodestar/types"; +import {describe, expect, it} from "vitest"; import { Interchange, parseInterchange, diff --git a/packages/validator/test/unit/slashingProtection/minMaxSurround/surroundTests.test.ts b/packages/validator/test/unit/slashingProtection/minMaxSurround/surroundTests.test.ts index 6bdc49fb7f0c..7e0d31fbfe7e 100644 --- a/packages/validator/test/unit/slashingProtection/minMaxSurround/surroundTests.test.ts +++ b/packages/validator/test/unit/slashingProtection/minMaxSurround/surroundTests.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import { MinMaxSurround, MinMaxSurroundAttestation, diff --git a/packages/validator/test/unit/slashingProtection/minMaxSurround/updateSpans.test.ts b/packages/validator/test/unit/slashingProtection/minMaxSurround/updateSpans.test.ts index 62f1ea5e1b4f..3471a81f49db 100644 --- a/packages/validator/test/unit/slashingProtection/minMaxSurround/updateSpans.test.ts +++ b/packages/validator/test/unit/slashingProtection/minMaxSurround/updateSpans.test.ts @@ -1,6 +1,6 @@ -import {describe, it, expect} from "vitest"; -import {MinMaxSurroundAttestation, MinMaxSurround} from "../../../../src/slashingProtection/minMaxSurround/index.js"; -import {DistanceStoreMemory, storeToSpansPerEpoch, emptyPubkey} from "./utils.js"; +import {describe, expect, it} from "vitest"; +import {MinMaxSurround, MinMaxSurroundAttestation} from "../../../../src/slashingProtection/minMaxSurround/index.js"; +import {DistanceStoreMemory, emptyPubkey, storeToSpansPerEpoch} from "./utils.js"; const updateSpansTests: { name: string; diff --git a/packages/validator/test/unit/slashingProtection/minMaxSurround/utils.ts b/packages/validator/test/unit/slashingProtection/minMaxSurround/utils.ts index 6d9e4e0f559d..96dc470a00f7 100644 --- a/packages/validator/test/unit/slashingProtection/minMaxSurround/utils.ts +++ b/packages/validator/test/unit/slashingProtection/minMaxSurround/utils.ts @@ -1,5 +1,5 @@ import {BLSPubkey, ssz} from "@lodestar/types"; -import {IDistanceStore, DistanceEntry} from "../../../../src/slashingProtection/minMaxSurround/index.js"; +import {DistanceEntry, IDistanceStore} from "../../../../src/slashingProtection/minMaxSurround/index.js"; export const emptyPubkey = ssz.BLSPubkey.defaultValue(); export class DistanceMapStore { diff --git a/packages/validator/test/unit/slashingProtection/utils.test.ts b/packages/validator/test/unit/slashingProtection/utils.test.ts index 2e0e4859436d..178b1ac4df63 100644 --- a/packages/validator/test/unit/slashingProtection/utils.test.ts +++ b/packages/validator/test/unit/slashingProtection/utils.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {minEpoch} from "../../../src/slashingProtection/utils.js"; describe("slashingProtection / utils / minEpoch", () => { diff --git a/packages/validator/test/unit/utils/batch.test.ts b/packages/validator/test/unit/utils/batch.test.ts index 455d31e19577..78c814505859 100644 --- a/packages/validator/test/unit/utils/batch.test.ts +++ b/packages/validator/test/unit/utils/batch.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {batchItems} from "../../../src/util/index.js"; describe("util / batch", () => { diff --git a/packages/validator/test/unit/utils/clock.test.ts b/packages/validator/test/unit/utils/clock.test.ts index 056260d9e515..430251d25a6e 100644 --- a/packages/validator/test/unit/utils/clock.test.ts +++ b/packages/validator/test/unit/utils/clock.test.ts @@ -1,7 +1,7 @@ -import {describe, it, expect, beforeEach, afterEach, vi} from "vitest"; +import {BeaconConfig} from "@lodestar/config"; import {config} from "@lodestar/config/default"; import {SLOTS_PER_EPOCH} from "@lodestar/params"; -import {BeaconConfig} from "@lodestar/config"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {Clock, getCurrentSlotAround} from "../../../src/util/clock.js"; import {testLogger} from "../../utils/logger.js"; diff --git a/packages/validator/test/unit/utils/difference.test.ts b/packages/validator/test/unit/utils/difference.test.ts index 023a6144877a..3d249d1999d9 100644 --- a/packages/validator/test/unit/utils/difference.test.ts +++ b/packages/validator/test/unit/utils/difference.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {differenceHex} from "../../../src/util/difference.js"; describe("utils / differenceHex", () => { diff --git a/packages/validator/test/unit/utils/metrics.test.ts b/packages/validator/test/unit/utils/metrics.test.ts index de4010761001..6876c3705ae9 100644 --- a/packages/validator/test/unit/utils/metrics.test.ts +++ b/packages/validator/test/unit/utils/metrics.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from "vitest"; +import {describe, expect, it} from "vitest"; import {BeaconHealth, renderEnumNumeric} from "../../../src/metrics.js"; describe("renderEnumNumeric", () => { diff --git a/packages/validator/test/unit/utils/params.test.ts b/packages/validator/test/unit/utils/params.test.ts index 13bab507cf13..b483c9a067c3 100644 --- a/packages/validator/test/unit/utils/params.test.ts +++ b/packages/validator/test/unit/utils/params.test.ts @@ -1,9 +1,9 @@ -import {describe, it, expect} from "vitest"; -import {chainConfigToJson, ChainConfig} from "@lodestar/config"; +import {ChainConfig, chainConfigToJson} from "@lodestar/config"; import {chainConfig} from "@lodestar/config/default"; import {networksChainConfig} from "@lodestar/config/networks"; -import {assertEqualParams, NotEqualParamsError} from "../../../src/util/params.js"; -import {lighthouseHoleskyConfig, prysmHoleskyConfig, tekuHoleskyConfig, nimbusHoleskyConfig} from "./interopConfigs.js"; +import {describe, expect, it} from "vitest"; +import {NotEqualParamsError, assertEqualParams} from "../../../src/util/params.js"; +import {lighthouseHoleskyConfig, nimbusHoleskyConfig, prysmHoleskyConfig, tekuHoleskyConfig} from "./interopConfigs.js"; const testCases: {name: string; items: [ChainConfig, Record]}[] = [ {name: "lighthouse", items: [networksChainConfig.holesky, lighthouseHoleskyConfig]}, diff --git a/packages/validator/test/unit/validatorStore.test.ts b/packages/validator/test/unit/validatorStore.test.ts index b029a33e163a..d32acf41647a 100644 --- a/packages/validator/test/unit/validatorStore.test.ts +++ b/packages/validator/test/unit/validatorStore.test.ts @@ -1,15 +1,15 @@ -import {describe, it, expect, beforeEach, afterEach, vi} from "vitest"; -import {toBufferBE} from "bigint-buffer"; -import {toHexString, fromHexString} from "@chainsafe/ssz"; import {SecretKey} from "@chainsafe/blst"; +import {fromHexString, toHexString} from "@chainsafe/ssz"; +import {routes} from "@lodestar/api"; import {chainConfig} from "@lodestar/config/default"; import {bellatrix} from "@lodestar/types"; -import {routes} from "@lodestar/api"; +import {toBufferBE} from "bigint-buffer"; +import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {ValidatorStore} from "../../src/services/validatorStore.js"; +import {ValidatorProposerConfig} from "../../src/services/validatorStore.js"; import {getApiClientStub} from "../utils/apiStub.js"; import {initValidatorStore} from "../utils/validatorStore.js"; -import {ValidatorProposerConfig} from "../../src/services/validatorStore.js"; describe("ValidatorStore", () => { const api = getApiClientStub(); diff --git a/packages/validator/test/utils/apiStub.ts b/packages/validator/test/utils/apiStub.ts index 4443dab5c4ac..e26a18a1c216 100644 --- a/packages/validator/test/utils/apiStub.ts +++ b/packages/validator/test/utils/apiStub.ts @@ -1,5 +1,5 @@ -import {vi, Mocked} from "vitest"; import {ApiClientMethods, ApiResponse, Endpoint, Endpoints, HttpStatusCode, IHttpClient} from "@lodestar/api"; +import {Mocked, vi} from "vitest"; type ApiClientStub = {[K in keyof Endpoints]: Mocked>} & { httpClient: Mocked; diff --git a/packages/validator/test/utils/logger.ts b/packages/validator/test/utils/logger.ts index 44f5190dfe79..7f32ddba0381 100644 --- a/packages/validator/test/utils/logger.ts +++ b/packages/validator/test/utils/logger.ts @@ -1,6 +1,6 @@ -import {vi, Mocked} from "vitest"; import {Logger} from "@lodestar/logger"; import {getEnvLogger} from "@lodestar/logger/env"; +import {Mocked, vi} from "vitest"; import {getLoggerVc} from "../../src/util/index.js"; import {ClockMock} from "./clock.js"; diff --git a/packages/validator/test/utils/validatorStore.ts b/packages/validator/test/utils/validatorStore.ts index d3037ce522b9..e8eaa485cada 100644 --- a/packages/validator/test/utils/validatorStore.ts +++ b/packages/validator/test/utils/validatorStore.ts @@ -1,7 +1,7 @@ import {SecretKey} from "@chainsafe/blst"; import {ApiClient} from "@lodestar/api"; +import {ChainConfig, createBeaconConfig} from "@lodestar/config"; import {chainConfig} from "@lodestar/config/default"; -import {createBeaconConfig, ChainConfig} from "@lodestar/config"; import {Signer, SignerType, ValidatorStore} from "../../src/index.js"; import {IndicesService} from "../../src/services/indices.js"; import {ValidatorProposerConfig} from "../../src/services/validatorStore.js";