@lodestar/beacon-node
Version:
A Typescript implementation of the beacon chain
58 lines • 2.25 kB
TypeScript
import { BitArray } from "@chainsafe/ssz";
import { BeaconConfig } from "@lodestar/config";
import { Epoch, altair, phase0 } from "@lodestar/types";
import { Logger } from "@lodestar/utils";
export declare enum ENRKey {
tcp = "tcp",
eth2 = "eth2",
attnets = "attnets",
syncnets = "syncnets",
nfd = "nfd"
}
export declare enum SubnetType {
attnets = "attnets",
syncnets = "syncnets"
}
export type MetadataOpts = {
metadata?: altair.Metadata;
};
export type MetadataModules = {
config: BeaconConfig;
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 config;
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);
/** Consumers that need the phase0.Metadata type can just ignore the .syncnets property */
get json(): altair.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): void;
}
export declare function getENRForkID(config: BeaconConfig, clockEpoch: Epoch): phase0.ENRForkID;
//# sourceMappingURL=metadata.d.ts.map