@lodestar/api
Version:
A Typescript REST client for the Ethereum Consensus API
180 lines • 7.37 kB
TypeScript
import { ContainerType, OptionalType, ValueOf } from "@chainsafe/ssz";
import { ChainForkConfig } from "@lodestar/config";
import { StringType, fulu } from "@lodestar/types";
import { EmptyArgs, EmptyMeta, EmptyRequest, EmptyResponseData } from "../../utils/codecs.js";
import { Endpoint, RouteDefinitions } from "../../utils/index.js";
export declare const NetworkIdentityType: ContainerType<{
/** Cryptographic hash of a peer’s public key. [Read more](https://docs.libp2p.io/concepts/peer-id/) */
peerId: StringType<string>;
/** Ethereum node record. [Read more](https://eips.ethereum.org/EIPS/eip-778) */
enr: StringType<string>;
p2pAddresses: import("@chainsafe/ssz").ArrayType<import("@chainsafe/ssz").Type<string>, unknown, unknown>;
discoveryAddresses: import("@chainsafe/ssz").ArrayType<import("@chainsafe/ssz").Type<string>, unknown, unknown>;
/** Based on Ethereum Consensus [Metadata object](https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#metadata) */
metadata: ContainerType<{
seqNumber: import("@chainsafe/ssz").UintBigintType;
attnets: import("@chainsafe/ssz").BitVectorType;
syncnets: import("@chainsafe/ssz").BitVectorType;
}>;
}>;
export declare const PeerCountType: ContainerType<{
disconnected: import("@chainsafe/ssz").UintNumberType;
connecting: import("@chainsafe/ssz").UintNumberType;
connected: import("@chainsafe/ssz").UintNumberType;
disconnecting: import("@chainsafe/ssz").UintNumberType;
}>;
export declare const SyncingStatusType: ContainerType<{
/** Head slot node is trying to reach */
headSlot: import("@chainsafe/ssz").UintNumberType;
/** How many slots node needs to process to reach head. 0 if synced. */
syncDistance: import("@chainsafe/ssz").UintNumberType;
/** Set to true if the node is syncing, false if the node is synced. */
isSyncing: import("@chainsafe/ssz").BooleanType;
/** Set to true if the node is optimistically tracking head. */
isOptimistic: import("@chainsafe/ssz").BooleanType;
/** Set to true if the connected el client is offline */
elOffline: import("@chainsafe/ssz").BooleanType;
}>;
export type NetworkIdentity = ValueOf<typeof NetworkIdentityType> & {
metadata: Partial<fulu.Metadata>;
};
export type PeerState = "disconnected" | "connecting" | "connected" | "disconnecting";
export type PeerDirection = "inbound" | "outbound";
export declare const NodePeerType: ContainerType<{
peerId: StringType<string>;
enr: OptionalType<StringType<string>>;
lastSeenP2pAddress: StringType<string>;
state: StringType<PeerState>;
direction: OptionalType<StringType<PeerDirection>>;
}>;
export declare const NodePeersType: import("@chainsafe/ssz").ArrayType<import("@chainsafe/ssz").Type<import("@chainsafe/ssz").ValueOfFields<{
peerId: StringType<string>;
enr: OptionalType<StringType<string>>;
lastSeenP2pAddress: StringType<string>;
state: StringType<PeerState>;
direction: OptionalType<StringType<PeerDirection>>;
}>>, unknown, unknown>;
export type NodePeer = ValueOf<typeof NodePeerType>;
export type NodePeers = ValueOf<typeof NodePeersType>;
export type PeersMeta = {
count: number;
};
export type PeerCount = ValueOf<typeof PeerCountType>;
export type FilterGetPeers = {
state?: PeerState[];
direction?: PeerDirection[];
};
export type SyncingStatus = ValueOf<typeof SyncingStatusType>;
export declare enum NodeHealth {
READY = 200,
SYNCING = 206,
NOT_INITIALIZED_OR_ISSUES = 503
}
/**
* Client code as defined in https://github.com/ethereum/execution-apis/blob/dc4dbca37ef8697d782f431af19120beaf5517f5/src/engine/identification.md#clientcode
* ClientCode.XX is dedicated to other clients which do not have their own code
*/
export declare enum ClientCode {
BU = "BU",
EJ = "EJ",
EG = "EG",
GE = "GE",
GR = "GR",
LH = "LH",
LS = "LS",
NM = "NM",
NB = "NB",
TE = "TE",
TK = "TK",
PM = "PM",
RH = "RH",
XX = "XX"
}
/**
* A structure which uniquely identifies a client implementation and its version.
* Mirrors the client version specification in the Engine API.
* https://github.com/ethereum/execution-apis/blob/dc4dbca37ef8697d782f431af19120beaf5517f5/src/engine/identification.md
*/
export type ClientVersion = {
code: ClientCode;
name: string;
version: string;
commit: string;
};
export type NodeVersionV2 = {
beaconNode: ClientVersion;
executionClient?: ClientVersion;
};
/**
* Read information about the beacon node.
*/
export type Endpoints = {
/**
* Get node network identity
* Retrieves data about the node's network presence
*/
getNetworkIdentity: Endpoint<"GET", EmptyArgs, EmptyRequest, NetworkIdentity, EmptyMeta>;
/**
* Get node network peers
* Retrieves data about the node's network peers. By default this returns all peers. Multiple query params are combined using AND conditions
*/
getPeers: Endpoint<"GET", FilterGetPeers, {
query: {
state?: PeerState[];
direction?: PeerDirection[];
};
}, NodePeers, PeersMeta>;
/**
* Get peer
* Retrieves data about the given peer
*/
getPeer: Endpoint<"GET", {
peerId: string;
}, {
params: {
peer_id: string;
};
}, NodePeer, EmptyMeta>;
/**
* Get peer count
* Retrieves number of known peers.
*/
getPeerCount: Endpoint<"GET", EmptyArgs, EmptyRequest, PeerCount, EmptyMeta>;
/**
* Get version string of the running beacon node.
* Requests that the beacon node identify information about its implementation in a format similar to a [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) field.
*/
getNodeVersion: Endpoint<"GET", EmptyArgs, EmptyRequest, {
version: string;
}, EmptyMeta>;
/**
* Get version information for the beacon node and execution client.
* Retrieves structured information about the version of the beacon node and its attached execution client
* in the same format as used on the
* [Engine API](https://github.com/ethereum/execution-apis/blob/dc4dbca37ef8697d782f431af19120beaf5517f5/src/engine/identification.md).
*
* Version information about the execution client may not be available at all times and is therefore optional.
*
* If the beacon node receives multiple values from `engine_getClientVersionV1`,
* the first value should be returned on this endpoint.
*/
getNodeVersionV2: Endpoint<"GET", EmptyArgs, EmptyRequest, NodeVersionV2, EmptyMeta>;
/**
* Get node syncing status
* Requests the beacon node to describe if it's currently syncing or not, and if it is, what block it is up to.
*/
getSyncingStatus: Endpoint<"GET", EmptyArgs, EmptyRequest, SyncingStatus, EmptyMeta>;
/**
* Get health check
* Returns node health status in http status codes. Useful for load balancers.
*/
getHealth: Endpoint<"GET", {
syncingStatus?: number;
}, {
query: {
syncing_status?: number;
};
}, EmptyResponseData, EmptyMeta>;
};
export declare function getDefinitions(_config: ChainForkConfig): RouteDefinitions<Endpoints>;
//# sourceMappingURL=node.d.ts.map