@jinn-network/client 0.1.6-canary.fb9c8196 → 0.1.7-canary.d4e4e183
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.
- package/CHANGELOG.md +33 -0
- package/deployments/deployment-jinn-mvi-l1-sepolia-fast.json +23 -4
- package/deployments/deployment-jinn-mvi-l1-sepolia.json +23 -4
- package/deployments/deployment-jinn-mvi-l2-baseSepolia.json +5 -4
- package/dist/adapters/mech/adapter.d.ts +38 -1
- package/dist/adapters/mech/adapter.js +241 -54
- package/dist/adapters/mech/adapter.js.map +1 -1
- package/dist/adapters/mech/contracts.d.ts +17 -4
- package/dist/adapters/mech/contracts.js +8 -2
- package/dist/adapters/mech/contracts.js.map +1 -1
- package/dist/adapters/mech/safe-revert.d.ts +20 -0
- package/dist/adapters/mech/safe-revert.js +12 -4
- package/dist/adapters/mech/safe-revert.js.map +1 -1
- package/dist/adapters/mech/safe.d.ts +5 -1
- package/dist/adapters/mech/safe.js +27 -8
- package/dist/adapters/mech/safe.js.map +1 -1
- package/dist/adapters/mech/verdict-code.d.ts +1 -0
- package/dist/adapters/mech/verdict-code.js +18 -0
- package/dist/adapters/mech/verdict-code.js.map +1 -1
- package/dist/api/admin-endpoint.d.ts +15 -3
- package/dist/api/admin-endpoint.js +24 -2
- package/dist/api/admin-endpoint.js.map +1 -1
- package/dist/api/bootstrap-endpoint.js +9 -5
- package/dist/api/bootstrap-endpoint.js.map +1 -1
- package/dist/api/codex-doctor-endpoint.d.ts +73 -0
- package/dist/api/codex-doctor-endpoint.js +177 -0
- package/dist/api/codex-doctor-endpoint.js.map +1 -0
- package/dist/api/discovery-endpoint.d.ts +1 -0
- package/dist/api/discovery-endpoint.js +26 -0
- package/dist/api/discovery-endpoint.js.map +1 -1
- package/dist/api/gather-status.d.ts +11 -0
- package/dist/api/gather-status.js +332 -3
- package/dist/api/gather-status.js.map +1 -1
- package/dist/api/hermes-doctor-endpoint.d.ts +107 -0
- package/dist/api/hermes-doctor-endpoint.js +204 -5
- package/dist/api/hermes-doctor-endpoint.js.map +1 -1
- package/dist/api/launcher-status.d.ts +21 -16
- package/dist/api/launcher-status.js +2 -1
- package/dist/api/launcher-status.js.map +1 -1
- package/dist/api/portfolio-v0-build.d.ts +10 -0
- package/dist/api/portfolio-v0-build.js +24 -5
- package/dist/api/portfolio-v0-build.js.map +1 -1
- package/dist/api/prediction-v1-build.d.ts +10 -0
- package/dist/api/prediction-v1-build.js +7 -1
- package/dist/api/prediction-v1-build.js.map +1 -1
- package/dist/api/server.d.ts +31 -1
- package/dist/api/server.js +68 -1
- package/dist/api/server.js.map +1 -1
- package/dist/api/setup-endpoints.js +50 -4
- package/dist/api/setup-endpoints.js.map +1 -1
- package/dist/api/solvernets-endpoints.d.ts +8 -0
- package/dist/api/solvernets-endpoints.js +71 -43
- package/dist/api/solvernets-endpoints.js.map +1 -1
- package/dist/api/status-build.d.ts +58 -0
- package/dist/api/status-build.js +50 -0
- package/dist/api/status-build.js.map +1 -1
- package/dist/api/task-run-routing.d.ts +7 -0
- package/dist/api/task-run-routing.js +12 -0
- package/dist/api/task-run-routing.js.map +1 -0
- package/dist/api/task-runs-build.d.ts +21 -0
- package/dist/api/task-runs-build.js +14 -1
- package/dist/api/task-runs-build.js.map +1 -1
- package/dist/build-info.json +4 -4
- package/dist/build-meta.json +1 -1
- package/dist/chain-read-errors.d.ts +10 -0
- package/dist/chain-read-errors.js +15 -0
- package/dist/chain-read-errors.js.map +1 -1
- package/dist/cli/commands/auth.js +1 -1
- package/dist/cli/commands/auth.js.map +1 -1
- package/dist/cli/commands/create.js +3 -2
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/doctor.d.ts +2 -0
- package/dist/cli/commands/doctor.js +2 -0
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/rewards.js +11 -7
- package/dist/cli/commands/rewards.js.map +1 -1
- package/dist/cli/commands/status.js +1 -1
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/tasks.js +86 -9
- package/dist/cli/commands/tasks.js.map +1 -1
- package/dist/cli/commands/update.d.ts +10 -0
- package/dist/cli/commands/update.js +36 -0
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/introspection-context.js +5 -0
- package/dist/cli/introspection-context.js.map +1 -1
- package/dist/cli/task-native-readiness.d.ts +3 -1
- package/dist/cli/task-native-readiness.js +28 -6
- package/dist/cli/task-native-readiness.js.map +1 -1
- package/dist/config.d.ts +97 -5
- package/dist/config.js +90 -18
- package/dist/config.js.map +1 -1
- package/dist/daemon/checkpoint-loop.d.ts +48 -0
- package/dist/daemon/checkpoint-loop.js +76 -0
- package/dist/daemon/checkpoint-loop.js.map +1 -0
- package/dist/daemon/creator.d.ts +1 -1
- package/dist/daemon/creator.js +7 -3
- package/dist/daemon/creator.js.map +1 -1
- package/dist/daemon/daemon.d.ts +11 -0
- package/dist/daemon/daemon.js +51 -1
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/jinn-claim-loop-wiring.d.ts +33 -0
- package/dist/daemon/jinn-claim-loop-wiring.js +40 -0
- package/dist/daemon/jinn-claim-loop-wiring.js.map +1 -0
- package/dist/daemon/jinn-claim-loop.d.ts +24 -17
- package/dist/daemon/jinn-claim-loop.js +77 -23
- package/dist/daemon/jinn-claim-loop.js.map +1 -1
- package/dist/daemon/skip-log-dedup.d.ts +69 -0
- package/dist/daemon/skip-log-dedup.js +106 -0
- package/dist/daemon/skip-log-dedup.js.map +1 -0
- package/dist/dashboard/assets/index-BUlE8F3Y.js +330 -0
- package/dist/dashboard/assets/index-blqc7eqq.css +32 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/discovery/factory.d.ts +17 -5
- package/dist/discovery/factory.js +46 -18
- package/dist/discovery/factory.js.map +1 -1
- package/dist/discovery/http.js +142 -3
- package/dist/discovery/http.js.map +1 -1
- package/dist/discovery/onchain.d.ts +5 -0
- package/dist/discovery/onchain.js +407 -15
- package/dist/discovery/onchain.js.map +1 -1
- package/dist/discovery/types.d.ts +45 -1
- package/dist/discovery/types.js +8 -10
- package/dist/discovery/types.js.map +1 -1
- package/dist/discovery/with-fallback.d.ts +7 -0
- package/dist/discovery/with-fallback.js +10 -0
- package/dist/discovery/with-fallback.js.map +1 -1
- package/dist/earning/bootstrap.d.ts +44 -12
- package/dist/earning/bootstrap.js +88 -46
- package/dist/earning/bootstrap.js.map +1 -1
- package/dist/earning/contracts.d.ts +5 -3
- package/dist/earning/contracts.js +12 -7
- package/dist/earning/contracts.js.map +1 -1
- package/dist/earning/funding-plan.js +27 -18
- package/dist/earning/funding-plan.js.map +1 -1
- package/dist/earning/safe-adapter.d.ts +2 -0
- package/dist/earning/safe-adapter.js +26 -12
- package/dist/earning/safe-adapter.js.map +1 -1
- package/dist/earning/store.d.ts +8 -0
- package/dist/earning/store.js.map +1 -1
- package/dist/earning/testnet-setup-migration.js +10 -0
- package/dist/earning/testnet-setup-migration.js.map +1 -1
- package/dist/erc8004/reputation.d.ts +8 -0
- package/dist/erc8004/reputation.js +22 -3
- package/dist/erc8004/reputation.js.map +1 -1
- package/dist/harnesses/engine/engine.d.ts +72 -0
- package/dist/harnesses/engine/engine.js +105 -8
- package/dist/harnesses/engine/engine.js.map +1 -1
- package/dist/harnesses/engine/persistence.d.ts +51 -1
- package/dist/harnesses/engine/persistence.js +118 -5
- package/dist/harnesses/engine/persistence.js.map +1 -1
- package/dist/harnesses/engine/work-dir-reaper.d.ts +65 -0
- package/dist/harnesses/engine/work-dir-reaper.js +100 -0
- package/dist/harnesses/engine/work-dir-reaper.js.map +1 -0
- package/dist/harnesses/impls/hermes-agent/adapter.js +40 -0
- package/dist/harnesses/impls/hermes-agent/adapter.js.map +1 -1
- package/dist/harnesses/impls/hermes-agent/bootstrap.d.ts +20 -0
- package/dist/harnesses/impls/hermes-agent/bootstrap.js +40 -6
- package/dist/harnesses/impls/hermes-agent/bootstrap.js.map +1 -1
- package/dist/harnesses/impls/hermes-agent/harness.d.ts +37 -1
- package/dist/harnesses/impls/hermes-agent/harness.js +59 -4
- package/dist/harnesses/impls/hermes-agent/harness.js.map +1 -1
- package/dist/harnesses/impls/index.d.ts +5 -0
- package/dist/harnesses/impls/index.js +11 -0
- package/dist/harnesses/impls/index.js.map +1 -1
- package/dist/harnesses/impls/learner/harness.d.ts +38 -4
- package/dist/harnesses/impls/learner/harness.js +96 -2
- package/dist/harnesses/impls/learner/harness.js.map +1 -1
- package/dist/harnesses/impls/learner/plugin-path.d.ts +0 -13
- package/dist/harnesses/impls/learner/plugin-path.js +35 -15
- package/dist/harnesses/impls/learner/plugin-path.js.map +1 -1
- package/dist/harnesses/impls/learner/types.d.ts +11 -0
- package/dist/harnesses/impls/stub.d.ts +58 -0
- package/dist/harnesses/impls/stub.js +89 -0
- package/dist/harnesses/impls/stub.js.map +1 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.d.ts +69 -50
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js +178 -93
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js.map +1 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.d.ts +12 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.js +121 -7
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.js.map +1 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.d.ts +15 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js +54 -4
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js.map +1 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.d.ts +6 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.js +1 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.js.map +1 -1
- package/dist/harnesses/readiness-registry.js +9 -1
- package/dist/harnesses/readiness-registry.js.map +1 -1
- package/dist/main.js +168 -53
- package/dist/main.js.map +1 -1
- package/dist/observability/emit-event.d.ts +1 -1
- package/dist/observability/emit-event.js.map +1 -1
- package/dist/plugins/learner/.claude-plugin/plugin.json +9 -0
- package/dist/plugins/learner/.codex-plugin/plugin.json +39 -0
- package/dist/plugins/learner/AGENTS.md +40 -0
- package/dist/plugins/learner/CLAUDE.md +33 -0
- package/dist/plugins/learner/README.md +59 -0
- package/dist/plugins/learner/hooks/hooks.json +16 -0
- package/dist/plugins/learner/hooks/session-start +38 -0
- package/dist/plugins/learner/skills/learn/SKILL.md +412 -0
- package/dist/plugins/learner/skills/learn/analyst-prompt.md +68 -0
- package/dist/plugins/learner/skills/learn/consolidator-prompt.md +94 -0
- package/dist/plugins/learner/skills/learn/explorer-prompt.md +53 -0
- package/dist/plugins/learner/skills/learn/planner-prompt.md +87 -0
- package/dist/plugins/learner/skills/learn/promoter-prompt.md +113 -0
- package/dist/plugins/learner/skills/learn/step-worker-prompt.md +47 -0
- package/dist/plugins/learner/skills/learn/strategist-prompt.md +85 -0
- package/dist/restart-daemon.d.ts +29 -10
- package/dist/restart-daemon.js +27 -14
- package/dist/restart-daemon.js.map +1 -1
- package/dist/solver-nets/prediction-operator-ux.js +31 -12
- package/dist/solver-nets/prediction-operator-ux.js.map +1 -1
- package/dist/solver-types/_swe-rebench-v2-pool-cache.d.ts +58 -0
- package/dist/solver-types/_swe-rebench-v2-pool-cache.js +87 -0
- package/dist/solver-types/_swe-rebench-v2-pool-cache.js.map +1 -0
- package/dist/solver-types/_swe-rebench-v2-substrate.d.ts +1 -0
- package/dist/solver-types/_swe-rebench-v2-substrate.js +10 -0
- package/dist/solver-types/_swe-rebench-v2-substrate.js.map +1 -1
- package/dist/solver-types/_swe-rebench-v2-validated-pool.d.ts +65 -0
- package/dist/solver-types/_swe-rebench-v2-validated-pool.js +243 -26
- package/dist/solver-types/_swe-rebench-v2-validated-pool.js.map +1 -1
- package/dist/solver-types/swe-rebench-v2-auto.d.ts +22 -7
- package/dist/solver-types/swe-rebench-v2-auto.js +45 -20
- package/dist/solver-types/swe-rebench-v2-auto.js.map +1 -1
- package/dist/solver-types/swe-rebench-v2.d.ts +13 -2
- package/dist/solver-types/swe-rebench-v2.js +233 -94
- package/dist/solver-types/swe-rebench-v2.js.map +1 -1
- package/dist/solvernets/daemon-init.d.ts +10 -2
- package/dist/solvernets/daemon-init.js +22 -2
- package/dist/solvernets/daemon-init.js.map +1 -1
- package/dist/solvernets/launched-record-dispatcher.js +35 -7
- package/dist/solvernets/launched-record-dispatcher.js.map +1 -1
- package/dist/solvernets/store.d.ts +5 -0
- package/dist/solvernets/store.js +1 -0
- package/dist/solvernets/store.js.map +1 -1
- package/dist/store/store.d.ts +15 -0
- package/dist/store/store.js +118 -3
- package/dist/store/store.js.map +1 -1
- package/dist/tasks/sources.d.ts +18 -1
- package/dist/tasks/sources.js +33 -5
- package/dist/tasks/sources.js.map +1 -1
- package/dist/tx-retry.d.ts +151 -19
- package/dist/tx-retry.js +286 -32
- package/dist/tx-retry.js.map +1 -1
- package/dist/types/payloads/prediction-apy-v0.d.ts +5 -5
- package/dist/types/payloads/prediction-v0.d.ts +5 -5
- package/dist/types/task-document.d.ts +392 -0
- package/dist/types/task-document.js +10 -0
- package/dist/types/task-document.js.map +1 -1
- package/dist/types/task.d.ts +28 -0
- package/dist/util/extract-tx-hash.d.ts +14 -0
- package/dist/util/extract-tx-hash.js +19 -0
- package/dist/util/extract-tx-hash.js.map +1 -0
- package/dist/vendor/@jinn-network/sdk/dist/contracts.js +1 -1
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/manifest-schema.d.ts +3 -0
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/manifest-schema.js +1 -0
- package/package.json +29 -12
- package/dist/dashboard/assets/index-C_QnE4YV.js +0 -140
- package/dist/dashboard/assets/index-CarzUepP.css +0 -32
|
@@ -145,6 +145,36 @@ export interface DiscoveryAPI {
|
|
|
145
145
|
* `undefined` if no lifecycle events have been recorded for it yet.
|
|
146
146
|
*/
|
|
147
147
|
getLifecycleStatus(manifestCid: string): Promise<SolverNetLifecycleStatus | undefined>;
|
|
148
|
+
/**
|
|
149
|
+
* Returns the number of distinct operators that have *ever* claimed a task
|
|
150
|
+
* on the SolverNet identified by `manifestCid` — i.e. the count of unique
|
|
151
|
+
* `attempt.operator` Safe addresses across every task whose
|
|
152
|
+
* `manifestDigest === keccak256(manifestCid)`, **including tasks that are
|
|
153
|
+
* now finalized or refunded**.
|
|
154
|
+
*
|
|
155
|
+
* This is an *ever-participated* signal, not a "currently active" one. The
|
|
156
|
+
* count never filters on task lifecycle state: the on-chain backing reads
|
|
157
|
+
* raw `TaskAttemptCreated` logs, which carry no finalized/refunded flag, so
|
|
158
|
+
* the only count consistent across all three backings (HTTP / embedded /
|
|
159
|
+
* on-chain) is the all-time distinct-operator total. Treat it as "operators
|
|
160
|
+
* who have participated at least once", not "operators participating today".
|
|
161
|
+
*
|
|
162
|
+
* It is the protocol-observable participation signal: a "join" in the
|
|
163
|
+
* operator app is purely a local config write (`joinedSolverNets[<cid>]`,
|
|
164
|
+
* see `spec/2026-05-05-solvernet-creation-and-launch.md` §12) and leaves no
|
|
165
|
+
* on-chain footprint. An operator only becomes visible to the network once
|
|
166
|
+
* they claim a task — `TaskAttemptCreated` is the first on-chain event tied
|
|
167
|
+
* to (operator, SolverNet). This method therefore counts *participating*
|
|
168
|
+
* operators (operators who have claimed at least one task), which is the
|
|
169
|
+
* only honest cross-operator count derivable from the indexer / chain.
|
|
170
|
+
*
|
|
171
|
+
* Task pagination is hard-capped (`MAX_OPERATOR_COUNT_TASK_PAGES` in each
|
|
172
|
+
* backing) so a pathological task volume cannot turn this into an unbounded
|
|
173
|
+
* scan; on a SolverNet beyond the cap the count is a lower bound.
|
|
174
|
+
*
|
|
175
|
+
* Returns `0` when no operator has attempted a task on the SolverNet yet.
|
|
176
|
+
*/
|
|
177
|
+
getSolverNetOperatorCount(manifestCid: string): Promise<number>;
|
|
148
178
|
/**
|
|
149
179
|
* Returns envelope refs matching the query. Refs only — byte retrieval is
|
|
150
180
|
* done by the corpus library on demand.
|
|
@@ -200,7 +230,21 @@ export interface DiscoveryAPI {
|
|
|
200
230
|
* The `withFallback` wrapper catches this class (plus network-shaped errors)
|
|
201
231
|
* and routes to the floor implementation for the duration of the outage.
|
|
202
232
|
*/
|
|
233
|
+
/**
|
|
234
|
+
* Machine-readable reason a discovery read failed. `rpc_rate_limited` is the
|
|
235
|
+
* one branch callers act on distinctly: it means the configured RPC endpoint
|
|
236
|
+
* returned a 429 (or otherwise rate-limited the daemon), which — on the shared
|
|
237
|
+
* default RPC — is an operator-actionable condition ("add your own key"), not
|
|
238
|
+
* an indexer outage. Any other transport failure is left untyped (`undefined`).
|
|
239
|
+
*/
|
|
240
|
+
export type DiscoveryUnavailableCode = 'rpc_rate_limited';
|
|
203
241
|
export declare class DiscoveryUnavailableError extends Error {
|
|
204
242
|
readonly cause?: unknown;
|
|
205
|
-
|
|
243
|
+
/**
|
|
244
|
+
* Typed reason, when one can be classified — currently only
|
|
245
|
+
* `rpc_rate_limited`, surfaced end-to-end so the operator UI can render a
|
|
246
|
+
* distinct "your RPC is throttled" message instead of a generic failure.
|
|
247
|
+
*/
|
|
248
|
+
readonly code?: DiscoveryUnavailableCode;
|
|
249
|
+
constructor(message: string, cause?: unknown, code?: DiscoveryUnavailableCode);
|
|
206
250
|
}
|
package/dist/discovery/types.js
CHANGED
|
@@ -9,21 +9,19 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Spec: spec/2026-05-11-discovery-api-and-shared-indexer.md §5.
|
|
11
11
|
*/
|
|
12
|
-
// ── Error ────────────────────────────────────────────────────────────────────
|
|
13
|
-
/**
|
|
14
|
-
* Thrown by a DiscoveryAPI implementation when it is temporarily unable to
|
|
15
|
-
* serve a request — e.g. indexer unreachable, embedded Ponder still syncing,
|
|
16
|
-
* hosted subgraph 5xx.
|
|
17
|
-
*
|
|
18
|
-
* The `withFallback` wrapper catches this class (plus network-shaped errors)
|
|
19
|
-
* and routes to the floor implementation for the duration of the outage.
|
|
20
|
-
*/
|
|
21
12
|
export class DiscoveryUnavailableError extends Error {
|
|
22
13
|
cause;
|
|
23
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Typed reason, when one can be classified — currently only
|
|
16
|
+
* `rpc_rate_limited`, surfaced end-to-end so the operator UI can render a
|
|
17
|
+
* distinct "your RPC is throttled" message instead of a generic failure.
|
|
18
|
+
*/
|
|
19
|
+
code;
|
|
20
|
+
constructor(message, cause, code) {
|
|
24
21
|
super(message);
|
|
25
22
|
this.name = 'DiscoveryUnavailableError';
|
|
26
23
|
this.cause = cause;
|
|
24
|
+
this.code = code;
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/discovery/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/discovery/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAkRH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAChC,KAAK,CAAW;IAClC;;;;OAIG;IACM,IAAI,CAA4B;IAEzC,YAAY,OAAe,EAAE,KAAe,EAAE,IAA+B;QAC3E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
* operators can see why their daemon is running slowly. After the window
|
|
13
13
|
* elapses the wrapper probes the primary again on the next call.
|
|
14
14
|
*
|
|
15
|
+
* NOTE (2026-05-23): this wrapper is no longer engaged by default. The
|
|
16
|
+
* factory installs it only when `discovery.fallbackToOnchain === true` (an
|
|
17
|
+
* explicit opt-in). Without the opt-in, indexer outages propagate as
|
|
18
|
+
* DiscoveryUnavailableError so the operator-app surfaces them rather than the
|
|
19
|
+
* daemon silently storming shared RPC. The wrapper itself is unchanged for
|
|
20
|
+
* operators who still want it.
|
|
21
|
+
*
|
|
15
22
|
* Spec: spec/2026-05-11-discovery-api-and-shared-indexer.md §9.3.
|
|
16
23
|
*/
|
|
17
24
|
import type { DiscoveryAPI } from './types.js';
|
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
* operators can see why their daemon is running slowly. After the window
|
|
13
13
|
* elapses the wrapper probes the primary again on the next call.
|
|
14
14
|
*
|
|
15
|
+
* NOTE (2026-05-23): this wrapper is no longer engaged by default. The
|
|
16
|
+
* factory installs it only when `discovery.fallbackToOnchain === true` (an
|
|
17
|
+
* explicit opt-in). Without the opt-in, indexer outages propagate as
|
|
18
|
+
* DiscoveryUnavailableError so the operator-app surfaces them rather than the
|
|
19
|
+
* daemon silently storming shared RPC. The wrapper itself is unchanged for
|
|
20
|
+
* operators who still want it.
|
|
21
|
+
*
|
|
15
22
|
* Spec: spec/2026-05-11-discovery-api-and-shared-indexer.md §9.3.
|
|
16
23
|
*/
|
|
17
24
|
import { DiscoveryUnavailableError } from './types.js';
|
|
@@ -145,6 +152,9 @@ export function withFallback(primary, floor, opts = {}) {
|
|
|
145
152
|
getLifecycleStatus(manifestCid) {
|
|
146
153
|
return dispatch(() => primary.getLifecycleStatus(manifestCid), () => floor.getLifecycleStatus(manifestCid));
|
|
147
154
|
},
|
|
155
|
+
getSolverNetOperatorCount(manifestCid) {
|
|
156
|
+
return dispatch(() => primary.getSolverNetOperatorCount(manifestCid), () => floor.getSolverNetOperatorCount(manifestCid));
|
|
157
|
+
},
|
|
148
158
|
queryEnvelopes(query) {
|
|
149
159
|
return dispatch(() => primary.queryEnvelopes(query), () => floor.queryEnvelopes(query));
|
|
150
160
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-fallback.js","sourceRoot":"","sources":["../../src/discovery/with-fallback.ts"],"names":[],"mappings":"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AAI;YACvB,OAAO,QAAQ,CACb,GAAG,EAAE,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,EACxC,GAAG,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAAC,CACvC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Phase 1 (master): generate mnemonic → fund master EOA
|
|
5
5
|
* Phase 2 (per-service): derive agent → stake → deploy mech
|
|
6
6
|
*/
|
|
7
|
-
import type { FleetState, FleetBootstrapResult } from './types.js';
|
|
7
|
+
import type { FleetState, FleetBootstrapResult, StakingMode } from './types.js';
|
|
8
8
|
import { requestTestnetFunding } from './faucet.js';
|
|
9
9
|
import { type JinnOnchainNetwork } from './viem-clients.js';
|
|
10
10
|
/**
|
|
@@ -16,33 +16,65 @@ import { type JinnOnchainNetwork } from './viem-clients.js';
|
|
|
16
16
|
* ≈ 0.0046 ETH minimum; 2× gives ≈ 0.009–0.010 ETH — the bootstrap
|
|
17
17
|
* `minEoaGasEth` default.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
* on-chain (i.e. the fleet is truly cold — OR migration-wiped, where
|
|
21
|
-
* services exist in shape but lost their on-chain anchor). Once any service
|
|
22
|
-
* has committed a `service_id`, the fleet is past the cold-start cliff and
|
|
23
|
-
* 1× suffices.
|
|
19
|
+
* Used by {@link stage1MinMasterEth} to size the Stage 1 master gas budget.
|
|
24
20
|
*
|
|
25
21
|
* Single source of truth: imported by funding-plan.ts.
|
|
26
22
|
*/
|
|
27
23
|
export declare const STANDARD_MASTER_BOOTSTRAP_MULTIPLIER = 2n;
|
|
28
24
|
/**
|
|
29
|
-
*
|
|
25
|
+
* Self-bond mode needs much more ETH per service than standard mode because
|
|
26
|
+
* the master funds the agent which then pays for: Safe deploy, 5 service
|
|
27
|
+
* registry txs (create, activate, register, deploy, stake), and mech deploy.
|
|
28
|
+
* Roughly 15 txs at varying gas costs. 0.03 ETH per service is a safe
|
|
29
|
+
* estimate. Single source of truth: imported by funding-plan.ts.
|
|
30
|
+
*/
|
|
31
|
+
export declare const SELF_BOND_ETH_PER_SERVICE = 30000000000000000n;
|
|
32
|
+
/**
|
|
33
|
+
* Single source of truth for the master-ETH cold-start funding gate.
|
|
34
|
+
*
|
|
35
|
+
* Both the mutating bootstrapper ({@link FleetBootstrapper.ensureStage1And2})
|
|
36
|
+
* and the read-only funding plan (`planFleetFunding` in funding-plan.ts) route
|
|
37
|
+
* through this helper, so a migration-wiped fleet computes an identical
|
|
38
|
+
* required-ETH gate in both views. Re-implementing the gate inline at either
|
|
39
|
+
* call site is the u34i cross-module invariant-drift hazard — do not do it.
|
|
40
|
+
*
|
|
41
|
+
* Standard-mode gate has three branches:
|
|
42
|
+
* 1. `standardFleetAlreadyComplete` — fleet already has its full target of
|
|
43
|
+
* operational services and no deprecated-setup migration is pending →
|
|
44
|
+
* `0n` (nothing to fund).
|
|
45
|
+
* 2. `preStage1` — no fleet identity yet (`fleet_stage === 'none'` or no
|
|
46
|
+
* fleet state at all) → the Stage 1 gate from {@link stage1MinMasterEth},
|
|
47
|
+
* which covers the master → agent transfer plus the master's own gas
|
|
48
|
+
* reserve. See jinn-mono-u34i.
|
|
49
|
+
* 3. otherwise — the Stage 2 master gas budget: `minEoaGasEth` (stake gas)
|
|
50
|
+
* plus a per-extra-service top-up transfer for services 2..N.
|
|
51
|
+
*
|
|
52
|
+
* Self-bond mode is a flat `SELF_BOND_ETH_PER_SERVICE × targetServices`
|
|
53
|
+
* regardless of stage.
|
|
30
54
|
*
|
|
31
55
|
* @param services Persisted service states
|
|
32
56
|
* @param minEoaGasEth Configured minimum EOA gas target (wei)
|
|
33
|
-
* @param
|
|
34
|
-
*
|
|
57
|
+
* @param pendingSetupMigration True when a deprecated testnet setup is
|
|
58
|
+
* detected — suppresses the `standardFleetAlreadyComplete` short-circuit so a
|
|
59
|
+
* migration-wiped fleet is correctly treated as needing funding. Both call
|
|
60
|
+
* sites MUST pass this so the bootstrapper gate and the funding-plan view
|
|
61
|
+
* agree for migration-wiped fleets.
|
|
35
62
|
* @param targetServices How many services the fleet is aiming for
|
|
63
|
+
* @param stakingMode `'standard'` (default) or `'self-bond'`
|
|
64
|
+
* @param preStage1 True when fleet identity is not yet provisioned —
|
|
65
|
+
* selects the Stage 1 gate. The bootstrapper passes `false` here because it
|
|
66
|
+
* only computes this gate *after* `ensureStage1` succeeds.
|
|
36
67
|
*/
|
|
37
|
-
export declare function computeRequiredMasterEth({ services, minEoaGasEth,
|
|
68
|
+
export declare function computeRequiredMasterEth({ services, minEoaGasEth, pendingSetupMigration, targetServices, stakingMode, preStage1, }: {
|
|
38
69
|
services: Array<{
|
|
39
|
-
service_id
|
|
70
|
+
service_id?: number | null | undefined;
|
|
40
71
|
step?: string;
|
|
41
72
|
}>;
|
|
42
73
|
minEoaGasEth: bigint;
|
|
43
|
-
standardMultiplier?: bigint;
|
|
44
74
|
pendingSetupMigration?: boolean;
|
|
45
75
|
targetServices?: number;
|
|
76
|
+
stakingMode?: StakingMode;
|
|
77
|
+
preStage1?: boolean;
|
|
46
78
|
}): bigint;
|
|
47
79
|
/** Master ETH required to FINISH the whole bootstrap from a fresh start (not
|
|
48
80
|
* just to enter Stage 1). Centralized so the daemon's ensureStage1 gate,
|
|
@@ -34,36 +34,80 @@ const SAFE_TOKEN_BOOTSTRAP_MULTIPLIER = 2n;
|
|
|
34
34
|
* ≈ 0.0046 ETH minimum; 2× gives ≈ 0.009–0.010 ETH — the bootstrap
|
|
35
35
|
* `minEoaGasEth` default.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
* on-chain (i.e. the fleet is truly cold — OR migration-wiped, where
|
|
39
|
-
* services exist in shape but lost their on-chain anchor). Once any service
|
|
40
|
-
* has committed a `service_id`, the fleet is past the cold-start cliff and
|
|
41
|
-
* 1× suffices.
|
|
37
|
+
* Used by {@link stage1MinMasterEth} to size the Stage 1 master gas budget.
|
|
42
38
|
*
|
|
43
39
|
* Single source of truth: imported by funding-plan.ts.
|
|
44
40
|
*/
|
|
45
41
|
export const STANDARD_MASTER_BOOTSTRAP_MULTIPLIER = 2n;
|
|
46
42
|
/**
|
|
47
|
-
*
|
|
43
|
+
* Self-bond mode needs much more ETH per service than standard mode because
|
|
44
|
+
* the master funds the agent which then pays for: Safe deploy, 5 service
|
|
45
|
+
* registry txs (create, activate, register, deploy, stake), and mech deploy.
|
|
46
|
+
* Roughly 15 txs at varying gas costs. 0.03 ETH per service is a safe
|
|
47
|
+
* estimate. Single source of truth: imported by funding-plan.ts.
|
|
48
|
+
*/
|
|
49
|
+
export const SELF_BOND_ETH_PER_SERVICE = 30000000000000000n; // 0.03 ETH
|
|
50
|
+
/**
|
|
51
|
+
* Single source of truth for the master-ETH cold-start funding gate.
|
|
52
|
+
*
|
|
53
|
+
* Both the mutating bootstrapper ({@link FleetBootstrapper.ensureStage1And2})
|
|
54
|
+
* and the read-only funding plan (`planFleetFunding` in funding-plan.ts) route
|
|
55
|
+
* through this helper, so a migration-wiped fleet computes an identical
|
|
56
|
+
* required-ETH gate in both views. Re-implementing the gate inline at either
|
|
57
|
+
* call site is the u34i cross-module invariant-drift hazard — do not do it.
|
|
58
|
+
*
|
|
59
|
+
* Standard-mode gate has three branches:
|
|
60
|
+
* 1. `standardFleetAlreadyComplete` — fleet already has its full target of
|
|
61
|
+
* operational services and no deprecated-setup migration is pending →
|
|
62
|
+
* `0n` (nothing to fund).
|
|
63
|
+
* 2. `preStage1` — no fleet identity yet (`fleet_stage === 'none'` or no
|
|
64
|
+
* fleet state at all) → the Stage 1 gate from {@link stage1MinMasterEth},
|
|
65
|
+
* which covers the master → agent transfer plus the master's own gas
|
|
66
|
+
* reserve. See jinn-mono-u34i.
|
|
67
|
+
* 3. otherwise — the Stage 2 master gas budget: `minEoaGasEth` (stake gas)
|
|
68
|
+
* plus a per-extra-service top-up transfer for services 2..N.
|
|
69
|
+
*
|
|
70
|
+
* Self-bond mode is a flat `SELF_BOND_ETH_PER_SERVICE × targetServices`
|
|
71
|
+
* regardless of stage.
|
|
48
72
|
*
|
|
49
73
|
* @param services Persisted service states
|
|
50
74
|
* @param minEoaGasEth Configured minimum EOA gas target (wei)
|
|
51
|
-
* @param
|
|
52
|
-
*
|
|
75
|
+
* @param pendingSetupMigration True when a deprecated testnet setup is
|
|
76
|
+
* detected — suppresses the `standardFleetAlreadyComplete` short-circuit so a
|
|
77
|
+
* migration-wiped fleet is correctly treated as needing funding. Both call
|
|
78
|
+
* sites MUST pass this so the bootstrapper gate and the funding-plan view
|
|
79
|
+
* agree for migration-wiped fleets.
|
|
53
80
|
* @param targetServices How many services the fleet is aiming for
|
|
81
|
+
* @param stakingMode `'standard'` (default) or `'self-bond'`
|
|
82
|
+
* @param preStage1 True when fleet identity is not yet provisioned —
|
|
83
|
+
* selects the Stage 1 gate. The bootstrapper passes `false` here because it
|
|
84
|
+
* only computes this gate *after* `ensureStage1` succeeds.
|
|
54
85
|
*/
|
|
55
|
-
export function computeRequiredMasterEth({ services, minEoaGasEth,
|
|
56
|
-
|
|
57
|
-
|
|
86
|
+
export function computeRequiredMasterEth({ services, minEoaGasEth, pendingSetupMigration = false, targetServices = 1, stakingMode = 'standard', preStage1 = false, }) {
|
|
87
|
+
if (stakingMode !== 'standard') {
|
|
88
|
+
return SELF_BOND_ETH_PER_SERVICE * BigInt(targetServices);
|
|
89
|
+
}
|
|
90
|
+
// Reconciled `standardFleetAlreadyComplete` — a single definition replacing
|
|
91
|
+
// the three historic inline variants. Adopts the strictest of them (the
|
|
92
|
+
// FleetBootstrapper variant): the fleet must have at least `targetServices`
|
|
93
|
+
// rows AND every row must be operational AND no deprecated-setup migration
|
|
94
|
+
// may be pending. A migration-wiped fleet (which sets
|
|
95
|
+
// `pendingSetupMigration`) is therefore never short-circuited to `0n`.
|
|
96
|
+
const standardFleetAlreadyComplete = services.length >= targetServices &&
|
|
97
|
+
services.every(s => s.step !== undefined && isOperationalServiceStep(s.step)) &&
|
|
98
|
+
!pendingSetupMigration;
|
|
58
99
|
if (standardFleetAlreadyComplete)
|
|
59
100
|
return 0n;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
101
|
+
if (preStage1) {
|
|
102
|
+
// Stage 1 gate: master → agent transfer (STAGE1_AGENT_ETH) + the master's
|
|
103
|
+
// own gas reserve, plus per-extra-service transfers. See jinn-mono-u34i.
|
|
104
|
+
return stage1MinMasterEth({ minEoaGasEth }, targetServices);
|
|
105
|
+
}
|
|
106
|
+
// Stage 2 master gas budget — covers distributor.stake() (~0.003 ETH at
|
|
107
|
+
// typical 6 gwei Base Sepolia) plus per-extra-service top-up transfers.
|
|
108
|
+
// Service 1 piggybacks on HD-1's Stage 1 funding, so the base term is a
|
|
109
|
+
// single `minEoaGasEth` (not `× 2`). See jinn-mono-u34i.
|
|
110
|
+
return minEoaGasEth + minEoaGasEth * BigInt(Math.max(0, targetServices - 1));
|
|
67
111
|
}
|
|
68
112
|
/** Master ETH required to FINISH the whole bootstrap from a fresh start (not
|
|
69
113
|
* just to enter Stage 1). Centralized so the daemon's ensureStage1 gate,
|
|
@@ -429,12 +473,8 @@ export class FleetBootstrapper {
|
|
|
429
473
|
// Phase 1b: Check master funding for the full operator path.
|
|
430
474
|
const masterAddress = state.master_address;
|
|
431
475
|
let masterBalance = await this.publicClient.getBalance({ address: masterAddress });
|
|
432
|
-
//
|
|
433
|
-
//
|
|
434
|
-
// (create, activate, register, deploy, stake), and mech deploy. Roughly
|
|
435
|
-
// 15 txs at varying gas costs. 0.03 ETH per service is a safe estimate.
|
|
436
|
-
// On re-runs, include ETH already held by funded agents/safes in the total.
|
|
437
|
-
const SELF_BOND_ETH_PER_SERVICE = 30000000000000000n; // 0.03 ETH
|
|
476
|
+
// On re-runs, include ETH already held by funded agents/safes in the
|
|
477
|
+
// total for self-bond mode.
|
|
438
478
|
let systemEth = masterBalance;
|
|
439
479
|
if (this.stakingMode === 'self-bond') {
|
|
440
480
|
for (const svc of state.services) {
|
|
@@ -456,25 +496,20 @@ export class FleetBootstrapper {
|
|
|
456
496
|
stakingMode: this.stakingMode,
|
|
457
497
|
currentStakingContract: this.config.stakingContract,
|
|
458
498
|
}).services.length > 0;
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
// 0.020 ETH budget by ~127k gwei of Stage 1 gas burn, causing a
|
|
474
|
-
// second funding prompt.
|
|
475
|
-
: this.config.minEoaGasEth +
|
|
476
|
-
this.config.minEoaGasEth * BigInt(Math.max(0, this.targetServices - 1)))
|
|
477
|
-
: SELF_BOND_ETH_PER_SERVICE * BigInt(this.targetServices);
|
|
499
|
+
// Single source of truth: the master-ETH gate is computed by
|
|
500
|
+
// `computeRequiredMasterEth` (defined above), the same helper the
|
|
501
|
+
// read-only `planFleetFunding` view routes through. Re-deriving it inline
|
|
502
|
+
// here is the u34i cross-module invariant-drift hazard. `ensureStage1And2`
|
|
503
|
+
// only reaches this point AFTER `ensureStage1` has succeeded, so the
|
|
504
|
+
// fleet is always past Stage 1 — `preStage1` is `false`.
|
|
505
|
+
const requiredMasterEth = computeRequiredMasterEth({
|
|
506
|
+
services: state.services,
|
|
507
|
+
minEoaGasEth: this.config.minEoaGasEth,
|
|
508
|
+
pendingSetupMigration,
|
|
509
|
+
targetServices: this.targetServices,
|
|
510
|
+
stakingMode: this.stakingMode,
|
|
511
|
+
preStage1: false,
|
|
512
|
+
});
|
|
478
513
|
const autoFaucetEnabled = this.autoTestnetFaucet;
|
|
479
514
|
// Re-sum system ETH (master + agent/safe balances for self-bond mode).
|
|
480
515
|
// Hoisted so the drip loop below can refresh cheaply.
|
|
@@ -1098,16 +1133,23 @@ export class FleetBootstrapper {
|
|
|
1098
1133
|
// calling stake() again would revert with AgentInstanceRegistered (selector 0x631695bd)
|
|
1099
1134
|
// and there is nothing useful the operator can do without rotating the agent EOA.
|
|
1100
1135
|
// Fail fast with a typed error instead of letting the contract revert.
|
|
1136
|
+
//
|
|
1137
|
+
// ServiceRegistryL2 exposes the `mapAgentInstanceOperators(address) → address` mapping:
|
|
1138
|
+
// it returns the operator address that registered the given agent instance, or the
|
|
1139
|
+
// zero address when no operator has bound that instance. A non-zero return means the
|
|
1140
|
+
// EOA is already bound. (There is no `mapAgentInstances(address) → uint256` getter on
|
|
1141
|
+
// the deployed registry — an earlier draft of this guard referenced one and was a
|
|
1142
|
+
// permanent no-op.)
|
|
1101
1143
|
if (svc.agent_address && svc.service_id === null && this.config.serviceRegistry) {
|
|
1102
1144
|
let alreadyBound = false;
|
|
1103
1145
|
try {
|
|
1104
|
-
const
|
|
1146
|
+
const boundOperator = (await this.publicClient.readContract({
|
|
1105
1147
|
address: getAddress(this.config.serviceRegistry),
|
|
1106
1148
|
abi: SERVICE_REGISTRY_L2_ABI,
|
|
1107
|
-
functionName: '
|
|
1149
|
+
functionName: 'mapAgentInstanceOperators',
|
|
1108
1150
|
args: [getAddress(svc.agent_address)],
|
|
1109
1151
|
}));
|
|
1110
|
-
alreadyBound =
|
|
1152
|
+
alreadyBound = boundOperator !== '0x0000000000000000000000000000000000000000';
|
|
1111
1153
|
}
|
|
1112
1154
|
catch {
|
|
1113
1155
|
// Registry read failure is non-fatal — proceed and let stake() surface
|