Skip to content

feat(cardano): log per-account epoch stake distribution - #1151

Open
mmahut wants to merge 1 commit into
mainfrom
mmahut/epoch-stake-log
Open

feat(cardano): log per-account epoch stake distribution#1151
mmahut wants to merge 1 commit into
mainfrom
mmahut/epoch-stake-log

Conversation

@mmahut

@mmahut mmahut commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Data layer for /epochs/{n}/stakes (#1082) and /epochs/{n}/stakes/{pool} (#1101). Endpoints follow in a separate PR.

New AccountStakeLog { amount, pool_id }, namespace account-stakes, written by RUPD per shard.

Required by:

@mmahut
mmahut requested a review from scarmuega as a code owner July 31, 2026 22:24
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@mmahut, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 17 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e5e6a1dc-1d80-47f2-8532-796b77217810

📥 Commits

Reviewing files that changed from the base of the PR and between 174a5de and 11a289f.

📒 Files selected for processing (7)
  • crates/cardano/src/model/logs.rs
  • crates/cardano/src/model/mod.rs
  • crates/cardano/src/rupd/loading.rs
  • crates/cardano/src/rupd/mod.rs
  • crates/cardano/src/rupd/work_unit.rs
  • crates/core/src/work_unit.rs
  • src/bin/dolos/data/dump_logs.rs
✨ 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 mmahut/epoch-stake-log

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.

❤️ Share

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

Copilot AI 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.

Pull request overview

Adds a new Cardano archive log (AccountStakeLog) to persist per-account active stake distribution per epoch, enabling upcoming minibf endpoints (/epochs/{n}/stakes and /epochs/{n}/stakes/{pool}) to be served from Dolos’ data layer. The PR also tightens the sharded RUPD durability/resume semantics and adjusts stake snapshot accounting so per-pool StakeLog figures remain correct across restarts.

Changes:

  • Introduces AccountStakeLog (namespace account-stakes) and wires it into the Cardano model/schema and the dolos data dump-logs CLI.
  • Updates RUPD to write per-shard per-account stake logs (archive) before advancing the shard progress cursor, and rebuilds per-pool StakeLog rewards from persisted PendingRewardState to avoid restart undercounts.
  • Extends StakeSnapshot to track global per-pool delegator counts (computed in the globals pass) to keep StakeLog.delegators_count restart-safe, and adds targeted tests for the new behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/bin/dolos/data/dump_logs.rs Adds dump support and formatting for the new account-stakes archive namespace.
crates/core/src/work_unit.rs Documents commit-phase durability ordering constraints for shard-resumable work units.
crates/cardano/src/rupd/work_unit.rs Writes per-account stake logs per shard, reworks finalize-time pool aggregation to be restart-safe, and adds tests.
crates/cardano/src/rupd/mod.rs Adds global pool_delegator_counts to StakeSnapshot and a helper accessor.
crates/cardano/src/rupd/loading.rs Populates global per-pool delegator counts during the globals pass.
crates/cardano/src/model/mod.rs Registers AccountStakeLog in the Cardano entity enum and schema.
crates/cardano/src/model/logs.rs Defines the AccountStakeLog type and documents access patterns/tradeoffs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +63 to +69
fn aggregate_pending_pool_rewards<S: StateStore>(
state: &S,
) -> Result<HashMap<PoolHash, (u64, u64)>, DomainError> {
let mut out: HashMap<PoolHash, (u64, u64)> = HashMap::new();

for record in state.iter_entities_typed::<PendingRewardState>(PendingRewardState::NS, None)? {
let (_, pending) = record?;
@mmahut

mmahut commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
✅ 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.

@mmahut
mmahut force-pushed the mmahut/epoch-stake-log branch from 0e21525 to 11a289f Compare July 31, 2026 22:45
@mmahut mmahut added enhancement New feature or request area:minibf Mini Blockfrost (minibf) API labels Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:minibf Mini Blockfrost (minibf) API enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants