Skip to content

Commit ad9cc32

Browse files
committed
refactor(validation): remove compute-budget special-casing from must_call_programs
Keep must_call_programs focused on required-program matching only. Compute-only transaction rejection belongs to the dedicated compute-only validation flow (PR #421), not this rule. - Remove ComputeBudget filtering from must_call_programs runtime check - Remove compute-budget-only config rejection for must_call_programs - Update docs/comments and adjust config validator test expectations Refs: PRO-1089
1 parent dfbdc6f commit ad9cc32

4 files changed

Lines changed: 10 additions & 37 deletions

File tree

crates/lib/src/config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ pub struct ValidationConfig {
138138
#[serde(default)]
139139
pub max_price_staleness_slots: u64,
140140
/// Programs that must be called by the transaction (at least one must appear).
141-
/// Transactions containing only ComputeBudget instructions are also rejected when non-empty.
142141
/// Each required program must also be listed in `allowed_programs`.
143142
/// Default: empty (no restriction).
144143
#[serde(default)]

crates/lib/src/validator/config_validator.rs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -448,19 +448,6 @@ impl ConfigValidator {
448448

449449
// Validate must_call_programs constraints
450450
if !config.validation.must_call_programs.is_empty() {
451-
let compute_budget_program = solana_compute_budget_interface::id().to_string();
452-
453-
if config
454-
.validation
455-
.must_call_programs
456-
.iter()
457-
.all(|program| program == &compute_budget_program)
458-
{
459-
errors.push(
460-
"must_call_programs cannot contain only the Compute Budget program".to_string(),
461-
);
462-
}
463-
464451
for program in &config.validation.must_call_programs {
465452
if !config.validation.allowed_programs.contains(program) {
466453
errors.push(format!(
@@ -1127,24 +1114,22 @@ mod tests {
11271114

11281115
#[tokio::test]
11291116
#[serial]
1130-
async fn test_validate_with_result_must_call_programs_compute_budget_only_error() {
1117+
async fn test_validate_with_result_must_call_programs_allows_compute_budget_program() {
11311118
let mut config = ConfigMockBuilder::new().build();
11321119
config.kora.cache.enabled = false;
11331120
let compute_budget_program = solana_compute_budget_interface::id().to_string();
1134-
config.validation.allowed_programs = vec![compute_budget_program.clone()];
1121+
config.validation.allowed_programs = vec![
1122+
SYSTEM_PROGRAM_ID.to_string(),
1123+
SPL_TOKEN_PROGRAM_ID.to_string(),
1124+
compute_budget_program.clone(),
1125+
];
11351126
config.validation.must_call_programs = vec![compute_budget_program];
1136-
config.validation.price.model = PriceModel::Free;
11371127

11381128
let _ = update_config(config);
11391129

11401130
let rpc_client = RpcMockBuilder::new().build();
11411131
let result = ConfigValidator::validate_with_result(&rpc_client, true).await;
1142-
assert!(result.is_err());
1143-
let errors = result.unwrap_err();
1144-
1145-
assert!(errors.iter().any(|e| {
1146-
e.contains("must_call_programs cannot contain only the Compute Budget program")
1147-
}));
1132+
assert!(result.is_ok());
11481133
}
11491134

11501135
#[tokio::test]

crates/lib/src/validator/transaction_validator.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,10 @@ impl TransactionValidator {
187187
return Ok(());
188188
}
189189

190-
let compute_budget_id = solana_compute_budget_interface::id();
191-
let non_cu_instructions: Vec<_> = transaction_resolved
190+
let called = transaction_resolved
192191
.all_instructions
193192
.iter()
194-
.filter(|ix| ix.program_id != compute_budget_id)
195-
.collect();
196-
197-
if non_cu_instructions.is_empty() {
198-
return Err(KoraError::InvalidTransaction(
199-
"Transaction contains only ComputeBudget instructions".to_string(),
200-
));
201-
}
202-
203-
let called =
204-
non_cu_instructions.iter().any(|ix| self.must_call_programs.contains(&ix.program_id));
193+
.any(|ix| self.must_call_programs.contains(&ix.program_id));
205194
if !called {
206195
return Err(KoraError::InvalidTransaction(format!(
207196
"Transaction must call at least one of the required programs: {:?}",

kora.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ allowed_tokens = [
6868
allowed_spl_paid_tokens = []
6969
#allowed_spl_paid_tokens = "All" # Allow any token to be used for payment,
7070
disallowed_accounts = []
71-
# must_call_programs = [] # At least one of these programs must be called. Each must also appear in allowed_programs. Transactions with only ComputeBudget instructions are rejected when non-empty.
71+
# must_call_programs = [] # At least one of these programs must be called. Each must also appear in allowed_programs.
7272

7373
# Fee payer policy controls what actions the fee payer can perform
7474
#

0 commit comments

Comments
 (0)