UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

49 lines 2.33 kB
import { CommitteeIndex, RootHex, Slot, SubnetID, phase0 } from "@lodestar/types"; import { Metrics } from "../../metrics/metrics.js"; import { InsertOutcome } from "../opPools/types.js"; export type SeenAttDataKey = AttDataBase64; type AttDataBase64 = string; export type AttestationDataCacheEntry = { committeeValidatorIndices: Uint32Array; committeeIndex: CommitteeIndex; signingRoot: Uint8Array; attDataRootHex: RootHex; attestationData: phase0.AttestationData; subnet: SubnetID; }; export declare enum RejectReason { reached_limit = "reached_limit", too_old = "too_old", already_known = "already_known" } export declare const PRE_ELECTRA_SINGLE_ATTESTATION_COMMITTEE_INDEX = 0; /** * Cached seen AttestationData to improve gossip validation. For Electra, this still take into account attestationIndex * even through it is moved outside of AttestationData. * As of April 2023, validating gossip attestation takes ~12% of cpu time for a node subscribing to all subnets on mainnet. * Having this cache help saves a lot of cpu time since most of the gossip attestations are on the same slot. */ export declare class SeenAttestationDatas { private readonly metrics; private readonly cacheSlotDistance; private readonly maxCacheSizePerSlot; private cacheEntryByAttDataByIndexBySlot; private lowestPermissibleSlot; constructor(metrics: Metrics | null, cacheSlotDistance?: number, maxCacheSizePerSlot?: number); /** * Add an AttestationDataCacheEntry to the cache. * - preElectra: add(slot, PRE_ELECTRA_SINGLE_ATTESTATION_COMMITTEE_INDEX, attDataBase64, cacheEntry) * - electra: add(slot, committeeIndex, attDataBase64, cacheEntry) */ add(slot: Slot, committeeIndex: CommitteeIndex, attDataBase64: AttDataBase64, cacheEntry: AttestationDataCacheEntry): InsertOutcome; /** * Get an AttestationDataCacheEntry from the cache. * - preElectra: get(slot, PRE_ELECTRA_SINGLE_ATTESTATION_COMMITTEE_INDEX, attDataBase64) * - electra: get(slot, committeeIndex, attDataBase64) */ get(slot: Slot, committeeIndex: CommitteeIndex, attDataBase64: SeenAttDataKey): AttestationDataCacheEntry | null; onSlot(clockSlot: Slot): void; private onScrapeLodestarMetrics; } export {}; //# sourceMappingURL=seenAttestationData.d.ts.map