feat(pair): bound CleanLimitBook traversal with max_steps + resume cursor (#274) #753
No reviewers
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic!753
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "qa/274-clean-traversal-cap"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up on #274, your "start index + max steps" direction.
clean_limit_bookcapped parks (max_orders) but not traversal — the walk visited every node until it parkedmax_ordersor hit the end, so a book of healthy or zero-remaining orders could be walked unboundedly (the gas DoS).Fix:
MAX_CLEAN_SCAN_STEPS=500in dex-common/limit_clean.rs (mirrors the matcher'sMAX_SCAN_STEPS, same ~19k-gas/iter sizing) +clamp_max_clean_scan_steps.clean_limit_booktakesmax_steps, counts EVERY visited node (zero-remaining skip, healthy fall-through, parked), and breaks at the cap.CleanLimitBookResultgainsscan_capped+resume_cursor— the first UNVISITED oid (the gotcha: NOT the last processed, or re-passing the same start_hint loops on the same prefix). Both emitted as execute attrs.max_stepson theCleanLimitBookExecuteMsg (#[serde(default)]; absent or0-> the full cap, backward-compatible). A stale resume_cursor degrades safely via resolve_start -> head.start_hintis the "start index"; the park cap stays independent.Keeper loop: re-submit with
start_hint = resume_cursoruntilscan_capped/cap_hitclear (noresume_cursor).Tests (contract suite 419/0):
clean_limit_book_traversal_bounded_when_nothing_parked(the DoS — 0 parks, still bounded),..._scan_cap_resume_reaches_tail,..._zero_max_steps_means_full_cap,..._park_cap_independent_of_scan_cap. Live gas re-confirm rides the next deploy. No closing keyword.mentioned in issue #274
mentioned in issue #289
mentioned in commit
974cabb659