Skip to content

Conversation

@noa-starkware
Copy link
Collaborator

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

This change is Reviewable


Note

Switches to timestamp-based per-epoch block rewards (cached) and updates tests/utilities, including reward supplier V3 upgrade and block-time-aware helpers.

  • Staking (core):
    • Add last_calculated_epoch and block_rewards to Storage and compute block rewards via calculate_block_rewards(...) using per-epoch caching and update_current_epoch_block_rewards().
    • Wire new calc into update_rewards (pass curr_epoch).
  • Test utilities:
    • Introduce calculate_current_block_rewards_v3(...) and variant with custom avg block time; derive rewards from yearly mint and block duration (SECONDS_IN_YEAR, BLOCK_DURATION_SCALE).
    • Add advance_blocks(blocks, block_duration) to move block number and timestamp together.
  • Flows/Tests:
    • Replace advance_block_number_global with advance_blocks(..., AVG_BLOCK_DURATION) where rewards are updated per block; adjust expectations to block-level rewards helpers and drop unused staking_contract params.
    • Use new block-reward helpers in staking tests; ensure consistent rewards when blocks are missed and across epochs.
  • Upgrade path:
    • Extend V3 system upgrade to also upgrade RewardSupplier implementation.
  • Docs:
    • Add "block rewards by timestamp" test ideas to flow_test/flow_ideas.md.

Written by Cursor Bugbot for commit 313688c. 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 2 times, most recently from b29228c to b6dd1db Compare November 30, 2025 07:41
@noa-starkware noa-starkware force-pushed the noa/staking/v3/calculate-block-rewards branch from b6dd1db to 313688c Compare November 30, 2025 08:44
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