Skip to content
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

[Spec] Ensures for stake.move #9700

Merged
merged 33 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d6a252d
1
chan-bing Jul 20, 2023
6370b47
Merge branch 'hp_stake' of https://github.com/movebit/aptos-core into…
UIZorrot Jul 20, 2023
7d65822
cannot finish hp
chan-bing Jul 25, 2023
c4c4bfa
remove some wrong statements
chan-bing Jul 26, 2023
f6284dc
hp1-3
chan-bing Jul 27, 2023
cdcf6ce
rewrite hp2
chan-bing Aug 4, 2023
e0041d3
rewrite hp2 again
chan-bing Aug 5, 2023
7485174
hp1-3
chan-bing Aug 8, 2023
f6a39ae
Merge branch 'hp_stake' of https://github.com/movebit/aptos-core into…
UIZorrot Aug 21, 2023
bfdecb5
init
UIZorrot Aug 21, 2023
479ddb9
fix
UIZorrot Aug 23, 2023
67970a6
fix ensures
UIZorrot Aug 28, 2023
02e1945
fix ensure in the update_sat
UIZorrot Aug 29, 2023
907008c
Merge branch 'main' into hp_stake
UIZorrot Sep 1, 2023
c4cb449
Merge branch 'hp_stake' of https://github.com/movebit/aptos-core into…
UIZorrot Sep 1, 2023
e13a325
fix comment
UIZorrot Sep 6, 2023
f828c2d
Merge branch 'main' into hp_stake
UIZorrot Sep 6, 2023
01dc65f
Merge branch 'hp_stake' of https://github.com/movebit/aptos-core into…
UIZorrot Sep 6, 2023
bec2ef6
fix md
UIZorrot Sep 6, 2023
600eb40
fix new comment
UIZorrot Sep 7, 2023
f871d92
Merge branch 'main' into hp_stake
UIZorrot Sep 12, 2023
483e3db
Merge branch 'main' into hp_stake
UIZorrot Sep 19, 2023
34af27d
update comment
UIZorrot Sep 19, 2023
6725ab4
Merge branch 'hp_stake' of https://github.com/movebit/aptos-core into…
UIZorrot Sep 19, 2023
c15000d
fix indent
UIZorrot Sep 20, 2023
65f2d11
fix timeout
UIZorrot Sep 21, 2023
6ae2928
Merge branch 'main' into hp_stake
UIZorrot Sep 22, 2023
7f91550
Merge branch 'main' into hp_stake
UIZorrot Sep 22, 2023
f28b3d3
fix timeout
UIZorrot Sep 23, 2023
5141aa3
Merge branch 'hp_stake' of https://github.com/movebit/aptos-core into…
UIZorrot Sep 23, 2023
be13b65
Merge branch 'main' into hp_stake
UIZorrot Sep 25, 2023
b654273
Merge branch 'hp_stake' of https://github.com/movebit/aptos-core into…
UIZorrot Sep 25, 2023
008ee4f
fix timeout
UIZorrot Sep 25, 2023
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
76 changes: 75 additions & 1 deletion aptos-move/framework/aptos-framework/doc/aptos_governance.md
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,79 @@ The same as spec of <code><a href="aptos_governance.md#0x1_aptos_governance_crea
</code></pre>


<code>stake_pool</code> must exist StakePool.
The delegated voter under the resource StakePool of the stake_pool must be the proposer address.
Address @aptos_framework must exist GovernanceEvents.


<a name="0x1_aptos_governance_CreateProposalAbortsIf"></a>


