Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ab2cab7
feat: governed gass pool fee deposit.
l-monninger Dec 12, 2024
932d3e0
feat: governed gas pool.
l-monninger Dec 16, 2024
368de0e
fix: spec.
l-monninger Dec 16, 2024
41b4dcc
feat: default governed-gas-pool feature flag.
l-monninger Dec 17, 2024
c68ade6
feat: default governed-gas-pool feature flag.
l-monninger Dec 17, 2024
2e441ef
create: initial spec for gas_pool
0xmovses Dec 28, 2024
e14fb8e
fix: bad keyword
0xmovses Jan 2, 2025
b67a258
update: global ghost variables
0xmovses Jan 2, 2025
0e2f96f
update: init assertion
0xmovses Jan 3, 2025
c7eb934
update: fund spec
0xmovses Jan 4, 2025
202ac61
update: fund spec
0xmovses Jan 7, 2025
706bfd1
update: transaction_validation.spec
0xmovses Jan 7, 2025
568af1c
fix: bring back disabled features
0xmovses Jan 7, 2025
483f867
remove: disable fa_migration feature causing spec to fail
0xmovses Jan 7, 2025
8c8ce6c
test: initial structure for governed_gas_pool test
0xmovses Jan 8, 2025
887d461
feat: add initialize for ggp to genesis
0xmovses Jan 8, 2025
2a49f7d
update: vm-genesis
0xmovses Jan 8, 2025
6df0b13
update: call ggp init in vm-genesis
0xmovses Jan 8, 2025
190d7a2
fix: typo
0xmovses Jan 8, 2025
a01cd38
update: correct type error
0xmovses Jan 8, 2025
f040da5
update: fix MoveValue
0xmovses Jan 8, 2025
3c5b209
fix: enable COIN_TO_FUNGIBLE_ASSET_MIGRATION feature
0xmovses Jan 9, 2025
8b9d1a5
feat: get balance and test for ggp
0xmovses Jan 13, 2025
844bc62
fix: not pub
0xmovses Jan 13, 2025
8b8eb8f
Merge pull request #120 from movementlabsxyz/0xmovses/genesis-ggp
0xmovses Jan 13, 2025
4f69b0e
feat: add test helper to set chain_id
0xmovses Jan 26, 2025
d9c930c
Merge pull request #127 from movementlabsxyz/0xmovses/new-test-helper
0xmovses Jan 26, 2025
7379c01
fix: merge conflict
0xmovses Jan 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
555 changes: 555 additions & 0 deletions .github/ts-tasks/package-lock.json

Large diffs are not rendered by default.

