import { BeaconConfig, ForkBoundary } from "@lodestar/config";
import { Slot, SubnetID } from "@lodestar/types";
import { Logger } from "@lodestar/utils";
import { IClock } from "../../util/clock.js";
import { NetworkCoreMetrics } from "../core/metrics.js";
import { MetadataController } from "../metadata.js";
import { RequestedSubnet } from "../peers/utils/index.js";
import { CommitteeSubscription, GossipSubscriber, IAttnetsService, NodeId, SubnetsServiceOpts } from "./interface.js";
export declare enum SubnetSource {
    committee = "committee",
    longLived = "long_lived"
}
/**
 * Manage deleterministic long lived (DLL) subnets and short lived subnets.
 * - PeerManager uses attnetsService to know which peers are required for duties and long lived subscriptions
 * - Network call addCommitteeSubscriptions() from API calls
 * - Gossip handler checks shouldProcess to know if validator is aggregator
 */
export declare class AttnetsService implements IAttnetsService {
    private readonly config;
    private readonly clock;
    private readonly gossip;
    private readonly metadata;
    private readonly logger;
    private readonly metrics;
    private readonly nodeId;
    private readonly opts;
    /** Committee subnets - PeerManager must find peers for those */
    private committeeSubnets;
    /**
     * All currently subscribed short-lived subnets, for attestation aggregation
     * This class will tell gossip to subscribe and un-subscribe
     * If a value exists for `SubscriptionId` it means that gossip subscription is active in network.gossip
     */
    private shortLivedSubscriptions;
    /** ${SUBNETS_PER_NODE} long lived subscriptions, may overlap with `shortLivedSubscriptions` */
    private longLivedSubscriptions;
    /**
     * Map of an aggregator at a slot and AggregatorDutyInfo
     * Used to determine if we should process an attestation.
     */
    private aggregatorSlotSubnet;
    constructor(config: BeaconConfig, clock: IClock, gossip: GossipSubscriber, metadata: MetadataController, logger: Logger, metrics: NetworkCoreMetrics | null, nodeId: NodeId | null, opts: SubnetsServiceOpts);
    close(): void;
    /**
     * Get all active subnets for the hearbeat:
     *   - committeeSubnets so that submitted attestations can be spread to the network
     *  - longLivedSubscriptions because other peers based on this node's ENR for their submitted attestations
     */
    getActiveSubnets(): RequestedSubnet[];
    /**
     * Called from the API when validator is a part of a committee.
     */
    addCommitteeSubscriptions(subscriptions: CommitteeSubscription[]): void;
    /**
     * Check if a subscription is still active before handling a gossip object
     */
    shouldProcess(subnet: SubnetID, slot: Slot): boolean;
    /**
     * TODO-dll: clarify how many epochs before the fork we should subscribe to the new fork
     * Call ONLY ONCE: Two epoch before the fork, re-subscribe all existing random subscriptions to the new fork
     **/
    subscribeSubnetsNextBoundary(boundary: ForkBoundary): void;
    /**
     * TODO-dll: clarify how many epochs after the fork we should unsubscribe to the new fork
     * Call  ONLY ONCE: Two epochs after the fork, un-subscribe all subnets from the old fork
     **/
    unsubscribeSubnetsPrevBoundary(boundary: ForkBoundary): void;
    /**
     * Run per slot.
     * - Subscribe to gossip subnets 2 slots in advance
     * - Unsubscribe from expired subnets
     * - Track time to stable mesh if not yet formed
     */
    private onSlot;
    private onHalfSlot;
    /**
     * Track time to form stable mesh if not yet formed
     */
    private trackTimeToStableMesh;
    /**
     * Run per epoch, clean-up operations that are not urgent
     * Subscribe to new random subnets every EPOCHS_PER_SUBNET_SUBSCRIPTION epochs
     */
    private onEpoch;
    private recomputeLongLivedSubnets;
    /**
     * Unsubscribe to a committee subnet from subscribedCommitteeSubnets.
     * If a random subnet is present, we do not unsubscribe from it.
     */
    private unsubscribeExpiredCommitteeSubnets;
    /**
     * No need to track aggregator for past slots.
     * @param currentSlot
     */
    private pruneExpiredAggregator;
    /** Update ENR */
    private updateMetadata;
    /**
     * Trigger a gossip subcription only if not already subscribed
     * shortLivedSubscriptions or longLivedSubscriptions should be updated right AFTER this called
     **/
    private subscribeToSubnets;
    /**
     * Trigger a gossip un-subscription only if no-one is still subscribed
     * If unsubscribe long lived subnets, longLivedSubscriptions should be updated right BEFORE this called
     **/
    private unsubscribeSubnets;
    private onScrapeLodestarMetrics;
}
//# sourceMappingURL=attnetsService.d.ts.map