Skip to content

Conversation

@arad-starkware
Copy link
Collaborator

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

This change is Reviewable


Note

Adds a new regression flow to validate enabling/disabling BTC tokens across upgrade and consensus phases, wires it into fork tests, and imports v3 BTC pool rewards calc; minor doc cleanup.

  • Flow tests:
    • Add EnableDisableTokenBeforeAfterUpgradeFlow in src/flow_test/flows.cairo:
      • Sets up two BTC tokens, delegates, toggles enable/disable across an upgrade, verifies get_tokens view and rewards.
      • Validates rewards pre-upgrade (v2) and post-consensus (v3) for enabled token only.
    • Register test enable_disable_token_before_after_upgrade_flow_test in src/flow_test/fork_test.cairo.
  • Utilities:
    • Import calculate_staker_btc_pool_rewards_v3 to support post-consensus rewards assertions.
  • Docs:
    • Remove obsolete section from src/flow_test/flow_ideas.md.

Written by Cursor Bugbot for commit e5c165d. 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 10:18
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch 3 times, most recently from cde9c29 to 87dd152 Compare November 24, 2025 12:12
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from a3d9239 to 1765bb9 Compare November 24, 2025 12:12
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, 5 unresolved discussions (waiting on @arad-starkware)


src/flow_test/flows.cairo line 7147 at r1 (raw file):

/// Flow:
/// Add tokens A and B

/// Delegate for both tokens


src/flow_test/flows.cairo line 7149 at r1 (raw file):

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

not relevant to the test, remove from doc

Code quote:

/// Enable token B
/// Advance epoch

src/flow_test/flows.cairo line 7237 at r1 (raw file):

        );
        staking_attestation
            .update_rewards_from_attestation_contract(staker_address: staker.staker.address);

why not system.attest(staker)?


src/flow_test/flows.cairo line 7237 at r1 (raw file):

        );
        staking_attestation
            .update_rewards_from_attestation_contract(staker_address: staker.staker.address);

test also staker rewards (own+commission from pool a)


src/flow_test/flows.cairo line 7250 at r1 (raw file):

        assert!(expected_rewards.is_non_zero());
        assert!(rewards_a == expected_rewards);
        assert!(rewards_b.is_zero());

test also with V3 rewards? we have such test somewhere?

@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch from 87dd152 to da91327 Compare November 25, 2025 08:13
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, 5 unresolved discussions (waiting on @arad-starkware and @noa-starkware)


src/flow_test/flows.cairo line 7147 at r1 (raw file):

Previously, noa-starkware wrote…

/// Delegate for both tokens

Done.


src/flow_test/flows.cairo line 7149 at r1 (raw file):

Previously, noa-starkware wrote…

not relevant to the test, remove from doc

Done.


src/flow_test/flows.cairo line 7237 at r1 (raw file):

Previously, noa-starkware wrote…

why not system.attest(staker)?

Done.


src/flow_test/flows.cairo line 7237 at r1 (raw file):

Previously, noa-starkware wrote…

test also staker rewards (own+commission from pool a)

Done.


src/flow_test/flows.cairo line 7250 at r1 (raw file):

Previously, noa-starkware wrote…

test also with V3 rewards? we have such test somewhere?

I'm not sure what's the scenario you're describing, testing V3 rewards with disabled tokens after upgrade?

@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from 1765bb9 to 3573ad2 Compare November 25, 2025 08:21
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch from da91327 to ae0c797 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, 4 unresolved discussions (waiting on @arad-starkware)


src/flow_test/flows.cairo line 7250 at r1 (raw file):

Previously, arad-starkware wrote…

I'm not sure what's the scenario you're describing, testing V3 rewards with disabled tokens after upgrade?

Yes, just continue the test with start consensus epoch, then call update_rewards and test rewards again (only a token enabled)


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

        system.advance_epoch();
        system.staking.disable_token(token_address: token_b.contract_address());
        system.staking.enable_token(token_address: token_a.contract_address());

I think these lines might be redundant

Code quote:

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

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

            calculate_staker_btc_pool_rewards_v2(
            pool_balance: delegation_amount,
            commission: 200,

Suggestion:

system.staker_info_v1(:staker).pool_info.unwrap().commission

@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch from ae0c797 to b46a1ff Compare November 26, 2025 08:01
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from 3573ad2 to ffdb8ec Compare November 26, 2025 08:01
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch from b46a1ff to 4b0ff1c Compare November 26, 2025 08:35
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch 2 times, most recently from 484a333 to 215d37b Compare November 26, 2025 08:45
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch 2 times, most recently from 2c8afd0 to e48b02c Compare November 26, 2025 11:51
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from 215d37b to 5deab3b Compare November 26, 2025 11:51
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch from e48b02c to 845927c Compare November 26, 2025 13:34
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 @arad-starkware and @noa-starkware)


src/flow_test/flows.cairo line 7250 at r1 (raw file):

Previously, noa-starkware wrote…

Yes, just continue the test with start consensus epoch, then call update_rewards and test rewards again (only a token enabled)

Done.


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

Previously, noa-starkware wrote…

I think these lines might be redundant

I wanted to explicitly disable a token instead of just leaving it disabled by default. Do you think it's unnecessary?


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

            calculate_staker_btc_pool_rewards_v2(
            pool_balance: delegation_amount,
            commission: 200,

Done

@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch from 845927c to 1fc2a9f Compare November 26, 2025 13:56
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch 2 times, most recently from 550520d to a9c72c0 Compare November 26, 2025 13:58
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch from bdca6a8 to 2edc4c4 Compare November 27, 2025 08:13
@arad-starkware arad-starkware changed the base branch from graphite-base/59 to arad/test_add_update_rewards_toggle_tokens_flow_test November 27, 2025 08:13
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch from 2edc4c4 to a123f39 Compare November 27, 2025 15:23
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch 2 times, most recently from 41be9ca to ddcbf57 Compare November 27, 2025 15:28
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch 2 times, most recently from 6fa473d to 9734280 Compare November 27, 2025 17:11
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from ddcbf57 to 0b18f21 Compare November 27, 2025 17:11
@graphite-app graphite-app bot changed the base branch from arad/test_add_update_rewards_toggle_tokens_flow_test to graphite-base/59 December 2, 2025 09:44
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch from 9734280 to 0b9ed88 Compare December 2, 2025 10:32
@arad-starkware arad-starkware changed the base branch from graphite-base/59 to arad/test_add_update_rewards_toggle_tokens_flow_test December 2, 2025 10:32
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from 129a1c6 to ca85233 Compare December 2, 2025 10:47
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch 2 times, most recently from 8a44fec to f7f21fa Compare December 4, 2025 12: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 changed the base branch from arad/test_add_update_rewards_toggle_tokens_flow_test to graphite-base/59 December 4, 2025 13:01
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch from f7f21fa to 1a95f7b Compare December 4, 2025 13:02
@graphite-app graphite-app bot changed the base branch from graphite-base/59 to main December 4, 2025 13:02
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch from 1a95f7b to e5c165d Compare December 4, 2025 13:02
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #59   +/-   ##
=======================================
  Coverage   95.81%   95.81%           
=======================================
  Files          42       42           
  Lines       10194    10194           
=======================================
  Hits         9767     9767           
  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 merged commit b42160b into main Dec 4, 2025
7 of 8 checks passed
Copy link
Collaborator Author

Merge activity

@arad-starkware arad-starkware deleted the arad/test_add_token_state_after_upgrade_flow branch December 4, 2025 13:07
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