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 flow and test to verify token enable/disable behavior across upgrade and during consensus rewards, and imports v3 BTC pool reward calc.

  • Flow Tests:
    • EnableDisableTokenBeforeAfterUpgradeFlow in src/flow_test/flows.cairo:
      • Sets up two BTC tokens, delegates to both, toggles enable/disable before and after upgrade.
      • Verifies get_tokens view and rewards distribution pre/post-upgrade and under consensus rewards.
    • Registers test enable_disable_token_before_after_upgrade_flow_test in src/flow_test/fork_test.cairo.
  • Utilities:
    • Imports calculate_staker_btc_pool_rewards_v3 for v3 reward calculations.
  • Docs:
    • Cleans up src/flow_test/flow_ideas.md by removing obsolete token test idea.

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

Copy link
Collaborator Author

arad-starkware commented Nov 24, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@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_update_rewards_toggle_tokens_flow_test branch 2 times, most recently from 96cb2c9 to 625acb6 Compare November 26, 2025 17:10
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch from ed9fb2d to 878cc79 Compare November 26, 2025 17:10
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch from 625acb6 to d3512f2 Compare November 26, 2025 17:16
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch 2 times, most recently from 2451b5c to 731bc76 Compare November 26, 2025 17:26
@arad-starkware arad-starkware force-pushed the arad/test_add_update_rewards_toggle_tokens_flow_test branch 3 times, most recently from 8a0dadc to bbf04ed Compare November 27, 2025 07:47
@arad-starkware arad-starkware force-pushed the arad/test_add_token_state_after_upgrade_flow branch from 731bc76 to bdca6a8 Compare November 27, 2025 07:47
@arad-starkware arad-starkware changed the base branch from arad/test_add_update_rewards_toggle_tokens_flow_test to graphite-base/59 November 27, 2025 08:12
@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 from 0b9ed88 to 8a44fec Compare December 2, 2025 10:47
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