-
Notifications
You must be signed in to change notification settings - Fork 28
update rewards and governed pool MIP-124 #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
d24dc17
9e05ac8
a0b6c84
bf94242
cd66e92
876ca01
1774dbf
8b72cd3
22a320d
338e622
99e4516
5831237
b11b9f9
279f535
13e9103
a7fffff
4fd6bcd
b779b6c
383ed85
fce0dd6
3c4ebed
97225a6
dcf8c6c
c1cc00f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,8 @@ module aptos_framework::governed_gas_pool { | |
| #[test_only] | ||
| use aptos_framework::aptos_coin::Self; | ||
|
|
||
| friend aptos_framework::stake; | ||
|
|
||
| const MODULE_SALT: vector<u8> = b"aptos_framework::governed_gas_pool"; | ||
|
|
||
| /// The Governed Gas Pool | ||
|
|
@@ -170,6 +172,27 @@ module aptos_framework::governed_gas_pool { | |
| coin::balance<CoinType>(pool_address) | ||
| } | ||
|
|
||
| /// Withdraws coins from the governed gas pool. | ||
| /// | ||
| /// This function allows friend modules to withdraw a specified amount of a given | ||
| /// `CoinType` from the governed gas pool. It uses the internal signer of the | ||
| /// governed gas pool to authorize the withdrawal. | ||
| /// | ||
| /// @param amount The amount of coins to withdraw from the pool. | ||
| /// @return A `Coin<CoinType>` resource containing the withdrawn amount. | ||
| public(friend) fun withdraw_from_pool<CoinType>( | ||
| amount: u64 | ||
|
areshand marked this conversation as resolved.
|
||
| ): Coin<CoinType> acquires GovernedGasPool { | ||
| let s = governed_gas_signer(); // uses the private signer function | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. assert the pool has sufficient balance for the withdraw? |
||
| coin::withdraw<CoinType>(&s, amount) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 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) ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I push the account implementation with 2 tests updated.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
It might seem clunky but it's correct, so I would say yes. |
||
| } | ||
|
|
||
| /// Register Aptos coin with Gouverned gas signer. | ||
|
areshand marked this conversation as resolved.
Outdated
|
||
| public(friend) fun register_coin<CoinType>() acquires GovernedGasPool { | ||
|
areshand marked this conversation as resolved.
|
||
| let s = governed_gas_signer(); | ||
| coin::register<CoinType>(&s); | ||
| } | ||
|
|
||
| #[test_only] | ||
| /// The AptosCoin mint capability | ||
| struct AptosCoinMintCapability has key { | ||
|
|
@@ -361,4 +384,4 @@ module aptos_framework::governed_gas_pool { | |
| // initialize the governed gas pool again, no abort | ||
| initialize(aptos_framework, vector::empty<u8>()); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.