@mysten-incubation/devstack 0.6.0 → 0.7.1

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 (65) hide show
  1. package/dist/build-integrations/vite/index.mjs +1 -0
  2. package/dist/build-integrations/vite/index.mjs.map +1 -1
  3. package/dist/cli/wirings/apply.mjs +24 -6
  4. package/dist/cli/wirings/apply.mjs.map +1 -1
  5. package/dist/cli/wirings/dump-deployment.mjs +2 -1
  6. package/dist/cli/wirings/dump-deployment.mjs.map +1 -1
  7. package/dist/cli/wirings/identity.mjs +2 -1
  8. package/dist/cli/wirings/identity.mjs.map +1 -1
  9. package/dist/cli/wirings/snapshot.mjs +2 -1
  10. package/dist/cli/wirings/snapshot.mjs.map +1 -1
  11. package/dist/cli/wirings/up.mjs +25 -29
  12. package/dist/cli/wirings/up.mjs.map +1 -1
  13. package/dist/plugins/package/codegen.mjs +4 -4
  14. package/dist/plugins/package/codegen.mjs.map +1 -1
  15. package/dist/plugins/package/dep-resolution.mjs +19 -9
  16. package/dist/plugins/package/dep-resolution.mjs.map +1 -1
  17. package/dist/plugins/package/index.d.mts +3 -3
  18. package/dist/plugins/package/index.mjs +9 -5
  19. package/dist/plugins/package/index.mjs.map +1 -1
  20. package/dist/plugins/package/mode-known.mjs +2 -2
  21. package/dist/plugins/package/mode-known.mjs.map +1 -1
  22. package/dist/plugins/package/mode-local.mjs +4 -4
  23. package/dist/plugins/package/mode-local.mjs.map +1 -1
  24. package/dist/plugins/sui/chain-build-container.mjs.map +1 -1
  25. package/dist/plugins/sui/index.d.mts +10 -10
  26. package/dist/plugins/sui/index.mjs.map +1 -1
  27. package/dist/plugins/sui/move/index.mjs +10 -6
  28. package/dist/plugins/sui/move/index.mjs.map +1 -1
  29. package/dist/plugins/wallet/codegen.d.mts +14 -10
  30. package/dist/plugins/wallet/codegen.mjs.map +1 -1
  31. package/dist/plugins/wallet/origin-policy.mjs +43 -3
  32. package/dist/plugins/wallet/origin-policy.mjs.map +1 -1
  33. package/dist/plugins/wallet/service.mjs +9 -7
  34. package/dist/plugins/wallet/service.mjs.map +1 -1
  35. package/dist/plugins/walrus/client-services.mjs +13 -5
  36. package/dist/plugins/walrus/client-services.mjs.map +1 -1
  37. package/dist/plugins/walrus/codegen.d.mts +1 -0
  38. package/dist/plugins/walrus/codegen.mjs +1 -0
  39. package/dist/plugins/walrus/codegen.mjs.map +1 -1
  40. package/dist/plugins/walrus/errors.d.mts +1 -1
  41. package/dist/plugins/walrus/errors.mjs.map +1 -1
  42. package/dist/plugins/walrus/index.d.mts +10 -0
  43. package/dist/plugins/walrus/index.mjs +14 -3
  44. package/dist/plugins/walrus/index.mjs.map +1 -1
  45. package/dist/plugins/walrus/mode/known-deploy.d.mts +1 -0
  46. package/dist/plugins/walrus/mode/known-deploy.mjs +6 -2
  47. package/dist/plugins/walrus/mode/known-deploy.mjs.map +1 -1
  48. package/dist/plugins/walrus/mode/local-cluster.d.mts +6 -2
  49. package/dist/plugins/walrus/mode/local-cluster.mjs +10 -7
  50. package/dist/plugins/walrus/mode/local-cluster.mjs.map +1 -1
  51. package/dist/plugins/walrus/routable.mjs +27 -31
  52. package/dist/plugins/walrus/routable.mjs.map +1 -1
  53. package/dist/plugins/walrus/snapshot.mjs.map +1 -1
  54. package/dist/substrate/cross-process.mjs +2 -1
  55. package/dist/substrate/cross-process.mjs.map +1 -1
  56. package/dist/substrate/runtime/cross-process/roster.mjs +5 -2
  57. package/dist/substrate/runtime/cross-process/roster.mjs.map +1 -1
  58. package/dist/surfaces/cli/commands/supervisor-presence.mjs +4 -2
  59. package/dist/surfaces/cli/commands/supervisor-presence.mjs.map +1 -1
  60. package/dist/surfaces/cli/errors.mjs +12 -2
  61. package/dist/surfaces/cli/errors.mjs.map +1 -1
  62. package/dist/surfaces/cli/index.mjs.map +1 -1
  63. package/images/walrus/Dockerfile +11 -7
  64. package/images/walrus/run-walrus-client-service.sh +41 -9
  65. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugins/walrus/index.ts"],"sourcesContent":["// Walrus plugin — barrel + factories.\n//\n// Architecture: Walrus is a service plugin that owns a local cluster\n// or describes a known deployment. The factory at this file folds the\n// four modes behind:\n//\n// - `walrus(opts?)` — local-cluster shorthand. No env\n// defaulting; use `walrusFor(...)`\n// for known deployments.\n// - `walrusFor(network)` — mode-narrowed factory namespace\n// (architecture Tension 11). Returns\n// `{ local: …, known: … }` narrowed\n// to the network's mode. Crucially,\n// the fork branch exposes ONLY\n// `.known` — `.local` is a compile\n// error on a fork-mode network.\n//\n// During `start`, the plugin emits (via the typed `ctx.*` verbs, per mode):\n//\n// Local mode (full local cluster):\n// 1. `ctx.snapshotExtra` — runtime/walrus/<name>/deploy/ subtree\n// + storage-node managed containers.\n// 2. `ctx.codegen` — `walrus-network` bindings.\n// 3. `ctx.endpoint` × (N+2) — per-node + aggregator + publisher.\n// 4. `ctx.provides` walrus-state-registry — local entry.\n// 5. `ctx.provides` endpoint-registry — N+2 entries.\n// 6. `ctx.provides` package-registry — `walrus.<name>`.\n// 7. `ctx.provides` coinType:<WAL fullCoinType> — WAL faucet\n// strategy\n// (when exchange exists).\n//\n// Known mode (read-only deployment):\n// 1. `ctx.snapshotExtra` — identity-guard only; no subtrees.\n// 2. `ctx.codegen` — `walrus-network` bindings (mode='known').\n// 3. `ctx.provides` walrus-state-registry — known entry.\n//\n// Resource id: `'walrus'` (singular). The plugin's substrate-level\n// plugin key is the same string.\n\nimport { Effect, Path } from 'effect';\n\nimport { defineModeNamespace } from '../../api/mode-narrowed-factory.ts';\nimport { definePlugin, resource, type ResourceRef } from '../../api/define-plugin.ts';\nimport type { ContainerRuntime } from '../../contracts/container-runtime.ts';\nimport type { RoutableDecl } from '../../contracts/routable.ts';\nimport type { StrategyContributorDecl } from '../../contracts/strategy-contributor.ts';\nimport { emitContributions, PluginContext } from '../../substrate/plugin-ctx.ts';\nimport { ContainerRuntimeService } from '../../runtime/docker/service.ts';\nimport { IdentityContext, StackPathsService } from '../../substrate/runtime/paths.ts';\nimport { CacheService } from '../../substrate/runtime/cache/index.ts';\nimport { deriveSubnetPrefix, withSubnetAddressing } from '../../substrate/runtime/subnet-broker.ts';\nimport { renderUrl, routedHostname } from '../../substrate/runtime/routed-url.ts';\nimport type { AccountFundingCoinValue } from '../account/index.ts';\nimport { coinResourceId, type CoinResourceId } from '../coin/index.ts';\nimport { suiResource, type SuiProbeKey } from '../sui/index.ts';\n\nimport { chainProbeFor } from '../../substrate/runtime/strategy-registry/index.ts';\n\nimport { makeCodegenable, makeWalrusStaticCodegen } from './codegen.ts';\nimport { LOCAL_NETWORK_NAME } from '../../api/inference-network.ts';\nimport { walrusPluginKey } from './plugin-key.ts';\nimport { walrusPluginError, type WalrusPluginError } from './errors.ts';\nimport { makeWalFaucetContribution, type WalFaucetStrategy } from './faucet-strategy.ts';\nimport { bootWalrusService, type WalrusMode } from './service.ts';\nimport {\n\tresolveLocalClusterOptions,\n\ttype WalrusLocalClusterOptions,\n} from './mode/local-cluster.ts';\nimport {\n\tresolveKnownDeploymentOptions,\n\ttype WalrusKnownDeploymentOptions,\n} from './mode/known-deploy.ts';\nimport { makeSnapshotable, type WalrusSnapshotMode } from './snapshot.ts';\nimport {\n\tWALRUS_AGGREGATOR_ENDPOINT_NAME,\n\tWALRUS_PUBLISHER_ENDPOINT_NAME,\n\tmakeLocalRoutables,\n} from './routable.ts';\nimport { WALRUS_STATE_REGISTRY_KEY, type WalrusStateEntry } from './registry-publish.ts';\nimport {\n\tWALRUS_ROUTER_PORT,\n\tbuildWalrusNetworkName,\n\ttype WalrusStorageNode,\n} from './storage-nodes.ts';\n\n// ---------------------------------------------------------------------------\n// Resource — the resolved value all consumers read\n// ---------------------------------------------------------------------------\n\n/** The Walrus resolved value carried by the resource. */\nexport interface WalrusResolved {\n\treadonly mode: 'local' | 'known';\n\t/** Network name the walrus deployment targets (`localnet`/`testnet`/…). */\n\treadonly network: string;\n\treadonly walrusPackageId: string | null;\n\treadonly walPackageId: string | null;\n\t/** SDK-ready `packageConfig` — structurally compatible with\n\t * `@mysten/walrus`'s `WalrusPackageConfig`. */\n\treadonly packageConfig: {\n\t\treadonly systemObjectId: string;\n\t\treadonly stakingPoolId: string;\n\t\treadonly exchangeIds?: ReadonlyArray<string>;\n\t};\n\treadonly nodes: ReadonlyArray<WalrusStorageNode>;\n\treadonly proxyUrl: string | null;\n\treadonly aggregatorUrl: string | null;\n\treadonly publisherUrl: string | null;\n\treadonly walFaucetStrategy: WalFaucetStrategy | null;\n\treadonly walCoinType: string | null;\n}\n\n/** Walrus plugin resource. */\nexport const walrusResource = resource<'walrus', WalrusResolved>('walrus');\n\nexport interface WalrusNetworkIdentity {\n\treadonly app: string;\n\treadonly stack: string;\n\treadonly walrusName: string;\n}\n\n/** Walrus deploy records storage-node listening IPs under this /24.\n * Docker network create requests the matching subnet explicitly, with\n * the prefix derived from the Walrus network identity so parallel\n * stacks don't all claim the same Docker IPAM range. Walrus claims\n * the `10.64.*` – `10.127.*` band; see substrate/runtime/subnet-broker.ts\n * for the algorithm and band coordination with seal. */\nexport const deriveWalrusSubnetPrefix = (identity: WalrusNetworkIdentity): string =>\n\tderiveSubnetPrefix(`${identity.app}\\0${identity.stack}\\0${identity.walrusName}`, 64);\n\nconst withWalrusNetworkAddressing = (\n\truntime: ContainerRuntime,\n\twalrusNetworkName: string,\n\tsubnetPrefix: string,\n): ContainerRuntime => ({\n\t...runtime,\n\tensureNetwork: (spec) =>\n\t\truntime.ensureNetwork(\n\t\t\tspec.name === walrusNetworkName ? withSubnetAddressing(spec, subnetPrefix) : spec,\n\t\t),\n});\n\n// ---------------------------------------------------------------------------\n// Plugin construction (internal — used by walrus() + walrusFor())\n// ---------------------------------------------------------------------------\n\nconst buildLocalPlugin = (opts: WalrusLocalClusterOptions) => {\n\t// Synchronous factory-time validation (distilled-doc invariants\n\t// 11 — `nodeCount >= 1` + `shards >= nodeCount`).\n\tconst resolved = resolveLocalClusterOptions(opts);\n\n\tconst walrusKey = walrusPluginKey(resolved.name);\n\n\treturn definePlugin({\n\t\tid: walrusResource.id,\n\t\tdependsOn: [suiResource] as const,\n\t\trole: 'service',\n\t\tsection: 'service',\n\t\tpluginKey: walrusKey,\n\t\t// Stack-free codegen: a local walrus cluster's deploy ids / endpoint\n\t\t// URLs are LOADED CONFIG DATA -- the committed `walrus.ts` stub emits\n\t\t// `requireValue(dep, 'walrus', '<key>')`, never a baked object id / URL.\n\t\tstaticCodegen: () => [makeWalrusStaticCodegen({ mode: 'local', network: LOCAL_NETWORK_NAME })],\n\t\t// `deps` auto-infers the resolved `[sui]` tuple from the\n\t\t// `[suiResource] as const` dependency. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: (deps) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst [sui] = deps;\n\n\t\t\t\t// Substrate-context primitives:\n\t\t\t\t// - `ContainerRuntimeService` + `IdentityContext` arrive\n\t\t\t\t// via the supervisor's plugin runtime context.\n\t\t\t\t// - `ArtifactPublisher` is the substrate-level\n\t\t\t\t// publisher (cache → verify → produce → register cycle).\n\t\t\t\t// - `ChainProbe<SuiProbeKey>` is looked up via the\n\t\t\t\t// StrategyRegistry under `chain-probe:<chainId>`;\n\t\t\t\t// Sui registered itself there at its own acquire.\n\t\t\t\t// - `StackPathsService` resolves the per-stack on-disk\n\t\t\t\t// root so the deploy-output bind-mount source is a\n\t\t\t\t// real path (not the `<runtime>/...` template).\n\t\t\t\tconst runtime = yield* ContainerRuntimeService;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst stackPaths = yield* StackPathsService;\n\t\t\t\tconst path = yield* Path.Path;\n\t\t\t\tconst publisher = yield* CacheService;\n\t\t\t\tconst probe = yield* chainProbeFor<SuiProbeKey>(sui.chainId);\n\n\t\t\t\t// Resolve the deploy-output bind-mount source from the\n\t\t\t\t// per-stack paths bundle. The deploy one-shot owns preparing\n\t\t\t\t// the directory immediately before its Docker bind mount.\n\t\t\t\tconst deployHostMountPath = path.join(\n\t\t\t\t\tstackPaths.stackRoot,\n\t\t\t\t\t'walrus',\n\t\t\t\t\tresolved.name,\n\t\t\t\t\t'deploy',\n\t\t\t\t);\n\n\t\t\t\t// Cross-container DNS: walrus containers (deploy one-shot\n\t\t\t\t// + N storage nodes) dial sui RPC + faucet via\n\t\t\t\t// `host.docker.internal`. The sui plugin binds brokered\n\t\t\t\t// host ports — no shared docker network needed.\n\t\t\t\t//\n\t\t\t\t// Architectural decision (B5): walrus owns its OWN docker\n\t\t\t\t// network for storage-node ↔ deploy connectivity; sui-side\n\t\t\t\t// hops go through the host gateway.\n\t\t\t\t// On Linux this requires Docker Desktop or the\n\t\t\t\t// `host.docker.internal:host-gateway` runtime hint (the\n\t\t\t\t// established devstack convention — see plugins/deepbook\n\t\t\t\t// which uses the same pattern).\n\t\t\t\tconst walrusNetworkName = buildWalrusNetworkName(\n\t\t\t\t\tidentity.app,\n\t\t\t\t\tidentity.stack,\n\t\t\t\t\tresolved.name,\n\t\t\t\t);\n\t\t\t\tconst walrusSubnetPrefix = deriveWalrusSubnetPrefix({\n\t\t\t\t\tapp: identity.app,\n\t\t\t\t\tstack: identity.stack,\n\t\t\t\t\twalrusName: resolved.name,\n\t\t\t\t});\n\t\t\t\tconst walrusRuntime = withWalrusNetworkAddressing(\n\t\t\t\t\truntime,\n\t\t\t\t\twalrusNetworkName,\n\t\t\t\t\twalrusSubnetPrefix,\n\t\t\t\t);\n\t\t\t\tconst suiRpcUrlInNetwork = sui.hostGateway.rpcUrl;\n\t\t\t\t// sui-faucet v2 endpoint — `/v2/gas` is the supported path\n\t\t\t\t// on devnet-v1.71.0+.\n\t\t\t\tconst suiFaucetUrlInNetwork = sui.hostGateway.faucetUrl;\n\t\t\t\tif (suiFaucetUrlInNetwork === null) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\twalrusPluginError(\n\t\t\t\t\t\t\t'deploy',\n\t\t\t\t\t\t\t'walrus local-cluster requires a Sui faucet URL for deploy funding.',\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst walrusFaucetUrlInNetwork = `${suiFaucetUrlInNetwork}/v2/gas`;\n\n\t\t\t\tconst mode: WalrusMode = { mode: 'local', opts: resolved };\n\t\t\t\tconst boot = yield* bootWalrusService(\n\t\t\t\t\t{\n\t\t\t\t\t\truntime: walrusRuntime,\n\t\t\t\t\t\tpublisher,\n\t\t\t\t\t\tprobe,\n\t\t\t\t\t\tsuiSdk: sui.sdk,\n\t\t\t\t\t\tsuiChainId: sui.chainId,\n\t\t\t\t\t\tsuiRpcUrlInNetwork,\n\t\t\t\t\t\twalrusFaucetUrlInNetwork,\n\t\t\t\t\t\twaitForFundsReady: sui.waitForTransactionsReady.wait,\n\t\t\t\t\t\tapp: identity.app,\n\t\t\t\t\t\tstack: identity.stack,\n\t\t\t\t\t\tsubnetPrefix: walrusSubnetPrefix,\n\t\t\t\t\t\twalrusNetworkName,\n\t\t\t\t\t\t// Walrus has no `sui-net` to attach to (sui binds\n\t\t\t\t\t\t// host ports). Reuse the walrus network so the\n\t\t\t\t\t\t// deploy one-shot + storage nodes land on a single\n\t\t\t\t\t\t// network and reach sui via `host.docker.internal`.\n\t\t\t\t\t\tsuiNetworkName: walrusNetworkName,\n\t\t\t\t\t\tdeployHostMountPath,\n\t\t\t\t\t\tstackRoot: stackPaths.stackRoot,\n\t\t\t\t\t},\n\t\t\t\t\tmode,\n\t\t\t\t);\n\n\t\t\t\tif (boot.mode !== 'local') {\n\t\t\t\t\t// Should be unreachable — dispatch is by mode. Defense.\n\t\t\t\t\treturn yield* Effect.die('walrus: mode mismatch in local plugin');\n\t\t\t\t}\n\n\t\t\t\tconst packageConfig: WalrusResolved['packageConfig'] =\n\t\t\t\t\tboot.exchangeObjectId === undefined\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsystemObjectId: boot.deploy.systemObject,\n\t\t\t\t\t\t\t\tstakingPoolId: boot.deploy.stakingObject,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tsystemObjectId: boot.deploy.systemObject,\n\t\t\t\t\t\t\t\tstakingPoolId: boot.deploy.stakingObject,\n\t\t\t\t\t\t\t\texchangeIds: [boot.exchangeObjectId],\n\t\t\t\t\t\t\t};\n\t\t\t\tconst serviceUrl = (role: string) =>\n\t\t\t\t\troutedHostname(identity, role).pipe(\n\t\t\t\t\t\tEffect.map((hostname) =>\n\t\t\t\t\t\t\trenderUrl({\n\t\t\t\t\t\t\t\tprotocol: 'http',\n\t\t\t\t\t\t\t\thostname,\n\t\t\t\t\t\t\t\tport: WALRUS_ROUTER_PORT,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tEffect.mapError((cause) =>\n\t\t\t\t\t\t\twalrusPluginError(\n\t\t\t\t\t\t\t\t'proxy',\n\t\t\t\t\t\t\t\t`walrus route URL assembly failed for ${role}: ${cause.detail}`,\n\t\t\t\t\t\t\t\t{ cause },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\tconst aggregatorUrl =\n\t\t\t\t\tboot.clientServices.aggregator === null\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: yield* serviceUrl(WALRUS_AGGREGATOR_ENDPOINT_NAME);\n\t\t\t\tconst publisherUrl =\n\t\t\t\t\tboot.clientServices.publisher === null\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: yield* serviceUrl(WALRUS_PUBLISHER_ENDPOINT_NAME);\n\n\t\t\t\tconst resolvedValue: WalrusResolved = {\n\t\t\t\t\tmode: 'local',\n\t\t\t\t\tnetwork: identity.network,\n\t\t\t\t\twalrusPackageId: boot.walrusPackageId,\n\t\t\t\t\twalPackageId: boot.walPackageId,\n\t\t\t\t\tpackageConfig,\n\t\t\t\t\tnodes: boot.nodes,\n\t\t\t\t\tproxyUrl: aggregatorUrl,\n\t\t\t\t\taggregatorUrl,\n\t\t\t\t\tpublisherUrl,\n\t\t\t\t\twalFaucetStrategy: boot.walFaucetStrategy,\n\t\t\t\t\twalCoinType: boot.walCoinType,\n\t\t\t\t};\n\t\t\t\t// Emit the resolved contributions inline: snapshot → codegen →\n\t\t\t\t// state-registry → (optional WAL faucet) → routables. `identity`\n\t\t\t\t// (from `IdentityContext`) stamps the snapshot + routable\n\t\t\t\t// container names. ID-stability surfaces (deploy/blob ids via\n\t\t\t\t// ArtifactPublisher) live OUTSIDE this emission and are untouched.\n\t\t\t\tconst walFaucetContribution: ReadonlyArray<StrategyContributorDecl> =\n\t\t\t\t\tresolvedValue.walFaucetStrategy === null || resolvedValue.walCoinType === null\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tmakeWalFaucetContribution(\n\t\t\t\t\t\t\t\t\tresolvedValue.walFaucetStrategy,\n\t\t\t\t\t\t\t\t\tresolvedValue.walCoinType,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t];\n\t\t\t\tconst clientServiceRoles = [\n\t\t\t\t\t...(boot.clientServices.aggregator === null ? [] : ['aggregator' as const]),\n\t\t\t\t\t...(boot.clientServices.publisher === null ? [] : ['publisher' as const]),\n\t\t\t\t];\n\t\t\t\temitContributions(ctx, [\n\t\t\t\t\tmakeSnapshotable(\n\t\t\t\t\t\t'local' satisfies WalrusSnapshotMode,\n\t\t\t\t\t\tidentity.app,\n\t\t\t\t\t\tidentity.stack,\n\t\t\t\t\t\tresolved.name,\n\t\t\t\t\t\tresolvedValue.network,\n\t\t\t\t\t\tresolved.nodeCount,\n\t\t\t\t\t\tclientServiceRoles,\n\t\t\t\t\t),\n\t\t\t\t\tmakeCodegenable({\n\t\t\t\t\t\tmode: 'local',\n\t\t\t\t\t\tnetwork: resolvedValue.network,\n\t\t\t\t\t\twalrusPackageId: resolvedValue.walrusPackageId,\n\t\t\t\t\t\twalPackageId: resolvedValue.walPackageId,\n\t\t\t\t\t\twalCoinType: resolvedValue.walCoinType,\n\t\t\t\t\t\tsystemObjectId: resolvedValue.packageConfig.systemObjectId,\n\t\t\t\t\t\tstakingPoolId: resolvedValue.packageConfig.stakingPoolId,\n\t\t\t\t\t\texchangeIds: resolvedValue.packageConfig.exchangeIds\n\t\t\t\t\t\t\t? [...resolvedValue.packageConfig.exchangeIds]\n\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\tproxyUrl: resolvedValue.proxyUrl,\n\t\t\t\t\t\taggregatorUrl: resolvedValue.aggregatorUrl,\n\t\t\t\t\t\tpublisherUrl: resolvedValue.publisherUrl,\n\t\t\t\t\t\tnodes: resolvedValue.nodes,\n\t\t\t\t\t}),\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: 'strategy-contributor',\n\t\t\t\t\t\tcapabilityKey: WALRUS_STATE_REGISTRY_KEY,\n\t\t\t\t\t\tstrategy: { noteName: resolved.name },\n\t\t\t\t\t\tautoMounted: true,\n\t\t\t\t\t} satisfies StrategyContributorDecl<\n\t\t\t\t\t\ttypeof WALRUS_STATE_REGISTRY_KEY,\n\t\t\t\t\t\t{ readonly noteName: string }\n\t\t\t\t\t>,\n\t\t\t\t\t...walFaucetContribution,\n\t\t\t\t\t...(makeLocalRoutables({\n\t\t\t\t\t\tapp: identity.app,\n\t\t\t\t\t\tstack: identity.stack,\n\t\t\t\t\t\twalrusName: resolved.name,\n\t\t\t\t\t\tserviceKey: String(walrusKey),\n\t\t\t\t\t\tnodeCount: resolved.nodeCount,\n\t\t\t\t\t\tcontainerApiPort: resolved.containerApiPort,\n\t\t\t\t\t\taggregator: boot.clientServices.aggregator,\n\t\t\t\t\t\tpublisher: boot.clientServices.publisher,\n\t\t\t\t\t}) as readonly RoutableDecl[]),\n\t\t\t\t]);\n\t\t\t\treturn resolvedValue;\n\t\t\t}),\n\t});\n};\n\nconst buildKnownPlugin = (opts: WalrusKnownDeploymentOptions) => {\n\t// Synchronous factory-time validation for required deployment ids.\n\tconst resolved = resolveKnownDeploymentOptions(opts);\n\n\treturn definePlugin({\n\t\tid: walrusResource.id,\n\t\tdependsOn: [suiResource] as const,\n\t\t// Known deployment is a pure value-producer — no containers,\n\t\t// no long-running children.\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\t// Stack-free codegen: a known deployment's ids / URLs are DECLARED\n\t\t// config (not loaded-at-runtime data) — bake them as literals in the\n\t\t// committed `walrus.ts` (mirrors `knownPackage`). `walrusPackageId` /\n\t\t// `walPackageId` / `walCoinType` are null for a known deployment.\n\t\tstaticCodegen: () => [\n\t\t\tmakeWalrusStaticCodegen({\n\t\t\t\tmode: 'known',\n\t\t\t\tnetwork: resolved.network,\n\t\t\t\tknown: {\n\t\t\t\t\twalrusPackageId: null,\n\t\t\t\t\twalPackageId: null,\n\t\t\t\t\twalCoinType: null,\n\t\t\t\t\tpackageConfig: {\n\t\t\t\t\t\tsystemObjectId: resolved.systemObjectId,\n\t\t\t\t\t\tstakingPoolId: resolved.stakingPoolId,\n\t\t\t\t\t\t...(resolved.exchangeIds.length > 0 ? { exchangeIds: [...resolved.exchangeIds] } : {}),\n\t\t\t\t\t},\n\t\t\t\t\tproxyUrl: resolved.proxyUrl,\n\t\t\t\t\taggregatorUrl: resolved.aggregatorUrl,\n\t\t\t\t\tpublisherUrl: resolved.publisherUrl,\n\t\t\t\t\tnodes: resolved.nodes,\n\t\t\t\t},\n\t\t\t}),\n\t\t],\n\t\t// Known mode is a pure value-producer — `sui` is unused (the value\n\t\t// reads `resolved.network` from the deployment options) but the\n\t\t// `dependsOn` edge still orders boot, so `start` is zero-arg.\n\t\t// `ctx` arrives via the `PluginContext` service.\n\t\tstart: () =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst resolvedValue = {\n\t\t\t\t\tmode: 'known',\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\twalrusPackageId: null,\n\t\t\t\t\twalPackageId: null,\n\t\t\t\t\tpackageConfig: {\n\t\t\t\t\t\tsystemObjectId: resolved.systemObjectId,\n\t\t\t\t\t\tstakingPoolId: resolved.stakingPoolId,\n\t\t\t\t\t\texchangeIds: resolved.exchangeIds.length > 0 ? resolved.exchangeIds : undefined,\n\t\t\t\t\t},\n\t\t\t\t\tnodes: resolved.nodes,\n\t\t\t\t\tproxyUrl: resolved.proxyUrl,\n\t\t\t\t\taggregatorUrl: resolved.aggregatorUrl,\n\t\t\t\t\tpublisherUrl: resolved.publisherUrl,\n\t\t\t\t\twalFaucetStrategy: null,\n\t\t\t\t\twalCoinType: null,\n\t\t\t\t} satisfies WalrusResolved;\n\t\t\t\t// Emit inline: snapshot → codegen → state-registry. Known mode\n\t\t\t\t// emits no routable. `identity` (from `IdentityContext`) stamps\n\t\t\t\t// the snapshot scoping.\n\t\t\t\tctx.snapshotExtra(\n\t\t\t\t\tmakeSnapshotable(\n\t\t\t\t\t\t'known' satisfies WalrusSnapshotMode,\n\t\t\t\t\t\tidentity.app,\n\t\t\t\t\t\tidentity.stack,\n\t\t\t\t\t\t'walrusKnownDeployment',\n\t\t\t\t\t\tresolvedValue.network,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tctx.codegen(\n\t\t\t\t\tmakeCodegenable({\n\t\t\t\t\t\tmode: 'known',\n\t\t\t\t\t\tnetwork: resolvedValue.network,\n\t\t\t\t\t\twalrusPackageId: resolvedValue.walrusPackageId,\n\t\t\t\t\t\twalPackageId: resolvedValue.walPackageId,\n\t\t\t\t\t\twalCoinType: resolvedValue.walCoinType,\n\t\t\t\t\t\tsystemObjectId: resolvedValue.packageConfig.systemObjectId,\n\t\t\t\t\t\tstakingPoolId: resolvedValue.packageConfig.stakingPoolId,\n\t\t\t\t\t\texchangeIds: resolvedValue.packageConfig.exchangeIds\n\t\t\t\t\t\t\t? [...resolvedValue.packageConfig.exchangeIds]\n\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\tproxyUrl: resolvedValue.proxyUrl,\n\t\t\t\t\t\taggregatorUrl: resolvedValue.aggregatorUrl,\n\t\t\t\t\t\tpublisherUrl: resolvedValue.publisherUrl,\n\t\t\t\t\t\tnodes: resolvedValue.nodes,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tctx.provides({\n\t\t\t\t\tkind: 'strategy-contributor',\n\t\t\t\t\tcapabilityKey: WALRUS_STATE_REGISTRY_KEY,\n\t\t\t\t\tstrategy: {\n\t\t\t\t\t\tname: 'walrusKnownDeployment',\n\t\t\t\t\t\tsystemObjectId: resolvedValue.packageConfig.systemObjectId,\n\t\t\t\t\t\tstakingObjectId: resolvedValue.packageConfig.stakingPoolId,\n\t\t\t\t\t\tnetwork: resolvedValue.network,\n\t\t\t\t\t},\n\t\t\t\t\tautoMounted: true,\n\t\t\t\t} satisfies StrategyContributorDecl<typeof WALRUS_STATE_REGISTRY_KEY, WalrusStateEntry>);\n\t\t\t\treturn resolvedValue;\n\t\t\t}),\n\t});\n};\n\nexport interface WalCoinValue extends AccountFundingCoinValue {\n\treadonly symbol: 'WAL';\n\treadonly fullCoinType: `${string}::wal::WAL`;\n\treadonly decimals: 9;\n\treadonly source: 'walrus';\n}\n\n/** Resolve the local Walrus deployment's WAL coin as an account-funding\n * coin ref. Accounts that need WAL should use:\n *\n * funding: [{ coin: walCoin(localWalrus), amount }]\n *\n * The funding strategy itself is contributed by the Walrus service\n * once its local exchange exists. */\nexport const walCoin = (walrusMember: ResourceRef<'walrus', WalrusResolved>) => {\n\tconst coinRef = resource<CoinResourceId<'wal'>, WalCoinValue>(coinResourceId('wal'));\n\n\treturn definePlugin({\n\t\tid: coinRef.id,\n\t\tdependsOn: walrusMember,\n\t\trole: 'task',\n\t\tsection: 'action',\n\t\tstart: (resolved): Effect.Effect<WalCoinValue, WalrusPluginError> =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tif (resolved.walCoinType === null) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\twalrusPluginError(\n\t\t\t\t\t\t\t'exchange',\n\t\t\t\t\t\t\t'walCoin(...) requires a local Walrus deployment with a WAL package.',\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tsymbol: 'WAL',\n\t\t\t\t\tfullCoinType: resolved.walCoinType as `${string}::wal::WAL`,\n\t\t\t\t\tdecimals: 9,\n\t\t\t\t\tsource: 'walrus',\n\t\t\t\t} satisfies WalCoinValue;\n\t\t\t}),\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// User-facing factories\n// ---------------------------------------------------------------------------\n\n/** Local-cluster shorthand. Known deployments are selected through the\n * per-network methods `walrusFor(network).testnet(...)` /\n * `.mainnet(...)` so network choice stays explicit; `.known(...)` is the\n * raw-id override form. */\nexport const walrus = (opts?: { readonly local?: WalrusLocalClusterOptions }) => {\n\treturn buildLocalPlugin(opts?.local ?? {});\n};\n\n/** Per-network factory options for `walrusFor(net).testnet()`/`.mainnet()`.\n * The `network` is injected by the namespace method, so the caller only\n * supplies the (still-required) `nodes` committee plus optional per-field\n * overrides — the on-chain ids default from the `@mysten/walrus` SDK package\n * config. Plugin-INTERNAL — deliberately NOT re-exported from `src/index.ts`. */\ntype WalrusKnownByNetworkOptions = Omit<WalrusKnownDeploymentOptions, 'network'>;\n\n/** Mode-narrowed factory namespace.\n *\n * Usage:\n * const network = { mode: 'local', network: 'localnet' } as const;\n * walrusFor(network).local({...}) // OK\n * walrusFor(liveNet).testnet({ nodes }) // OK — network injected\n * walrusFor(forkNet).local({...}) // compile error: no `.local` on fork\n *\n * Per-network methods (`.testnet`/`.mainnet`) inject the network into\n * `buildKnownPlugin`; `nodes` is still REQUIRED, so `.testnet({ nodes })` is\n * the minimal call. `.known(...)` is now the raw-id explicit-override form only\n * (`systemObjectId`/`stakingPoolId`/`nodes`) — the `network`-in-`.known()` path\n * was HARD CUT.\n *\n * Critically, the fork branch exposes NO `.local` — calling\n * `.local` on a fork-mode network is a **compile error** at the\n * call site (distilled-doc invariant 12 — type-level refusal). */\nexport const walrusFor = defineModeNamespace({\n\tlocal: {\n\t\tlocal: (opts: WalrusLocalClusterOptions = {}) => buildLocalPlugin(opts),\n\t\tknown: (opts: WalrusKnownByNetworkOptions) => buildKnownPlugin(opts),\n\t\ttestnet: (opts: WalrusKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'testnet', ...opts }),\n\t\tmainnet: (opts: WalrusKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'mainnet', ...opts }),\n\t},\n\tlive: {\n\t\tknown: (opts: WalrusKnownByNetworkOptions) => buildKnownPlugin(opts),\n\t\ttestnet: (opts: WalrusKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'testnet', ...opts }),\n\t\tmainnet: (opts: WalrusKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'mainnet', ...opts }),\n\t},\n\tfork: {\n\t\t// `.local` is intentionally absent — calling\n\t\t// `walrusFor(forkNetwork).local(...)` is a compile error.\n\t\tknown: (opts: WalrusKnownByNetworkOptions) => buildKnownPlugin(opts),\n\t\ttestnet: (opts: WalrusKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'testnet', ...opts }),\n\t\tmainnet: (opts: WalrusKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'mainnet', ...opts }),\n\t},\n});\n\n// ---------------------------------------------------------------------------\n// Re-exports for advanced callers\n// ---------------------------------------------------------------------------\n\nexport type {\n\tWalrusLocalClusterOptions,\n\tWalrusLocalPublisherOptions,\n\tWalrusLocalServiceOptions,\n} from './mode/local-cluster.ts';\nexport type { WalrusKnownDeploymentOptions, WalrusKnownNetwork } from './mode/known-deploy.ts';\nexport type { WalrusStorageNode } from './storage-nodes.ts';\nexport type { WalrusBindings, WalrusNodeBinding } from './codegen.ts';\nexport type { WalrusError, WalrusPluginError, WalrusConfigError, WalrusPhase } from './errors.ts';\nexport { walCoinType, walFaucetStrategyKey, type WalFaucetStrategy } from './faucet-strategy.ts';\nexport {\n\tWALRUS_STATE_REGISTRY_KEY,\n\ttype WalrusStateEntry,\n\ttype WalrusLocalStateEntry,\n\ttype WalrusKnownStateEntry,\n} from './registry-publish.ts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgHA,MAAa,iBAAiB,SAAmC,QAAQ;;;;;;;AAczE,MAAa,4BAA4B,aACxC,mBAAmB,GAAG,SAAS,IAAI,IAAI,SAAS,MAAM,IAAI,SAAS,cAAc,EAAE;AAEpF,MAAM,+BACL,SACA,mBACA,kBACuB;CACvB,GAAG;CACH,gBAAgB,SACf,QAAQ,cACP,KAAK,SAAS,oBAAoB,qBAAqB,MAAM,YAAY,IAAI,IAC9E;AACF;AAMA,MAAM,oBAAoB,SAAoC;CAG7D,MAAM,WAAW,2BAA2B,IAAI;CAEhD,MAAM,YAAY,gBAAgB,SAAS,IAAI;CAE/C,OAAO,aAAa;EACnB,IAAI,eAAe;EACnB,WAAW,CAAC,WAAW;EACvB,MAAM;EACN,SAAS;EACT,WAAW;EAIX,qBAAqB,CAAC,wBAAwB;GAAE,MAAM;GAAS,SAAS;EAAmB,CAAC,CAAC;EAI7F,QAAQ,SACP,OAAO,IAAI,aAAa;GACvB,MAAM,MAAM,OAAO;GACnB,MAAM,CAAC,OAAO;GAad,MAAM,UAAU,OAAO;GACvB,MAAM,WAAW,OAAO;GACxB,MAAM,aAAa,OAAO;GAC1B,MAAM,OAAO,OAAO,KAAK;GACzB,MAAM,YAAY,OAAO;GACzB,MAAM,QAAQ,OAAO,cAA2B,IAAI,OAAO;GAK3D,MAAM,sBAAsB,KAAK,KAChC,WAAW,WACX,UACA,SAAS,MACT,QACD;GAcA,MAAM,oBAAoB,uBACzB,SAAS,KACT,SAAS,OACT,SAAS,IACV;GACA,MAAM,qBAAqB,yBAAyB;IACnD,KAAK,SAAS;IACd,OAAO,SAAS;IAChB,YAAY,SAAS;GACtB,CA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js","names":[],"sources":["../../../src/plugins/walrus/index.ts"],"sourcesContent":["// Walrus plugin — barrel + factories.\n//\n// Architecture: Walrus is a service plugin that owns a local cluster\n// or describes a known deployment. The factory at this file folds the\n// four modes behind:\n//\n// - `walrus(opts?)` — local-cluster shorthand. No env\n// defaulting; use `walrusFor(...)`\n// for known deployments.\n// - `walrusFor(network)` — mode-narrowed factory namespace\n// (architecture Tension 11). Returns\n// `{ local: …, known: … }` narrowed\n// to the network's mode. Crucially,\n// the fork branch exposes ONLY\n// `.known` — `.local` is a compile\n// error on a fork-mode network.\n//\n// During `start`, the plugin emits (via the typed `ctx.*` verbs, per mode):\n//\n// Local mode (full local cluster):\n// 1. `ctx.snapshotExtra` — runtime/walrus/<name>/deploy/ subtree\n// + storage-node managed containers.\n// 2. `ctx.codegen` — `walrus-network` bindings.\n// 3. `ctx.endpoint` × (N+3) — per-node + aggregator + publisher + upload relay.\n// 4. `ctx.provides` walrus-state-registry — local entry.\n// 5. `ctx.provides` endpoint-registry — N+3 entries.\n// 6. `ctx.provides` package-registry — `walrus.<name>`.\n// 7. `ctx.provides` coinType:<WAL fullCoinType> — WAL faucet\n// strategy\n// (when exchange exists).\n//\n// Known mode (read-only deployment):\n// 1. `ctx.snapshotExtra` — identity-guard only; no subtrees.\n// 2. `ctx.codegen` — `walrus-network` bindings (mode='known').\n// 3. `ctx.provides` walrus-state-registry — known entry.\n//\n// Resource id: `'walrus'` (singular). The plugin's substrate-level\n// plugin key is the same string.\n\nimport { Effect, Path } from 'effect';\n\nimport { defineModeNamespace } from '../../api/mode-narrowed-factory.ts';\nimport { definePlugin, resource, type ResourceRef } from '../../api/define-plugin.ts';\nimport type { ContainerRuntime } from '../../contracts/container-runtime.ts';\nimport type { RoutableDecl } from '../../contracts/routable.ts';\nimport type { StrategyContributorDecl } from '../../contracts/strategy-contributor.ts';\nimport { emitContributions, PluginContext } from '../../substrate/plugin-ctx.ts';\nimport { ContainerRuntimeService } from '../../runtime/docker/service.ts';\nimport { IdentityContext, StackPathsService } from '../../substrate/runtime/paths.ts';\nimport { CacheService } from '../../substrate/runtime/cache/index.ts';\nimport { deriveSubnetPrefix, withSubnetAddressing } from '../../substrate/runtime/subnet-broker.ts';\nimport { renderUrl, routedHostname } from '../../substrate/runtime/routed-url.ts';\nimport type { AccountFundingCoinValue } from '../account/index.ts';\nimport { coinResourceId, type CoinResourceId } from '../coin/index.ts';\nimport { suiResource, type SuiProbeKey } from '../sui/index.ts';\n\nimport { chainProbeFor } from '../../substrate/runtime/strategy-registry/index.ts';\n\nimport { makeCodegenable, makeWalrusStaticCodegen } from './codegen.ts';\nimport { LOCAL_NETWORK_NAME } from '../../api/inference-network.ts';\nimport { walrusPluginKey } from './plugin-key.ts';\nimport { walrusPluginError, type WalrusPluginError } from './errors.ts';\nimport { makeWalFaucetContribution, type WalFaucetStrategy } from './faucet-strategy.ts';\nimport { bootWalrusService, type WalrusMode } from './service.ts';\nimport {\n\tresolveLocalClusterOptions,\n\ttype WalrusLocalClusterOptions,\n} from './mode/local-cluster.ts';\nimport {\n\tresolveKnownDeploymentOptions,\n\ttype WalrusKnownDeploymentOptions,\n} from './mode/known-deploy.ts';\nimport { makeSnapshotable, type WalrusSnapshotMode } from './snapshot.ts';\nimport {\n\tWALRUS_AGGREGATOR_ENDPOINT_NAME,\n\tWALRUS_PUBLISHER_ENDPOINT_NAME,\n\tWALRUS_UPLOAD_RELAY_ENDPOINT_NAME,\n\tmakeLocalRoutables,\n} from './routable.ts';\nimport { WALRUS_STATE_REGISTRY_KEY, type WalrusStateEntry } from './registry-publish.ts';\nimport {\n\tWALRUS_ROUTER_PORT,\n\tbuildWalrusNetworkName,\n\ttype WalrusStorageNode,\n} from './storage-nodes.ts';\n\n// ---------------------------------------------------------------------------\n// Resource — the resolved value all consumers read\n// ---------------------------------------------------------------------------\n\n/** The Walrus resolved value carried by the resource. */\nexport interface WalrusResolved {\n\treadonly mode: 'local' | 'known';\n\t/** Network name the walrus deployment targets (`localnet`/`testnet`/…). */\n\treadonly network: string;\n\treadonly walrusPackageId: string | null;\n\treadonly walPackageId: string | null;\n\t/** SDK-ready `packageConfig` — structurally compatible with\n\t * `@mysten/walrus`'s `WalrusPackageConfig`. */\n\treadonly packageConfig: {\n\t\treadonly systemObjectId: string;\n\t\treadonly stakingPoolId: string;\n\t\treadonly exchangeIds?: ReadonlyArray<string>;\n\t};\n\treadonly nodes: ReadonlyArray<WalrusStorageNode>;\n\treadonly proxyUrl: string | null;\n\treadonly aggregatorUrl: string | null;\n\treadonly publisherUrl: string | null;\n\treadonly uploadRelayUrl: string | null;\n\treadonly walFaucetStrategy: WalFaucetStrategy | null;\n\treadonly walCoinType: string | null;\n}\n\n/** Walrus plugin resource. */\nexport const walrusResource = resource<'walrus', WalrusResolved>('walrus');\n\nexport interface WalrusNetworkIdentity {\n\treadonly app: string;\n\treadonly stack: string;\n\treadonly walrusName: string;\n}\n\n/** Walrus deploy records storage-node listening IPs under this /24.\n * Docker network create requests the matching subnet explicitly, with\n * the prefix derived from the Walrus network identity so parallel\n * stacks don't all claim the same Docker IPAM range. Walrus claims\n * the `10.64.*` – `10.127.*` band; see substrate/runtime/subnet-broker.ts\n * for the algorithm and band coordination with seal. */\nexport const deriveWalrusSubnetPrefix = (identity: WalrusNetworkIdentity): string =>\n\tderiveSubnetPrefix(`${identity.app}\\0${identity.stack}\\0${identity.walrusName}`, 64);\n\nconst withWalrusNetworkAddressing = (\n\truntime: ContainerRuntime,\n\twalrusNetworkName: string,\n\tsubnetPrefix: string,\n): ContainerRuntime => ({\n\t...runtime,\n\tensureNetwork: (spec) =>\n\t\truntime.ensureNetwork(\n\t\t\tspec.name === walrusNetworkName ? withSubnetAddressing(spec, subnetPrefix) : spec,\n\t\t),\n});\n\n// ---------------------------------------------------------------------------\n// Plugin construction (internal — used by walrus() + walrusFor())\n// ---------------------------------------------------------------------------\n\nconst buildLocalPlugin = (opts: WalrusLocalClusterOptions) => {\n\t// Synchronous factory-time validation (distilled-doc invariants\n\t// 11 — `nodeCount >= 1` + `shards >= nodeCount`).\n\tconst resolved = resolveLocalClusterOptions(opts);\n\n\tconst walrusKey = walrusPluginKey(resolved.name);\n\n\treturn definePlugin({\n\t\tid: walrusResource.id,\n\t\tdependsOn: [suiResource] as const,\n\t\trole: 'service',\n\t\tsection: 'service',\n\t\tpluginKey: walrusKey,\n\t\t// Stack-free codegen: a local walrus cluster's deploy ids / endpoint\n\t\t// URLs are LOADED CONFIG DATA -- the committed `walrus.ts` stub emits\n\t\t// `requireValue(dep, 'walrus', '<key>')`, never a baked object id / URL.\n\t\tstaticCodegen: () => [makeWalrusStaticCodegen({ mode: 'local', network: LOCAL_NETWORK_NAME })],\n\t\t// `deps` auto-infers the resolved `[sui]` tuple from the\n\t\t// `[suiResource] as const` dependency. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: (deps) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst [sui] = deps;\n\n\t\t\t\t// Substrate-context primitives:\n\t\t\t\t// - `ContainerRuntimeService` + `IdentityContext` arrive\n\t\t\t\t// via the supervisor's plugin runtime context.\n\t\t\t\t// - `ArtifactPublisher` is the substrate-level\n\t\t\t\t// publisher (cache → verify → produce → register cycle).\n\t\t\t\t// - `ChainProbe<SuiProbeKey>` is looked up via the\n\t\t\t\t// StrategyRegistry under `chain-probe:<chainId>`;\n\t\t\t\t// Sui registered itself there at its own acquire.\n\t\t\t\t// - `StackPathsService` resolves the per-stack on-disk\n\t\t\t\t// root so the deploy-output bind-mount source is a\n\t\t\t\t// real path (not the `<runtime>/...` template).\n\t\t\t\tconst runtime = yield* ContainerRuntimeService;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst stackPaths = yield* StackPathsService;\n\t\t\t\tconst path = yield* Path.Path;\n\t\t\t\tconst publisher = yield* CacheService;\n\t\t\t\tconst probe = yield* chainProbeFor<SuiProbeKey>(sui.chainId);\n\n\t\t\t\t// Resolve the deploy-output bind-mount source from the\n\t\t\t\t// per-stack paths bundle. The deploy one-shot owns preparing\n\t\t\t\t// the directory immediately before its Docker bind mount.\n\t\t\t\tconst deployHostMountPath = path.join(\n\t\t\t\t\tstackPaths.stackRoot,\n\t\t\t\t\t'walrus',\n\t\t\t\t\tresolved.name,\n\t\t\t\t\t'deploy',\n\t\t\t\t);\n\n\t\t\t\t// Cross-container DNS: walrus containers (deploy one-shot\n\t\t\t\t// + N storage nodes) dial sui RPC + faucet via\n\t\t\t\t// `host.docker.internal`. The sui plugin binds brokered\n\t\t\t\t// host ports — no shared docker network needed.\n\t\t\t\t//\n\t\t\t\t// Architectural decision (B5): walrus owns its OWN docker\n\t\t\t\t// network for storage-node ↔ deploy connectivity; sui-side\n\t\t\t\t// hops go through the host gateway.\n\t\t\t\t// On Linux this requires Docker Desktop or the\n\t\t\t\t// `host.docker.internal:host-gateway` runtime hint (the\n\t\t\t\t// established devstack convention — see plugins/deepbook\n\t\t\t\t// which uses the same pattern).\n\t\t\t\tconst walrusNetworkName = buildWalrusNetworkName(\n\t\t\t\t\tidentity.app,\n\t\t\t\t\tidentity.stack,\n\t\t\t\t\tresolved.name,\n\t\t\t\t);\n\t\t\t\tconst walrusSubnetPrefix = deriveWalrusSubnetPrefix({\n\t\t\t\t\tapp: identity.app,\n\t\t\t\t\tstack: identity.stack,\n\t\t\t\t\twalrusName: resolved.name,\n\t\t\t\t});\n\t\t\t\tconst walrusRuntime = withWalrusNetworkAddressing(\n\t\t\t\t\truntime,\n\t\t\t\t\twalrusNetworkName,\n\t\t\t\t\twalrusSubnetPrefix,\n\t\t\t\t);\n\t\t\t\tconst suiRpcUrlInNetwork = sui.hostGateway.rpcUrl;\n\t\t\t\t// sui-faucet v2 endpoint — `/v2/gas` is the supported path\n\t\t\t\t// on devnet-v1.71.0+.\n\t\t\t\tconst suiFaucetUrlInNetwork = sui.hostGateway.faucetUrl;\n\t\t\t\tif (suiFaucetUrlInNetwork === null) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\twalrusPluginError(\n\t\t\t\t\t\t\t'deploy',\n\t\t\t\t\t\t\t'walrus local-cluster requires a Sui faucet URL for deploy funding.',\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst walrusFaucetUrlInNetwork = `${suiFaucetUrlInNetwork}/v2/gas`;\n\n\t\t\t\tconst mode: WalrusMode = { mode: 'local', opts: resolved };\n\t\t\t\tconst boot = yield* bootWalrusService(\n\t\t\t\t\t{\n\t\t\t\t\t\truntime: walrusRuntime,\n\t\t\t\t\t\tpublisher,\n\t\t\t\t\t\tprobe,\n\t\t\t\t\t\tsuiSdk: sui.sdk,\n\t\t\t\t\t\tsuiChainId: sui.chainId,\n\t\t\t\t\t\tsuiRpcUrlInNetwork,\n\t\t\t\t\t\twalrusFaucetUrlInNetwork,\n\t\t\t\t\t\twaitForFundsReady: sui.waitForTransactionsReady.wait,\n\t\t\t\t\t\tapp: identity.app,\n\t\t\t\t\t\tstack: identity.stack,\n\t\t\t\t\t\tsubnetPrefix: walrusSubnetPrefix,\n\t\t\t\t\t\twalrusNetworkName,\n\t\t\t\t\t\t// Walrus has no `sui-net` to attach to (sui binds\n\t\t\t\t\t\t// host ports). Reuse the walrus network so the\n\t\t\t\t\t\t// deploy one-shot + storage nodes land on a single\n\t\t\t\t\t\t// network and reach sui via `host.docker.internal`.\n\t\t\t\t\t\tsuiNetworkName: walrusNetworkName,\n\t\t\t\t\t\tdeployHostMountPath,\n\t\t\t\t\t\tstackRoot: stackPaths.stackRoot,\n\t\t\t\t\t},\n\t\t\t\t\tmode,\n\t\t\t\t);\n\n\t\t\t\tif (boot.mode !== 'local') {\n\t\t\t\t\t// Should be unreachable — dispatch is by mode. Defense.\n\t\t\t\t\treturn yield* Effect.die('walrus: mode mismatch in local plugin');\n\t\t\t\t}\n\n\t\t\t\tconst packageConfig: WalrusResolved['packageConfig'] =\n\t\t\t\t\tboot.exchangeObjectId === undefined\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsystemObjectId: boot.deploy.systemObject,\n\t\t\t\t\t\t\t\tstakingPoolId: boot.deploy.stakingObject,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tsystemObjectId: boot.deploy.systemObject,\n\t\t\t\t\t\t\t\tstakingPoolId: boot.deploy.stakingObject,\n\t\t\t\t\t\t\t\texchangeIds: [boot.exchangeObjectId],\n\t\t\t\t\t\t\t};\n\t\t\t\tconst serviceUrl = (role: string) =>\n\t\t\t\t\troutedHostname(identity, role).pipe(\n\t\t\t\t\t\tEffect.map((hostname) =>\n\t\t\t\t\t\t\trenderUrl({\n\t\t\t\t\t\t\t\tprotocol: 'http',\n\t\t\t\t\t\t\t\thostname,\n\t\t\t\t\t\t\t\tport: WALRUS_ROUTER_PORT,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tEffect.mapError((cause) =>\n\t\t\t\t\t\t\twalrusPluginError(\n\t\t\t\t\t\t\t\t'proxy',\n\t\t\t\t\t\t\t\t`walrus route URL assembly failed for ${role}: ${cause.detail}`,\n\t\t\t\t\t\t\t\t{ cause },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\tconst aggregatorUrl =\n\t\t\t\t\tboot.clientServices.aggregator === null\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: yield* serviceUrl(WALRUS_AGGREGATOR_ENDPOINT_NAME);\n\t\t\t\tconst publisherUrl =\n\t\t\t\t\tboot.clientServices.publisher === null\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: yield* serviceUrl(WALRUS_PUBLISHER_ENDPOINT_NAME);\n\t\t\t\tconst uploadRelayUrl =\n\t\t\t\t\tboot.clientServices.uploadRelay === null\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: yield* serviceUrl(WALRUS_UPLOAD_RELAY_ENDPOINT_NAME);\n\n\t\t\t\tconst resolvedValue: WalrusResolved = {\n\t\t\t\t\tmode: 'local',\n\t\t\t\t\tnetwork: identity.network,\n\t\t\t\t\twalrusPackageId: boot.walrusPackageId,\n\t\t\t\t\twalPackageId: boot.walPackageId,\n\t\t\t\t\tpackageConfig,\n\t\t\t\t\tnodes: boot.nodes,\n\t\t\t\t\tproxyUrl: aggregatorUrl,\n\t\t\t\t\taggregatorUrl,\n\t\t\t\t\tpublisherUrl,\n\t\t\t\t\tuploadRelayUrl,\n\t\t\t\t\twalFaucetStrategy: boot.walFaucetStrategy,\n\t\t\t\t\twalCoinType: boot.walCoinType,\n\t\t\t\t};\n\t\t\t\t// Emit the resolved contributions inline: snapshot → codegen →\n\t\t\t\t// state-registry → (optional WAL faucet) → routables. `identity`\n\t\t\t\t// (from `IdentityContext`) stamps the snapshot + routable\n\t\t\t\t// container names. ID-stability surfaces (deploy/blob ids via\n\t\t\t\t// ArtifactPublisher) live OUTSIDE this emission and are untouched.\n\t\t\t\tconst walFaucetContribution: ReadonlyArray<StrategyContributorDecl> =\n\t\t\t\t\tresolvedValue.walFaucetStrategy === null || resolvedValue.walCoinType === null\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tmakeWalFaucetContribution(\n\t\t\t\t\t\t\t\t\tresolvedValue.walFaucetStrategy,\n\t\t\t\t\t\t\t\t\tresolvedValue.walCoinType,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t];\n\t\t\t\tconst clientServiceRoles = [\n\t\t\t\t\t...(boot.clientServices.aggregator === null ? [] : ['aggregator' as const]),\n\t\t\t\t\t...(boot.clientServices.publisher === null ? [] : ['publisher' as const]),\n\t\t\t\t\t...(boot.clientServices.uploadRelay === null ? [] : ['upload-relay' as const]),\n\t\t\t\t];\n\t\t\t\temitContributions(ctx, [\n\t\t\t\t\tmakeSnapshotable(\n\t\t\t\t\t\t'local' satisfies WalrusSnapshotMode,\n\t\t\t\t\t\tidentity.app,\n\t\t\t\t\t\tidentity.stack,\n\t\t\t\t\t\tresolved.name,\n\t\t\t\t\t\tresolvedValue.network,\n\t\t\t\t\t\tresolved.nodeCount,\n\t\t\t\t\t\tclientServiceRoles,\n\t\t\t\t\t),\n\t\t\t\t\tmakeCodegenable({\n\t\t\t\t\t\tmode: 'local',\n\t\t\t\t\t\tnetwork: resolvedValue.network,\n\t\t\t\t\t\twalrusPackageId: resolvedValue.walrusPackageId,\n\t\t\t\t\t\twalPackageId: resolvedValue.walPackageId,\n\t\t\t\t\t\twalCoinType: resolvedValue.walCoinType,\n\t\t\t\t\t\tsystemObjectId: resolvedValue.packageConfig.systemObjectId,\n\t\t\t\t\t\tstakingPoolId: resolvedValue.packageConfig.stakingPoolId,\n\t\t\t\t\t\texchangeIds: resolvedValue.packageConfig.exchangeIds\n\t\t\t\t\t\t\t? [...resolvedValue.packageConfig.exchangeIds]\n\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\tproxyUrl: resolvedValue.proxyUrl,\n\t\t\t\t\t\taggregatorUrl: resolvedValue.aggregatorUrl,\n\t\t\t\t\t\tpublisherUrl: resolvedValue.publisherUrl,\n\t\t\t\t\t\tuploadRelayUrl: resolvedValue.uploadRelayUrl,\n\t\t\t\t\t\tnodes: resolvedValue.nodes,\n\t\t\t\t\t}),\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: 'strategy-contributor',\n\t\t\t\t\t\tcapabilityKey: WALRUS_STATE_REGISTRY_KEY,\n\t\t\t\t\t\tstrategy: { noteName: resolved.name },\n\t\t\t\t\t\tautoMounted: true,\n\t\t\t\t\t} satisfies StrategyContributorDecl<\n\t\t\t\t\t\ttypeof WALRUS_STATE_REGISTRY_KEY,\n\t\t\t\t\t\t{ readonly noteName: string }\n\t\t\t\t\t>,\n\t\t\t\t\t...walFaucetContribution,\n\t\t\t\t\t...(makeLocalRoutables({\n\t\t\t\t\t\tapp: identity.app,\n\t\t\t\t\t\tstack: identity.stack,\n\t\t\t\t\t\twalrusName: resolved.name,\n\t\t\t\t\t\tserviceKey: String(walrusKey),\n\t\t\t\t\t\tnodeCount: resolved.nodeCount,\n\t\t\t\t\t\tcontainerApiPort: resolved.containerApiPort,\n\t\t\t\t\t\taggregator: boot.clientServices.aggregator,\n\t\t\t\t\t\tpublisher: boot.clientServices.publisher,\n\t\t\t\t\t\tuploadRelay: boot.clientServices.uploadRelay,\n\t\t\t\t\t}) as readonly RoutableDecl[]),\n\t\t\t\t]);\n\t\t\t\treturn resolvedValue;\n\t\t\t}),\n\t});\n};\n\nconst buildKnownPlugin = (opts: WalrusKnownDeploymentOptions) => {\n\t// Synchronous factory-time validation for required deployment ids.\n\tconst resolved = resolveKnownDeploymentOptions(opts);\n\n\treturn definePlugin({\n\t\tid: walrusResource.id,\n\t\tdependsOn: [suiResource] as const,\n\t\t// Known deployment is a pure value-producer — no containers,\n\t\t// no long-running children.\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\t// Stack-free codegen: a known deployment's ids / URLs are DECLARED\n\t\t// config (not loaded-at-runtime data) — bake them as literals in the\n\t\t// committed `walrus.ts` (mirrors `knownPackage`). `walrusPackageId` /\n\t\t// `walPackageId` / `walCoinType` are null for a known deployment.\n\t\tstaticCodegen: () => [\n\t\t\tmakeWalrusStaticCodegen({\n\t\t\t\tmode: 'known',\n\t\t\t\tnetwork: resolved.network,\n\t\t\t\tknown: {\n\t\t\t\t\twalrusPackageId: null,\n\t\t\t\t\twalPackageId: null,\n\t\t\t\t\twalCoinType: null,\n\t\t\t\t\tpackageConfig: {\n\t\t\t\t\t\tsystemObjectId: resolved.systemObjectId,\n\t\t\t\t\t\tstakingPoolId: resolved.stakingPoolId,\n\t\t\t\t\t\t...(resolved.exchangeIds.length > 0 ? { exchangeIds: [...resolved.exchangeIds] } : {}),\n\t\t\t\t\t},\n\t\t\t\t\tproxyUrl: resolved.proxyUrl,\n\t\t\t\t\taggregatorUrl: resolved.aggregatorUrl,\n\t\t\t\t\tpublisherUrl: resolved.publisherUrl,\n\t\t\t\t\tuploadRelayUrl: resolved.uploadRelayUrl,\n\t\t\t\t\tnodes: resolved.nodes,\n\t\t\t\t},\n\t\t\t}),\n\t\t],\n\t\t// Known mode is a pure value-producer — `sui` is unused (the value\n\t\t// reads `resolved.network` from the deployment options) but the\n\t\t// `dependsOn` edge still orders boot, so `start` is zero-arg.\n\t\t// `ctx` arrives via the `PluginContext` service.\n\t\tstart: () =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst resolvedValue = {\n\t\t\t\t\tmode: 'known',\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\twalrusPackageId: null,\n\t\t\t\t\twalPackageId: null,\n\t\t\t\t\tpackageConfig: {\n\t\t\t\t\t\tsystemObjectId: resolved.systemObjectId,\n\t\t\t\t\t\tstakingPoolId: resolved.stakingPoolId,\n\t\t\t\t\t\texchangeIds: resolved.exchangeIds.length > 0 ? resolved.exchangeIds : undefined,\n\t\t\t\t\t},\n\t\t\t\t\tnodes: resolved.nodes,\n\t\t\t\t\tproxyUrl: resolved.proxyUrl,\n\t\t\t\t\taggregatorUrl: resolved.aggregatorUrl,\n\t\t\t\t\tpublisherUrl: resolved.publisherUrl,\n\t\t\t\t\tuploadRelayUrl: resolved.uploadRelayUrl,\n\t\t\t\t\twalFaucetStrategy: null,\n\t\t\t\t\twalCoinType: null,\n\t\t\t\t} satisfies WalrusResolved;\n\t\t\t\t// Emit inline: snapshot → codegen → state-registry. Known mode\n\t\t\t\t// emits no routable. `identity` (from `IdentityContext`) stamps\n\t\t\t\t// the snapshot scoping.\n\t\t\t\tctx.snapshotExtra(\n\t\t\t\t\tmakeSnapshotable(\n\t\t\t\t\t\t'known' satisfies WalrusSnapshotMode,\n\t\t\t\t\t\tidentity.app,\n\t\t\t\t\t\tidentity.stack,\n\t\t\t\t\t\t'walrusKnownDeployment',\n\t\t\t\t\t\tresolvedValue.network,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tctx.codegen(\n\t\t\t\t\tmakeCodegenable({\n\t\t\t\t\t\tmode: 'known',\n\t\t\t\t\t\tnetwork: resolvedValue.network,\n\t\t\t\t\t\twalrusPackageId: resolvedValue.walrusPackageId,\n\t\t\t\t\t\twalPackageId: resolvedValue.walPackageId,\n\t\t\t\t\t\twalCoinType: resolvedValue.walCoinType,\n\t\t\t\t\t\tsystemObjectId: resolvedValue.packageConfig.systemObjectId,\n\t\t\t\t\t\tstakingPoolId: resolvedValue.packageConfig.stakingPoolId,\n\t\t\t\t\t\texchangeIds: resolvedValue.packageConfig.exchangeIds\n\t\t\t\t\t\t\t? [...resolvedValue.packageConfig.exchangeIds]\n\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\tproxyUrl: resolvedValue.proxyUrl,\n\t\t\t\t\t\taggregatorUrl: resolvedValue.aggregatorUrl,\n\t\t\t\t\t\tpublisherUrl: resolvedValue.publisherUrl,\n\t\t\t\t\t\tuploadRelayUrl: resolvedValue.uploadRelayUrl,\n\t\t\t\t\t\tnodes: resolvedValue.nodes,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tctx.provides({\n\t\t\t\t\tkind: 'strategy-contributor',\n\t\t\t\t\tcapabilityKey: WALRUS_STATE_REGISTRY_KEY,\n\t\t\t\t\tstrategy: {\n\t\t\t\t\t\tname: 'walrusKnownDeployment',\n\t\t\t\t\t\tsystemObjectId: resolvedValue.packageConfig.systemObjectId,\n\t\t\t\t\t\tstakingObjectId: resolvedValue.packageConfig.stakingPoolId,\n\t\t\t\t\t\tnetwork: resolvedValue.network,\n\t\t\t\t\t},\n\t\t\t\t\tautoMounted: true,\n\t\t\t\t} satisfies StrategyContributorDecl<typeof WALRUS_STATE_REGISTRY_KEY, WalrusStateEntry>);\n\t\t\t\treturn resolvedValue;\n\t\t\t}),\n\t});\n};\n\nexport interface WalCoinValue extends AccountFundingCoinValue {\n\treadonly symbol: 'WAL';\n\treadonly fullCoinType: `${string}::wal::WAL`;\n\treadonly decimals: 9;\n\treadonly source: 'walrus';\n}\n\n/** Resolve the local Walrus deployment's WAL coin as an account-funding\n * coin ref. Accounts that need WAL should use:\n *\n * funding: [{ coin: walCoin(localWalrus), amount }]\n *\n * The funding strategy itself is contributed by the Walrus service\n * once its local exchange exists. */\nexport const walCoin = (walrusMember: ResourceRef<'walrus', WalrusResolved>) => {\n\tconst coinRef = resource<CoinResourceId<'wal'>, WalCoinValue>(coinResourceId('wal'));\n\n\treturn definePlugin({\n\t\tid: coinRef.id,\n\t\tdependsOn: walrusMember,\n\t\trole: 'task',\n\t\tsection: 'action',\n\t\tstart: (resolved): Effect.Effect<WalCoinValue, WalrusPluginError> =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tif (resolved.walCoinType === null) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\twalrusPluginError(\n\t\t\t\t\t\t\t'exchange',\n\t\t\t\t\t\t\t'walCoin(...) requires a local Walrus deployment with a WAL package.',\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tsymbol: 'WAL',\n\t\t\t\t\tfullCoinType: resolved.walCoinType as `${string}::wal::WAL`,\n\t\t\t\t\tdecimals: 9,\n\t\t\t\t\tsource: 'walrus',\n\t\t\t\t} satisfies WalCoinValue;\n\t\t\t}),\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// User-facing factories\n// ---------------------------------------------------------------------------\n\n/** Local-cluster shorthand. Known deployments are selected through the\n * per-network methods `walrusFor(network).testnet(...)` /\n * `.mainnet(...)` so network choice stays explicit; `.known(...)` is the\n * raw-id override form. */\nexport const walrus = (opts?: { readonly local?: WalrusLocalClusterOptions }) => {\n\treturn buildLocalPlugin(opts?.local ?? {});\n};\n\n/** Per-network factory options for `walrusFor(net).testnet()`/`.mainnet()`.\n * The `network` is injected by the namespace method, so the caller only\n * supplies the (still-required) `nodes` committee plus optional per-field\n * overrides — the on-chain ids default from the `@mysten/walrus` SDK package\n * config. Plugin-INTERNAL — deliberately NOT re-exported from `src/index.ts`. */\ntype WalrusKnownByNetworkOptions = Omit<WalrusKnownDeploymentOptions, 'network'>;\n\n/** Mode-narrowed factory namespace.\n *\n * Usage:\n * const network = { mode: 'local', network: 'localnet' } as const;\n * walrusFor(network).local({...}) // OK\n * walrusFor(liveNet).testnet({ nodes }) // OK — network injected\n * walrusFor(forkNet).local({...}) // compile error: no `.local` on fork\n *\n * Per-network methods (`.testnet`/`.mainnet`) inject the network into\n * `buildKnownPlugin`; `nodes` is still REQUIRED, so `.testnet({ nodes })` is\n * the minimal call. `.known(...)` is now the raw-id explicit-override form only\n * (`systemObjectId`/`stakingPoolId`/`nodes`) — the `network`-in-`.known()` path\n * was HARD CUT.\n *\n * Critically, the fork branch exposes NO `.local` — calling\n * `.local` on a fork-mode network is a **compile error** at the\n * call site (distilled-doc invariant 12 — type-level refusal). */\nexport const walrusFor = defineModeNamespace({\n\tlocal: {\n\t\tlocal: (opts: WalrusLocalClusterOptions = {}) => buildLocalPlugin(opts),\n\t\tknown: (opts: WalrusKnownByNetworkOptions) => buildKnownPlugin(opts),\n\t\ttestnet: (opts: WalrusKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'testnet', ...opts }),\n\t\tmainnet: (opts: WalrusKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'mainnet', ...opts }),\n\t},\n\tlive: {\n\t\tknown: (opts: WalrusKnownByNetworkOptions) => buildKnownPlugin(opts),\n\t\ttestnet: (opts: WalrusKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'testnet', ...opts }),\n\t\tmainnet: (opts: WalrusKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'mainnet', ...opts }),\n\t},\n\tfork: {\n\t\t// `.local` is intentionally absent — calling\n\t\t// `walrusFor(forkNetwork).local(...)` is a compile error.\n\t\tknown: (opts: WalrusKnownByNetworkOptions) => buildKnownPlugin(opts),\n\t\ttestnet: (opts: WalrusKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'testnet', ...opts }),\n\t\tmainnet: (opts: WalrusKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'mainnet', ...opts }),\n\t},\n});\n\n// ---------------------------------------------------------------------------\n// Re-exports for advanced callers\n// ---------------------------------------------------------------------------\n\nexport type {\n\tWalrusLocalClusterOptions,\n\tWalrusLocalPublisherOptions,\n\tWalrusLocalServiceOptions,\n} from './mode/local-cluster.ts';\nexport type { WalrusKnownDeploymentOptions, WalrusKnownNetwork } from './mode/known-deploy.ts';\nexport type { WalrusStorageNode } from './storage-nodes.ts';\nexport type { WalrusBindings, WalrusNodeBinding } from './codegen.ts';\nexport type { WalrusError, WalrusPluginError, WalrusConfigError, WalrusPhase } from './errors.ts';\nexport { walCoinType, walFaucetStrategyKey, type WalFaucetStrategy } from './faucet-strategy.ts';\nexport {\n\tWALRUS_STATE_REGISTRY_KEY,\n\ttype WalrusStateEntry,\n\ttype WalrusLocalStateEntry,\n\ttype WalrusKnownStateEntry,\n} from './registry-publish.ts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,MAAa,iBAAiB,SAAmC,QAAQ;;;;;;;AAczE,MAAa,4BAA4B,aACxC,mBAAmB,GAAG,SAAS,IAAI,IAAI,SAAS,MAAM,IAAI,SAAS,cAAc,EAAE;AAEpF,MAAM,+BACL,SACA,mBACA,kBACuB;CACvB,GAAG;CACH,gBAAgB,SACf,QAAQ,cACP,KAAK,SAAS,oBAAoB,qBAAqB,MAAM,YAAY,IAAI,IAC9E;AACF;AAMA,MAAM,oBAAoB,SAAoC;CAG7D,MAAM,WAAW,2BAA2B,IAAI;CAEhD,MAAM,YAAY,gBAAgB,SAAS,IAAI;CAE/C,OAAO,aAAa;EACnB,IAAI,eAAe;EACnB,WAAW,CAAC,WAAW;EACvB,MAAM;EACN,SAAS;EACT,WAAW;EAIX,qBAAqB,CAAC,wBAAwB;GAA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CAAC;AAC1C;;;;;;;;;;;;;;;;;;AA0BA,MAAa,YAAY,oBAAoB;CAC5C,OAAO;EACN,QAAQ,OAAkC,CAAC,MAAM,iBAAiB,IAAI;EACtE,QAAQ,SAAsC,iBAAiB,IAAI;EACnE,UAAU,OAAoC,CAAC,MAC9C,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;EACjD,UAAU,OAAoC,CAAC,MAC9C,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;CAClD;CACA,MAAM;EACL,QAAQ,SAAsC,iBAAiB,IAAI;EACnE,UAAU,OAAoC,CAAC,MAC9C,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;EACjD,UAAU,OAAoC,CAAC,MAC9C,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;CAClD;CACA,MAAM;EAGL,QAAQ,SAAsC,iBAAiB,IAAI;EACnE,UAAU,OAAoC,CAAC,MAC9C,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;EACjD,UAAU,OAAoC,CAAC,MAC9C,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;CAClD;AACD,CAAC"}
