Skip to content

Ab/reward catchup improve#3911

Merged
imabdulbasit merged 2 commits intoab/per-epoch-reward-distributionfrom
ab/reward-catchup-improve
Jan 27, 2026
Merged

Ab/reward catchup improve#3911
imabdulbasit merged 2 commits intoab/per-epoch-reward-distributionfrom
ab/reward-catchup-improve

Conversation

@imabdulbasit
Copy link
Contributor

No description provided.

@imabdulbasit imabdulbasit merged commit 470e883 into ab/per-epoch-reward-distribution Jan 27, 2026
34 of 39 checks passed
@imabdulbasit imabdulbasit deleted the ab/reward-catchup-improve branch January 27, 2026 06:56
@gemini-code-assist
Copy link

Summary of Changes

Hello @imabdulbasit, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the handling and persistence of reward account states within the sequencer. It introduces a dedicated database table for reward balances, along with a migration mechanism to populate it with historical data. Crucially, the reward calculation logic has been made more resilient, allowing the system to recover and correctly calculate epoch rewards even if they are not immediately available, by fetching and rebuilding the necessary state from peers. These changes aim to enhance the reliability and efficiency of reward processing and state synchronization.

Highlights

  • New Reward State Persistence: Introduced a new reward_state database table (for both Postgres and SQLite) to store reward account balances at each height, providing a more direct and efficient way to query account states.
  • Reward State Backfill Migration: Implemented a migration process to backfill existing reward data from the reward_merkle_tree_v2 into the newly created reward_state table. This ensures historical data is available in the new format without data loss, processing in batches.
  • Improved Reward Calculation Catch-up: Enhanced the EpochRewardsCalculator to handle missing epoch reward calculations more robustly. If rewards for a V6+ epoch are not immediately available, the system will now fetch all reward accounts from peers (paginated) and rebuild the reward Merkle tree from scratch, preventing failures and allowing for delayed reward application.
  • Optimized Test Profiles: Updated Cargo.toml to set opt-level = 2 for test profiles, which can lead to faster test execution due to increased compiler optimizations.
  • Refactored EpochRewardsCalculator Initialization: The EpochRewardsCalculator is now initialized once and passed to NodeState, improving consistency and potentially reducing redundant object creation. The cache for epoch reward results now retains the last 3 epochs.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces a new reward_state table and associated logic for persisting and retrieving reward account balances. This includes new SQL migration files for both PostgreSQL and SQLite, updates to the sql.rs file to use this new table, and modifications to the catchup.rs and state.rs files to integrate the new reward state persistence and fetching mechanisms. The Cargo.toml file also sees an update to optimization levels for debug and test profiles. Overall, the changes aim to improve the handling of reward account data and epoch reward calculations.


async fn try_fetch_all_reward_accounts(
&self,
_retry: usize,

Choose a reason for hiding this comment

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

critical

There is a typo in the type declaration for height. It should be u64 instead of u664.

Suggested change
_retry: usize,
height: u64,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant