Skip to content

refactor(txe): migrate rpc_translator to typed oracle registry#23530

Draft
nchamo wants to merge 3 commits into
nchamo/registry-introductionfrom
nchamo/txe-oracle-registry
Draft

refactor(txe): migrate rpc_translator to typed oracle registry#23530
nchamo wants to merge 3 commits into
nchamo/registry-introductionfrom
nchamo/txe-oracle-registry

Conversation

@nchamo
Copy link
Copy Markdown
Contributor

@nchamo nchamo commented May 23, 2026

Summary

  • Extends the typed oracle registry introduced in refactor(pxe): introduce typed oracle registry for serialization #23516 to cover TXE-specific oracle calls, adding type mappings for TXE domain types (TXE_TX_EFFECTS, TXE_OFFCHAIN_EFFECTS, TXE_CALL_CONTEXT, CONTRACT_INSTANCE_MEMBER, TXE_PRIVATE_EVENTS, etc.).
  • Migrates all rpc_translator handlers to use callTxeHandler with typed serialization/deserialization, so handlers become pure domain-type passthroughs.
  • Some handlers (privateCallNewFlow, executeUtilityFunction, publicCallNewFlow) still contain orchestration logic (tracked by TODO(F-674)) that will be tackled in a follow-up.

@nchamo nchamo self-assigned this May 23, 2026
import { packAsHintedNote } from './note_packing_utils.js';

const FIELD: TypeMapping<Fr> = {
export const FIELD: TypeMapping<Fr> = {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We export the ones we need over at TXE's registry

nullifierExists(siloedNullifier: Fr): Promise<boolean>;
storageWrite(slot: Fr, value: Fr): Promise<void>;
storageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr>;
getContractInstanceDeployer(address: AztecAddress): Promise<{ member: Fr; exists: boolean }>;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Previously, oracles like aztec_avm_getContractInstanceDeployer did something like this:

{ 
    const address = addressFromSingle(foreignAddress);
    const instance = await this.handlerAsUtility().getContractInstance(address);
    return toForeignCallResult([
      toSingle(instance.deployer),
      // AVM requires an extra boolean indicating the instance was found
      toSingle(new Fr(1)),
    ]);
}

The thing is that we needed to get this logic out of rpc_translator.ts. I considered a few different options, but I decided that it would be best to add this logic to the avm handler

If you think about it, we want to get to an auto-generated world where the oracle call aztec_avm_getContractInstanceDeployer auto-generates the function getContractInstanceDeployer on the interface. So I decided to do exactly that, but manually for now

})
).map(e => e.packedEvent);

if (events.length > MAX_PRIVATE_EVENTS_PER_TXE_QUERY) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved here this logic that was previously on rpc_translator.ts

return callTxeHandler({
oracle: 'aztec_txe_getPrivateEvents',
inputs,
handler: async ([selector, contractAddress, scope]) => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This one needs more work. It would require a bigger refactor to have this be only a thin transport layer, so I decided to do that in future PR

* - TXE_ORACLE_VERSION_MINOR for additive changes (new oracle method added).
*/
export const TXE_ORACLE_INTERFACE_HASH = '833b77ccdba925b1ed129028432c7d4b116867fb426cee40f9d6104c5aa31e42';
export const TXE_ORACLE_INTERFACE_HASH = 'e191c3083fae4aed4802d9fe8f2fbf3366dcbd058b2096c24be1110250f40db2';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hash changed because we added new functions to the ts interface, but we didn't actually change the oracles. So no version bump

deserialization: { fn: ([reader]) => reader.readField().toNumber() },
};

export const BIGINT: TypeMapping<bigint> = {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I decided to add here some of the mappings we need for TXE, but that we would probably need for PXE in the future

@nchamo nchamo marked this pull request as draft May 23, 2026 17:45
@nchamo nchamo requested a review from mverzilli May 23, 2026 17:48
@nchamo nchamo added the ci-draft Run CI on draft PRs. label May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-draft Run CI on draft PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant