Repository navigation
[simplex]: keep an order's evaluation for its confirmations plus 5 minutes, and redo it if it still expires, 0.18.3 - #1434
Merged
Conversation
… its bids The bid loop's pin keeps only what is still live when the loop starts, and a confirmation or chain-queue wait longer than CACHE_EXPIRY_MS left it with no plans and no gas estimate, so every bid failed with "No cached gas estimate" and the order was never evaluated again. The queued task now checks the gas estimate after pinning and, when it is gone, evaluates the order again before any bid goes out.
Member
|
The issue here is that the order from base takes some time for it to reach required confirmations, can't we cache the evaluation for the duration of the confirmation period? |
Member
Author
Yeah, I can change the default expiry to use the blocks + the 60s. |
…nutes, 0.18.3 Every order-keyed CacheService entry now stores its own expiresAt. The default lifetime is 300 s, and while an order waits for its source confirmations, handleNewOrder registers how long they take (required confirmations times the source block time measured at startup), so what the evaluation caches lives the default plus that wait. The wait is released once evaluation and confirmation are both done; entries keep the expiry they were written with. Bumps @hyperbridge/simplex and simplex-desktop to 0.18.3.
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.
What this does
IntentFillerevaluates an order while it waits for the order's source confirmations, then queues its bids on the destination chain. Everything the evaluation cached (gas estimate, bid plans, filler outputs) expired 60 s after it was written. The bid loop's pin from #1424 keeps only what is still live when the loop starts.When the confirmation wait outlasted that, the loop started with no plans and no gas estimate. Every bid then failed in
prepareBidUserOpwithNo cached gas estimate found for order <id>, and the order was never evaluated again. Seen on a BSC order: evaluation complete at 18:58:00, confirmed on source at 18:59:18, bid failed at 18:59:19.Cache lifetime
CacheServiceentry keyed by an order stores its ownexpiresAt, set when it is written. That covers the gas estimate, bid plans, filler outputs/inputs/budget, funding prepends, partial-fill and fee-check flags, matched limit orders, swap operations and pair classifications.CACHE_EXPIRY_MS, is now 300 s (was 60 s).handleNewOrderregisters how long they take withCacheService.extendForConfirmations(orderId, waitMs).ContractInteractionService.blockTimeSeconds(measured once at startup, now public).Re-evaluation
handleNewOrderalso handsexecuteOrdera re-evaluation of the order (evaluateOrderwith the samecanFillanswers). Confirmations slower than the block time predicted, or a long chain-queue wait, can still outlast an evaluation. So when the queued task starts, it pins the order and checks the gas estimate: the first thing an evaluation caches, and what every bid signs.orderSkipped). The expired evaluation is never used.@hyperbridge/simplexandsimplex-desktopare bumped to 0.18.3.simplex-v0.18.3is tagged on this branch's head (13ad1a41d). Note:docs/ai/changelog/2026-10-22-order-cache-lives-through-its-confirmations.md.Validation
handleNewOrder(bid-loop-cache-expiry.test.ts), with two confirmations at a 100 s block time:CacheServicelifetime:source-reorg.test.tsstubs the two new contract-service members;limit-order-budget.test.tsreads the expiry instead of hardcoding 61 s.pnpm --filter @hyperbridge/simplex test:unit: 300 passed.test:data: 139 passed.test:filler: 75 passed, 5 skipped.src/tests/core+src/tests/services: 571 passed, 3 skipped.lint: no errors.tsc: nothing reported in the touched files.🤖 Generated with Claude Code