Skip to content

feat: migration to rewards by timestamp - #69

Merged
noa-starkware merged 1 commit into
mainfrom
noa/staking/v3/migration-rewards
Mar 22, 2026
Merged

noa-starkware merged 1 commit into
mainfrom
noa/staking/v3/migration-rewards

Conversation

@noa-starkware

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

Copy link
Copy Markdown
Collaborator

Note

Medium Risk
Touches staking reward configuration and initialization logic, which can affect on-chain reward calculations and epoch transitions if the new initialization path is incorrect. Test updates reduce risk but coverage is still limited to the exercised scenarios.

Overview
Consensus-rewards migration now initializes timestamp-based block rewards on configuration. When set_consensus_rewards_first_epoch is called for the first time, the staking contract precomputes and stores block_rewards (and updates last_calculated_epoch) to avoid starting consensus rewards without initialized per-block rewards.

Tests and flows are updated to reflect timestamp-based progression: several staking tests advance an epoch before configuring consensus rewards, the set_consensus_rewards_first_epoch test now asserts block_rewards/last_calculated_epoch initialization, and flow tests replace advance_block_number_global with advance_blocks(..., block_duration) to advance time as well as block number. Documentation/notes add additional migration test ideas for rewards-by-timestamp.

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


This change is Reviewable

@noa-starkware noa-starkware self-assigned this Nov 25, 2025
@noa-starkware
noa-starkware force-pushed the noa/staking/v3/adjust-avg-with-cfg branch from 35a662a to 353e2e7 Compare November 27, 2025 20:52
@noa-starkware
noa-starkware force-pushed the noa/staking/v3/migration-rewards branch from a9ccb51 to 2793f13 Compare November 27, 2025 20:52
@noa-starkware
noa-starkware force-pushed the noa/staking/v3/adjust-avg-with-cfg branch from 353e2e7 to 324e872 Compare November 30, 2025 08:49
@noa-starkware
noa-starkware force-pushed the noa/staking/v3/migration-rewards branch 2 times, most recently from f4ee42e to 4465436 Compare November 30, 2025 08:53
@noa-starkware
noa-starkware requested a review from remollemo March 11, 2026 10:47
@noa-starkware
noa-starkware force-pushed the noa/staking/v3/adjust-avg-with-cfg branch from 324e872 to 42fbfcf Compare March 17, 2026 20:50
@noa-starkware
noa-starkware force-pushed the noa/staking/v3/migration-rewards branch from 4465436 to 24e1ab6 Compare March 17, 2026 20:52

@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 3 files and all commit messages, and made 1 comment.
Reviewable status: 3 of 4 files reviewed, all discussions resolved (waiting on NirLevi-starkware).

@noa-starkware
noa-starkware force-pushed the noa/staking/v3/adjust-avg-with-cfg branch from 42fbfcf to 7ef4637 Compare March 22, 2026 20:53
Base automatically changed from noa/staking/v3/adjust-avg-with-cfg to main March 22, 2026 20:56
@noa-starkware
noa-starkware force-pushed the noa/staking/v3/migration-rewards branch from 24e1ab6 to e017847 Compare March 22, 2026 20:59
@codecov

codecov Bot commented Mar 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.11321% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.82%. Comparing base (2de7a34) to head (e017847).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/staking/staking.cairo 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #69      +/-   ##
==========================================
- Coverage   95.83%   95.82%   -0.01%     
==========================================
  Files          42       42              
  Lines       10385    10434      +49     
==========================================
+ Hits         9952     9998      +46     
- Misses        433      436       +3     

☔ 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.

@noa-starkware
noa-starkware merged commit cbaf0ae into main Mar 22, 2026
8 of 11 checks passed
@noa-starkware
noa-starkware deleted the noa/staking/v3/migration-rewards branch March 22, 2026 21:13
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