Skip to content

feat: adust block duration in set_avg_block_durarion with config#68

Merged
noa-starkware merged 1 commit into
mainfrom
noa/staking/v3/adjust-avg-with-cfg
Mar 22, 2026
Merged

feat: adust block duration in set_avg_block_durarion with config#68
noa-starkware merged 1 commit into
mainfrom
noa/staking/v3/adjust-avg-with-cfg

Conversation

@noa-starkware

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

Copy link
Copy Markdown
Collaborator

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 bumps starkware_utils to a new git revision, introducing upstream behavior changes.

Overview
Block-reward calculations now enforce configured block-time bounds. RewardSupplier::set_avg_block_duration clamps the computed average block duration to block_duration_config min/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 clamped avg_block_duration and resulting rewards. The PR also updates the starkware_utils / starkware_utils_testing dependency revision.

Written by Cursor Bugbot for commit 7ef4637. 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/block-time-config branch from ea1ad7f to b28368c Compare November 27, 2025 20:51
@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/block-time-config branch from b28368c to 37e67c7 Compare November 30, 2025 08:45
@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 changed the title feat: use block duration config in set_avg_block_durarion to adust th… feat: adust block duration in set_avg_block_durarion with config Nov 30, 2025
@noa-starkware noa-starkware requested a review from remollemo March 11, 2026 10:47
@noa-starkware noa-starkware force-pushed the noa/staking/v3/block-time-config branch from 37e67c7 to d82b3d1 Compare March 17, 2026 20:49
@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

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

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

@noa-starkware noa-starkware force-pushed the noa/staking/v3/block-time-config branch from d82b3d1 to fb344f6 Compare March 22, 2026 20:48
Base automatically changed from noa/staking/v3/block-time-config to main March 22, 2026 20:52
@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
@noa-starkware noa-starkware enabled auto-merge (squash) March 22, 2026 20:53
@noa-starkware noa-starkware merged commit 2de7a34 into main Mar 22, 2026
6 checks passed
@noa-starkware noa-starkware deleted the noa/staking/v3/adjust-avg-with-cfg branch March 22, 2026 20:56
@codecov

codecov Bot commented Mar 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.83%. Comparing base (137d12b) to head (7ef4637).
⚠️ Report is 7 commits behind head on main.

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

.clamp(
block_duration_config.min_block_duration,
block_duration_config.max_block_duration,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Additional Locations (1)
Fix in Cursor Fix in Web

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