feat(indexer): akash bme event handlers with exact ledger records - #3603
Conversation
There was a problem hiding this comment.
Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.
Once credits are available, push a new commit or reopen this pull request to trigger a review.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (17)
Included review availability: 3 reviews are currently available. Based on recent review activity, included reviews refill at 4 per hour. 📝 WalkthroughWalkthroughAdds BME event decoding, validation, derivation, account interning, database persistence, schema migrations, and block-commit integration for executed, canceled, and mint-status records. ChangesBME indexing
Estimated code review effort: 4 (Complex) | ~60 minutes Merge Risk: ⚪ Minimal · up to This PR adds exact BME ledger persistence and event handling without any supplied merge-blocking correctness, deployment, security, or availability risk; it is merge-ready after normal checks and review. Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Comment |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
|
@coderabbitai review |
✅ Action performedReview finished.
|
17d2fc8
into
feat/indexer-scaffold-chain-indexer-app
Why
Closes CON-813
The old indexer treats BME as a special case spliced into the sync insert phase:
chainSyncscans EndBlocker events inline into abme_raw_eventstaging table, and a separate indexer later derives ledger records from those rows plus six cumulativeDOUBLEcolumns on the block table fed byparseFloat. That means float math on money and a staging table the new pipeline has no reason to keep.What
BME becomes a normal domain layer on the new pipeline, with the same deriver + writer shape as the other handlers.
akashtables, all exact numerics (numeric(38,0)amounts,numeric(38,18)prices, where the oldDECIMAL(20,10)truncated the chain's 18-decimal Dec):bme_ledger_records, keyed by the full on-chainLedgerRecordID.record_heightis the record's creation height andheightthe block whose EndBlocker executed it, so pending records that execute later keep both.bme_status_changes, keyed by(height, ordinal).bme_canceled_records, parsed into typed columns. The old indexer kept cancellations only as raw staging rows.cancel_reasonis text on purpose: sandbox already emitsminimum_mint, which the SDK enum does not know.deriveBmeChangesscans successful-tx events then block events in chain order. A malformed event is logged (BME_EVENT_PARSE_FAILED) and skipped rather than halting the block, and it still consumes its ordinal so a later parser fix replays with stable keys. Unset proto fields reach the wire as the literal JSONnull(observed on sandbox) and are treated as absent.BmeWriteris plain conflict-ignoring appends inside the batch transaction; replaying a block is a no-op.EventVaultFundedis deliberately not captured: the vault's balance history is already exact incosmos.balance_changes(the reason classifier maps the vault address tobme), and the reconcile CLI checks it against the chain.VaultFundedTransfer/MigrationMintedevents (the balance ledger records those movements from the generic coin events), oracle price parsing and the one-time denom row mutations (the resulting gap for pre-upgrade deployments is tracked in CON-842), and the cumulativeDOUBLEblock columns (computable by query from the ledger; the API layer is CON-817).The migration only creates new tables and one enum, so it cannot block a production database.
Verification on sandbox
block_resultsevents: 149 executed records, 106 status changes and 315 canceled records, 570 field sets, 0 mismatches.cosmos.balance_changeswithbme/mintreasons and cross-check the ledger records exactly (collateral inflow equalsremint_credit_accrued, payout equals minted minus spread, cancel refunds net to zero).Summary by CodeRabbit
New Features
Bug Fixes