diff --git a/yarn-project/protocol-contracts/src/protocol_contract.ts b/yarn-project/protocol-contracts/src/protocol_contract.ts index 6544cdab1209..283cd82df733 100644 --- a/yarn-project/protocol-contracts/src/protocol_contract.ts +++ b/yarn-project/protocol-contracts/src/protocol_contract.ts @@ -20,4 +20,17 @@ export function isProtocolContract(address: AztecAddress) { return Object.values(ProtocolContractAddress).some(a => a.equals(address)); } +/** Returns true if the address is one of the ACTUAL protocol contracts (ContractInstanceRegistry, + * ContractClassRegistry or FeeJuice). + * + * TODO(F-416): Drop this function when protocol contracts are redeployed. + */ +export function isActualProtocolContract(address: AztecAddress) { + return ( + address.equals(ProtocolContractAddress.ContractInstanceRegistry) || + address.equals(ProtocolContractAddress.ContractClassRegistry) || + address.equals(ProtocolContractAddress.FeeJuice) + ); +} + export { type ProtocolContractsProvider } from './provider/protocol_contracts_provider.js'; diff --git a/yarn-project/pxe/src/contract_function_simulator/oracle/oracle.ts b/yarn-project/pxe/src/contract_function_simulator/oracle/oracle.ts index 12d673d745d0..5d17986be4dd 100644 --- a/yarn-project/pxe/src/contract_function_simulator/oracle/oracle.ts +++ b/yarn-project/pxe/src/contract_function_simulator/oracle/oracle.ts @@ -85,13 +85,28 @@ export class Oracle { }); // Build callback object and return it - return oracleNames.reduce((acc, name) => { + const callback = oracleNames.reduce((acc, name) => { const method = this[name as keyof Omit]; acc[name] = method.bind(this); return acc; }, {} as ACIRCallback); + + // Legacy oracle names used by alpha payload protocol contracts (ContractInstanceRegistry, + // ContractClassRegistry, FeeJuice). Their bytecode is committed and cannot be changed. + // TODO(F-416): Remove these aliases on v5 when protocol contracts are redeployed. + const legacyOracles: ACIRCallback = { + utilityLog: this.aztec_utl_log.bind(this), + utilityAssertCompatibleOracleVersion: this.aztec_utl_assertCompatibleOracleVersion.bind(this), + utilityLoadCapsule: this.aztec_utl_loadCapsule.bind(this), + privateStoreInExecutionCache: this.aztec_prv_storeInExecutionCache.bind(this), + privateLoadFromExecutionCache: this.aztec_prv_loadFromExecutionCache.bind(this), + }; + + return { ...callback, ...legacyOracles }; } + // TODO(F-416): This oracle must never change its signature - it is called by the pinned alpha payload protocol + // contracts (ContractInstanceRegistry, ContractClassRegistry, FeeJuice) which cannot be redeployed. // eslint-disable-next-line camelcase aztec_utl_assertCompatibleOracleVersion([version]: ACVMField[]) { this.handlerAsMisc().assertCompatibleOracleVersion(Fr.fromString(version).toNumber()); @@ -104,12 +119,16 @@ export class Oracle { return Promise.resolve([toACVMField(val)]); } + // TODO(F-416): This oracle must never change its signature - it is called by the pinned alpha payload protocol + // contracts (ContractInstanceRegistry, ContractClassRegistry, FeeJuice) which cannot be redeployed. // eslint-disable-next-line camelcase aztec_prv_storeInExecutionCache(values: ACVMField[], [hash]: ACVMField[]): Promise { this.handlerAsPrivate().storeInExecutionCache(values.map(Fr.fromString), Fr.fromString(hash)); return Promise.resolve([]); } + // TODO(F-416): This oracle must never change its signature - it is called by the pinned alpha payload protocol + // contracts (ContractInstanceRegistry, ContractClassRegistry, FeeJuice) which cannot be redeployed. // eslint-disable-next-line camelcase async aztec_prv_loadFromExecutionCache([returnsHash]: ACVMField[]): Promise { const values = await this.handlerAsPrivate().loadFromExecutionCache(Fr.fromString(returnsHash)); @@ -426,6 +445,8 @@ export class Oracle { return Promise.resolve([]); } + // TODO(F-416): This oracle must never change its signature - it is called by the pinned alpha payload protocol + // contracts (ContractInstanceRegistry, ContractClassRegistry, FeeJuice) which cannot be redeployed. // eslint-disable-next-line camelcase async aztec_utl_log( level: ACVMField[], @@ -540,6 +561,8 @@ export class Oracle { return []; } + // TODO(F-416): This oracle must never change its signature - it is called by the pinned alpha payload protocol + // contracts (ContractInstanceRegistry, ContractClassRegistry, FeeJuice) which cannot be redeployed. // eslint-disable-next-line camelcase async aztec_utl_loadCapsule( [contractAddress]: ACVMField[], diff --git a/yarn-project/pxe/src/contract_function_simulator/oracle/utility_execution_oracle.ts b/yarn-project/pxe/src/contract_function_simulator/oracle/utility_execution_oracle.ts index dfb66ce833e3..17c8138a0fd9 100644 --- a/yarn-project/pxe/src/contract_function_simulator/oracle/utility_execution_oracle.ts +++ b/yarn-project/pxe/src/contract_function_simulator/oracle/utility_execution_oracle.ts @@ -6,6 +6,7 @@ import { Point } from '@aztec/foundation/curves/grumpkin'; import { LogLevels, type Logger, createLogger } from '@aztec/foundation/log'; import type { MembershipWitness } from '@aztec/foundation/trees'; import type { KeyStore } from '@aztec/key-store'; +import { isActualProtocolContract } from '@aztec/protocol-contracts'; import type { AuthWitness } from '@aztec/stdlib/auth-witness'; import { AztecAddress } from '@aztec/stdlib/aztec-address'; import { BlockHash } from '@aztec/stdlib/block'; @@ -109,6 +110,12 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra } public assertCompatibleOracleVersion(version: number): void { + // Alpha payload protocol contracts (ContractInstanceRegistry, ContractClassRegistry, FeeJuice) shipped with + // committed bytecode that cannot be changed. Skip the version check for these contracts. + // TODO(F-416): Remove this hack on v5 when protocol contracts are redeployed. + if (isActualProtocolContract(this.contractAddress)) { + return; + } if (version !== ORACLE_VERSION) { throw new Error(`Incompatible oracle version. Expected version ${ORACLE_VERSION}, got ${version}.`); }