Add deactivate-feature feature to test validator cli (#23041)

This commit is contained in:
Charlie You 2022-02-09 15:45:24 -06:00 committed by GitHub
parent 57a9146fa1
commit a7598b6d78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View File

@ -151,3 +151,19 @@ JSON RPC URL: http://127.0.0.1:8899
[commitment levels](clients/jsonrpc-api#configuring-state-commitment),
slot height of the last snapshot, transaction count,
[voting authority](/running-validator/vote-accounts#vote-authority) balance
## Appendix II: Runtime Features
By default, the test validator runs with all [runtime features](programming-model/runtime#features) activated.
You can verify this using the [Solana command-line tools](cli/install-solana-cli-tools.md):
```bash
solana feature status -ul
```
Since this may not always be desired, especially when testing programs meant for deployment to mainnet, the CLI provides an option to deactivate specific features:
```bash
solana-test-validator --deactivate-feature <FEATURE_PUBKEY_1> --deactivate-feature <FEATURE_PUBKEY_2>
```

View File

@ -325,6 +325,15 @@ fn main() {
.long("no-accounts-db-caching")
.help("Disables accounts caching"),
)
.arg(
Arg::with_name("deactivate_feature")
.long("deactivate-feature")
.takes_value(true)
.value_name("FEATURE_PUBKEY")
.validator(is_pubkey)
.multiple(true)
.help("deactivate this feature in genesis.")
)
.get_matches();
let output = if matches.is_present("quiet") {
@ -549,6 +558,8 @@ fn main() {
});
}
let features_to_deactivate = pubkeys_of(&matches, "deactivate_feature").unwrap_or_default();
if TestValidatorGenesis::ledger_exists(&ledger_path) {
for (name, long) in &[
("bpf_program", "--bpf-program"),
@ -558,6 +569,7 @@ fn main() {
("ticks_per_slot", "--ticks-per-slot"),
("slots_per_epoch", "--slots-per-epoch"),
("faucet_sol", "--faucet-sol"),
("deactivate_feature", "--deactivate-feature"),
] {
if matches.is_present(name) {
println!("{} argument ignored, ledger already exists", long);
@ -626,7 +638,8 @@ fn main() {
.bpf_jit(!matches.is_present("no_bpf_jit"))
.rpc_port(rpc_port)
.add_programs_with_path(&programs_to_load)
.add_accounts_from_json_files(&accounts_to_load);
.add_accounts_from_json_files(&accounts_to_load)
.deactivate_features(&features_to_deactivate);
if !accounts_to_clone.is_empty() {
genesis.clone_accounts(