feat(validation): add must_call_programs validation rule#422
Conversation
Adds a new optional config field `must_call_programs` to `ValidationConfig`. When non-empty, transactions must call at least one of the listed programs. Transactions containing only ComputeBudget instructions are also rejected. Refs: PRO-1089
📊 TypeScript Coverage ReportCoverage: 33.9% View detailed reportCoverage artifacts have been uploaded to this workflow run. |
Greptile SummaryThis PR adds an optional
Confidence Score: 4/5Safe to merge after adding pubkey-format validation for One P1 finding remains: invalid pubkeys in
|
| Filename | Overview |
|---|---|
| crates/lib/src/validator/transaction_validator.rs | Adds must_call_programs field and validate_must_call_programs method; logic is correct but pubkey parsing errors surface only at request-time rather than config-load time. |
| crates/lib/src/validator/config_validator.rs | Updated test fixtures only; missing pubkey-format validation and cross-validation for must_call_programs against allowed_programs. |
| crates/lib/src/config.rs | Adds must_call_programs: Vec<String> with #[serde(default)] — backward-compatible and correctly structured. |
| crates/lib/src/tests/config_mock.rs | Adds with_must_call_programs builder method and initialises the field to vec![] in defaults — clean and consistent. |
| crates/lib/src/tests/toml_mock.rs | Adds must_call_programs to the TOML builder with correct serialisation — no issues. |
| kora.toml | Adds commented-out must_call_programs example — informative and non-breaking. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Incoming Transaction] --> B[validate_programs\nall instructions must be in allowed_programs]
B -->|fail| E[Reject: program not allowed]
B -->|pass| C{must_call_programs\nnon-empty?}
C -->|no| G[Continue validation...]
C -->|yes| D{non-CU instructions\nexist?}
D -->|no| F[Reject: CU-only transaction]
D -->|yes| H{at least one\ninstruction calls a\nmust_call_program?}
H -->|no| I[Reject: required program not called]
H -->|yes| G
Comments Outside Diff (2)
-
crates/lib/src/validator/config_validator.rs, line 429-437 (link)Missing pubkey format validation for
must_call_programsallowed_programsaddresses are validated at config-load time in this block, butmust_call_programshas no equivalent check. An invalid address there is only caught insideTransactionValidator::new(), surfacing asKoraError::InternalServerErroron every request instead of a startup configuration error. Add the same loop pattern used forallowed_programs, iterating overconfig.validation.must_call_programsand pushing an error for any entry that cannot be parsed as a valid Solana pubkey. -
crates/lib/src/validator/config_validator.rs, line 429-437 (link)must_call_programsentry not inallowed_programsmakes all transactions impossibleIf a program is listed in
must_call_programsbut absent fromallowed_programs, it is impossible for any transaction to pass both checks: a transaction that calls the required program failsvalidate_programs, and one that omits it failsvalidate_must_call_programs. The config validator should warn about this misconfiguration by checking eachmust_call_programsentry againstallowed_programsand emitting a warning when an entry is missing.
Reviews (1): Last reviewed commit: "feat(validation): add must_call_programs..." | Re-trigger Greptile
Add startup config checks for must_call_programs to fail fast on invalid or unsatisfiable policy values. - Validate must_call_programs entries are valid pubkeys - Require each must_call_programs entry to also exist in allowed_programs - Reject compute-budget-only must_call_programs policy - Add config-validator tests for these scenarios - Update config docs/comments to reflect constraints Refs: PRO-1089
…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
|
great suggestion @loopcreativeandy |
Summary
must_call_programs: Vec<String>field toValidationConfig(backward-compatible via#[serde(default)])allowed_programspattern for config parsing and validationTest Plan
just unit-test— all 611 tests passCloses PRO-1089
📊 Unit Test Coverage
Unit Test Coverage: 85.0%
View Detailed Coverage Report