Skip to content

test: add update_rewards several blocks delegation rewards test#92

Open
arad-starkware wants to merge 1 commit into
arad/test_add_disable_rewards_intermittently_flowfrom
arad/test_add_update_rewards_several_blocks_delegation_rewards_test
Open

test: add update_rewards several blocks delegation rewards test#92
arad-starkware wants to merge 1 commit into
arad/test_add_disable_rewards_intermittently_flowfrom
arad/test_add_update_rewards_several_blocks_delegation_rewards_test

Conversation

@arad-starkware

@arad-starkware arad-starkware commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

This change is Reviewable


Note

Adds a flow test verifying staker/delegator rewards accumulate correctly when update_rewards is called multiple times within the same epoch.

  • Tests:
    • update_rewards_delegator_rewards_same_epoch_flow_test in src/flow_test/test.cairo:
      • Stakes, delegates, starts consensus rewards, calls update_rewards 4 times within one epoch (separated by quarter-epoch block advances), and asserts staker/delegator rewards equal 4× single-block expectations.
    • Import update: use EpochInfoTrait (alongside NormalizedAmountTrait).
  • Docs:
    • Trim a bullet in src/flow_test/flow_ideas.md under update_rewards.

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

arad-starkware commented Nov 27, 2025

Copy link
Copy Markdown
Contributor Author

@arad-starkware arad-starkware self-assigned this Nov 27, 2025
@arad-starkware arad-starkware marked this pull request as ready for review November 27, 2025 15:13
@arad-starkware arad-starkware force-pushed the arad/test_add_disable_rewards_intermittently_flow branch from 5b321b5 to fec770a Compare November 27, 2025 15:28
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_several_blocks_delegation_rewards_test branch 2 times, most recently from 366dcb1 to f179d36 Compare November 27, 2025 17:11
@arad-starkware arad-starkware force-pushed the arad/test_add_disable_rewards_intermittently_flow branch from fec770a to eb46cf8 Compare November 27, 2025 17:11

@noa-starkware noa-starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @arad-starkware)


src/flow_test/test.cairo line 3872 at r1 (raw file):

/// Flow:
/// Staker stake.
/// Delegator delegate.

Add btc

@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_several_blocks_delegation_rewards_test branch from f179d36 to 5103722 Compare November 28, 2025 09:47
@arad-starkware arad-starkware force-pushed the arad/test_add_disable_rewards_intermittently_flow branch from eb46cf8 to feac4a7 Compare November 28, 2025 09:49
@arad-starkware arad-starkware force-pushed the arad/test_add_disable_rewards_intermittently_flow branch from feac4a7 to 7670413 Compare December 1, 2025 13:20
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_several_blocks_delegation_rewards_test branch from 5103722 to 016908f Compare December 1, 2025 13:20
Comment thread src/flow_test/test.cairo
system.update_rewards(:staker, disable_rewards: false);
advance_blocks(
blocks: quarter_epoch_length, block_duration: AVG_BLOCK_DURATION * quarter_epoch_length,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Wrong block_duration calculation causes squared time advancement

The advance_blocks function expects block_duration to be the duration per single block, then multiplies it internally by the blocks count. The test passes AVG_BLOCK_DURATION * quarter_epoch_length as block_duration, but since the function multiplies by quarter_epoch_length again, the time advancement is squared. Other usages in the codebase show the correct pattern: advance_blocks(blocks: 1, block_duration: AVG_BLOCK_DURATION). The block_duration argument should just be AVG_BLOCK_DURATION.

Additional Locations (2)

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