Implement the new table balances logic to client runner#2320
Conversation
WalkthroughRefactors the local_db pipeline to introduce an ApplyPipeline trait with an ApplyPipelineTargetInfo (start_block/target_block), adds a build_post_batch hook, passes deployment_block through BootstrapConfig, and implements ClientApplyAdapter to emit post-batch vault-balance upserts. Changes
Sequence Diagram(s)sequenceDiagram
participant Engine
participant Apply as ApplyPipeline
participant Default as DefaultApplyPipeline
participant Client as ClientApplyAdapter
participant DB
Engine->>Apply: build_batch(target_info, logs, events, tokens, upserts)
Apply->>Default: default build_batch() (or impl)
Default-->>Engine: primary SqlStatementBatch
Engine->>Apply: build_post_batch(target_info)
alt DefaultApplyPipeline (default)
Apply-->>Engine: empty SqlStatementBatch
else ClientApplyAdapter
Apply->>Client: build_post_batch(target_info)
alt start_block ≤ target_block
Client->>Client: upsert_vault_balances_batch(ob_id, start, target)
Client-->>Engine: vault-balance SqlStatementBatch
else start_block > target_block
Client-->>Engine: empty SqlStatementBatch
end
end
Engine->>Engine: extend primary batch with post_batch
Engine->>Apply: persist(db, combined_batch)
Apply->>DB: execute batch inside transaction
DB-->>Apply: execution result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (7)
🧰 Additional context used📓 Path-based instructions (3)crates/**/*.rs📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/crates/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.rs📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (9)📓 Common learnings📚 Learning: 2025-10-06T11:13:29.956ZApplied to files:
📚 Learning: 2025-10-06T14:41:41.909ZApplied to files:
📚 Learning: 2025-10-14T07:51:55.148ZApplied to files:
📚 Learning: 2025-05-27T06:16:12.195ZApplied to files:
📚 Learning: 2025-09-24T10:54:42.060ZApplied to files:
📚 Learning: 2025-11-04T09:20:06.368ZApplied to files:
📚 Learning: 2025-10-06T13:03:35.337ZApplied to files:
📚 Learning: 2025-10-18T10:38:41.273ZApplied to files:
🧬 Code graph analysis (3)crates/common/src/local_db/pipeline/mod.rs (1)
crates/common/src/local_db/pipeline/adapters/apply.rs (1)
crates/cli/src/commands/local_db/pipeline/runner/mod.rs (2)
🔇 Additional comments (26)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment: S/M/L PR Classification Guidelines:This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed. Small (S)Characteristics:
Review Effort: Would have taken 5-10 minutes Examples:
Medium (M)Characteristics:
Review Effort: Would have taken 15-30 minutes Examples:
Large (L)Characteristics:
Review Effort: Would have taken 45+ minutes Examples:
Additional Factors to ConsiderWhen deciding between sizes, also consider:
Notes:
|
|
Tip For best results, initiate chat on the files or code changes. SIZE=L 🧠 Learnings used |
Chained PR
Motivation
Now that we have the new vault balances tables, we can implement the logic that will insert to these tables during the client-runner process.
We need to:
Solution
crates/common/src/local_db/pipeline/adapters/bootstrap.rsbuild_post_batchfunction. The default implementation for this is an empty batch list, but the client will provide sql statements for the vault balance changescrates/common/src/local_db/pipeline/adapters/apply.rscrates/common/src/raindex_client/local_db/pipeline/apply.rsChecks
By submitting this for review, I'm confirming I've done the following:
Summary by CodeRabbit
New Features
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.