<pre><code><b>schema</b> <a href="aptos_governance.md#0x1_aptos_governance_CreateProposalAbortsIf">CreateProposalAbortsIf</a> {
proposer: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>;
stake_pool: <b>address</b>;
execution_hash: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;;
metadata_location: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;;
metadata_hash: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;;
<b>include</b> <a href="aptos_governance.md#0x1_aptos_governance_VotingGetDelegatedVoterAbortsIf">VotingGetDelegatedVoterAbortsIf</a> { sign: proposer };
<b>include</b> <a href="aptos_governance.md#0x1_aptos_governance_AbortsIfNotGovernanceConfig">AbortsIfNotGovernanceConfig</a>;
<b>include</b> <a href="aptos_governance.md#0x1_aptos_governance_GetVotingPowerAbortsIf">GetVotingPowerAbortsIf</a> { pool_address: stake_pool };
<b>let</b> <a href="staking_config.md#0x1_staking_config">staking_config</a> = <b>global</b>&lt;<a href="staking_config.md#0x1_staking_config_StakingConfig">staking_config::StakingConfig</a>&gt;(@aptos_framework);
<b>let</b> allow_validator_set_change = <a href="staking_config.md#0x1_staking_config">staking_config</a>.allow_validator_set_change;
<b>let</b> stake_pool_res = <b>global</b>&lt;<a href="stake.md#0x1_stake_StakePool">stake::StakePool</a>&gt;(stake_pool);
<b>let</b> stake_balance_0 = stake_pool_res.active.value + stake_pool_res.pending_active.value + stake_pool_res.pending_inactive.value;
<b>let</b> stake_balance_1 = stake_pool_res.active.value + stake_pool_res.pending_inactive.value;
<b>let</b> stake_balance_2 = 0;
<b>let</b> governance_config = <b>global</b>&lt;<a href="aptos_governance.md#0x1_aptos_governance_GovernanceConfig">GovernanceConfig</a>&gt;(@aptos_framework);
<b>let</b> required_proposer_stake = governance_config.required_proposer_stake;
<b>aborts_if</b> allow_validator_set_change && stake_balance_0 &lt; required_proposer_stake;
<b>aborts_if</b> !allow_validator_set_change && <a href="stake.md#0x1_stake_spec_is_current_epoch_validator">stake::spec_is_current_epoch_validator</a>(stake_pool) && stake_balance_1 &lt; required_proposer_stake;
<b>aborts_if</b> !allow_validator_set_change && !<a href="stake.md#0x1_stake_spec_is_current_epoch_validator">stake::spec_is_current_epoch_validator</a>(stake_pool) && stake_balance_2 &lt; required_proposer_stake;
<b>aborts_if</b> !<b>exists</b>&lt;<a href="timestamp.md#0x1_timestamp_CurrentTimeMicroseconds">timestamp::CurrentTimeMicroseconds</a>&gt;(@aptos_framework);
<b>let</b> current_time = <a href="timestamp.md#0x1_timestamp_spec_now_seconds">timestamp::spec_now_seconds</a>();
<b>let</b> proposal_expiration = current_time + governance_config.voting_duration_secs;
<b>aborts_if</b> stake_pool_res.locked_until_secs &lt; proposal_expiration;
<b>include</b> <a href="aptos_governance.md#0x1_aptos_governance_CreateProposalMetadataAbortsIf">CreateProposalMetadataAbortsIf</a>;
<b>let</b> addr = aptos_std::type_info::type_of&lt;AptosCoin&gt;().account_address;
<b>aborts_if</b> !<b>exists</b>&lt;<a href="coin.md#0x1_coin_CoinInfo">coin::CoinInfo</a>&lt;AptosCoin&gt;&gt;(addr);
<b>let</b> maybe_supply = <b>global</b>&lt;<a href="coin.md#0x1_coin_CoinInfo">coin::CoinInfo</a>&lt;AptosCoin&gt;&gt;(addr).supply;
<b>let</b> supply = <a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_spec_borrow">option::spec_borrow</a>(maybe_supply);
<b>let</b> total_supply = aptos_framework::optional_aggregator::optional_aggregator_value(supply);
<b>let</b> early_resolution_vote_threshold_value = total_supply / 2 + 1;
<b>aborts_if</b> <a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_spec_is_some">option::spec_is_some</a>(maybe_supply) && governance_config.min_voting_threshold &gt; early_resolution_vote_threshold_value;
<b>aborts_if</b> len(execution_hash) &lt;= 0;
<b>aborts_if</b> !<b>exists</b>&lt;<a href="voting.md#0x1_voting_VotingForum">voting::VotingForum</a>&lt;GovernanceProposal&gt;&gt;(@aptos_framework);
<b>let</b> voting_forum = <b>global</b>&lt;<a href="voting.md#0x1_voting_VotingForum">voting::VotingForum</a>&lt;GovernanceProposal&gt;&gt;(@aptos_framework);
<b>let</b> proposal_id = voting_forum.next_proposal_id;
<b>aborts_if</b> proposal_id + 1 &gt; <a href="aptos_governance.md#0x1_aptos_governance_MAX_U64">MAX_U64</a>;
<b>let</b> <b>post</b> post_voting_forum = <b>global</b>&lt;<a href="voting.md#0x1_voting_VotingForum">voting::VotingForum</a>&lt;GovernanceProposal&gt;&gt;(@aptos_framework);
<b>let</b> <b>post</b> post_next_proposal_id = post_voting_forum.next_proposal_id;
<b>ensures</b> post_next_proposal_id == proposal_id + 1;
<b>aborts_if</b> !<a href="../../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_spec_internal_check_utf8">string::spec_internal_check_utf8</a>(<a href="voting.md#0x1_voting_IS_MULTI_STEP_PROPOSAL_KEY">voting::IS_MULTI_STEP_PROPOSAL_KEY</a>);
<b>aborts_if</b> !<a href="../../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_spec_internal_check_utf8">string::spec_internal_check_utf8</a>(<a href="voting.md#0x1_voting_IS_MULTI_STEP_PROPOSAL_IN_EXECUTION_KEY">voting::IS_MULTI_STEP_PROPOSAL_IN_EXECUTION_KEY</a>);
<b>aborts_if</b> <a href="../../aptos-stdlib/doc/table.md#0x1_table_spec_contains">table::spec_contains</a>(voting_forum.proposals,proposal_id);
<b>ensures</b> <a href="../../aptos-stdlib/doc/table.md#0x1_table_spec_contains">table::spec_contains</a>(post_voting_forum.proposals, proposal_id);
<b>aborts_if</b> !<b>exists</b>&lt;<a href="aptos_governance.md#0x1_aptos_governance_GovernanceEvents">GovernanceEvents</a>&gt;(@aptos_framework);
}
</code></pre>




