@ocap/resolver 1.31.8 → 1.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/esm/_virtual/rolldown_runtime.mjs +7 -0
  2. package/esm/api.d.mts +33 -5
  3. package/esm/api.mjs +939 -53
  4. package/esm/dashboard.d.mts +199 -0
  5. package/esm/dashboard.mjs +2481 -0
  6. package/esm/explorer.d.mts +29 -0
  7. package/esm/explorer.mjs +227 -0
  8. package/esm/follower.d.mts +277 -0
  9. package/esm/follower.mjs +2428 -0
  10. package/esm/hooks.mjs +1 -1
  11. package/esm/hotstuff-runtime.d.mts +271 -0
  12. package/esm/hotstuff-runtime.mjs +2668 -0
  13. package/esm/index.d.mts +87 -4
  14. package/esm/index.mjs +937 -177
  15. package/esm/node-preferences.d.mts +203 -0
  16. package/esm/node-preferences.mjs +1021 -0
  17. package/esm/replayer.d.mts +74 -0
  18. package/esm/replayer.mjs +394 -0
  19. package/esm/token-distribution.mjs +2 -2
  20. package/esm/token-flow.mjs +1 -1
  21. package/esm/types.d.mts +25 -2
  22. package/lib/api.cjs +941 -52
  23. package/lib/api.d.cts +33 -5
  24. package/lib/dashboard.cjs +2491 -0
  25. package/lib/dashboard.d.cts +199 -0
  26. package/lib/explorer.cjs +227 -0
  27. package/lib/explorer.d.cts +29 -0
  28. package/lib/follower.cjs +2434 -0
  29. package/lib/follower.d.cts +277 -0
  30. package/lib/hooks.cjs +1 -1
  31. package/lib/hotstuff-runtime.cjs +2671 -0
  32. package/lib/hotstuff-runtime.d.cts +271 -0
  33. package/lib/index.cjs +972 -177
  34. package/lib/index.d.cts +87 -4
  35. package/lib/node-preferences.cjs +1043 -0
  36. package/lib/node-preferences.d.cts +203 -0
  37. package/lib/replayer.cjs +395 -0
  38. package/lib/replayer.d.cts +74 -0
  39. package/lib/token-distribution.cjs +2 -2
  40. package/lib/token-flow.cjs +1 -1
  41. package/lib/types.d.cts +25 -2
  42. package/package.json +20 -14
package/lib/index.d.cts CHANGED
@@ -1,4 +1,11 @@
1
- import { IAddressArgs, IAssetState, IChainConfig, IChunkIterator, IDataObject, IDelegateState, IEvidenceState, IFilter, IGetAccountStateArgs, IGetAccountTokensArgs, IGetStateParams, IIndexDB as IIndexDB$1, IListChunksParams, IPaginatedResult, IPipelineLogger as IPipelineLogger$1, IResolver, IResolverAccountState, IResolverChainInfo, IResolverContext as IResolverContext$1, IResolverFactoryState, IResolverForgeStats, IResolverListAccountsResult, IResolverListAssetsResult, IResolverListDelegationsResult, IResolverListFactoriesResult, IResolverListRollupBlocksResult, IResolverListRollupValidatorsResult, IResolverListRollupsResult, IResolverListStakesResult, IResolverListTokenFactoriesResult, IResolverListTokensResult, IResolverListTransactionsResult, IResolverNetInfo, IResolverNodeInfo, IResolverPaging, IResolverParams, IResolverRollupState, IResolverStakeState, IResolverTransaction, IResolverValidatorsInfo, IRollupBlock, IStateDB as IStateDB$1, ITokenCache, ITokenFactoryState, ITokenFlowsResult, ITokenInfo, ITokenState, TIndexedTokenState as TIndexedTokenState$1, TRequestEstimateGas, TRequestGetEvidenceState, TRequestGetRollupBlock, TRequestGetTokenDistribution, TRequestGetTx, TRequestListAssetTransactions, TRequestListAssets, TRequestListDelegations, TRequestListFactories, TRequestListRollupBlocks, TRequestListRollupValidators, TRequestListRollups, TRequestListStakes, TRequestListTokenFactories, TRequestListTokenFlows, TRequestListTokens, TRequestListTopAccounts, TRequestListTransactions, TRequestSearch, TRequestVerifyAccountRisk, TSearchResult, TTokenDistribution, TVerifyAccountRiskResult } from "./types.cjs";
1
+ import { AdminAuthGuardOptions, DnsLookupAllFn, IAdminAuthGuard, IAttributedBlockedAccount, IAttributedReservedSymbol, IAttributedTrustedAccount, IBlockedAccountEntry, ILedgerHealthThresholds, ILegacyPreferencesResult, INodePreferencesFileSchema, INodePreferencesSnapshot, INodeRuntimePreferences, IReservedSymbolEntry, ITrustedAccountEntry, IUpdateNodePreferencesInput, IUpdateNodePreferencesResult, MAX_BLOCKED_ACCOUNTS, MAX_CONFIG_BODY_BYTES, MAX_MEMO_LENGTH, MAX_PEER_URLS, MAX_RESERVED_SYMBOLS, MAX_TRUSTED_ACCOUNTS, NodePreferencesError, NodePreferencesManager, NodePreferencesManagerOptions, TPreferenceSource, applyBootRuntimePreferences, createAdminAuthGuard, createFollowerPeerFetchGuard, isPrivateOrReservedIpAddress, isValidAccountAddressCandidate, loadNodePreferences, normalizeBlockedAccountKey, timingSafeTokenEqual, validateFollowerPeerUrls } from "./node-preferences.cjs";
2
+ import { CreateNodeDashboardRouterOptions, CreateUnifiedConsoleMiddlewareOptions, IDashboardResolverTarget, IDatabaseFileMetrics, ILedgerHealthSummary, INodeMaintenanceController, INodeMaintenanceStatusSummary, ISlowStorageTelemetry, NodeMaintenanceControllerOptions, UNIFIED_CONSOLE_APP_JS, buildUnifiedConsoleHtml, collectLedgerHealthSummary, createNodeDashboardRouter, createNodeMaintenanceController, createUnifiedConsoleMiddleware, isDashboardEnabled } from "./dashboard.cjs";
3
+ import { IAddressArgs, IAssetState, IChainConfig, IChunkIterator, IDataObject, IDelegateState, IEvidenceState, IFilter as IFilter$1, IFollowerStatusResponse, IGetAccountStateArgs, IGetAccountTokensArgs, IGetStateParams, IIndexDB as IIndexDB$1, IListChunksParams, INodeRuntimeAdapter, IPaginatedResult, IPipelineLogger as IPipelineLogger$1, IResolver, IResolverAccountState, IResolverChainInfo, IResolverContext as IResolverContext$1, IResolverFactoryState, IResolverForgeStats, IResolverListAccountsResult, IResolverListAssetsResult, IResolverListDelegationsResult, IResolverListFactoriesResult, IResolverListRollupBlocksResult, IResolverListRollupValidatorsResult, IResolverListRollupsResult, IResolverListStakesResult, IResolverListTokenFactoriesResult, IResolverListTokensResult, IResolverListTransactionsResult, IResolverNetInfo, IResolverNodeInfo, IResolverPaging, IResolverParams, IResolverRollupState, IResolverStakeState, IResolverTransaction, IResolverValidatorsInfo, IRollupBlock, IStateDB as IStateDB$1, ITokenCache, ITokenFactoryState, ITokenFlowsResult, ITokenInfo, ITokenState, TIndexedTokenState as TIndexedTokenState$1, TRequestEstimateGas, TRequestGetEvidenceState, TRequestGetRollupBlock, TRequestGetTokenDistribution, TRequestGetTx, TRequestListAssetTransactions, TRequestListAssets, TRequestListDelegations, TRequestListFactories, TRequestListRollupBlocks, TRequestListRollupValidators, TRequestListRollups, TRequestListStakes, TRequestListTokenFactories, TRequestListTokenFlows, TRequestListTokens, TRequestListTopAccounts, TRequestListTransactions, TRequestSearch, TRequestVerifyAccountRisk, TSearchResult, TTokenDistribution, TVerifyAccountRiskResult } from "./types.cjs";
4
+ import { CreateAPIHandlerOptions, ICreateAPIHandlerParams } from "./api.cjs";
5
+ import { CreateExplorerMiddlewareOptions, createExplorerMiddleware, isExplorerEnabled } from "./explorer.cjs";
6
+ import { IDryRunVerifyEntriesOptions, IDryRunVerifyEntriesResult, IReplayEntryOptions, IReplayEntryResult, IReplayerResolverTarget, LedgerEntryReplayer } from "./replayer.cjs";
7
+ import { DEFAULT_FOLLOWER_MAX_SYNC_LAG, DEFAULT_FOLLOWER_MAX_UPSTREAM_STALE_MS, DEFAULT_FOLLOWER_POLL_INTERVAL_MS, FollowerSyncService, FollowerSyncServiceOptions, IColdSegmentReader, ILeaderRouterLike, TFollowerUpstreamFetchInterceptor, TFollowerUpstreamFetchKind, isTransientSqliteLockError } from "./follower.cjs";
8
+ import { ConsensusAbortError, HotStuffNodeRuntime, HotStuffNodeRuntimeOptions, IHotStuffNetworkInterceptorContext, IHotStuffRuntimeStateSnapshot, IHotStuffRuntimeStateStore, TConsensusAbortCode } from "./hotstuff-runtime.cjs";
2
9
  import { MigrationChainManager } from "./migration-chain.cjs";
3
10
  import { TokenDistributionManager } from "./token-distribution.cjs";
4
11
  import { ILedger } from "@ocap/types";
@@ -8,11 +15,19 @@ import Queue from "queue";
8
15
  //#region src/index.d.ts
9
16
  declare const formatData: (data: IDataObject | null | undefined) => IDataObject | null | undefined;
10
17
  declare const formatDelegationOps: (state: IDelegateState) => any;
18
+ /**
19
+ * Index `tx` columns a GraphQL `IndexedTransaction` read needs (#1872): the type's fields (hash sender receiver time
20
+ * type tx valid code receipts gasPayer; `tokenSymbols` is always recomputed by _formatTx) plus every input of
21
+ * _formatTx / getTxReceipts / getTxSender / deriveTxGasPayer / isDefaultTokenChanged / attachPaidTxGas, which only
22
+ * read these. Used only when the caller sets `ctx.graphqlTxProjection` (@ocap/gql does, for listTransactions and
23
+ * listAssetTransactions); every other caller keeps receiving every column.
24
+ */
25
+ declare const GRAPHQL_INDEXED_TX_COLUMNS: readonly string[];
11
26
  declare class OCAPResolver implements IResolver {
12
27
  statedb: IStateDB$1;
13
28
  indexdb: IIndexDB$1;
14
29
  ledger: ILedger;
15
- filter?: IFilter;
30
+ filter?: IFilter$1;
16
31
  config: IChainConfig;
17
32
  chainAddr: string;
18
33
  tokenItx: TIndexedTokenState$1 | null;
@@ -26,6 +41,24 @@ declare class OCAPResolver implements IResolver {
26
41
  formatTx: (tx: IResolverTransaction | null, ctx?: IResolverContext$1) => Promise<IResolverTransaction | null>;
27
42
  inFlightPreFlights: number;
28
43
  private initializationPromise;
44
+ private shutdownPromise;
45
+ private isShuttingDown;
46
+ private preFlightDrainWaiters;
47
+ private readonly deferInitialize;
48
+ private readonly explicitConsensusMode?;
49
+ private readonly now;
50
+ private skipInitializeStateDB;
51
+ private nodeRuntime?;
52
+ private admissionBlockedCheck?;
53
+ private admissionReservedSymbolCheck?;
54
+ private maxTxRequestOverride?;
55
+ private pendingIndexWrites;
56
+ private txAcceptedTotal;
57
+ private txPersistedFailedTotal;
58
+ private txPreFlightRejectedTotal;
59
+ private txForwardedTotal;
60
+ private readonly txBucketsSec;
61
+ private readonly txBucketCounts;
29
62
  /**
30
63
  * Creates an instance of OCAPResolver.
31
64
  * @param params Parameters to bootstrap the resolver
@@ -42,9 +75,46 @@ declare class OCAPResolver implements IResolver {
42
75
  ledger,
43
76
  config,
44
77
  filter,
78
+ admissionBlockedCheck,
79
+ admissionReservedSymbolCheck,
45
80
  validateTokenConfig,
81
+ skipInitializeStateDB,
82
+ deferInitialize,
83
+ consensusMode,
84
+ txQueueConfig,
85
+ now,
86
+ nodeRuntime,
46
87
  logger
47
88
  }: IResolverParams);
89
+ initialize(): Promise<void>;
90
+ setNodeRuntime(runtime?: INodeRuntimeAdapter): void;
91
+ getNodeRuntime(): INodeRuntimeAdapter | undefined;
92
+ setAdmissionBlockedCheck(fn?: (address: string) => boolean | Promise<boolean>): void;
93
+ setAdmissionReservedSymbolCheck(fn?: (symbol: string) => boolean | Promise<boolean>): void;
94
+ getMaxTxRequest(): number;
95
+ setMaxTxRequest(maxRequest?: number): void;
96
+ private recordCommittedTxSample;
97
+ getPipelineTelemetry(nowMs?: number): {
98
+ queueDepth: number;
99
+ inFlightPreFlights: number;
100
+ maxTxRequest: number;
101
+ concurrency: number;
102
+ acceptedTotal: number;
103
+ persistedFailedTotal: number;
104
+ preFlightRejectedTotal: number;
105
+ forwardedTotal: number;
106
+ tps10s: number;
107
+ tps60s: number;
108
+ };
109
+ private assertNotBlockedAtAdmission;
110
+ getFollowerStatus(): Promise<IFollowerStatusResponse | null>;
111
+ signForwardedSendTxReceipt(txHash: string): Promise<{
112
+ proposer: string;
113
+ signature: string;
114
+ commitProof?: string;
115
+ } | null>;
116
+ private trackIndexWrite;
117
+ flushIndexWrites(): Promise<void>;
48
118
  sendTx({
49
119
  tx: txBase64,
50
120
  extra
@@ -60,10 +130,19 @@ declare class OCAPResolver implements IResolver {
60
130
  getBlock(): null;
61
131
  getBlocks(): never[];
62
132
  getUnconfirmedTxs(): never[];
133
+ private resolveNodeSyncMetadata;
63
134
  getChainInfo(): Promise<IResolverChainInfo>;
64
135
  getNodeInfo(): Promise<IResolverNodeInfo>;
65
136
  getNetInfo(): Promise<IResolverNetInfo>;
66
137
  getValidatorsInfo(): Promise<IResolverValidatorsInfo>;
138
+ getLedgerInfo(): Promise<{
139
+ chainId: string;
140
+ latestSequence: number;
141
+ entryHashV2From: string | null;
142
+ proposer: string | null;
143
+ proposerPublicKey: string | null;
144
+ checkpointSigningEnabled: boolean;
145
+ } | null>;
67
146
  getLatestCheckpoint({
68
147
  height
69
148
  }?: {
@@ -83,6 +162,7 @@ declare class OCAPResolver implements IResolver {
83
162
  }): Promise<{
84
163
  proof: unknown;
85
164
  checkpoint: unknown;
165
+ entryHashV2From?: string;
86
166
  } | null>;
87
167
  getConfig(): string;
88
168
  getAccountState({
@@ -155,7 +235,10 @@ declare class OCAPResolver implements IResolver {
155
235
  runAsLambda<T>(fn: (txn?: unknown) => T | Promise<T>, args?: Record<string, unknown>): Promise<T>;
156
236
  getChain(): Promise<Record<string, unknown> | null>;
157
237
  getToken(id: string): Promise<ITokenState | null>;
158
- initializeStateDB(): Promise<void>;
238
+ initializeStateDB(options?: {
239
+ txTime?: string | number | Date;
240
+ readonly?: boolean;
241
+ }): Promise<void>;
159
242
  /**
160
243
  * Persist a durable trail for a failed indexdb write from connectIndexDB()'s statedb
161
244
  * listeners. The write path itself is fire-and-forget (EventEmitter, no retry) — this
@@ -267,4 +350,4 @@ declare class OCAPResolver implements IResolver {
267
350
  }): Promise<IChunkIterator<IResolverStakeState>>;
268
351
  }
269
352
  //#endregion
270
- export { type IChainConfig, type IChunkIterator, type IDataObject, type IPaginatedResult, type IResolverPaging, type IResolverParams, type IResolverTransaction, type ITokenInfo, OCAPResolver as default, formatData, formatDelegationOps };
353
+ export { type AdminAuthGuardOptions, ConsensusAbortError, type CreateAPIHandlerOptions, type CreateExplorerMiddlewareOptions, type CreateNodeDashboardRouterOptions, type CreateUnifiedConsoleMiddlewareOptions, DEFAULT_FOLLOWER_MAX_SYNC_LAG, DEFAULT_FOLLOWER_MAX_UPSTREAM_STALE_MS, DEFAULT_FOLLOWER_POLL_INTERVAL_MS, type DnsLookupAllFn, FollowerSyncService, type FollowerSyncServiceOptions, GRAPHQL_INDEXED_TX_COLUMNS, HotStuffNodeRuntime, type HotStuffNodeRuntimeOptions, type IAdminAuthGuard, type IAttributedBlockedAccount, type IAttributedReservedSymbol, type IAttributedTrustedAccount, type IBlockedAccountEntry, type IChainConfig, type IChunkIterator, type IColdSegmentReader, type ICreateAPIHandlerParams, type IDashboardResolverTarget, type IDataObject, type IDatabaseFileMetrics, type IDryRunVerifyEntriesOptions, type IDryRunVerifyEntriesResult, type IFollowerStatusResponse, type IHotStuffNetworkInterceptorContext, type IHotStuffRuntimeStateSnapshot, type IHotStuffRuntimeStateStore, type ILeaderRouterLike, type ILedgerHealthSummary, type ILedgerHealthThresholds, type ILegacyPreferencesResult, type INodeMaintenanceController, type INodeMaintenanceStatusSummary, type INodePreferencesFileSchema, type INodePreferencesSnapshot, type INodeRuntimeAdapter, type INodeRuntimePreferences, type IPaginatedResult, type IReplayEntryOptions, type IReplayEntryResult, type IReplayerResolverTarget, type IReservedSymbolEntry, type IResolverPaging, type IResolverParams, type IResolverTransaction, type ISlowStorageTelemetry, type ITokenInfo, type ITrustedAccountEntry, type IUpdateNodePreferencesInput, type IUpdateNodePreferencesResult, LedgerEntryReplayer, MAX_BLOCKED_ACCOUNTS, MAX_CONFIG_BODY_BYTES, MAX_MEMO_LENGTH, MAX_PEER_URLS, MAX_RESERVED_SYMBOLS, MAX_TRUSTED_ACCOUNTS, type NodeMaintenanceControllerOptions, NodePreferencesError, NodePreferencesManager, type NodePreferencesManagerOptions, type TConsensusAbortCode, type TFollowerUpstreamFetchInterceptor, type TFollowerUpstreamFetchKind, type TPreferenceSource, UNIFIED_CONSOLE_APP_JS, applyBootRuntimePreferences, buildUnifiedConsoleHtml, collectLedgerHealthSummary, createAdminAuthGuard, createExplorerMiddleware, createFollowerPeerFetchGuard, createNodeDashboardRouter, createNodeMaintenanceController, createUnifiedConsoleMiddleware, OCAPResolver as default, formatData, formatDelegationOps, isDashboardEnabled, isExplorerEnabled, isPrivateOrReservedIpAddress, isTransientSqliteLockError, isValidAccountAddressCandidate, loadNodePreferences, normalizeBlockedAccountKey, timingSafeTokenEqual, validateFollowerPeerUrls };