Skip to content

Commit

Permalink
[Spec] Updated the spec of the Genesis module
Browse files Browse the repository at this point in the history
This commits update the `verify_only` genesis steps to reflect the `encode_aptos_mainnet_genesis_transaction` of `vm-genesis`.

The spec of `create_signer` is added.

One TODO is removed because the `Table` issue has been fixed.
  • Loading branch information
junkil-park committed Dec 5, 2022
1 parent 3973311 commit a68d6a5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
23 changes: 15 additions & 8 deletions aptos-move/framework/aptos-framework/doc/genesis.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<b>use</b> <a href="coin.md#0x1_coin">0x1::coin</a>;
<b>use</b> <a href="consensus_config.md#0x1_consensus_config">0x1::consensus_config</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error">0x1::error</a>;
<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="reconfiguration.md#0x1_reconfiguration">0x1::reconfiguration</a>;
Expand Down Expand Up @@ -850,7 +851,7 @@ The last step of genesis.



<pre><code><b>fun</b> <a href="genesis.md#0x1_genesis_initialize_for_verification">initialize_for_verification</a>(<a href="gas_schedule.md#0x1_gas_schedule">gas_schedule</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;, <a href="chain_id.md#0x1_chain_id">chain_id</a>: u8, initial_version: u64, <a href="consensus_config.md#0x1_consensus_config">consensus_config</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;, epoch_interval_microsecs: u64, minimum_stake: u64, maximum_stake: u64, recurring_lockup_duration_secs: u64, allow_validator_set_change: bool, rewards_rate: u64, rewards_rate_denominator: u64, voting_power_increase_limit: u64, aptos_framework: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, validators: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;<a href="genesis.md#0x1_genesis_ValidatorConfiguration">genesis::ValidatorConfiguration</a>&gt;, min_voting_threshold: u128, required_proposer_stake: u64, voting_duration_secs: u64)
<pre><code><b>fun</b> <a href="genesis.md#0x1_genesis_initialize_for_verification">initialize_for_verification</a>(<a href="gas_schedule.md#0x1_gas_schedule">gas_schedule</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;, <a href="chain_id.md#0x1_chain_id">chain_id</a>: u8, initial_version: u64, <a href="consensus_config.md#0x1_consensus_config">consensus_config</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;, epoch_interval_microsecs: u64, minimum_stake: u64, maximum_stake: u64, recurring_lockup_duration_secs: u64, allow_validator_set_change: bool, rewards_rate: u64, rewards_rate_denominator: u64, voting_power_increase_limit: u64, aptos_framework: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, min_voting_threshold: u128, required_proposer_stake: u64, voting_duration_secs: u64, accounts: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;<a href="genesis.md#0x1_genesis_AccountMap">genesis::AccountMap</a>&gt;, employee_vesting_start: u64, employee_vesting_period_duration: u64, employees: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;<a href="genesis.md#0x1_genesis_EmployeeAccountMap">genesis::EmployeeAccountMap</a>&gt;, validators: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;<a href="genesis.md#0x1_genesis_ValidatorConfigurationWithCommission">genesis::ValidatorConfigurationWithCommission</a>&gt;)
</code></pre>


Expand All @@ -873,10 +874,14 @@ The last step of genesis.
rewards_rate_denominator: u64,
voting_power_increase_limit: u64,
aptos_framework: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>,
validators: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;<a href="genesis.md#0x1_genesis_ValidatorConfiguration">ValidatorConfiguration</a>&gt;,
min_voting_threshold: u128,
required_proposer_stake: u64,
voting_duration_secs: u64,
accounts: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;<a href="genesis.md#0x1_genesis_AccountMap">AccountMap</a>&gt;,
employee_vesting_start: u64,
employee_vesting_period_duration: u64,
employees: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;<a href="genesis.md#0x1_genesis_EmployeeAccountMap">EmployeeAccountMap</a>&gt;,
validators: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;<a href="genesis.md#0x1_genesis_ValidatorConfigurationWithCommission">ValidatorConfigurationWithCommission</a>&gt;
) {
<a href="genesis.md#0x1_genesis_initialize">initialize</a>(
<a href="gas_schedule.md#0x1_gas_schedule">gas_schedule</a>,
Expand All @@ -892,17 +897,17 @@ The last step of genesis.
rewards_rate_denominator,
voting_power_increase_limit
);

<a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features_change_feature_flags">features::change_feature_flags</a>(aptos_framework, <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>[1, 2], <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>[]);
<a href="genesis.md#0x1_genesis_initialize_aptos_coin">initialize_aptos_coin</a>(aptos_framework);

<a href="aptos_governance.md#0x1_aptos_governance_initialize_for_verification">aptos_governance::initialize_for_verification</a>(
aptos_framework,
min_voting_threshold,
required_proposer_stake,
voting_duration_secs
);

<a href="genesis.md#0x1_genesis_create_initialize_validators">create_initialize_validators</a>(aptos_framework, validators);
<a href="genesis.md#0x1_genesis_create_accounts">create_accounts</a>(aptos_framework, accounts);
<a href="genesis.md#0x1_genesis_create_employee_validators">create_employee_validators</a>(employee_vesting_start, employee_vesting_period_duration, employees);
<a href="genesis.md#0x1_genesis_create_initialize_validators_with_commission">create_initialize_validators_with_commission</a>(aptos_framework, <b>true</b>, validators);
<a href="genesis.md#0x1_genesis_set_genesis_end">set_genesis_end</a>(aptos_framework);
}
</code></pre>
Expand Down Expand Up @@ -934,6 +939,8 @@ The last step of genesis.


