Skip to content

Commit

Permalink
Concurrent FungibleAsset balance (#11183)
Browse files Browse the repository at this point in the history
https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-70.md

* concurrent fungible balance

* removing auto-upgrade checks. adding a test

* fixing unit test
  • Loading branch information
igor-aptos authored May 29, 2024
1 parent 1c7d250 commit 6ba90fc
Show file tree
Hide file tree
Showing 9 changed files with 614 additions and 74 deletions.
10 changes: 10 additions & 0 deletions aptos-move/aptos-release-builder/src/components/feature_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ pub enum FeatureFlag {
NewAccountsDefaultToFaAptStore,
OperationsDefaultToFaAptStore,
AggregatorV2IsAtLeastApi,
ConcurrentFungibleBalance,
DefaultToConcurrentFungibleBalance,
}

fn generate_features_blob(writer: &CodeWriter, data: &[u64]) {
Expand Down Expand Up @@ -304,6 +306,10 @@ impl From<FeatureFlag> for AptosFeatureFlag {
FeatureFlag::AggregatorV2IsAtLeastApi => {
AptosFeatureFlag::AGGREGATOR_V2_IS_AT_LEAST_API
},
FeatureFlag::ConcurrentFungibleBalance => AptosFeatureFlag::CONCURRENT_FUNGIBLE_BALANCE,
FeatureFlag::DefaultToConcurrentFungibleBalance => {
AptosFeatureFlag::DEFAULT_TO_CONCURRENT_FUNGIBLE_BALANCE
},
}
}
}
Expand Down Expand Up @@ -420,6 +426,10 @@ impl From<AptosFeatureFlag> for FeatureFlag {
AptosFeatureFlag::AGGREGATOR_V2_IS_AT_LEAST_API => {
FeatureFlag::AggregatorV2IsAtLeastApi
},
AptosFeatureFlag::CONCURRENT_FUNGIBLE_BALANCE => FeatureFlag::ConcurrentFungibleBalance,
AptosFeatureFlag::DEFAULT_TO_CONCURRENT_FUNGIBLE_BALANCE => {
FeatureFlag::DefaultToConcurrentFungibleBalance
},
}
}
}
Expand Down
304 changes: 276 additions & 28 deletions aptos-move/framework/aptos-framework/doc/fungible_asset.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion aptos-move/framework/aptos-framework/doc/stake.md
Original file line number Diff line number Diff line change
Expand Up @@ -4911,7 +4911,8 @@ Returns validator's next epoch voting power, including pending_active, active, a



