diff --git a/aptos-move/framework/aptos-framework/sources/delegation_pool.move b/aptos-move/framework/aptos-framework/sources/delegation_pool.move index 1db2438ed4241..bab7f756ca311 100644 --- a/aptos-move/framework/aptos-framework/sources/delegation_pool.move +++ b/aptos-move/framework/aptos-framework/sources/delegation_pool.move @@ -2402,6 +2402,12 @@ module aptos_framework::delegation_pool { validator: &signer, ) acquires DelegationPoolOwnership, DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { initialize_for_test(aptos_framework); + // This test case checks the scenario where delegation_pool_partial_governance_voting is disabled. + features::change_feature_flags_for_testing( + aptos_framework, + vector[], + vector[features::get_delegation_pool_partial_governance_voting()] + ); let validator_address = signer::address_of(validator); initialize_delegation_pool(validator, 0, vector::empty()); @@ -2435,10 +2441,33 @@ module aptos_framework::delegation_pool { validator: &signer, ) acquires DelegationPoolOwnership, DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { initialize_for_test(aptos_framework); + // This test case checks the scenario where delegation_pool_partial_governance_voting is disabled. + features::change_feature_flags_for_testing( + aptos_framework, + vector[], + vector[features::get_delegation_pool_partial_governance_voting()] + ); // account does not own any delegation pool set_delegated_voter(validator, @0x112); } + #[test(aptos_framework = @aptos_framework, validator = @0x123)] + #[expected_failure(abort_code = 0x3000C, location = Self)] + public entry fun test_cannot_set_delegated_voter_if_partial_governance_voting( + aptos_framework: &signer, + validator: &signer, + ) acquires DelegationPoolOwnership, DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { + initialize_for_test(aptos_framework); + // This test case checks the scenario where delegation_pool_partial_governance_voting is enabled. + features::change_feature_flags_for_testing( + aptos_framework, + vector[features::get_delegation_pool_partial_governance_voting()], + vector[] + ); + // cannot call this deprecated function anymore + set_delegated_voter(validator, @0x112); + } + #[test(aptos_framework = @aptos_framework, validator = @0x123)] #[expected_failure(abort_code = 0x80002, location = Self)] public entry fun test_already_owns_delegation_pool( @@ -2467,6 +2496,12 @@ module aptos_framework::delegation_pool { validator: &signer, ) acquires DelegationPoolOwnership, DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { initialize_for_test(aptos_framework); + // This test case checks the scenario where delegation_pool_partial_governance_voting is disabled. + features::change_feature_flags_for_testing( + aptos_framework, + vector[], + vector[features::get_delegation_pool_partial_governance_voting()] + ); let validator_address = signer::address_of(validator); initialize_delegation_pool(validator, 1234, vector::empty()); @@ -2477,6 +2512,7 @@ module aptos_framework::delegation_pool { assert!(stake::stake_pool_exists(pool_address), 0); assert!(stake::get_operator(pool_address) == validator_address, 0); + // pool created before partial governance voting, owner account is delegated voter assert!(stake::get_delegated_voter(pool_address) == validator_address, 0); assert!(observed_lockup_cycle(pool_address) == 0, 0); @@ -4429,6 +4465,12 @@ module aptos_framework::delegation_pool { 1000, ); aptos_governance::initialize_partial_voting(aptos_framework); + // This test case checks the scenario where delegation_pool_partial_governance_voting is disabled. + features::change_feature_flags_for_testing( + aptos_framework, + vector[], + vector[features::get_delegation_pool_partial_governance_voting()] + ); initialize_test_validator(validator, 100 * ONE_APT, true, false); @@ -4592,6 +4634,12 @@ module aptos_framework::delegation_pool { voter1: &signer, voter2: &signer, ) acquires DelegationPoolOwnership, DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage, DelegationPoolAllowlisting { + // This test case checks the scenario where delegation_pool_partial_governance_voting is disabled. + features::change_feature_flags_for_testing( + aptos_framework, + vector[], + vector[features::get_delegation_pool_partial_governance_voting()] + ); // partial voing hasn't been enabled yet. A proposal has been created by the validator. let proposal1_id = setup_vote(aptos_framework, validator, false); @@ -4685,6 +4733,12 @@ module aptos_framework::delegation_pool { delegator1: &signer, voter1: &signer, ) acquires DelegationPoolOwnership, DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage, DelegationPoolAllowlisting { + // This test case checks the scenario where delegation_pool_partial_governance_voting is disabled. + features::change_feature_flags_for_testing( + aptos_framework, + vector[], + vector[features::get_delegation_pool_partial_governance_voting()] + ); // partial voing hasn't been enabled yet. A proposal has been created by the validator. let proposal1_id = setup_vote(aptos_framework, validator, false); @@ -4722,6 +4776,12 @@ module aptos_framework::delegation_pool { delegator1: &signer, voter1: &signer, ) acquires DelegationPoolOwnership, DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage, DelegationPoolAllowlisting { + // This test case checks the scenario where delegation_pool_partial_governance_voting is disabled. + features::change_feature_flags_for_testing( + aptos_framework, + vector[], + vector[features::get_delegation_pool_partial_governance_voting()] + ); // partial voing hasn't been enabled yet. A proposal has been created by the validator. let proposal1_id = setup_vote(aptos_framework, validator, false); @@ -4761,6 +4821,12 @@ module aptos_framework::delegation_pool { validator: &signer, delegator1: &signer, ) acquires DelegationPoolOwnership, DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage, DelegationPoolAllowlisting { + // This test case checks the scenario where delegation_pool_partial_governance_voting is disabled. + features::change_feature_flags_for_testing( + aptos_framework, + vector[], + vector[features::get_delegation_pool_partial_governance_voting()] + ); // partial voing hasn't been enabled yet. A proposal has been created by the validator. let proposal1_id = setup_vote(aptos_framework, validator, true); @@ -4780,6 +4846,12 @@ module aptos_framework::delegation_pool { delegator1: &signer, voter1: &signer, ) acquires DelegationPoolOwnership, DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage, DelegationPoolAllowlisting { + // This test case checks the scenario where delegation_pool_partial_governance_voting is disabled. + features::change_feature_flags_for_testing( + aptos_framework, + vector[], + vector[features::get_delegation_pool_partial_governance_voting()] + ); // partial voing hasn't been enabled yet. A proposal has been created by the validator. setup_vote(aptos_framework, validator, true); diff --git a/types/src/on_chain_config/aptos_features.rs b/types/src/on_chain_config/aptos_features.rs index 70bc4f18aa546..3ec9d862dec4d 100644 --- a/types/src/on_chain_config/aptos_features.rs +++ b/types/src/on_chain_config/aptos_features.rs @@ -125,6 +125,7 @@ impl FeatureFlag { FeatureFlag::SIGNATURE_CHECKER_V2, FeatureFlag::STORAGE_SLOT_METADATA, FeatureFlag::CHARGE_INVARIANT_VIOLATION, + FeatureFlag::DELEGATION_POOL_PARTIAL_GOVERNANCE_VOTING, FeatureFlag::APTOS_UNIQUE_IDENTIFIERS, FeatureFlag::GAS_PAYER_ENABLED, FeatureFlag::BULLETPROOFS_NATIVES,