UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

101 lines 3.55 kB
import { SlotRootHex } from "@lodestar/types"; import { Logger } from "@lodestar/utils"; import { IBeaconChain } from "../../chain/interface.js"; import { IBeaconDb } from "../../db/interface.js"; import { Metrics } from "../../metrics/metrics.js"; import { PeerIdStr } from "../../util/peerId.js"; import { NetworkEventBus } from "../events.js"; import { GossipHandlers, GossipType } from "../gossip/interface.js"; import { GossipHandlerOpts, ValidatorFnsModules } from "./gossipHandlers.js"; import { ValidatorFnModules } from "./gossipValidatorFn.js"; import { PendingGossipsubMessage } from "./types.js"; export * from "./types.js"; export type NetworkProcessorModules = ValidatorFnsModules & ValidatorFnModules & { chain: IBeaconChain; db: IBeaconDb; events: NetworkEventBus; logger: Logger; metrics: Metrics | null; gossipHandlers?: GossipHandlers; }; export type NetworkProcessorOpts = GossipHandlerOpts & { maxGossipTopicConcurrency?: number; }; /** * Reprocess reject reason for metrics */ export declare enum ReprocessRejectReason { /** * There are too many attestations that have unknown block root. */ reached_limit = "reached_limit", /** * The awaiting attestation is pruned per clock slot. */ expired = "expired" } /** * Cannot accept work reason for metrics */ export declare enum CannotAcceptWorkReason { /** * bls is busy. */ bls = "bls_busy", /** * regen is busy. */ regen = "regen_busy" } /** * Network processor handles the gossip queues and throtles processing to not overload the main thread * - Decides when to process work and what to process * * What triggers execute work? * * - When work is submitted * - When downstream workers become available * * ### PendingGossipsubMessage beacon_attestation example * * For attestations, processing the message includes the steps: * 1. Pre shuffling sync validation * 2. Retrieve shuffling: async + goes into the regen queue and can be expensive * 3. Pre sig validation sync validation * 4. Validate BLS signature: async + goes into workers through another manager * * The gossip queues should receive "backpressue" from the regen and BLS workers queues. * Such that enough work is processed to fill either one of the queue. */ export declare class NetworkProcessor { private readonly opts; private readonly chain; private readonly events; private readonly logger; private readonly metrics; private readonly gossipValidatorFn; private readonly gossipValidatorBatchFn; private readonly gossipQueues; private readonly gossipTopicConcurrency; private readonly extractBlockSlotRootFns; private readonly awaitingGossipsubMessagesByRootBySlot; private unknownBlockGossipsubMessagesCount; private unknownRootsBySlot; constructor(modules: NetworkProcessorModules, opts: NetworkProcessorOpts); stop(): Promise<void>; dropAllJobs(): void; dumpGossipQueue(topic: GossipType): PendingGossipsubMessage[]; searchUnknownSlotRoot({ slot, root }: SlotRootHex, peer?: PeerIdStr): void; private onPendingGossipsubMessage; private pushPendingGossipsubMessageToQueue; private onBlockProcessed; private onClockSlot; private executeWork; private processPendingGossipsubMessage; private trackJobTime; /** * Return null if chain can accept work, otherwise return the reason why it cannot accept work */ private checkAcceptWork; } //# sourceMappingURL=index.d.ts.map