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

Cherry pick certain optimization PRs #15612

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,45 @@ struct OuterStruct has key {
}

entry public test_upgrade(Arg0: &signer) /* def_idx: 0 */ {
L1: loc0: OuterStruct
L2: loc1: &mut vector<InnerStruct>
L1: loc0: &mut vector<InnerStruct>
L2: loc1: u64
L3: loc2: u64
L4: loc3: u64
L5: loc4: u64
B0:
0: CopyLoc[0](Arg0: &signer)
1: Call signer::address_of(&signer): address
2: VecPack(3, 0)
3: Pack[1](OuterStruct)
4: StLoc[1](loc0: OuterStruct)
5: MoveLoc[0](Arg0: &signer)
6: MoveLoc[1](loc0: OuterStruct)
7: MoveTo[1](OuterStruct)
8: MutBorrowGlobal[1](OuterStruct)
9: MutBorrowField[0](OuterStruct.any_field: vector<InnerStruct>)
10: StLoc[2](loc1: &mut vector<InnerStruct>)
11: LdU64(0)
12: StLoc[3](loc2: u64)
13: CopyLoc[2](loc1: &mut vector<InnerStruct>)
14: FreezeRef
15: VecLen(3)
16: StLoc[4](loc3: u64)
2: MoveLoc[0](Arg0: &signer)
3: VecPack(3, 0)
4: Pack[1](OuterStruct)
5: MoveTo[1](OuterStruct)
6: MutBorrowGlobal[1](OuterStruct)
7: MutBorrowField[0](OuterStruct.any_field: vector<InnerStruct>)
8: StLoc[1](loc0: &mut vector<InnerStruct>)
9: LdU64(0)
10: StLoc[2](loc1: u64)
11: CopyLoc[1](loc0: &mut vector<InnerStruct>)
12: FreezeRef
13: VecLen(3)
14: StLoc[3](loc2: u64)
B1:
17: CopyLoc[3](loc2: u64)
18: CopyLoc[4](loc3: u64)
19: Lt
20: BrFalse(31)
15: CopyLoc[2](loc1: u64)
16: CopyLoc[3](loc2: u64)
17: Lt
18: BrFalse(29)
B2:
21: CopyLoc[2](loc1: &mut vector<InnerStruct>)
22: CopyLoc[3](loc2: u64)
23: VecMutBorrow(3)
24: FreezeRef
25: Call debug::print<InnerStruct>(&InnerStruct)
26: MoveLoc[3](loc2: u64)
27: LdU64(1)
28: Add
29: StLoc[3](loc2: u64)
30: Branch(17)
19: CopyLoc[1](loc0: &mut vector<InnerStruct>)
20: CopyLoc[2](loc1: u64)
21: VecMutBorrow(3)
22: FreezeRef
23: Call debug::print<InnerStruct>(&InnerStruct)
24: MoveLoc[2](loc1: u64)
25: LdU64(1)
26: Add
27: StLoc[2](loc1: u64)
28: Branch(15)
B3:
31: MoveLoc[2](loc1: &mut vector<InnerStruct>)
32: Pop
33: Ret
29: MoveLoc[1](loc0: &mut vector<InnerStruct>)
30: Pop
31: Ret
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ This function is private because it's called directly from the vm.
<a href="system_addresses.md#0x1_system_addresses_assert_aptos_framework">system_addresses::assert_aptos_framework</a>(aptos_framework);

<a href="voting.md#0x1_voting_register">voting::register</a>&lt;GovernanceProposal&gt;(aptos_framework);
<a href="aptos_governance.md#0x1_aptos_governance_initialize_partial_voting">initialize_partial_voting</a>(aptos_framework);
<b>move_to</b>(aptos_framework, <a href="aptos_governance.md#0x1_aptos_governance_GovernanceConfig">GovernanceConfig</a> {
voting_duration_secs,
min_voting_threshold,
Expand Down Expand Up @@ -2132,6 +2133,7 @@ Limit addition overflow.
<b>ensures</b> <b>exists</b>&lt;<a href="aptos_governance.md#0x1_aptos_governance_GovernanceEvents">GovernanceEvents</a>&gt;(addr);
<b>ensures</b> <b>exists</b>&lt;<a href="aptos_governance.md#0x1_aptos_governance_VotingRecords">VotingRecords</a>&gt;(addr);
<b>ensures</b> <b>exists</b>&lt;<a href="aptos_governance.md#0x1_aptos_governance_ApprovedExecutionHashes">ApprovedExecutionHashes</a>&gt;(addr);
<b>ensures</b> <b>exists</b>&lt;<a href="aptos_governance.md#0x1_aptos_governance_VotingRecordsV2">VotingRecordsV2</a>&gt;(addr);
</code></pre>


Expand Down Expand Up @@ -2204,6 +2206,7 @@ Abort if structs have already been created.
<b>aborts_if</b> <b>exists</b>&lt;<a href="aptos_governance.md#0x1_aptos_governance_VotingRecords">VotingRecords</a>&gt;(addr);
<b>aborts_if</b> <b>exists</b>&lt;<a href="aptos_governance.md#0x1_aptos_governance_ApprovedExecutionHashes">ApprovedExecutionHashes</a>&gt;(addr);
<b>aborts_if</b> !<b>exists</b>&lt;<a href="account.md#0x1_account_Account">account::Account</a>&gt;(addr);
<b>aborts_if</b> <b>exists</b>&lt;<a href="aptos_governance.md#0x1_aptos_governance_VotingRecordsV2">VotingRecordsV2</a>&gt;(addr);
}
</code></pre>

Expand Down
166 changes: 93 additions & 73 deletions aptos-move/framework/aptos-framework/tests/compiler-v2-doc/coin.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ Genesis step 1: Initialize aptos framework account and core modules on chain.
<a href="execution_config.md#0x1_execution_config_set">execution_config::set</a>(&aptos_framework_account, <a href="execution_config.md#0x1_execution_config">execution_config</a>);
<a href="version.md#0x1_version_initialize">version::initialize</a>(&aptos_framework_account, initial_version);
<a href="stake.md#0x1_stake_initialize">stake::initialize</a>(&aptos_framework_account);
<a href="timestamp.md#0x1_timestamp_set_time_has_started">timestamp::set_time_has_started</a>(&aptos_framework_account);
<a href="staking_config.md#0x1_staking_config_initialize">staking_config::initialize</a>(
&aptos_framework_account,
minimum_stake,
Expand All @@ -360,7 +361,6 @@ Genesis step 1: Initialize aptos framework account and core modules on chain.
<a href="reconfiguration.md#0x1_reconfiguration_initialize">reconfiguration::initialize</a>(&aptos_framework_account);
<a href="block.md#0x1_block_initialize">block::initialize</a>(&aptos_framework_account, epoch_interval_microsecs);
<a href="state_storage.md#0x1_state_storage_initialize">state_storage::initialize</a>(&aptos_framework_account);
<a href="timestamp.md#0x1_timestamp_set_time_has_started">timestamp::set_time_has_started</a>(&aptos_framework_account);
}
</code></pre>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,17 @@ Only called during genesis.
rewards_rate_denominator,
voting_power_increase_limit,
});