@@ -22,6 +22,7 @@ interface WalrusKnownDeploymentOptions {
22
22
  readonly nodes?: ReadonlyArray<WalrusStorageNode>;
23
23
  readonly aggregatorUrl?: string;
24
24
  readonly publisherUrl?: string;
25
+ readonly uploadRelayUrl?: string;
25
26
  readonly proxyUrl?: string;
26
27
  }
27
28
  //#endregion
@@ -6,7 +6,7 @@ import { MAINNET_WALRUS_PACKAGE_CONFIG, TESTNET_WALRUS_PACKAGE_CONFIG } from "@m
6
6
  /** Known-deployment registry — baked-in record per network. The
7
7
  * on-chain ids default from the `@mysten/walrus` SDK package config
8
8
  * (`{TESTNET,MAINNET}_WALRUS_PACKAGE_CONFIG`) so a caller only needs
9
- * to supply `nodes`; the aggregator/publisher/proxy URLs are
9
+ * to supply `nodes`; the aggregator/publisher/upload-relay/proxy URLs are
10
10
  * devstack-owned (the SDK ships none). Devnet has no canonical SDK
11
11
  * record today, so it keeps no id defaults. */
12
12
  const KNOWN_DEPLOYMENT_REGISTRY = {
@@ -17,6 +17,7 @@ const KNOWN_DEPLOYMENT_REGISTRY = {
17
17
  exchangeIds: TESTNET_WALRUS_PACKAGE_CONFIG.exchangeIds,
18
18
  aggregatorUrl: "https://aggregator.walrus-testnet.walrus.space",
19
19
  publisherUrl: "https://publisher.walrus-testnet.walrus.space",
20
+ uploadRelayUrl: "https://upload-relay.testnet.walrus.space",
20
21
  proxyUrl: "https://aggregator.walrus-testnet.walrus.space"
21
22
  },
22
23
  mainnet: {
@@ -25,6 +26,7 @@ const KNOWN_DEPLOYMENT_REGISTRY = {
25
26
  stakingPoolId: MAINNET_WALRUS_PACKAGE_CONFIG.stakingPoolId,
26
27
  aggregatorUrl: "https://aggregator.walrus.space",
27
28
  publisherUrl: "https://publisher.walrus.space",
29
+ uploadRelayUrl: "https://upload-relay.mainnet.walrus.space",
28
30
  proxyUrl: "https://aggregator.walrus.space"
29
31
  },
30
32
  devnet: { network: "devnet" }
@@ -47,6 +49,7 @@ const resolveKnownDeploymentOptions = (opts) => {
47
49
  if (!nodes) throw walrusConfigError("nodes", `walrusKnownDeployment: explicit 'nodes' committee is required — Walrus ${opts.network ?? "custom"} has nodes fetched dynamically by the SDK`, "pass an empty array if you accept the SDK-driven committee lookup, or use walrus()/walrusFor(network).local({...}) for a local self-hosted cluster");
48
50
  const aggregatorUrl = opts.aggregatorUrl ?? reg?.aggregatorUrl ?? null;
49
51
  const publisherUrl = opts.publisherUrl ?? reg?.publisherUrl ?? null;
52
+ const uploadRelayUrl = opts.uploadRelayUrl ?? reg?.uploadRelayUrl ?? null;
50
53
  const proxyUrl = opts.proxyUrl ?? reg?.proxyUrl ?? aggregatorUrl ?? null;
51
54
  return {
52
55
  mode: "known",
@@ -57,7 +60,8 @@ const resolveKnownDeploymentOptions = (opts) => {
57
60
  nodes,
58
61
  proxyUrl,
59
62
  aggregatorUrl,
60
- publisherUrl
63
+ publisherUrl,
64
+ uploadRelayUrl
61
65
  };
62
66
  };
63
67
  /** "Boot" the known deployment. Purely synchronous projection inside
@@ -1 +1 @@
1
- {"version":3,"file":"known-deploy.mjs","names":[],"sources":["../../../../src/plugins/walrus/mode/known-deploy.ts"],"sourcesContent":["// Walrus mode — known deployment (testnet / mainnet / *-fork via\n// upstream translation).\n//\n// Distilled-doc reference (06-walrus.md §\"Lifecycle: Startup —\n// known deployment\"). Purely synchronous body — no ordered phases.\n// The factory validates required deployment fields and returns a\n// resolved value whose tags are eager `Layer.succeed(...)` constants.\n//\n// Distilled-doc invariants honored:\n// - 15: each of `proxyUrl / aggregatorUrl / publisherUrl` surfaces\n// INDEPENDENTLY. Encoded as `string | null` in the resolved\n// shape — a given field is null only when THAT specific URL\n// is unresolved (registry default + explicit override both\n// absent). The plugin's projection step publishes each tag\n// when its own URL is present; a missing publisher URL does\n// not suppress an available proxy/aggregator URL.\n// - 16: throw synchronously when `nodes` is missing for a\n// registered network. The on-chain ids\n// (`systemObjectId` / `stakingPoolId` / `exchangeIds`) ARE\n// stable and come from the `@mysten/walrus` SDK package config\n// — we default them from the SDK and let callers override.\n// Only the node committee stays explicit: testnet has 100+\n// nodes that the SDK fetches dynamically, so we don't pin them.\n\nimport { MAINNET_WALRUS_PACKAGE_CONFIG, TESTNET_WALRUS_PACKAGE_CONFIG } from '@mysten/walrus';\nimport { Effect, type Scope } from 'effect';\n\nimport { expectNonEmptyString } from '../../../substrate/runtime/config-validation.ts';\nimport { walrusConfigError, type WalrusConfigError } from '../errors.ts';\nimport type { WalrusStorageNode } from '../storage-nodes.ts';\n\n/** Known networks supported by the registry lookup. */\nexport type WalrusKnownNetwork = 'testnet' | 'mainnet' | 'devnet';\n\n/** Options for the known-deployment mode. */\nexport interface WalrusKnownDeploymentOptions {\n\t/** Network shortcut — looks up per-field defaults from a registry\n\t * baked into this package. */\n\treadonly network?: WalrusKnownNetwork;\n\t/** Per-field overrides for the on-chain ids. For `testnet`/`mainnet`\n\t * these default from the `@mysten/walrus` SDK package config, so\n\t * they're optional; for `devnet` (or when `network` is omitted)\n\t * `systemObjectId`/`stakingPoolId` are required. An explicit value\n\t * here always wins over the registry default. */\n\treadonly systemObjectId?: string;\n\treadonly stakingPoolId?: string;\n\treadonly exchangeIds?: ReadonlyArray<string>;\n\t/** Explicit storage-node committee. Required (throws if missing\n\t * even when `network` is set — distilled-doc invariant 16). */\n\treadonly nodes?: ReadonlyArray<WalrusStorageNode>;\n\treadonly aggregatorUrl?: string;\n\treadonly publisherUrl?: string;\n\treadonly proxyUrl?: string;\n}\n\n/** Resolved known-deployment boot artifacts. */\nexport interface KnownDeploymentBootResult {\n\treadonly mode: 'known';\n\t/** The known network's name (`testnet`/`mainnet`/`devnet`) — its stable\n\t * identity. A known remote deployment has no per-boot genesis digest, so\n\t * the network name IS its `chainId` for codegen/snapshot keying. */\n\treadonly network: string;\n\treadonly systemObjectId: string;\n\treadonly stakingPoolId: string;\n\treadonly exchangeIds: ReadonlyArray<string>;\n\treadonly nodes: ReadonlyArray<WalrusStorageNode>;\n\t/** Null only when the read/proxy URL itself is unresolved (no explicit\n\t * `proxyUrl` override, registry proxy URL, or aggregator URL). Surfaces\n\t * independently of `aggregatorUrl` / `publisherUrl` — distilled-doc\n\t * invariant 15. */\n\treadonly proxyUrl: string | null;\n\treadonly aggregatorUrl: string | null;\n\treadonly publisherUrl: string | null;\n}\n\n/** Known-deployment registry — baked-in record per network. The\n * on-chain ids default from the `@mysten/walrus` SDK package config\n * (`{TESTNET,MAINNET}_WALRUS_PACKAGE_CONFIG`) so a caller only needs\n * to supply `nodes`; the aggregator/publisher/proxy URLs are\n * devstack-owned (the SDK ships none). Devnet has no canonical SDK\n * record today, so it keeps no id defaults. */\nconst KNOWN_DEPLOYMENT_REGISTRY: Readonly<\n\tRecord<\n\t\tWalrusKnownNetwork,\n\t\t{\n\t\t\treadonly network: string;\n\t\t\treadonly systemObjectId?: string;\n\t\t\treadonly stakingPoolId?: string;\n\t\t\treadonly exchangeIds?: ReadonlyArray<string>;\n\t\t\treadonly aggregatorUrl?: string;\n\t\t\treadonly publisherUrl?: string;\n\t\t\treadonly proxyUrl?: string;\n\t\t}\n\t>\n> = {\n\ttestnet: {\n\t\tnetwork: 'testnet',\n\t\t// On-chain ids default from the SDK package config; callers may\n\t\t// still override per-field. The URLs below are devstack-owned —\n\t\t// the SDK ships none.\n\t\tsystemObjectId: TESTNET_WALRUS_PACKAGE_CONFIG.systemObjectId,\n\t\tstakingPoolId: TESTNET_WALRUS_PACKAGE_CONFIG.stakingPoolId,\n\t\texchangeIds: TESTNET_WALRUS_PACKAGE_CONFIG.exchangeIds,\n\t\taggregatorUrl: 'https://aggregator.walrus-testnet.walrus.space',\n\t\tpublisherUrl: 'https://publisher.walrus-testnet.walrus.space',\n\t\tproxyUrl: 'https://aggregator.walrus-testnet.walrus.space',\n\t},\n\tmainnet: {\n\t\tnetwork: 'mainnet',\n\t\t// On-chain ids default from the SDK package config; callers may\n\t\t// still override per-field. Mainnet ships no `exchangeIds` in the\n\t\t// SDK config (testnet-only faucet exchange), so it stays absent.\n\t\tsystemObjectId: MAINNET_WALRUS_PACKAGE_CONFIG.systemObjectId,\n\t\tstakingPoolId: MAINNET_WALRUS_PACKAGE_CONFIG.stakingPoolId,\n\t\taggregatorUrl: 'https://aggregator.walrus.space',\n\t\tpublisherUrl: 'https://publisher.walrus.space',\n\t\tproxyUrl: 'https://aggregator.walrus.space',\n\t},\n\tdevnet: {\n\t\tnetwork: 'devnet',\n\t},\n};\n\n/** Synchronous factory-time validation + projection. Throws (NOT\n * Effect-fail) on missing required fields so misconfiguration trips\n * at the `defineDevstack` call site rather than at deferred\n * Layer.build time. Distilled-doc invariants 14 + 16. */\nexport const resolveKnownDeploymentOptions = (\n\topts: WalrusKnownDeploymentOptions,\n): KnownDeploymentBootResult => {\n\tconst reg = opts.network ? KNOWN_DEPLOYMENT_REGISTRY[opts.network] : undefined;\n\n\t// On-chain ids: caller override (`opts.*`) wins, else the registry\n\t// default sourced from the `@mysten/walrus` SDK package config.\n\t// Testnet/mainnet default from the SDK so only `nodes` is required;\n\t// devnet has no SDK record, so these stay required there.\n\tconst systemObjectId = expectNonEmptyString(opts.systemObjectId ?? reg?.systemObjectId, {\n\t\tfield: 'systemObjectId',\n\t\tmkError: ({ field }) =>\n\t\t\twalrusConfigError(\n\t\t\t\tfield,\n\t\t\t\t`walrusKnownDeployment: 'systemObjectId' is required (testnet/mainnet default from the @mysten/walrus SDK; pass it explicitly for devnet or networks without an SDK record)`,\n\t\t\t),\n\t});\n\n\tconst stakingPoolId = expectNonEmptyString(opts.stakingPoolId ?? reg?.stakingPoolId, {\n\t\tfield: 'stakingPoolId',\n\t\tmkError: ({ field }) =>\n\t\t\twalrusConfigError(\n\t\t\t\tfield,\n\t\t\t\t`walrusKnownDeployment: 'stakingPoolId' is required (testnet/mainnet default from the @mysten/walrus SDK; pass it explicitly for devnet or networks without an SDK record)`,\n\t\t\t),\n\t});\n\n\tconst nodes = opts.nodes;\n\tif (!nodes) {\n\t\t// Distilled-doc invariant 16: even when `network` is set, the\n\t\t// node committee must be explicit. The on-chain ids come from\n\t\t// the SDK package config, but the committee is dynamic — testnet\n\t\t// has 100+ nodes the SDK fetches at runtime, so we don't pin it.\n\t\tthrow walrusConfigError(\n\t\t\t'nodes',\n\t\t\t`walrusKnownDeployment: explicit 'nodes' committee is required — ` +\n\t\t\t\t`Walrus ${opts.network ?? 'custom'} has nodes fetched dynamically by the SDK`,\n\t\t\t`pass an empty array if you accept the SDK-driven committee lookup, ` +\n\t\t\t\t`or use walrus()/walrusFor(network).local({...}) for a local self-hosted cluster`,\n\t\t);\n\t}\n\n\tconst aggregatorUrl = opts.aggregatorUrl ?? reg?.aggregatorUrl ?? null;\n\tconst publisherUrl = opts.publisherUrl ?? reg?.publisherUrl ?? null;\n\tconst proxyUrl = opts.proxyUrl ?? reg?.proxyUrl ?? aggregatorUrl ?? null;\n\n\t// Invariant 15: surface null per individual URL when missing so the\n\t// plugin's projection can conditionally publish each tag. Previously\n\t// any single missing URL nullified all three, dropping user-supplied\n\t// values for the URLs they did provide.\n\treturn {\n\t\tmode: 'known' as const,\n\t\tnetwork: reg?.network ?? 'custom',\n\t\tsystemObjectId,\n\t\tstakingPoolId,\n\t\texchangeIds: opts.exchangeIds ?? reg?.exchangeIds ?? [],\n\t\tnodes,\n\t\tproxyUrl,\n\t\taggregatorUrl,\n\t\tpublisherUrl,\n\t};\n};\n\n/** \"Boot\" the known deployment. Purely synchronous projection inside\n * Effect.gen — no I/O, no Scope work. Surfaces as Effect for\n * uniformity with the local-cluster boot signature. */\nexport const bootKnownDeployment = (\n\topts: WalrusKnownDeploymentOptions,\n): Effect.Effect<KnownDeploymentBootResult, WalrusConfigError, Scope.Scope> =>\n\tEffect.try({\n\t\ttry: () => resolveKnownDeploymentOptions(opts),\n\t\t// `resolveKnownDeploymentOptions` throws our typed config error\n\t\t// shape. STYLE_GUIDE §2 forbids bare error casts; runtime-guard\n\t\t// the `_tag` so an unexpected synchronous throw (e.g. a future\n\t\t// helper that throws a stock `TypeError`) is wrapped instead of\n\t\t// silently mis-tagged as `WalrusConfigError`.\n\t\tcatch: (err): WalrusConfigError => {\n\t\t\tif (\n\t\t\t\ttypeof err === 'object' &&\n\t\t\t\terr !== null &&\n\t\t\t\t'_tag' in err &&\n\t\t\t\t(err as { readonly _tag?: unknown })._tag === 'WalrusConfigError'\n\t\t\t) {\n\t\t\t\treturn err as WalrusConfigError;\n\t\t\t}\n\t\t\treturn walrusConfigError(\n\t\t\t\t'unknown',\n\t\t\t\t`walrusKnownDeployment: unexpected non-typed throw inside resolveKnownDeploymentOptions: ${\n\t\t\t\t\terr instanceof Error ? err.message : String(err)\n\t\t\t\t}`,\n\t\t\t\tundefined,\n\t\t\t\terr,\n\t\t\t);\n\t\t},\n\t});\n"],"mappings":";;;;;;;;;;;AAiFA,MAAM,4BAaF;CACH,SAAS;EACR,SAAS;EA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"file":"known-deploy.mjs","names":[],"sources":["../../../../src/plugins/walrus/mode/known-deploy.ts"],"sourcesContent":["// Walrus mode — known deployment (testnet / mainnet / *-fork via\n// upstream translation).\n//\n// Distilled-doc reference (06-walrus.md §\"Lifecycle: Startup —\n// known deployment\"). Purely synchronous body — no ordered phases.\n// The factory validates required deployment fields and returns a\n// resolved value whose tags are eager `Layer.succeed(...)` constants.\n//\n// Distilled-doc invariants honored:\n// - 15: each of `proxyUrl / aggregatorUrl / publisherUrl / uploadRelayUrl` surfaces\n// INDEPENDENTLY. Encoded as `string | null` in the resolved\n// shape — a given field is null only when THAT specific URL\n// is unresolved (registry default + explicit override both\n// absent). The plugin's projection step publishes each tag\n// when its own URL is present; a missing publisher URL does\n// not suppress an available proxy/aggregator URL.\n// - 16: throw synchronously when `nodes` is missing for a\n// registered network. The on-chain ids\n// (`systemObjectId` / `stakingPoolId` / `exchangeIds`) ARE\n// stable and come from the `@mysten/walrus` SDK package config\n// — we default them from the SDK and let callers override.\n// Only the node committee stays explicit: testnet has 100+\n// nodes that the SDK fetches dynamically, so we don't pin them.\n\nimport { MAINNET_WALRUS_PACKAGE_CONFIG, TESTNET_WALRUS_PACKAGE_CONFIG } from '@mysten/walrus';\nimport { Effect, type Scope } from 'effect';\n\nimport { expectNonEmptyString } from '../../../substrate/runtime/config-validation.ts';\nimport { walrusConfigError, type WalrusConfigError } from '../errors.ts';\nimport type { WalrusStorageNode } from '../storage-nodes.ts';\n\n/** Known networks supported by the registry lookup. */\nexport type WalrusKnownNetwork = 'testnet' | 'mainnet' | 'devnet';\n\n/** Options for the known-deployment mode. */\nexport interface WalrusKnownDeploymentOptions {\n\t/** Network shortcut — looks up per-field defaults from a registry\n\t * baked into this package. */\n\treadonly network?: WalrusKnownNetwork;\n\t/** Per-field overrides for the on-chain ids. For `testnet`/`mainnet`\n\t * these default from the `@mysten/walrus` SDK package config, so\n\t * they're optional; for `devnet` (or when `network` is omitted)\n\t * `systemObjectId`/`stakingPoolId` are required. An explicit value\n\t * here always wins over the registry default. */\n\treadonly systemObjectId?: string;\n\treadonly stakingPoolId?: string;\n\treadonly exchangeIds?: ReadonlyArray<string>;\n\t/** Explicit storage-node committee. Required (throws if missing\n\t * even when `network` is set — distilled-doc invariant 16). */\n\treadonly nodes?: ReadonlyArray<WalrusStorageNode>;\n\treadonly aggregatorUrl?: string;\n\treadonly publisherUrl?: string;\n\treadonly uploadRelayUrl?: string;\n\treadonly proxyUrl?: string;\n}\n\n/** Resolved known-deployment boot artifacts. */\nexport interface KnownDeploymentBootResult {\n\treadonly mode: 'known';\n\t/** The known network's name (`testnet`/`mainnet`/`devnet`) — its stable\n\t * identity. A known remote deployment has no per-boot genesis digest, so\n\t * the network name IS its `chainId` for codegen/snapshot keying. */\n\treadonly network: string;\n\treadonly systemObjectId: string;\n\treadonly stakingPoolId: string;\n\treadonly exchangeIds: ReadonlyArray<string>;\n\treadonly nodes: ReadonlyArray<WalrusStorageNode>;\n\t/** Null only when the read/proxy URL itself is unresolved (no explicit\n\t * `proxyUrl` override, registry proxy URL, or aggregator URL). Surfaces\n\t * independently of `aggregatorUrl` / `publisherUrl` /\n\t * `uploadRelayUrl` — distilled-doc invariant 15. */\n\treadonly proxyUrl: string | null;\n\treadonly aggregatorUrl: string | null;\n\treadonly publisherUrl: string | null;\n\treadonly uploadRelayUrl: string | null;\n}\n\n/** Known-deployment registry — baked-in record per network. The\n * on-chain ids default from the `@mysten/walrus` SDK package config\n * (`{TESTNET,MAINNET}_WALRUS_PACKAGE_CONFIG`) so a caller only needs\n * to supply `nodes`; the aggregator/publisher/upload-relay/proxy URLs are\n * devstack-owned (the SDK ships none). Devnet has no canonical SDK\n * record today, so it keeps no id defaults. */\nconst KNOWN_DEPLOYMENT_REGISTRY: Readonly<\n\tRecord<\n\t\tWalrusKnownNetwork,\n\t\t{\n\t\t\treadonly network: string;\n\t\t\treadonly systemObjectId?: string;\n\t\t\treadonly stakingPoolId?: string;\n\t\t\treadonly exchangeIds?: ReadonlyArray<string>;\n\t\t\treadonly aggregatorUrl?: string;\n\t\t\treadonly publisherUrl?: string;\n\t\t\treadonly uploadRelayUrl?: string;\n\t\t\treadonly proxyUrl?: string;\n\t\t}\n\t>\n> = {\n\ttestnet: {\n\t\tnetwork: 'testnet',\n\t\t// On-chain ids default from the SDK package config; callers may\n\t\t// still override per-field. The URLs below are devstack-owned —\n\t\t// the SDK ships none.\n\t\tsystemObjectId: TESTNET_WALRUS_PACKAGE_CONFIG.systemObjectId,\n\t\tstakingPoolId: TESTNET_WALRUS_PACKAGE_CONFIG.stakingPoolId,\n\t\texchangeIds: TESTNET_WALRUS_PACKAGE_CONFIG.exchangeIds,\n\t\taggregatorUrl: 'https://aggregator.walrus-testnet.walrus.space',\n\t\tpublisherUrl: 'https://publisher.walrus-testnet.walrus.space',\n\t\tuploadRelayUrl: 'https://upload-relay.testnet.walrus.space',\n\t\tproxyUrl: 'https://aggregator.walrus-testnet.walrus.space',\n\t},\n\tmainnet: {\n\t\tnetwork: 'mainnet',\n\t\t// On-chain ids default from the SDK package config; callers may\n\t\t// still override per-field. Mainnet ships no `exchangeIds` in the\n\t\t// SDK config (testnet-only faucet exchange), so it stays absent.\n\t\tsystemObjectId: MAINNET_WALRUS_PACKAGE_CONFIG.systemObjectId,\n\t\tstakingPoolId: MAINNET_WALRUS_PACKAGE_CONFIG.stakingPoolId,\n\t\taggregatorUrl: 'https://aggregator.walrus.space',\n\t\tpublisherUrl: 'https://publisher.walrus.space',\n\t\tuploadRelayUrl: 'https://upload-relay.mainnet.walrus.space',\n\t\tproxyUrl: 'https://aggregator.walrus.space',\n\t},\n\tdevnet: {\n\t\tnetwork: 'devnet',\n\t},\n};\n\n/** Synchronous factory-time validation + projection. Throws (NOT\n * Effect-fail) on missing required fields so misconfiguration trips\n * at the `defineDevstack` call site rather than at deferred\n * Layer.build time. Distilled-doc invariants 14 + 16. */\nexport const resolveKnownDeploymentOptions = (\n\topts: WalrusKnownDeploymentOptions,\n): KnownDeploymentBootResult => {\n\tconst reg = opts.network ? KNOWN_DEPLOYMENT_REGISTRY[opts.network] : undefined;\n\n\t// On-chain ids: caller override (`opts.*`) wins, else the registry\n\t// default sourced from the `@mysten/walrus` SDK package config.\n\t// Testnet/mainnet default from the SDK so only `nodes` is required;\n\t// devnet has no SDK record, so these stay required there.\n\tconst systemObjectId = expectNonEmptyString(opts.systemObjectId ?? reg?.systemObjectId, {\n\t\tfield: 'systemObjectId',\n\t\tmkError: ({ field }) =>\n\t\t\twalrusConfigError(\n\t\t\t\tfield,\n\t\t\t\t`walrusKnownDeployment: 'systemObjectId' is required (testnet/mainnet default from the @mysten/walrus SDK; pass it explicitly for devnet or networks without an SDK record)`,\n\t\t\t),\n\t});\n\n\tconst stakingPoolId = expectNonEmptyString(opts.stakingPoolId ?? reg?.stakingPoolId, {\n\t\tfield: 'stakingPoolId',\n\t\tmkError: ({ field }) =>\n\t\t\twalrusConfigError(\n\t\t\t\tfield,\n\t\t\t\t`walrusKnownDeployment: 'stakingPoolId' is required (testnet/mainnet default from the @mysten/walrus SDK; pass it explicitly for devnet or networks without an SDK record)`,\n\t\t\t),\n\t});\n\n\tconst nodes = opts.nodes;\n\tif (!nodes) {\n\t\t// Distilled-doc invariant 16: even when `network` is set, the\n\t\t// node committee must be explicit. The on-chain ids come from\n\t\t// the SDK package config, but the committee is dynamic — testnet\n\t\t// has 100+ nodes the SDK fetches at runtime, so we don't pin it.\n\t\tthrow walrusConfigError(\n\t\t\t'nodes',\n\t\t\t`walrusKnownDeployment: explicit 'nodes' committee is required — ` +\n\t\t\t\t`Walrus ${opts.network ?? 'custom'} has nodes fetched dynamically by the SDK`,\n\t\t\t`pass an empty array if you accept the SDK-driven committee lookup, ` +\n\t\t\t\t`or use walrus()/walrusFor(network).local({...}) for a local self-hosted cluster`,\n\t\t);\n\t}\n\n\tconst aggregatorUrl = opts.aggregatorUrl ?? reg?.aggregatorUrl ?? null;\n\tconst publisherUrl = opts.publisherUrl ?? reg?.publisherUrl ?? null;\n\tconst uploadRelayUrl = opts.uploadRelayUrl ?? reg?.uploadRelayUrl ?? null;\n\tconst proxyUrl = opts.proxyUrl ?? reg?.proxyUrl ?? aggregatorUrl ?? null;\n\n\t// Invariant 15: surface null per individual URL when missing so the\n\t// plugin's projection can conditionally publish each tag. Previously\n\t// any single missing URL nullified all three, dropping user-supplied\n\t// values for the URLs they did provide.\n\treturn {\n\t\tmode: 'known' as const,\n\t\tnetwork: reg?.network ?? 'custom',\n\t\tsystemObjectId,\n\t\tstakingPoolId,\n\t\texchangeIds: opts.exchangeIds ?? reg?.exchangeIds ?? [],\n\t\tnodes,\n\t\tproxyUrl,\n\t\taggregatorUrl,\n\t\tpublisherUrl,\n\t\tuploadRelayUrl,\n\t};\n};\n\n/** \"Boot\" the known deployment. Purely synchronous projection inside\n * Effect.gen — no I/O, no Scope work. Surfaces as Effect for\n * uniformity with the local-cluster boot signature. */\nexport const bootKnownDeployment = (\n\topts: WalrusKnownDeploymentOptions,\n): Effect.Effect<KnownDeploymentBootResult, WalrusConfigError, Scope.Scope> =>\n\tEffect.try({\n\t\ttry: () => resolveKnownDeploymentOptions(opts),\n\t\t// `resolveKnownDeploymentOptions` throws our typed config error\n\t\t// shape. STYLE_GUIDE §2 forbids bare error casts; runtime-guard\n\t\t// the `_tag` so an unexpected synchronous throw (e.g. a future\n\t\t// helper that throws a stock `TypeError`) is wrapped instead of\n\t\t// silently mis-tagged as `WalrusConfigError`.\n\t\tcatch: (err): WalrusConfigError => {\n\t\t\tif (\n\t\t\t\ttypeof err === 'object' &&\n\t\t\t\terr !== null &&\n\t\t\t\t'_tag' in err &&\n\t\t\t\t(err as { readonly _tag?: unknown })._tag === 'WalrusConfigError'\n\t\t\t) {\n\t\t\t\treturn err as WalrusConfigError;\n\t\t\t}\n\t\t\treturn walrusConfigError(\n\t\t\t\t'unknown',\n\t\t\t\t`walrusKnownDeployment: unexpected non-typed throw inside resolveKnownDeploymentOptions: ${\n\t\t\t\t\terr instanceof Error ? err.message : String(err)\n\t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CAM7C,QAAQ,QAA2B;EAClC,IACC,OAAO,QAAQ,YACf,QAAQ,QACR,UAAU,OACT,IAAoC,SAAS,qBAE9C,OAAO;EAER,OAAO,kBACN,WACA,2FACC,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,KAEhD,KAAA,GACA,GACD;CACD;AACD,CAAC"}
@@ -34,14 +34,18 @@ interface WalrusLocalClusterOptions {
34
34
  /** Local app-facing publisher service. Defaults to enabled. Set
35
35
  * `false` to run storage nodes without the simple publish API. */
36
36
  readonly publisher?: boolean | WalrusLocalPublisherOptions;
37
+ /** Local app-facing upload relay service. Defaults to enabled. Set
38
+ * `false` to run storage nodes without the SDK upload relay API. */
39
+ readonly uploadRelay?: boolean | WalrusLocalUploadRelayOptions;
37
40
  }
38
41
  interface WalrusLocalServiceOptions {
39
42
  /** In-container port passed to the release service's
40
- * `--bind-address 0.0.0.0:<port>`. Defaults to the Walrus CLI's
41
- * publisher/aggregator port. */
43
+ * bind-address flag. Defaults to the service-specific release
44
+ * port: publisher/aggregator 31415, upload relay 3000. */
42
45
  readonly port?: number;
43
46
  }
44
47
  type WalrusLocalPublisherOptions = WalrusLocalServiceOptions;
48
+ type WalrusLocalUploadRelayOptions = WalrusLocalServiceOptions;
45
49
  //#endregion
46
50
  export { WalrusLocalClusterOptions, WalrusLocalPublisherOptions, WalrusLocalServiceOptions };
47
51
  //# sourceMappingURL=local-cluster.d.mts.map
@@ -8,7 +8,7 @@ import { resolveWalExchange } from "../wal-swap.mjs";
8
8
  import { makeWalFaucetStrategy, resolveWalCoinType, walPackageIdFromCoinType } from "../faucet-strategy.mjs";
9
9
  import { deployWalrusContracts } from "../deploy.mjs";
10
10
  import { resolveCargoImage } from "../bootstrap-assets/cargo-image.mjs";
11
- import { startWalrusClientServices } from "../client-services.mjs";
11
+ import { DEFAULT_WALRUS_CLIENT_SERVICE_PORT, DEFAULT_WALRUS_UPLOAD_RELAY_SERVICE_PORT, startWalrusClientServices } from "../client-services.mjs";
12
12
  import { Effect } from "effect";
13
13
  //#region src/plugins/walrus/mode/local-cluster.ts
14
14
  /** Synchronous factory-time validation. Throws (NOT Effect-fail) so
@@ -43,14 +43,15 @@ const expectOptionalPort = (value, field) => value === void 0 ? void 0 : expectP
43
43
  field,
44
44
  mkError: ({ field: f, message, hint }) => walrusConfigError(f, `walrusLocalCluster: ${f} ${message}`, hint)
45
45
  });
46
- const resolveLocalServiceBase = (value, fieldPrefix) => {
46
+ const resolveLocalServiceBase = (value, fieldPrefix, defaultPort) => {
47
47
  if (value === false) return null;
48
- return { port: expectOptionalPort((value === void 0 || value === true ? {} : value).port, `${fieldPrefix}.port`) ?? 31415 };
48
+ return { port: expectOptionalPort((value === void 0 || value === true ? {} : value).port, `${fieldPrefix}.port`) ?? defaultPort };
49
49
  };
50
50
  const resolveLocalServicesOptions = (opts) => {
51
51
  return {
52
- aggregator: resolveLocalServiceBase(opts.aggregator, "aggregator"),
53
- publisher: resolveLocalServiceBase(opts.publisher, "publisher")
52
+ aggregator: resolveLocalServiceBase(opts.aggregator, "aggregator", DEFAULT_WALRUS_CLIENT_SERVICE_PORT),
53
+ publisher: resolveLocalServiceBase(opts.publisher, "publisher", DEFAULT_WALRUS_CLIENT_SERVICE_PORT),
54
+ uploadRelay: resolveLocalServiceBase(opts.uploadRelay, "uploadRelay", DEFAULT_WALRUS_UPLOAD_RELAY_SERVICE_PORT)
54
55
  };
55
56
  };
56
57
  /** Boot the local cluster. Returns the resolved value the plugin
@@ -137,7 +138,8 @@ const bootLocalCluster = (deps, opts) => Effect.gen(function* () {
137
138
  }, `${walrusImage.tag}-${nodeImageScope}-node-${i}`));
138
139
  const clientServiceImages = yield* Effect.all({
139
140
  aggregator: opts.aggregator === null ? Effect.succeed(null) : resolveServiceImage("aggregator"),
140
- publisher: opts.publisher === null ? Effect.succeed(null) : resolveServiceImage("publisher")
141
+ publisher: opts.publisher === null ? Effect.succeed(null) : resolveServiceImage("publisher"),
142
+ uploadRelay: opts.uploadRelay === null ? Effect.succeed(null) : resolveServiceImage("upload-relay")
141
143
  });
142
144
  yield* setCurrentPluginPhase(`starting ${opts.nodeCount} Walrus storage node${opts.nodeCount === 1 ? "" : "s"}`);
143
145
  const { nodes } = yield* startStorageNodes(deps.runtime, {
@@ -164,7 +166,8 @@ const bootLocalCluster = (deps, opts) => Effect.gen(function* () {
164
166
  images: clientServiceImages,
165
167
  options: {
166
168
  aggregator: opts.aggregator,
167
- publisher: opts.publisher
169
+ publisher: opts.publisher,
170
+ uploadRelay: opts.uploadRelay
168
171
  },
169
172
  walrusNetworkName: deps.walrusNetworkName,
170
173
  suiNetworkName: deps.suiNetworkName,
@@ -1 +1 @@
1
- {"version":3,"file":"local-cluster.mjs","names":["brandContentHash"],"sources":["../../../../src/plugins/walrus/mode/local-cluster.ts"],"sourcesContent":["// Walrus mode — local cluster.\n//\n// Distilled-doc reference (06-walrus.md §\"Lifecycle: Startup —\n// local cluster\"). Eight ordered phases:\n//\n// 0. Yield deps (Sui, Identity, ChainProbe, faucet strategy opt).\n// 1. Image build — upstream cargo image (bootstrap asset) +\n// wrapper image (inline; content-addressed on\n// the upstream tag + suiVersion).\n// 1b. Docker network create — per-stack `/24` via\n// `Docker.networkCreate(networkName, {subnet})`.\n// 2. Deploy contracts — via `ArtifactPublisher`. The\n// publisher folds chainId into the cache\n// key; verify probes BOTH the on-disk\n// `deploy` file AND on-chain object\n// existence; produce runs the deploy\n// one-shot.\n// 3. Register committee — omitted entirely (no placeholder).\n// 4. Storage nodes — parallel boot of N storage-node containers.\n// 5. Exchange resolution — on-chain getObject + parse type.\n// Degrades to undefined on\n// OBJECT_NOT_FOUND.\n// 6. WAL faucet strategy register — opt-in when an exchange exists.\n// 7. Registries — package + endpoint + walrus-state.\n//\n// What this file owns: the dispatch shape + the typed options\n// surface + the synchronous factory-time validation.\n//\n// What this file delegates: container/Move heavy paths live in\n// `storage-nodes.ts`, `deploy.ts`, and the `ArtifactPublisher`\n// primitive.\n\nimport { Effect, FileSystem, Path, type Scope } from 'effect';\n\nimport type {\n\tArtifactPublishError,\n\tArtifactPublisher,\n} from '../../../primitives/artifact-publisher.ts';\nimport type { ChainProbe } from '../../../contracts/chain-probe.ts';\nimport type { ContainerRuntime } from '../../../contracts/container-runtime.ts';\nimport type { SuiProbeKey } from '../../sui/index.ts';\nimport { contentHash as brandContentHash } from '../../../substrate/brand.ts';\nimport { expectPort, expectPositiveInteger } from '../../../substrate/runtime/config-validation.ts';\nimport { setCurrentPluginPhase } from '../../../substrate/runtime/current-plugin.ts';\nimport { walrusConfigError, walrusPluginError, type WalrusError } from '../errors.ts';\nimport { WALRUS_MAX_NODE_COUNT } from '../routable.ts';\nimport type { WalrusStorageNode } from '../storage-nodes.ts';\nimport {\n\tDEFAULT_NODE_READY_TIMEOUT_MS,\n\tDEFAULT_CONTAINER_API_PORT,\n\tWALRUS_NODE_IP_BASE,\n\tcomputeCommitteeHostname,\n\tstartStorageNodes,\n} from '../storage-nodes.ts';\nimport { deployWalrusContracts, type CachedDeployState } from '../deploy.ts';\nimport {\n\tDEFAULT_SUI_VERSION,\n\tDEFAULT_WALRUS_REF,\n\tresolveCargoImage,\n} from '../bootstrap-assets/cargo-image.ts';\nimport {\n\tDEFAULT_WALRUS_CLIENT_SERVICE_PORT,\n\tstartWalrusClientServices,\n\ttype WalrusClientServices,\n} from '../client-services.ts';\nimport {\n\tmakeWalFaucetStrategy,\n\twalPackageIdFromCoinType,\n\tresolveWalCoinType,\n\ttype WalFaucetStrategy,\n} from '../faucet-strategy.ts';\nimport { resolveWalExchange, type WalExchangeHandle, type WalSwapSdk } from '../wal-swap.ts';\n\n/** Options for the local-cluster mode (06-walrus.md\n * §\"Configuration\"). */\nexport interface WalrusLocalClusterOptions {\n\t/** Engine row name + on-disk dir suffix + registry key.\n\t * Default `'walrus'`. */\n\treadonly name?: string;\n\t/** Number of storage-node containers. Must be `>= 1` (synchronous\n\t * factory-time guard). Default `1`. */\n\treadonly nodeCount?: number;\n\t/** Total shards distributed across the committee. Must be\n\t * `>= nodeCount`. Default `100` (distilled-doc default block). */\n\treadonly shards?: number;\n\t/** Pinned walrus release — drives the wrapper image build.\n\t * Default `'testnet-v1.49.1'`. */\n\treadonly version?: string;\n\t/** Sui release whose binary the wrapper image bakes (distilled-\n\t * doc invariant 24). Default `'devnet-v1.71.0'`. */\n\treadonly suiVersion?: string;\n\t/** Port each storage node binds inside the container. Default\n\t * 9185 (same as the router entrypoint — invariant 9). */\n\treadonly containerApiPort?: number;\n\t/** Walrus epoch length passed to `walrus-deploy --epoch-duration`.\n\t * Default `'24h'`. */\n\treadonly epochDuration?: string;\n\t/** Per-node TCP ready-probe timeout (ms). Defaults to\n\t * `DEFAULT_NODE_READY_TIMEOUT_MS`. */\n\treadonly readyTimeoutMs?: number;\n\t/** Local app-facing aggregator service. Defaults to enabled. Set\n\t * `false` to expose only storage-node routes. */\n\treadonly aggregator?: boolean | WalrusLocalServiceOptions;\n\t/** Local app-facing publisher service. Defaults to enabled. Set\n\t * `false` to run storage nodes without the simple publish API. */\n\treadonly publisher?: boolean | WalrusLocalPublisherOptions;\n}\n\nexport interface WalrusLocalServiceOptions {\n\t/** In-container port passed to the release service's\n\t * `--bind-address 0.0.0.0:<port>`. Defaults to the Walrus CLI's\n\t * publisher/aggregator port. */\n\treadonly port?: number;\n}\n\nexport type WalrusLocalPublisherOptions = WalrusLocalServiceOptions;\n\n/** Resolved local-cluster boot artifacts. */\nexport interface LocalClusterBootResult {\n\treadonly mode: 'local';\n\treadonly deploy: CachedDeployState;\n\treadonly walrusPackageId: string;\n\treadonly walPackageId: string;\n\treadonly nodes: ReadonlyArray<WalrusStorageNode>;\n\treadonly exchangeObjectId: string | undefined;\n\treadonly exchange: WalExchangeHandle | null;\n\treadonly clientServices: WalrusClientServices;\n\t/** WAL faucet strategy — present only when the local cluster has a\n\t * non-empty exchange object. The barrel registers this onto the\n\t * `coinType:<fullCoinType>` strategy contributor decl. `null`\n\t * otherwise. */\n\treadonly walFaucetStrategy: WalFaucetStrategy | null;\n\treadonly walCoinType: string;\n}\n\n/** Defaults applied to options. */\nexport interface ResolvedLocalClusterOptions {\n\treadonly name: string;\n\treadonly nodeCount: number;\n\treadonly shards: number;\n\treadonly version: string;\n\treadonly suiVersion: string;\n\treadonly containerApiPort: number;\n\treadonly epochDuration: string;\n\treadonly readyTimeoutMs: number;\n\treadonly aggregator: ResolvedWalrusLocalServiceOptions | null;\n\treadonly publisher: ResolvedWalrusLocalPublisherOptions | null;\n}\n\nexport interface ResolvedWalrusLocalServiceOptions {\n\treadonly port: number;\n}\n\nexport type ResolvedWalrusLocalPublisherOptions = ResolvedWalrusLocalServiceOptions;\n\n/** Synchronous factory-time validation. Throws (NOT Effect-fail) so\n * misconfiguration trips at the `defineDevstack` call site rather\n * than at deferred Layer.build time. Distilled-doc invariant 11. */\nexport const resolveLocalClusterOptions = (\n\topts: WalrusLocalClusterOptions,\n): ResolvedLocalClusterOptions => {\n\tconst nodeCount = expectPositiveInteger(opts.nodeCount ?? 1, {\n\t\tfield: 'nodeCount',\n\t\tmkError: ({ field, message, hint }) =>\n\t\t\twalrusConfigError(\n\t\t\t\tfield,\n\t\t\t\t`walrusLocalCluster: nodeCount must be >= 1 (got ${String(opts.nodeCount ?? 1)})`,\n\t\t\t\thint ?? message,\n\t\t\t),\n\t\thint: 'set nodeCount to a positive integer (default 1)',\n\t});\n\tif (nodeCount > WALRUS_MAX_NODE_COUNT) {\n\t\tthrow walrusConfigError(\n\t\t\t'nodeCount',\n\t\t\t`walrusLocalCluster: nodeCount (${nodeCount}) exceeds the maximum ${WALRUS_MAX_NODE_COUNT} ` +\n\t\t\t\t`pre-declared Traefik entrypoints (walrus-node-0..${WALRUS_MAX_NODE_COUNT - 1}).`,\n\t\t\t`reduce nodeCount or raise WALRUS_MAX_NODE_COUNT in plugins/walrus/routable.ts`,\n\t\t);\n\t}\n\tconst shards = expectPositiveInteger(opts.shards ?? 100, {\n\t\tfield: 'shards',\n\t\tmkError: ({ field, message, hint }) =>\n\t\t\twalrusConfigError(\n\t\t\t\tfield,\n\t\t\t\t`walrusLocalCluster: shards must be a positive integer (got ${String(opts.shards ?? 100)})`,\n\t\t\t\thint ?? message,\n\t\t\t),\n\t\thint: 'set shards to a positive integer (default 100)',\n\t});\n\tif (shards < nodeCount) {\n\t\tthrow walrusConfigError(\n\t\t\t'shards',\n\t\t\t`walrusLocalCluster: shards (${shards}) must be >= nodeCount (${nodeCount})`,\n\t\t\t`set shards >= ${nodeCount} (default 100)`,\n\t\t);\n\t}\n\treturn {\n\t\tname: opts.name ?? 'walrus',\n\t\tnodeCount,\n\t\tshards,\n\t\tversion: opts.version ?? DEFAULT_WALRUS_REF,\n\t\tsuiVersion: opts.suiVersion ?? DEFAULT_SUI_VERSION,\n\t\tcontainerApiPort: opts.containerApiPort ?? DEFAULT_CONTAINER_API_PORT,\n\t\tepochDuration: opts.epochDuration ?? '24h',\n\t\treadyTimeoutMs: opts.readyTimeoutMs ?? DEFAULT_NODE_READY_TIMEOUT_MS,\n\t\t...resolveLocalServicesOptions(opts),\n\t};\n};\n\nconst expectOptionalPort = (value: number | undefined, field: string): number | undefined =>\n\tvalue === undefined\n\t\t? undefined\n\t\t: expectPort(value, {\n\t\t\t\tfield,\n\t\t\t\tmkError: ({ field: f, message, hint }) =>\n\t\t\t\t\twalrusConfigError(f, `walrusLocalCluster: ${f} ${message}`, hint),\n\t\t\t});\n\nconst resolveLocalServiceBase = (\n\tvalue: boolean | WalrusLocalServiceOptions | undefined,\n\tfieldPrefix: 'aggregator' | 'publisher',\n): ResolvedWalrusLocalServiceOptions | null => {\n\tif (value === false) return null;\n\tconst authored = value === undefined || value === true ? {} : value;\n\treturn {\n\t\tport:\n\t\t\texpectOptionalPort(authored.port, `${fieldPrefix}.port`) ??\n\t\t\tDEFAULT_WALRUS_CLIENT_SERVICE_PORT,\n\t};\n};\n\nconst resolveLocalServicesOptions = (\n\topts: WalrusLocalClusterOptions,\n): Pick<ResolvedLocalClusterOptions, 'aggregator' | 'publisher'> => {\n\treturn {\n\t\taggregator: resolveLocalServiceBase(opts.aggregator, 'aggregator'),\n\t\tpublisher: resolveLocalServiceBase(opts.publisher, 'publisher'),\n\t};\n};\n\n/** Dependencies the local service consumes at acquire-time. */\nexport interface LocalClusterDeps {\n\treadonly runtime: ContainerRuntime;\n\treadonly publisher: ArtifactPublisher;\n\treadonly probe: ChainProbe<SuiProbeKey>;\n\treadonly suiSdk: WalSwapSdk;\n\treadonly suiChainId: string;\n\treadonly suiRpcUrlInNetwork: string;\n\treadonly walrusFaucetUrlInNetwork: string;\n\treadonly waitForFundsReady: Effect.Effect<void, unknown>;\n\treadonly app: string;\n\treadonly stack: string;\n\t/** Pre-allocated /24 prefix from `subnetForStack`. */\n\treadonly subnetPrefix: string;\n\treadonly walrusNetworkName: string;\n\treadonly suiNetworkName: string;\n\treadonly deployHostMountPath: string;\n\t/** On-disk per-stack root from `StackPathsService.stackRoot`. The\n\t * walrus bind-mount is computed off this; `deployHostMountPath`\n\t * MUST live under it. */\n\treadonly stackRoot: string;\n}\n\n/** Boot the local cluster. Returns the resolved value the plugin\n * projects onto its tags.\n *\n * Steps:\n * - Image build — `resolveCargoImage` (bootstrap asset).\n * Honors `WALRUS_CARGO_IMAGE_OVERRIDE` for the pre-baked path.\n * - Docker network ensure — `runtime.ensureNetwork(walrusNet)`.\n * The sui network is owned by the sui plugin; we attach to it\n * as a secondary network on each storage node.\n * - Deploy contracts — `deployWalrusContracts` dispatches through\n * the artifact publisher primitive; the produce body runs the walrus deploy\n * one-shot.\n * - Storage nodes — parallel boot via `startStorageNodes`.\n * - WAL faucet strategy — constructed if `state.exchangeObject`\n * exists. Surfaced on the boot result; the barrel registers\n * the contributor decl.\n *\n * Per-step failures surface as `WalrusPluginError` with the phase\n * vocabulary from `errors.ts`; artifact publisher failures pass through as\n * `ArtifactPublishError`. The plugin narration vocabulary anchors\n * on these phase tags.\n */\nexport const bootLocalCluster = (\n\tdeps: LocalClusterDeps,\n\topts: ResolvedLocalClusterOptions,\n): Effect.Effect<\n\tLocalClusterBootResult,\n\tWalrusError | ArtifactPublishError,\n\tScope.Scope | FileSystem.FileSystem | Path.Path\n> =>\n\tEffect.gen(function* () {\n\t\t// ---- cargo image (bootstrap asset) -----------------------\n\t\t// The cargo image is content-addressed; the resolver owns the\n\t\t// cache check + the registry-tag override fast path.\n\t\tyield* setCurrentPluginPhase(`resolving Walrus image ${opts.version}`);\n\t\tconst walrusImage = yield* resolveCargoImage(deps.runtime, {\n\t\t\twalrusRef: opts.version,\n\t\t\tsuiVersion: opts.suiVersion,\n\t\t\towner: { app: deps.app, stack: deps.stack },\n\t\t});\n\n\t\t// ---- docker network ensure ------------------------------\n\t\tyield* setCurrentPluginPhase(`ensuring Walrus network ${deps.walrusNetworkName}`);\n\t\tyield* deps.runtime\n\t\t\t.ensureNetwork({\n\t\t\t\tname: deps.walrusNetworkName,\n\t\t\t\tapp: deps.app,\n\t\t\t\tstack: deps.stack,\n\t\t\t})\n\t\t\t.pipe(\n\t\t\t\tEffect.catch((cause) =>\n\t\t\t\t\tEffect.fail(\n\t\t\t\t\t\twalrusPluginError(\n\t\t\t\t\t\t\t'cluster-network',\n\t\t\t\t\t\t\t`walrus: ensureNetwork('${deps.walrusNetworkName}') failed: ${cause.reason}: ${cause.detail}`,\n\t\t\t\t\t\t\t{ cause },\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\n\t\t// ---- deploy via ArtifactPublisher ----------------\n\t\t// The deploy one-shot needs the walrus image + sui network so it\n\t\t// can dial the per-stack sui RPC + faucet over docker DNS.\n\t\t//\n\t\t// Per-node committee hostnames are Docker-network aliases, because the\n\t\t// real Rust publisher/aggregator read these public_host values from chain\n\t\t// and dial storage nodes from inside the Walrus network. Router-facing\n\t\t// `.localhost` hostnames are still produced by `startStorageNodes` for\n\t\t// devstack's public diagnostic URLs.\n\t\tconst committeeHosts = Array.from({ length: opts.nodeCount }, (_, i) =>\n\t\t\tcomputeCommitteeHostname(i),\n\t\t).join(',');\n\t\tconst listeningIps = Array.from(\n\t\t\t{ length: opts.nodeCount },\n\t\t\t(_, i) => `${deps.subnetPrefix}.${WALRUS_NODE_IP_BASE + i}`,\n\t\t).join(',');\n\n\t\tyield* setCurrentPluginPhase(\n\t\t\t`deploying Walrus contracts (${opts.nodeCount} node${opts.nodeCount === 1 ? '' : 's'}, ${opts.shards} shards)`,\n\t\t);\n\t\tconst { state } = yield* deployWalrusContracts(deps.publisher, deps.probe, deps.runtime, {\n\t\t\twalrusName: opts.name,\n\t\t\tchainId: deps.suiChainId,\n\t\t\tcontentHash: brandContentHash(\n\t\t\t\t`walrus|${opts.version}|${opts.suiVersion}|${opts.nodeCount}|${opts.shards}|${opts.epochDuration}|committee=${committeeHosts}|listen=${listeningIps}`,\n\t\t\t),\n\t\t\toutputDirHostPath: deps.deployHostMountPath,\n\t\t\tstackRoot: deps.stackRoot,\n\t\t\tsuiRpcUrlInNetwork: deps.suiRpcUrlInNetwork,\n\t\t\twalrusFaucetUrlInNetwork: deps.walrusFaucetUrlInNetwork,\n\t\t\twaitForFundsReady: deps.waitForFundsReady,\n\t\t\tcommitteeSize: opts.nodeCount,\n\t\t\tshards: opts.shards,\n\t\t\tepochDuration: opts.epochDuration,\n\t\t\tpublicHostsCsv: committeeHosts,\n\t\t\tlisteningIpsCsv: listeningIps,\n\t\t\twalrusImage,\n\t\t\tsuiNetworkName: deps.suiNetworkName,\n\t\t});\n\t\tconst deployConfigHash = [\n\t\t\t'walrus-deploy',\n\t\t\tstate.walrusPackageId,\n\t\t\tstate.systemObject,\n\t\t\tstate.stakingObject,\n\t\t\tstate.exchangeObject ?? 'no-exchange',\n\t\t].join('|');\n\n\t\t// Per-node image tags. Each storage node runs under its OWN tag (a cheap\n\t\t// re-tag of the one content-cached cargo build) so its committed writable\n\t\t// layer — the RocksDB holding that node's slivers — promotes to a DISTINCT\n\t\t// image on snapshot restore. A single shared tag would make the restore\n\t\t// image-promote collapse all N committed layers onto one tag\n\t\t// (last-write-wins): N-1 nodes boot on the wrong layer and every\n\t\t// pre-snapshot blob is orphaned. The tag is scoped by the deployed\n\t\t// `walrusPackageId` — stable across boot1 -> restore -> boot2 (the deploy\n\t\t// cache reuses the same id, so the restore's promote target matches what\n\t\t// boot2 requests), but DISTINCT per fresh deployment, so a later cold boot\n\t\t// on a new chain never inherits a prior run's committed node layers (which\n\t\t// carry a stale committee and would reject writes). The base `walrusImage`\n\t\t// (shared) still backs the transient deploy one-shot (`--rm`, unsnapshotted).\n\t\tconst nodeImageScope = state.walrusPackageId.replace(/^0x/, '').slice(0, 12);\n\t\tconst resolveServiceImage = (role: 'aggregator' | 'publisher') =>\n\t\t\tresolveCargoImage(\n\t\t\t\tdeps.runtime,\n\t\t\t\t{\n\t\t\t\t\twalrusRef: opts.version,\n\t\t\t\t\tsuiVersion: opts.suiVersion,\n\t\t\t\t\towner: { app: deps.app, stack: deps.stack },\n\t\t\t\t},\n\t\t\t\t`${walrusImage.tag}-${nodeImageScope}-${role}`,\n\t\t\t);\n\t\tconst nodeImages = yield* Effect.forEach(\n\t\t\tArray.from({ length: opts.nodeCount }, (_, i) => i),\n\t\t\t(i) =>\n\t\t\t\tresolveCargoImage(\n\t\t\t\t\tdeps.runtime,\n\t\t\t\t\t{\n\t\t\t\t\t\twalrusRef: opts.version,\n\t\t\t\t\t\tsuiVersion: opts.suiVersion,\n\t\t\t\t\t\towner: { app: deps.app, stack: deps.stack },\n\t\t\t\t\t},\n\t\t\t\t\t`${walrusImage.tag}-${nodeImageScope}-node-${i}`,\n\t\t\t\t),\n\t\t);\n\t\tconst clientServiceImages = yield* Effect.all({\n\t\t\taggregator:\n\t\t\t\topts.aggregator === null ? Effect.succeed(null) : resolveServiceImage('aggregator'),\n\t\t\tpublisher: opts.publisher === null ? Effect.succeed(null) : resolveServiceImage('publisher'),\n\t\t});\n\n\t\t// ---- storage nodes — parallel boot ----------------------\n\t\tyield* setCurrentPluginPhase(\n\t\t\t`starting ${opts.nodeCount} Walrus storage node${opts.nodeCount === 1 ? '' : 's'}`,\n\t\t);\n\t\tconst { nodes } = yield* startStorageNodes(deps.runtime, {\n\t\t\tapp: deps.app,\n\t\t\tstack: deps.stack,\n\t\t\twalrusName: opts.name,\n\t\t\timages: nodeImages,\n\t\t\tnodeCount: opts.nodeCount,\n\t\t\tsubnetPrefix: deps.subnetPrefix,\n\t\t\tcontainerApiPort: opts.containerApiPort,\n\t\t\twalrusNetworkName: deps.walrusNetworkName,\n\t\t\tsuiNetworkName: deps.suiNetworkName,\n\t\t\tdeployHostMountPath: deps.deployHostMountPath,\n\t\t\tstackRoot: deps.stackRoot,\n\t\t\tdeployConfigHash,\n\t\t\treadyTimeoutMs: opts.readyTimeoutMs,\n\t\t});\n\n\t\t// `nodeCount >= 1` is enforced synchronously already; this is\n\t\t// defense-in-depth.\n\t\tif (nodes.length === 0) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\twalrusPluginError('storage-node', 'walrus: at least one storage node is required'),\n\t\t\t);\n\t\t}\n\n\t\t// ---- app-facing Rust publisher / aggregator services ----\n\t\tyield* setCurrentPluginPhase('starting Walrus client services');\n\t\tconst clientServices = yield* startWalrusClientServices(deps.runtime, {\n\t\t\tapp: deps.app,\n\t\t\tstack: deps.stack,\n\t\t\twalrusName: opts.name,\n\t\t\timages: clientServiceImages,\n\t\t\toptions: {\n\t\t\t\taggregator: opts.aggregator,\n\t\t\t\tpublisher: opts.publisher,\n\t\t\t},\n\t\t\twalrusNetworkName: deps.walrusNetworkName,\n\t\t\tsuiNetworkName: deps.suiNetworkName,\n\t\t\tdeployHostMountPath: deps.deployHostMountPath,\n\t\t\tstackRoot: deps.stackRoot,\n\t\t\tdeployConfigHash,\n\t\t\tsuiRpcUrlInNetwork: deps.suiRpcUrlInNetwork,\n\t\t\treadyTimeoutMs: opts.readyTimeoutMs,\n\t\t});\n\n\t\t// ---- exchange resolution + WAL funding strategy ------\n\t\t// Register a `coinType:<fullCoinType>` strategy that swaps the\n\t\t// requesting account's SUI into WAL on demand. Accounts opt in via\n\t\t// their normal `funding` list.\n\t\tyield* setCurrentPluginPhase('resolving WAL exchange');\n\t\tconst exchange = yield* resolveWalExchange(deps.probe, state.exchangeObject);\n\t\tconst walFaucetStrategy: WalFaucetStrategy | null = exchange\n\t\t\t? makeWalFaucetStrategy({\n\t\t\t\t\texchange,\n\t\t\t\t\tsdk: deps.suiSdk,\n\t\t\t\t})\n\t\t\t: null;\n\t\tconst resolvedWalCoinType = yield* resolveWalCoinType({\n\t\t\tprobe: deps.probe,\n\t\t\ttreasuryObjectId: state.treasuryObject,\n\t\t\tdeployPackageId: state.walrusPackageId,\n\t\t\trequireTreasuryObject: exchange !== null,\n\t\t});\n\t\tconst resolvedWalPackageId = walPackageIdFromCoinType(resolvedWalCoinType);\n\n\t\treturn {\n\t\t\tmode: 'local' as const,\n\t\t\tdeploy: state,\n\t\t\twalrusPackageId: state.walrusPackageId,\n\t\t\twalPackageId: resolvedWalPackageId,\n\t\t\tnodes,\n\t\t\texchangeObjectId: state.exchangeObject,\n\t\t\texchange,\n\t\t\tclientServices,\n\t\t\twalFaucetStrategy,\n\t\t\twalCoinType: resolvedWalCoinType,\n\t\t};\n\t});\n"],"mappings":";;;;;;;;;;;;;;;;AA8JA,MAAa,8BACZ,SACiC;CACjC,MAAM,YAAY,sBAAsB,KAAK,aAAa,GAAG;EAC5D,OAAO;EACP,UAAU,EAAE,OAAO,SAAS,WAC3B,kBACC,OACA,mDAAmD,OAAO,KAAK,aAAa,CAAC,EAAE,IAC/E,QAAQ,OACT;EACD,MAAM;CACP,CAAC;CACD,IAAI,YAAA,GACH,MAAM,kBACL,aACA,kCAAkC,UAAU,+EAE5C,+EACD;CAED,MAAM,SAAS,sBAAsB,KAAK,UAAU,KAAK;EACxD,OAAO;EACP,UAAU,EAAE,OAAO,SAAS,WAC3B,kBACC,OACA,8DAA8D,OAAO,KAAK,UAAU,GAAG,EAAE,IACzF,QAAQ,OACT;EACD,MAAM;CACP,CAAC;CACD,IAAI,SAAS,WACZ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AC1B,WAAW,KAAK;EAChB;EACA,oBAAoB,KAAK;EACzB,gBAAgB,KAAK;CACtB,CAAC;CAMD,OAAO,sBAAsB,wBAAwB;CACrD,MAAM,WAAW,OAAO,mBAAmB,KAAK,OAAO,MAAM,cAAc;CAC3E,MAAM,oBAA8C,WACjD,sBAAsB;EACtB;EACA,KAAK,KAAK;CACX,CAAC,IACA;CACH,MAAM,sBAAsB,OAAO,mBAAmB;EACrD,OAAO,KAAK;EACZ,kBAAkB,MAAM;EACxB,iBAAiB,MAAM;EACvB,uBAAuB,aAAa;CACrC,CAAC;CACD,MAAM,uBAAuB,yBAAyB,mBAAmB;CAEzE,OAAO;EACN,MAAM;EACN,QAAQ;EACR,iBAAiB,MAAM;EACvB,cAAc;EACd;EACA,kBAAkB,MAAM;EACxB;EACA;EACA;EACA,aAAa;CACd;AACD,CAAC"}
1
+ {"version":3,"file":"local-cluster.mjs","names":["brandContentHash"],"sources":["../../../../src/plugins/walrus/mode/local-cluster.ts"],"sourcesContent":["// Walrus mode — local cluster.\n//\n// Distilled-doc reference (06-walrus.md §\"Lifecycle: Startup —\n// local cluster\"). Eight ordered phases:\n//\n// 0. Yield deps (Sui, Identity, ChainProbe, faucet strategy opt).\n// 1. Image build — upstream cargo image (bootstrap asset) +\n// wrapper image (inline; content-addressed on\n// the upstream tag + suiVersion).\n// 1b. Docker network create — per-stack `/24` via\n// `Docker.networkCreate(networkName, {subnet})`.\n// 2. Deploy contracts — via `ArtifactPublisher`. The\n// publisher folds chainId into the cache\n// key; verify probes BOTH the on-disk\n// `deploy` file AND on-chain object\n// existence; produce runs the deploy\n// one-shot.\n// 3. Register committee — omitted entirely (no placeholder).\n// 4. Storage nodes — parallel boot of N storage-node containers.\n// 5. Exchange resolution — on-chain getObject + parse type.\n// Degrades to undefined on\n// OBJECT_NOT_FOUND.\n// 6. WAL faucet strategy register — opt-in when an exchange exists.\n// 7. Registries — package + endpoint + walrus-state.\n//\n// What this file owns: the dispatch shape + the typed options\n// surface + the synchronous factory-time validation.\n//\n// What this file delegates: container/Move heavy paths live in\n// `storage-nodes.ts`, `deploy.ts`, and the `ArtifactPublisher`\n// primitive.\n\nimport { Effect, FileSystem, Path, type Scope } from 'effect';\n\nimport type {\n\tArtifactPublishError,\n\tArtifactPublisher,\n} from '../../../primitives/artifact-publisher.ts';\nimport type { ChainProbe } from '../../../contracts/chain-probe.ts';\nimport type { ContainerRuntime } from '../../../contracts/container-runtime.ts';\nimport type { SuiProbeKey } from '../../sui/index.ts';\nimport { contentHash as brandContentHash } from '../../../substrate/brand.ts';\nimport { expectPort, expectPositiveInteger } from '../../../substrate/runtime/config-validation.ts';\nimport { setCurrentPluginPhase } from '../../../substrate/runtime/current-plugin.ts';\nimport { walrusConfigError, walrusPluginError, type WalrusError } from '../errors.ts';\nimport { WALRUS_MAX_NODE_COUNT } from '../routable.ts';\nimport type { WalrusStorageNode } from '../storage-nodes.ts';\nimport {\n\tDEFAULT_NODE_READY_TIMEOUT_MS,\n\tDEFAULT_CONTAINER_API_PORT,\n\tWALRUS_NODE_IP_BASE,\n\tcomputeCommitteeHostname,\n\tstartStorageNodes,\n} from '../storage-nodes.ts';\nimport { deployWalrusContracts, type CachedDeployState } from '../deploy.ts';\nimport {\n\tDEFAULT_SUI_VERSION,\n\tDEFAULT_WALRUS_REF,\n\tresolveCargoImage,\n} from '../bootstrap-assets/cargo-image.ts';\nimport {\n\tDEFAULT_WALRUS_CLIENT_SERVICE_PORT,\n\tDEFAULT_WALRUS_UPLOAD_RELAY_SERVICE_PORT,\n\tstartWalrusClientServices,\n\ttype WalrusClientServices,\n\ttype WalrusClientServiceRole,\n} from '../client-services.ts';\nimport {\n\tmakeWalFaucetStrategy,\n\twalPackageIdFromCoinType,\n\tresolveWalCoinType,\n\ttype WalFaucetStrategy,\n} from '../faucet-strategy.ts';\nimport { resolveWalExchange, type WalExchangeHandle, type WalSwapSdk } from '../wal-swap.ts';\n\n/** Options for the local-cluster mode (06-walrus.md\n * §\"Configuration\"). */\nexport interface WalrusLocalClusterOptions {\n\t/** Engine row name + on-disk dir suffix + registry key.\n\t * Default `'walrus'`. */\n\treadonly name?: string;\n\t/** Number of storage-node containers. Must be `>= 1` (synchronous\n\t * factory-time guard). Default `1`. */\n\treadonly nodeCount?: number;\n\t/** Total shards distributed across the committee. Must be\n\t * `>= nodeCount`. Default `100` (distilled-doc default block). */\n\treadonly shards?: number;\n\t/** Pinned walrus release — drives the wrapper image build.\n\t * Default `'testnet-v1.49.1'`. */\n\treadonly version?: string;\n\t/** Sui release whose binary the wrapper image bakes (distilled-\n\t * doc invariant 24). Default `'devnet-v1.71.0'`. */\n\treadonly suiVersion?: string;\n\t/** Port each storage node binds inside the container. Default\n\t * 9185 (same as the router entrypoint — invariant 9). */\n\treadonly containerApiPort?: number;\n\t/** Walrus epoch length passed to `walrus-deploy --epoch-duration`.\n\t * Default `'24h'`. */\n\treadonly epochDuration?: string;\n\t/** Per-node TCP ready-probe timeout (ms). Defaults to\n\t * `DEFAULT_NODE_READY_TIMEOUT_MS`. */\n\treadonly readyTimeoutMs?: number;\n\t/** Local app-facing aggregator service. Defaults to enabled. Set\n\t * `false` to expose only storage-node routes. */\n\treadonly aggregator?: boolean | WalrusLocalServiceOptions;\n\t/** Local app-facing publisher service. Defaults to enabled. Set\n\t * `false` to run storage nodes without the simple publish API. */\n\treadonly publisher?: boolean | WalrusLocalPublisherOptions;\n\t/** Local app-facing upload relay service. Defaults to enabled. Set\n\t * `false` to run storage nodes without the SDK upload relay API. */\n\treadonly uploadRelay?: boolean | WalrusLocalUploadRelayOptions;\n}\n\nexport interface WalrusLocalServiceOptions {\n\t/** In-container port passed to the release service's\n\t * bind-address flag. Defaults to the service-specific release\n\t * port: publisher/aggregator 31415, upload relay 3000. */\n\treadonly port?: number;\n}\n\nexport type WalrusLocalPublisherOptions = WalrusLocalServiceOptions;\nexport type WalrusLocalUploadRelayOptions = WalrusLocalServiceOptions;\n\n/** Resolved local-cluster boot artifacts. */\nexport interface LocalClusterBootResult {\n\treadonly mode: 'local';\n\treadonly deploy: CachedDeployState;\n\treadonly walrusPackageId: string;\n\treadonly walPackageId: string;\n\treadonly nodes: ReadonlyArray<WalrusStorageNode>;\n\treadonly exchangeObjectId: string | undefined;\n\treadonly exchange: WalExchangeHandle | null;\n\treadonly clientServices: WalrusClientServices;\n\t/** WAL faucet strategy — present only when the local cluster has a\n\t * non-empty exchange object. The barrel registers this onto the\n\t * `coinType:<fullCoinType>` strategy contributor decl. `null`\n\t * otherwise. */\n\treadonly walFaucetStrategy: WalFaucetStrategy | null;\n\treadonly walCoinType: string;\n}\n\n/** Defaults applied to options. */\nexport interface ResolvedLocalClusterOptions {\n\treadonly name: string;\n\treadonly nodeCount: number;\n\treadonly shards: number;\n\treadonly version: string;\n\treadonly suiVersion: string;\n\treadonly containerApiPort: number;\n\treadonly epochDuration: string;\n\treadonly readyTimeoutMs: number;\n\treadonly aggregator: ResolvedWalrusLocalServiceOptions | null;\n\treadonly publisher: ResolvedWalrusLocalPublisherOptions | null;\n\treadonly uploadRelay: ResolvedWalrusLocalUploadRelayOptions | null;\n}\n\nexport interface ResolvedWalrusLocalServiceOptions {\n\treadonly port: number;\n}\n\nexport type ResolvedWalrusLocalPublisherOptions = ResolvedWalrusLocalServiceOptions;\nexport type ResolvedWalrusLocalUploadRelayOptions = ResolvedWalrusLocalServiceOptions;\n\n/** Synchronous factory-time validation. Throws (NOT Effect-fail) so\n * misconfiguration trips at the `defineDevstack` call site rather\n * than at deferred Layer.build time. Distilled-doc invariant 11. */\nexport const resolveLocalClusterOptions = (\n\topts: WalrusLocalClusterOptions,\n): ResolvedLocalClusterOptions => {\n\tconst nodeCount = expectPositiveInteger(opts.nodeCount ?? 1, {\n\t\tfield: 'nodeCount',\n\t\tmkError: ({ field, message, hint }) =>\n\t\t\twalrusConfigError(\n\t\t\t\tfield,\n\t\t\t\t`walrusLocalCluster: nodeCount must be >= 1 (got ${String(opts.nodeCount ?? 1)})`,\n\t\t\t\thint ?? message,\n\t\t\t),\n\t\thint: 'set nodeCount to a positive integer (default 1)',\n\t});\n\tif (nodeCount > WALRUS_MAX_NODE_COUNT) {\n\t\tthrow walrusConfigError(\n\t\t\t'nodeCount',\n\t\t\t`walrusLocalCluster: nodeCount (${nodeCount}) exceeds the maximum ${WALRUS_MAX_NODE_COUNT} ` +\n\t\t\t\t`pre-declared Traefik entrypoints (walrus-node-0..${WALRUS_MAX_NODE_COUNT - 1}).`,\n\t\t\t`reduce nodeCount or raise WALRUS_MAX_NODE_COUNT in plugins/walrus/routable.ts`,\n\t\t);\n\t}\n\tconst shards = expectPositiveInteger(opts.shards ?? 100, {\n\t\tfield: 'shards',\n\t\tmkError: ({ field, message, hint }) =>\n\t\t\twalrusConfigError(\n\t\t\t\tfield,\n\t\t\t\t`walrusLocalCluster: shards must be a positive integer (got ${String(opts.shards ?? 100)})`,\n\t\t\t\thint ?? message,\n\t\t\t),\n\t\thint: 'set shards to a positive integer (default 100)',\n\t});\n\tif (shards < nodeCount) {\n\t\tthrow walrusConfigError(\n\t\t\t'shards',\n\t\t\t`walrusLocalCluster: shards (${shards}) must be >= nodeCount (${nodeCount})`,\n\t\t\t`set shards >= ${nodeCount} (default 100)`,\n\t\t);\n\t}\n\treturn {\n\t\tname: opts.name ?? 'walrus',\n\t\tnodeCount,\n\t\tshards,\n\t\tversion: opts.version ?? DEFAULT_WALRUS_REF,\n\t\tsuiVersion: opts.suiVersion ?? DEFAULT_SUI_VERSION,\n\t\tcontainerApiPort: opts.containerApiPort ?? DEFAULT_CONTAINER_API_PORT,\n\t\tepochDuration: opts.epochDuration ?? '24h',\n\t\treadyTimeoutMs: opts.readyTimeoutMs ?? DEFAULT_NODE_READY_TIMEOUT_MS,\n\t\t...resolveLocalServicesOptions(opts),\n\t};\n};\n\nconst expectOptionalPort = (value: number | undefined, field: string): number | undefined =>\n\tvalue === undefined\n\t\t? undefined\n\t\t: expectPort(value, {\n\t\t\t\tfield,\n\t\t\t\tmkError: ({ field: f, message, hint }) =>\n\t\t\t\t\twalrusConfigError(f, `walrusLocalCluster: ${f} ${message}`, hint),\n\t\t\t});\n\nconst resolveLocalServiceBase = (\n\tvalue: boolean | WalrusLocalServiceOptions | undefined,\n\tfieldPrefix: 'aggregator' | 'publisher' | 'uploadRelay',\n\tdefaultPort: number,\n): ResolvedWalrusLocalServiceOptions | null => {\n\tif (value === false) return null;\n\tconst authored = value === undefined || value === true ? {} : value;\n\treturn {\n\t\tport: expectOptionalPort(authored.port, `${fieldPrefix}.port`) ?? defaultPort,\n\t};\n};\n\nconst resolveLocalServicesOptions = (\n\topts: WalrusLocalClusterOptions,\n): Pick<ResolvedLocalClusterOptions, 'aggregator' | 'publisher' | 'uploadRelay'> => {\n\treturn {\n\t\taggregator: resolveLocalServiceBase(\n\t\t\topts.aggregator,\n\t\t\t'aggregator',\n\t\t\tDEFAULT_WALRUS_CLIENT_SERVICE_PORT,\n\t\t),\n\t\tpublisher: resolveLocalServiceBase(\n\t\t\topts.publisher,\n\t\t\t'publisher',\n\t\t\tDEFAULT_WALRUS_CLIENT_SERVICE_PORT,\n\t\t),\n\t\tuploadRelay: resolveLocalServiceBase(\n\t\t\topts.uploadRelay,\n\t\t\t'uploadRelay',\n\t\t\tDEFAULT_WALRUS_UPLOAD_RELAY_SERVICE_PORT,\n\t\t),\n\t};\n};\n\n/** Dependencies the local service consumes at acquire-time. */\nexport interface LocalClusterDeps {\n\treadonly runtime: ContainerRuntime;\n\treadonly publisher: ArtifactPublisher;\n\treadonly probe: ChainProbe<SuiProbeKey>;\n\treadonly suiSdk: WalSwapSdk;\n\treadonly suiChainId: string;\n\treadonly suiRpcUrlInNetwork: string;\n\treadonly walrusFaucetUrlInNetwork: string;\n\treadonly waitForFundsReady: Effect.Effect<void, unknown>;\n\treadonly app: string;\n\treadonly stack: string;\n\t/** Pre-allocated /24 prefix from `subnetForStack`. */\n\treadonly subnetPrefix: string;\n\treadonly walrusNetworkName: string;\n\treadonly suiNetworkName: string;\n\treadonly deployHostMountPath: string;\n\t/** On-disk per-stack root from `StackPathsService.stackRoot`. The\n\t * walrus bind-mount is computed off this; `deployHostMountPath`\n\t * MUST live under it. */\n\treadonly stackRoot: string;\n}\n\n/** Boot the local cluster. Returns the resolved value the plugin\n * projects onto its tags.\n *\n * Steps:\n * - Image build — `resolveCargoImage` (bootstrap asset).\n * Honors `WALRUS_CARGO_IMAGE_OVERRIDE` for the pre-baked path.\n * - Docker network ensure — `runtime.ensureNetwork(walrusNet)`.\n * The sui network is owned by the sui plugin; we attach to it\n * as a secondary network on each storage node.\n * - Deploy contracts — `deployWalrusContracts` dispatches through\n * the artifact publisher primitive; the produce body runs the walrus deploy\n * one-shot.\n * - Storage nodes — parallel boot via `startStorageNodes`.\n * - WAL faucet strategy — constructed if `state.exchangeObject`\n * exists. Surfaced on the boot result; the barrel registers\n * the contributor decl.\n *\n * Per-step failures surface as `WalrusPluginError` with the phase\n * vocabulary from `errors.ts`; artifact publisher failures pass through as\n * `ArtifactPublishError`. The plugin narration vocabulary anchors\n * on these phase tags.\n */\nexport const bootLocalCluster = (\n\tdeps: LocalClusterDeps,\n\topts: ResolvedLocalClusterOptions,\n): Effect.Effect<\n\tLocalClusterBootResult,\n\tWalrusError | ArtifactPublishError,\n\tScope.Scope | FileSystem.FileSystem | Path.Path\n> =>\n\tEffect.gen(function* () {\n\t\t// ---- cargo image (bootstrap asset) -----------------------\n\t\t// The cargo image is content-addressed; the resolver owns the\n\t\t// cache check + the registry-tag override fast path.\n\t\tyield* setCurrentPluginPhase(`resolving Walrus image ${opts.version}`);\n\t\tconst walrusImage = yield* resolveCargoImage(deps.runtime, {\n\t\t\twalrusRef: opts.version,\n\t\t\tsuiVersion: opts.suiVersion,\n\t\t\towner: { app: deps.app, stack: deps.stack },\n\t\t});\n\n\t\t// ---- docker network ensure ------------------------------\n\t\tyield* setCurrentPluginPhase(`ensuring Walrus network ${deps.walrusNetworkName}`);\n\t\tyield* deps.runtime\n\t\t\t.ensureNetwork({\n\t\t\t\tname: deps.walrusNetworkName,\n\t\t\t\tapp: deps.app,\n\t\t\t\tstack: deps.stack,\n\t\t\t})\n\t\t\t.pipe(\n\t\t\t\tEffect.catch((cause) =>\n\t\t\t\t\tEffect.fail(\n\t\t\t\t\t\twalrusPluginError(\n\t\t\t\t\t\t\t'cluster-network',\n\t\t\t\t\t\t\t`walrus: ensureNetwork('${deps.walrusNetworkName}') failed: ${cause.reason}: ${cause.detail}`,\n\t\t\t\t\t\t\t{ cause },\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\n\t\t// ---- deploy via ArtifactPublisher ----------------\n\t\t// The deploy one-shot needs the walrus image + sui network so it\n\t\t// can dial the per-stack sui RPC + faucet over docker DNS.\n\t\t//\n\t\t// Per-node committee hostnames are Docker-network aliases, because the\n\t\t// real Rust publisher/aggregator read these public_host values from chain\n\t\t// and dial storage nodes from inside the Walrus network. Router-facing\n\t\t// `.localhost` hostnames are still produced by `startStorageNodes` for\n\t\t// devstack's public diagnostic URLs.\n\t\tconst committeeHosts = Array.from({ length: opts.nodeCount }, (_, i) =>\n\t\t\tcomputeCommitteeHostname(i),\n\t\t).join(',');\n\t\tconst listeningIps = Array.from(\n\t\t\t{ length: opts.nodeCount },\n\t\t\t(_, i) => `${deps.subnetPrefix}.${WALRUS_NODE_IP_BASE + i}`,\n\t\t).join(',');\n\n\t\tyield* setCurrentPluginPhase(\n\t\t\t`deploying Walrus contracts (${opts.nodeCount} node${opts.nodeCount === 1 ? '' : 's'}, ${opts.shards} shards)`,\n\t\t);\n\t\tconst { state } = yield* deployWalrusContracts(deps.publisher, deps.probe, deps.runtime, {\n\t\t\twalrusName: opts.name,\n\t\t\tchainId: deps.suiChainId,\n\t\t\tcontentHash: brandContentHash(\n\t\t\t\t`walrus|${opts.version}|${opts.suiVersion}|${opts.nodeCount}|${opts.shards}|${opts.epochDuration}|committee=${committeeHosts}|listen=${listeningIps}`,\n\t\t\t),\n\t\t\toutputDirHostPath: deps.deployHostMountPath,\n\t\t\tstackRoot: deps.stackRoot,\n\t\t\tsuiRpcUrlInNetwork: deps.suiRpcUrlInNetwork,\n\t\t\twalrusFaucetUrlInNetwork: deps.walrusFaucetUrlInNetwork,\n\t\t\twaitForFundsReady: deps.waitForFundsReady,\n\t\t\tcommitteeSize: opts.nodeCount,\n\t\t\tshards: opts.shards,\n\t\t\tepochDuration: opts.epochDuration,\n\t\t\tpublicHostsCsv: committeeHosts,\n\t\t\tlisteningIpsCsv: listeningIps,\n\t\t\twalrusImage,\n\t\t\tsuiNetworkName: deps.suiNetworkName,\n\t\t});\n\t\tconst deployConfigHash = [\n\t\t\t'walrus-deploy',\n\t\t\tstate.walrusPackageId,\n\t\t\tstate.systemObject,\n\t\t\tstate.stakingObject,\n\t\t\tstate.exchangeObject ?? 'no-exchange',\n\t\t].join('|');\n\n\t\t// Per-node image tags. Each storage node runs under its OWN tag (a cheap\n\t\t// re-tag of the one content-cached cargo build) so its committed writable\n\t\t// layer — the RocksDB holding that node's slivers — promotes to a DISTINCT\n\t\t// image on snapshot restore. A single shared tag would make the restore\n\t\t// image-promote collapse all N committed layers onto one tag\n\t\t// (last-write-wins): N-1 nodes boot on the wrong layer and every\n\t\t// pre-snapshot blob is orphaned. The tag is scoped by the deployed\n\t\t// `walrusPackageId` — stable across boot1 -> restore -> boot2 (the deploy\n\t\t// cache reuses the same id, so the restore's promote target matches what\n\t\t// boot2 requests), but DISTINCT per fresh deployment, so a later cold boot\n\t\t// on a new chain never inherits a prior run's committed node layers (which\n\t\t// carry a stale committee and would reject writes). The base `walrusImage`\n\t\t// (shared) still backs the transient deploy one-shot (`--rm`, unsnapshotted).\n\t\tconst nodeImageScope = state.walrusPackageId.replace(/^0x/, '').slice(0, 12);\n\t\tconst resolveServiceImage = (role: WalrusClientServiceRole) =>\n\t\t\tresolveCargoImage(\n\t\t\t\tdeps.runtime,\n\t\t\t\t{\n\t\t\t\t\twalrusRef: opts.version,\n\t\t\t\t\tsuiVersion: opts.suiVersion,\n\t\t\t\t\towner: { app: deps.app, stack: deps.stack },\n\t\t\t\t},\n\t\t\t\t`${walrusImage.tag}-${nodeImageScope}-${role}`,\n\t\t\t);\n\t\tconst nodeImages = yield* Effect.forEach(\n\t\t\tArray.from({ length: opts.nodeCount }, (_, i) => i),\n\t\t\t(i) =>\n\t\t\t\tresolveCargoImage(\n\t\t\t\t\tdeps.runtime,\n\t\t\t\t\t{\n\t\t\t\t\t\twalrusRef: opts.version,\n\t\t\t\t\t\tsuiVersion: opts.suiVersion,\n\t\t\t\t\t\towner: { app: deps.app, stack: deps.stack },\n\t\t\t\t\t},\n\t\t\t\t\t`${walrusImage.tag}-${nodeImageScope}-node-${i}`,\n\t\t\t\t),\n\t\t);\n\t\tconst clientServiceImages = yield* Effect.all({\n\t\t\taggregator:\n\t\t\t\topts.aggregator === null ? Effect.succeed(null) : resolveServiceImage('aggregator'),\n\t\t\tpublisher: opts.publisher === null ? Effect.succeed(null) : resolveServiceImage('publisher'),\n\t\t\tuploadRelay:\n\t\t\t\topts.uploadRelay === null ? Effect.succeed(null) : resolveServiceImage('upload-relay'),\n\t\t});\n\n\t\t// ---- storage nodes — parallel boot ----------------------\n\t\tyield* setCurrentPluginPhase(\n\t\t\t`starting ${opts.nodeCount} Walrus storage node${opts.nodeCount === 1 ? '' : 's'}`,\n\t\t);\n\t\tconst { nodes } = yield* startStorageNodes(deps.runtime, {\n\t\t\tapp: deps.app,\n\t\t\tstack: deps.stack,\n\t\t\twalrusName: opts.name,\n\t\t\timages: nodeImages,\n\t\t\tnodeCount: opts.nodeCount,\n\t\t\tsubnetPrefix: deps.subnetPrefix,\n\t\t\tcontainerApiPort: opts.containerApiPort,\n\t\t\twalrusNetworkName: deps.walrusNetworkName,\n\t\t\tsuiNetworkName: deps.suiNetworkName,\n\t\t\tdeployHostMountPath: deps.deployHostMountPath,\n\t\t\tstackRoot: deps.stackRoot,\n\t\t\tdeployConfigHash,\n\t\t\treadyTimeoutMs: opts.readyTimeoutMs,\n\t\t});\n\n\t\t// `nodeCount >= 1` is enforced synchronously already; this is\n\t\t// defense-in-depth.\n\t\tif (nodes.length === 0) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\twalrusPluginError('storage-node', 'walrus: at least one storage node is required'),\n\t\t\t);\n\t\t}\n\n\t\t// ---- app-facing Rust publisher / aggregator / upload-relay services ----\n\t\tyield* setCurrentPluginPhase('starting Walrus client services');\n\t\tconst clientServices = yield* startWalrusClientServices(deps.runtime, {\n\t\t\tapp: deps.app,\n\t\t\tstack: deps.stack,\n\t\t\twalrusName: opts.name,\n\t\t\timages: clientServiceImages,\n\t\t\toptions: {\n\t\t\t\taggregator: opts.aggregator,\n\t\t\t\tpublisher: opts.publisher,\n\t\t\t\tuploadRelay: opts.uploadRelay,\n\t\t\t},\n\t\t\twalrusNetworkName: deps.walrusNetworkName,\n\t\t\tsuiNetworkName: deps.suiNetworkName,\n\t\t\tdeployHostMountPath: deps.deployHostMountPath,\n\t\t\tstackRoot: deps.stackRoot,\n\t\t\tdeployConfigHash,\n\t\t\tsuiRpcUrlInNetwork: deps.suiRpcUrlInNetwork,\n\t\t\treadyTimeoutMs: opts.readyTimeoutMs,\n\t\t});\n\n\t\t// ---- exchange resolution + WAL funding strategy ------\n\t\t// Register a `coinType:<fullCoinType>` strategy that swaps the\n\t\t// requesting account's SUI into WAL on demand. Accounts opt in via\n\t\t// their normal `funding` list.\n\t\tyield* setCurrentPluginPhase('resolving WAL exchange');\n\t\tconst exchange = yield* resolveWalExchange(deps.probe, state.exchangeObject);\n\t\tconst walFaucetStrategy: WalFaucetStrategy | null = exchange\n\t\t\t? makeWalFaucetStrategy({\n\t\t\t\t\texchange,\n\t\t\t\t\tsdk: deps.suiSdk,\n\t\t\t\t})\n\t\t\t: null;\n\t\tconst resolvedWalCoinType = yield* resolveWalCoinType({\n\t\t\tprobe: deps.probe,\n\t\t\ttreasuryObjectId: state.treasuryObject,\n\t\t\tdeployPackageId: state.walrusPackageId,\n\t\t\trequireTreasuryObject: exchange !== null,\n\t\t});\n\t\tconst resolvedWalPackageId = walPackageIdFromCoinType(resolvedWalCoinType);\n\n\t\treturn {\n\t\t\tmode: 'local' as const,\n\t\t\tdeploy: state,\n\t\t\twalrusPackageId: state.walrusPackageId,\n\t\t\twalPackageId: resolvedWalPackageId,\n\t\t\tnodes,\n\t\t\texchangeObjectId: state.exchangeObject,\n\t\t\texchange,\n\t\t\tclientServices,\n\t\t\twalFaucetStrategy,\n\t\t\twalCoinType: resolvedWalCoinType,\n\t\t};\n\t});\n"],"mappings":";;;;;;;;;;;;;;;;AAsKA,MAAa,8BACZ,SACiC;CACjC,MAAM,YAAY,sBAAsB,KAAK,aAAa,GAAG;EAC5D,OAAO;EACP,UAAU,EAAE,OAAO,SAAS,WAC3B,kBACC,OACA,mDAAmD,OAAO,KAAK,aAAa,CAAC,EAAE,IAC/E,QAAQ,OACT;EACD,MAAM;CACP,CAAC;CACD,IAAI,YAAA,GACH,MAAM,kBACL,aACA,kCAAkC,UAAU,+EAE5C,+EACD;CAED,MAAM,SAAS,sBAAsB,KAAK,UAAU,KAAK;EACxD,OAAO;EACP,UAAU,EAAE,OAAO,SAAS,WAC3B,kBACC,OACA,8DAA8D,OAAO,KAAK,UAAU,GAAG,EAAE,IACzF,QAAQ,OACT;EACD,MAAM;CACP,CAAC;CACD,IAAI,SAAS,WACZ,MAAM,kBACL,UACA,+BAA+B,OAAO,0BAA0B,UAAU,IAC1E,iBAAiB,UAAU,eAC5B;CAED,OAAO;EACN,MAAM,KAAK,QAAQ;EACnB;EACA;EACA,SAAS,KAAK,WAAA;EACd,YAAY,KAAK,cAAA;EACjB,kBAAkB,KAAK,oBAAA;EACvB,eAAe,KAAK,iBAAiB;EACrC,gBAAgB,KAAK,kBAAA;EACrB,GAAG,4BAA4B,IAAI;CACpC;AACD;AAEA,MAAM,sBAAsB,OAA2B,UACtD,UAAU,KAAA,IACP,KAAA,IACA,WAAW,OAAO;CAClB;CACA,UAAU,EAAE,OAAO,GAAG,SAAS,WAC9B,k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AO,KAAK;EACZ,kBAAkB,MAAM;EACxB,iBAAiB,MAAM;EACvB,uBAAuB,aAAa;CACrC,CAAC;CACD,MAAM,uBAAuB,yBAAyB,mBAAmB;CAEzE,OAAO;EACN,MAAM;EACN,QAAQ;EACR,iBAAiB,MAAM;EACvB,cAAc;EACd;EACA,kBAAkB,MAAM;EACxB;EACA;EACA;EACA,aAAa;CACd;AACD,CAAC"}
@@ -3,6 +3,7 @@ import { WALRUS_ROUTER_PORT } from "./storage-nodes.mjs";
3
3
  const WALRUS_NODE_ENDPOINT_PREFIX = "walrus-node-";
4
4
  const WALRUS_AGGREGATOR_ENDPOINT_NAME = "walrus-aggregator";
5
5
  const WALRUS_PUBLISHER_ENDPOINT_NAME = "walrus-publisher";
6
+ const WALRUS_UPLOAD_RELAY_ENDPOINT_NAME = "walrus-upload-relay";
6
7
  const WALRUS_ENTRYPOINTS = [
7
8
  ...Array.from({ length: 8 }, (_, i) => ({
8
9
  name: `${WALRUS_NODE_ENDPOINT_PREFIX}${i}`,
@@ -18,6 +19,11 @@ const WALRUS_ENTRYPOINTS = [
18
19
  name: WALRUS_PUBLISHER_ENDPOINT_NAME,
19
20
  port: WALRUS_ROUTER_PORT,
20
21
  protocol: "http"
22
+ },
23
+ {
24
+ name: WALRUS_UPLOAD_RELAY_ENDPOINT_NAME,
25
+ port: WALRUS_ROUTER_PORT,
26
+ protocol: "http"
21
27
  }
22
28
  ];
23
29
  /** Build the Routable contributions for the local cluster. `nodeCount`
@@ -42,39 +48,29 @@ const makeLocalRoutables = (args) => {
42
48
  wireProtocol: "https"
43
49
  }));
44
50
  const serviceRoutes = [];
45
- if (args.aggregator !== void 0 && args.aggregator !== null) serviceRoutes.push({
46
- kind: "routable",
47
- endpointName: WALRUS_AGGREGATOR_ENDPOINT_NAME,
48
- dispatchId: {
49
- serviceKey: args.serviceKey,
50
- role: WALRUS_AGGREGATOR_ENDPOINT_NAME
51
- },
52
- upstream: {
53
- type: "container",
54
- containerName: args.aggregator.containerName,
55
- containerPort: args.aggregator.containerPort
56
- },
57
- cors: true,
58
- wireProtocol: "http"
59
- });
60
- if (args.publisher !== void 0 && args.publisher !== null) serviceRoutes.push({
61
- kind: "routable",
62
- endpointName: WALRUS_PUBLISHER_ENDPOINT_NAME,
63
- dispatchId: {
64
- serviceKey: args.serviceKey,
65
- role: WALRUS_PUBLISHER_ENDPOINT_NAME
66
- },
67
- upstream: {
68
- type: "container",
69
- containerName: args.publisher.containerName,
70
- containerPort: args.publisher.containerPort
71
- },
72
- cors: true,
73
- wireProtocol: "http"
74
- });
51
+ const pushServiceRoute = (endpointName, service) => {
52
+ serviceRoutes.push({
53
+ kind: "routable",
54
+ endpointName,
55
+ dispatchId: {
56
+ serviceKey: args.serviceKey,
57
+ role: endpointName
58
+ },
59
+ upstream: {
60
+ type: "container",
61
+ containerName: service.containerName,
62
+ containerPort: service.containerPort
63
+ },
64
+ cors: true,
65
+ wireProtocol: "http"
66
+ });
67
+ };
68
+ if (args.aggregator !== void 0 && args.aggregator !== null) pushServiceRoute(WALRUS_AGGREGATOR_ENDPOINT_NAME, args.aggregator);
69
+ if (args.publisher !== void 0 && args.publisher !== null) pushServiceRoute(WALRUS_PUBLISHER_ENDPOINT_NAME, args.publisher);
70
+ if (args.uploadRelay !== void 0 && args.uploadRelay !== null) pushServiceRoute(WALRUS_UPLOAD_RELAY_ENDPOINT_NAME, args.uploadRelay);
75
71
  return [...perNodeRoutes, ...serviceRoutes];
76
72
  };
77
73
  //#endregion
78
- export { WALRUS_AGGREGATOR_ENDPOINT_NAME, WALRUS_ENTRYPOINTS, WALRUS_PUBLISHER_ENDPOINT_NAME, makeLocalRoutables };
74
+ export { WALRUS_AGGREGATOR_ENDPOINT_NAME, WALRUS_ENTRYPOINTS, WALRUS_PUBLISHER_ENDPOINT_NAME, WALRUS_UPLOAD_RELAY_ENDPOINT_NAME, makeLocalRoutables };
79
75
 
80
76
  //# sourceMappingURL=routable.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"routable.mjs","names":[],"sources":["../../../src/plugins/walrus/routable.ts"],"sourcesContent":["// Walrus plugin — Routable contributions.\n//\n// Distilled-doc reference (06-walrus.md §\"Routes registered\"):\n// each storage node carries one Traefik route. The router binds host\n// port 9185 once globally and dispatches by `Host:` header to the\n// per-stack backend — `routerHostname(identity, 'walrus-node-<i>')`.\n//\n// For the local cluster:\n// - N × `walrus-node-<i>` routes — one per storage node, with\n// `cors: true` (walrus storage REST API lacks CORS headers). These\n// are HTTP public routes backed by HTTPS upstreams because Walrus\n// storage nodes self-sign TLS with their network key.\n// - 1 × `walrus-aggregator` route — release `walrus aggregator`\n// service container\n// exposing `GET /v1/blobs/:id` through a single app-facing URL.\n// - 1 × `walrus-publisher` route — release `walrus publisher`\n// service container\n// exposing `PUT /v1/blobs` through a single app-facing URL.\n//\n// Known-deployment publishes no routes — the aggregator/publisher\n// URLs land on the codegen-emitted `WalrusBindings.{aggregator,\n// publisher}Url` instead.\n\nimport type { EntrypointDecl, RoutableDecl } from '../../contracts/routable.ts';\nimport { WALRUS_ROUTER_PORT } from './storage-nodes.ts';\nimport type { WalrusClientService } from './client-services.ts';\n\nexport const WALRUS_NODE_ENDPOINT_PREFIX = 'walrus-node-' as const;\nexport const WALRUS_AGGREGATOR_ENDPOINT_NAME = 'walrus-aggregator' as const;\nexport const WALRUS_PUBLISHER_ENDPOINT_NAME = 'walrus-publisher' as const;\n\n/** Upper bound on `nodeCount` — Traefik entrypoints are bound at boot,\n * so the cluster's per-node routes need pre-declared entrypoint names.\n * Validated at factory time in `mode/local-cluster.ts:resolveOptions`. */\nexport const WALRUS_MAX_NODE_COUNT = 8;\n\nexport const WALRUS_ENTRYPOINTS: ReadonlyArray<EntrypointDecl> = [\n\t...Array.from(\n\t\t{ length: WALRUS_MAX_NODE_COUNT },\n\t\t(_, i): EntrypointDecl => ({\n\t\t\tname: `${WALRUS_NODE_ENDPOINT_PREFIX}${i}`,\n\t\t\tport: WALRUS_ROUTER_PORT,\n\t\t\tprotocol: 'http',\n\t\t}),\n\t),\n\t{ name: WALRUS_AGGREGATOR_ENDPOINT_NAME, port: WALRUS_ROUTER_PORT, protocol: 'http' },\n\t{ name: WALRUS_PUBLISHER_ENDPOINT_NAME, port: WALRUS_ROUTER_PORT, protocol: 'http' },\n];\n\n/** Build the Routable contributions for the local cluster. `nodeCount`\n * drives the per-node fan-out; the plugin's service key + route role\n * identify the dispatch target. */\nexport const makeLocalRoutables = (args: {\n\treadonly app: string;\n\treadonly stack: string;\n\treadonly walrusName: string;\n\treadonly serviceKey: string;\n\treadonly nodeCount: number;\n\treadonly containerApiPort?: number;\n\treadonly aggregator?: WalrusClientService | null;\n\treadonly publisher?: WalrusClientService | null;\n}): ReadonlyArray<RoutableDecl> => {\n\tconst containerPort = args.containerApiPort ?? WALRUS_ROUTER_PORT;\n\tconst containerNameFor = (i: number): string =>\n\t\t`devstack-${args.app}-${args.stack}-walrus-${args.walrusName}-node-${i}`;\n\tconst perNodeRoutes: ReadonlyArray<RoutableDecl> = Array.from(\n\t\t{ length: args.nodeCount },\n\t\t(_, i): RoutableDecl => ({\n\t\t\tkind: 'routable',\n\t\t\tendpointName: `${WALRUS_NODE_ENDPOINT_PREFIX}${i}`,\n\t\t\tdispatchId: {\n\t\t\t\tserviceKey: args.serviceKey,\n\t\t\t\trole: `${WALRUS_NODE_ENDPOINT_PREFIX}${i}`,\n\t\t\t},\n\t\t\tupstream: {\n\t\t\t\ttype: 'container',\n\t\t\t\tcontainerName: containerNameFor(i),\n\t\t\t\tcontainerPort,\n\t\t\t},\n\t\t\t// Distilled-doc §\"Routes registered\": cors: true (walrus\n\t\t\t// storage REST API lacks CORS headers).\n\t\t\tcors: true,\n\t\t\twireProtocol: 'https',\n\t\t}),\n\t);\n\n\tconst serviceRoutes: RoutableDecl[] = [];\n\tif (args.aggregator !== undefined && args.aggregator !== null) {\n\t\tserviceRoutes.push({\n\t\t\tkind: 'routable',\n\t\t\tendpointName: WALRUS_AGGREGATOR_ENDPOINT_NAME,\n\t\t\tdispatchId: {\n\t\t\t\tserviceKey: args.serviceKey,\n\t\t\t\trole: WALRUS_AGGREGATOR_ENDPOINT_NAME,\n\t\t\t},\n\t\t\tupstream: {\n\t\t\t\ttype: 'container',\n\t\t\t\tcontainerName: args.aggregator.containerName,\n\t\t\t\tcontainerPort: args.aggregator.containerPort,\n\t\t\t},\n\t\t\tcors: true,\n\t\t\twireProtocol: 'http',\n\t\t});\n\t}\n\tif (args.publisher !== undefined && args.publisher !== null) {\n\t\tserviceRoutes.push({\n\t\t\tkind: 'routable',\n\t\t\tendpointName: WALRUS_PUBLISHER_ENDPOINT_NAME,\n\t\t\tdispatchId: {\n\t\t\t\tserviceKey: args.serviceKey,\n\t\t\t\trole: WALRUS_PUBLISHER_ENDPOINT_NAME,\n\t\t\t},\n\t\t\tupstream: {\n\t\t\t\ttype: 'container',\n\t\t\t\tcontainerName: args.publisher.containerName,\n\t\t\t\tcontainerPort: args.publisher.containerPort,\n\t\t\t},\n\t\t\tcors: true,\n\t\t\twireProtocol: 'http',\n\t\t});\n\t}\n\n\treturn [...perNodeRoutes, ...serviceRoutes];\n};\n"],"mappings":";;AA2BA,MAAa,8BAA8B;AAC3C,MAAa,kCAAkC;AAC/C,MAAa,iCAAiC;AAO9C,MAAa,qBAAoD;CAChE,GAAG,MAAM,KACR,EAAE,QAAA,EAA8B,IAC/B,GAAG,OAAuB;EAC1B,MAAM,GAAG,8BAA8B;EACvC,MAAM;EACN,UAAU;CACX,EACD;CACA;EAAE,MAAM;EAAiC,MAAM;EAAoB,UAAU;CAAO;CACpF;EAAE,MAAM;EAAgC,MAAM;EAAoB,UAAU;CAAO;AACpF;;;;AAKA,MAAa,sBAAsB,SASA;CAClC,MAAM,gBAAgB,KAAK,oBAAA;CAC3B,MAAM,oBAAoB,MACzB,YAAY,KAAK,IAAI,GAAG,KAAK,MAAM,UAAU,KAAK,WAAW,QAAQ;CACtE,MAAM,gBAA6C,MAAM,KACxD,EAAE,QAAQ,KAAK,UAAU,IACxB,GAAG,OAAqB;EACxB,MAAM;EACN,cAAc,GAAG,8BAA8B;EAC/C,YAAY;GACX,YAAY,KAAK;GACjB,MAAM,GAAG,8BAA8B;EACxC;EACA,UAAU;GACT,MAAM;GACN,eAAe,iBAAiB,CAAC;GACjC;EACD;EAGA,MAAM;EACN,cAAc;CACf,EACD;CAEA,MAAM,gBAAgC,CAAC;CACvC,IAAI,KAAK,eAAe,KAAA,KAAa,KAAK,eAAe,MACxD,cAAc,KAAK;EAClB,MAAM;EACN,cAAc;EACd,YAAY;GACX,YAAY,KAAK;GACjB,MAAM;EACP;EACA,UAAU;GACT,MAAM;GACN,eAAe,KAAK,WAAW;GAC/B,eAAe,KAAK,WAAW;EAChC;EACA,MAAM;EACN,cAAc;CACf,CAAC;CAEF,IAAI,KAAK,cAAc,KAAA,KAAa,KAAK,cAAc,MACtD,cAAc,KAAK;EAClB,MAAM;EACN,cAAc;EACd,YAAY;GACX,YAAY,KAAK;GACjB,MAAM;EACP;EACA,UAAU;GACT,MAAM;GACN,eAAe,KAAK,UAAU;GAC9B,eAAe,KAAK,UAAU;EAC/B;EACA,MAAM;EACN,cAAc;CACf,CAAC;CAGF,OAAO,CAAC,GAAG,eAAe,GAAG,aAAa;AAC3C"}
1
+ {"version":3,"file":"routable.mjs","names":[],"sources":["../../../src/plugins/walrus/routable.ts"],"sourcesContent":["// Walrus plugin — Routable contributions.\n//\n// Distilled-doc reference (06-walrus.md §\"Routes registered\"):\n// each storage node carries one Traefik route. The router binds host\n// port 9185 once globally and dispatches by `Host:` header to the\n// per-stack backend — `routerHostname(identity, 'walrus-node-<i>')`.\n//\n// For the local cluster:\n// - N × `walrus-node-<i>` routes — one per storage node, with\n// `cors: true` (walrus storage REST API lacks CORS headers). These\n// are HTTP public routes backed by HTTPS upstreams because Walrus\n// storage nodes self-sign TLS with their network key.\n// - 1 × `walrus-aggregator` route — release `walrus aggregator`\n// service container\n// exposing `GET /v1/blobs/:id` through a single app-facing URL.\n// - 1 × `walrus-publisher` route — release `walrus publisher`\n// service container\n// exposing `PUT /v1/blobs` through a single app-facing URL.\n// - 1 × `walrus-upload-relay` route — release `walrus-upload-relay`\n// service container\n// exposing the SDK upload relay API through a single app-facing URL.\n//\n// Known-deployment publishes no routes — the aggregator/publisher\n// / upload-relay URLs land on the codegen-emitted `WalrusBindings`\n// URL fields instead.\n\nimport type { EntrypointDecl, RoutableDecl } from '../../contracts/routable.ts';\nimport { WALRUS_ROUTER_PORT } from './storage-nodes.ts';\nimport type { WalrusClientService } from './client-services.ts';\n\nexport const WALRUS_NODE_ENDPOINT_PREFIX = 'walrus-node-' as const;\nexport const WALRUS_AGGREGATOR_ENDPOINT_NAME = 'walrus-aggregator' as const;\nexport const WALRUS_PUBLISHER_ENDPOINT_NAME = 'walrus-publisher' as const;\nexport const WALRUS_UPLOAD_RELAY_ENDPOINT_NAME = 'walrus-upload-relay' as const;\n\n/** Upper bound on `nodeCount` — Traefik entrypoints are bound at boot,\n * so the cluster's per-node routes need pre-declared entrypoint names.\n * Validated at factory time in `mode/local-cluster.ts:resolveOptions`. */\nexport const WALRUS_MAX_NODE_COUNT = 8;\n\nexport const WALRUS_ENTRYPOINTS: ReadonlyArray<EntrypointDecl> = [\n\t...Array.from(\n\t\t{ length: WALRUS_MAX_NODE_COUNT },\n\t\t(_, i): EntrypointDecl => ({\n\t\t\tname: `${WALRUS_NODE_ENDPOINT_PREFIX}${i}`,\n\t\t\tport: WALRUS_ROUTER_PORT,\n\t\t\tprotocol: 'http',\n\t\t}),\n\t),\n\t{ name: WALRUS_AGGREGATOR_ENDPOINT_NAME, port: WALRUS_ROUTER_PORT, protocol: 'http' },\n\t{ name: WALRUS_PUBLISHER_ENDPOINT_NAME, port: WALRUS_ROUTER_PORT, protocol: 'http' },\n\t{ name: WALRUS_UPLOAD_RELAY_ENDPOINT_NAME, port: WALRUS_ROUTER_PORT, protocol: 'http' },\n];\n\n/** Build the Routable contributions for the local cluster. `nodeCount`\n * drives the per-node fan-out; the plugin's service key + route role\n * identify the dispatch target. */\nexport const makeLocalRoutables = (args: {\n\treadonly app: string;\n\treadonly stack: string;\n\treadonly walrusName: string;\n\treadonly serviceKey: string;\n\treadonly nodeCount: number;\n\treadonly containerApiPort?: number;\n\treadonly aggregator?: WalrusClientService | null;\n\treadonly publisher?: WalrusClientService | null;\n\treadonly uploadRelay?: WalrusClientService | null;\n}): ReadonlyArray<RoutableDecl> => {\n\tconst containerPort = args.containerApiPort ?? WALRUS_ROUTER_PORT;\n\tconst containerNameFor = (i: number): string =>\n\t\t`devstack-${args.app}-${args.stack}-walrus-${args.walrusName}-node-${i}`;\n\tconst perNodeRoutes: ReadonlyArray<RoutableDecl> = Array.from(\n\t\t{ length: args.nodeCount },\n\t\t(_, i): RoutableDecl => ({\n\t\t\tkind: 'routable',\n\t\t\tendpointName: `${WALRUS_NODE_ENDPOINT_PREFIX}${i}`,\n\t\t\tdispatchId: {\n\t\t\t\tserviceKey: args.serviceKey,\n\t\t\t\trole: `${WALRUS_NODE_ENDPOINT_PREFIX}${i}`,\n\t\t\t},\n\t\t\tupstream: {\n\t\t\t\ttype: 'container',\n\t\t\t\tcontainerName: containerNameFor(i),\n\t\t\t\tcontainerPort,\n\t\t\t},\n\t\t\t// Distilled-doc §\"Routes registered\": cors: true (walrus\n\t\t\t// storage REST API lacks CORS headers).\n\t\t\tcors: true,\n\t\t\twireProtocol: 'https',\n\t\t}),\n\t);\n\n\tconst serviceRoutes: RoutableDecl[] = [];\n\tconst pushServiceRoute = (endpointName: string, service: WalrusClientService) => {\n\t\tserviceRoutes.push({\n\t\t\tkind: 'routable',\n\t\t\tendpointName,\n\t\t\tdispatchId: {\n\t\t\t\tserviceKey: args.serviceKey,\n\t\t\t\trole: endpointName,\n\t\t\t},\n\t\t\tupstream: {\n\t\t\t\ttype: 'container',\n\t\t\t\tcontainerName: service.containerName,\n\t\t\t\tcontainerPort: service.containerPort,\n\t\t\t},\n\t\t\tcors: true,\n\t\t\twireProtocol: 'http',\n\t\t});\n\t};\n\tif (args.aggregator !== undefined && args.aggregator !== null) {\n\t\tpushServiceRoute(WALRUS_AGGREGATOR_ENDPOINT_NAME, args.aggregator);\n\t}\n\tif (args.publisher !== undefined && args.publisher !== null) {\n\t\tpushServiceRoute(WALRUS_PUBLISHER_ENDPOINT_NAME, args.publisher);\n\t}\n\tif (args.uploadRelay !== undefined && args.uploadRelay !== null) {\n\t\tpushServiceRoute(WALRUS_UPLOAD_RELAY_ENDPOINT_NAME, args.uploadRelay);\n\t}\n\n\treturn [...perNodeRoutes, ...serviceRoutes];\n};\n"],"mappings":";;AA8BA,MAAa,8BAA8B;AAC3C,MAAa,kCAAkC;AAC/C,MAAa,iCAAiC;AAC9C,MAAa,oCAAoC;AAOjD,MAAa,qBAAoD;CAChE,GAAG,MAAM,KACR,EAAE,QAAA,EAA8B,IAC/B,GAAG,OAAuB;EAC1B,MAAM,GAAG,8BAA8B;EACvC,MAAM;EACN,UAAU;CACX,EACD;CACA;EAAE,MAAM;EAAiC,MAAM;EAAoB,UAAU;CAAO;CACpF;EAAE,MAAM;EAAgC,MAAM;EAAoB,UAAU;CAAO;CACnF;EAAE,MAAM;EAAmC,MAAM;EAAoB,UAAU;CAAO;AACvF;;;;AAKA,MAAa,sBAAsB,SAUA;CAClC,MAAM,gBAAgB,KAAK,oBAAA;CAC3B,MAAM,oBAAoB,MACzB,YAAY,KAAK,IAAI,GAAG,KAAK,MAAM,UAAU,KAAK,WAAW,QAAQ;CACtE,MAAM,gBAA6C,MAAM,KACxD,EAAE,QAAQ,KAAK,UAAU,IACxB,GAAG,OAAqB;EACxB,MAAM;EACN,cAAc,GAAG,8BAA8B;EAC/C,YAAY;GACX,YAAY,KAAK;GACjB,MAAM,GAAG,8BAA8B;EACxC;EACA,UAAU;GACT,MAAM;GACN,eAAe,iBAAiB,CAAC;GACjC;EACD;EAGA,MAAM;EACN,cAAc;CACf,EACD;CAEA,MAAM,gBAAgC,CAAC;CACvC,MAAM,oBAAoB,cAAsB,YAAiC;EACh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