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

test validator: make feature accounts additive #3766

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

buffalojoec
Copy link

Problem

In a situation where you may want to place a certain account at one of the feature IDs in the SDK's feature set, the test validator will always overwrite your provided account with a feature account. You can provide the --deactivate-feature option, but the account is still overwritten before it is then removed, rendering the user no way to place an account at that particular address.

This may not be especially useful to typical program developers, however it is definitely useful to test runtime behavior, such as that of the nascent Feature Gate Core BPF program.

Summary of Changes

Simply reorder how the test validator pops deactivated features out of the genesis accounts list. Rather than populating the account store with a feature account at every feature ID and then removing the declared deactivated features, instead only create accounts for the active ones, allowing provided accounts for deactivated features to make it into genesis.

Comment on lines +870 to +872
for feature in feature_set {
genesis_utils::activate_feature(&mut genesis_config, feature);
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may look a little redundant, but I wanted to be absolutely sure the original behavior for create_genesis_config_with_leader_ex was preserved.

@buffalojoec buffalojoec marked this pull request as ready for review November 24, 2024 23:51
Copy link

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good to me! just a suggestion on the test.

Just to be totally sure, with this change, if you want to add account data at a feature address, you'll need to specify both --account ... and --deactivate-feature ..., correct?

We could eventually return an error if the pubkey on a provided --account is a feature and the --deactivate-feature option is not provided, but as you said, this is a pretty niche use-case.

let mut deactivate_features = Vec::new();
[
solana_sdk::feature_set::deprecate_rewards_sysvar::id(),
solana_sdk::feature_set::disable_fees_sysvar::id(),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't seem to exercise the exact behavior that you want, of overriding a feature account with something else. How about adding some account data at one of these addresses?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, yeah, good point. Updated!

@buffalojoec
Copy link
Author

We could eventually return an error if the pubkey on a provided --account is a feature and the --deactivate-feature option is not provided, but as you said, this is a pretty niche use-case.

I can add this if you think we should include it here, but for now you'd just get your account overwritten like it does now. I think that's okay, but happy to add the check if need be.

Copy link

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks! This just needs a rebase to pick up the newer dependencies which satisfy cargo-audit

@buffalojoec buffalojoec force-pushed the test-validator-genesis-features branch from a641488 to 12ff917 Compare November 26, 2024 11:12
@buffalojoec buffalojoec added the automerge automerge Merge this Pull Request automatically once CI passes label Nov 26, 2024
@mergify mergify bot merged commit 191cf4c into anza-xyz:master Nov 26, 2024
41 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants