-
Notifications
You must be signed in to change notification settings - Fork 597
feat(txe): add oracle versioning for test environment #23285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
a0f839e
af51d26
f5869c8
cc8d41b
f053db6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| /** | ||
| * The TXE oracle version constants are used to check that the oracle interface used for tests is in sync between | ||
| * TXE and Aztec.nr. This is separate from the contract oracle version in `pxe/src/oracle_version.ts`, which covers | ||
| * oracles used during contract execution by PXE. | ||
| * | ||
| * The Noir counterparts are in `noir-projects/aztec-nr/aztec/src/test/helpers/txe_oracles.nr`. | ||
| */ | ||
| export const TXE_ORACLE_VERSION_MAJOR = 1; | ||
| export const TXE_ORACLE_VERSION_MINOR = 0; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,7 @@ import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context. | |
| import { RPCTranslator } from './rpc_translator.js'; | ||
| import { TXEArchiver } from './state_machine/archiver.js'; | ||
| import { TXEStateMachine } from './state_machine/index.js'; | ||
| import { TXE_ORACLE_VERSION_MAJOR, TXE_ORACLE_VERSION_MINOR } from './txe_oracle_version.js'; | ||
| import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js'; | ||
| import { TXEAccountStore } from './util/txe_account_store.js'; | ||
| import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js'; | ||
|
|
@@ -109,6 +110,9 @@ export type TXEOracleFunctionName = Exclude< | |
| >; | ||
|
|
||
| export interface TXESessionStateHandler { | ||
| /** Records the TXE oracle version reported by the Noir test code for diagnostics. */ | ||
| setTxeOracleVersion(version: { major: number; minor: number }): void; | ||
|
|
||
| enterTopLevelState(): Promise<void>; | ||
| enterPublicState(contractAddress?: AztecAddress): Promise<void>; | ||
| enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?: BlockNumber): Promise<PrivateContextInputs>; | ||
|
|
@@ -186,6 +190,7 @@ export class TXESession implements TXESessionStateHandler { | |
| private state: SessionState = { name: 'TOP_LEVEL' }; | ||
| private authwits: Map<string, AuthWitness> = new Map(); | ||
| private lastCallInfo: LastCallState = emptyLastCallState(); | ||
| private txeOracleVersion: { major: number; minor: number } | undefined; | ||
|
|
||
| constructor( | ||
| private logger: Logger, | ||
|
|
@@ -306,7 +311,28 @@ export class TXESession implements TXESessionStateHandler { | |
| return translator[validatedFunctionName](...inputs); | ||
| } catch (error) { | ||
| if (error instanceof z.ZodError) { | ||
| throw new Error(`${functionName} does not correspond to any oracle handler available on RPCTranslator`); | ||
| let versionHint: string; | ||
| if (!this.txeOracleVersion) { | ||
| versionHint = | ||
| ' The test appears to have been compiled with an older version of Aztec.nr that does not' + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| ' support test environment oracle versioning. Recompile the test with a compatible version of Aztec.nr.' + | ||
| ' 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` + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests are not compiled, rather 'the test uses aztecnr vx.y' etc |
||
| ` ${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.` + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. upgrade the aztec cli, not 'the test env' |
||
| ` See https://docs.aztec.network/errors/12`; | ||
| } else { | ||
| versionHint = | ||
| ` 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.`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } | ||
| throw new Error(`Unknown oracle '${functionName}'.${versionHint}`); | ||
| } else if (error instanceof Error) { | ||
| throw new Error( | ||
| `Execution error while processing function ${functionName} in state ${this.state.name}: ${error.message}`, | ||
|
|
@@ -375,6 +401,11 @@ export class TXESession implements TXESessionStateHandler { | |
| return { txHash, anchorBlockTimestamp }; | ||
| } | ||
|
|
||
| setTxeOracleVersion(version: { major: number; minor: number }): void { | ||
| this.txeOracleVersion = version; | ||
| this.logger.debug(`Test compiled with test oracle version ${version.major}.${version.minor}`); | ||
| } | ||
|
|
||
| async enterTopLevelState() { | ||
| switch (this.state.name) { | ||
| case 'PRIVATE': { | ||
|
|
||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good chamo