fix: make sure that accounts don't automatically redelegate to unregistered and re-registered pools#1030
fix: make sure that accounts don't automatically redelegate to unregistered and re-registered pools#1030etorreborre wants to merge 2 commits into
Conversation
WalkthroughThe change introduces explicit account create/update values, unbinds accounts delegated to retiring pools during epoch transitions, records the unbound count in tracing schemas, and adds store and RocksDB integration coverage. ChangesRetired-pool account unbinding
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant EpochTransition
participant AccountsStore
participant TraceSpan
EpochTransition->>AccountsStore: inspect accounts during pool retirement
AccountsStore-->>EpochTransition: unset delegations to retired pools
EpochTransition->>TraceSpan: record accounts_unbound
EpochTransition->>AccountsStore: update retired and remaining pool rows
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
1398a3a to
e77a4c9
Compare
e77a4c9 to
13edd8e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/amaru-ledger/src/state/volatile/fragment.rs (1)
410-424: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDitch the inline commentary, mate — let the match speak for itself.
The logic's grand (Create-vs-Update split reads true to the new
AccountsValuecontract), but that freshly-bolted-on two-liner explaining the deposit semantics runs against the repo's own house rules.As per coding guidelines: "Never include comments in code unless explicitly asked; use descriptive names instead."
♻️ Suggested tidy-up
iterator.map(|(credential, Bind { left: pool, right: drep, value: deposit })| { - // A bound deposit denotes a (re-)registration within the window (see DiffBind::register); - // without one, only delegations changed and the account is known to exist already. - let value = match deposit { + let value = match deposit { Some(deposit) => AccountsValue::Create { pool, drep, deposit, rewards: 0 }, None => AccountsValue::Update { pool, drep }, }; (credential, value) })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/amaru-ledger/src/state/volatile/fragment.rs` around lines 410 - 424, Remove the inline two-line comment inside add_accounts while leaving the existing deposit match and AccountsValue::Create/Update behavior unchanged.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/amaru-ledger/src/store/epoch_transition.rs`:
- Around line 179-197: The pool-retirement handling currently scans every
account through with_accounts; replace this full-table traversal with a
pool-to-delegator lookup or equivalent delegation index. Update the retirement
branch to fetch only accounts delegated to pools in retirements, clear their
pool assignments, and preserve the accounts_unbound metric and existing error
propagation.
---
Nitpick comments:
In `@crates/amaru-ledger/src/state/volatile/fragment.rs`:
- Around line 410-424: Remove the inline two-line comment inside add_accounts
while leaving the existing deposit match and AccountsValue::Create/Update
behavior unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cbf6379f-71ea-4639-8dd2-d908aef21c4d
📒 Files selected for processing (12)
CHANGELOG.mdcrates/amaru-ledger/src/bootstrap.rscrates/amaru-ledger/src/epoch_transition.rscrates/amaru-ledger/src/state/volatile/fragment.rscrates/amaru-ledger/src/store/columns/accounts.rscrates/amaru-ledger/src/store/epoch_transition.rscrates/amaru-observability/src/schemas.rscrates/amaru-stores/src/lib.rscrates/amaru-stores/src/rocksdb/ledger/columns/accounts.rscrates/amaru-stores/src/rocksdb/mod.rsdocs/TRACES.mddocs/traces-schema.json
💤 Files with no reviewable changes (1)
- crates/amaru-ledger/src/epoch_transition.rs
3d83b23 to
4702471
Compare
Signed-off-by: Eric Torreborre <etorreborre@yahoo.com>
Signed-off-by: Eric Torreborre <etorreborre@yahoo.com>
4702471 to
a8d7764
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/amaru-stores/src/rocksdb/ledger/columns/accounts.rs`:
- Line 48: Remove the inline implementation comment immediately preceding the
account creation logic; leave the surrounding behavior and code unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5978f82a-7ff3-4195-90c5-8259b3eec2a1
📒 Files selected for processing (12)
CHANGELOG.mdcrates/amaru-ledger/src/bootstrap.rscrates/amaru-ledger/src/epoch_transition.rscrates/amaru-ledger/src/state/volatile/fragment.rscrates/amaru-ledger/src/store/columns/accounts.rscrates/amaru-ledger/src/store/epoch_transition.rscrates/amaru-observability/src/schemas.rscrates/amaru-stores/src/lib.rscrates/amaru-stores/src/rocksdb/ledger/columns/accounts.rscrates/amaru-stores/src/rocksdb/mod.rsdocs/TRACES.mddocs/traces-schema.json
💤 Files with no reviewable changes (1)
- crates/amaru-ledger/src/epoch_transition.rs
🚧 Files skipped from review as they are similar to previous changes (9)
- crates/amaru-observability/src/schemas.rs
- docs/traces-schema.json
- docs/TRACES.md
- crates/amaru-ledger/src/state/volatile/fragment.rs
- crates/amaru-ledger/src/store/columns/accounts.rs
- crates/amaru-ledger/src/bootstrap.rs
- crates/amaru-ledger/src/store/epoch_transition.rs
- crates/amaru-stores/src/rocksdb/mod.rs
- crates/amaru-stores/src/lib.rs
This PR implements the
FIXMEsection described in #878Summary by CodeRabbit
accounts_unboundfield/metric to epoch transition traces to report the number of accounts unbound.