fix(minibf): adjust /network endpoint mappings - #773
Conversation
WalkthroughThe changes introduce active stake tracking alongside live stake in the account and network models, add explicit initialization for network reserves and treasury fields, and implement aggregation logic to compute network-level stake metrics from individual account states. Changes
Sequence Diagram(s)sequenceDiagram
participant Network as Network Model Builder
participant Accounts as Account States
participant Aggregator as Aggregation Logic
participant Output as Final Response
Network->>Accounts: iterate all AccountState entities
Accounts->>Aggregator: provide live_stake() and active_stake()
Aggregator->>Aggregator: sum live_stake() across all accounts
Aggregator->>Aggregator: sum active_stake() across all accounts
Aggregator->>Network: return aggregated totals
Network->>Network: populate NetworkModelBuilder fields
Network->>Output: build network response with aggregated stake
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
crates/minibf/src/routes/network.rs (1)
259-272: Consider performance implications of iterating all accounts.This aggregation iterates over every
AccountStateentity on each request to the/networkendpoint. For networks with many accounts, this could become a performance bottleneck. Consider:
- Caching the aggregated totals
- Precomputing during epoch transitions
- Using a separate aggregate tracking mechanism
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
crates/cardano/src/model.rs(1 hunks)crates/minibf/src/routes/accounts.rs(1 hunks)crates/minibf/src/routes/network.rs(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
crates/minibf/src/routes/network.rs (2)
crates/cardano/src/model.rs (6)
new(150-159)new(548-558)new(743-759)new(1496-1506)live_stake(560-562)active_stake(564-566)crates/core/src/state.rs (1)
new(212-218)
crates/cardano/src/model.rs (3)
crates/cardano/src/rewards/mocking.rs (1)
active_stake(213-219)crates/cardano/src/rupd/loading.rs (1)
active_stake(267-269)crates/cardano/src/rewards/mod.rs (1)
active_stake(323-323)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Test (macos-14)
- GitHub Check: Test (ubuntu-latest)
- GitHub Check: Test (windows-latest)
- GitHub Check: Test (macos-13)
🔇 Additional comments (3)
crates/minibf/src/routes/accounts.rs (1)
119-120: LGTM: Explicit initialization improves clarity.The explicit
"0".to_string()is clearer thanDefault::default()and makes the intent more obvious to readers.crates/cardano/src/model.rs (1)
564-566: LGTM: Consistent implementation of active stake accessor.The
active_stake()method correctly mirrorslive_stake()but uses thego()snapshot (epoch - 3), providing access to historically active stake. This is used by the network aggregation logic to compute network-level totals.crates/minibf/src/routes/network.rs (1)
237-237: Verify the semantic change fromobligations()toutxosfor the locked field.This changes what's reported as "locked" in the network supply response. Ensure this aligns with the intended semantics and verify against expected behavior or documentation.
Summary by CodeRabbit
New Features
Chores