@xyo-network/xl1-protocol-sdk 1.30.0 → 1.30.2

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.
@@ -365,4 +365,4 @@ async function getFileConfig(searchPlaces) {
365
365
  export {
366
366
  getFileConfig
367
367
  };
368
- //# sourceMappingURL=getFileConfig.mjs.map
368
+ //# sourceMappingURL=getFileConfig.mjs.map
@@ -1 +1,7 @@
1
- {"version":3,"sources":["../../src/getFileConfig.ts","../../src/config/Actor.ts","../../src/config/Base.ts","../../src/config/Chain.ts","../../src/config/DataLake/DataLake.ts","../../src/config/DataLake/RestDataLakeConfig.ts","../../src/config/DataLake/DataLakeRemoteConfig.ts","../../src/config/DataLake/RouterDataLakeConfig.ts","../../src/config/Evm.ts","../../src/config/Log.ts","../../src/config/Providers.ts","../../src/config/Provider.ts","../../src/config/Remote.ts","../../src/config/storage/driver/Mongo.ts","../../src/config/storage/Storage.ts","../../src/config/Telemetry.ts","../../src/config/Validation.ts","../../src/primitives/uncle/findBestUncle.ts","../../src/config/Actors.ts","../../src/config/Config.ts"],"sourcesContent":["import { isDefined, isNull } from '@xylabs/sdk-js'\nimport { cosmiconfig } from 'cosmiconfig'\n\nimport { ConfigZod } from './config/index.ts'\n\n/**\n * The name of the configuration file to search for.\n */\nconst configName = 'xyo'\n\n/**\n * The name of the section within the configuration file to parse.\n */\nconst configSection = 'xl1' // Default section in the config file\n\n/**\n * Attempts to parse the configuration from a file using cosmiconfig.\n * @returns The parsed configuration object if found and valid, otherwise undefined.\n */\nexport async function getFileConfig(searchPlaces?: string[]) {\n const explorer = cosmiconfig(\n configName,\n {\n cache: true,\n searchPlaces,\n },\n )\n const result: unknown = (await explorer.search())?.config\n if (!isNull(result)) {\n const section = (result as Record<string, unknown>)[configSection]\n if (isDefined(section) && typeof section === 'object') {\n return ConfigZod.loose().parse(section)\n }\n }\n return ConfigZod.parse({})\n}\n","import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@xylabs/sdk-js'\nimport { globalRegistry, z } from 'zod'\n\nimport { BaseConfigZod } from './Base.ts'\n\n/**\n * BIP-32 derivation path for an actor wallet.\n *\n * - Absolute form: starts with `m/` (e.g. `m/44'/60'/0'/0/0`). The full path is used as-is,\n * giving the caller complete control over coin type, account, and hardening.\n * - Relative form: a segment list without the `m/` prefix (e.g. `0`, `0/1`, `44'/60'/0'/0/0`).\n * The consumer appends this to its configured root base path.\n *\n * Each segment is a non-negative integer, optionally suffixed with `'` to mark it as hardened.\n */\nexport const AccountPathZod = z.string().regex(\n /^(m(\\/\\d+'?)+|\\d+'?(\\/\\d+'?)*)$/,\n 'Invalid BIP-32 derivation path. Use either an absolute path like \"m/44\\'/60\\'/0\\'/0/0\" or a relative path like \"0\", \"0/1\", or \"44\\'/60\\'/0\\'/0/0\".',\n)\n\n/** ActorConfigZod constant. */\nexport const ActorConfigZod = BaseConfigZod.extend({\n name: z.string(),\n accountPath: AccountPathZod.optional().register(globalRegistry, {\n description: 'BIP-32 derivation path for the actor wallet. Absolute when it starts with \"m/\"; otherwise relative to the root wallet base path. Each actor must derive to a distinct path.',\n title: 'accountPath',\n type: 'string',\n }),\n /**\n * @deprecated Use the top-level `healthCheckPort` on `ConfigZod` instead.\n * The system-wide health server covers all actors in a single process; per-actor\n * health ports will be removed in a future major release.\n */\n healthCheckPort: z.coerce.number().optional().register(globalRegistry, {\n description: '[DEPRECATED — use top-level healthCheckPort] Per-actor health server port.',\n title: 'actor.healthCheckPort',\n type: 'number',\n }),\n})\n\n/** ActorConfig type. */\nexport type ActorConfig = z.infer<typeof ActorConfigZod>\n\n/** Type guard that checks if a value is a valid ActorConfig. */\nexport const isActorConfig = zodIsFactory(ActorConfigZod)\n/** Converts a value to ActorConfig, throwing if invalid. */\nexport const asActorConfig = zodAsFactory(ActorConfigZod, 'asActorConfig')\n/** toActorConfig constant. */\nexport const toActorConfig = zodToFactory(ActorConfigZod, 'toActorConfig')\n","import { z } from 'zod'\n\nimport { ChainConfigZod } from './Chain.ts'\nimport { DataLakeConfigZod } from './DataLake/index.ts'\nimport { EvmConfigZod } from './Evm.ts'\nimport { LogConfigZod } from './Log.ts'\nimport { ProvidersConfigZod } from './Providers.ts'\nimport { RemoteConfigZod } from './Remote.ts'\nimport { StorageConfigZod } from './storage/index.ts'\nimport { TelemetryConfigZod } from './Telemetry.ts'\nimport { ValidationConfigZod } from './Validation.ts'\n\n/** BaseConfigZod constant. */\nexport const BaseConfigZod = z.object({\n chain: ChainConfigZod.default(ChainConfigZod.parse({})).describe('Configuration for the chain'),\n dataLake: DataLakeConfigZod.optional().describe('Configuration for data lakes'),\n evm: EvmConfigZod.default(EvmConfigZod.parse({})).describe('Configuration for EVM-backed services'),\n log: LogConfigZod.default(LogConfigZod.parse({})).describe('Configuration for logging'),\n providers: ProvidersConfigZod.default(ProvidersConfigZod.parse([])).describe('Configuration for providers'),\n remote: RemoteConfigZod.default(RemoteConfigZod.parse({})).describe('Configuration for remote services'),\n storage: StorageConfigZod.default(StorageConfigZod.parse({})).describe('Configuration for the storage'),\n telemetry: TelemetryConfigZod.default(TelemetryConfigZod.parse({})).describe('Configuration for telemetry'),\n validation: ValidationConfigZod.default(ValidationConfigZod.parse({})).describe('Configuration for validation'),\n})\n\n/** BaseConfig type. */\nexport type BaseConfig = z.infer<typeof BaseConfigZod>\n","import { AddressZod, HexZod } from '@xylabs/sdk-js'\nimport { globalRegistry, z } from 'zod'\n\n/** ChainConfigZod constant. */\nexport const ChainConfigZod = z.object({\n id: HexZod.optional()\n .register(globalRegistry, {\n description:\n 'The unique identifier for the chain. Should be the staking contract address for contract-backed chains.',\n title: 'chain.id',\n type: 'string',\n }),\n genesisRewardAddress: AddressZod.optional()\n .register(globalRegistry, {\n description:\n 'Address to send the initial genesis rewards to, if a new chain is being created.',\n title: 'chain.genesisRewardAddress',\n type: 'Address',\n }),\n})\n\n/** ChainConfig type. */\nexport type ChainConfig = z.infer<typeof ChainConfigZod>\n","import { z } from 'zod'\n\nimport { type RestDataLakeConfig, RestDataLakeConfigZod } from './RestDataLakeConfig.ts'\n// eslint-disable-next-line import-x/no-cycle -- intentional cycle for z.lazy recursive type\nimport { type RouterDataLakeConfig, RouterDataLakeConfigZod } from './RouterDataLakeConfig.ts'\n\n/** DataLakeConfig type. */\nexport type DataLakeConfig = RestDataLakeConfig | RouterDataLakeConfig\n\n// z.lazy handles the circular reference between DataLakeConfigZod and RouterDataLakeZod\n/** DataLakeConfigZod constant. */\nexport const DataLakeConfigZod: z.ZodType<DataLakeConfig> = z.lazy(() =>\n z.union([RestDataLakeConfigZod, RouterDataLakeConfigZod])).describe('Configuration for a data lake')\n","import { globalRegistry, z } from 'zod'\n\nimport { DataLakeDriverConfigBaseZod } from './DataLakeRemoteConfig.ts'\n\n/** RestDataLakeConfigZod constant. */\nexport const RestDataLakeConfigZod = DataLakeDriverConfigBaseZod.extend({\n driver: z.literal('rest').register(globalRegistry, {\n description: 'Driver for the REST data lake',\n type: 'string',\n }),\n url: z.string().register(globalRegistry, {\n description: 'URL for the REST data lake',\n type: 'string',\n }),\n}).describe('Configuration for the REST data lake driver')\n\n/** RestDataLakeConfig type. */\nexport type RestDataLakeConfig = z.infer<typeof RestDataLakeConfigZod>\n","import { globalRegistry, z } from 'zod'\n\n/** DataLakeDriverConfigBaseZod constant. */\nexport const DataLakeDriverConfigBaseZod = z.object({\n driver: z.string().register(globalRegistry, {\n description: 'Driver for the data lake',\n type: 'string',\n }),\n}).describe('Base configuration for a data lake driver')\n/** DataLakeDriverConfigBase type. */\nexport type DataLakeDriverConfigBase = z.infer<typeof DataLakeDriverConfigBaseZod>\n","import { globalRegistry, z } from 'zod'\n\nimport type { DataLakeConfig } from './DataLake.ts'\n// eslint-disable-next-line import-x/no-cycle -- intentional cycle for z.lazy recursive type\nimport { DataLakeConfigZod } from './DataLake.ts'\n\n/** Configuration for RouterDataLake. */\nexport interface RouterDataLakeConfig {\n children: DataLakeConfig[]\n driver: 'router'\n}\n\n/** RouterDataLakeConfigZod constant. */\nexport const RouterDataLakeConfigZod: z.ZodType<RouterDataLakeConfig> = z.object({\n driver: z.literal('router').register(globalRegistry, {\n description: 'Driver for the router data lake',\n type: 'string',\n }),\n children: z.array(z.lazy(() => DataLakeConfigZod)).register(globalRegistry, {\n description: 'Child data lake drivers',\n type: 'array',\n }),\n}).describe('Configuration for the router data lake driver')\n","import { globalRegistry, z } from 'zod'\n\n/** EvmInfuraConfigZod constant. */\nexport const EvmInfuraConfigZod = z.object({\n projectId: z.string().optional().register(globalRegistry, {\n description: 'Infura project ID',\n title: 'evm.infura.projectId',\n type: 'string',\n }),\n projectSecret: z.string().optional().register(globalRegistry, {\n description: 'Infura project secret',\n title: 'evm.infura.projectSecret',\n type: 'string',\n }),\n})\n\n/** EvmJsonRpcConfigZod constant. */\nexport const EvmJsonRpcConfigZod = z.object({\n url: z.url().optional().register(globalRegistry, {\n description: 'JSON-RPC URL',\n title: 'evm.jsonRpc.url',\n type: 'string',\n }),\n})\n\n/** EvmConfigZod constant. */\nexport const EvmConfigZod = z.object({\n chainId: z.string().optional().register(globalRegistry, {\n description: 'EVM chain ID',\n title: 'evm.chainId',\n type: 'string',\n }),\n infura: EvmInfuraConfigZod.optional().describe('Infura Provider configuration'),\n jsonRpc: EvmJsonRpcConfigZod.optional().describe('JSON-RPC Provider configuration'),\n})\n\n/** EvmConfig type. */\nexport type EvmConfig = z.infer<typeof EvmConfigZod>\n","import type { LogLevelKey } from '@xylabs/sdk-js'\nimport { LogLevel } from '@xylabs/sdk-js'\nimport { globalRegistry, z } from 'zod'\n\nconst LogLevelNames = Object.keys(LogLevel) as [LogLevelKey]\n\n/** LogConfigZod constant. */\nexport const LogConfigZod = z.object({\n logLevel: z.enum(LogLevelNames).default('info').register(globalRegistry, {\n choices: LogLevelNames,\n default: 'info',\n description: 'Desired process verbosity',\n title: 'logLevel',\n type: 'string',\n }),\n silent: z.boolean().default(false).register(globalRegistry, {\n default: false,\n description: 'Whether to run in silent mode',\n title: 'silent',\n type: 'boolean',\n }),\n})\n\n/** LogConfig type. */\nexport type LogConfig = z.infer<typeof LogConfigZod>\n","import z from 'zod'\n\nimport { ProviderConfigZod } from './Provider.ts'\n\n/** ProvidersConfigZod constant. */\nexport const ProvidersConfigZod = z.array(ProviderConfigZod.loose()).describe('Configuration for providers').default([])\n\n/** ProvidersConfig type. */\nexport type ProvidersConfig = z.infer<typeof ProvidersConfigZod>\n","import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@xylabs/sdk-js'\nimport { z } from 'zod'\n\n/** ProviderConfigZod constant. */\nexport const ProviderConfigZod = z.object({\n moniker: z.string(),\n labels: z.array(z.string()).optional(),\n}).describe('Configuration for a Provider')\n\n/** ProviderConfig type. */\nexport type ProviderConfig = z.infer<typeof ProviderConfigZod>\n\n/** Type guard that checks if a value is a valid ProviderConfig. */\nexport const isProviderConfig = zodIsFactory(ProviderConfigZod)\n/** Converts a value to ProviderConfig, throwing if invalid. */\nexport const asProviderConfig = zodAsFactory(ProviderConfigZod, 'asProviderConfig')\n/** toProviderConfig constant. */\nexport const toProviderConfig = zodToFactory(ProviderConfigZod, 'toProviderConfig')\n","import { globalRegistry, z } from 'zod'\n\n/** RpcRemoteConfigBaseZod constant. */\nexport const RpcRemoteConfigBaseZod = z.object({\n protocol: z.string('http').register(globalRegistry, {\n description: 'Protocol for the RPC connection',\n type: 'string',\n }),\n}).describe('Base configuration for the remote RPC')\n\n/** RpcRemoteConfigBase type. */\nexport type RpcRemoteConfigBase = z.infer<typeof RpcRemoteConfigBaseZod>\n\n/** HttpRpcRemoteConfigZod constant. */\nexport const HttpRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({\n protocol: z.string('http').register(globalRegistry, {\n description: 'Protocol for the RPC connection',\n type: 'string',\n }).default('http'),\n url: z.string().register(globalRegistry, {\n description: 'URL for the Chain RPC API',\n type: 'string',\n }),\n}).describe('Configuration for the remote RPC using Http')\n\n/** HttpRpcRemoteConfig type. */\nexport type HttpRpcRemoteConfig = z.infer<typeof HttpRpcRemoteConfigZod>\n\n/** PostMessageRpcRemoteConfigZod constant. */\nexport const PostMessageRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({\n protocol: z.string().register(globalRegistry, {\n description: 'Protocol for the RPC connection',\n type: 'string',\n }).default('postMessage'),\n networkId: z.string().register(globalRegistry, {\n description: 'Network ID to use for the postMessage RPC connection',\n type: 'string',\n }),\n sessionId: z.string().register(globalRegistry, {\n description: 'Session ID to use for the postMessage RPC connection',\n type: 'string',\n }),\n}).describe('Configuration for the remote RPC using postMessage')\n\n/** PostMessageRpcRemoteConfig type. */\nexport type PostMessageRpcRemoteConfig = z.infer<typeof PostMessageRpcRemoteConfigZod>\n\n/** RpcRemoteConfigZod constant. */\nexport const RpcRemoteConfigZod = z.union([HttpRpcRemoteConfigZod, PostMessageRpcRemoteConfigZod])\n .describe('Configuration for a remote RPC connection, either Http or postMessage')\n\n/** RpcRemoteConfig type. */\nexport type RpcRemoteConfig = z.infer<typeof RpcRemoteConfigZod>\n\n/** RemoteConfigZod constant. */\nexport const RemoteConfigZod = z.object({ rpc: RpcRemoteConfigZod.optional() }).describe('Configuration for remote connections, including RPC')\n\n/** RemoteConfig type. */\nexport type RemoteConfig = z.infer<typeof RemoteConfigZod>\n","import { isDefined, isUndefined } from '@xylabs/sdk-js'\nimport { globalRegistry, z } from 'zod'\n\n/**\n * Checks if the provided MongoDB configuration contains the fields needed to\n * identify a Mongo target. `username` / `password` are intentionally not\n * required: `mongodb-memory-server` and many production deployments run\n * without auth (or carry credentials inline in the `connectionString` URI).\n * @param config MongoDB configuration object\n * @returns True iff `connectionString`, `database`, and `domain` are all set\n */\nexport const hasMongoConfig = (\n config?: MongoConfig,\n): config is MongoConfig & { connectionString: string; database: string; domain: string } => {\n if (isUndefined(config)) return false\n return (\n isDefined(config.connectionString)\n && isDefined(config.database)\n && isDefined(config.domain)\n )\n}\n\n/** MongoConfigZod constant. */\nexport const MongoConfigZod = z.object({\n // TODO: Create from other arguments\n connectionString: z.string().nonempty().optional().register(globalRegistry, {\n description: 'MongoDB connection string',\n title: 'storage.mongo.connectionString',\n type: 'string',\n }),\n database: z.string().nonempty().optional().register(globalRegistry, {\n description: 'MongoDB database name',\n title: 'storage.mongo.database',\n type: 'string',\n }),\n domain: z.string().nonempty().optional().register(globalRegistry, {\n description: 'MongoDB domain',\n title: 'storage.mongo.domain',\n type: 'string',\n }),\n password: z.string().nonempty().optional().register(globalRegistry, {\n description: 'MongoDB password',\n title: 'storage.mongo.password',\n type: 'string',\n }),\n username: z.string().nonempty().optional().register(globalRegistry, {\n description: 'MongoDB username',\n title: 'storage.mongo.username',\n type: 'string',\n }),\n})\n\n/** MongoConfig type. */\nexport type MongoConfig = z.infer<typeof MongoConfigZod>\n","import { globalRegistry, z } from 'zod'\n\nimport { MongoConfigZod } from './driver/index.ts'\n\n/** StorageConfigZod constant. */\nexport const StorageConfigZod = z.object({\n mongo: MongoConfigZod.optional().describe('Configuration for the MongoD storage driver'),\n root: z.string().optional().register(globalRegistry, {\n description: 'Root directory for local storage',\n title: 'storage.root',\n type: 'string',\n }),\n}).describe('Storage configuration options')\n\n/** StorageConfig type. */\nexport type StorageConfig = z.infer<typeof StorageConfigZod>\n","import { globalRegistry, z } from 'zod'\n\n/** DefaultMetricsScrapePorts constant. */\nexport const DefaultMetricsScrapePorts = {\n api: 9465,\n bridge: 9468,\n mempool: 9466,\n producer: 9464,\n rewardRedemptionApi: 9467,\n}\n\n/** MetricsScrapeConfigZod constant. */\nexport const MetricsScrapeConfigZod = z.object({\n path: z.string().default('/metrics').register(globalRegistry, {\n default: '/metrics',\n description: 'Path for the metrics scrape endpoint',\n title: 'telemetry.metrics.scrape.path',\n type: 'string',\n }),\n port: z.coerce.number().int().positive().optional().register(globalRegistry, {\n description: 'Port for the metrics scrape endpoint',\n title: 'telemetry.metrics.scrape.port',\n type: 'number',\n }),\n}).describe('Metrics scrape configuration')\n\n/** MetricsConfigZod constant. */\nexport const MetricsConfigZod = z.object({ scrape: MetricsScrapeConfigZod }).describe('Metrics configuration options')\n\n/** OpenTelemetryConfigZod constant. */\nexport const OpenTelemetryConfigZod = z.object({\n // OpenTelemetry options\n otlpEndpoint: z.url().optional().register(globalRegistry, {\n description: 'OTLP endpoint for exporting telemetry data',\n title: 'telemetry.otel.otlpEndpoint',\n type: 'string',\n }),\n})\n\n/** TelemetryConfigZod constant. */\nexport const TelemetryConfigZod = z.object({\n // Metrics configuration\n metrics: MetricsConfigZod.optional().describe('Metrics configuration'),\n // OpenTelemetry configuration\n otel: OpenTelemetryConfigZod.optional().describe('OpenTelemetry configuration'),\n}).describe('Telemetry configuration options')\n\n/** TelemetryConfig type. */\nexport type TelemetryConfig = z.infer<typeof TelemetryConfigZod>\n","import { AddressZod } from '@xylabs/sdk-js'\nimport { globalRegistry, z } from 'zod'\n\nimport { DEFAULT_BACKOFF_MS, DEFAULT_MIN_CANDIDATES } from '../primitives/index.ts'\n\n/** ValidationConfigZod constant. */\nexport const ValidationConfigZod = z.object({\n allowedRewardRedeemers: z.array(AddressZod).optional().register(globalRegistry, {\n description: 'List of allowed reward redeemer addresses, if undefined anyone can participate',\n title: 'allowedRewardRedeemers',\n type: 'array',\n }),\n allowedRewardEscrowAccountSigners: z.array(AddressZod).optional().register(globalRegistry, {\n description: 'List of allowed reward escrow account signer addresses, if undefined anyone can participate',\n title: 'allowedRewardEscrowAccountSigners',\n type: 'array',\n }),\n minCandidates: z.coerce.number().default(DEFAULT_MIN_CANDIDATES).register(globalRegistry, {\n default: DEFAULT_MIN_CANDIDATES,\n description: 'Minimum number of uncle candidates before selecting the best uncle',\n title: 'validation.minCandidates',\n type: 'number',\n }),\n backoffMs: z.coerce.number().default(DEFAULT_BACKOFF_MS).register(globalRegistry, {\n default: DEFAULT_BACKOFF_MS,\n description: 'Back-off timeout in ms. If head age exceeds this, minCandidates is ignored',\n title: 'validation.backoffMs',\n type: 'number',\n }),\n})\n\n/** ValidationConfig type. */\nexport type ValidationConfig = z.infer<typeof ValidationConfigZod>\n","import type { SignedHydratedBlockWithHashMeta } from '@xyo-network/xl1-protocol-lib'\n\nimport { scoreUncle } from './scoreUncle.ts'\n\n/** Default minimum number of uncle candidates before selecting. */\nexport const DEFAULT_MIN_CANDIDATES = 1\n\n/** Default back-off timeout in milliseconds. If the head has not changed for this long, minCandidates is ignored. */\nexport const DEFAULT_BACKOFF_MS = 120_000\n\n/** Options for findBestUncle block selection. */\nexport interface FindBestUncleOptions {\n /** Back-off timeout in ms. If head age exceeds this, minCandidates is ignored. Default: 120_000. */\n backoffMs?: number\n /** Minimum number of uncle candidates before selecting. Default: 1. */\n minCandidates?: number\n /** Current timestamp in ms. Injectable for testing. Default: Date.now(). */\n now?: number\n}\n\n/** Selects the best uncle chain from candidates using Proof of Perfect scoring. */\nexport function findBestUncle(\n finalizedWindowedChain: SignedHydratedBlockWithHashMeta[],\n uncles: SignedHydratedBlockWithHashMeta[][],\n options?: FindBestUncleOptions,\n): SignedHydratedBlockWithHashMeta[] | undefined {\n if (uncles.length === 0) return undefined\n\n const minCandidates = options?.minCandidates ?? DEFAULT_MIN_CANDIDATES\n const backoffMs = options?.backoffMs ?? DEFAULT_BACKOFF_MS\n const now = options?.now ?? Date.now()\n\n if (uncles.length < minCandidates) {\n const headEpoch = finalizedWindowedChain.at(-1)?.[0].$epoch ?? 0\n const headAge = now - headEpoch\n if (headAge < backoffMs) {\n return undefined\n }\n }\n\n const scores = uncles.map(uncle => ([scoreUncle(finalizedWindowedChain, uncle), uncle] as const)).toSorted((a, b) => b[0] - a[0])\n return scores[0]?.[1]\n}\n","import z from 'zod'\n\nimport { ActorConfigZod } from './Actor.ts'\n\n/** ActorsConfigZod constant. */\nexport const ActorsConfigZod = z.array(ActorConfigZod.loose()).describe('Actor-specific configurations that override the base configuration when the actor is running').default([])\n\n/** ActorsConfig type. */\nexport type ActorsConfig = z.infer<typeof ActorsConfigZod>\n","import { globalRegistry, z } from 'zod'\n\nimport { ActorConfigZod } from './Actor.ts'\nimport { ActorsConfigZod } from './Actors.ts'\nimport { BaseConfigZod } from './Base.ts'\nimport type { DeepPartial } from './DeepPartial.ts'\n\n/** ConfigZod constant. */\nexport const ConfigZod = BaseConfigZod.extend({\n actors: ActorsConfigZod,\n healthCheckPort: z.coerce.number().optional().register(globalRegistry, {\n description: 'Port for the system-wide health, readiness, and liveness endpoints (/healthz, /livez, /readyz). Set to 0 to disable.',\n title: 'healthCheckPort',\n type: 'number',\n }),\n}).describe('The complete configuration for the protocol, including global settings and actor-specific overrides')\n\n/** Config type. */\nexport type Config = z.infer<typeof ConfigZod>\n\n/** ResolveConfig helper function. */\nexport function resolveConfig(\n config: DeepPartial<Config>,\n) {\n const parsedConfig = ConfigZod.parse(config)\n const { actors, ...rootConfig } = parsedConfig\n parsedConfig.actors = actors.map((actorConfig) => {\n return ActorConfigZod.loose().parse({ ...rootConfig, ...actorConfig })\n })\n return parsedConfig\n}\n"],"mappings":";AAAA,SAAS,aAAAA,YAAW,cAAc;AAClC,SAAS,mBAAmB;;;ACD5B;AAAA,EACE,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,OACvB;AACP,SAAS,kBAAAC,kBAAgB,KAAAC,WAAS;;;ACHlC,SAAS,KAAAC,WAAS;;;ACAlB,SAAS,YAAY,cAAc;AACnC,SAAS,gBAAgB,SAAS;AAG3B,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,IAAI,OAAO,SAAS,EACjB,SAAS,gBAAgB;AAAA,IACxB,aACA;AAAA,IACA,OAAO;AAAA,IACP,MAAM;AAAA,EACR,CAAC;AAAA,EACH,sBAAsB,WAAW,SAAS,EACvC,SAAS,gBAAgB;AAAA,IACxB,aACA;AAAA,IACA,OAAO;AAAA,IACP,MAAM;AAAA,EACR,CAAC;AACL,CAAC;;;ACnBD,SAAS,KAAAC,UAAS;;;ACAlB,SAAS,kBAAAC,iBAAgB,KAAAC,UAAS;;;ACAlC,SAAS,kBAAAC,iBAAgB,KAAAC,UAAS;AAG3B,IAAM,8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E,QAAIC,WAAU,OAAO,KAAK,OAAO,YAAY,UAAU;AACrD,aAAO,UAAU,MAAM,EAAE,MAAM,OAAO;AAAA,IACxC;AAAA,EACF;AACA,SAAO,UAAU,MAAM,CAAC,CAAC;AAC3B;","names":["isDefined","zodAsFactory","zodIsFactory","zodToFactory","globalRegistry","z","z","z","globalRegistry","z","globalRegistry","z","z","globalRegistry","globalRegistry","z","z","globalRegistry","z","globalRegistry","z","globalRegistry","z","z","z","z","globalRegistry","z","globalRegistry","z","z","globalRegistry","globalRegistry","z","z","globalRegistry","globalRegistry","z","z","globalRegistry","AddressZod","globalRegistry","z","z","AddressZod","globalRegistry","z","z","globalRegistry","zodIsFactory","zodAsFactory","zodToFactory","z","z","globalRegistry","z","z","globalRegistry","isDefined"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/getFileConfig.ts", "../../src/config/Actor.ts", "../../src/config/Base.ts", "../../src/config/Chain.ts", "../../src/config/DataLake/DataLake.ts", "../../src/config/DataLake/RestDataLakeConfig.ts", "../../src/config/DataLake/DataLakeRemoteConfig.ts", "../../src/config/DataLake/RouterDataLakeConfig.ts", "../../src/config/Evm.ts", "../../src/config/Log.ts", "../../src/config/Providers.ts", "../../src/config/Provider.ts", "../../src/config/Remote.ts", "../../src/config/storage/driver/Mongo.ts", "../../src/config/storage/Storage.ts", "../../src/config/Telemetry.ts", "../../src/config/Validation.ts", "../../src/primitives/uncle/findBestUncle.ts", "../../src/config/Actors.ts", "../../src/config/Config.ts"],
4
+ "sourcesContent": ["import { isDefined, isNull } from '@xylabs/sdk-js'\nimport { cosmiconfig } from 'cosmiconfig'\n\nimport { ConfigZod } from './config/index.ts'\n\n/**\n * The name of the configuration file to search for.\n */\nconst configName = 'xyo'\n\n/**\n * The name of the section within the configuration file to parse.\n */\nconst configSection = 'xl1' // Default section in the config file\n\n/**\n * Attempts to parse the configuration from a file using cosmiconfig.\n * @returns The parsed configuration object if found and valid, otherwise undefined.\n */\nexport async function getFileConfig(searchPlaces?: string[]) {\n const explorer = cosmiconfig(\n configName,\n {\n cache: true,\n searchPlaces,\n },\n )\n const result: unknown = (await explorer.search())?.config\n if (!isNull(result)) {\n const section = (result as Record<string, unknown>)[configSection]\n if (isDefined(section) && typeof section === 'object') {\n return ConfigZod.loose().parse(section)\n }\n }\n return ConfigZod.parse({})\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@xylabs/sdk-js'\nimport { globalRegistry, z } from 'zod'\n\nimport { BaseConfigZod } from './Base.ts'\n\n/**\n * BIP-32 derivation path for an actor wallet.\n *\n * - Absolute form: starts with `m/` (e.g. `m/44'/60'/0'/0/0`). The full path is used as-is,\n * giving the caller complete control over coin type, account, and hardening.\n * - Relative form: a segment list without the `m/` prefix (e.g. `0`, `0/1`, `44'/60'/0'/0/0`).\n * The consumer appends this to its configured root base path.\n *\n * Each segment is a non-negative integer, optionally suffixed with `'` to mark it as hardened.\n */\nexport const AccountPathZod = z.string().regex(\n /^(m(\\/\\d+'?)+|\\d+'?(\\/\\d+'?)*)$/,\n 'Invalid BIP-32 derivation path. Use either an absolute path like \"m/44\\'/60\\'/0\\'/0/0\" or a relative path like \"0\", \"0/1\", or \"44\\'/60\\'/0\\'/0/0\".',\n)\n\n/** ActorConfigZod constant. */\nexport const ActorConfigZod = BaseConfigZod.extend({\n name: z.string(),\n accountPath: AccountPathZod.optional().register(globalRegistry, {\n description: 'BIP-32 derivation path for the actor wallet. Absolute when it starts with \"m/\"; otherwise relative to the root wallet base path. Each actor must derive to a distinct path.',\n title: 'accountPath',\n type: 'string',\n }),\n /**\n * @deprecated Use the top-level `healthCheckPort` on `ConfigZod` instead.\n * The system-wide health server covers all actors in a single process; per-actor\n * health ports will be removed in a future major release.\n */\n healthCheckPort: z.coerce.number().optional().register(globalRegistry, {\n description: '[DEPRECATED \u2014 use top-level healthCheckPort] Per-actor health server port.',\n title: 'actor.healthCheckPort',\n type: 'number',\n }),\n})\n\n/** ActorConfig type. */\nexport type ActorConfig = z.infer<typeof ActorConfigZod>\n\n/** Type guard that checks if a value is a valid ActorConfig. */\nexport const isActorConfig = zodIsFactory(ActorConfigZod)\n/** Converts a value to ActorConfig, throwing if invalid. */\nexport const asActorConfig = zodAsFactory(ActorConfigZod, 'asActorConfig')\n/** toActorConfig constant. */\nexport const toActorConfig = zodToFactory(ActorConfigZod, 'toActorConfig')\n", "import { z } from 'zod'\n\nimport { ChainConfigZod } from './Chain.ts'\nimport { DataLakeConfigZod } from './DataLake/index.ts'\nimport { EvmConfigZod } from './Evm.ts'\nimport { LogConfigZod } from './Log.ts'\nimport { ProvidersConfigZod } from './Providers.ts'\nimport { RemoteConfigZod } from './Remote.ts'\nimport { StorageConfigZod } from './storage/index.ts'\nimport { TelemetryConfigZod } from './Telemetry.ts'\nimport { ValidationConfigZod } from './Validation.ts'\n\n/** BaseConfigZod constant. */\nexport const BaseConfigZod = z.object({\n chain: ChainConfigZod.default(ChainConfigZod.parse({})).describe('Configuration for the chain'),\n dataLake: DataLakeConfigZod.optional().describe('Configuration for data lakes'),\n evm: EvmConfigZod.default(EvmConfigZod.parse({})).describe('Configuration for EVM-backed services'),\n log: LogConfigZod.default(LogConfigZod.parse({})).describe('Configuration for logging'),\n providers: ProvidersConfigZod.default(ProvidersConfigZod.parse([])).describe('Configuration for providers'),\n remote: RemoteConfigZod.default(RemoteConfigZod.parse({})).describe('Configuration for remote services'),\n storage: StorageConfigZod.default(StorageConfigZod.parse({})).describe('Configuration for the storage'),\n telemetry: TelemetryConfigZod.default(TelemetryConfigZod.parse({})).describe('Configuration for telemetry'),\n validation: ValidationConfigZod.default(ValidationConfigZod.parse({})).describe('Configuration for validation'),\n})\n\n/** BaseConfig type. */\nexport type BaseConfig = z.infer<typeof BaseConfigZod>\n", "import { AddressZod, HexZod } from '@xylabs/sdk-js'\nimport { globalRegistry, z } from 'zod'\n\n/** ChainConfigZod constant. */\nexport const ChainConfigZod = z.object({\n id: HexZod.optional()\n .register(globalRegistry, {\n description:\n 'The unique identifier for the chain. Should be the staking contract address for contract-backed chains.',\n title: 'chain.id',\n type: 'string',\n }),\n genesisRewardAddress: AddressZod.optional()\n .register(globalRegistry, {\n description:\n 'Address to send the initial genesis rewards to, if a new chain is being created.',\n title: 'chain.genesisRewardAddress',\n type: 'Address',\n }),\n})\n\n/** ChainConfig type. */\nexport type ChainConfig = z.infer<typeof ChainConfigZod>\n", "import { z } from 'zod'\n\nimport { type RestDataLakeConfig, RestDataLakeConfigZod } from './RestDataLakeConfig.ts'\n// eslint-disable-next-line import-x/no-cycle -- intentional cycle for z.lazy recursive type\nimport { type RouterDataLakeConfig, RouterDataLakeConfigZod } from './RouterDataLakeConfig.ts'\n\n/** DataLakeConfig type. */\nexport type DataLakeConfig = RestDataLakeConfig | RouterDataLakeConfig\n\n// z.lazy handles the circular reference between DataLakeConfigZod and RouterDataLakeZod\n/** DataLakeConfigZod constant. */\nexport const DataLakeConfigZod: z.ZodType<DataLakeConfig> = z.lazy(() =>\n z.union([RestDataLakeConfigZod, RouterDataLakeConfigZod])).describe('Configuration for a data lake')\n", "import { globalRegistry, z } from 'zod'\n\nimport { DataLakeDriverConfigBaseZod } from './DataLakeRemoteConfig.ts'\n\n/** RestDataLakeConfigZod constant. */\nexport const RestDataLakeConfigZod = DataLakeDriverConfigBaseZod.extend({\n driver: z.literal('rest').register(globalRegistry, {\n description: 'Driver for the REST data lake',\n type: 'string',\n }),\n url: z.string().register(globalRegistry, {\n description: 'URL for the REST data lake',\n type: 'string',\n }),\n}).describe('Configuration for the REST data lake driver')\n\n/** RestDataLakeConfig type. */\nexport type RestDataLakeConfig = z.infer<typeof RestDataLakeConfigZod>\n", "import { globalRegistry, z } from 'zod'\n\n/** DataLakeDriverConfigBaseZod constant. */\nexport const DataLakeDriverConfigBaseZod = z.object({\n driver: z.string().register(globalRegistry, {\n description: 'Driver for the data lake',\n type: 'string',\n }),\n}).describe('Base configuration for a data lake driver')\n/** DataLakeDriverConfigBase type. */\nexport type DataLakeDriverConfigBase = z.infer<typeof DataLakeDriverConfigBaseZod>\n", "import { globalRegistry, z } from 'zod'\n\nimport type { DataLakeConfig } from './DataLake.ts'\n// eslint-disable-next-line import-x/no-cycle -- intentional cycle for z.lazy recursive type\nimport { DataLakeConfigZod } from './DataLake.ts'\n\n/** Configuration for RouterDataLake. */\nexport interface RouterDataLakeConfig {\n children: DataLakeConfig[]\n driver: 'router'\n}\n\n/** RouterDataLakeConfigZod constant. */\nexport const RouterDataLakeConfigZod: z.ZodType<RouterDataLakeConfig> = z.object({\n driver: z.literal('router').register(globalRegistry, {\n description: 'Driver for the router data lake',\n type: 'string',\n }),\n children: z.array(z.lazy(() => DataLakeConfigZod)).register(globalRegistry, {\n description: 'Child data lake drivers',\n type: 'array',\n }),\n}).describe('Configuration for the router data lake driver')\n", "import { globalRegistry, z } from 'zod'\n\n/** EvmInfuraConfigZod constant. */\nexport const EvmInfuraConfigZod = z.object({\n projectId: z.string().optional().register(globalRegistry, {\n description: 'Infura project ID',\n title: 'evm.infura.projectId',\n type: 'string',\n }),\n projectSecret: z.string().optional().register(globalRegistry, {\n description: 'Infura project secret',\n title: 'evm.infura.projectSecret',\n type: 'string',\n }),\n})\n\n/** EvmJsonRpcConfigZod constant. */\nexport const EvmJsonRpcConfigZod = z.object({\n url: z.url().optional().register(globalRegistry, {\n description: 'JSON-RPC URL',\n title: 'evm.jsonRpc.url',\n type: 'string',\n }),\n})\n\n/** EvmConfigZod constant. */\nexport const EvmConfigZod = z.object({\n chainId: z.string().optional().register(globalRegistry, {\n description: 'EVM chain ID',\n title: 'evm.chainId',\n type: 'string',\n }),\n infura: EvmInfuraConfigZod.optional().describe('Infura Provider configuration'),\n jsonRpc: EvmJsonRpcConfigZod.optional().describe('JSON-RPC Provider configuration'),\n})\n\n/** EvmConfig type. */\nexport type EvmConfig = z.infer<typeof EvmConfigZod>\n", "import type { LogLevelKey } from '@xylabs/sdk-js'\nimport { LogLevel } from '@xylabs/sdk-js'\nimport { globalRegistry, z } from 'zod'\n\nconst LogLevelNames = Object.keys(LogLevel) as [LogLevelKey]\n\n/** LogConfigZod constant. */\nexport const LogConfigZod = z.object({\n logLevel: z.enum(LogLevelNames).default('info').register(globalRegistry, {\n choices: LogLevelNames,\n default: 'info',\n description: 'Desired process verbosity',\n title: 'logLevel',\n type: 'string',\n }),\n silent: z.boolean().default(false).register(globalRegistry, {\n default: false,\n description: 'Whether to run in silent mode',\n title: 'silent',\n type: 'boolean',\n }),\n})\n\n/** LogConfig type. */\nexport type LogConfig = z.infer<typeof LogConfigZod>\n", "import z from 'zod'\n\nimport { ProviderConfigZod } from './Provider.ts'\n\n/** ProvidersConfigZod constant. */\nexport const ProvidersConfigZod = z.array(ProviderConfigZod.loose()).describe('Configuration for providers').default([])\n\n/** ProvidersConfig type. */\nexport type ProvidersConfig = z.infer<typeof ProvidersConfigZod>\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@xylabs/sdk-js'\nimport { z } from 'zod'\n\n/** ProviderConfigZod constant. */\nexport const ProviderConfigZod = z.object({\n moniker: z.string(),\n labels: z.array(z.string()).optional(),\n}).describe('Configuration for a Provider')\n\n/** ProviderConfig type. */\nexport type ProviderConfig = z.infer<typeof ProviderConfigZod>\n\n/** Type guard that checks if a value is a valid ProviderConfig. */\nexport const isProviderConfig = zodIsFactory(ProviderConfigZod)\n/** Converts a value to ProviderConfig, throwing if invalid. */\nexport const asProviderConfig = zodAsFactory(ProviderConfigZod, 'asProviderConfig')\n/** toProviderConfig constant. */\nexport const toProviderConfig = zodToFactory(ProviderConfigZod, 'toProviderConfig')\n", "import { globalRegistry, z } from 'zod'\n\n/** RpcRemoteConfigBaseZod constant. */\nexport const RpcRemoteConfigBaseZod = z.object({\n protocol: z.string('http').register(globalRegistry, {\n description: 'Protocol for the RPC connection',\n type: 'string',\n }),\n}).describe('Base configuration for the remote RPC')\n\n/** RpcRemoteConfigBase type. */\nexport type RpcRemoteConfigBase = z.infer<typeof RpcRemoteConfigBaseZod>\n\n/** HttpRpcRemoteConfigZod constant. */\nexport const HttpRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({\n protocol: z.string('http').register(globalRegistry, {\n description: 'Protocol for the RPC connection',\n type: 'string',\n }).default('http'),\n url: z.string().register(globalRegistry, {\n description: 'URL for the Chain RPC API',\n type: 'string',\n }),\n}).describe('Configuration for the remote RPC using Http')\n\n/** HttpRpcRemoteConfig type. */\nexport type HttpRpcRemoteConfig = z.infer<typeof HttpRpcRemoteConfigZod>\n\n/** PostMessageRpcRemoteConfigZod constant. */\nexport const PostMessageRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({\n protocol: z.string().register(globalRegistry, {\n description: 'Protocol for the RPC connection',\n type: 'string',\n }).default('postMessage'),\n networkId: z.string().register(globalRegistry, {\n description: 'Network ID to use for the postMessage RPC connection',\n type: 'string',\n }),\n sessionId: z.string().register(globalRegistry, {\n description: 'Session ID to use for the postMessage RPC connection',\n type: 'string',\n }),\n}).describe('Configuration for the remote RPC using postMessage')\n\n/** PostMessageRpcRemoteConfig type. */\nexport type PostMessageRpcRemoteConfig = z.infer<typeof PostMessageRpcRemoteConfigZod>\n\n/** RpcRemoteConfigZod constant. */\nexport const RpcRemoteConfigZod = z.union([HttpRpcRemoteConfigZod, PostMessageRpcRemoteConfigZod])\n .describe('Configuration for a remote RPC connection, either Http or postMessage')\n\n/** RpcRemoteConfig type. */\nexport type RpcRemoteConfig = z.infer<typeof RpcRemoteConfigZod>\n\n/** RemoteConfigZod constant. */\nexport const RemoteConfigZod = z.object({ rpc: RpcRemoteConfigZod.optional() }).describe('Configuration for remote connections, including RPC')\n\n/** RemoteConfig type. */\nexport type RemoteConfig = z.infer<typeof RemoteConfigZod>\n", "import { isDefined, isUndefined } from '@xylabs/sdk-js'\nimport { globalRegistry, z } from 'zod'\n\n/**\n * Checks if the provided MongoDB configuration contains the fields needed to\n * identify a Mongo target. `username` / `password` are intentionally not\n * required: `mongodb-memory-server` and many production deployments run\n * without auth (or carry credentials inline in the `connectionString` URI).\n * @param config MongoDB configuration object\n * @returns True iff `connectionString`, `database`, and `domain` are all set\n */\nexport const hasMongoConfig = (\n config?: MongoConfig,\n): config is MongoConfig & { connectionString: string; database: string; domain: string } => {\n if (isUndefined(config)) return false\n return (\n isDefined(config.connectionString)\n && isDefined(config.database)\n && isDefined(config.domain)\n )\n}\n\n/** MongoConfigZod constant. */\nexport const MongoConfigZod = z.object({\n // TODO: Create from other arguments\n connectionString: z.string().nonempty().optional().register(globalRegistry, {\n description: 'MongoDB connection string',\n title: 'storage.mongo.connectionString',\n type: 'string',\n }),\n database: z.string().nonempty().optional().register(globalRegistry, {\n description: 'MongoDB database name',\n title: 'storage.mongo.database',\n type: 'string',\n }),\n domain: z.string().nonempty().optional().register(globalRegistry, {\n description: 'MongoDB domain',\n title: 'storage.mongo.domain',\n type: 'string',\n }),\n password: z.string().nonempty().optional().register(globalRegistry, {\n description: 'MongoDB password',\n title: 'storage.mongo.password',\n type: 'string',\n }),\n username: z.string().nonempty().optional().register(globalRegistry, {\n description: 'MongoDB username',\n title: 'storage.mongo.username',\n type: 'string',\n }),\n})\n\n/** MongoConfig type. */\nexport type MongoConfig = z.infer<typeof MongoConfigZod>\n", "import { globalRegistry, z } from 'zod'\n\nimport { MongoConfigZod } from './driver/index.ts'\n\n/** StorageConfigZod constant. */\nexport const StorageConfigZod = z.object({\n mongo: MongoConfigZod.optional().describe('Configuration for the MongoD storage driver'),\n root: z.string().optional().register(globalRegistry, {\n description: 'Root directory for local storage',\n title: 'storage.root',\n type: 'string',\n }),\n}).describe('Storage configuration options')\n\n/** StorageConfig type. */\nexport type StorageConfig = z.infer<typeof StorageConfigZod>\n", "import { globalRegistry, z } from 'zod'\n\n/** DefaultMetricsScrapePorts constant. */\nexport const DefaultMetricsScrapePorts = {\n api: 9465,\n bridge: 9468,\n mempool: 9466,\n producer: 9464,\n rewardRedemptionApi: 9467,\n}\n\n/** MetricsScrapeConfigZod constant. */\nexport const MetricsScrapeConfigZod = z.object({\n path: z.string().default('/metrics').register(globalRegistry, {\n default: '/metrics',\n description: 'Path for the metrics scrape endpoint',\n title: 'telemetry.metrics.scrape.path',\n type: 'string',\n }),\n port: z.coerce.number().int().positive().optional().register(globalRegistry, {\n description: 'Port for the metrics scrape endpoint',\n title: 'telemetry.metrics.scrape.port',\n type: 'number',\n }),\n}).describe('Metrics scrape configuration')\n\n/** MetricsConfigZod constant. */\nexport const MetricsConfigZod = z.object({ scrape: MetricsScrapeConfigZod }).describe('Metrics configuration options')\n\n/** OpenTelemetryConfigZod constant. */\nexport const OpenTelemetryConfigZod = z.object({\n // OpenTelemetry options\n otlpEndpoint: z.url().optional().register(globalRegistry, {\n description: 'OTLP endpoint for exporting telemetry data',\n title: 'telemetry.otel.otlpEndpoint',\n type: 'string',\n }),\n})\n\n/** TelemetryConfigZod constant. */\nexport const TelemetryConfigZod = z.object({\n // Metrics configuration\n metrics: MetricsConfigZod.optional().describe('Metrics configuration'),\n // OpenTelemetry configuration\n otel: OpenTelemetryConfigZod.optional().describe('OpenTelemetry configuration'),\n}).describe('Telemetry configuration options')\n\n/** TelemetryConfig type. */\nexport type TelemetryConfig = z.infer<typeof TelemetryConfigZod>\n", "import { AddressZod } from '@xylabs/sdk-js'\nimport { globalRegistry, z } from 'zod'\n\nimport { DEFAULT_BACKOFF_MS, DEFAULT_MIN_CANDIDATES } from '../primitives/index.ts'\n\n/** ValidationConfigZod constant. */\nexport const ValidationConfigZod = z.object({\n allowedRewardRedeemers: z.array(AddressZod).optional().register(globalRegistry, {\n description: 'List of allowed reward redeemer addresses, if undefined anyone can participate',\n title: 'allowedRewardRedeemers',\n type: 'array',\n }),\n allowedRewardEscrowAccountSigners: z.array(AddressZod).optional().register(globalRegistry, {\n description: 'List of allowed reward escrow account signer addresses, if undefined anyone can participate',\n title: 'allowedRewardEscrowAccountSigners',\n type: 'array',\n }),\n minCandidates: z.coerce.number().default(DEFAULT_MIN_CANDIDATES).register(globalRegistry, {\n default: DEFAULT_MIN_CANDIDATES,\n description: 'Minimum number of uncle candidates before selecting the best uncle',\n title: 'validation.minCandidates',\n type: 'number',\n }),\n backoffMs: z.coerce.number().default(DEFAULT_BACKOFF_MS).register(globalRegistry, {\n default: DEFAULT_BACKOFF_MS,\n description: 'Back-off timeout in ms. If head age exceeds this, minCandidates is ignored',\n title: 'validation.backoffMs',\n type: 'number',\n }),\n})\n\n/** ValidationConfig type. */\nexport type ValidationConfig = z.infer<typeof ValidationConfigZod>\n", "import type { SignedHydratedBlockWithHashMeta } from '@xyo-network/xl1-protocol-lib'\n\nimport { scoreUncle } from './scoreUncle.ts'\n\n/** Default minimum number of uncle candidates before selecting. */\nexport const DEFAULT_MIN_CANDIDATES = 1\n\n/** Default back-off timeout in milliseconds. If the head has not changed for this long, minCandidates is ignored. */\nexport const DEFAULT_BACKOFF_MS = 120_000\n\n/** Options for findBestUncle block selection. */\nexport interface FindBestUncleOptions {\n /** Back-off timeout in ms. If head age exceeds this, minCandidates is ignored. Default: 120_000. */\n backoffMs?: number\n /** Minimum number of uncle candidates before selecting. Default: 1. */\n minCandidates?: number\n /** Current timestamp in ms. Injectable for testing. Default: Date.now(). */\n now?: number\n}\n\n/** Selects the best uncle chain from candidates using Proof of Perfect scoring. */\nexport function findBestUncle(\n finalizedWindowedChain: SignedHydratedBlockWithHashMeta[],\n uncles: SignedHydratedBlockWithHashMeta[][],\n options?: FindBestUncleOptions,\n): SignedHydratedBlockWithHashMeta[] | undefined {\n if (uncles.length === 0) return undefined\n\n const minCandidates = options?.minCandidates ?? DEFAULT_MIN_CANDIDATES\n const backoffMs = options?.backoffMs ?? DEFAULT_BACKOFF_MS\n const now = options?.now ?? Date.now()\n\n if (uncles.length < minCandidates) {\n const headEpoch = finalizedWindowedChain.at(-1)?.[0].$epoch ?? 0\n const headAge = now - headEpoch\n if (headAge < backoffMs) {\n return undefined\n }\n }\n\n const scores = uncles.map(uncle => ([scoreUncle(finalizedWindowedChain, uncle), uncle] as const)).toSorted((a, b) => b[0] - a[0])\n return scores[0]?.[1]\n}\n", "import z from 'zod'\n\nimport { ActorConfigZod } from './Actor.ts'\n\n/** ActorsConfigZod constant. */\nexport const ActorsConfigZod = z.array(ActorConfigZod.loose()).describe('Actor-specific configurations that override the base configuration when the actor is running').default([])\n\n/** ActorsConfig type. */\nexport type ActorsConfig = z.infer<typeof ActorsConfigZod>\n", "import { globalRegistry, z } from 'zod'\n\nimport { ActorConfigZod } from './Actor.ts'\nimport { ActorsConfigZod } from './Actors.ts'\nimport { BaseConfigZod } from './Base.ts'\nimport type { DeepPartial } from './DeepPartial.ts'\n\n/** ConfigZod constant. */\nexport const ConfigZod = BaseConfigZod.extend({\n actors: ActorsConfigZod,\n healthCheckPort: z.coerce.number().optional().register(globalRegistry, {\n description: 'Port for the system-wide health, readiness, and liveness endpoints (/healthz, /livez, /readyz). Set to 0 to disable.',\n title: 'healthCheckPort',\n type: 'number',\n }),\n}).describe('The complete configuration for the protocol, including global settings and actor-specific overrides')\n\n/** Config type. */\nexport type Config = z.infer<typeof ConfigZod>\n\n/** ResolveConfig helper function. */\nexport function resolveConfig(\n config: DeepPartial<Config>,\n) {\n const parsedConfig = ConfigZod.parse(config)\n const { actors, ...rootConfig } = parsedConfig\n parsedConfig.actors = actors.map((actorConfig) => {\n return ActorConfigZod.loose().parse({ ...rootConfig, ...actorConfig })\n })\n return parsedConfig\n}\n"],
5
+ "mappings": ";AAAA,SAAS,aAAAA,YAAW,cAAc;AAClC,SAAS,mBAAmB;;;ACD5B;AAAA,EACE,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,OACvB;AACP,SAAS,kBAAAC,kBAAgB,KAAAC,WAAS;;;ACHlC,SAAS,KAAAC,WAAS;;;ACAlB,SAAS,YAAY,cAAc;AACnC,SAAS,gBAAgB,SAAS;AAG3B,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,IAAI,OAAO,SAAS,EACjB,SAAS,gBAAgB;AAAA,IACxB,aACA;AAAA,IACA,OAAO;AAAA,IACP,MAAM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GAAqG;;;AnBPjH,IAAM,aAAa;AAKnB,IAAM,gBAAgB;AAMtB,eAAsB,cAAc,cAAyB;AAC3D,QAAM,WAAW;AAAA,IACf;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACA,QAAM,UAAmB,MAAM,SAAS,OAAO,IAAI;AACnD,MAAI,CAAC,OAAO,MAAM,GAAG;AACnB,UAAM,UAAW,OAAmC,aAAa;AACjE,QAAIC,WAAU,OAAO,KAAK,OAAO,YAAY,UAAU;AACrD,aAAO,UAAU,MAAM,EAAE,MAAM,OAAO;AAAA,IACxC;AAAA,EACF;AACA,SAAO,UAAU,MAAM,CAAC,CAAC;AAC3B;",
6
+ "names": ["isDefined", "zodAsFactory", "zodIsFactory", "zodToFactory", "globalRegistry", "z", "z", "z", "globalRegistry", "z", "globalRegistry", "z", "z", "globalRegistry", "globalRegistry", "z", "z", "globalRegistry", "z", "globalRegistry", "z", "globalRegistry", "z", "z", "z", "z", "globalRegistry", "z", "globalRegistry", "z", "z", "globalRegistry", "globalRegistry", "z", "z", "globalRegistry", "globalRegistry", "z", "z", "globalRegistry", "AddressZod", "globalRegistry", "z", "z", "AddressZod", "globalRegistry", "z", "z", "globalRegistry", "zodIsFactory", "zodAsFactory", "zodToFactory", "z", "z", "globalRegistry", "z", "z", "globalRegistry", "isDefined"]
7
+ }
@@ -4973,18 +4973,26 @@ import {
4973
4973
  isSignedHydratedBlockWithHashMeta,
4974
4974
  isSignedHydratedTransactionWithHashMeta,
4975
4975
  MempoolRunnerMoniker,
4976
+ MempoolViewerMoniker,
4976
4977
  TransactionRejectionSchema,
4977
4978
  TransactionValidationViewerMoniker
4978
4979
  } from "@xyo-network/xl1-protocol-lib";
4979
4980
  import { Mutex } from "async-mutex";
4980
4981
  var DEFAULT_SYNC_INTERVAL = 3e4;
4981
4982
  var DEFAULT_SYNC_LIMIT = 100;
4983
+ var ENFORCE_CAP_BATCH_SIZE = 1e3;
4984
+ function isDemotionAware(viewer) {
4985
+ if (!viewer) return false;
4986
+ const candidate = viewer;
4987
+ return typeof candidate.forget === "function" && typeof candidate.getEvictionPriorityOrder === "function";
4988
+ }
4982
4989
  var SimpleMempoolRunner = class extends AbstractCreatableProvider {
4983
4990
  moniker = SimpleMempoolRunner.defaultMoniker;
4984
4991
  _blockValidationViewer;
4985
4992
  _chainContractViewer;
4986
4993
  _deadLetterQueueRunner;
4987
4994
  _finalizationViewer;
4995
+ _mempoolViewer;
4988
4996
  _transactionValidationViewer;
4989
4997
  _syncMutex = new Mutex();
4990
4998
  _syncTimerId = null;
@@ -5003,6 +5011,9 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
5003
5011
  get maxExpAhead() {
5004
5012
  return this.params.maxExpAhead ?? DEFAULT_MAX_EXP_AHEAD;
5005
5013
  }
5014
+ get maxPendingTransactions() {
5015
+ return this.params.maxPendingTransactions ?? 0;
5016
+ }
5006
5017
  get pendingBlocksArchivist() {
5007
5018
  return this.params.pendingBlocksArchivist;
5008
5019
  }
@@ -5035,6 +5046,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
5035
5046
  this._finalizationViewer = await this.locator.getInstance(FinalizationViewerMoniker4);
5036
5047
  this._transactionValidationViewer = await this.locator.getInstance(TransactionValidationViewerMoniker);
5037
5048
  this._deadLetterQueueRunner = await this.locator.tryGetInstance(DeadLetterQueueRunnerMoniker);
5049
+ this._mempoolViewer = await this.locator.tryGetInstance(MempoolViewerMoniker);
5038
5050
  }
5039
5051
  async prunePendingBlocks({
5040
5052
  batchSize = 10,
@@ -5149,6 +5161,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
5149
5161
  pruned += pruneHashes.length;
5150
5162
  total += batch.length;
5151
5163
  await this.pendingTransactionsArchivist.delete(pruneHashes);
5164
+ this.forgetBundleHashes(pruneHashes);
5152
5165
  const pruneSet = new Set(pruneHashes);
5153
5166
  const lastSurvivor = batch.findLast((p) => !pruneSet.has(p._hash));
5154
5167
  cursor = lastSurvivor?._sequence ?? cursor;
@@ -5158,8 +5171,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
5158
5171
  order: "desc"
5159
5172
  });
5160
5173
  }
5161
- this.logger?.debug(`prunePendingTransactions completed: pruned=${pruned}, totalChecked=${total}`);
5162
- return [pruned, total];
5174
+ return this.finalizePruneTransactionsResult(pruned, total);
5163
5175
  }
