Skip to content

update rewards and governed pool MIP-124 - #227

Merged
0xmovses merged 24 commits into
movement-migrationfrom
0xmovses/update-rewards
Oct 17, 2025
Merged

update rewards and governed pool MIP-124#227
0xmovses merged 24 commits into
movement-migrationfrom
0xmovses/update-rewards

Conversation

@0xmovses

@0xmovses 0xmovses commented Oct 8, 2025

Copy link
Copy Markdown

Description

Based on MIP-124.

Implements this changes: https://www.notion.so/movementlabs/Staking-reward-using-GGP-28118675b2d780848e30c0c7e51d47cc

Testing

In the folder aptos-move/framework/aptos-framework run movement move test to run all test.
Or movement move test -f stake to run stake related tests.

@0xmovses
0xmovses changed the base branch from main to movement October 8, 2025 23:16
@musitdev musitdev self-assigned this Oct 13, 2025
@apenzk

apenzk commented Oct 13, 2025

Copy link
Copy Markdown

given the amount of changes required, possibly it is a better decision to stick with the rewards_rate system as it exists? it already implements an APR system just that the governance has to precalculate the reward_rate per epoch from the desired APR. @0xmovses @musitdev

This reverts commit 8b72cd3.

Too complexe, we use the Aptos way to update reward rate.
@musitdev

Copy link
Copy Markdown

given the amount of changes required, possibly it is a better decision to stick with the rewards_rate system as it exists? it already implements an APR system just that the governance has to precalculate the reward_rate per epoch from the desired APR. @0xmovses @musitdev

Ok I revert the commit and do the test to confirm the issue.

@0xmovses
0xmovses changed the base branch from movement to movement-migration October 14, 2025 16:12
@0xmovses 0xmovses changed the title [WIP]0xmovses/update rewards update rewards and governed pool MIP-124 Oct 14, 2025
@0xmovses

Copy link
Copy Markdown
Author

All unit tests are passing. Only ask is that we update the Move fmt. And then @areshand can review. Thanks!

@0xmovses
0xmovses changed the base branch from movement-migration to movement October 15, 2025 12:59
@musitdev
musitdev changed the base branch from movement to movement-migration October 15, 2025 14:07
@musitdev
musitdev changed the base branch from movement-migration to movement October 15, 2025 16:18
@0xmovses
0xmovses changed the base branch from movement to movement-migration October 15, 2025 16:26
@0xmovses
0xmovses changed the base branch from movement-migration to movement October 15, 2025 16:26
@0xmovses
0xmovses changed the base branch from movement to movement-migration October 15, 2025 16:27
@0xmovses
0xmovses requested a review from areshand October 15, 2025 16:28
amount: u64
): Coin<CoinType> acquires GovernedGasPool {
let s = governed_gas_signer(); // uses the private signer function
coin::withdraw<CoinType>(&s, amount)

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.

can we have a dedicated event for withdraw from GGP for accounting purpose

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yep

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Add an event to GGP is a little more complicated than expected. Creating the event handler in the unit test need to have the sender account created, and the framework account is not for most of the test that use the staking.
I've tested, and I get the MISSING_DATA (code 4008) error when the handler is created.

To solve this, you need to add this line in all test that fails: aptos_framework::account::create_account_for_test(@aptos_framework);

I've tested using account::new_event_handle<>() and event::new_event_handle<>() , the account must be created to create the handler.

What do you think, I add the create_account_for_test in all failing test (all test that use the GGP) ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I push the account implementation with 2 tests updated.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That's correct, it uses the resource account pattern https://aptos.dev/build/smart-contracts/resource-accounts

What do you think, I add the create_account_for_test in all failing test (all test that use the GGP) ?

It might seem clunky but it's correct, so I would say yes.

Comment thread aptos-move/framework/aptos-framework/sources/governed_gas_pool.move
Comment thread aptos-move/framework/aptos-framework/sources/governed_gas_pool.move Outdated

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

Just in case we want to shut down this part of logic

Comment thread aptos-move/framework/aptos-framework/sources/governed_gas_pool.move

// Decrease the treasury counter.
if (ggp.deposited_treasury_counter > amount) {
ggp.deposited_treasury_counter = ggp.deposited_treasury_counter - amount;

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.

maybe we rename deposited_treasury_counter to total_deposited_treasury_counter. we don't need to decrease it

@musitdev musitdev Oct 16, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In fact, what is the goal of this treasury counter. If it's to know how many treasures that was deposited, it shouldn't be decrease, if it's the part of the deposited treasure in the current pool, we should decrease it.
Perhaps by adding an event to deposit_treasury we can manage these data off chain and not on chain.

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.

IMO, we can only know how many treasures that was deposited. During withdraw reward, we dont differentiate gas fund from treasury fund

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

So the need is to know how many treasure has been deposited. I remove the withdraw.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I pull the change, the treasure decrease has been removed.

Comment thread aptos-move/framework/aptos-framework/sources/governed_gas_pool.move Outdated
@0xmovses
0xmovses requested review from areshand and musitdev October 16, 2025 18:39
}

/// Contains added variable needed for the GovernedGasPool staking reward update.
struct GovernedGasPoolV2 has key {

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.

naming is hard. But this is not ggp v2. this is more like a GovernedGasPoolExtension.

signer_capability: governed_gas_pool_signer_cap,
});

move_to(aptos_framework, GovernedGasPoolV2{

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.

this is only called during genesis. You need to a separate function to initialize this resource. Otherwise, deposit and withdraw would break

@0xmovses

Copy link
Copy Markdown
Author

Note: Partner PR to follow, this squash commit into movement branch

@0xmovses
0xmovses merged commit 0ae9d6f into movement-migration Oct 17, 2025
0xmovses added a commit that referenced this pull request Oct 20, 2025
This was cherry picked from `0ae9d6f8721954e7428a9feefac83ae52bff0355`
on `movement-migration` which is the squash commit from PR
#227.

We need this commits now on `movement` for testing purposes.

---------

Co-authored-by: Bo Wu <bo.wu@movementlabs.xyz>
Co-authored-by: musitdev <philippe.delrieu@free.fr>
0xmovses added a commit that referenced this pull request Oct 22, 2025
Based on [MIP-124](movement-network/MIP#124).

Implements this changes:
https://www.notion.so/movementlabs/Staking-reward-using-GGP-28118675b2d780848e30c0c7e51d47cc

In the folder `aptos-move/framework/aptos-framework` run `movement move
test` to run all test.
Or `movement move test -f stake `to run stake related tests.

---------

Co-authored-by: musitdev <philippe.delrieu@free.fr>
0xmovses added a commit that referenced this pull request Oct 30, 2025
Based on [MIP-124](movement-network/MIP#124).

Implements these changes:

https://www.notion.so/movementlabs/Staking-reward-using-GGP-28118675b2d780848e30c0c7e51d47cc

In the folder `aptos-move/framework/aptos-framework` run `aptos move
test` to run all test.
Or `aptos move test -f stake `to run stake related tests.

---------

See the #227 original PR

---------

Co-authored-by: musitdev <philippe.delrieu@free.fr>
@sausagee
sausagee deleted the 0xmovses/update-rewards branch March 12, 2026 23:39
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.

4 participants