Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- cli: Add priority fees to idl commands ([#2845](https://github.com/coral-xyz/anchor/pull/2845)).
- ts: Add `prepend` option to MethodBuilder `preInstructions` method ([#2863](https://github.com/coral-xyz/anchor/pull/2863)).
- lang: Add `declare_program!` macro ([#2857](https://github.com/coral-xyz/anchor/pull/2857)).
- cli: Add `deactivate_feature` flag to `solana-test-validator` config in Anchor.toml ([#2872](https://github.com/coral-xyz/anchor/pull/2872)).

### Fixes

Expand Down
10 changes: 10 additions & 0 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,9 @@ pub struct _Validator {
// Warp the ledger to WARP_SLOT after starting the validator.
#[serde(skip_serializing_if = "Option::is_none")]
pub warp_slot: Option<String>,
// Deactivate one or more features.
#[serde(skip_serializing_if = "Option::is_none")]
pub deactivate_feature: Option<Vec<String>>,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -1094,6 +1097,8 @@ pub struct Validator {
pub ticks_per_slot: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
pub warp_slot: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub deactivate_feature: Option<Vec<String>>,
}

impl From<_Validator> for Validator {
Expand Down Expand Up @@ -1122,6 +1127,7 @@ impl From<_Validator> for Validator {
slots_per_epoch: _validator.slots_per_epoch,
ticks_per_slot: _validator.ticks_per_slot,
warp_slot: _validator.warp_slot,
deactivate_feature: _validator.deactivate_feature,
}
}
}
Expand All @@ -1146,6 +1152,7 @@ impl From<Validator> for _Validator {
slots_per_epoch: validator.slots_per_epoch,
ticks_per_slot: validator.ticks_per_slot,
warp_slot: validator.warp_slot,
deactivate_feature: validator.deactivate_feature,
}
}
}
Expand Down Expand Up @@ -1235,6 +1242,9 @@ impl Merge for _Validator {
.or_else(|| self.slots_per_epoch.take()),
ticks_per_slot: other.ticks_per_slot.or_else(|| self.ticks_per_slot.take()),
warp_slot: other.warp_slot.or_else(|| self.warp_slot.take()),
deactivate_feature: other
.deactivate_feature
.or_else(|| self.deactivate_feature.take()),
};
}
}
Expand Down
18 changes: 18 additions & 0 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3338,6 +3338,24 @@ fn validator_flags(
flags.push("--clone".to_string());
flags.push(pubkey.to_string());
}
} else if key == "deactivate_feature" {
// Verify that the feature flags are valid pubkeys
let pubkeys_result: Result<Vec<Pubkey>, _> = value
.as_array()
.unwrap()
.iter()
.map(|entry| {
let feature_flag = entry.as_str().unwrap();
Pubkey::from_str(feature_flag).map_err(|_| {
anyhow!("Invalid pubkey (feature flag) {}", feature_flag)
})
})
.collect();
let features = pubkeys_result?;
for feature in features {
flags.push("--deactivate-feature".to_string());
flags.push(feature.to_string());
}
} else {
// Remaining validator flags are non-array types
flags.push(format!("--{}", key.replace('_', "-")));
Expand Down