import { ChainForkConfig } from "@lodestar/config";
import { CheckpointWithHex } from "@lodestar/fork-choice";
import { BLSSignature, RootHex, Slot, deneb, fulu } from "@lodestar/types";
import { Logger } from "@lodestar/utils";
import { Metrics } from "../../metrics/metrics.js";
import { IClock } from "../../util/clock.js";
import { CustodyConfig } from "../../util/dataColumns.js";
import { SerializedCache } from "../../util/serializedCache.js";
import { BlockInput, BlockInputBlobs, BlockInputColumns, BlockWithSource, IBlockInput, SourceMeta } from "../blocks/blockInput/index.js";
import { ChainEventEmitter } from "../emitter.js";
export type SeenBlockInputCacheModules = {
    config: ChainForkConfig;
    clock: IClock;
    chainEvents: ChainEventEmitter;
    signal: AbortSignal;
    custodyConfig: CustodyConfig;
    serializedCache: SerializedCache;
    metrics: Metrics | null;
    logger?: Logger;
};
export type GetByBlobOptions = {
    throwErrorIfAlreadyKnown?: boolean;
};
/**
 * Consumers that create BlockInputs or change types of old BlockInputs
 *
 * - gossipHandlers (block and blob)
 * - beaconBlocksMaybeBlobsByRange
 * - unavailableBeaconBlobsByRoot (beaconBlocksMaybeBlobsByRoot)
 * - publishBlock in the beacon/blocks/index.ts API
 *   https://github.com/ChainSafe/lodestar/blob/unstable/packages/beacon-node/src/api/impl/beacon/blocks/index.ts#L62
 * - maybeValidateBlobs in verifyBlocksDataAvailability (is_data_available spec function)
 *   https://github.com/ChainSafe/lodestar/blob/unstable/packages/beacon-node/src/chain/blocks/verifyBlocksDataAvailability.ts#L111
 *
 *
 * Pruning management for SeenBlockInputCache
 * ------------------------------------------
 * There are four cases for how pruning needs to be handled
 * - Normal operation following head via gossip (and/or reqresp). For this situation the consumer (process pipeline or
 *   caller of processBlock) will call the `prune` method to remove any processed BlockInputs from the cache. This will
 *   also remove any ancestors of the processed BlockInput as that will also need to have been successfully processed
 *   for import to work correctly
 * - onFinalized event handler will help to prune any non-canonical forks once the chain finalizes. Any block-slots that
 *   are before the finalized checkpoint will be pruned.
 * - Range-sync periods.  The range process uses this cache to store and sync blocks with DA data as the chain is pulled
 *   from peers.  We pull batches, by epoch, so 32 slots are pulled at a time and several batches are downloaded
 *   concurrently (up to MAX_LOOK_AHEAD_EPOCHS ahead).  All downloaded blocks are added to this shared cache, so it
 *   must be large enough to hold blocks from all concurrent batches.  If pruneToMaxSize() evicts blocks from the batch
 *   currently being processed, those blocks may not yet be persisted to the database, causing getBlockByRoot() to fail
 *   when async event handlers (e.g. onForkChoiceFinalized) try to look them up.
 * - Non-Finality times.  This is a bit more tricky.  There can be long periods of non-finality and storing everything
 *   will cause OOM.  The pruneToMaxSize will help ensure the number of stored blocks (with DA) is trimmed back to
 *   MAX_BLOCK_INPUT_CACHE_SIZE after each prune() or onFinalized() call
 */
export declare class SeenBlockInput {
    private readonly config;
    private readonly custodyConfig;
    private readonly clock;
    private readonly chainEvents;
    private readonly signal;
    private readonly serializedCache;
    private readonly metrics;
    private readonly logger?;
    private blockInputs;
    private verifiedProposerSignatures;
    constructor({ config, custodyConfig, clock, chainEvents, signal, serializedCache, metrics, logger }: SeenBlockInputCacheModules);
    has(rootHex: RootHex): boolean;
    get(rootHex: RootHex): IBlockInput | undefined;
    /**
     * Removes the single BlockInput from the cache
     */
    remove(rootHex: RootHex): void;
    /**
     * Removes a processed BlockInput from the cache and also removes any ancestors of processed blocks
     */
    prune(rootHex: RootHex): void;
    onFinalized: (checkpoint: CheckpointWithHex) => void;
    getByBlock({ blockRootHex, block, source, seenTimestampSec, peerIdStr }: BlockWithSource): BlockInput;
    getByBlob({ blockRootHex, blobSidecar, source, seenTimestampSec, peerIdStr }: SourceMeta & {
        blockRootHex: RootHex;
        blobSidecar: deneb.BlobSidecar;
    }, opts?: GetByBlobOptions): BlockInputBlobs;
    getByColumn({ blockRootHex, columnSidecar, seenTimestampSec, source, peerIdStr }: SourceMeta & {
        blockRootHex: RootHex;
        columnSidecar: fulu.DataColumnSidecar;
    }, opts?: GetByBlobOptions): BlockInputColumns;
    /**
     * Check if a proposer signature has already been verified for this slot and block root.
     */
    isVerifiedProposerSignature(slot: Slot, blockRootHex: RootHex, signature: BLSSignature): boolean;
    /**
     * Mark that the proposer signature for this slot and block root has been verified
     * so that we only verify it once per slot
     */
    markVerifiedProposerSignature(slot: Slot, blockRootHex: RootHex, signature: BLSSignature): void;
    private buildCommonProps;
    /**
     * Use custom implementation of pruneSetToMax to allow for sorting by slot
     * and deleting via key/rootHex
     */
    private pruneToMaxSize;
    private evictBlockInput;
}
//# sourceMappingURL=seenGossipBlockInput.d.ts.map