<a name="0x1_aptos_governance_VotingGetDelegatedVoterAbortsIf"></a>


<pre><code><b>schema</b> <a href="aptos_governance.md#0x1_aptos_governance_VotingGetDelegatedVoterAbortsIf">VotingGetDelegatedVoterAbortsIf</a> {
stake_pool: <b>address</b>;
sign: <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>;
<b>let</b> addr = <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(sign);
<b>let</b> stake_pool_res = <b>global</b>&lt;<a href="stake.md#0x1_stake_StakePool">stake::StakePool</a>&gt;(stake_pool);
<b>aborts_if</b> !<b>exists</b>&lt;<a href="stake.md#0x1_stake_StakePool">stake::StakePool</a>&gt;(stake_pool);
<b>aborts_if</b> stake_pool_res.delegated_voter != addr;
}
</code></pre>



<a name="@Specification_1_vote"></a>

Expand Down Expand Up @@ -2494,7 +2567,8 @@ Signer address must be @aptos_framework.
Address @aptos_framework must exist GovernanceConfig and GovernanceEvents.


<pre><code><b>let</b> addr = <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(aptos_framework);
<pre><code><b>pragma</b> verify = <b>false</b>;
<b>let</b> addr = <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(aptos_framework);
<b>aborts_if</b> addr != @aptos_framework;
<b>include</b> <a href="transaction_fee.md#0x1_transaction_fee_RequiresCollectedFeesPerValueLeqBlockAptosSupply">transaction_fee::RequiresCollectedFeesPerValueLeqBlockAptosSupply</a>;
<b>requires</b> <a href="chain_status.md#0x1_chain_status_is_operating">chain_status::is_operating</a>();
Expand Down
Loading
Loading