feat: adust block duration in set_avg_block_durarion with config#68
Conversation
ea1ad7f to
b28368c
Compare
35a662a to
353e2e7
Compare
b28368c to
37e67c7
Compare
353e2e7 to
324e872
Compare
37e67c7 to
d82b3d1
Compare
324e872 to
42fbfcf
Compare
remollemo
left a comment
There was a problem hiding this comment.
@remollemo reviewed 6 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on NirLevi-starkware).
d82b3d1 to
fb344f6
Compare
42fbfcf to
7ef4637
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #68 +/- ##
==========================================
+ Coverage 95.81% 95.83% +0.01%
==========================================
Files 42 42
Lines 10342 10385 +43
==========================================
+ Hits 9909 9952 +43
Misses 433 433 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| .clamp( | ||
| block_duration_config.min_block_duration, | ||
| block_duration_config.max_block_duration, | ||
| ); |
There was a problem hiding this comment.
Clamp with uninitialized config zeroes out block rewards
High Severity
For upgraded contracts (where the constructor doesn't run), block_duration_config remains at its default storage value of {0, 0} since the EIC to initialize it is only a TODO. The new .clamp(0, 0) call forces calculated_block_duration to 0 on every epoch, which then sets avg_block_duration to 0, making total_rewards permanently zero. Before this change, the raw calculated value was used directly, allowing the system to self-correct. Now there's no recovery without an external set_block_duration_config call or EIC deployment.


Note
Medium Risk
Changes the on-chain reward calculation input (
avg_block_duration) by clamping it to governance-configured bounds, which can alter emitted block rewards and payout amounts. Also bumpsstarkware_utilsto a new git revision, introducing upstream behavior changes.Overview
Block-reward calculations now enforce configured block-time bounds.
RewardSupplier::set_avg_block_durationclamps the computed average block duration toblock_duration_configmin/max before persisting, replacing the previous TODO.Tests are extended with a new helper (
advance_epoch_global_custom_time) and a new case that drives block times below/above the configured range to assert both the clampedavg_block_durationand resulting rewards. The PR also updates thestarkware_utils/starkware_utils_testingdependency revision.Written by Cursor Bugbot for commit 7ef4637. This will update automatically on new commits. Configure here.
This change is