Skip to content

feat(indexer): akash bme event handlers with exact ledger records - #3603

Merged
baktun14 merged 2 commits into
feat/indexer-scaffold-chain-indexer-appfrom
feat/indexer-bme-event-handlers
Aug 17, 2026
Merged

feat(indexer): akash bme event handlers with exact ledger records#3603
baktun14 merged 2 commits into
feat/indexer-scaffold-chain-indexer-appfrom
feat/indexer-bme-event-handlers

Conversation

@baktun14

@baktun14 baktun14 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Why

Closes CON-813

The old indexer treats BME as a special case spliced into the sync insert phase: chainSync scans EndBlocker events inline into a bme_raw_event staging table, and a separate indexer later derives ledger records from those rows plus six cumulative DOUBLE columns on the block table fed by parseFloat. 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.

  • Three new akash tables, all exact numerics (numeric(38,0) amounts, numeric(38,18) prices, where the old DECIMAL(20,10) truncated the chain's 18-decimal Dec):
    • bme_ledger_records, keyed by the full on-chain LedgerRecordID. record_height is the record's creation height and height the 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_reason is text on purpose: sandbox already emits minimum_mint, which the SDK enum does not know.
  • deriveBmeChanges scans 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 JSON null (observed on sandbox) and are treated as absent.
  • BmeWriter is plain conflict-ignoring appends inside the batch transaction; replaying a block is a no-op.
  • EventVaultFunded is deliberately not captured: the vault's balance history is already exact in cosmos.balance_changes (the reason classifier maps the vault address to bme), and the reconcile CLI checks it against the chain.
  • Not ported from the old indexer: the raw staging table, the synthesized VaultFundedTransfer/MigrationMinted events (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 cumulative DOUBLE block 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

  • AC1 (ledger parity): backfilled every sandbox height carrying BME events (146 ranges) and compared each stored row field by field against the raw block_results events: 149 executed records, 106 status changes and 315 canceled records, 570 field sets, 0 mismatches.
  • AC2 (vault in balance ledger): vault movements appear in cosmos.balance_changes with bme/mint reasons and cross-check the ledger records exactly (collateral inflow equals remint_credit_accrued, payout equals minted minus spread, cancel refunds net to zero).
  • AC3 (no staging): no raw table exists in the schema, and the deriver spec pins that unhandled events store nothing.

Summary by CodeRabbit

  • New Features

    • Added support for tracking Akash BME (burn-mint-equilibrium) ledger activity.
    • Records mint status changes, executed ledger transactions, and canceled operations.
    • Captures related token amounts, prices, accounts, block details, and cancellation information.
    • Integrates BME event processing into block indexing for reliable historical querying.
  • Bug Fixes

    • Improved handling of malformed or incomplete BME events so valid events continue processing.
    • Standardized account resolution across Akash indexing workflows.

@baktun14
baktun14 requested a review from a team as a code owner August 17, 2026 07:37

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization's overage spend limit has been reached.

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.

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 87abaacd-c935-496f-8eae-765d9927b91b

📥 Commits

Reviewing files that changed from the base of the PR and between 6a5066f and 435f39a.

📒 Files selected for processing (17)
  • apps/chain-indexer/drizzle/0008_good_galactus.sql
  • apps/chain-indexer/drizzle/meta/0008_snapshot.json
  • apps/chain-indexer/drizzle/meta/_journal.json
  • apps/chain-indexer/src/akash/akash-deriver.ts
  • apps/chain-indexer/src/akash/akash-writer.service.ts
  • apps/chain-indexer/src/akash/json.ts
  • apps/chain-indexer/src/akash/provider-writer.service.ts
  • apps/chain-indexer/src/bme/bme-deriver.spec.ts
  • apps/chain-indexer/src/bme/bme-deriver.ts
  • apps/chain-indexer/src/bme/bme-writer.service.spec.ts
  • apps/chain-indexer/src/bme/bme-writer.service.ts
  • apps/chain-indexer/src/db/schema.ts
  • apps/chain-indexer/src/pipeline/balance/account-interner.service.ts
  • apps/chain-indexer/src/pipeline/block-committer.service.spec.ts
  • apps/chain-indexer/src/pipeline/block-committer.service.ts
  • apps/chain-indexer/src/pipeline/block-decoder.service.spec.ts
  • apps/chain-indexer/src/pipeline/block-decoder.service.ts

Included review availability: 3 reviews are currently available. Based on recent review activity, included reviews refill at 4 per hour.


📝 Walkthrough

Walkthrough

Adds BME event decoding, validation, derivation, account interning, database persistence, schema migrations, and block-commit integration for executed, canceled, and mint-status records.

Changes

BME indexing

Layer / File(s) Summary
BME schema and migration
apps/chain-indexer/drizzle/0008_good_galactus.sql, apps/chain-indexer/drizzle/meta/..., apps/chain-indexer/src/db/schema.ts
Adds BME enum values, tables, composite keys, account foreign keys, query indexes, and migration metadata.
BME event derivation
apps/chain-indexer/src/bme/bme-deriver.ts, apps/chain-indexer/src/bme/bme-deriver.spec.ts, apps/chain-indexer/src/akash/json.ts, apps/chain-indexer/src/akash/akash-deriver.ts
Parses executed, canceled, and mint-status events. Tracks event order and collects parse warnings. Adds coverage for valid and invalid event data.
BME persistence
apps/chain-indexer/src/bme/bme-writer.service.ts, apps/chain-indexer/src/bme/bme-writer.service.spec.ts
Maps derived changes to database rows, resolves interned accounts, aggregates warnings, and performs chunked transactional inserts.
Block pipeline integration and account lookup reuse
apps/chain-indexer/src/pipeline/block-decoder.service.ts, apps/chain-indexer/src/pipeline/block-committer.service.ts, apps/chain-indexer/src/pipeline/*spec.ts, apps/chain-indexer/src/pipeline/balance/account-interner.service.ts, apps/chain-indexer/src/akash/akash-writer.service.ts, apps/chain-indexer/src/akash/provider-writer.service.ts
Retains BME events, derives changes during block commits, interns BME addresses, invokes BmeWriter, and replaces duplicated account-ID lookup helpers with requireAccountId.

Estimated code review effort: 4 (Complex) | ~60 minutes

Merge Risk: ⚪ Minimal · up to 435f3

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
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/indexer-bme-event-handlers

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Comment @coderabbitai help to get the list of available commands.

@baktun14

Copy link
Copy Markdown
Contributor Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@baktun14

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@baktun14
baktun14 merged commit 17d2fc8 into feat/indexer-scaffold-chain-indexer-app Aug 17, 2026
6 checks passed
@baktun14
baktun14 deleted the feat/indexer-bme-event-handlers branch August 17, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant