Benchmark MAX_EXPIRED_PARKS_PER_SWAP vs max gas/tx size (GitLab #289) #309
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#309
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Current codebase
MAX_EXPIRED_PARKS_PER_SWAPis 15, defined insmartcontracts/packages/dex-common/src/pair.rsand mirrored in:smartcontracts/contracts/pair/src/orderbook.rs— parks expired limits duringmatch_bids/match_asksfrontend-dapp/src/services/terraclassic/hybridBookWalkLimits.ts— offline gas budgetingfrontend-dapp/src/services/terraclassic/hybridSwapGas.ts—bookWalkScanOverheadGassmartcontracts/tests/src/limit_order_tests.rs, pair unit tests inorderbook.rsWhen cap is hit, additional expired head orders are skipped (
expired_parks_capped=true). Value 15 was raised in #254 from an earlier lower cap but was not re-benchmarked against Terra Classic max tx gas / max tx size after subsequent orderbook features (dust flush #264, scan cap #254, adjust steps #265).Follow-up: GitLab #289.
Why this is needed
Raising
MAX_EXPIRED_PARKS_PER_SWAPimproves maker UX (fewer stranded expired orders) but each park costs storage writes + events. Too high risks:HYBRID_SWAP_GAS_LIMIT/ chain max)An evidence-based cap balances cleanup throughput vs reliability.
Constraints / guardrails
hybridBookWalkLimits.tsafter change.docs/contracts-security-audit.md).MAX_SCAN_STEPS(500) andMAX_MAKER_FILLS_HARD_CAP(100) — worst-case tx uses all budgets.docs/limit-orders.md,skills/AGENTS_TERRACLASSIC_GAS.md, and security audit table.Relevant files
smartcontracts/packages/dex-common/src/pair.rssmartcontracts/contracts/pair/src/orderbook.rsskills/AGENTS_TERRACLASSIC_GAS.md,docs/limit-orders.mdfrontend-dapp/src/services/terraclassic/hybridSwapGas.ts,hybridBookWalkLimits.tssmartcontracts/tests/src/limit_order_tests.rsRecommended direction
book_input > 0, measure gas used vs limit for N = 1..30.App.MAX_EXPIRED_PARKS_PER_SWAPto that N; update frontend mirror + docs.docs/limit-orders.md.Acceptance criteria
Test plan (all paths)
hybridSwapGas.test.tsexpectations updatedAttack / abuse / hack vectors
Verification criteria
make test-contractsgreen with updated cap tests.make test-frontendfor gas helper tests.marked as related to #289
mentioned in commit
00e6467733mentioned in merge request !794
Implementation complete — MR !794 opened.
Outcome: retain
MAX_EXPIRED_PARKS_PER_SWAP = 15. LocalTerra optimized-wasm sweep (N=1..30) shows isolated worst case ~855kgas_usedat the cap (≪ 12M headroom). ~29k gas/park on-chain; scan-step budget (500) remains binding on deep expired prefixes.Benchmark table and methodology:
docs/limit-orders.md#expired-park-benchmark-gitlab-309Live repro:
make verify-issue-309mentioned in commit
6463af2bb5mentioned in commit
c0d8ad6c49mentioned in merge request !795
mentioned in merge request !841
mentioned in issue #379