// Initialize <a href="staking_config.md#0x1_staking_config_StakingRewardsConfig">StakingRewardsConfig</a> <b>with</b> the given rewards_rate and rewards_rate_denominator,
// <b>while</b> setting min_rewards_rate and rewards_rate_decrease_rate <b>to</b> 0.
<a href="staking_config.md#0x1_staking_config_initialize_rewards">initialize_rewards</a>(
aptos_framework,
<a href="../../../aptos-stdlib/tests/compiler-v2-doc/fixed_point64.md#0x1_fixed_point64_create_from_rational">fixed_point64::create_from_rational</a>((rewards_rate <b>as</b> u128), (rewards_rate_denominator <b>as</b> u128)),
<a href="../../../aptos-stdlib/tests/compiler-v2-doc/fixed_point64.md#0x1_fixed_point64_create_from_rational">fixed_point64::create_from_rational</a>(0, 1000),
<a href="staking_config.md#0x1_staking_config_ONE_YEAR_IN_SECS">ONE_YEAR_IN_SECS</a>,
0,
<a href="../../../aptos-stdlib/tests/compiler-v2-doc/fixed_point64.md#0x1_fixed_point64_create_from_rational">fixed_point64::create_from_rational</a>(0, 1000),
);
}
</code></pre>

Expand Down Expand Up @@ -1072,6 +1083,7 @@ Can only be called as part of the Aptos governance proposal process established


<pre><code><b>invariant</b> [suspendable] <a href="chain_status.md#0x1_chain_status_is_operating">chain_status::is_operating</a>() ==&gt; <b>exists</b>&lt;<a href="staking_config.md#0x1_staking_config_StakingConfig">StakingConfig</a>&gt;(@aptos_framework);
<b>invariant</b> [suspendable] <a href="chain_status.md#0x1_chain_status_is_operating">chain_status::is_operating</a>() ==&gt; <b>exists</b>&lt;<a href="staking_config.md#0x1_staking_config_StakingRewardsConfig">StakingRewardsConfig</a>&gt;(@aptos_framework);
<b>pragma</b> verify = <b>true</b>;
<b>pragma</b> aborts_if_is_strict;
</code></pre>
Expand Down Expand Up @@ -1223,6 +1235,7 @@ StakingConfig does not exist under the aptos_framework before creating it.


