Skip to content

Conversation

@arad-starkware
Copy link
Collaborator

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

This change is Reviewable


Note

Adds a comprehensive flow test that toggles enabled BTC tokens across attestation and consensus epochs and validates rewards behavior with update_rewards.

  • Tests:
    • Add update_rewards_token_enable_disable_flow_test in src/flow_test/test.cairo:
      • Adds two BTC tokens (8d/18d), toggles enable/disable across epochs, performs staking/delegation, attests, starts consensus, calls update_rewards (including twice in same epoch), and asserts staker/delegator rewards per token in attestation (v2) and consensus (v3) modes.
      • Uses NormalizedAmountTrait and v2/v3 reward calculators for STRK/BTC.
  • Supporting changes:
    • Import updates: NormalizedAmountTrait; switch to/use calculate_staker_btc_pool_rewards_v3, calculate_staker_strk_rewards_v2, etc.
    • Tidy src/flow_test/flow_ideas.md by simplifying the k=1 -> k=2 token item.

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

Copy link
Collaborator Author

arad-starkware commented Nov 24, 2025

@arad-starkware arad-starkware self-assigned this Nov 24, 2025
@arad-starkware arad-starkware marked this pull request as ready for review November 24, 2025 09:44
@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.81%. Comparing base (6294afd) to head (2dc8dac).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #57      +/-   ##
==========================================
+ Coverage   95.77%   95.81%   +0.03%     
==========================================
  Files          42       42              
  Lines       10102    10194      +92     
==========================================
+ Hits         9675     9767      +92     
  Misses        427      427              

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

@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from 17f1baf to a3d9239 Compare November 24, 2025 10:17
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch 2 times, most recently from 1765bb9 to 3573ad2 Compare November 25, 2025 08:21
Copy link
Collaborator

@noa-starkware noa-starkware left a comment

Choose a reason for hiding this comment

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

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


src/flow_test/test.cairo line 3039 at r3 (raw file):

/// Advance K epochs
/// Enable token A, disable token B
/// update_rewards

I think we need this test for both v2 rewards and consensus rewards, please update the test


src/flow_test/flows.cairo line 7070 at r3 (raw file):

/// Add tokens A and B
/// Enable token B
/// Advance epoch

rebase issues?

@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch 3 times, most recently from 484a333 to 215d37b Compare November 26, 2025 08:45
Copy link
Collaborator Author

@arad-starkware arad-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @noa-starkware)


src/flow_test/test.cairo line 3039 at r3 (raw file):

Previously, noa-starkware wrote…

I think we need this test for both v2 rewards and consensus rewards, please update the test

I'm not sure about the flow you're describing, do you mean specifically v2 rewards and consensus in the same test? we have MultipleTokensDelegationFlow for v2 rewards otherwise


src/flow_test/flows.cairo line 7070 at r3 (raw file):

Previously, noa-starkware wrote…

rebase issues?

yes

@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch 3 times, most recently from 550520d to a9c72c0 Compare November 26, 2025 13:58
@arad-starkware arad-starkware changed the base branch from main to graphite-base/57 November 26, 2025 14:10
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from a9c72c0 to 1d21b45 Compare November 26, 2025 14:10
@arad-starkware arad-starkware changed the base branch from graphite-base/57 to arad/test_add_another_balances_delay_flow November 26, 2025 14:11
@arad-starkware arad-starkware changed the base branch from arad/test_add_another_balances_delay_flow to graphite-base/57 November 26, 2025 14:21
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from 1d21b45 to 943c3b0 Compare November 26, 2025 14:21
@arad-starkware arad-starkware changed the base branch from graphite-base/57 to arad/test_add_balances_delay_flow November 26, 2025 14:21
This was referenced Nov 26, 2025
Copy link
Collaborator Author

@arad-starkware arad-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 7 unresolved discussions (waiting on @noa-starkware)


src/flow_test/test.cairo line 3094 at r6 (raw file):

Previously, noa-starkware wrote…

test also staker rewards please

Done.


src/flow_test/test.cairo line 3111 at r6 (raw file):

Previously, noa-starkware wrote…

test also staker rewards please

Done.


src/flow_test/test.cairo line 3120 at r6 (raw file):

Previously, noa-starkware wrote…

test also staker rewards please

Done.


src/flow_test/test.cairo line 3128 at r6 (raw file):

Previously, noa-starkware wrote…

// Enable token B, disable token A

Done


src/flow_test/test.cairo line 3148 at r6 (raw file):

Previously, noa-starkware wrote…

test also staker rewards please

Done.


src/flow_test/test.cairo line 3156 at r6 (raw file):

Previously, noa-starkware wrote…

test also staker rewards please

Done.

@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from ea98f96 to 96cb2c9 Compare November 26, 2025 17:05
@arad-starkware arad-starkware force-pushed the arad/test_add_balances_delay_flow branch from d3ed532 to 071a55d Compare November 26, 2025 17:10
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch 2 times, most recently from 625acb6 to d3512f2 Compare November 26, 2025 17:16
@arad-starkware arad-starkware force-pushed the arad/test_add_balances_delay_flow branch 2 times, most recently from 6ad074b to 5f4a056 Compare November 26, 2025 17:26
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from d3512f2 to 5270e9e Compare November 26, 2025 17:26
@arad-starkware arad-starkware changed the base branch from arad/test_add_balances_delay_flow to graphite-base/57 November 27, 2025 07:47
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from 5270e9e to 8a0dadc Compare November 27, 2025 07:47
@graphite-app graphite-app bot changed the base branch from graphite-base/57 to main November 27, 2025 07:47
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from 8a0dadc to bbf04ed Compare November 27, 2025 07:47
Copy link
Collaborator

@noa-starkware noa-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

@noa-starkware reviewed 1 of 2 files at r11.
Reviewable status: 1 of 3 files reviewed, 3 unresolved discussions (waiting on @arad-starkware)


src/flow_test/test.cairo line 3244 at r11 (raw file):

    system.staking.disable_token(token_address: token_a.contract_address());

    // Calculate rewards for consensus rewards
  • only for one token enabled

src/flow_test/test.cairo line 3269 at r11 (raw file):

    // update_rewards - test rewards only for token A
    system.update_rewards(:staker, disable_rewards: false);

update_rewards twice before advance epoch?

@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from eb7dc58 to 41be9ca Compare November 27, 2025 15:23
Copy link
Collaborator Author

@arad-starkware arad-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 3 files reviewed, all discussions resolved


src/flow_test/test.cairo line 3244 at r11 (raw file):

Previously, noa-starkware wrote…
  • only for one token enabled

Done


src/flow_test/test.cairo line 3269 at r11 (raw file):

Previously, noa-starkware wrote…

update_rewards twice before advance epoch?

Done

@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch 2 times, most recently from ddcbf57 to 0b18f21 Compare November 27, 2025 17:11
@graphite-app
Copy link

graphite-app bot commented Dec 2, 2025

Merge activity

  • Dec 2, 9:44 AM UTC: This pull request can not be added to the Graphite merge queue. Please try rebasing and resubmitting to merge when ready.
  • Dec 2, 9:44 AM UTC: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..
  • Dec 4, 1:01 PM UTC: @arad-starkware merged this pull request with Graphite.

@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch 2 times, most recently from 129a1c6 to ca85233 Compare December 2, 2025 10:47
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from ca85233 to 2dc8dac Compare December 4, 2025 12:47
@arad-starkware arad-starkware merged commit bb4f50b into main Dec 4, 2025
7 of 8 checks passed
@arad-starkware arad-starkware deleted the arad/test_add_update_rewards_toggle_tokens_flow_test branch December 4, 2025 13:01
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.

3 participants