diff --git a/CHANGELOG.md b/CHANGELOG.md index 13495e0392..2f9e8d3bb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cli/src/config.rs b/cli/src/config.rs index fdd6574dd2..1d8e2fcf1e 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -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, + // Deactivate one or more features. + #[serde(skip_serializing_if = "Option::is_none")] + pub deactivate_feature: Option>, } #[derive(Debug, Default, Clone, Serialize, Deserialize)] @@ -1094,6 +1097,8 @@ pub struct Validator { pub ticks_per_slot: Option, #[serde(skip_serializing_if = "Option::is_none")] pub warp_slot: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub deactivate_feature: Option>, } impl From<_Validator> for Validator { @@ -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, } } } @@ -1146,6 +1152,7 @@ impl From 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, } } } @@ -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()), }; } } diff --git a/cli/src/lib.rs b/cli/src/lib.rs index f5c81519c3..90715b005e 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -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, _> = 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('_', "-")));