UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

65 lines 2.55 kB
import { ChainConfig } from "@lodestar/config"; import { Logger } from "@lodestar/utils"; import { Metrics } from "../metrics/index.js"; import { EthJsonRpcBlockRaw, IEth1Provider, PowMergeBlock, TDProgress } from "./interface.js"; export declare enum StatusCode { STOPPED = "STOPPED", SEARCHING = "SEARCHING", FOUND = "FOUND" } export type Eth1MergeBlockTrackerModules = { config: ChainConfig; logger: Logger; signal: AbortSignal; metrics: Metrics | null; }; /** * Follows the eth1 chain to find a (or multiple?) merge blocks that cross the threshold of total terminal difficulty * * Finding the mergeBlock could be done in demand when proposing pre-merge blocks. However, that would slow block * production during the weeks between BELLATRIX_EPOCH and TTD. */ export declare class Eth1MergeBlockTracker { private readonly eth1Provider; private readonly config; private readonly logger; private readonly metrics; private readonly blocksByHashCache; private readonly intervals; private status; private latestEth1Block; private getTerminalPowBlockFromEth1Promise; private readonly safeTDFactor; constructor({ config, logger, signal, metrics }: Eth1MergeBlockTrackerModules, eth1Provider: IEth1Provider); /** * Returns the most recent POW block that satisfies the merge block condition */ getTerminalPowBlock(): Promise<PowMergeBlock | null>; getTDProgress(): TDProgress | null; /** * Get a POW block by hash checking the local cache first */ getPowBlock(powBlockHash: string): Promise<PowMergeBlock | null>; /** * Should only start polling for mergeBlock if: * - after BELLATRIX_FORK_EPOCH * - Beacon node synced * - head state not isMergeTransitionComplete */ startPollingMergeBlock(): void; private close; private getTerminalPowBlockFromEth1; /** * **internal** + **unsafe** since it can create multiple backward searches that overload the eth1 client. * Must be called in a wrapper to ensure that there's only once concurrent call to this fn. */ private internalGetTerminalPowBlockFromEth1; private cacheBlock; } export declare function toPowBlock(block: EthJsonRpcBlockRaw): PowMergeBlock; /** * TTD values can be very large, for xDAI > 1e45. So scale down. * To be good, TTD should be rendered as a number < Number.MAX_TD_RENDER_VALUE ~= 9e15 */ export declare function getSafeTDFactor(ttd: bigint): bigint; //# sourceMappingURL=eth1MergeBlockTracker.d.ts.map