Skip to content

feat(txe): add oracle versioning for test environment#23285

Merged
nchamo merged 5 commits into
merge-train/fairiesfrom
nchamo/f-648-add-txe-version-oracle
May 14, 2026
Merged

feat(txe): add oracle versioning for test environment#23285
nchamo merged 5 commits into
merge-train/fairiesfrom
nchamo/f-648-add-txe-version-oracle

Conversation

@nchamo
Copy link
Copy Markdown
Contributor

@nchamo nchamo commented May 14, 2026

Why we are doing this

PXE already has oracle versioning: every contract function begins with an assertCompatibleOracleVersion call, and PXE stores the contract's major.minor so that unknown-oracle errors include an actionable hint. The TXE test environment had nothing equivalent — an unknown oracle just gave an opaque dispatch error with no version context.

Our fix

Mirrors the PXE pattern for TXE, with a separate version namespace (TXE_ORACLE_VERSION_MAJOR/MINOR) to track the TXE-specific oracle interface independently.

At startup (TestEnvironment::new()), a new aztec_txe_assertCompatibleOracleVersion oracle call enforces a strict major-version check. On mismatch:

  • PXE: Incompatible private environment version: The contract was compiled with a newer/older version of Aztec.nr than your private environment supports. [...] See /errors/8 (expected oracle major version X, got Y)
  • TXE: Incompatible test environment version: The test was compiled with a newer/older version of Aztec.nr than your test environment supports. [...] See /errors/12 (expected test oracle major version X, got Y)

When an unknown oracle is called, TXE uses the stored minor version for three-way diagnostics (same logic as PXE's Proxy-based handler):

Case 1 — no version stored (version check was never called):

  • PXE: Oracle 'X' not found and the contract's oracle version is unknown (the version check oracle was not called before 'X'). This usually means the contract was not compiled with the #[aztec] macro, which injects the version check as the first oracle call in every private/utility external function. If you're using a custom entry point, ensure assert_compatible_oracle_version() is called before any other oracle calls. See /errors/8
  • TXE: Unknown oracle 'X'. The test appears to have been compiled with an older version of Aztec.nr that does not support test environment oracle versioning. Recompile the test with a compatible version of Aztec.nr. See /errors/12

Case 2 — minor version too high (test needs oracles this env doesn't have):

  • PXE: Oracle 'X' not found. This usually means the contract requires a newer private execution environment than you have. Upgrade your private execution environment to a compatible version. The contract was compiled with Aztec.nr oracle version A.B, but this private execution environment only supports up to C.D. See /errors/8
  • TXE: Unknown oracle 'X'. The test was compiled with Aztec.nr test oracle version A.B, but this test environment only supports up to C.D. Upgrade your test environment to a compatible version. See /errors/12

Case 3 — versions compatible (likely a bug):

  • PXE: Oracle 'X' not found. The contract's oracle version (A.B) is compatible with this private execution environment (C.D), so all standard oracles should be available. This could mean the contract was compiled against a modified version of Aztec.nr, or that it references an oracle that does not exist. See /errors/8
  • TXE: Unknown oracle 'X'. The test's oracle version (A.B) is compatible with this test environment (C.D), so all standard oracles should be available. This could mean the test was compiled against a modified version of Aztec.nr, or that it references an oracle that does not exist.

Not yet implemented: automatically detecting changes to the TXE oracle interface (the CI hash check that PXE has in check_oracle_version.ts). TXE oracles are spread across rpc_translator.ts and session handlers rather than a single Oracle class, making it harder to extract a clean interface to hash. Tracked in F-667.

Fixes F-648

@nchamo nchamo requested a review from nventuro as a code owner May 14, 2026 16:46
@nchamo nchamo self-assigned this May 14, 2026
@nchamo nchamo added ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure backport-to-v4-next labels May 14, 2026

:::warning
Always use `aztec test` instead of `nargo test`. The `TestEnvironment` requires the TXE (Test eXecution Environment) oracle resolver.
Always use `aztec test` instead of `nargo test`. The `TestEnvironment` requires the test environment oracle resolver provided by the `aztec` CLI.
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'm trying to remove the term "TXE" from all user facing docs/errors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

good chamo

@nchamo nchamo requested a review from dbanks12 May 14, 2026 17:46

:::warning
Always use `aztec test` instead of `nargo test`. The `TestEnvironment` requires the TXE (Test eXecution Environment) oracle resolver.
Always use `aztec test` instead of `nargo test`. The `TestEnvironment` requires the test environment oracle resolver provided by the `aztec` CLI.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

good chamo

Comment thread yarn-project/txe/src/txe_session.ts Outdated
` The test was compiled with Aztec.nr test oracle version` +
` ${this.txeOracleVersion.major}.${this.txeOracleVersion.minor}, but this test environment` +
` only supports up to ${TXE_ORACLE_VERSION_MAJOR}.${TXE_ORACLE_VERSION_MINOR}.` +
` Upgrade your test environment to a compatible version.` +
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

upgrade the aztec cli, not 'the test env'

Comment thread yarn-project/txe/src/txe_session.ts Outdated
' See https://docs.aztec.network/errors/12';
} else if (this.txeOracleVersion.minor > TXE_ORACLE_VERSION_MINOR) {
versionHint =
` The test was compiled with Aztec.nr test oracle version` +
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tests are not compiled, rather 'the test uses aztecnr vx.y' etc

Comment thread yarn-project/txe/src/txe_session.ts Outdated
let versionHint: string;
if (!this.txeOracleVersion) {
versionHint =
' The test appears to have been compiled with an older version of Aztec.nr that does not' +
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same comment re. test compilation. may make people think they need to recompile contracts, which they dont

Comment thread yarn-project/txe/src/txe_session.ts Outdated
Comment on lines +329 to +333
` The test's oracle version (${this.txeOracleVersion.major}.${this.txeOracleVersion.minor})` +
` is compatible with this test environment` +
` (${TXE_ORACLE_VERSION_MAJOR}.${TXE_ORACLE_VERSION_MINOR}), so all standard oracles should` +
` be available. This could mean the test was compiled against a modified version of Aztec.nr,` +
` or that it references an oracle that does not exist.`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i don't think this message clearly conveys that we don't know wtf is wrong

@nchamo nchamo merged commit 76b6290 into merge-train/fairies May 14, 2026
14 checks passed
@nchamo nchamo deleted the nchamo/f-648-add-txe-version-oracle branch May 14, 2026 19:10
@AztecBot
Copy link
Copy Markdown
Collaborator

✅ Successfully backported to backport-to-v4-next-staging #23291.

nchamo added a commit that referenced this pull request May 14, 2026
BEGIN_COMMIT_OVERRIDE
feat(txe): add oracle versioning for test environment (#23285)
feat: add basic gas settings to testenv (#23289)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v4-next ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants