UNPKG

@lodestar/api

Version:

A Typescript REST client for the Ethereum Consensus API

246 lines • 9.04 kB
import { ContainerType, Type, ValueOf } from "@chainsafe/ssz"; import { ChainForkConfig } from "@lodestar/config"; import { BeaconState, Epoch, RootHex, Slot, ValidatorIndex } from "@lodestar/types"; import { EmptyArgs, EmptyMeta, EmptyRequest, EmptyResponseData } from "../../utils/codecs.js"; import { Endpoint, RouteDefinitions } from "../../utils/index.js"; import { ExecutionOptimisticFinalizedAndVersionMeta, VersionMeta } from "../../utils/metadata.js"; import { StateArgs } from "./beacon/state.js"; import { FilterGetPeers, NodePeer, PeerDirection, PeerState } from "./node.js"; export type SyncChainDebugState = { targetRoot: string | null; targetSlot: number | null; syncType: string; status: string; startEpoch: number; peers: number; batches: any[]; }; export type GossipQueueItem = { topic: unknown; propagationSource: string; data: Uint8Array; addedTimeMs: number; seenTimestampSec: number; }; export type PeerScoreStat = { peerId: string; lodestarScore: number; gossipScore: number; ignoreNegativeGossipScore: boolean; score: number; lastUpdate: number; }; export type GossipPeerScoreStat = { peerId: string; }; /** * A multiaddr with peer ID or ENR string. * * Supported formats: * - Multiaddr with peer ID: `/ip4/192.168.1.1/tcp/9000/p2p/16Uiu2HAmKLhW7...` * - ENR: `enr:-IS4QHCYrYZbAKWCBRlAy5zzaDZXJBGkcnh4MHcBFZntXNFrdvJjX04jRzjzCBOo...` * * For multiaddrs, the string must contain a /p2p/ component with the peer ID. * For ENRs, the TCP multiaddr and peer ID are extracted from the encoded record. */ export type DirectPeer = string; export type RegenQueueItem = { key: string; args: unknown; addedTimeMs: number; }; export type BlockProcessorQueueItem = { blockSlots: Slot[]; jobOpts: Record<string, string | number | boolean | undefined>; addedTimeMs: number; }; export type StateCacheItem = { slot: Slot; root: RootHex; /** Total number of reads */ reads: number; /** Unix timestamp (ms) of the last read */ lastRead: number; checkpointState: boolean; }; export type LodestarNodePeer = NodePeer & { agentVersion: string; status: unknown | null; metadata: unknown | null; agentClient: string; lastReceivedMsgUnixTsMs: number; lastStatusUnixTsMs: number; connectedUnixTsMs: number; }; export type BlacklistedBlock = { root: RootHex; slot: Slot | null; }; export type LodestarThreadType = "main" | "network" | "discv5"; declare const HistoricalSummariesResponseType: ContainerType<{ slot: import("@chainsafe/ssz").UintNumberType; historicalSummaries: import("@chainsafe/ssz").ListCompositeType<ContainerType<{ blockSummaryRoot: import("@chainsafe/ssz").ByteVectorType; stateSummaryRoot: import("@chainsafe/ssz").ByteVectorType; }>>; proof: import("@chainsafe/ssz").ArrayType<Type<Uint8Array<ArrayBufferLike>>, unknown, unknown>; }>; export type HistoricalSummariesResponse = ValueOf<typeof HistoricalSummariesResponseType>; export type CustodyInfo = { /** Earliest slot for which the node has custodied data columns */ earliestCustodiedSlot: Slot; /** Number of custody groups the node is responsible for */ custodyGroupCount: number; /** List of column indices the node is custodying */ custodyColumns: number[]; }; export type Endpoints = { /** Trigger to write a heapdump to disk at `dirpath`. May take > 1min */ writeHeapdump: Endpoint<"POST", { thread?: LodestarThreadType; dirpath?: string; }, { query: { thread?: LodestarThreadType; dirpath?: string; }; }, { filepath: string; }, EmptyMeta>; /** Trigger to write 10m network thread profile to disk */ writeProfile: Endpoint<"POST", { thread?: LodestarThreadType; duration?: number; dirpath?: string; }, { query: { thread?: LodestarThreadType; duration?: number; dirpath?: string; }; }, { result: string; }, EmptyMeta>; /** TODO: description */ getLatestWeakSubjectivityCheckpointEpoch: Endpoint<"GET", EmptyArgs, EmptyRequest, Epoch, EmptyMeta>; /** TODO: description */ getSyncChainsDebugState: Endpoint<"GET", EmptyArgs, EmptyRequest, SyncChainDebugState[], EmptyMeta>; /** Dump all items in a gossip queue, by gossipType */ getGossipQueueItems: Endpoint<"GET", { gossipType: string; }, { params: { gossipType: string; }; }, unknown[], EmptyMeta>; /** Dump all items in the regen queue */ getRegenQueueItems: Endpoint<"GET", EmptyArgs, EmptyRequest, RegenQueueItem[], EmptyMeta>; /** Dump all items in the block processor queue */ getBlockProcessorQueueItems: Endpoint<"GET", EmptyArgs, EmptyRequest, BlockProcessorQueueItem[], EmptyMeta>; /** Dump a summary of the states in the block state cache and checkpoint state cache */ getStateCacheItems: Endpoint<"GET", EmptyArgs, EmptyRequest, StateCacheItem[], EmptyMeta>; /** Dump peer gossip stats by peer */ getGossipPeerScoreStats: Endpoint<"GET", EmptyArgs, EmptyRequest, GossipPeerScoreStat[], EmptyMeta>; /** Dump lodestar score stats by peer */ getLodestarPeerScoreStats: Endpoint<"GET", EmptyArgs, EmptyRequest, PeerScoreStat[], EmptyMeta>; /** Run GC with `global.gc()` */ runGC: Endpoint<"POST", EmptyArgs, EmptyRequest, EmptyResponseData, EmptyMeta>; /** Drop all states in the state cache */ dropStateCache: Endpoint<"POST", EmptyArgs, EmptyRequest, EmptyResponseData, EmptyMeta>; /** Connect to peer at this multiaddress */ connectPeer: Endpoint<"POST", { peerId: string; multiaddrs: string[]; }, { query: { peerId: string; multiaddr: string[]; }; }, EmptyResponseData, EmptyMeta>; /** Disconnect peer */ disconnectPeer: Endpoint<"POST", { peerId: string; }, { query: { peerId: string; }; }, EmptyResponseData, EmptyMeta>; /** * Add a direct peer at runtime. * Direct peers maintain permanent mesh connections without GRAFT/PRUNE negotiation. * Accepts either a multiaddr with peer ID or an ENR string. */ addDirectPeer: Endpoint<"POST", { peer: DirectPeer; }, { query: { peer: string; }; }, { peerId: string; }, EmptyMeta>; /** Remove a peer from direct peers */ removeDirectPeer: Endpoint<"DELETE", { peerId: string; }, { query: { peerId: string; }; }, { removed: boolean; }, EmptyMeta>; /** Get list of direct peer IDs */ getDirectPeers: Endpoint<"GET", EmptyArgs, EmptyRequest, string[], EmptyMeta>; /** Same to node api with new fields */ getPeers: Endpoint<"GET", FilterGetPeers, { query: { state?: PeerState[]; direction?: PeerDirection[]; }; }, LodestarNodePeer[], { count: number; }>; /** Returns root/slot of blacklisted blocks */ getBlacklistedBlocks: Endpoint<"GET", EmptyArgs, EmptyRequest, BlacklistedBlock[], EmptyMeta>; /** Returns historical summaries and proof for a given state ID */ getHistoricalSummaries: Endpoint<"GET", StateArgs, { params: { state_id: string; }; }, HistoricalSummariesResponse, ExecutionOptimisticFinalizedAndVersionMeta>; getPersistedCheckpointState: Endpoint<"GET", { /** The checkpoint in `<root>:<epoch>` format to be returned instead of the latest safe checkpoint state */ checkpointId?: string; }, { query: { checkpoint_id?: string; }; }, BeaconState, VersionMeta>; /** * Returns the validator indices that are currently being monitored by the validator monitor. */ getMonitoredValidatorIndices: Endpoint<"GET", EmptyArgs, EmptyRequest, ValidatorIndex[], EmptyMeta>; /** Dump Discv5 Kad values */ discv5GetKadValues: Endpoint<"GET", EmptyArgs, EmptyRequest, string[], EmptyMeta>; /** * Dump level-db entry keys for a given Bucket declared in code, or for all buckets. */ dumpDbBucketKeys: Endpoint<"GET", { /** Must be the string name of a bucket entry: `allForks_blockArchive` */ bucket: string; }, { params: { bucket: string; }; }, string[], EmptyMeta>; /** Return all entries in the StateArchive index with bucket index_stateArchiveRootIndex */ dumpDbStateIndex: Endpoint<"GET", EmptyArgs, EmptyRequest, { root: RootHex; slot: Slot; }[], EmptyMeta>; /** Get custody information for data columns */ getCustodyInfo: Endpoint<"GET", EmptyArgs, EmptyRequest, CustodyInfo, EmptyMeta>; }; export declare function getDefinitions(_config: ChainForkConfig): RouteDefinitions<Endpoints>; export {}; //# sourceMappingURL=lodestar.d.ts.map