Skip to content

feat: calculate block rewards by timestamp#66

Merged
noa-starkware merged 1 commit into
mainfrom
noa/staking/v3/calculate-block-rewards
Mar 17, 2026
Merged

feat: calculate block rewards by timestamp#66
noa-starkware merged 1 commit into
mainfrom
noa/staking/v3/calculate-block-rewards

Conversation

@noa-starkware

@noa-starkware noa-starkware commented Nov 25, 2025

Copy link
Copy Markdown
Collaborator

This change is Reviewable


Note

High Risk
Changes core reward distribution by caching per-epoch block rewards and sourcing them from timestamp-based avg block duration via RewardSupplier; mistakes could misprice rewards across epochs or break reward updates if epoch transitions aren’t handled correctly.

Overview
Block reward calculation is changed to be timestamp-based and epoch-cached. Staking now stores last_calculated_epoch and block_rewards, and update_rewards calls calculate_block_rewards(..., curr_epoch) which refreshes rewards only once per epoch by invoking RewardSupplier.update_current_epoch_block_rewards().

Test utilities and flow/tests are updated to advance both block number and timestamp (advance_blocks) and to compute expected V3 rewards directly from the minting curve using an average block duration (instead of dividing epoch rewards by epoch length). The V3 replaceability upgrade flow now also upgrades the RewardSupplier implementation.

Written by Cursor Bugbot for commit 76687b8. This will update automatically on new commits. Configure here.

@noa-starkware noa-starkware self-assigned this Nov 25, 2025
@noa-starkware
noa-starkware force-pushed the noa/staking/v3/update_current_epoch_block_rewards branch from deb5f00 to 6fda82c Compare November 27, 2025 20:50
@noa-starkware
noa-starkware force-pushed the noa/staking/v3/calculate-block-rewards branch 3 times, most recently from b6dd1db to 313688c Compare November 30, 2025 08:44
@noa-starkware
noa-starkware requested a review from remollemo March 11, 2026 10:46

@remollemo remollemo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:lgtm:

@remollemo reviewed 7 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on NirLevi-starkware).

Base automatically changed from noa/staking/v3/update_current_epoch_block_rewards to main March 12, 2026 16:21
@noa-starkware
noa-starkware force-pushed the noa/staking/v3/calculate-block-rewards branch 2 times, most recently from fa8c27c to 1adf198 Compare March 12, 2026 16:39
@noa-starkware
noa-starkware enabled auto-merge (squash) March 12, 2026 16:39
@noa-starkware
noa-starkware force-pushed the noa/staking/v3/calculate-block-rewards branch from 1adf198 to 76687b8 Compare March 17, 2026 20:44
@noa-starkware
noa-starkware merged commit f3267d6 into main Mar 17, 2026
5 of 6 checks passed
@noa-starkware
noa-starkware deleted the noa/staking/v3/calculate-block-rewards branch March 17, 2026 20:47
@codecov

codecov Bot commented Mar 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.78%. Comparing base (1d3ac9a) to head (76687b8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #66   +/-   ##
=======================================
  Coverage   95.78%   95.78%           
=======================================
  Files          42       42           
  Lines       10295    10299    +4     
=======================================
+ Hits         9861     9865    +4     
  Misses        434      434           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants