fix(indexer): link limit fills to their own swap by per-pair ordinal (#316) #774
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!774
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "qa/316-fill-swap-linkage"
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 to #287 — the fill->swap linkage I flagged as still using MIN(id).
process_limit_order_fillresolved the parent swap viaswap_id_for_tx_pair=SELECT id ... ORDER BY id ASC LIMIT 1— always the FIRST swap on the pair in the tx. With multiple swaps on the same pair in one tx (router revisit / batch), fills from the 2nd swap mis-linked to the 1st.Fills carry no swap_index on-chain, so I derive it from the deterministic parser walk: maker fills are emitted before their
swapaction in the same execute (the pair addsbook_fill_events, then the swap attribute), so a fill belongs to the upcoming swap on its pair.parse_limit_order_fillsnow tracks a per-pair swap counter that mirrorsparse_swaps' one-swap-per-event detection exactly, and tags each fill with that ordinal.process_limit_order_filllinks viaswap_id_for_tx_pair_index(tx, pair, swap_index)— the unique(tx_hash, pair_id, swap_index)key from #287 — instead of MIN(id).swap_event_idFK).Tests:
parse_limit_order_fills_assigns_swap_index_per_pair_swap(parser unit: two swaps one pair -> fills carry 0/1/1) +limit_fill_swap_linkage.rs(integration: each swap_index resolves to its own swap_events row, absent ordinal -> None).mentioned in issue #316
Security review
Commit reviewed:
f1caac4f50aef2ea2d075ccd775679959645e534Scope: Indexer parser + DB query change linking
limit_order_fills.swap_event_idvia per-pairswap_indexordinal (swap_id_for_tx_pair_index), plus docs and integration tests.Outcome:
FINDINGS: 0medium+Summary: Reviewed the MR diff for injection, authn/authz, secret leakage, SSRF/XSS, deserialization, and supply-chain risk. This change is an internal indexer data-linkage correctness fix:
swap_id_for_tx_pair_indexuses sqlx parameterized binds ($1–$3); no new SQL injection surface.swap_indexis derived deterministically insideparse_limit_order_fillsfrom wasm event walk order (mirroringparse_swaps); it is not sourced from HTTP/API input.process_block_txs, so the FK lookup runs after swap rows exist.swap_event_idremains optional; a miss yieldsNonerather than an incorrect forced link.No plausible medium+ attack path identified on this diff. Inline threads: none.
mentioned in commit
8c591a47a4