fix(pair): UpdateLimitOrderPrice same-id relink joins FIFO tail #1235

Merged
PlasticDigits merged 3 commits from issue/1227 into main 2026-09-12 02:44:21 +00:00

Summary

  • UpdateLimitOrderPrice still keeps order_id (no second maker fee, no CW20). After unlink it inserts as a new arrival at the destination price (RELINK_EQUAL_PRICE_SORT_ID) so a globally older id cannot leapfrog makers already quoting that level.
  • Same-price update is a no-op. Cross-price priority is unchanged. Hints cannot invert equal-price FIFO.
  • Indexer snapshot stores LCD DLL order as resting_limit_orders.walk_index; db_orderbook_sim reads ORDER BY walk_index (L8 / L23).

Fixes #1227

Acceptance

  • AC1. After B reprices to A’s P, a taker that fills one maker at P fills A, not B.
  • AC2. Ask-side twin.
  • AC3. New placements at the same price still FIFO by ascending order_id.
  • AC4. Relink to a better price is still the new head; worse price stays behind better resters.
  • AC5. Same-price update does not bump later same-price makers.
  • AC6. LimitInsertStepsExceeded / non-owner leave the book unchanged (atomicity). Pause / expiry / blacklist gates unchanged at execute.
  • AC7. remaining unchanged on success; no CW20 on the update tx.
  • AC8. Hybrid sim + execute fill the same first maker; indexer walk_index preserves DLL order.
  • AC9. Docs: time-priority at the quoted price; L23 closes the #424 leapfrog in the matcher.
  • AC10. Focused make verify-issue-1227 + pair proptest. make test-contracts: 513 passed; one pre-existing factory cw2 version pin (1.9.0 vs 1.10.0) unrelated to this change.

Test plan

  • make verify-issue-1227 (first pass + retest after docs grep fix)
  • cargo test -p cl8y-dex-pair --lib prop_escrow_dll_after_random_inserts
  • cargo clippy -- -D warnings in smartcontracts
  • Reviewer: confirm relink uses tail insert, not a new order_id
  • Optional: VERIFY1227_INDEXER=1 make verify-issue-1227 (Postgres + indexer/.env)
  • Reviewer: /trade price-only Edit still one tx / same row after refresh (T11, docs-only)
## Summary - `UpdateLimitOrderPrice` still keeps `order_id` (no second maker fee, no CW20). After unlink it inserts as a **new arrival** at the destination price (`RELINK_EQUAL_PRICE_SORT_ID`) so a globally older id cannot leapfrog makers already quoting that level. - Same-price update is a no-op. Cross-price priority is unchanged. Hints cannot invert equal-price FIFO. - Indexer snapshot stores LCD DLL order as `resting_limit_orders.walk_index`; `db_orderbook_sim` reads `ORDER BY walk_index` (L8 / L23). Fixes #1227 ## Acceptance - [x] AC1. After B reprices to A’s `P`, a taker that fills one maker at `P` fills A, not B. - [x] AC2. Ask-side twin. - [x] AC3. New placements at the same price still FIFO by ascending `order_id`. - [x] AC4. Relink to a better price is still the new head; worse price stays behind better resters. - [x] AC5. Same-price update does not bump later same-price makers. - [x] AC6. `LimitInsertStepsExceeded` / non-owner leave the book unchanged (atomicity). Pause / expiry / blacklist gates unchanged at execute. - [x] AC7. `remaining` unchanged on success; no CW20 on the update tx. - [x] AC8. Hybrid sim + execute fill the same first maker; indexer `walk_index` preserves DLL order. - [x] AC9. Docs: time-priority at the quoted price; L23 closes the #424 leapfrog in the matcher. - [x] AC10. Focused `make verify-issue-1227` + pair proptest. `make test-contracts`: 513 passed; one pre-existing factory cw2 version pin (`1.9.0` vs `1.10.0`) unrelated to this change. ## Test plan - [x] `make verify-issue-1227` (first pass + retest after docs grep fix) - [x] `cargo test -p cl8y-dex-pair --lib prop_escrow_dll_after_random_inserts` - [x] `cargo clippy -- -D warnings` in `smartcontracts` - [ ] Reviewer: confirm relink uses tail insert, not a new `order_id` - [ ] Optional: `VERIFY1227_INDEXER=1 make verify-issue-1227` (Postgres + `indexer/.env`) - [ ] Reviewer: `/trade` price-only Edit still one tx / same row after refresh (T11, docs-only)
Keep the storage order_id for cancel and Edit. Relink inserts as a new
arrival at the destination price so a globally older id cannot leapfrog
makers already quoting that level. Same-price update is a no-op.
Indexer snapshot walk_index preserves DLL order for sim parity (L23).
AC3 asked for the ask twin of fifo_two_bids. verify-issue-1227 now runs
that test, the ask relink unit, and indexer walk_index when .env exists.
Cross-link L23 in testing docs and agent skills.
Author
Owner

drain skip: hard-blocked (needs-human / high-risk / human topic); remaining continue

drain skip: hard-blocked (needs-human / high-risk / human topic); remaining continue
Merge origin/main into issue/1227 for PR #1235
All checks were successful
ci/woodpecker/pr/woodpecker gitleaks tracked-tree scan passed locally
a06493784e
PlasticDigits deleted branch issue/1227 2026-09-12 02:44:21 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic!1235
No description provided.