Skip to content

Commit

Permalink
consolidate default features into a single list (#11913)
Browse files Browse the repository at this point in the history
* consolidate default features into a single list

* cleaning up unnecessary method
  • Loading branch information
igor-aptos authored Feb 27, 2024
1 parent 7a3132e commit 8003356
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 68 deletions.
6 changes: 3 additions & 3 deletions aptos-move/aptos-release-builder/src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use aptos_temppath::TempPath;
use aptos_types::{
account_config::CORE_CODE_ADDRESS,
on_chain_config::{
ExecutionConfigV1, GasScheduleV2, OnChainConfig, OnChainConsensusConfig,
OnChainExecutionConfig, TransactionShufflerType, Version,
ExecutionConfigV1, FeatureFlag as AptosFeatureFlag, GasScheduleV2, OnChainConfig,
OnChainConsensusConfig, OnChainExecutionConfig, TransactionShufflerType, Version,
},
};
use futures::executor::block_on;
Expand Down Expand Up @@ -595,7 +595,7 @@ impl Default for ReleaseConfig {
name: "feature_flags".to_string(),
update_sequence: vec![
ReleaseEntry::FeatureFlag(Features {
enabled: aptos_vm_genesis::default_features()
enabled: AptosFeatureFlag::default_features()
.into_iter()
.map(crate::components::feature_flags::FeatureFlag::from)
.collect(),
Expand Down
53 changes: 1 addition & 52 deletions aptos-move/vm-genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,59 +413,8 @@ fn initialize(
);
}

pub fn default_features() -> Vec<FeatureFlag> {
vec![
FeatureFlag::CODE_DEPENDENCY_CHECK,
FeatureFlag::TREAT_FRIEND_AS_PRIVATE,
FeatureFlag::SHA_512_AND_RIPEMD_160_NATIVES,
FeatureFlag::APTOS_STD_CHAIN_ID_NATIVES,
FeatureFlag::VM_BINARY_FORMAT_V6,
FeatureFlag::MULTI_ED25519_PK_VALIDATE_V2_NATIVES,
FeatureFlag::BLAKE2B_256_NATIVE,
FeatureFlag::RESOURCE_GROUPS,
FeatureFlag::MULTISIG_ACCOUNTS,
FeatureFlag::DELEGATION_POOLS,
FeatureFlag::CRYPTOGRAPHY_ALGEBRA_NATIVES,
FeatureFlag::BLS12_381_STRUCTURES,
FeatureFlag::ED25519_PUBKEY_VALIDATE_RETURN_FALSE_WRONG_LENGTH,
FeatureFlag::STRUCT_CONSTRUCTORS,
FeatureFlag::SIGNATURE_CHECKER_V2,
FeatureFlag::STORAGE_SLOT_METADATA,
FeatureFlag::CHARGE_INVARIANT_VIOLATION,
FeatureFlag::APTOS_UNIQUE_IDENTIFIERS,
FeatureFlag::GAS_PAYER_ENABLED,
FeatureFlag::BULLETPROOFS_NATIVES,
FeatureFlag::SIGNER_NATIVE_FORMAT_FIX,
FeatureFlag::MODULE_EVENT,
FeatureFlag::EMIT_FEE_STATEMENT,
FeatureFlag::STORAGE_DELETION_REFUND,
FeatureFlag::SIGNATURE_CHECKER_V2_SCRIPT_FIX,
FeatureFlag::AGGREGATOR_V2_API,
FeatureFlag::SAFER_RESOURCE_GROUPS,
FeatureFlag::SAFER_METADATA,
FeatureFlag::SINGLE_SENDER_AUTHENTICATOR,
FeatureFlag::SPONSORED_AUTOMATIC_ACCOUNT_V1_CREATION,
FeatureFlag::FEE_PAYER_ACCOUNT_OPTIONAL,
FeatureFlag::AGGREGATOR_V2_DELAYED_FIELDS,
FeatureFlag::CONCURRENT_TOKEN_V2,
FeatureFlag::LIMIT_MAX_IDENTIFIER_LENGTH,
FeatureFlag::OPERATOR_BENEFICIARY_CHANGE,
FeatureFlag::BN254_STRUCTURES,
FeatureFlag::RESOURCE_GROUPS_SPLIT_IN_VM_CHANGE_SET,
FeatureFlag::COMMISSION_CHANGE_DELEGATION_POOL,
FeatureFlag::WEBAUTHN_SIGNATURE,
// FeatureFlag::RECONFIGURE_WITH_DKG, //TODO: re-enable once randomness is ready.
FeatureFlag::OIDB_SIGNATURE,
FeatureFlag::OIDB_ZKLESS_SIGNATURE,
FeatureFlag::JWK_CONSENSUS,
FeatureFlag::REFUNDABLE_BYTES,
FeatureFlag::OBJECT_CODE_DEPLOYMENT,
FeatureFlag::MAX_OBJECT_NESTING_CHECK,
]
}

fn initialize_features(session: &mut SessionExt) {
let features: Vec<u64> = default_features()
let features: Vec<u64> = FeatureFlag::default_features()
.into_iter()
.map(|feature| feature as u64)
.collect();
Expand Down
4 changes: 2 additions & 2 deletions testsuite/smoke-test/src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use aptos_release_builder::{
ReleaseEntry,
};
use aptos_temppath::TempPath;
use aptos_types::on_chain_config::OnChainConsensusConfig;
use aptos_types::on_chain_config::{FeatureFlag as AptosFeatureFlag, OnChainConsensusConfig};
use std::{fs, path::PathBuf, process::Command, sync::Arc};

// Ignored. This is redundant with the forge compat test but this test is easier to run locally and
Expand Down Expand Up @@ -129,7 +129,7 @@ async fn test_upgrade_flow() {
metadata: ProposalMetadata::default(),
update_sequence: vec![
ReleaseEntry::FeatureFlag(Features {
enabled: aptos_vm_genesis::default_features()
enabled: AptosFeatureFlag::default_features()
.into_iter()
.map(FeatureFlag::from)
.collect(),
Expand Down
67 changes: 56 additions & 11 deletions types/src/on_chain_config/aptos_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,59 @@ pub enum FeatureFlag {
MAX_OBJECT_NESTING_CHECK = 53,
}

impl FeatureFlag {
pub fn default_features() -> Vec<Self> {
vec![
FeatureFlag::CODE_DEPENDENCY_CHECK,
FeatureFlag::TREAT_FRIEND_AS_PRIVATE,
FeatureFlag::SHA_512_AND_RIPEMD_160_NATIVES,
FeatureFlag::APTOS_STD_CHAIN_ID_NATIVES,
FeatureFlag::VM_BINARY_FORMAT_V6,
FeatureFlag::MULTI_ED25519_PK_VALIDATE_V2_NATIVES,
FeatureFlag::BLAKE2B_256_NATIVE,
FeatureFlag::RESOURCE_GROUPS,
FeatureFlag::MULTISIG_ACCOUNTS,
FeatureFlag::DELEGATION_POOLS,
FeatureFlag::CRYPTOGRAPHY_ALGEBRA_NATIVES,
FeatureFlag::BLS12_381_STRUCTURES,
FeatureFlag::ED25519_PUBKEY_VALIDATE_RETURN_FALSE_WRONG_LENGTH,
FeatureFlag::STRUCT_CONSTRUCTORS,
FeatureFlag::SIGNATURE_CHECKER_V2,
FeatureFlag::STORAGE_SLOT_METADATA,
FeatureFlag::CHARGE_INVARIANT_VIOLATION,
FeatureFlag::APTOS_UNIQUE_IDENTIFIERS,
FeatureFlag::GAS_PAYER_ENABLED,
FeatureFlag::BULLETPROOFS_NATIVES,
FeatureFlag::SIGNER_NATIVE_FORMAT_FIX,
FeatureFlag::MODULE_EVENT,
FeatureFlag::EMIT_FEE_STATEMENT,
FeatureFlag::STORAGE_DELETION_REFUND,
FeatureFlag::SIGNATURE_CHECKER_V2_SCRIPT_FIX,
FeatureFlag::AGGREGATOR_V2_API,
FeatureFlag::SAFER_RESOURCE_GROUPS,
FeatureFlag::SAFER_METADATA,
FeatureFlag::SINGLE_SENDER_AUTHENTICATOR,
FeatureFlag::SPONSORED_AUTOMATIC_ACCOUNT_V1_CREATION,
FeatureFlag::FEE_PAYER_ACCOUNT_OPTIONAL,
FeatureFlag::AGGREGATOR_V2_DELAYED_FIELDS,
FeatureFlag::CONCURRENT_TOKEN_V2,
FeatureFlag::LIMIT_MAX_IDENTIFIER_LENGTH,
FeatureFlag::OPERATOR_BENEFICIARY_CHANGE,
FeatureFlag::BN254_STRUCTURES,
FeatureFlag::RESOURCE_GROUPS_SPLIT_IN_VM_CHANGE_SET,
FeatureFlag::COMMISSION_CHANGE_DELEGATION_POOL,
FeatureFlag::WEBAUTHN_SIGNATURE,
// FeatureFlag::RECONFIGURE_WITH_DKG, //TODO: re-enable once randomness is ready.
FeatureFlag::OIDB_SIGNATURE,
FeatureFlag::OIDB_ZKLESS_SIGNATURE,
FeatureFlag::JWK_CONSENSUS,
FeatureFlag::REFUNDABLE_BYTES,
FeatureFlag::OBJECT_CODE_DEPLOYMENT,
FeatureFlag::MAX_OBJECT_NESTING_CHECK,
]
}
}

/// Representation of features on chain as a bitset.
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord, Serialize)]
pub struct Features {
Expand All @@ -76,17 +129,9 @@ impl Default for Features {
features: vec![0; 5],
};

use FeatureFlag::*;
features.enable(VM_BINARY_FORMAT_V6);
features.enable(BLS12_381_STRUCTURES);
features.enable(SIGNATURE_CHECKER_V2);
features.enable(STORAGE_SLOT_METADATA);
features.enable(APTOS_UNIQUE_IDENTIFIERS);
features.enable(SIGNATURE_CHECKER_V2_SCRIPT_FIX);
features.enable(AGGREGATOR_V2_API);
features.enable(BN254_STRUCTURES);
features.enable(REFUNDABLE_BYTES);

for feature in FeatureFlag::default_features() {
features.enable(feature);
}
features
}
}
Expand Down

0 comments on commit 8003356

Please sign in to comment.