import type { PeerScoreStatsDump } from "@libp2p/gossipsub/score";
import type { PeerId, PrivateKey } from "@libp2p/interface";
import { routes } from "@lodestar/api";
import { BeaconConfig } from "@lodestar/config";
import { LoggerNode } from "@lodestar/logger/node";
import { AttesterSlashing, DataColumnSidecar, LightClientBootstrap, LightClientFinalityUpdate, LightClientOptimisticUpdate, LightClientUpdate, Root, SignedAggregateAndProof, SignedBeaconBlock, SingleAttestation, SlotRootHex, SubnetID, altair, capella, deneb, fulu, gloas, phase0 } from "@lodestar/types";
import { BlockInputSource } from "../chain/blocks/blockInput/types.js";
import { IBeaconChain } from "../chain/index.js";
import { IBeaconDb } from "../db/interface.js";
import { Metrics } from "../metrics/index.js";
import { CustodyConfig } from "../util/dataColumns.js";
import { PeerIdStr } from "../util/peerId.js";
import { BeaconBlocksByRootRequest, BlobSidecarsByRootRequest, DataColumnSidecarsByRootRequest } from "../util/types.js";
import { INetworkCore } from "./core/index.js";
import { INetworkEventBus, NetworkEventBus } from "./events.js";
import { GossipHandlers, GossipType } from "./gossip/index.js";
import { INetwork } from "./interface.js";
import { NetworkOptions } from "./options.js";
import { PeerAction, PeerScoreStats } from "./peers/index.js";
import { PeerSyncMeta } from "./peers/peersData.js";
import { AggregatorTracker } from "./processor/aggregatorTracker.js";
import { NetworkProcessor, PendingGossipsubMessage } from "./processor/index.js";
import { GetReqRespHandlerFn } from "./reqresp/types.js";
import { CommitteeSubscription } from "./subnets/index.js";
type NetworkModules = {
    opts: NetworkOptions;
    privateKey: PrivateKey;
    config: BeaconConfig;
    logger: LoggerNode;
    chain: IBeaconChain;
    networkEventBus: NetworkEventBus;
    aggregatorTracker: AggregatorTracker;
    networkProcessor: NetworkProcessor;
    core: INetworkCore;
};
export type NetworkInitModules = {
    opts: NetworkOptions;
    config: BeaconConfig;
    privateKey: PrivateKey;
    peerStoreDir?: string;
    logger: LoggerNode;
    metrics: Metrics | null;
    chain: IBeaconChain;
    db: IBeaconDb;
    getReqRespHandler: GetReqRespHandlerFn;
    gossipHandlers?: GossipHandlers;
};
/**
 * Must support running both on worker and on main thread.
 *
 * Exists a front class that's what consumers interact with.
 * This class will multiplex between:
 * - libp2p in worker
 * - libp2p in main thread
 */
export declare class Network implements INetwork {
    readonly peerId: PeerId;
    readonly custodyConfig: CustodyConfig;
    readonly events: INetworkEventBus;
    private readonly logger;
    private readonly config;
    private readonly clock;
    private readonly chain;
    private readonly controller;
    private readonly networkProcessor;
    private readonly core;
    private readonly aggregatorTracker;
    private subscribedToCoreTopics;
    private connectedPeersSyncMeta;
    constructor(modules: NetworkModules);
    static init({ opts, config, logger, metrics, chain, db, gossipHandlers, privateKey, peerStoreDir, getReqRespHandler }: NetworkInitModules): Promise<Network>;
    get closed(): boolean;
    /** Destroy this instance. Can only be called once. */
    close(): Promise<void>;
    scrapeMetrics(): Promise<string>;
    /**
     * Request att subnets up `toSlot`. Network will ensure to mantain some peers for each
     */
    prepareBeaconCommitteeSubnets(subscriptions: CommitteeSubscription[]): Promise<void>;
    prepareSyncCommitteeSubnets(subscriptions: CommitteeSubscription[]): Promise<void>;
    /**
     * The app layer needs to refresh the status of some peers. The sync have reached a target
     */
    reStatusPeers(peers: PeerIdStr[]): Promise<void>;
    searchUnknownSlotRoot(slotRoot: SlotRootHex, source: BlockInputSource, peer?: PeerIdStr): void;
    reportPeer(peer: PeerIdStr, action: PeerAction, actionName: string): Promise<void>;
    getConnectedPeers(): PeerIdStr[];
    getConnectedPeerSyncMeta(peerId: PeerIdStr): PeerSyncMeta;
    getConnectedPeerCount(): number;
    getNetworkIdentity(): Promise<routes.node.NetworkIdentity>;
    /**
     * Subscribe to all gossip events. Safe to call multiple times
     */
    subscribeGossipCoreTopics(): Promise<void>;
    /**
     * Unsubscribe from all gossip events. Safe to call multiple times
     */
    unsubscribeGossipCoreTopics(): Promise<void>;
    isSubscribedToGossipCoreTopics(): boolean;
    shouldAggregate(subnet: SubnetID, slot: number): boolean;
    publishBeaconBlock(signedBlock: SignedBeaconBlock): Promise<number>;
    publishBlobSidecar(blobSidecar: deneb.BlobSidecar): Promise<number>;
    publishDataColumnSidecar(dataColumnSidecar: DataColumnSidecar): Promise<number>;
    publishBeaconAggregateAndProof(aggregateAndProof: SignedAggregateAndProof): Promise<number>;
    publishBeaconAttestation(attestation: SingleAttestation, subnet: SubnetID): Promise<number>;
    publishVoluntaryExit(voluntaryExit: phase0.SignedVoluntaryExit): Promise<number>;
    publishBlsToExecutionChange(blsToExecutionChange: capella.SignedBLSToExecutionChange): Promise<number>;
    publishProposerSlashing(proposerSlashing: phase0.ProposerSlashing): Promise<number>;
    publishAttesterSlashing(attesterSlashing: AttesterSlashing): Promise<number>;
    publishSyncCommitteeSignature(signature: altair.SyncCommitteeMessage, subnet: SubnetID): Promise<number>;
    publishContributionAndProof(contributionAndProof: altair.SignedContributionAndProof): Promise<number>;
    publishLightClientFinalityUpdate(update: LightClientFinalityUpdate): Promise<number>;
    publishLightClientOptimisticUpdate(update: LightClientOptimisticUpdate): Promise<number>;
    publishSignedExecutionPayloadEnvelope(signedEnvelope: gloas.SignedExecutionPayloadEnvelope): Promise<number>;
    private publishGossip;
    sendBeaconBlocksByRange(peerId: PeerIdStr, request: phase0.BeaconBlocksByRangeRequest): Promise<SignedBeaconBlock[]>;
    sendBeaconBlocksByRoot(peerId: PeerIdStr, request: BeaconBlocksByRootRequest): Promise<SignedBeaconBlock[]>;
    sendLightClientBootstrap(peerId: PeerIdStr, request: Root): Promise<LightClientBootstrap>;
    sendLightClientOptimisticUpdate(peerId: PeerIdStr): Promise<LightClientOptimisticUpdate>;
    sendLightClientFinalityUpdate(peerId: PeerIdStr): Promise<LightClientFinalityUpdate>;
    sendLightClientUpdatesByRange(peerId: PeerIdStr, request: altair.LightClientUpdatesByRange): Promise<LightClientUpdate[]>;
    sendBlobSidecarsByRange(peerId: PeerIdStr, request: deneb.BlobSidecarsByRangeRequest): Promise<deneb.BlobSidecar[]>;
    sendBlobSidecarsByRoot(peerId: PeerIdStr, request: BlobSidecarsByRootRequest): Promise<deneb.BlobSidecar[]>;
    sendDataColumnSidecarsByRange(peerId: PeerIdStr, request: fulu.DataColumnSidecarsByRangeRequest): Promise<fulu.DataColumnSidecar[]>;
    sendDataColumnSidecarsByRoot(peerId: PeerIdStr, request: DataColumnSidecarsByRootRequest): Promise<fulu.DataColumnSidecar[]>;
    private sendReqRespRequest;
    connectToPeer(peer: string, multiaddr: string[]): Promise<void>;
    disconnectPeer(peer: string): Promise<void>;
    addDirectPeer(peer: routes.lodestar.DirectPeer): Promise<string | null>;
    removeDirectPeer(peerId: string): Promise<boolean>;
    getDirectPeers(): Promise<string[]>;
    dumpPeer(peerIdStr: string): Promise<routes.lodestar.LodestarNodePeer | undefined>;
    dumpPeers(): Promise<routes.lodestar.LodestarNodePeer[]>;
    dumpPeerScoreStats(): Promise<PeerScoreStats>;
    dumpGossipPeerScoreStats(): Promise<PeerScoreStatsDump>;
    dumpDiscv5KadValues(): Promise<string[]>;
    dumpMeshPeers(): Promise<Record<string, string[]>>;
    dumpGossipQueue(gossipType: GossipType): Promise<PendingGossipsubMessage[]>;
    writeNetworkThreadProfile(durationMs: number, dirpath: string): Promise<string>;
    writeDiscv5Profile(durationMs: number, dirpath: string): Promise<string>;
    writeNetworkHeapSnapshot(prefix: string, dirpath: string): Promise<string>;
    writeDiscv5HeapSnapshot(prefix: string, dirpath: string): Promise<string>;
    private onLightClientFinalityUpdate;
    private onLightClientOptimisticUpdate;
    private waitForSyncMessageCutoff;
    private onHead;
    private onPeerConnected;
    private onPeerDisconnected;
    private onTargetGroupCountUpdated;
    private onPublishDataColumns;
    private onPublishBlobSidecars;
    private onUpdateStatus;
}
export {};
//# sourceMappingURL=network.d.ts.map