Skip to content

Commit

Permalink
Enable DELEGATION_POOL_PARTIAL_GOVERNANCE_VOTING by default (#15549)
Browse files Browse the repository at this point in the history
- enable DELEGATION_POOL_PARTIAL_GOVERNANCE_VOTING
- fix the broken tests due to that.
  • Loading branch information
junkil-park authored Dec 11, 2024
1 parent 1dab352 commit 652be07
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
72 changes: 72 additions & 0 deletions aptos-move/framework/aptos-framework/sources/delegation_pool.move
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>());
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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<u8>());
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down
1 change: 1 addition & 0 deletions types/src/on_chain_config/aptos_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,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,
Expand Down

0 comments on commit 652be07

Please sign in to comment.