Skip to content

refactor: move validation and error handling out of transport layer#23422

Merged
nchamo merged 4 commits into
merge-train/fairiesfrom
nchamo/lean-transport-layer
May 21, 2026
Merged

refactor: move validation and error handling out of transport layer#23422
nchamo merged 4 commits into
merge-train/fairiesfrom
nchamo/lean-transport-layer

Conversation

@nchamo
Copy link
Copy Markdown
Contributor

@nchamo nchamo commented May 20, 2026

Why we are doing this

rpc_translator.ts and oracle.ts were mixing serialization/deserialization with validation, error handling, and orchestration logic, making it hard to reason about and difficult to auto-generate in the future.

Our fix

Validation, null checks, bounds enforcement, forbidden-operation throws, and the version compatibility check have all moved into the handler layer:

  • Null-check-and-throw for six oracle methods (getNoteHashMembershipWitness, getNullifierMembershipWitness, getLowNullifierMembershipWitness,getPublicDataWitness, getBlockHeader, getAuthWitness) — handlers now return non-optional values and throw when the lookup fails.
  • Forbidden operations are enforced in handler subclasses (TXEPrivateExecutionOracle, TXEOraclePublicContext) by overriding methods to throw; the transport calls the handler without knowing the difference.
  • Bounds validation (MAX_PRIVATE_LOGS_PER_TX, offchain-effects length) moved into handlers.
  • Decryption failure handling moved to handler (returns Buffer | undefined; transport no longer catches).
  • Version compatibility check moved to TXESession.setTxeOracleVersion().
  • MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY and MAX_OFFCHAIN_EFFECT_LEN moved from txe_oracle_version.ts to txe_session.ts, co-located with the validation that uses them.

The transport is now pure serialize → delegate → deserialize. No behavior change.

@nchamo nchamo self-assigned this May 20, 2026
@nchamo nchamo force-pushed the nchamo/lean-transport-layer branch from 952b906 to 4d3378e Compare May 20, 2026 08:00
@nchamo nchamo requested a review from mverzilli May 20, 2026 08:32
@nchamo nchamo changed the title refactor(txe): move validation and error handling out of transport layer refactor: move validation and error handling out of transport layer May 20, 2026
…/lean-transport-layer

# Conflicts:
#	yarn-project/txe/src/rpc_translator.ts
Comment thread yarn-project/txe/src/oracle/interfaces.ts
Copy link
Copy Markdown
Contributor

@mverzilli mverzilli left a comment

Choose a reason for hiding this comment

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

🧹

@nchamo nchamo merged commit e2a3ae3 into merge-train/fairies May 21, 2026
14 checks passed
@nchamo nchamo deleted the nchamo/lean-transport-layer branch May 21, 2026 13:33
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.

2 participants