feat(#331): emit swap_index on limit_order_fill wasm events #817
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!817
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "cursor/gitlab-issue-workflow-ed71"
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?
Summary
Implements https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/331 (follow-up to #316).
tx_swap_index) stampsswap_indexon eachlimit_order_fillwasm event during hybridexecute_swap, so LCD replay can attribute fills without parser walk-order heuristics.parse_limit_order_fillsprefers on-chainswap_indexwhen present; legacy txs without the attr still use walk-order inference (#316).Acceptance checklist
limit_order_fillincludesswap_indexmatching parent swap ordinalcargo test -p cl8y-dex-tests hybrid_swap_emits_limit_order_fillswap_index; inference for legacycargo test --lib parse_limit_order_fills(incl.prefers_on_chain_swap_index_attr)limit_fill_swap_linkageextendedcargo test --test limit_fill_swap_linkage(needs Postgres)make test-contractsgreenswap_indextx_swap_index::stamp_swap_index_on_fill_eventsVerification for reviewers
After deploy: hybrid swap on LocalTerra → LCD tx query should show
swap_indexonlimit_order_fillwasm attrs.Issue stays open until MR merge + deploy verification.
changed the description
mentioned in issue #331
changed the description
changed the description
Security review
Commit reviewed:
b6c3cae16914356aad3f22ae7b81debc7d8fe500Scope: Pair
tx_swap_indexstate +execute_swapevent stamping; indexerparse_limit_order_fillspreference for on-chainswap_index; docs/tests only elsewhere.Outcome:
FINDINGS: 0medium+ — Security review: no medium+ findings on this diff.Summary
This MR adds deterministic per-tx swap ordinals on
limit_order_fillwasm events and teaches the indexer to prefer the on-chainswap_indexattribute when present. Review focused on injection, authn/authz, permission boundaries, and whether attacker-controlled input reaches a sensitive sink.Pair contract (
tx_swap_index.rs,contract.rs)swap_indexis derived from internalTX_SWAP_SCOPE/TX_SWAP_COUNTERstate keyed by(block.height, tx.index)— not from user-supplied execute args.execute_swapcompletion (after book match, pool leg, and invariants), before hook submessages run — consistent with multi-swap-in-one-tx ordering.Indexer (
parser.rs)swap_indexis parsed asi32and used only to resolve optionalswap_event_idvia parameterized SQL (swap_id_for_tx_pair_index) — no injection surface.limit_order_fill/swap_indexattrs cannot attribute rows to a victim pair: emitter scoping remains_contract_address-only (GitLab #285; existing tests unchanged). A malicious contract can only affect indexer rows scoped to its own address.swap_event_idis off-chain linkage metadata (API/CSV); mis-linkage does not affect on-chain balances, trading gates, or auth.Inline threads: none (no medium+ findings).
mentioned in commit
13be1a3398mentioned in commit
91e3c83823mentioned in commit
21f6eb6adamentioned in commit
21f6eb6ada