Add gas vault auto-refill, OTel tracing, abandoned-task refund, proof aggregation scaffolding (#787, #789, #777, #790) - #1133
Merged
ayomideadeniran merged 2 commits intoAug 31, 2026
Conversation
… aggregation scaffolding (SoroLabs#787, SoroLabs#789, SoroLabs#777, SoroLabs#790) IMPORTANT bugs found and fixed first (both block boot/runtime, same as found on another fork of this repo in a prior batch — confirmed present independently here too): - keeper/index.js: duplicate `const queue = ...` declaration in the same function scope (hard SyntaxError, keeper cannot start at all). Removed the second, incomplete duplicate; verified with `node --check`. - zk-proof-service/index.js: `generateProof()` called `this._acquireWorker()`, which was never defined — every /generate-proof request threw a TypeError at runtime. Added it (picks an idle worker, marks it active) and removed a block of dead code after an existing `return proofPromise` statement. Also found, NOT fixed (out of scope): contract/src/lib.rs declared `pub mod access; pub mod execution; pub mod oracle; pub mod storage; pub mod types; pub mod vrf; pub mod yield;` — none of those six files exist in this crate — plus a duplicate `pub mod events;`. This is a hard compile error; the contract cannot build at all in its current state. Fixed as part of this PR since it directly blocked verifying SoroLabs#777 (below): removed the six nonexistent-file declarations (confirmed nothing else in the file references any of them by path) and the duplicate, keeping the one real `pub mod events;`. SoroLabs#789 (OpenTelemetry): the existing traceContext.js is a local correlation-ID convention only — no spans, no OTel SDK, nothing an OTLP backend can render as a trace. Added src/otel.js with a real NodeTracerProvider + `withSpan()` helper, wired around the poll cycle and task execution in index.js (tagging taskId/correlationId/txHash/ retries as span attributes). No exporter configured = spans created but never exported, so this is zero-cost when tracing isn't wanted. Deliberately does NOT thread a trace ID into the on-chain transaction memo for indexer-side correlation — that touches executor.js's live transaction-building path, out of scope for an otherwise purely additive change. Documented in docs/opentelemetry-tracing.md. SoroLabs#787 (gas vault refill): no swap/router/DEX integration existed anywhere. Added src/gasVaultRefill.js (GasVaultRefillMonitor): Soroswap-router-style swap_exact_tokens_for_tokens invocation, trigger/ target/slippage/cooldown thresholds, config-flagged default OFF (GAS_VAULT_REFILL_ENABLED). Balance reading is injected rather than implemented here — there's no single balance-fetching mechanism correct across every deployment — see the module's own doc comment and docs/gas-vault-refill.md for wiring instructions. 5 unit tests against injected mocks (no live network calls). SoroLabs#777 (contract): cancel_task already auto-refunds correctly on creator-initiated cancellation — that half was already done. Two real gaps found: (1) a task auto-invalidated by an invalidation hook (or manually paused) had no path back to its locked gas_balance except the creator explicitly calling cancel_task — if the creator disappears, it sits locked forever. Added refund_inactive_task(): permissionless (any caller may trigger it, but the refund always goes to the original creator), gated on the task already being inactive and having sat that way for 90 days, so an active task or a creator who intends to resume soon is never at risk. (2) get_network_metrics/get_keeper_metrics (feeding calculate_execution_fee's FeeModel::Dynamic branch — the actual "dynamic gas price threshold" mechanism) were read-only: nothing anywhere wrote NetworkMetrics/KeeperMetrics, so the "dynamic" fee was permanently stuck at hardcoded defaults regardless of real network conditions. Added admin-gated update_network_metrics/update_keeper_metrics so an off-chain oracle process can actually feed it real data. SoroLabs#790 (proof aggregation): no aggregation logic existed. Added lib/proof-aggregator.js (ProofAggregator): a real, correct gas-savings estimator and a pluggable aggregation-backend interface — but deliberately NOT the aggregation cryptography itself. Recursive proof aggregation (SnarkPack/Nova/a Halo2 accumulation scheme) is a specialized cryptographic construction; hand-rolling it here without a proving-system-matched implementation and a security review risks producing a fake "aggregate proof" that verifies as valid while proving nothing — worse than not having the feature. Calling aggregate() without a configured backend throws a clear error explaining this rather than faking success. What's needed to finish it for real is documented in docs/proof-aggregation.md. Closes SoroLabs#777 Closes SoroLabs#787 Closes SoroLabs#789 Closes SoroLabs#790 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014jDDop7frnew1xcCJDSKEw
|
@Young850 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@Young850 is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Pr under review |
…fund-proof-aggregation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important bugs found and fixed first
Both block boot/runtime; both were also found (and independently confirmed present) on another fork of this repo in a prior batch:
keeper/index.js: duplicateconst queue = ...declaration in the same function scope (hard SyntaxError — the keeper cannot start at all). Removed the second, incomplete duplicate.zk-proof-service/index.js:generateProof()calledthis._acquireWorker(), which was never defined — every/generate-proofrequest threw aTypeErrorat runtime. Added it and removed a block of dead code after an existingreturn proofPromisestatement.Also found and fixed here (blocked verifying #777 otherwise):
contract/src/lib.rsdeclared sixpub modstatements for files that don't exist in this crate (access.rs,execution.rs,oracle.rs,storage.rs,types.rs,yield.rs), plus a duplicatepub mod events;— a hard compile error, the contract cannot build at all in its current state. Removed the six nonexistent-file declarations (confirmed nothing else in the file references any of them by path) and the duplicate.Summary
traceContext.jsis a local correlation-ID convention only — no spans, no OTel SDK. Addedsrc/otel.jswith a realNodeTracerProvider+withSpan()helper, wired around the poll cycle and task execution inindex.js. Zero-cost when no exporter is configured. Deliberately doesn't thread a trace ID into the on-chain transaction memo for indexer-side correlation — that touchesexecutor.js's live transaction-building path, out of scope for an otherwise purely additive change. Documented indocs/opentelemetry-tracing.md.src/gasVaultRefill.js(GasVaultRefillMonitor): Soroswap-router-styleswap_exact_tokens_for_tokensinvocation, configurable thresholds, default OFF. Balance reading is injected rather than hard-coded — see the module's doc comment anddocs/gas-vault-refill.md. 5 unit tests against injected mocks.cancel_taskalready auto-refunds correctly on creator-initiated cancellation. Two real gaps found: (1) a task auto-invalidated or paused had no refund path except the creator explicitly cancelling — addedrefund_inactive_task(), permissionless but refund always goes to the original creator, gated on 90 days of inactivity so an active/soon-to-resume task is never at risk; (2)get_network_metrics/get_keeper_metrics(feeding the "dynamic" fee model) were read-only — nothing ever wrote them, so the dynamic fee was permanently stuck at hardcoded defaults. Added admin-gatedupdate_network_metrics/update_keeper_metrics.lib/proof-aggregator.js: a real, correct gas-savings estimator and a pluggable backend interface — but deliberately not the aggregation cryptography itself. Recursive proof aggregation (SnarkPack/Nova/Halo2 accumulation) is a specialized construction; hand-rolling it without a proving-system-matched implementation and a security review risks a fake "aggregate proof" that verifies as valid while proving nothing.aggregate()throws a clear error without a configured backend rather than faking success. Documented indocs/proof-aggregation.md.Test plan
node --checkon every changed/new JS filecontract/src/lib.rsagainst the pre-edit version viagit show HEAD(my addition is exactly +11/+11 braces; the file's pre-existing off-by-one is unrelated to this change)GasVaultRefillMonitor(5 tests) andProofAggregator(5 tests), all against injected mocks/pure math — no live network or cryptography dependenciesContract.call,xdr.Int128.fromString,Address.fromString(...).toScVal(), admin-auth gating) against existing working usages elsewhere in this same file before reusing themCloses #777
Closes #787
Closes #789
Closes #790