UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

46 lines 2.44 kB
import { BeaconConfig } from "@lodestar/config"; import { Root, Slot } from "@lodestar/types"; import { Logger } from "@lodestar/utils"; import { IBeaconChain } from "../../chain/interface.js"; import { Metrics } from "../../metrics/index.js"; import { INetworkCore } from "../core/index.js"; import { NetworkEventBus } from "../events.js"; import { GossipHandlers } from "../gossip/interface.js"; import { INetwork } from "../interface.js"; import { AggregatorTracker } from "./aggregatorTracker.js"; /** * Gossip handler options as part of network options */ export type GossipHandlerOpts = { /** By default pass gossip attestations to forkchoice */ dontSendGossipAttestationsToForkchoice?: boolean; }; export type ValidatorFnsModules = { chain: IBeaconChain; config: BeaconConfig; logger: Logger; metrics: Metrics | null; events: NetworkEventBus; aggregatorTracker: AggregatorTracker; core: INetworkCore; }; /** * Gossip handlers perform validation + handling in a single function. * - This gossip handlers MUST only be registered as validator functions. No handler is registered for any topic. * - All `chain/validation/*` functions MUST throw typed GossipActionError instances so they gossip action is captured * by `getGossipValidatorFn()` try catch block. * - This gossip handlers should not let any handling errors propagate to the caller. Only validation errors must be thrown. * * Note: `libp2p/js-libp2p-interfaces` would normally indicate to register separate validator functions and handler functions. * This approach is not suitable for us because: * - We do expensive processing on the object in the validator function that we need to re-use in the handler function. * - The validator function produces extra data that is needed for the handler function. Making this data available in * the handler function scope is hard to achieve without very hacky strategies * - Ethereum Consensus gossipsub protocol strictly defined a single topic for message */ export declare function getGossipHandlers(modules: ValidatorFnsModules, options: GossipHandlerOpts): GossipHandlers; /** * Retry a function if it throws error code UNKNOWN_OR_PREFINALIZED_BEACON_BLOCK_ROOT */ export declare function validateGossipFnRetryUnknownRoot<T>(fn: () => Promise<T>, network: INetwork, chain: IBeaconChain, slot: Slot, blockRoot: Root): Promise<T>; //# sourceMappingURL=gossipHandlers.d.ts.map