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
github-merge-queue Bot pushed a commit that referenced this pull request May 25, 2026
BEGIN_COMMIT_OVERRIDE
feat(txe): add TXE oracle version check to bootstrap (#23324)
fix(txe): correct TXE_ORACLE_INTERFACE_HASH to match current oracle
interface (#23460)
feat(aztec-nr): add Serialize/Deserialize for EphemeralArray (#23417)
refactor: move validation and error handling out of transport layer
(#23422)
feat(pxe)!: add source and block-range filtering to get_logs_by_tag
(#23326)
fix(txe): update TXE oracle interface hash for new AVM oracle methods
(#23492)
chore(ci): capture sandbox diagnostics on acceptance test failure
(#23495)
feat(aztec-nr)!: rename push_nullifier to push_nullifier_unsafe (#23488)
feat(aztec-nr)!: add explicit custom_sync_state hook to AztecConfig
(#23446)
fix(ci): skip aztec-cli notify job when acceptance test is skipped
(#23534)
fix: released contract artifact aztec version (forward port of #23470)
(#23500)
fix: merge train conflicts (#23548)
END_COMMIT_OVERRIDE
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