Skip to content

feat(validation): block compute-only transactions#421

Merged
dev-jodee merged 1 commit intomainfrom
feat/PRO-1090-block-compute-only-transactions
Apr 9, 2026
Merged

feat(validation): block compute-only transactions#421
dev-jodee merged 1 commit intomainfrom
feat/PRO-1090-block-compute-only-transactions

Conversation

@dev-jodee
Copy link
Copy Markdown
Contributor

@dev-jodee dev-jodee commented Apr 8, 2026

Summary

  • reject transactions that contain only ComputeBudget instructions
  • keep ComputeBudget usage valid when paired with a non-compute instruction
  • add transaction validator tests for both reject and allow behavior

Test Plan (if applicable)

  • cargo test -p kora-lib test_reject_compute_budget_only_transaction -- --nocapture
  • cargo test -p kora-lib test_allow_transaction_with_compute_budget_and_non_compute_instruction -- --nocapture
  • cargo test -p kora-lib test_empty_transaction -- --nocapture
  • cargo test -p kora-lib test_validate_programs -- --nocapture

Closes PRO-1090


Open with Devin

📊 Unit Test Coverage

Coverage

Unit Test Coverage: 84.8%

View Detailed Coverage Report

Reject transactions that contain only ComputeBudget instructions while still allowing ComputeBudget instructions when combined with real program instructions.\nAdd validator tests for both reject and allow paths.\n\nRefs: PRO-1090
@dev-jodee dev-jodee requested a review from amilz as a code owner April 8, 2026 15:13
@linear
Copy link
Copy Markdown

linear bot commented Apr 8, 2026

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

📊 TypeScript Coverage Report

Coverage: 33.9%

View detailed report

Coverage artifacts have been uploaded to this workflow run.
View Artifacts

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 8, 2026

Greptile Summary

Adds a validate_has_non_compute_instruction guard in validate_transaction that rejects transactions composed entirely of ComputeBudget instructions, preventing cost-free no-ops. The check is correctly positioned after the empty-instructions guard and two focused tests (reject and allow) are included.

Confidence Score: 5/5

Safe to merge — the change is a narrow, well-tested validation addition with no breaking side-effects.

Logic is correct (empty-instructions guard fires before the new check, so .any() on an empty iterator cannot produce a misleading error), tests cover both the rejection and pass-through paths, and no existing behavior is altered for valid transactions.

No files require special attention.

Vulnerabilities

No security concerns identified. The new validation tightens the attack surface by rejecting cost-free no-op transactions that contain only ComputeBudget instructions.

Important Files Changed

Filename Overview
crates/lib/src/validator/transaction_validator.rs Adds validate_has_non_compute_instruction guard and two new tests; logic and ordering are correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[validate_transaction called] --> B{all_instructions empty?}
    B -- Yes --> C[Error: no instructions]
    B -- No --> D{Any non-ComputeBudget instruction?}
    D -- No --> E[Error: only ComputeBudget instructions]
    D -- Yes --> F{all_account_keys empty?}
    F -- Yes --> G[Error: no account keys]
    F -- No --> H[validate_signatures]
    H --> I[validate_programs]
    I --> J[validate_transfer_amounts]
    J --> K[validate_disallowed_accounts]
    K --> L[validate_fee_payer_usage]
    L --> M[Ok]
Loading

Reviews (1): Last reviewed commit: "feat(validation): block compute-only tra..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

dev-jodee added a commit that referenced this pull request Apr 8, 2026
…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
@amilz
Copy link
Copy Markdown
Contributor

amilz commented Apr 8, 2026

fyi @loopcreativeandy

@dev-jodee dev-jodee merged commit 4072ee1 into main Apr 9, 2026
13 checks passed
@dev-jodee dev-jodee deleted the feat/PRO-1090-block-compute-only-transactions branch April 9, 2026 12:09
@loopcreativeandy
Copy link
Copy Markdown

fyi @loopcreativeandy

Great job :D

dev-jodee added a commit that referenced this pull request Apr 9, 2026
* feat(validation): add must_call_programs validation rule

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

* fix(validation): validate must_call_programs config constraints

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

* 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

---------

Co-authored-by: Jo D <dev-jodee@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants