Limit insert hint fallback: walk from hint toward head/tail when verify fails #265

Closed
opened 2026-06-01 03:56:55 +00:00 by PlasticDigits · 7 comments
PlasticDigits commented 2026-06-01 03:56:55 +00:00 (Migrated from gitlab.com)

Summary

When hint_after / hint_after_order_id fails O(1) verification but the hinted order still exists on the correct side and is linked in the DLL, fall back by walking from the hint toward the head or tail (whichever direction the price-time order says is correct) instead of restarting from the book head. Stale, wrong-side, or unlinked hints keep today's head walk.

Supersedes the head-only fallback described in #256 (O(1) fast path shipped; this issue is the follow-up from PlasticDigits' comment on #256).

Current codebase

  • Shipped in #256: try_insert_after_hint_bid / try_insert_after_hint_ask in orderbook.rs load the hint (+ optional next), verify side, on-book linkage, and price-time order (bid_before / ask_before composite key). On success, find_insert_* returns in O(1).
  • Today's fallback: any verify failure in find_insert_bid / find_insert_ask discards the hint anchor and walks from HEAD_BID / HEAD_ASK, counting every load against the shared steps counter until max_adjust_steps (min with MAX_ADJUST_STEPS_HARD_CAP = 256) or insert position found.
  • Call sites unchanged: insert_bid_with_id / insert_ask_with_id, batch/ladder placement (limit_placement.rs — chains last_placed_hint), UpdateLimitOrderPrice → relink_limit_order_price (contract.rs).
  • Frontend/indexer: dApp resolves hints from merged deep-book pages via limitBookInsertHint.ts; batch wire field hint_after_order_id (#261).
  • Docs/invariants: invariant L14 in docs/contracts-security-audit.md and docs/limit-orders.md document "stale/wrong hints → bounded head walk". This issue updates that contract.

Why this is needed

  • Invalid hints are usually near-misses: a few orders filled/cancelled/placed between quote/sign and on-chain execution. The client hint is close to the true predecessor but no longer exact.
  • Head walk from a deep book prefix can exhaust max_adjust_steps even when the true slot is 1–3 nodes from the hinted order — the live A/B in #256 showed valid hints succeeding where head walk reverts, but stale near-miss hints still pay the full prefix cost.
  • Directional fallback preserves #256's safety (verify every step, shared step budget) while matching the common production failure mode: off-by-a-few, not off-by-the-whole-book.
  • No gas baseline requirement: current expenditure is acceptable; the win is fewer reverts / skipped batch rungs under tight caps, not a mandatory before/after gas benchmark.

Constraints and guardrails

  • Never trust hint without verification — same composite-key rules as today (bid_before / ask_before; head = best price, FIFO by order_id).
  • Direction selection only when the hint order is a valid anchor: exists, correct side, linked (prev set or id == head). Otherwise → head walk (unchanged).
  • Direction rules (after O(1) verify fails on a valid anchor):
    • Toward head (prev walk): new sorts before hint (too good to sit after hint) — e.g. bid price higher than hint, or same price with lower order_id.
    • Toward tail (next walk): new sorts after hint's next neighbor (too bad for the hinted slot) — walk forward from hint.next (or from hint when next missing/wrong-side).
    • Ambiguous / both checks fail on missing neighbor: prefer the direction implied by the first failed comparator; document in code comments.
  • Shared steps counter: O(1) hint loads + directional walk + any head-walk fallback all count toward max_adjust_steps; LimitInsertStepsExceeded semantics unchanged.
  • Do not weaken total order / FIFO or bypass step cap via malicious hints — worst case must remain bounded head walk (e.g. hint id missing → head).
  • No wire/API changes — same optional hint_after_order_id fields.
  • Simulation: N/A (execute only).
  • Migration: none.

Relevant files

Area Path
Insert / relink / fallback smartcontracts/contracts/pair/src/orderbook.rs (try_insert_after_hint_*, find_insert_*, link_*, relink_limit_order_price)
Batch place smartcontracts/contracts/pair/src/limit_placement.rs
Execute smartcontracts/contracts/pair/src/contract.rs (execute_update_limit_order_price)
Types smartcontracts/packages/dex-common/src/limit_placement.rs, pair.rs
Docs / invariants docs/limit-orders.md, docs/contracts-security-audit.md (L5, L14), docs/integrators.md
Agent playbooks skills/AGENTS_FRONTEND_LIMIT_ORDER_PLACEMENT_GAS.md, skills/AGENTS_LIMIT_ORDER_BATCH_LADDER.md
Frontend hint resolver frontend-dapp/src/utils/limitBookInsertHint.ts
Tests orderbook.rs unit tests, smartcontracts/tests/src/limit_order_tests.rs
  1. Refactor try_insert_after_hint_* to return a richer result, e.g. HintInsertResult:
    • Ok(Some(neighbors)) — fast path (unchanged).
    • Ok(None) with reason — MissingOrWrongSide, Unlinked, NeedWalkTowardHead { hint_id }, NeedWalkTowardTail { start_id }.
  2. Add walk_insert_bid_from / walk_insert_ask_from — same comparator loop as today's head walk but starting at a cursor id and following prev or next only; increment steps per load; stop on position found or cap.
  3. Wire into find_insert_*:
    • Valid hint + fast path → return.
    • Valid anchor + direction → directional walk; if cap hit, error (do not silently restart head walk unless steps remain and product wants chained fallback — default: one anchor strategy per tx to keep gas predictable).
    • Missing/wrong-side/unlinked → head walk (today's loop).
  4. Head-walk chaining (optional): if directional walk exhausts steps without finding slot, only fall back to head when steps < max_steps at directional failure — document choice; prefer no double walk to avoid doubling gas on attack. Safer default: single strategy per invocation.
  5. Update L14 docs to describe directional fallback for near-miss hints; note head walk only when anchor unusable.

Acceptance criteria

  • Valid hint_after still inserts in O(1) (≤ 3 order loads) — #256 behavior preserved.
  • Near-miss hint (hint exists, correct side, linked, wrong predecessor by 1–N nodes): insert succeeds within max_adjust_steps where today's head walk reverts.
  • Stale hint (order id absent), wrong-side hint, unlinked hint: head walk fallback unchanged.
  • UpdateLimitOrderPrice and batch/ladder placement benefit without wire changes.
  • Book ordering invariants hold (head = best price, FIFO at price).
  • Invariant L14 and docs/limit-orders.md updated for directional fallback semantics.

Test plan (functional paths)

Path Expectation
Empty book Head insert; hint ignored
Valid hint (exact predecessor) O(1) fast path — unchanged
Hint 1–2 nodes too early (new better than hint) prev walk from hint finds slot; succeeds under cap where head walk fails
Hint 1–2 nodes too late (new worse than hint.next) next walk from hint/hint.next finds slot
Hint at tail, new belongs before hint prev walk to correct level
Hint at head neighbor, new belongs after hint next walk
Hint order cancelled (id missing) Head walk fallback
Hint wrong side (ask id for bid) Head walk fallback
Hint unlinked / dangling id Head walk fallback
max_adjust_steps tight with near-miss hint Directional walk succeeds; head walk would revert
max_adjust_steps = 1 with far-miss hint LimitInsertStepsExceeded (unchanged error)
Relink price across levels with near-miss hint Correct new position
Batch ladder with interleaved external fills Later rungs with stale chained hints still safe

Test plan (attack / abuse / hack vectors)

Vector Verification
Hint points near tail but new belongs at head (malicious/wrong) Direction chosen by comparators; each step verified; bounded by max_adjust_steps; no wrong-level insert
Hint on another maker's order Owner-agnostic price-time verify — same as #256
Concurrent fills/cancels before tx Near-miss → directional walk; total miss → head walk; ordering preserved
Gas griefing via bogus near-miss hints No extra unbounded work; step cap unchanged; no double-walk gas amplification
Hint id loops / corrupted DLL Each load uses stored prev/next; comparators reject; cap prevents infinite loop
Directional walk exhausts cap mid-search LimitInsertStepsExceeded; no partial insert / corrupted links

Verification criteria

  • cd smartcontracts && cargo test -p cl8y-dex-pair hint — existing #256 tests green + new directional cases.
  • cd smartcontracts && cargo test -p cl8y-dex-tests limit_order — integration tests green.
  • LocalTerra: deep book, cancel/fill 1–2 orders at hint neighborhood, place/relink with stale hint — succeeds at Low steps where pre-change head fallback reverts.
  • Manual book walk after tests: head = best price, FIFO at equal price, no DLL breaks.
## Summary When `hint_after` / `hint_after_order_id` fails O(1) verification but the hinted order still exists on the correct side and is linked in the DLL, **fall back by walking from the hint** toward the head or tail (whichever direction the price-time order says is correct) instead of restarting from the book head. Stale, wrong-side, or unlinked hints keep today's head walk. Supersedes the head-only fallback described in [#256](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/256) (O(1) fast path shipped; this issue is the follow-up from [PlasticDigits' comment on #256](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/256#note_3404156286)). ## Current codebase - **Shipped in #256:** `try_insert_after_hint_bid` / `try_insert_after_hint_ask` in [`orderbook.rs`](smartcontracts/contracts/pair/src/orderbook.rs) load the hint (+ optional `next`), verify side, on-book linkage, and price-time order (`bid_before` / `ask_before` composite key). On success, `find_insert_*` returns in O(1). - **Today's fallback:** any verify failure in `find_insert_bid` / `find_insert_ask` discards the hint anchor and walks from **`HEAD_BID` / `HEAD_ASK`**, counting every load against the shared `steps` counter until `max_adjust_steps` (min with `MAX_ADJUST_STEPS_HARD_CAP` = 256) or insert position found. - **Call sites unchanged:** `insert_bid_with_id` / `insert_ask_with_id`, batch/ladder placement ([`limit_placement.rs`](smartcontracts/contracts/pair/src/limit_placement.rs) — chains `last_placed_hint`), `UpdateLimitOrderPrice` → `relink_limit_order_price` ([`contract.rs`](smartcontracts/contracts/pair/src/contract.rs)). - **Frontend/indexer:** dApp resolves hints from merged deep-book pages via [`limitBookInsertHint.ts`](frontend-dapp/src/utils/limitBookInsertHint.ts); batch wire field `hint_after_order_id` ([#261](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/261)). - **Docs/invariants:** invariant **L14** in [`docs/contracts-security-audit.md`](docs/contracts-security-audit.md) and [`docs/limit-orders.md`](docs/limit-orders.md) document "stale/wrong hints → bounded **head** walk". This issue updates that contract. ## Why this is needed - Invalid hints are **usually near-misses**: a few orders filled/cancelled/placed between quote/sign and on-chain execution. The client hint is close to the true predecessor but no longer exact. - Head walk from a deep book prefix can exhaust `max_adjust_steps` even when the true slot is **1–3 nodes** from the hinted order — the live A/B in #256 showed valid hints succeeding where head walk reverts, but **stale near-miss hints still pay the full prefix cost**. - Directional fallback preserves #256's safety (verify every step, shared step budget) while matching the common production failure mode: off-by-a-few, not off-by-the-whole-book. - **No gas baseline requirement:** current expenditure is acceptable; the win is fewer reverts / skipped batch rungs under tight caps, not a mandatory before/after gas benchmark. ## Constraints and guardrails - **Never trust hint without verification** — same composite-key rules as today (`bid_before` / `ask_before`; head = best price, FIFO by `order_id`). - **Direction selection only when the hint order is a valid anchor:** exists, correct side, linked (`prev` set or id == head). Otherwise → head walk (unchanged). - **Direction rules (after O(1) verify fails on a valid anchor):** - **Toward head (`prev` walk):** new sorts **before** hint (too good to sit after hint) — e.g. bid price higher than hint, or same price with lower `order_id`. - **Toward tail (`next` walk):** new sorts **after** hint's `next` neighbor (too bad for the hinted slot) — walk forward from `hint.next` (or from hint when `next` missing/wrong-side). - **Ambiguous / both checks fail on missing neighbor:** prefer the direction implied by the first failed comparator; document in code comments. - **Shared `steps` counter:** O(1) hint loads + directional walk + any head-walk fallback all count toward `max_adjust_steps`; `LimitInsertStepsExceeded` semantics unchanged. - **Do not weaken total order / FIFO** or bypass step cap via malicious hints — worst case must remain bounded head walk (e.g. hint id missing → head). - **No wire/API changes** — same optional `hint_after_order_id` fields. - **Simulation:** N/A (execute only). - **Migration:** none. ## Relevant files | Area | Path | |------|------| | Insert / relink / fallback | [`smartcontracts/contracts/pair/src/orderbook.rs`](smartcontracts/contracts/pair/src/orderbook.rs) (`try_insert_after_hint_*`, `find_insert_*`, `link_*`, `relink_limit_order_price`) | | Batch place | [`smartcontracts/contracts/pair/src/limit_placement.rs`](smartcontracts/contracts/pair/src/limit_placement.rs) | | Execute | [`smartcontracts/contracts/pair/src/contract.rs`](smartcontracts/contracts/pair/src/contract.rs) (`execute_update_limit_order_price`) | | Types | [`smartcontracts/packages/dex-common/src/limit_placement.rs`](smartcontracts/packages/dex-common/src/limit_placement.rs), [`pair.rs`](smartcontracts/packages/dex-common/src/pair.rs) | | Docs / invariants | [`docs/limit-orders.md`](docs/limit-orders.md), [`docs/contracts-security-audit.md`](docs/contracts-security-audit.md) (L5, L14), [`docs/integrators.md`](docs/integrators.md) | | Agent playbooks | [`skills/AGENTS_FRONTEND_LIMIT_ORDER_PLACEMENT_GAS.md`](skills/AGENTS_FRONTEND_LIMIT_ORDER_PLACEMENT_GAS.md), [`skills/AGENTS_LIMIT_ORDER_BATCH_LADDER.md`](skills/AGENTS_LIMIT_ORDER_BATCH_LADDER.md) | | Frontend hint resolver | [`frontend-dapp/src/utils/limitBookInsertHint.ts`](frontend-dapp/src/utils/limitBookInsertHint.ts) | | Tests | `orderbook.rs` unit tests, [`smartcontracts/tests/src/limit_order_tests.rs`](smartcontracts/tests/src/limit_order_tests.rs) | ## Recommended direction 1. **Refactor `try_insert_after_hint_*`** to return a richer result, e.g. `HintInsertResult`: - `Ok(Some(neighbors))` — fast path (unchanged). - `Ok(None)` with reason — `MissingOrWrongSide`, `Unlinked`, `NeedWalkTowardHead { hint_id }`, `NeedWalkTowardTail { start_id }`. 2. **Add `walk_insert_bid_from` / `walk_insert_ask_from`** — same comparator loop as today's head walk but starting at a cursor id and following `prev` or `next` only; increment `steps` per load; stop on position found or cap. 3. **Wire into `find_insert_*`:** - Valid hint + fast path → return. - Valid anchor + direction → directional walk; if cap hit, error (do **not** silently restart head walk unless steps remain and product wants chained fallback — default: one anchor strategy per tx to keep gas predictable). - Missing/wrong-side/unlinked → head walk (today's loop). 4. **Head-walk chaining (optional):** if directional walk exhausts steps without finding slot, only fall back to head when `steps < max_steps` at directional failure — document choice; prefer **no double walk** to avoid doubling gas on attack. Safer default: single strategy per invocation. 5. **Update L14 docs** to describe directional fallback for near-miss hints; note head walk only when anchor unusable. ## Acceptance criteria - [ ] Valid `hint_after` still inserts in O(1) (≤ 3 order loads) — #256 behavior preserved. - [ ] Near-miss hint (hint exists, correct side, linked, wrong predecessor by 1–N nodes): insert succeeds within `max_adjust_steps` where today's head walk reverts. - [ ] Stale hint (order id absent), wrong-side hint, unlinked hint: head walk fallback unchanged. - [ ] `UpdateLimitOrderPrice` and batch/ladder placement benefit without wire changes. - [ ] Book ordering invariants hold (head = best price, FIFO at price). - [ ] Invariant **L14** and `docs/limit-orders.md` updated for directional fallback semantics. ## Test plan (functional paths) | Path | Expectation | |------|-------------| | Empty book | Head insert; hint ignored | | Valid hint (exact predecessor) | O(1) fast path — unchanged | | Hint 1–2 nodes too early (new better than hint) | `prev` walk from hint finds slot; succeeds under cap where head walk fails | | Hint 1–2 nodes too late (new worse than hint.next) | `next` walk from hint/hint.next finds slot | | Hint at tail, new belongs before hint | `prev` walk to correct level | | Hint at head neighbor, new belongs after hint | `next` walk | | Hint order cancelled (id missing) | Head walk fallback | | Hint wrong side (ask id for bid) | Head walk fallback | | Hint unlinked / dangling id | Head walk fallback | | `max_adjust_steps` tight with near-miss hint | Directional walk succeeds; head walk would revert | | `max_adjust_steps = 1` with far-miss hint | `LimitInsertStepsExceeded` (unchanged error) | | Relink price across levels with near-miss hint | Correct new position | | Batch ladder with interleaved external fills | Later rungs with stale chained hints still safe | ## Test plan (attack / abuse / hack vectors) | Vector | Verification | |--------|----------------| | Hint points near tail but new belongs at head (malicious/wrong) | Direction chosen by comparators; each step verified; bounded by `max_adjust_steps`; no wrong-level insert | | Hint on another maker's order | Owner-agnostic price-time verify — same as #256 | | Concurrent fills/cancels before tx | Near-miss → directional walk; total miss → head walk; ordering preserved | | Gas griefing via bogus near-miss hints | No extra unbounded work; step cap unchanged; no double-walk gas amplification | | Hint id loops / corrupted DLL | Each load uses stored `prev`/`next`; comparators reject; cap prevents infinite loop | | Directional walk exhausts cap mid-search | `LimitInsertStepsExceeded`; no partial insert / corrupted links | ## Verification criteria - `cd smartcontracts && cargo test -p cl8y-dex-pair hint` — existing #256 tests green + new directional cases. - `cd smartcontracts && cargo test -p cl8y-dex-tests limit_order` — integration tests green. - LocalTerra: deep book, cancel/fill 1–2 orders at hint neighborhood, place/relink with stale hint — succeeds at Low steps where pre-change head fallback reverts. - Manual book walk after tests: head = best price, FIFO at equal price, no DLL breaks.
PlasticDigits commented 2026-06-01 03:57:00 +00:00 (Migrated from gitlab.com)

mentioned in issue #256

mentioned in issue #256
PlasticDigits commented 2026-06-01 04:03:50 +00:00 (Migrated from gitlab.com)

mentioned in commit b347a7bbf9

mentioned in commit b347a7bbf914f7adf16115a256328978d756c9a9
PlasticDigits commented 2026-06-01 04:03:56 +00:00 (Migrated from gitlab.com)

Implementation summary (merged to main — b347a7b)

Implemented directional insert-hint fallback (GitLab #265) in orderbook.rs:

  1. try_insert_after_hint_* now returns HintInsertOutcome: O(1) ready, head-walk (missing/wrong-side/unlinked), walk toward head (prev), or walk toward tail (next).
  2. walk_insert_*_toward_head / walk_insert_*_from — bounded walks from the hint neighborhood using the same bid_before / ask_before comparators; shared steps counter toward max_adjust_steps.
  3. find_insert_* — single strategy per invocation (no double head walk after directional exhaustion); stale anchors still use head walk.

Wire/API: unchanged (hint_after_order_id only).

Docs: invariant L14 and L5 updated in docs/contracts-security-audit.md; docs/limit-orders.md, docs/integrators.md; agent playbooks skills/AGENTS_FRONTEND_LIMIT_ORDER_PLACEMENT_GAS.md, skills/AGENTS_LIMIT_ORDER_BATCH_LADDER.md.

Tests added/updated:

  • Unit: near-miss head/tail walks, deep-book cap beat, relink with near-miss hint
  • Integration: limit_batch_chained_near_miss_hint_directional_walk_succeeds; adjusted partial-batch skip test for #265 behavior

Verification checklist

  • cd smartcontracts && cargo test -p cl8y-dex-pair hint — 12 tests green
  • cd smartcontracts && cargo test -p cl8y-dex-tests limit_order — 64 tests green
  • Valid exact hint_after still O(1) (≤ 3 loads) — insert_bid_with_valid_hint_after_is_o1
  • Near-miss hint 1–2 nodes off succeeds under Low max_adjust_steps where pre-change head walk reverts — insert_bid_deep_book_near_miss_hint_beats_head_walk_cap
  • Stale / wrong-side / unlinked hints → head walk unchanged — insert_bid_stale_hint_falls_back_to_head_walk, insert_bid_wrong_side_hint_falls_back
  • Batch chained near-miss succeeds — limit_batch_chained_near_miss_hint_directional_walk_succeeds
  • max_adjust_steps = 1 with far-miss still → LimitInsertStepsExceeded
  • Book invariants after tests: head = best price, FIFO at equal price, DLL links intact
  • LocalTerra (optional): deep book, cancel/fill 1–2 orders near hint, place with stale hint at Low steps — succeeds where old head fallback reverted

Follow-ups

  • Contract wasm rebuild + deploy when ready for testnet/mainnet (logic-only pair change; no migration).
  • Frontend/indexer already pass hints (#261); no client changes required — benefit is automatic for near-miss hints.

Requesting verification from the QA agent team when convenient.

## Implementation summary (merged to `main` — `b347a7b`) Implemented **directional insert-hint fallback** (GitLab #265) in `orderbook.rs`: 1. **`try_insert_after_hint_*`** now returns `HintInsertOutcome`: O(1) ready, head-walk (missing/wrong-side/unlinked), walk toward head (`prev`), or walk toward tail (`next`). 2. **`walk_insert_*_toward_head` / `walk_insert_*_from`** — bounded walks from the hint neighborhood using the same `bid_before` / `ask_before` comparators; shared `steps` counter toward `max_adjust_steps`. 3. **`find_insert_*`** — single strategy per invocation (no double head walk after directional exhaustion); stale anchors still use head walk. **Wire/API:** unchanged (`hint_after_order_id` only). **Docs:** invariant **L14** and **L5** updated in `docs/contracts-security-audit.md`; `docs/limit-orders.md`, `docs/integrators.md`; agent playbooks `skills/AGENTS_FRONTEND_LIMIT_ORDER_PLACEMENT_GAS.md`, `skills/AGENTS_LIMIT_ORDER_BATCH_LADDER.md`. **Tests added/updated:** - Unit: near-miss head/tail walks, deep-book cap beat, relink with near-miss hint - Integration: `limit_batch_chained_near_miss_hint_directional_walk_succeeds`; adjusted partial-batch skip test for #265 behavior --- ## Verification checklist - [ ] `cd smartcontracts && cargo test -p cl8y-dex-pair hint` — 12 tests green - [ ] `cd smartcontracts && cargo test -p cl8y-dex-tests limit_order` — 64 tests green - [ ] Valid exact `hint_after` still O(1) (≤ 3 loads) — `insert_bid_with_valid_hint_after_is_o1` - [ ] Near-miss hint 1–2 nodes off succeeds under Low `max_adjust_steps` where pre-change head walk reverts — `insert_bid_deep_book_near_miss_hint_beats_head_walk_cap` - [ ] Stale / wrong-side / unlinked hints → head walk unchanged — `insert_bid_stale_hint_falls_back_to_head_walk`, `insert_bid_wrong_side_hint_falls_back` - [ ] Batch chained near-miss succeeds — `limit_batch_chained_near_miss_hint_directional_walk_succeeds` - [ ] `max_adjust_steps = 1` with far-miss still → `LimitInsertStepsExceeded` - [ ] Book invariants after tests: head = best price, FIFO at equal price, DLL links intact - [ ] LocalTerra (optional): deep book, cancel/fill 1–2 orders near hint, place with stale hint at Low steps — succeeds where old head fallback reverted --- ## Follow-ups - Contract wasm rebuild + deploy when ready for testnet/mainnet (logic-only pair change; no migration). - Frontend/indexer already pass hints (#261); no client changes required — benefit is automatic for near-miss hints. --- Requesting verification from the QA agent team when convenient.
Brouie commented 2026-06-01 14:12:48 +00:00 (Migrated from gitlab.com)

mentioned in merge request !733

mentioned in merge request !733
Brouie commented 2026-06-01 15:41:57 +00:00 (Migrated from gitlab.com)

Verified #265 on d6701c4 (directional insert-hint fallback). Contract-only logic; no gas baseline required.

  • cargo test -p cl8y-dex-pair hint = 12/12 green: insert_bid_with_valid_hint_after_is_o1 (O(1) ≤3 loads
    preserved), insert_bid_deep_book_near_miss_hint_beats_head_walk_cap (headline — near-miss succeeds under
    Low max_adjust_steps where head walk reverts), insert_bid/ask_near_miss_hint_toward_head/tail_succeeds_under_cap
    (directional), insert_bid_stale_hint_falls_back_to_head_walk + insert_bid_wrong_side_hint_falls_back
    (anchor unusable → head walk unchanged), insert_bid_bad_hint_with_max_steps_one_errors
    (far-miss → LimitInsertStepsExceeded), relink_limit_order_price_near_miss_hint_succeeds (UpdateLimitOrderPrice benefits).
  • Integration limit_batch_chained_near_miss_hint_directional_walk_succeeds green (batch chained near-miss).
  • All within make test-contracts = 402/0.
  • L14 + L5 (contracts-security-audit.md) and limit-orders.md updated: prev-toward-head / next-toward-tail,
    shared steps budget, single strategy per insert (no double head walk). Wire/API unchanged.

Good to close from my side once !733 merges. @PlasticDigits

Verified #265 on d6701c4 (directional insert-hint fallback). Contract-only logic; no gas baseline required. - cargo test -p cl8y-dex-pair hint = 12/12 green: insert_bid_with_valid_hint_after_is_o1 (O(1) ≤3 loads preserved), insert_bid_deep_book_near_miss_hint_beats_head_walk_cap (headline — near-miss succeeds under Low max_adjust_steps where head walk reverts), insert_bid/ask_near_miss_hint_toward_head/tail_succeeds_under_cap (directional), insert_bid_stale_hint_falls_back_to_head_walk + insert_bid_wrong_side_hint_falls_back (anchor unusable → head walk unchanged), insert_bid_bad_hint_with_max_steps_one_errors (far-miss → LimitInsertStepsExceeded), relink_limit_order_price_near_miss_hint_succeeds (UpdateLimitOrderPrice benefits). - Integration limit_batch_chained_near_miss_hint_directional_walk_succeeds green (batch chained near-miss). - All within make test-contracts = 402/0. - L14 + L5 (contracts-security-audit.md) and limit-orders.md updated: prev-toward-head / next-toward-tail, shared steps budget, single strategy per insert (no double head walk). Wire/API unchanged. Good to close from my side once !733 merges. @PlasticDigits
Brouie commented 2026-06-01 16:29:50 +00:00 (Migrated from gitlab.com)

mentioned in issue #263

mentioned in issue #263
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-06-02 06:53:00 +00:00
PlasticDigits commented 2026-06-05 04:08:27 +00:00 (Migrated from gitlab.com)

mentioned in issue #309

mentioned in issue #309
Sign in to join this conversation.
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#265
No description provided.