<pre><code><b>let</b> addr = <a href="../../../aptos-stdlib/../move-stdlib/tests/compiler-v2-doc/signer.md#0x1_signer_address_of">signer::address_of</a>(aptos_framework);
<b>requires</b> <b>exists</b>&lt;<a href="timestamp.md#0x1_timestamp_CurrentTimeMicroseconds">timestamp::CurrentTimeMicroseconds</a>&gt;(@aptos_framework);
// This enforces <a id="high-level-req-1.1" href="#high-level-req">high-level requirement 1</a>:
<b>aborts_if</b> addr != @aptos_framework;
<b>aborts_if</b> minimum_stake &gt; maximum_stake || maximum_stake == 0;
Expand All @@ -1234,7 +1247,9 @@ StakingConfig does not exist under the aptos_framework before creating it.
<b>aborts_if</b> rewards_rate &gt; <a href="staking_config.md#0x1_staking_config_MAX_REWARDS_RATE">MAX_REWARDS_RATE</a>;
<b>aborts_if</b> rewards_rate &gt; rewards_rate_denominator;
<b>aborts_if</b> <b>exists</b>&lt;<a href="staking_config.md#0x1_staking_config_StakingConfig">StakingConfig</a>&gt;(addr);
<b>aborts_if</b> <b>exists</b>&lt;<a href="staking_config.md#0x1_staking_config_StakingRewardsConfig">StakingRewardsConfig</a>&gt;(addr);
<b>ensures</b> <b>exists</b>&lt;<a href="staking_config.md#0x1_staking_config_StakingConfig">StakingConfig</a>&gt;(addr);
<b>ensures</b> <b>exists</b>&lt;<a href="staking_config.md#0x1_staking_config_StakingRewardsConfig">StakingRewardsConfig</a>&gt;(addr);
</code></pre>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ return true.
- [Function `transaction_simulation_enhancement_enabled`](#0x1_features_transaction_simulation_enhancement_enabled)
- [Function `get_collection_owner_feature`](#0x1_features_get_collection_owner_feature)
- [Function `is_collection_owner_enabled`](#0x1_features_is_collection_owner_enabled)
- [Function `get_native_memory_operations_feature`](#0x1_features_get_native_memory_operations_feature)
- [Function `is_native_memory_operations_enabled`](#0x1_features_is_native_memory_operations_enabled)
- [Function `change_feature_flags`](#0x1_features_change_feature_flags)
- [Function `change_feature_flags_internal`](#0x1_features_change_feature_flags_internal)
- [Function `change_feature_flags_for_next_epoch`](#0x1_features_change_feature_flags_for_next_epoch)
Expand Down Expand Up @@ -670,6 +672,15 @@ Lifetime: transient



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



<pre><code><b>const</b> <a href="features.md#0x1_features_NATIVE_MEMORY_OPERATIONS">NATIVE_MEMORY_OPERATIONS</a>: u64 = 80;
</code></pre>



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

Lifetime: transient
Expand Down Expand Up @@ -3273,6 +3284,52 @@ Deprecated feature



</details>

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

## Function `get_native_memory_operations_feature`



<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_get_native_memory_operations_feature">get_native_memory_operations_feature</a>(): u64
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_get_native_memory_operations_feature">get_native_memory_operations_feature</a>(): u64 { <a href="features.md#0x1_features_NATIVE_MEMORY_OPERATIONS">NATIVE_MEMORY_OPERATIONS</a> }
</code></pre>



</details>

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

## Function `is_native_memory_operations_enabled`



<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_is_native_memory_operations_enabled">is_native_memory_operations_enabled</a>(): bool
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_is_native_memory_operations_enabled">is_native_memory_operations_enabled</a>(): bool <b>acquires</b> <a href="features.md#0x1_features_Features">Features</a> {
<a href="features.md#0x1_features_is_enabled">is_enabled</a>(<a href="features.md#0x1_features_NATIVE_MEMORY_OPERATIONS">NATIVE_MEMORY_OPERATIONS</a>)
}
</code></pre>



</details>

<a id="0x1_features_change_feature_flags"></a>
Expand Down Expand Up @@ -3697,6 +3754,17 @@ Helper to check whether a feature flag is enabled.



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


<pre><code><b>fun</b> <a href="features.md#0x1_features_spec_new_accounts_default_to_fa_apt_store_enabled">spec_new_accounts_default_to_fa_apt_store_enabled</a>(): bool {
<a href="features.md#0x1_features_spec_is_enabled">spec_is_enabled</a>(<a href="features.md#0x1_features_NEW_ACCOUNTS_DEFAULT_TO_FA_APT_STORE">NEW_ACCOUNTS_DEFAULT_TO_FA_APT_STORE</a>)
}
</code></pre>




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


Expand Down
Loading
Loading