diff --git a/noir-projects/labs/aztec-nr/aztec/src/test/helpers/mod.nr b/noir-projects/labs/aztec-nr/aztec/src/test/helpers/mod.nr index 1732db45a308..1c3df4620ed9 100644 --- a/noir-projects/labs/aztec-nr/aztec/src/test/helpers/mod.nr +++ b/noir-projects/labs/aztec-nr/aztec/src/test/helpers/mod.nr @@ -5,11 +5,8 @@ pub mod test_environment; @[ quote { get_last_tx_effects_oracle }, // TODO: implement once we support more complex types quote { get_last_call_offchain_effects_oracle }, // TODO: implement once we support more complex types - quote { get_last_call_context }, // TODO: implement once we support more complex types quote { get_private_events_oracle }, // TODO: implement once we support more complex types quote { deploy_oracle }, // TODO: implement once we support more complex types - quote { create_account }, // TODO: implement once we support more complex types - quote { add_account }, // TODO: implement once we support more complex types quote { private_call_new_flow_oracle }, // TODO: implement once we support more complex types quote { public_call_new_flow_oracle }, // TODO: implement once we support more complex types quote { set_private_txe_context_oracle }, // TODO: implement once we support more complex types diff --git a/noir-projects/labs/aztec-nr/aztec/src/test/helpers/txe_oracles.nr b/noir-projects/labs/aztec-nr/aztec/src/test/helpers/txe_oracles.nr index 54cbf803d8f0..d441a25d0859 100644 --- a/noir-projects/labs/aztec-nr/aztec/src/test/helpers/txe_oracles.nr +++ b/noir-projects/labs/aztec-nr/aztec/src/test/helpers/txe_oracles.nr @@ -189,6 +189,7 @@ unconstrained fn get_last_call_offchain_effects_oracle() -> ([[Field; MAX_OFFCHA /// The context of the last top-level call into TXE, as captured by the call executor. Refreshed on /// every top-level call. +#[derive(Eq)] pub struct TXECallContext { /// Tx hash of the top-level call, or `None` if the call was tx-less (`execute_utility`, context /// setters, etc.). diff --git a/noir-projects/labs/aztec-nr/aztec/src/test/helpers/utils.nr b/noir-projects/labs/aztec-nr/aztec/src/test/helpers/utils.nr index 32806b7141f3..91085fae094d 100644 --- a/noir-projects/labs/aztec-nr/aztec/src/test/helpers/utils.nr +++ b/noir-projects/labs/aztec-nr/aztec/src/test/helpers/utils.nr @@ -123,7 +123,7 @@ impl ContractDeployment { } } -#[derive(Deserialize, Serialize)] +#[derive(Deserialize, Eq, Serialize)] pub struct TestAccount { pub address: AztecAddress, pub keys: PublicKeys, diff --git a/yarn-project/pxe/src/contract_function_simulator/index.ts b/yarn-project/pxe/src/contract_function_simulator/index.ts index 64d3cde6661f..de3411793a4b 100644 --- a/yarn-project/pxe/src/contract_function_simulator/index.ts +++ b/yarn-project/pxe/src/contract_function_simulator/index.ts @@ -34,6 +34,7 @@ export { PENDING_TAGGED_LOG, POINT, PROVIDED_SECRET, + PUBLIC_KEYS, SCALAR, SLOT_NUMBER, STR, diff --git a/yarn-project/pxe/src/contract_function_simulator/oracle/oracle_type_mappings.ts b/yarn-project/pxe/src/contract_function_simulator/oracle/oracle_type_mappings.ts index f132ddc11d6c..30208ee2e1a3 100644 --- a/yarn-project/pxe/src/contract_function_simulator/oracle/oracle_type_mappings.ts +++ b/yarn-project/pxe/src/contract_function_simulator/oracle/oracle_type_mappings.ts @@ -373,7 +373,7 @@ export const KEY_VALIDATION_REQUEST: TypeMapping = STRUCT< { name: 'skApp', type: FIELD }, ]); -const PUBLIC_KEYS: TypeMapping = STRUCT([ +export const PUBLIC_KEYS: TypeMapping = STRUCT([ { name: 'npkMHash', type: FIELD }, { name: 'ivpkM', type: POINT }, { name: 'ovpkMHash', type: FIELD }, diff --git a/yarn-project/txe/src/oracle/txe_oracle_registry.ts b/yarn-project/txe/src/oracle/txe_oracle_registry.ts index 6af26eaedf93..410188ee2d19 100644 --- a/yarn-project/txe/src/oracle/txe_oracle_registry.ts +++ b/yarn-project/txe/src/oracle/txe_oracle_registry.ts @@ -25,8 +25,10 @@ import { type MaybePromise, OPTION, ORACLE_REGISTRY, + type Option, type OracleRegistryEntry, type OutputSlot, + PUBLIC_KEYS, type ParamTypes, SCALAR, STR, @@ -120,11 +122,10 @@ const PRIVATE_CONTEXT_INPUTS: TypeMapping = LEAF({ shape: Array(PRIVATE_CONTEXT_INPUTS_LENGTH).fill('scalar'), }); -const COMPLETE_ADDRESS: TypeMapping = LEAF({ - kind: 'complete-address', - serialization: { fn: v => [v.address.toField(), ...v.publicKeys.toFields()] }, - shape: Array(8).fill('scalar'), // address + 7 public-key fields -}); +const COMPLETE_ADDRESS: TypeMapping = STRUCT([ + { name: 'address', type: AZTEC_ADDRESS }, + { name: 'publicKeys', type: PUBLIC_KEYS }, +]); const TXE_TX_EFFECTS: TypeMapping<{ txHash: TxHash; @@ -198,16 +199,10 @@ const TXE_OFFCHAIN_EFFECTS: TypeMapping<{ effects: Fr[][] }> = LEAF({ ], }); -const TXE_CALL_CONTEXT: TypeMapping<{ txHash: Fr; anchorBlockTimestamp: bigint }> = LEAF({ - kind: 'txe-call-context', - serialization: { - fn: ({ txHash, anchorBlockTimestamp }) => { - const isSome = txHash.isZero() ? 0 : 1; - return [new Fr(isSome), txHash, new Fr(anchorBlockTimestamp)]; - }, - }, - shape: ['scalar', 'scalar', 'scalar'], // discriminant, txHash, anchor block timestamp -}); +const TXE_CALL_CONTEXT: TypeMapping<{ txHash: Option; anchorBlockTimestamp: bigint }> = STRUCT([ + { name: 'txHash', type: OPTION(FIELD) }, + { name: 'anchorBlockTimestamp', type: U64 }, +]); const CONTRACT_INSTANCE_MEMBER: TypeMapping<{ exists: boolean; member: Fr }[]> = FIXED_ARRAY( STRUCT([ diff --git a/yarn-project/txe/src/oracle/txe_oracle_version.ts b/yarn-project/txe/src/oracle/txe_oracle_version.ts index ce716ebde46b..db2e75b476b5 100644 --- a/yarn-project/txe/src/oracle/txe_oracle_version.ts +++ b/yarn-project/txe/src/oracle/txe_oracle_version.ts @@ -14,4 +14,4 @@ export const TXE_ORACLE_VERSION_MINOR = 1; * - TXE_ORACLE_VERSION_MAJOR (and reset MINOR to 0) for breaking changes, or * - TXE_ORACLE_VERSION_MINOR for additive changes (new oracle method added). */ -export const TXE_ORACLE_INTERFACE_HASH = '1a6c578d0a47cd8dd7dae07fd00abe781225a73920c596d873afcc061c0e4284'; +export const TXE_ORACLE_INTERFACE_HASH = '86d900da6ca21d8dee76b790175aaaee9e865bf99950844e2dc727250fe14a40'; diff --git a/yarn-project/txe/src/txe_session.ts b/yarn-project/txe/src/txe_session.ts index 92b475a5c576..9eddfbf60d26 100644 --- a/yarn-project/txe/src/txe_session.ts +++ b/yarn-project/txe/src/txe_session.ts @@ -193,11 +193,11 @@ export interface TXESessionStateHandler { getLastCallOffchainEffects(): { effects: Fr[][] }; /** - * Returns the context of the last top-level call: its tx hash (`Fr.ZERO` if the call was tx-less) and the anchor + * Returns the context of the last top-level call: its tx hash (absent if the call was tx-less) and the anchor * block timestamp captured at the start of the call. Does *not* mark the buffer as queried — context reads are * metadata, not effect consumption. */ - getLastCallContext(): { txHash: Fr; anchorBlockTimestamp: bigint }; + getLastCallContext(): { txHash: Option; anchorBlockTimestamp: bigint }; } /** @@ -218,10 +218,10 @@ interface LastCallState { */ queried: boolean; /** - * Tx hash of the most recently completed top-level call, or `Fr.ZERO` if the call was tx-less (context setters, - * utility execution). Populated by call executor handlers after execution completes. + * Tx hash of the most recently completed top-level call, absent if the call was tx-less (context setters, utility + * execution). Populated by call executor handlers after execution completes. */ - txHash: Fr; + txHash: Option; /** * Anchor block timestamp of the most recently completed top-level call, captured from the anchor block header that * was active when the call started. Populated by call executor handlers after execution completes. @@ -230,7 +230,7 @@ interface LastCallState { } function emptyLastCallState(): LastCallState { - return { offchainEffects: [], queried: false, txHash: Fr.ZERO, anchorBlockTimestamp: 0n }; + return { offchainEffects: [], queried: false, txHash: Option.none(), anchorBlockTimestamp: 0n }; } /** @@ -495,7 +495,7 @@ export class TXESession implements TXESessionStateHandler { this.lastCallInfo.offchainEffects.push(data); } - private setLastCallContext(txHash: Fr, anchorBlockTimestamp: bigint): void { + private setLastCallContext(txHash: Option, anchorBlockTimestamp: bigint): void { this.lastCallInfo.txHash = txHash; this.lastCallInfo.anchorBlockTimestamp = anchorBlockTimestamp; } @@ -507,7 +507,7 @@ export class TXESession implements TXESessionStateHandler { const anchorBlockTimestamp = (await this.stateMachine.node.getBlockData('latest'))!.header.globalVariables .timestamp; const { result, txHash } = await work(); - this.setLastCallContext(txHash ?? Fr.ZERO, anchorBlockTimestamp); + this.setLastCallContext(txHash ? Option.some(txHash) : Option.none(), anchorBlockTimestamp); return result; } @@ -525,7 +525,7 @@ export class TXESession implements TXESessionStateHandler { return { effects }; } - getLastCallContext(): { txHash: Fr; anchorBlockTimestamp: bigint } { + getLastCallContext(): { txHash: Option; anchorBlockTimestamp: bigint } { const { txHash, anchorBlockTimestamp } = this.lastCallInfo; return { txHash, anchorBlockTimestamp }; } @@ -794,7 +794,7 @@ export class TXESession implements TXESessionStateHandler { // Record the *resolved* anchor's timestamp — if the caller pinned the anchor to a past block // via `anchorBlockNumber`, "latest" would be the wrong anchor for offchain-message semantics. - this.setLastCallContext(Fr.ZERO, anchorBlock!.globalVariables.timestamp); + this.setLastCallContext(Option.none(), anchorBlock!.globalVariables.timestamp); return (this.oracleHandler as TXEPrivateExecutionOracle).getPrivateContextInputs(); } @@ -826,7 +826,7 @@ export class TXESession implements TXESessionStateHandler { this.logger.debug(`Entered state ${this.state.name}`); // Public state is anchored at the latest block. - this.setLastCallContext(Fr.ZERO, latestHeader.globalVariables.timestamp); + this.setLastCallContext(Option.none(), latestHeader.globalVariables.timestamp); } async enterUtilityState(contractAddressOpt: Option) { @@ -889,7 +889,7 @@ export class TXESession implements TXESessionStateHandler { this.logger.debug(`Entered state ${this.state.name}`); // Utility state anchors at whatever the anchor block store is pointing to (tracked as latest). - this.setLastCallContext(Fr.ZERO, anchorBlockHeader.globalVariables.timestamp); + this.setLastCallContext(Option.none(), anchorBlockHeader.globalVariables.timestamp); } private exitTopLevelState() {