feat: chain-aware fill window, per-user intent cap, remove dead metho… - #362
Merged
Conversation
…ds, slash reconciliation Issue 1 — chain-aware fill window in acceptIfOpen - Add CHAIN_FILL_WINDOW_DEFAULTS and DEFAULT_FILL_WINDOW_SECONDS to configuration.ts (mirrors CHAIN_DEADLINE_DEFAULTS shape, documented with per-chain rationale: stellar=120s, base/optimism/arbitrum/avalanche=600s, polygon=900s, ethereum=1800s). - IntentsService.acceptIfOpen() now looks up the intent's srcChain and uses CHAIN_FILL_WINDOW_DEFAULTS[srcChain] instead of the hardcoded 300s; falls back to DEFAULT_FILL_WINDOW_SECONDS for unknown chains. - Add 4 unit tests to acceptIfOpen describe block: stellar 120s window, ethereum 1800s window, stellar < ethereum assert distinct deadlines, and unknown-chain fallback to DEFAULT_FILL_WINDOW_SECONDS. - Update docs/solver-onboarding.md slashing section with a per-chain fill window table and operator guidance on planning within these windows. Issue 2 — per-user open-intent cap - Add MAX_OPEN_INTENTS_PER_USER=50 named constant and countOpenByUser() method to IntentsService; designed to stay efficient against a future Prisma COUNT query without touching the interface (issue stellar-vortex-protocol#1). - IntentsController.create() checks countOpenByUser before creating and throws ConflictException(409) with an explicit message distinguishing it from the existing rate-limit 429. - Add e2e test in test/intent-lifecycle.e2e-spec.ts: creates exactly MAX_OPEN_INTENTS_PER_USER intents, asserts N+1 returns 409 with cap message, cancels one, asserts creation succeeds again. - Update docs/runbooks/on-call.md troubleshooting table to reference the real cap (MAX_OPEN_INTENTS_PER_USER in src/intents/intents.service.ts) instead of the old "consider adding a cap" suggestion. Issue 3 — remove dead markLive/markOffline from SolversService Decision: removed (not wired up, no distinct call site from reactivate/ deactivate); will file a separate issue for real WS-driven liveness detection once issue stellar-vortex-protocol#96 WS auth lands. - Delete markLive() and markOffline() from SolversService. - Fix pre-existing bug in reactivate(): isActive was an undefined variable reference; corrected to isActive: true. - Remove the markLive test from solvers.service.spec.ts. Issue 4 — recordFailedFill pending-slash reconciliation - Add SolverPenaltyState ('pending'|'confirmed'|'failed') type and SolverPendingPenalty interface to solvers.types.ts. - SolversService: add pendingPenalties Map, update recordFailedFill to accept intentId and store a pending entry; add confirmPenalty(intentId, slashAmount) which reconciles bondAmount on on-chain confirmation; add rollbackPenalty(intentId) which decrements fillsFailed when the on-chain slash submission fails or never confirms. - IntentsSweeperService.slashMissedFill: call recordFailedFill(solver, intentId) first (pending state), then submit on-chain; on submission failure call rollbackPenalty so the solver is not permanently penalised for an unenforced slash. - EventIngestionService: inject SolversService, add solver_slashed branch to processEvent, add handleSolverSlashed which extracts (solverAddress, intentId, slashAmount) from the event topic and calls confirmPenalty; malformed events are warned and skipped without stalling the poll loop. - SorobanModule: import SolversModule so SolversService is available to EventIngestionService. - event-ingestion.service.spec.ts: pass fakeSolversService() to constructor. - Update docs/solver-onboarding.md with pending-vs-confirmed slash lifecycle. Fixes: sweeper spec missing imports (ALPHA_ADDR, SOLVERS_REPOSITORY, buildIntentsService), gateway spec 3-arg IntentsService construction, intents.service.spec.ts makeService/buildService missing repo arg and PrismaService provider. All 4 modified test suites pass (30/30 tests).
|
@abrak01 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! 🚀 |
…p-slash-reconciliation
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.
…ds, slash reconciliation
Issue 1 — chain-aware fill window in acceptIfOpen
Issue 2 — per-user open-intent cap
Issue 3 — remove dead markLive/markOffline from SolversService Decision: removed (not wired up, no distinct call site from reactivate/ deactivate); will file a separate issue for real WS-driven liveness detection once issue #96 WS auth lands.
Issue 4 — recordFailedFill pending-slash reconciliation
Fixes: sweeper spec missing imports (ALPHA_ADDR, SOLVERS_REPOSITORY, buildIntentsService), gateway spec 3-arg IntentsService construction, intents.service.spec.ts makeService/buildService missing repo arg and PrismaService provider. All 4 modified test suites pass (30/30 tests).
Summary
Related issue
Type of change
Component
vortex-contract)vortex-backend)vortex-frontend)Checklist
Screenshots / notes
closes #265
closes #266
closes #267
closes #268