<pre><code><b>include</b> <a href="stake.md#0x1_stake_ResourceRequirement">ResourceRequirement</a>;
<pre><code><b>pragma</b> verify_duration_estimate = 120;
<b>include</b> <a href="stake.md#0x1_stake_ResourceRequirement">ResourceRequirement</a>;
<b>let</b> addr = <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(owner);
<b>ensures</b> <b>global</b>&lt;<a href="stake.md#0x1_stake_ValidatorConfig">ValidatorConfig</a>&gt;(addr) == <a href="stake.md#0x1_stake_ValidatorConfig">ValidatorConfig</a> {
consensus_pubkey: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector_empty">vector::empty</a>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module aptos_framework::create_signer {
friend aptos_framework::account;
friend aptos_framework::aptos_account;
friend aptos_framework::coin;
friend aptos_framework::fungible_asset;
friend aptos_framework::genesis;
friend aptos_framework::multisig_account;
friend aptos_framework::object;
Expand Down
224 changes: 179 additions & 45 deletions aptos-move/framework/aptos-framework/sources/fungible_asset.move

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions aptos-move/framework/aptos-framework/sources/stake.spec.move
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,9 @@ spec aptos_framework::stake {
operator: address,
voter: address,
) {
// TODO: These function failed in github CI
pragma verify_duration_estimate = 120;

include ResourceRequirement;
let addr = signer::address_of(owner);
ensures global<ValidatorConfig>(addr) == ValidatorConfig {
Expand Down
119 changes: 119 additions & 0 deletions aptos-move/framework/move-stdlib/doc/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ return true.
- [Function `new_accounts_default_to_fa_apt_store_enabled`](#0x1_features_new_accounts_default_to_fa_apt_store_enabled)
- [Function `get_operations_default_to_fa_apt_store_feature`](#0x1_features_get_operations_default_to_fa_apt_store_feature)
- [Function `operations_default_to_fa_apt_store_enabled`](#0x1_features_operations_default_to_fa_apt_store_enabled)
- [Function `get_concurrent_fungible_balance_feature`](#0x1_features_get_concurrent_fungible_balance_feature)
- [Function `concurrent_fungible_balance_enabled`](#0x1_features_concurrent_fungible_balance_enabled)
- [Function `get_default_to_concurrent_fungible_balance_feature`](#0x1_features_get_default_to_concurrent_fungible_balance_feature)
- [Function `default_to_concurrent_fungible_balance_enabled`](#0x1_features_default_to_concurrent_fungible_balance_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 @@ -390,6 +394,18 @@ Lifetime: transient



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

Whether enable concurent Fungible Balance
to create higher throughput concurrent variants.
Lifetime: transient


<pre><code><b>const</b> <a href="features.md#0x1_features_CONCURRENT_FUNGIBLE_BALANCE">CONCURRENT_FUNGIBLE_BALANCE</a>: u64 = 67;
</code></pre>



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

Whether enable TokenV2 collection creation and Fungible Asset creation
Expand All @@ -414,6 +430,17 @@ Lifetime: transient



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

Whether to default new Fungible Store to the concurrent variant.
Lifetime: transient


<pre><code><b>const</b> <a href="features.md#0x1_features_DEFAULT_TO_CONCURRENT_FUNGIBLE_BALANCE">DEFAULT_TO_CONCURRENT_FUNGIBLE_BALANCE</a>: u64 = 68;
</code></pre>



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

Whether delegation pools are enabled.
Expand Down Expand Up @@ -2993,6 +3020,98 @@ Lifetime: transient



</details>

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

## Function `get_concurrent_fungible_balance_feature`



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



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_get_concurrent_fungible_balance_feature">get_concurrent_fungible_balance_feature</a>(): u64 { <a href="features.md#0x1_features_CONCURRENT_FUNGIBLE_BALANCE">CONCURRENT_FUNGIBLE_BALANCE</a> }
</code></pre>



</details>

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

## Function `concurrent_fungible_balance_enabled`



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



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_concurrent_fungible_balance_enabled">concurrent_fungible_balance_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_CONCURRENT_FUNGIBLE_BALANCE">CONCURRENT_FUNGIBLE_BALANCE</a>)
}
</code></pre>



</details>

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

## Function `get_default_to_concurrent_fungible_balance_feature`



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



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_get_default_to_concurrent_fungible_balance_feature">get_default_to_concurrent_fungible_balance_feature</a>(): u64 { <a href="features.md#0x1_features_DEFAULT_TO_CONCURRENT_FUNGIBLE_BALANCE">DEFAULT_TO_CONCURRENT_FUNGIBLE_BALANCE</a> }
</code></pre>



</details>

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

## Function `default_to_concurrent_fungible_balance_enabled`



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



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_default_to_concurrent_fungible_balance_enabled">default_to_concurrent_fungible_balance_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_DEFAULT_TO_CONCURRENT_FUNGIBLE_BALANCE">DEFAULT_TO_CONCURRENT_FUNGIBLE_BALANCE</a>)
}
</code></pre>



</details>

<a id="0x1_features_change_feature_flags"></a>
Expand Down
21 changes: 21 additions & 0 deletions aptos-move/framework/move-stdlib/sources/configs/features.move
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,27 @@ module std::features {
is_enabled(OPERATIONS_DEFAULT_TO_FA_APT_STORE)
}

/// Whether enable concurent Fungible Balance
/// to create higher throughput concurrent variants.
/// Lifetime: transient
const CONCURRENT_FUNGIBLE_BALANCE: u64 = 67;

public fun get_concurrent_fungible_balance_feature(): u64 { CONCURRENT_FUNGIBLE_BALANCE }

public fun concurrent_fungible_balance_enabled(): bool acquires Features {
is_enabled(CONCURRENT_FUNGIBLE_BALANCE)
}

/// Whether to default new Fungible Store to the concurrent variant.
/// Lifetime: transient
const DEFAULT_TO_CONCURRENT_FUNGIBLE_BALANCE: u64 = 68;

public fun get_default_to_concurrent_fungible_balance_feature(): u64 { DEFAULT_TO_CONCURRENT_FUNGIBLE_BALANCE }

public fun default_to_concurrent_fungible_balance_enabled(): bool acquires Features {
is_enabled(DEFAULT_TO_CONCURRENT_FUNGIBLE_BALANCE)
}

// ============================================================================================
// Feature Flag Implementation

Expand Down
3 changes: 3 additions & 0 deletions types/src/on_chain_config/aptos_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ pub enum FeatureFlag {
NEW_ACCOUNTS_DEFAULT_TO_FA_APT_STORE = 64,
OPERATIONS_DEFAULT_TO_FA_APT_STORE = 65,
AGGREGATOR_V2_IS_AT_LEAST_API = 66,
CONCURRENT_FUNGIBLE_BALANCE = 67,
DEFAULT_TO_CONCURRENT_FUNGIBLE_BALANCE = 68,
}

impl FeatureFlag {
Expand Down Expand Up @@ -146,6 +148,7 @@ impl FeatureFlag {
FeatureFlag::REMOVE_DETAILED_ERROR_FROM_HASH,
FeatureFlag::CONCURRENT_FUNGIBLE_ASSETS,
FeatureFlag::AGGREGATOR_V2_IS_AT_LEAST_API,
FeatureFlag::CONCURRENT_FUNGIBLE_BALANCE,
]
}
}
Expand Down

0 comments on commit 6ba90fc

Please sign in to comment.