196 changes: 124 additions & 72 deletions aptos-move/framework/aptos-framework/doc/coin.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ This module provides the foundation for typesafe Coins.
- [Function `register`](#0x1_coin_register)
- [Function `transfer`](#0x1_coin_transfer)
- [Function `value`](#0x1_coin_value)
- [Function `withdraw_from`](#0x1_coin_withdraw_from)
- [Function `withdraw`](#0x1_coin_withdraw)
- [Function `zero`](#0x1_coin_zero)
- [Function `destroy_freeze_cap`](#0x1_coin_destroy_freeze_cap)
Expand Down Expand Up @@ -3399,6 +3400,71 @@ Returns the <code>value</code> passed in <code><a href="coin.md#0x1_coin">coin</



</details>

<a id="0x1_coin_withdraw_from"></a>

## Function `withdraw_from`

Withdraws a specifed <code>amount</code> of coin <code>CoinType</code> from the specified <code><a href="account.md#0x1_account">account</a></code>.
@param account The account from which to withdraw the coin.
@param amount The amount of coin to withdraw.


<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="coin.md#0x1_coin_withdraw_from">withdraw_from</a>&lt;CoinType&gt;(account_addr: <b>address</b>, amount: u64): <a href="coin.md#0x1_coin_Coin">coin::Coin</a>&lt;CoinType&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="coin.md#0x1_coin_withdraw_from">withdraw_from</a>&lt;CoinType&gt;(
account_addr: <b>address</b>,
amount: u64
): <a href="coin.md#0x1_coin_Coin">Coin</a>&lt;CoinType&gt; <b>acquires</b> <a href="coin.md#0x1_coin_CoinStore">CoinStore</a>, <a href="coin.md#0x1_coin_CoinConversionMap">CoinConversionMap</a>, <a href="coin.md#0x1_coin_CoinInfo">CoinInfo</a>, <a href="coin.md#0x1_coin_PairedCoinType">PairedCoinType</a> {

<b>let</b> (coin_amount_to_withdraw, fa_amount_to_withdraw) = <a href="coin.md#0x1_coin_calculate_amount_to_withdraw">calculate_amount_to_withdraw</a>&lt;CoinType&gt;(
account_addr,
amount
);
<b>let</b> withdrawn_coin = <b>if</b> (coin_amount_to_withdraw &gt; 0) {
<b>let</b> coin_store = <b>borrow_global_mut</b>&lt;<a href="coin.md#0x1_coin_CoinStore">CoinStore</a>&lt;CoinType&gt;&gt;(account_addr);
<b>assert</b>!(
!coin_store.frozen,
<a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_permission_denied">error::permission_denied</a>(<a href="coin.md#0x1_coin_EFROZEN">EFROZEN</a>),
);
<b>if</b> (std::features::module_event_migration_enabled()) {
<a href="event.md#0x1_event_emit">event::emit</a>(
<a href="coin.md#0x1_coin_CoinWithdraw">CoinWithdraw</a> {
coin_type: type_name&lt;CoinType&gt;(), <a href="account.md#0x1_account">account</a>: account_addr, amount: coin_amount_to_withdraw
}
);
};
<a href="event.md#0x1_event_emit_event">event::emit_event</a>&lt;<a href="coin.md#0x1_coin_WithdrawEvent">WithdrawEvent</a>&gt;(
&<b>mut</b> coin_store.withdraw_events,
<a href="coin.md#0x1_coin_WithdrawEvent">WithdrawEvent</a> { amount: coin_amount_to_withdraw },
);
<a href="coin.md#0x1_coin_extract">extract</a>(&<b>mut</b> coin_store.<a href="coin.md#0x1_coin">coin</a>, coin_amount_to_withdraw)
} <b>else</b> {
<a href="coin.md#0x1_coin_zero">zero</a>()
};
<b>if</b> (fa_amount_to_withdraw &gt; 0) {
<b>let</b> store_addr = <a href="primary_fungible_store.md#0x1_primary_fungible_store_primary_store_address">primary_fungible_store::primary_store_address</a>(
account_addr,
<a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_destroy_some">option::destroy_some</a>(<a href="coin.md#0x1_coin_paired_metadata">paired_metadata</a>&lt;CoinType&gt;())
);
<b>let</b> fa = <a href="fungible_asset.md#0x1_fungible_asset_withdraw_internal">fungible_asset::withdraw_internal</a>(store_addr, fa_amount_to_withdraw);
<a href="coin.md#0x1_coin_merge">merge</a>(&<b>mut</b> withdrawn_coin, <a href="coin.md#0x1_coin_fungible_asset_to_coin">fungible_asset_to_coin</a>&lt;CoinType&gt;(fa));
};

withdrawn_coin
}
</code></pre>



</details>

<a id="0x1_coin_withdraw"></a>
Expand Down Expand Up @@ -3814,64 +3880,6 @@ initialize, initialize_internal, initialize_with_parallelizable_supply;




<a id="0x1_coin_spec_is_account_registered"></a>


<pre><code><b>fun</b> <a href="coin.md#0x1_coin_spec_is_account_registered">spec_is_account_registered</a>&lt;CoinType&gt;(account_addr: <b>address</b>): bool {
<b>let</b> paired_metadata_opt = <a href="coin.md#0x1_coin_spec_paired_metadata">spec_paired_metadata</a>&lt;CoinType&gt;();
<b>exists</b>&lt;<a href="coin.md#0x1_coin_CoinStore">CoinStore</a>&lt;CoinType&gt;&gt;(account_addr) || (<a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_spec_is_some">option::spec_is_some</a>(
paired_metadata_opt
) && <a href="primary_fungible_store.md#0x1_primary_fungible_store_spec_primary_store_exists">primary_fungible_store::spec_primary_store_exists</a>(account_addr, <a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_spec_borrow">option::spec_borrow</a>(paired_metadata_opt)))
}
</code></pre>




<a id="0x1_coin_CoinSubAbortsIf"></a>


<pre><code><b>schema</b> <a href="coin.md#0x1_coin_CoinSubAbortsIf">CoinSubAbortsIf</a>&lt;CoinType&gt; {
amount: u64;
<b>let</b> addr = <a href="../../aptos-stdlib/doc/type_info.md#0x1_type_info_type_of">type_info::type_of</a>&lt;CoinType&gt;().account_address;
<b>let</b> maybe_supply = <b>global</b>&lt;<a href="coin.md#0x1_coin_CoinInfo">CoinInfo</a>&lt;CoinType&gt;&gt;(addr).<a href="coin.md#0x1_coin_supply">supply</a>;
<b>include</b> (<a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_is_some">option::is_some</a>(
maybe_supply
)) ==&gt; <a href="optional_aggregator.md#0x1_optional_aggregator_SubAbortsIf">optional_aggregator::SubAbortsIf</a> { <a href="optional_aggregator.md#0x1_optional_aggregator">optional_aggregator</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_borrow">option::borrow</a>(maybe_supply), value: amount };
}
</code></pre>




<a id="0x1_coin_CoinAddAbortsIf"></a>


<pre><code><b>schema</b> <a href="coin.md#0x1_coin_CoinAddAbortsIf">CoinAddAbortsIf</a>&lt;CoinType&gt; {
amount: u64;
<b>let</b> addr = <a href="../../aptos-stdlib/doc/type_info.md#0x1_type_info_type_of">type_info::type_of</a>&lt;CoinType&gt;().account_address;
<b>let</b> maybe_supply = <b>global</b>&lt;<a href="coin.md#0x1_coin_CoinInfo">CoinInfo</a>&lt;CoinType&gt;&gt;(addr).<a href="coin.md#0x1_coin_supply">supply</a>;
<b>include</b> (<a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_is_some">option::is_some</a>(
maybe_supply
)) ==&gt; <a href="optional_aggregator.md#0x1_optional_aggregator_AddAbortsIf">optional_aggregator::AddAbortsIf</a> { <a href="optional_aggregator.md#0x1_optional_aggregator">optional_aggregator</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_borrow">option::borrow</a>(maybe_supply), value: amount };
}
</code></pre>




<a id="0x1_coin_AbortsIfNotExistCoinInfo"></a>


<pre><code><b>schema</b> <a href="coin.md#0x1_coin_AbortsIfNotExistCoinInfo">AbortsIfNotExistCoinInfo</a>&lt;CoinType&gt; {
<b>let</b> addr = <a href="../../aptos-stdlib/doc/type_info.md#0x1_type_info_type_of">type_info::type_of</a>&lt;CoinType&gt;().account_address;
<b>aborts_if</b> !<b>exists</b>&lt;<a href="coin.md#0x1_coin_CoinInfo">CoinInfo</a>&lt;CoinType&gt;&gt;(addr);
}
</code></pre>



<a id="@Specification_1_AggregatableCoin"></a>

### Struct `AggregatableCoin`
Expand Down Expand Up @@ -4095,20 +4103,6 @@ Can only be updated by <code>@aptos_framework</code>.




<a id="0x1_coin_DepositAbortsIf"></a>


<pre><code><b>schema</b> <a href="coin.md#0x1_coin_DepositAbortsIf">DepositAbortsIf</a>&lt;CoinType&gt; {
account_addr: <b>address</b>;
<b>let</b> coin_store = <b>global</b>&lt;<a href="coin.md#0x1_coin_CoinStore">CoinStore</a>&lt;CoinType&gt;&gt;(account_addr);
<b>aborts_if</b> !<b>exists</b>&lt;<a href="coin.md#0x1_coin_CoinStore">CoinStore</a>&lt;CoinType&gt;&gt;(account_addr);
<b>aborts_if</b> coin_store.frozen;
}
</code></pre>



<a id="@Specification_1_coin_address"></a>

### Function `coin_address`
Expand Down Expand Up @@ -4215,6 +4209,64 @@ Get address by reflection.




<a id="0x1_coin_spec_is_account_registered"></a>


<pre><code><b>fun</b> <a href="coin.md#0x1_coin_spec_is_account_registered">spec_is_account_registered</a>&lt;CoinType&gt;(account_addr: <b>address</b>): bool {
<b>let</b> paired_metadata_opt = <a href="coin.md#0x1_coin_spec_paired_metadata">spec_paired_metadata</a>&lt;CoinType&gt;();
<b>exists</b>&lt;<a href="coin.md#0x1_coin_CoinStore">CoinStore</a>&lt;CoinType&gt;&gt;(account_addr) || (<a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_spec_is_some">option::spec_is_some</a>(
paired_metadata_opt
) && <a href="primary_fungible_store.md#0x1_primary_fungible_store_spec_primary_store_exists">primary_fungible_store::spec_primary_store_exists</a>(account_addr, <a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_spec_borrow">option::spec_borrow</a>(paired_metadata_opt)))
}
</code></pre>




<a id="0x1_coin_CoinSubAbortsIf"></a>


<pre><code><b>schema</b> <a href="coin.md#0x1_coin_CoinSubAbortsIf">CoinSubAbortsIf</a>&lt;CoinType&gt; {
amount: u64;
<b>let</b> addr = <a href="../../aptos-stdlib/doc/type_info.md#0x1_type_info_type_of">type_info::type_of</a>&lt;CoinType&gt;().account_address;
<b>let</b> maybe_supply = <b>global</b>&lt;<a href="coin.md#0x1_coin_CoinInfo">CoinInfo</a>&lt;CoinType&gt;&gt;(addr).<a href="coin.md#0x1_coin_supply">supply</a>;
<b>include</b> (<a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_is_some">option::is_some</a>(
maybe_supply
)) ==&gt; <a href="optional_aggregator.md#0x1_optional_aggregator_SubAbortsIf">optional_aggregator::SubAbortsIf</a> { <a href="optional_aggregator.md#0x1_optional_aggregator">optional_aggregator</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_borrow">option::borrow</a>(maybe_supply), value: amount };
}
</code></pre>




<a id="0x1_coin_CoinAddAbortsIf"></a>


<pre><code><b>schema</b> <a href="coin.md#0x1_coin_CoinAddAbortsIf">CoinAddAbortsIf</a>&lt;CoinType&gt; {
amount: u64;
<b>let</b> addr = <a href="../../aptos-stdlib/doc/type_info.md#0x1_type_info_type_of">type_info::type_of</a>&lt;CoinType&gt;().account_address;
<b>let</b> maybe_supply = <b>global</b>&lt;<a href="coin.md#0x1_coin_CoinInfo">CoinInfo</a>&lt;CoinType&gt;&gt;(addr).<a href="coin.md#0x1_coin_supply">supply</a>;
<b>include</b> (<a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_is_some">option::is_some</a>(
maybe_supply
)) ==&gt; <a href="optional_aggregator.md#0x1_optional_aggregator_AddAbortsIf">optional_aggregator::AddAbortsIf</a> { <a href="optional_aggregator.md#0x1_optional_aggregator">optional_aggregator</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_borrow">option::borrow</a>(maybe_supply), value: amount };
}
</code></pre>




<a id="0x1_coin_AbortsIfNotExistCoinInfo"></a>


<pre><code><b>schema</b> <a href="coin.md#0x1_coin_AbortsIfNotExistCoinInfo">AbortsIfNotExistCoinInfo</a>&lt;CoinType&gt; {
<b>let</b> addr = <a href="../../aptos-stdlib/doc/type_info.md#0x1_type_info_type_of">type_info::type_of</a>&lt;CoinType&gt;().account_address;
<b>aborts_if</b> !<b>exists</b>&lt;<a href="coin.md#0x1_coin_CoinInfo">CoinInfo</a>&lt;CoinType&gt;&gt;(addr);
}
</code></pre>



<a id="@Specification_1_name"></a>

### Function `name`
Expand Down
29 changes: 29 additions & 0 deletions aptos-move/framework/aptos-framework/doc/genesis.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [Constants](#@Constants_0)
- [Function `initialize`](#0x1_genesis_initialize)
- [Function `initialize_aptos_coin`](#0x1_genesis_initialize_aptos_coin)
- [Function `initialize_governed_gas_pool`](#0x1_genesis_initialize_governed_gas_pool)
- [Function `initialize_core_resources_and_aptos_coin`](#0x1_genesis_initialize_core_resources_and_aptos_coin)
- [Function `create_accounts`](#0x1_genesis_create_accounts)
- [Function `create_account`](#0x1_genesis_create_account)
Expand Down Expand Up @@ -50,6 +51,7 @@
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features">0x1::features</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/fixed_point32.md#0x1_fixed_point32">0x1::fixed_point32</a>;
<b>use</b> <a href="gas_schedule.md#0x1_gas_schedule">0x1::gas_schedule</a>;
<b>use</b> <a href="governed_gas_pool.md#0x1_governed_gas_pool">0x1::governed_gas_pool</a>;
<b>use</b> <a href="native_bridge.md#0x1_native_bridge">0x1::native_bridge</a>;
<b>use</b> <a href="reconfiguration.md#0x1_reconfiguration">0x1::reconfiguration</a>;
<b>use</b> <a href="../../aptos-stdlib/doc/simple_map.md#0x1_simple_map">0x1::simple_map</a>;
Expand Down Expand Up @@ -407,6 +409,33 @@ Genesis step 2: Initialize Aptos coin.



</details>

<a id="0x1_genesis_initialize_governed_gas_pool"></a>

## Function `initialize_governed_gas_pool`



<pre><code><b>fun</b> <a href="genesis.md#0x1_genesis_initialize_governed_gas_pool">initialize_governed_gas_pool</a>(aptos_framework: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, delegation_pool_creation_seed: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;)
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>fun</b> <a href="genesis.md#0x1_genesis_initialize_governed_gas_pool">initialize_governed_gas_pool</a>(
aptos_framework: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>,
delegation_pool_creation_seed: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
) {
<a href="governed_gas_pool.md#0x1_governed_gas_pool_initialize">governed_gas_pool::initialize</a>(aptos_framework, delegation_pool_creation_seed);
}
</code></pre>



</details>

<a id="0x1_genesis_initialize_core_resources_and_aptos_coin"></a>
Expand Down
Loading