<pre><code><b>pragma</b> opaque;
<b>aborts_if</b> <b>false</b>;
<b>ensures</b> <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(result) == addr;
</code></pre>


Expand All @@ -943,13 +950,13 @@ The last step of genesis.
### Function `initialize_for_verification`


<pre><code><b>fun</b> <a href="genesis.md#0x1_genesis_initialize_for_verification">initialize_for_verification</a>(<a href="gas_schedule.md#0x1_gas_schedule">gas_schedule</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;, <a href="chain_id.md#0x1_chain_id">chain_id</a>: u8, initial_version: u64, <a href="consensus_config.md#0x1_consensus_config">consensus_config</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;, epoch_interval_microsecs: u64, minimum_stake: u64, maximum_stake: u64, recurring_lockup_duration_secs: u64, allow_validator_set_change: bool, rewards_rate: u64, rewards_rate_denominator: u64, voting_power_increase_limit: u64, aptos_framework: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, validators: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;<a href="genesis.md#0x1_genesis_ValidatorConfiguration">genesis::ValidatorConfiguration</a>&gt;, min_voting_threshold: u128, required_proposer_stake: u64, voting_duration_secs: u64)
<pre><code><b>fun</b> <a href="genesis.md#0x1_genesis_initialize_for_verification">initialize_for_verification</a>(<a href="gas_schedule.md#0x1_gas_schedule">gas_schedule</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;, <a href="chain_id.md#0x1_chain_id">chain_id</a>: u8, initial_version: u64, <a href="consensus_config.md#0x1_consensus_config">consensus_config</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;, epoch_interval_microsecs: u64, minimum_stake: u64, maximum_stake: u64, recurring_lockup_duration_secs: u64, allow_validator_set_change: bool, rewards_rate: u64, rewards_rate_denominator: u64, voting_power_increase_limit: u64, aptos_framework: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, min_voting_threshold: u128, required_proposer_stake: u64, voting_duration_secs: u64, accounts: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;<a href="genesis.md#0x1_genesis_AccountMap">genesis::AccountMap</a>&gt;, employee_vesting_start: u64, employee_vesting_period_duration: u64, employees: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;<a href="genesis.md#0x1_genesis_EmployeeAccountMap">genesis::EmployeeAccountMap</a>&gt;, validators: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;<a href="genesis.md#0x1_genesis_ValidatorConfigurationWithCommission">genesis::ValidatorConfigurationWithCommission</a>&gt;)
</code></pre>




<pre><code><b>pragma</b> verify = <b>false</b>;
<pre><code><b>pragma</b> verify = <b>true</b>;
</code></pre>


Expand Down
17 changes: 12 additions & 5 deletions aptos-move/framework/aptos-framework/sources/genesis.move
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ module aptos_framework::genesis {

native fun create_signer(addr: address): signer;

#[verify_only]
use std::features;

#[verify_only]
fun initialize_for_verification(
gas_schedule: vector<u8>,
Expand All @@ -407,10 +410,14 @@ module aptos_framework::genesis {
rewards_rate_denominator: u64,
voting_power_increase_limit: u64,
aptos_framework: &signer,
validators: vector<ValidatorConfiguration>,
min_voting_threshold: u128,
required_proposer_stake: u64,
voting_duration_secs: u64,
accounts: vector<AccountMap>,
employee_vesting_start: u64,
employee_vesting_period_duration: u64,
employees: vector<EmployeeAccountMap>,
validators: vector<ValidatorConfigurationWithCommission>
) {
initialize(
gas_schedule,
Expand All @@ -426,17 +433,17 @@ module aptos_framework::genesis {
rewards_rate_denominator,
voting_power_increase_limit
);

features::change_feature_flags(aptos_framework, vector[1, 2], vector[]);
initialize_aptos_coin(aptos_framework);

aptos_governance::initialize_for_verification(
aptos_framework,
min_voting_threshold,
required_proposer_stake,
voting_duration_secs
);

create_initialize_validators(aptos_framework, validators);
create_accounts(aptos_framework, accounts);
create_employee_validators(employee_vesting_start, employee_vesting_period_duration, employees);
create_initialize_validators_with_commission(aptos_framework, true, validators);
set_genesis_end(aptos_framework);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ spec aptos_framework::genesis {
}

spec initialize_for_verification {
// TODO: disabled due to the issue of Table.
pragma verify = false;
pragma verify = true;
}

spec create_signer {
// TODO: temporary mockup.
spec create_signer(addr: address): signer {
use std::signer;
pragma opaque;
aborts_if false;
ensures signer::address_of(result) == addr;
}
}
2 changes: 1 addition & 1 deletion aptos-move/framework/aptos-token/doc/token.md
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ The field is not mutable
Withdraw capability doesn't have sufficient amount


<pre><code><b>const</b> <a href="token.md#0x3_token_EINSUFFICIENT_WITHDRAW_CAPABILITY_AMOUNT">EINSUFFICIENT_WITHDRAW_CAPABILITY_AMOUNT</a>: u64 = 37;
<pre><code><b>const</b> <a href="token.md#0x3_token_EINSUFFICIENT_WITHDRAW_CAPABILITY_AMOUNT">EINSUFFICIENT_WITHDRAW_CAPABILITY_AMOUNT</a>: u64 = 38;
</code></pre>


Expand Down

0 comments on commit a68d6a5

Please sign in to comment.