Skip to content

Commit 232a458

Browse files
committed
svm repo split: dedev: feature-set
1 parent 13f5a3f commit 232a458

File tree

5 files changed

+25
-30
lines changed

5 files changed

+25
-30
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compute-budget-instruction/src/instructions_processor.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ pub fn process_compute_budget_instructions<'a>(
1818
.sanitize_and_convert_to_compute_budget_limits(feature_set)
1919
}
2020

21+
// Call this in tests if you are not testing any builtin -> BPF migrations.
22+
#[cfg(feature = "dev-context-only-utils")]
23+
pub fn process_compute_budget_instructions_with_default_feature_set<'a>(
24+
instructions: impl Iterator<Item = (&'a Pubkey, SVMInstruction<'a>)> + Clone,
25+
) -> Result<ComputeBudgetLimits, TransactionError> {
26+
ComputeBudgetInstructionDetails::try_from(instructions)?
27+
.sanitize_and_convert_to_compute_budget_limits(&FeatureSet::default())
28+
}
29+
2130
#[cfg(test)]
2231
mod tests {
2332
use {

svm-feature-set/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[derive(Clone, Copy, Default)]
1+
#[derive(Clone, Copy, Debug, Default)]
22
pub struct SVMFeatureSet {
33
pub move_precompile_verification_to_svm: bool,
44
pub stricter_abi_and_runtime_constraints: bool,

svm/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ spl-generic-token = { workspace = true }
8181
thiserror = { workspace = true }
8282

8383
[dev-dependencies]
84-
agave-feature-set = { workspace = true }
8584
agave-reserved-account-keys = { workspace = true }
8685
agave-syscalls = { workspace = true }
8786
assert_matches = { workspace = true }
@@ -93,7 +92,7 @@ rand0-7 = { workspace = true }
9392
shuttle = { workspace = true }
9493
solana-bpf-loader-program = { workspace = true }
9594
solana-clock = { workspace = true }
96-
solana-compute-budget-instruction = { workspace = true }
95+
solana-compute-budget-instruction = { workspace = true, features = ["dev-context-only-utils"] }
9796
solana-compute-budget-interface = { workspace = true }
9897
solana-compute-budget-program = { workspace = true }
9998
solana-ed25519-program = { workspace = true }

svm/tests/integration_test.rs

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ use {
77
program_data_size, register_builtins, MockBankCallback, MockForkGraph, EXECUTION_EPOCH,
88
EXECUTION_SLOT, WALLCLOCK_TIME,
99
},
10-
agave_feature_set::{self as feature_set, raise_cpi_nesting_limit_to_8, FeatureSet},
1110
solana_account::{AccountSharedData, ReadableAccount, WritableAccount, PROGRAM_OWNERS},
1211
solana_clock::Slot,
13-
solana_compute_budget_instruction::instructions_processor::process_compute_budget_instructions,
12+
solana_compute_budget_instruction::instructions_processor::process_compute_budget_instructions_with_default_feature_set,
1413
solana_compute_budget_interface::ComputeBudgetInstruction,
1514
solana_fee_structure::FeeDetails,
1615
solana_hash::Hash,
@@ -41,6 +40,7 @@ use {
4140
TransactionProcessingEnvironment,
4241
},
4342
},
43+
solana_svm_feature_set::SVMFeatureSet,
4444
solana_svm_transaction::svm_message::SVMMessage,
4545
solana_svm_type_overrides::sync::{Arc, RwLock},
4646
solana_system_interface::{instruction as system_instruction, program as system_program},
@@ -114,10 +114,9 @@ impl SvmTestEnvironment<'_> {
114114
..Default::default()
115115
};
116116

117-
let feature_set = test_entry.feature_set();
118117
let processing_environment = TransactionProcessingEnvironment {
119118
blockhash: LAST_BLOCKHASH,
120-
feature_set: feature_set.runtime_features(),
119+
feature_set: test_entry.feature_set,
121120
blockhash_lamports_per_signature: LAMPORTS_PER_SIGNATURE,
122121
..TransactionProcessingEnvironment::default()
123122
};
@@ -298,8 +297,8 @@ impl SvmTestEnvironment<'_> {
298297
// container for a transaction batch and all data needed to run and verify it against svm
299298
#[derive(Clone, Default, Debug)]
300299
pub struct SvmTestEntry {
301-
// features are enabled by default; these will be disabled
302-
pub disabled_features: Vec<Pubkey>,
300+
// SVM feature set for this test.
301+
pub feature_set: SVMFeatureSet,
303302

304303
// until LoaderV4 is live on mainnet, we default to omitting it, but can also test it
305304
pub with_loader_v4: bool,
@@ -448,10 +447,10 @@ impl SvmTestEntry {
448447
.map(|item| {
449448
let message = SanitizedTransaction::from_transaction_for_tests(item.transaction);
450449
let check_result = item.check_result.map(|tx_details| {
451-
let compute_budget_limits = process_compute_budget_instructions(
452-
SVMMessage::program_instructions_iter(&message),
453-
&self.feature_set(),
454-
);
450+
let compute_budget_limits =
451+
process_compute_budget_instructions_with_default_feature_set(
452+
SVMMessage::program_instructions_iter(&message),
453+
);
455454
let signature_count = message
456455
.num_transaction_signatures()
457456
.saturating_add(message.num_ed25519_signatures())
@@ -465,8 +464,7 @@ impl SvmTestEntry {
465464
signature_count.saturating_mul(LAMPORTS_PER_SIGNATURE),
466465
v.get_prioritization_fee(),
467466
),
468-
self.feature_set()
469-
.is_active(&raise_cpi_nesting_limit_to_8::id()),
467+
self.feature_set.raise_cpi_nesting_limit_to_8,
470468
)
471469
});
472470
CheckedTransactionDetails::new(tx_details.nonce, compute_budget)
@@ -485,16 +483,6 @@ impl SvmTestEntry {
485483
.map(|item| item.asserts)
486484
.collect()
487485
}
488-
489-
// internal helper to map our feature list to a FeatureSet
490-
fn feature_set(&self) -> FeatureSet {
491-
let mut feature_set = FeatureSet::all_enabled();
492-
for feature_id in &self.disabled_features {
493-
feature_set.deactivate(feature_id);
494-
}
495-
496-
feature_set
497-
}
498486
}
499487

500488
// one transaction in a batch plus check results for svm and asserts for tests
@@ -2204,8 +2192,8 @@ fn simd83_account_reallocate(formalize_loaded_transaction_data_size: bool) -> Ve
22042192
common_test_entry.add_initial_program(program_name);
22052193
if !formalize_loaded_transaction_data_size {
22062194
common_test_entry
2207-
.disabled_features
2208-
.push(feature_set::formalize_loaded_transaction_data_size::id());
2195+
.feature_set
2196+
.formalize_loaded_transaction_data_size = false;
22092197
}
22102198

22112199
let fee_payer_keypair = Keypair::new();
@@ -2910,8 +2898,8 @@ fn svm_inspect_nonce_load_failure(
29102898

29112899
if !formalize_loaded_transaction_data_size {
29122900
test_entry
2913-
.disabled_features
2914-
.push(feature_set::formalize_loaded_transaction_data_size::id());
2901+
.feature_set
2902+
.formalize_loaded_transaction_data_size = false;
29152903
}
29162904

29172905
let fee_payer_keypair = Keypair::new();

0 commit comments

Comments
 (0)