test: add update_rewards epoch length flow#90
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
| system.start_consensus_rewards(); | ||
|
|
||
| system.update_rewards(:staker, disable_rewards: false); | ||
| let default_length_rewards = system.staker_claim_rewards(:staker); |
There was a problem hiding this comment.
Bug: Missing epoch advancement before baseline rewards measurement
The test claims default_length_rewards immediately after start_consensus_rewards() without advancing through any epochs where rewards are active. The start_consensus_rewards() function sets rewards to start at current_epoch + K and advances exactly K epochs, arriving at the start of the first rewards epoch with zero accumulated rewards. Therefore default_length_rewards would be 0 or nearly 0. When the test later claims increased_length_rewards after advancing an epoch, this value would be positive. The assertion increased_length_rewards < default_length_rewards would evaluate to positive < 0, which is false and would cause the test to fail.
ba4450d to
77ea9d3
Compare
486ac4d to
bdb1849
Compare
77ea9d3 to
555b38d
Compare
noa-starkware
left a comment
There was a problem hiding this comment.
Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @arad-starkware)
src/flow_test/test.cairo line 3830 at r2 (raw file):
let decreased_length_rewards = system.staker_claim_rewards(:staker); assert!(increased_length_rewards < default_length_rewards);
assert all not zero
bdb1849 to
4dcf4e2
Compare
555b38d to
453b967
Compare
| let decreased_length_rewards = system.staker_claim_rewards(:staker); | ||
|
|
||
| assert!(increased_length_rewards < default_length_rewards); | ||
| assert!(default_length_rewards < decreased_length_rewards); |
There was a problem hiding this comment.
Bug: Test assertions contradict V3 block rewards calculation logic
The test update_rewards_epoch_length_flow_test asserts that changing epoch_length changes per-block rewards (increased_length_rewards < default_length_rewards < decreased_length_rewards). However, in V3 consensus rewards, block rewards are calculated as yearly_mint * avg_block_duration / (BLOCK_DURATION_SCALE * SECONDS_IN_YEAR), where avg_block_duration = time_delta / num_blocks. Since advance_epoch() uses constant AVG_BLOCK_DURATION per block, the ratio time_delta/num_blocks remains constant regardless of epoch_length. The block rewards should be identical for all epoch lengths, making these assertions incorrect for V3 behavior.
453b967 to
e4e5171
Compare

This change is
Note
Introduce per-block consensus rewards driven by average block duration, add RewardSupplier EIC and config, and wire staking to cache/use epoch block rewards with extensive tests and spec updates.
SECONDS_IN_YEARconstant and compute block rewards using average block duration.update_current_epoch_block_rewardsto compute per-block (STRK/BTC) rewards.avg_block_duration,block_snapshot, andBlockDurationConfigwith min/max clamping.get_block_duration_configandset_block_duration_config(app governor-only).RewardSupplierEICto initialize new storage (avg/min/max) during V2→V3 upgrade.block_rewardsandlast_calculated_epoch; compute via RewardSupplier once per epoch.set_consensus_rewards_first_epoch, pre-initialize next-epoch block rewards.BlockDurationConfig, and errorINVALID_MIN_MAX_BLOCK_DURATION.AVG_BLOCK_DURATION; addadvance_blocksand custom epoch-time helpers.Written by Cursor Bugbot for commit 4dcf4e2. This will update automatically on new commits. Configure here.