5164
5176
  async submitBlocks(blocks) {
5165
5177
  const bundles = await Promise.all(blocks.map(async ([bw, payloads]) => {
@@ -5205,6 +5217,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
5205
5217
  }
5206
5218
  const bundles = hashedTransactions.map((tx) => hydratedTransactionToPayloadBundle(tx));
5207
5219
  const inserted = await this.pendingTransactionsArchivist.insert(bundles);
5220
+ await this.enforceCap();
5208
5221
  return inserted.map((p) => p._hash);
5209
5222
  }
5210
5223
  async startHandler() {
@@ -5223,6 +5236,50 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
5223
5236
  this._syncTimerId = null;
5224
5237
  }
5225
5238
  }
5239
+ async collectAllPendingTransactionBundles() {
5240
+ const all = [];
5241
+ let cursor;
5242
+ while (true) {
5243
+ const batch = await this.pendingTransactionsArchivist.next({
5244
+ limit: ENFORCE_CAP_BATCH_SIZE,
5245
+ cursor,
5246
+ order: "asc"
5247
+ });
5248
+ if (batch.length === 0) break;
5249
+ all.push(...batch);
5250
+ cursor = batch.at(-1)?._sequence;
5251
+ if (batch.length < ENFORCE_CAP_BATCH_SIZE) break;
5252
+ }
5253
+ return all;
5254
+ }
5255
+ async enforceCap() {
5256
+ const cap = this.maxPendingTransactions;
5257
+ if (cap <= 0) return;
5258
+ const all = await this.collectAllPendingTransactionBundles();
5259
+ if (all.length <= cap) return;
5260
+ const excess = all.length - cap;
5261
+ const bundleHashesOldestFirst = all.map((p) => p._hash);
5262
+ const orderedForEviction = this.orderForEviction(bundleHashesOldestFirst);
5263
+ const toEvict = orderedForEviction.slice(0, excess);
5264
+ await this.pendingTransactionsArchivist.delete(toEvict);
5265
+ this.forgetBundleHashes(toEvict);
5266
+ this.logger?.debug(`enforceCap evicted ${toEvict.length} bundles (pool=${all.length}, cap=${cap})`);
5267
+ }
5268
+ async finalizePruneTransactionsResult(pruned, total) {
5269
+ this.logger?.debug(`prunePendingTransactions completed: pruned=${pruned}, totalChecked=${total}`);
5270
+ await this.enforceCap();
5271
+ return [pruned, total];
5272
+ }
5273
+ forgetBundleHashes(bundleHashes) {
5274
+ if (bundleHashes.length === 0) return;
5275
+ if (isDemotionAware(this._mempoolViewer)) this._mempoolViewer.forget(bundleHashes);
5276
+ }
5277
+ orderForEviction(bundleHashesOldestFirst) {
5278
+ if (isDemotionAware(this._mempoolViewer)) {
5279
+ return this._mempoolViewer.getEvictionPriorityOrder(bundleHashesOldestFirst);
5280
+ }
5281
+ return bundleHashesOldestFirst;
5282
+ }
5226
5283
  async routeRejectedTransaction(transaction, errors) {
5227
5284
  if (!this._deadLetterQueueRunner) return;
5228
5285
  const rejectionErrors = errors.map((e) => ({
@@ -5335,13 +5392,22 @@ import {
5335
5392
  } from "@xylabs/sdk-js";
5336
5393
  import { isHashMeta as isHashMeta2, isPayloadBundle as isPayloadBundle2 } from "@xyo-network/sdk-js";
5337
5394
  import {
5338
- MempoolViewerMoniker,
5395
+ MempoolViewerMoniker as MempoolViewerMoniker2,
5339
5396
  WindowedBlockViewerMoniker
5340
5397
  } from "@xyo-network/xl1-protocol-lib";
5341
5398
  var DEFAULT_MEMPOOL_SELECTION_RATIO = 0.66;
5399
+ var DEFAULT_DEMOTION_THRESHOLD = 3;
5400
+ var DEFAULT_HANDOUT_STATS_TTL_BLOCKS = 1e3;
5342
5401
  var SimpleMempoolViewer = class extends AbstractCreatableProvider {
5343
5402
  moniker = SimpleMempoolViewer.defaultMoniker;
5403
+ _handoutStats = /* @__PURE__ */ new Map();
5344
5404
  _windowedBlockViewer;
5405
+ get demotionThreshold() {
5406
+ return this.params.demotionThreshold ?? DEFAULT_DEMOTION_THRESHOLD;
5407
+ }
5408
+ get handoutStatsTtlBlocks() {
5409
+ return this.params.handoutStatsTtlBlocks ?? DEFAULT_HANDOUT_STATS_TTL_BLOCKS;
5410
+ }
5345
5411
  get pendingBlocksArchivist() {
5346
5412
  return this.params.pendingBlocksArchivist;
5347
5413
  }
@@ -5355,6 +5421,32 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
5355
5421
  await super.createHandler();
5356
5422
  this._windowedBlockViewer = await this.locator.getInstance(WindowedBlockViewerMoniker);
5357
5423
  }
5424
+ /** Drop handout stats for the given bundle hashes. Called when a bundle has been evicted or otherwise removed from the pool. */
5425
+ forget(bundleHashes) {
5426
+ for (const hash of bundleHashes) this._handoutStats.delete(hash);
5427
+ }
5428
+ /** Return the subset of the given bundle hashes that are currently considered demoted. */
5429
+ getDemotedBundleHashes(bundleHashes) {
5430
+ return bundleHashes.filter((hash) => this.isDemoted(hash));
5431
+ }
5432
+ /**
5433
+ * Return the bundle hashes in the order they should be evicted under size pressure.
5434
+ * Demoted entries come first, sorted by handouts descending; the remainder is left as-is
5435
+ * so the caller can append by FIFO sequence order.
5436
+ */
5437
+ getEvictionPriorityOrder(bundleHashes) {
5438
+ const demoted = [];
5439
+ const nonDemoted = [];
5440
+ for (const hash of bundleHashes) {
5441
+ if (this.isDemoted(hash)) demoted.push(hash);
5442
+ else nonDemoted.push(hash);
5443
+ }
5444
+ demoted.sort((a, b) => (this._handoutStats.get(b)?.handouts ?? 0) - (this._handoutStats.get(a)?.handouts ?? 0));
5445
+ return [...demoted, ...nonDemoted];
5446
+ }
5447
+ getHandoutStats(bundleHash) {
5448
+ return this._handoutStats.get(bundleHash);
5449
+ }
5358
5450
  async pendingBlocks({ cursor: providedCursor } = {}) {
5359
5451
  let cursor = void 0;
5360
5452
  if (isHash2(providedCursor)) {
@@ -5397,6 +5489,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
5397
5489
  })
5398
5490
  )).filter(exists9);
5399
5491
  const currentBlock = await this.windowedBlockViewer.currentBlock();
5492
+ const currentBlockNumber = currentBlock[0].block;
5400
5493
  const evaluated = await Promise.all(
5401
5494
  hydratedWithBundle.map(async ({ bundle: bundle3, tx }) => ({
5402
5495
  bundle: bundle3,
@@ -5410,25 +5503,43 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
5410
5503
  await Promise.all(
5411
5504
  deletionCandidates.map(async ({ bundle: bundle3, tx }) => {
5412
5505
  await this.deleteBundledTransaction(bundle3);
5506
+ this._handoutStats.delete(bundle3._hash);
5413
5507
  this.logger?.debug(`Purged completed/expired bundled transaction: ${bundle3._hash}/${tx[0]._hash}`);
5414
5508
  })
5415
5509
  );
5416
- const inclusionCandidates = (await Promise.all(validTransactions.map((x) => x.tx).map(async (tx) => {
5417
- if (await this.isInclusionCandidate(tx, currentBlock, false)) return tx;
5510
+ this.gcHandoutStats(currentBlockNumber);
5511
+ const inclusionCandidates = (await Promise.all(validTransactions.map(async ({ bundle: bundle3, tx }) => {
5512
+ if (await this.isInclusionCandidate(tx, currentBlock, false)) return { bundle: bundle3, tx };
5418
5513
  }))).filter(exists9);
5419
5514
  const selectionRatio = this.params.mempoolSelectionRatio ?? DEFAULT_MEMPOOL_SELECTION_RATIO;
5420
- const maxByRatio = Math.ceil(inclusionCandidates.length * selectionRatio);
5421
- const effectiveLimit = Math.min(limit, maxByRatio);
5422
- const randomInclusionCandidates = deduplicateBySigner(
5423
- inclusionCandidates.filter(() => Math.random() < selectionRatio)
5424
- ).slice(0, effectiveLimit);
5425
- const result = randomInclusionCandidates.length > 0 ? randomInclusionCandidates : deduplicateBySigner(inclusionCandidates).slice(0, 1);
5426
- this.logger?.debug(`Inclusion candidates: ${inclusionCandidates.length}`);
5427
- return result;
5515
+ const nonDemoted = inclusionCandidates.filter(({ bundle: bundle3 }) => !this.isDemoted(bundle3._hash));
5516
+ const demoted = inclusionCandidates.filter(({ bundle: bundle3 }) => this.isDemoted(bundle3._hash));
5517
+ const primary = this.selectWithRatio(nonDemoted, limit, selectionRatio);
5518
+ const topupNeeded = limit - primary.length;
5519
+ const topup = topupNeeded > 0 ? this.selectWithRatio(demoted, topupNeeded, selectionRatio) : [];
5520
+ let combined = [...primary, ...topup];
5521
+ if (combined.length === 0 && inclusionCandidates.length > 0) {
5522
+ combined = deduplicateWithBundleBySigner(inclusionCandidates).slice(0, 1);
5523
+ }
5524
+ for (const { bundle: bundle3 } of combined) {
5525
+ this.recordHandout(bundle3._hash, currentBlockNumber);
5526
+ }
5527
+ this.logger?.debug(`Inclusion candidates: ${inclusionCandidates.length} (nonDemoted=${nonDemoted.length}, demoted=${demoted.length}); returning ${combined.length}`);
5528
+ return combined.map(({ tx }) => tx);
5529
+ }
5530
+ isDemoted(bundleHash) {
5531
+ const stats = this._handoutStats.get(bundleHash);
5532
+ return stats !== void 0 && stats.handouts >= this.demotionThreshold;
5428
5533
  }
5429
5534
  async deleteBundledTransaction(bundle3) {
5430
5535
  await this.pendingTransactionsArchivist.delete([bundle3._hash]);
5431
5536
  }
5537
+ gcHandoutStats(currentBlockNumber) {
5538
+ const ttl = this.handoutStatsTtlBlocks;
5539
+ for (const [hash, stats] of this._handoutStats) {
5540
+ if (currentBlockNumber - stats.firstHandoutAt > ttl) this._handoutStats.delete(hash);
5541
+ }
5542
+ }
5432
5543
  /**
5433
5544
  * Evaluates a transaction to determine if it should be purged from the mempool.
5434
5545
  * @param tx The transaction to evaluate
@@ -5461,16 +5572,31 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
5461
5572
  if (checkForDeletable && await this.isDeletable(tx, currentBlock)) return false;
5462
5573
  return true;
5463
5574
  }
5575
+ recordHandout(bundleHash, currentBlockNumber) {
5576
+ const existing = this._handoutStats.get(bundleHash);
5577
+ if (existing) {
5578
+ existing.handouts += 1;
5579
+ } else {
5580
+ this._handoutStats.set(bundleHash, { handouts: 1, firstHandoutAt: currentBlockNumber });
5581
+ }
5582
+ }
5583
+ selectWithRatio(group, take, selectionRatio) {
5584
+ if (take <= 0 || group.length === 0) return [];
5585
+ const maxByRatio = Math.ceil(group.length * selectionRatio);
5586
+ const effectiveLimit = Math.min(take, maxByRatio);
5587
+ const randomSelected = group.filter(() => Math.random() < selectionRatio);
5588
+ return deduplicateWithBundleBySigner(randomSelected).slice(0, effectiveLimit);
5589
+ }
5464
5590
  };
5465
- __publicField(SimpleMempoolViewer, "defaultMoniker", MempoolViewerMoniker);
5591
+ __publicField(SimpleMempoolViewer, "defaultMoniker", MempoolViewerMoniker2);
5466
5592
  __publicField(SimpleMempoolViewer, "dependencies", [WindowedBlockViewerMoniker]);
5467
- __publicField(SimpleMempoolViewer, "monikers", [MempoolViewerMoniker]);
5593
+ __publicField(SimpleMempoolViewer, "monikers", [MempoolViewerMoniker2]);
5468
5594
  SimpleMempoolViewer = __decorateClass([
5469
5595
  creatableProvider()
5470
5596
  ], SimpleMempoolViewer);
5471
- function deduplicateBySigner(txs) {
5597
+ function deduplicateWithBundleBySigner(items) {
5472
5598
  const seen = /* @__PURE__ */ new Set();
5473
- return txs.filter((tx) => {
5599
+ return items.filter(({ tx }) => {
5474
5600
  const key = tx[0].addresses.toSorted().join(",");
5475
5601
  if (seen.has(key)) return false;
5476
5602
  seen.add(key);
@@ -6925,4 +7051,4 @@ export {
6925
7051
  withContextCacheResponse,
6926
7052
  xl1BlockNumberToEthBlockNumber
6927
7053
  };
6928
- //# sourceMappingURL=index.mjs.map
7054
+ //# sourceMappingURL=index.mjs.map