From 800335645032b60596908a0a9388006f80f1c3c2 Mon Sep 17 00:00:00 2001 From: igor-aptos <110557261+igor-aptos@users.noreply.github.com> Date: Mon, 26 Feb 2024 16:51:44 -0800 Subject: [PATCH] consolidate default features into a single list (#11913) * consolidate default features into a single list * cleaning up unnecessary method --- .../src/components/mod.rs | 6 +- aptos-move/vm-genesis/src/lib.rs | 53 +-------------- testsuite/smoke-test/src/upgrade.rs | 4 +- types/src/on_chain_config/aptos_features.rs | 67 ++++++++++++++++--- 4 files changed, 62 insertions(+), 68 deletions(-) diff --git a/aptos-move/aptos-release-builder/src/components/mod.rs b/aptos-move/aptos-release-builder/src/components/mod.rs index e7e2ef5c08ac2..ae30196b836d7 100644 --- a/aptos-move/aptos-release-builder/src/components/mod.rs +++ b/aptos-move/aptos-release-builder/src/components/mod.rs @@ -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; @@ -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(), diff --git a/aptos-move/vm-genesis/src/lib.rs b/aptos-move/vm-genesis/src/lib.rs index 9ef8a50a1c55a..61c0f9b849782 100644 --- a/aptos-move/vm-genesis/src/lib.rs +++ b/aptos-move/vm-genesis/src/lib.rs @@ -413,59 +413,8 @@ fn initialize( ); } -pub fn default_features() -> Vec { - 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 = default_features() + let features: Vec = FeatureFlag::default_features() .into_iter() .map(|feature| feature as u64) .collect(); diff --git a/testsuite/smoke-test/src/upgrade.rs b/testsuite/smoke-test/src/upgrade.rs index 4eac208f0b19b..9de56f9076ea5 100644 --- a/testsuite/smoke-test/src/upgrade.rs +++ b/testsuite/smoke-test/src/upgrade.rs @@ -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 @@ -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(), diff --git a/types/src/on_chain_config/aptos_features.rs b/types/src/on_chain_config/aptos_features.rs index 3ea9bfa322bd4..6a5b126c7629d 100644 --- a/types/src/on_chain_config/aptos_features.rs +++ b/types/src/on_chain_config/aptos_features.rs @@ -63,6 +63,59 @@ pub enum FeatureFlag { MAX_OBJECT_NESTING_CHECK = 53, } +impl FeatureFlag { + pub fn default_features() -> Vec { + 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 { @@ -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 } }