@lodestar/beacon-node
Version:
A Typescript implementation of the beacon chain
63 lines • 2.45 kB
TypeScript
import { BitArray } from "@chainsafe/ssz";
import { BeaconConfig } from "@lodestar/config";
import { Epoch, fulu, phase0 } from "@lodestar/types";
import { Logger } from "@lodestar/utils";
import { NetworkConfig } from "./networkConfig.js";
export declare enum ENRKey {
tcp = "tcp",
quic = "quic",
eth2 = "eth2",
attnets = "attnets",
syncnets = "syncnets",
cgc = "cgc",
nfd = "nfd"
}
export declare enum SubnetType {
attnets = "attnets",
syncnets = "syncnets"
}
export type MetadataOpts = {
metadata?: fulu.Metadata;
};
export type MetadataModules = {
networkConfig: NetworkConfig;
logger: Logger;
onSetValue: (key: string, value: Uint8Array) => void;
};
/**
* Implementation of Ethereum Consensus p2p MetaData.
* For the spec that this code is based on, see:
* https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#metadata
*/
export declare class MetadataController {
private onSetValue;
private networkConfig;
private logger;
private _metadata;
constructor(opts: MetadataOpts, modules: MetadataModules);
upstreamValues(currentEpoch: Epoch): void;
get seqNumber(): bigint;
get syncnets(): BitArray;
set syncnets(syncnets: BitArray);
get attnets(): BitArray;
set attnets(attnets: BitArray);
get custodyGroupCount(): number;
set custodyGroupCount(custodyGroupCount: number);
/** Consumers that need the phase0.Metadata type can just ignore the .syncnets property */
get json(): fulu.Metadata;
/**
* From spec:
* fork_digest is compute_fork_digest(current_fork_version, genesis_validators_root) where
* - current_fork_version is the fork version at the node's current epoch defined by the wall-clock time (not
* necessarily the epoch to which the node is sync)
* - genesis_validators_root is the static Root found in state.genesis_validators_root
* - epoch of fork boundary is used to get blob parameters of current Blob Parameter Only (BPO) fork
*
* 1. MUST be called on start to populate ENR
* 2. Network MUST call this method on fork transition.
* Current Clock implementation ensures no race conditions, epoch is correct if re-fetched
*/
updateEth2Field(epoch: Epoch): phase0.ENRForkID;
}
export declare function getENRForkID(config: BeaconConfig, clockEpoch: Epoch): phase0.ENRForkID;
//# sourceMappingURL=metadata.d.ts.map