Skip to content

feat: add midnight_validateTransaction RPC endpoint with detailed errors#867

Draft
ozgb wants to merge 7 commits intomainfrom
ozgb-validate-transaction-rpc
Draft

feat: add midnight_validateTransaction RPC endpoint with detailed errors#867
ozgb wants to merge 7 commits intomainfrom
ozgb-validate-transaction-rpc

Conversation

@ozgb
Copy link
Contributor

@ozgb ozgb commented Mar 5, 2026

Overview

Addresses https://shielded.atlassian.net/browse/PM-21415 using @kapke 's suggestion for a new RPC endpoint

  • Exposes a rate-limited RPC endpoint for transaction validation
  • Implemented as RPC to mitigate DOS attacks (can't do rate limiting on runtime calls)
  • Draft only for now - do we need this for mainnet?

🗹 TODO before merging

  • Ready
  • Remove runtime changes to make this change client-only
  • Extension: Add an RPC for a full validate-then-try-applying RPC (?)

📌 Submission Checklist

  • Changes are backward-compatible (or flagged if breaking)
  • Pull request description explains why the change is needed
  • Self-reviewed the diff
  • I have included a change file, or skipped for this reason:
  • If the changes introduce a new feature, I have bumped the node minor version
  • Update documentation (if relevant)
  • Updated AGENTS.md if build commands, architecture, or workflows changed
  • No new todos introduced

🧪 Testing Evidence

Please describe any additional testing aside from CI:

  • Additional tests are provided (if possible)

🔱 Fork Strategy

  • Node Runtime Update
  • Node Client Update
  • Other:
  • N/A

Links

ozgb added 6 commits March 5, 2026 15:00
Add a new RPC endpoint that validates transactions natively and returns
detailed error information including the original error data that was
previously lost during lossy type conversions. The endpoint is rate
limited via governor with configurable global and per-transaction limits.

Validation dispatches to the correct ledger version (ledger_8 or
hard_fork_test) based on the runtime's reported ledger version, and
returns a version-agnostic ValidationError with error_code, reason,
and details fields.

JIRA: PM-21415
Extract the native_api module from an inline definition in lib.rs
to a dedicated ledger/src/native_api.rs file.
@ozgb ozgb changed the title Ozgb validate transaction rpc feat: add midnight_validateTransaction RPC endpoint with detailed errors Mar 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

kics-logo

KICS version: v2.1.19

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 47
LOW LOW 3
INFO INFO 59
TRACE TRACE 0
TOTAL TOTAL 109
Metric Values
Files scanned placeholder 26
Files parsed placeholder 26
Files failed to scan placeholder 0
Total executed queries placeholder 73
Queries failed to execute placeholder 0
Execution time placeholder 11

…ries

Read validation context directly from storage in the RPC layer instead
of going through a dedicated runtime API, avoiding a runtime API version
bump. StateKey, ParentTimestamp, and Timestamp::Now are read via
storage queries; spec_version via CallApiAt::runtime_version_at;
max_block_weight is passed from the node as a config value.
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.

1 participant