Reject malformed indexer event amounts without corrupting accounting #1406

Merged
PlasticDigits merged 3 commits from fix/issue-1395-strict-event-amounts into main 2026-10-06 02:08:45 +00:00
Owner

Malformed LCD amounts previously became valid zero or permissive decimal values, corrupting swap, fee and position accounting. This PR rejects the complete affected action before mutation using typed missing/invalid/overflow errors, while retaining genuine zero, optional absence, authenticated emitters, valid siblings and replay identities.

Shared raw/price parsing covers swaps, liquidity, lifecycle records, hooks and pinned wrap/window fees. Columnar records remain aligned, action scanning tracks emitters forward, and rejection diagnostics contain only bounded static metadata. Precision-preserving migrations cover raw sums, fees, parked escrow and P&L; raw aggregate clipping is removed, derived storage overflow is checked, and reorg cleanup includes orphan protocol fees.

Fixes #1395.

Validation: make verify-issue-1395 passed with 490 library tests twice, nine new Postgres scenarios twice, and 95 related tests. All 58 forward migrations, updated #1277 statics, documentation checks and normal commit hooks passed. Fixtures are synthetic; no production deployment or historical repair is claimed.

  • AC1: malformed mandatory/present optional amounts never become valid zero; genuine zero/absence preserve schema policy.
  • AC2: bounded rejection observability and poison replay preserve block progress.
  • AC3: largest supported raw amounts, decimals, multihop fee identities, replay and exact aggregates reconcile.
  • Isolated database/API, retry, migration and recovery verification.
  • Production deployment and historical repair are outside this PR's completed scope.

Agent reproduction: configure isolated Postgres in indexer/.env, record revision/UTC, run make verify-issue-1395, and inspect the assertions in the review checklist. Agents may mark unavailable items SKIP with concrete reasons while reporting overall PASS for completed checks; executed failures require fixes and retests. Receipt, invariants, and third-party agent playbook are crosslinked.

Existing LP/hook keys still coalesce repeated same-action occurrences within a transaction; this separate limitation is documented. Original authenticated input is needed before repairing legacy coerced rows.

Malformed LCD amounts previously became valid zero or permissive decimal values, corrupting swap, fee and position accounting. This PR rejects the complete affected action before mutation using typed missing/invalid/overflow errors, while retaining genuine zero, optional absence, authenticated emitters, valid siblings and replay identities. Shared raw/price parsing covers swaps, liquidity, lifecycle records, hooks and pinned wrap/window fees. Columnar records remain aligned, action scanning tracks emitters forward, and rejection diagnostics contain only bounded static metadata. Precision-preserving migrations cover raw sums, fees, parked escrow and P&L; raw aggregate clipping is removed, derived storage overflow is checked, and reorg cleanup includes orphan protocol fees. Fixes #1395. Validation: `make verify-issue-1395` passed with 490 library tests twice, nine new Postgres scenarios twice, and 95 related tests. All 58 forward migrations, updated #1277 statics, documentation checks and normal commit hooks passed. Fixtures are synthetic; no production deployment or historical repair is claimed. - [x] AC1: malformed mandatory/present optional amounts never become valid zero; genuine zero/absence preserve schema policy. - [x] AC2: bounded rejection observability and poison replay preserve block progress. - [x] AC3: largest supported raw amounts, decimals, multihop fee identities, replay and exact aggregates reconcile. - [x] Isolated database/API, retry, migration and recovery verification. - [ ] Production deployment and historical repair are outside this PR's completed scope. Agent reproduction: configure isolated Postgres in `indexer/.env`, record revision/UTC, run `make verify-issue-1395`, and inspect the assertions in the [review checklist](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/fix/issue-1395-strict-event-amounts/docs/qa/issue-1395/README.md). Agents may mark unavailable items SKIP with concrete reasons while reporting overall PASS for completed checks; executed failures require fixes and retests. [Receipt](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/fix/issue-1395-strict-event-amounts/docs/qa/issue-1395/verification.md), [invariants](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/fix/issue-1395-strict-event-amounts/docs/indexer-invariants.md#exact-event-amounts-1395), and [third-party agent playbook](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/fix/issue-1395-strict-event-amounts/skills/AGENTS_INDEXER_EVENT_AMOUNTS.md) are crosslinked. Existing LP/hook keys still coalesce repeated same-action occurrences within a transaction; this separate limitation is documented. Original authenticated input is needed before repairing legacy coerced rows.
Reject malformed economic event amounts before accounting
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending
59f1860a9e
Use bounded exact parsing and action-scoped provenance. Preserve replay identities and widen raw accounting storage; add integrity regressions and agent verification guidance.
Link issue 1395 implementation and verification receipts
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
fc1413ba5a
Refresh strict event ingestion against main [skip ci]
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
c6ae8966ed
Sign in to join this conversation.
No reviewers
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!1406
No description provided.