Skip to content

Commit

Permalink
Merge branch 'main' into vk/wildcard-preserve
Browse files Browse the repository at this point in the history
  • Loading branch information
vineethk authored Apr 12, 2024
2 parents a414bf4 + 7647a94 commit 7ec123f
Show file tree
Hide file tree
Showing 50 changed files with 235 additions and 473 deletions.
10 changes: 5 additions & 5 deletions aptos-move/aptos-release-builder/src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use aptos_temppath::TempPath;
use aptos_types::{
account_config::CORE_CODE_ADDRESS,
on_chain_config::{
ExecutionConfigV1, FeatureFlag as AptosFeatureFlag, GasScheduleV2, OnChainConfig,
OnChainConsensusConfig, OnChainExecutionConfig, OnChainJWKConsensusConfig,
OnChainRandomnessConfig, RandomnessConfigMoveStruct, TransactionShufflerType, Version,
AptosVersion, ExecutionConfigV1, FeatureFlag as AptosFeatureFlag, GasScheduleV2,
OnChainConfig, OnChainConsensusConfig, OnChainExecutionConfig, OnChainJWKConsensusConfig,
OnChainRandomnessConfig, RandomnessConfigMoveStruct, TransactionShufflerType,
},
};
use futures::executor::block_on;
Expand Down Expand Up @@ -136,7 +136,7 @@ pub enum ReleaseEntry {
DefaultGasWithOverride(GasOverrideConfig),
/// Only used before randomness framework upgrade.
DefaultGasWithOverrideOld(GasOverrideConfig),
Version(Version),
Version(AptosVersion),
FeatureFlag(Features),
Consensus(OnChainConsensusConfig),
Execution(OnChainExecutionConfig),
Expand Down Expand Up @@ -254,7 +254,7 @@ impl ReleaseEntry {
}
},
ReleaseEntry::Version(version) => {
if !fetch_and_equals::<Version>(client, version)? {
if !fetch_and_equals::<AptosVersion>(client, version)? {
result.append(&mut version::generate_version_upgrade_proposal(
version,
is_testnet,
Expand Down
4 changes: 2 additions & 2 deletions aptos-move/aptos-release-builder/src/components/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

use crate::{components::get_signer_arg, utils::*};
use anyhow::Result;
use aptos_types::on_chain_config::Version;
use aptos_types::on_chain_config::AptosVersion;
use move_model::{code_writer::CodeWriter, emitln, model::Loc};

pub fn generate_version_upgrade_proposal(
version: &Version,
version: &AptosVersion,
is_testnet: bool,
next_execution_hash: Vec<u8>,
) -> Result<Vec<(String, String)>> {
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-release-builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ async fn main() -> anyhow::Result<()> {
}
}

print_configs!(OnChainConsensusConfig, OnChainExecutionConfig, Version);
print_configs!(OnChainConsensusConfig, OnChainExecutionConfig, AptosVersion);

if print_gas_schedule {
print_configs!(GasScheduleV2, StorageGasSchedule);
Expand Down
4 changes: 2 additions & 2 deletions aptos-move/aptos-vm-types/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::storage::{
};
use aptos_gas_schedule::{AptosGasParameters, InitialGasSchedule, LATEST_GAS_FEATURE_VERSION};
use aptos_types::{
access_path::AccessPath,
on_chain_config::{ConfigStorage, Features},
state_store::state_key::StateKey,
};
use bytes::Bytes;
use std::fmt::Debug;
Expand Down Expand Up @@ -79,7 +79,7 @@ impl StorageGasParameters {
struct DummyConfigStorage;

impl ConfigStorage for DummyConfigStorage {
fn fetch_config(&self, _access_path: AccessPath) -> Option<Bytes> {
fn fetch_config_bytes(&self, _state_key: &StateKey) -> Option<Bytes> {
unreachable!("Not supposed to be called from latest() / tests.")
}
}
4 changes: 2 additions & 2 deletions aptos-move/aptos-vm/src/data_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ impl<'e, E: ExecutorView> TDelayedFieldView for StorageAdapter<'e, E> {
}

impl<'e, E: ExecutorView> ConfigStorage for StorageAdapter<'e, E> {
fn fetch_config(&self, access_path: AccessPath) -> Option<Bytes> {
fn fetch_config_bytes(&self, state_key: &StateKey) -> Option<Bytes> {
self.executor_view
.get_resource_bytes(&StateKey::access_path(access_path), None)
.get_resource_bytes(state_key, None)
.ok()?
}
}
Expand Down
7 changes: 5 additions & 2 deletions aptos-move/aptos-vm/src/move_vm_ext/warm_vm_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ use aptos_framework::natives::code::PackageRegistry;
use aptos_infallible::RwLock;
use aptos_metrics_core::TimerHelper;
use aptos_native_interface::SafeNativeBuilder;
use aptos_types::on_chain_config::{FeatureFlag, Features, OnChainConfig};
use aptos_types::{
on_chain_config::{FeatureFlag, Features, OnChainConfig},
state_store::state_key::StateKey,
};
use bytes::Bytes;
use move_binary_format::errors::{Location, PartialVMError, VMResult};
use move_core_types::{
Expand Down Expand Up @@ -134,7 +137,7 @@ impl WarmVmId {
fn core_packages_id_bytes(resolver: &impl AptosMoveResolver) -> VMResult<Option<Bytes>> {
let bytes = {
let _timer = TIMER.timer_with(&["fetch_pkgreg"]);
resolver.fetch_config(PackageRegistry::access_path().expect("Get AP failed."))
resolver.fetch_config_bytes(&StateKey::on_chain_config::<PackageRegistry>())
};

let core_package_registry = {
Expand Down
8 changes: 4 additions & 4 deletions aptos-move/e2e-tests/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ use aptos_types::{
chain_id::ChainId,
contract_event::ContractEvent,
on_chain_config::{
FeatureFlag, Features, OnChainConfig, TimedFeatureOverride, TimedFeaturesBuilder,
ValidatorSet, Version,
AptosVersion, FeatureFlag, Features, OnChainConfig, TimedFeatureOverride,
TimedFeaturesBuilder, ValidatorSet,
},
state_store::{state_key::StateKey, state_value::StateValue, StateView, TStateView},
transaction::{
Expand Down Expand Up @@ -273,8 +273,8 @@ impl FakeExecutor {
// - the e2e test outputs a golden file, and
// - the environment variable is properly set
if let Some(env_trace_dir) = env::var_os(ENV_TRACE_DIR) {
let aptos_version =
Version::fetch_config(&self.data_store.as_move_resolver()).map_or(0, |v| v.major);
let aptos_version = AptosVersion::fetch_config(&self.data_store.as_move_resolver())
.map_or(0, |v| v.major);

let trace_dir = Path::new(&env_trace_dir).join(file_name);
if trace_dir.exists() {
Expand Down
15 changes: 9 additions & 6 deletions aptos-move/e2e-testsuite/src/tests/on_chain_configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use aptos_cached_packages::aptos_stdlib;
use aptos_language_e2e_tests::{common_transactions::peer_to_peer_txn, executor::FakeExecutor};
use aptos_types::{
account_config::CORE_CODE_ADDRESS,
on_chain_config::{OnChainConfig, Version},
on_chain_config::{AptosVersion, OnChainConfig},
transaction::TransactionStatus,
};
use aptos_vm::data_cache::AsMoveResolver;
Expand All @@ -17,7 +17,7 @@ fn initial_aptos_version() {
let resolver = executor.get_state_view().as_move_resolver();
let version = aptos_types::on_chain_config::APTOS_MAX_KNOWN_VERSION;

assert_eq!(Version::fetch_config(&resolver).unwrap(), version);
assert_eq!(AptosVersion::fetch_config(&resolver).unwrap(), version);
let account = executor.new_account_at(CORE_CODE_ADDRESS);
let txn_0 = account
.transaction()
Expand All @@ -35,17 +35,20 @@ fn initial_aptos_version() {
executor.execute_and_apply(txn_1);

let resolver = executor.get_state_view().as_move_resolver();
assert_eq!(Version::fetch_config(&resolver).unwrap(), Version {
major: version.major + 1
});
assert_eq!(
AptosVersion::fetch_config(&resolver).unwrap(),
AptosVersion {
major: version.major + 1
}
);
}

#[test]
fn drop_txn_after_reconfiguration() {
let mut executor = FakeExecutor::from_head_genesis();
let resolver = executor.get_state_view().as_move_resolver();
let version = aptos_types::on_chain_config::APTOS_MAX_KNOWN_VERSION;
assert_eq!(Version::fetch_config(&resolver).unwrap(), version);
assert_eq!(AptosVersion::fetch_config(&resolver).unwrap(), version);

let txn = executor
.new_account_at(CORE_CODE_ADDRESS)
Expand Down
16 changes: 8 additions & 8 deletions aptos-move/framework/aptos-framework/doc/delegation_pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ Capability that represents ownership over privileged operations on the underlyin

## Struct `VoteDelegation`

Track delgated voter of each delegator.
Track delegated voter of each delegator.


<pre><code><b>struct</b> <a href="delegation_pool.md#0x1_delegation_pool_VoteDelegation">VoteDelegation</a> <b>has</b> <b>copy</b>, drop, store
Expand Down Expand Up @@ -475,7 +475,7 @@ Track delgated voter of each delegator.

## Struct `DelegatedVotes`

Track total voteing power of each voter.
Track total voting power of each voter.


<pre><code><b>struct</b> <a href="delegation_pool.md#0x1_delegation_pool_DelegatedVotes">DelegatedVotes</a> <b>has</b> <b>copy</b>, drop, store
Expand Down Expand Up @@ -1523,7 +1523,7 @@ There is not enough <code>active</code> stake on the stake pool to <code>unlock<

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

Chaning beneficiaries for operators is not supported.
Changing beneficiaries for operators is not supported.


<pre><code><b>const</b> <a href="delegation_pool.md#0x1_delegation_pool_EOPERATOR_BENEFICIARY_CHANGE_NOT_SUPPORTED">EOPERATOR_BENEFICIARY_CHANGE_NOT_SUPPORTED</a>: u64 = 19;
Expand Down Expand Up @@ -1619,7 +1619,7 @@ Maximum operator percentage fee(of double digit precision): 22.85% is represente
Minimum coins to exist on a shares pool at all times.
Enforced per delegator for both active and pending_inactive pools.
This constraint ensures the share price cannot overly increase and lead to
substantial loses when buying shares (can lose at most 1 share which may
substantial losses when buying shares (can lose at most 1 share which may
be worth a lot if current share price is high).
This constraint is not enforced on inactive pools as they only allow redeems
(can lose at most 1 coin regardless of current share price).
Expand Down Expand Up @@ -1744,7 +1744,7 @@ Return whether a delegation pool exists at supplied address <code>addr</code>.

## Function `partial_governance_voting_enabled`

Return whether a delegation pool has already enabled partial govnernance voting.
Return whether a delegation pool has already enabled partial governance voting.


<pre><code>#[view]
Expand Down Expand Up @@ -2459,7 +2459,7 @@ Ownership over setting the operator/voter is granted to <code>owner</code> who h
// save delegation pool ownership and resource <a href="account.md#0x1_account">account</a> <b>address</b> (inner <a href="stake.md#0x1_stake">stake</a> pool <b>address</b>) on `owner`
<b>move_to</b>(owner, <a href="delegation_pool.md#0x1_delegation_pool_DelegationPoolOwnership">DelegationPoolOwnership</a> { pool_address });

// All delegation pool enable partial governace <a href="voting.md#0x1_voting">voting</a> by default once the feature flag is enabled.
// All delegation pool enable partial governance <a href="voting.md#0x1_voting">voting</a> by default once the feature flag is enabled.
<b>if</b> (<a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features_partial_governance_voting_enabled">features::partial_governance_voting_enabled</a>() && <a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features_delegation_pool_partial_governance_voting_enabled">features::delegation_pool_partial_governance_voting_enabled</a>()) {
<a href="delegation_pool.md#0x1_delegation_pool_enable_partial_governance_voting">enable_partial_governance_voting</a>(pool_address);
}
Expand Down Expand Up @@ -2505,7 +2505,7 @@ Return the beneficiary address of the operator.
## Function `enable_partial_governance_voting`

Enable partial governance voting on a stake pool. The voter of this stake pool will be managed by this module.
THe existing voter will be replaced. The function is permissionless.
The existing voter will be replaced. The function is permissionless.


<pre><code><b>public</b> entry <b>fun</b> <a href="delegation_pool.md#0x1_delegation_pool_enable_partial_governance_voting">enable_partial_governance_voting</a>(pool_address: <b>address</b>)
Expand Down Expand Up @@ -3395,7 +3395,7 @@ Allows an owner to change the operator of the underlying stake pool.
## Function `set_beneficiary_for_operator`

Allows an operator to change its beneficiary. Any existing unpaid commission rewards will be paid to the new
beneficiary. To ensures payment to the current beneficiary, one should first call <code>synchronize_delegation_pool</code>
beneficiary. To ensure payment to the current beneficiary, one should first call <code>synchronize_delegation_pool</code>
before switching the beneficiary. An operator can set one beneficiary for delegation pools, not a separate
one for each pool.

Expand Down
4 changes: 2 additions & 2 deletions aptos-move/framework/aptos-framework/doc/fungible_asset.md
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ The fungible asset's supply has exceeded maximum.

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

The mint ref and the the store do not match.
The mint ref and the store do not match.


<pre><code><b>const</b> <a href="fungible_asset.md#0x1_fungible_asset_EMINT_REF_AND_STORE_MISMATCH">EMINT_REF_AND_STORE_MISMATCH</a>: u64 = 7;
Expand Down Expand Up @@ -2336,7 +2336,7 @@ Decrease the supply of a fungible asset by burning.

<tr>
<td>10</td>
<td>A store should only be deleted if it's balance is zero.</td>
<td>A store should only be deleted if its balance is zero.</td>
<td>Medium</td>
<td>The remove_store function validates the store's balance and removes the store under the object address.</td>
<td>Audited that aborts if the balance of the store is not zero. Audited that store is removed from the object address.</td>
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/framework/aptos-framework/doc/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Module `0x1::object`

This defines the Move object model with the the following properties:
This defines the Move object model with the following properties:
- Simplified storage interface that supports a heterogeneous collection of resources to be
stored together. This enables data types to share a common core data layer (e.g., tokens),
while having richer extensions (e.g., concert ticket, sword).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The transfer flow works as below:
2. The fungible asset metadata object calls <code>ensure_primary_store_exists</code> to ensure that both the sender's and the
recipient's primary stores exist. If either doesn't, it will be created.
3. The fungible asset metadata object calls <code>withdraw</code> on the sender's primary store to withdraw <code>amount</code> of
fungible asset from it. This emits an withdraw event.
fungible asset from it. This emits a withdraw event.
4. The fungible asset metadata object calls <code>deposit</code> on the recipient's primary store to deposit <code>amount</code> of
fungible asset to it. This emits an deposit event.

Expand Down Expand Up @@ -727,7 +727,7 @@ Transfer <code>amount</code> of FA from the primary store of <code>from</code> t
<td>Setting the frozen flag of a store is only allowed with a valid reference.</td>
<td>High</td>
<td>The function set_frozen_flag fetches the primary store and calls fungible_asset::set_frozen_flag which validates the TransferRef's metadata with the store's metadata and then updates the frozen flag.</td>
<td>Audited that it aborts if the store's metadata is not same as the the TransferRef's metadata. Audited that the status of the frozen flag is updated correctly.</td>
<td>Audited that it aborts if the store's metadata is not same as the TransferRef's metadata. Audited that the status of the frozen flag is updated correctly.</td>
</tr>

</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ module aptos_framework::delegation_pool {
/// The account is not the operator of the stake pool.
const ENOT_OPERATOR: u64 = 18;

/// Chaning beneficiaries for operators is not supported.
/// Changing beneficiaries for operators is not supported.
const EOPERATOR_BENEFICIARY_CHANGE_NOT_SUPPORTED: u64 = 19;

/// Commission percentage increase is too large.
Expand Down Expand Up @@ -230,7 +230,7 @@ module aptos_framework::delegation_pool {
/// Minimum coins to exist on a shares pool at all times.
/// Enforced per delegator for both active and pending_inactive pools.
/// This constraint ensures the share price cannot overly increase and lead to
/// substantial loses when buying shares (can lose at most 1 share which may
/// substantial losses when buying shares (can lose at most 1 share which may
/// be worth a lot if current share price is high).
/// This constraint is not enforced on inactive pools as they only allow redeems
/// (can lose at most 1 coin regardless of current share price).
Expand Down Expand Up @@ -282,7 +282,7 @@ module aptos_framework::delegation_pool {
proposal_id: u64,
}

/// Track delgated voter of each delegator.
/// Track delegated voter of each delegator.
struct VoteDelegation has copy, drop, store {
// The account who can vote on behalf of this delegator.
voter: address,
Expand All @@ -297,7 +297,7 @@ module aptos_framework::delegation_pool {
last_locked_until_secs: u64,
}

/// Track total voteing power of each voter.
/// Track total voting power of each voter.
struct DelegatedVotes has copy, drop, store {
// The total number of active shares delegated to this voter by all delegators.
active_shares: u128,
Expand Down Expand Up @@ -469,7 +469,7 @@ module aptos_framework::delegation_pool {
}

#[view]
/// Return whether a delegation pool has already enabled partial govnernance voting.
/// Return whether a delegation pool has already enabled partial governance voting.
public fun partial_governance_voting_enabled(pool_address: address): bool {
exists<GovernanceRecords>(pool_address) && stake::get_delegated_voter(pool_address) == pool_address
}
Expand Down Expand Up @@ -792,7 +792,7 @@ module aptos_framework::delegation_pool {
// save delegation pool ownership and resource account address (inner stake pool address) on `owner`
move_to(owner, DelegationPoolOwnership { pool_address });

// All delegation pool enable partial governace voting by default once the feature flag is enabled.
// All delegation pool enable partial governance voting by default once the feature flag is enabled.
if (features::partial_governance_voting_enabled() && features::delegation_pool_partial_governance_voting_enabled()) {
enable_partial_governance_voting(pool_address);
}
Expand All @@ -809,7 +809,7 @@ module aptos_framework::delegation_pool {
}

/// Enable partial governance voting on a stake pool. The voter of this stake pool will be managed by this module.
/// THe existing voter will be replaced. The function is permissionless.
/// The existing voter will be replaced. The function is permissionless.
public entry fun enable_partial_governance_voting(
pool_address: address,
) acquires DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage {
Expand Down Expand Up @@ -1159,7 +1159,7 @@ module aptos_framework::delegation_pool {
}

/// Allows an operator to change its beneficiary. Any existing unpaid commission rewards will be paid to the new
/// beneficiary. To ensures payment to the current beneficiary, one should first call `synchronize_delegation_pool`
/// beneficiary. To ensure payment to the current beneficiary, one should first call `synchronize_delegation_pool`
/// before switching the beneficiary. An operator can set one beneficiary for delegation pools, not a separate
/// one for each pool.
public entry fun set_beneficiary_for_operator(operator: &signer, new_beneficiary: address) acquires BeneficiaryForOperator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module aptos_framework::fungible_asset {
const EMAX_SUPPLY_EXCEEDED: u64 = 5;
/// Fungible asset do not match when merging.
const EFUNGIBLE_ASSET_MISMATCH: u64 = 6;
/// The mint ref and the the store do not match.
/// The mint ref and the store do not match.
const EMINT_REF_AND_STORE_MISMATCH: u64 = 7;
/// Account is not the store's owner.
const ENOT_STORE_OWNER: u64 = 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ spec aptos_framework::fungible_asset {
/// Enforcement: Audited that the store is properly initialized with zero balance.
///
/// No.: 10
/// Requirement: A store should only be deleted if it's balance is zero.
/// Requirement: A store should only be deleted if its balance is zero.
/// Criticality: Medium
/// Implementation: The remove_store function validates the store's balance and removes the store under the object
/// address.
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/framework/aptos-framework/sources/object.move
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// This defines the Move object model with the the following properties:
/// This defines the Move object model with the following properties:
/// - Simplified storage interface that supports a heterogeneous collection of resources to be
/// stored together. This enables data types to share a common core data layer (e.g., tokens),
/// while having richer extensions (e.g., concert ticket, sword).
Expand Down
Loading

0 comments on commit 7ec123f

Please sign in to comment.