Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable delegation_pool_partial_governance_voting by default #15549

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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,
Expand Down
Loading