@lodestar/beacon-node
Version:
A Typescript implementation of the beacon chain
58 lines • 2.64 kB
TypeScript
import { BitArray } from "@chainsafe/ssz";
import { Root, Slot, altair } from "@lodestar/types";
import { Logger } from "@lodestar/utils";
import { Metrics } from "../../metrics/metrics.js";
import { IClock } from "../../util/clock.js";
import { InsertOutcome } from "./types.js";
/**
* A one-one mapping to SyncContribution with fast data structure to help speed up the aggregation.
*/
export type SyncContributionFast = {
syncSubcommitteeBits: BitArray;
numParticipants: number;
syncSubcommitteeSignature: Uint8Array;
};
/**
* Cache SyncCommitteeContribution and seen ContributionAndProof.
* This is used for SignedContributionAndProof validation and block factory.
* This stays in-memory and should be pruned per slot.
*/
export declare class SyncContributionAndProofPool {
private readonly clock;
private readonly metrics;
private logger;
private readonly bestContributionBySubnetRootBySlot;
private lowestPermissibleSlot;
constructor(clock: IClock, metrics?: Metrics | null, logger?: Logger | null);
/** Returns current count of unique SyncContributionFast by block root and subnet */
get size(): number;
/**
* Only call this once we pass all validation.
*/
add(contributionAndProof: altair.ContributionAndProof, syncCommitteeParticipants: number, priority?: boolean): InsertOutcome;
/**
* This is for producing blocks, the same to process_sync_committee_contributions in the spec.
*/
getAggregate(slot: Slot, prevBlockRoot: Root): altair.SyncAggregate;
/**
* Prune per head slot.
* SyncCommittee aggregates are only useful for the next block they have signed.
* We don't want to prune by clock slot in case there's a long period of skipped slots.
*/
prune(headSlot: Slot): void;
private onScrapeMetrics;
}
/**
* Mutate bestContribution if new contribution has more participants
*/
export declare function replaceIfBetter(bestContribution: SyncContributionFast, newContribution: altair.SyncCommitteeContribution, newNumParticipants: number): InsertOutcome;
/**
* Format `contribution` into an efficient data structure to aggregate later.
*/
export declare function contributionToFast(contribution: altair.SyncCommitteeContribution, numParticipants: number): SyncContributionFast;
/**
* Aggregate best contributions of each subnet into SyncAggregate
* @returns SyncAggregate to be included in block body.
*/
export declare function aggregate(bestContributionBySubnet: Map<number, SyncContributionFast>, metrics?: Metrics | null): altair.SyncAggregate;
//# sourceMappingURL=syncContributionAndProofPool.d.ts.map