diff --git a/yarn-project/acir-simulator/src/acvm/acvm.ts b/yarn-project/acir-simulator/src/acvm/acvm.ts index 38d646e46f7..7b164ec38cb 100644 --- a/yarn-project/acir-simulator/src/acvm/acvm.ts +++ b/yarn-project/acir-simulator/src/acvm/acvm.ts @@ -25,6 +25,7 @@ export interface ACIRCallback { notifyCreatedNote(params: ACVMField[]): Promise<[ACVMField]>; notifyNullifiedNote(params: ACVMField[]): Promise<[ACVMField]>; callPrivateFunction(params: ACVMField[]): Promise; + callPublicFunction(params: ACVMField[]): Promise; storageRead(params: ACVMField[]): Promise<[ACVMField]>; storageWrite(params: ACVMField[]): Promise<[ACVMField]>; viewNotesPage(params: ACVMField[]): Promise; diff --git a/yarn-project/acir-simulator/src/client/private_execution.ts b/yarn-project/acir-simulator/src/client/private_execution.ts index b6de3444216..a8834319aba 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.ts @@ -157,6 +157,7 @@ export class PrivateFunctionExecution { viewNotesPage: notAvailable, storageRead: notAvailable, storageWrite: notAvailable, + callPublicFunction: notAvailable, }); const publicInputs = extractPublicInputs(partialWitness, acir); diff --git a/yarn-project/acir-simulator/src/client/unconstrained_execution.ts b/yarn-project/acir-simulator/src/client/unconstrained_execution.ts index 86caf832e95..5ad5c60caa7 100644 --- a/yarn-project/acir-simulator/src/client/unconstrained_execution.ts +++ b/yarn-project/acir-simulator/src/client/unconstrained_execution.ts @@ -58,6 +58,7 @@ export class UnconstrainedFunctionExecution { notifyCreatedNote: notAvailable, notifyNullifiedNote: notAvailable, callPrivateFunction: notAvailable, + callPublicFunction: notAvailable, storageRead: notAvailable, storageWrite: notAvailable, }); diff --git a/yarn-project/acir-simulator/src/public/db.ts b/yarn-project/acir-simulator/src/public/db.ts index 310a97cd629..043304c105d 100644 --- a/yarn-project/acir-simulator/src/public/db.ts +++ b/yarn-project/acir-simulator/src/public/db.ts @@ -1,10 +1,11 @@ +import { EthAddress } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; /** - * The database interface for public functions. + * Database interface for providing access to public state. */ -export interface PublicDB { +export interface PublicStateDB { /** * Reads a value from public storage, returning zero if none. * @param contract - Owner of the storage. @@ -13,3 +14,23 @@ export interface PublicDB { */ storageRead(contract: AztecAddress, slot: Fr): Promise; } + +/** + * Database interface for providing access to public contract data. + */ +export interface PublicContractsDB { + /** + * Returns the brillig (public bytecode) of a function. + * @param address - The contract address that owns this function. + * @param functionSelector - The selector for the function. + * @returns The bytecode or undefined if not found. + */ + getBytecode(address: AztecAddress, functionSelector: Buffer): Promise; + + /** + * Returns the portal contract address for an L2 address. + * @param address - The L2 contract address. + * @returns The portal contract address or undefined if not found. + */ + getPortalContractAddress(address: AztecAddress): Promise; +} diff --git a/yarn-project/acir-simulator/src/public/execution.ts b/yarn-project/acir-simulator/src/public/execution.ts index a57431f9ff7..db04085d521 100644 --- a/yarn-project/acir-simulator/src/public/execution.ts +++ b/yarn-project/acir-simulator/src/public/execution.ts @@ -1,12 +1,4 @@ -import { CallContext, FunctionData, StateRead, StateTransition, TxRequest } from '@aztec/circuits.js'; -import { createDebugLogger } from '@aztec/foundation/log'; -import { select_return_flattened as selectPublicWitnessFlattened } from '@noir-lang/noir_util_wasm'; -import { acvm, fromACVMField, toACVMField, toACVMWitness } from '../acvm/index.js'; -import { PublicDB } from './db.js'; -import { StateActionsCollector } from './state_actions.js'; -import { Fr } from '@aztec/foundation/fields'; -import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { EthAddress } from '@aztec/foundation/eth-address'; +import { AztecAddress, CallContext, Fr, FunctionData, StateRead, StateTransition, TxRequest } from '@aztec/circuits.js'; /** * The public function execution result. @@ -18,113 +10,30 @@ export interface PublicExecutionResult { stateReads: StateRead[]; /** The state transitions performed by the function. */ stateTransitions: StateTransition[]; + /** The results of nested calls. */ + nestedExecutions: this[]; } /** - * Generates the initial witness for a public function. - * @param args - The arguments to the function. - * @param callContext - The call context of the function. - * @param witnessStartIndex - The index where to start inserting the parameters. - * @returns The initial witness. + * The execution of a public function. */ -function getInitialWitness(args: Fr[], callContext: CallContext, witnessStartIndex = 1) { - return toACVMWitness(witnessStartIndex, [ - callContext.isContractDeployment, - callContext.isDelegateCall, - callContext.isStaticCall, - callContext.msgSender, - callContext.portalContractAddress, - callContext.storageContractAddress, - ...args, - ]); +export interface PublicExecution { + /** Address of the contract being executed. */ + contractAddress: AztecAddress; + /** Function of the contract being called. */ + functionData: FunctionData; + /** Arguments for the call. */ + args: Fr[]; + /** Context of the call. */ + callContext: CallContext; } /** - * The public function execution class. + * Returns whether the input is a public execution. + * @param input - Input to check. + * @returns Whether it's a public execution. */ -export class PublicExecution { - constructor( - /** The public database. */ - public readonly db: PublicDB, - /** The ACIR bytecode of the public function. */ - public readonly publicFunctionBytecode: Buffer, - /** The address of the contract to execute. */ - public readonly contractAddress: AztecAddress, - /** The function data of the function to execute. */ - public readonly functionData: FunctionData, - /** The arguments of the function to execute. */ - public readonly args: Fr[], - /** The call context of the execution. */ - public readonly callContext: CallContext, - - private log = createDebugLogger('aztec:simulator:public-execution'), - ) {} - - /** - * Creates a public function execution from a transaction request. - * @param db - The public database. - * @param request - The transaction request. - * @param bytecode - The bytecode of the public function. - * @param portalContractAddress - The address of the portal contract. - * @returns The public function execution. - */ - static fromTransactionRequest(db: PublicDB, request: TxRequest, bytecode: Buffer, portalContractAddress: EthAddress) { - const contractAddress = request.to; - const callContext: CallContext = new CallContext( - request.from, - request.to, - portalContractAddress, - false, - false, - false, - ); - return new this(db, bytecode, contractAddress, request.functionData, request.args, callContext); - } - - /** - * Executes the public function. - * @returns The execution result. - */ - public async run(): Promise { - const selectorHex = this.functionData.functionSelector.toString('hex'); - this.log(`Executing public external function ${this.contractAddress.toShortString()}:${selectorHex}`); - - const acir = this.publicFunctionBytecode; - const initialWitness = getInitialWitness(this.args, this.callContext); - const stateActions = new StateActionsCollector(this.db, this.contractAddress); - - const notAvailable = () => Promise.reject(`Built-in not available for public execution simulation`); - - const { partialWitness } = await acvm(acir, initialWitness, { - getSecretKey: notAvailable, - getNotes2: notAvailable, - getRandomField: notAvailable, - notifyCreatedNote: notAvailable, - notifyNullifiedNote: notAvailable, - callPrivateFunction: notAvailable, - viewNotesPage: notAvailable, - storageRead: async ([slot]) => { - const storageSlot = fromACVMField(slot); - const value = await stateActions.read(storageSlot); - this.log(`Oracle storage read: slot=${storageSlot.toShortString()} value=${value.toString()}`); - return [toACVMField(value)]; - }, - storageWrite: async ([slot, value]) => { - const storageSlot = fromACVMField(slot); - const newValue = fromACVMField(value); - await stateActions.write(storageSlot, newValue); - this.log(`Oracle storage write: slot=${storageSlot.toShortString()} value=${value.toString()}`); - return [toACVMField(newValue)]; - }, - }); - - const returnValues = selectPublicWitnessFlattened(acir, partialWitness).map(fromACVMField); - const [stateReads, stateTransitions] = stateActions.collect(); - - return { - stateReads, - stateTransitions, - returnValues, - }; - } +export function isPublicExecution(input: PublicExecution | TxRequest): input is PublicExecution { + const execution = input as PublicExecution; + return !!execution.callContext && !!execution.args && !!execution.contractAddress && !!execution.functionData; } diff --git a/yarn-project/acir-simulator/src/public/executor.ts b/yarn-project/acir-simulator/src/public/executor.ts new file mode 100644 index 00000000000..8042c9e4d50 --- /dev/null +++ b/yarn-project/acir-simulator/src/public/executor.ts @@ -0,0 +1,149 @@ +import { AztecAddress, CallContext, EthAddress, Fr, FunctionData, TxRequest } from '@aztec/circuits.js'; +import { padArrayEnd } from '@aztec/foundation/collection'; +import { createDebugLogger } from '@aztec/foundation/log'; +import { select_return_flattened as selectPublicWitnessFlattened } from '@noir-lang/noir_util_wasm'; +import { acvm, frToAztecAddress, frToSelector, fromACVMField, toACVMField, toACVMWitness } from '../acvm/index.js'; +import { PublicContractsDB, PublicStateDB } from './db.js'; +import { PublicExecution, PublicExecutionResult } from './execution.js'; +import { StateActionsCollector } from './state_actions.js'; + +// Copied from crate::abi at noir-contracts/src/contracts/noir-aztec3/src/abi.nr +const NOIR_MAX_RETURN_VALUES = 4; + +/** + * Handles execution of public functions. + */ +export class PublicExecutor { + constructor( + private readonly stateDb: PublicStateDB, + private readonly contractsDb: PublicContractsDB, + + private log = createDebugLogger('aztec:simulator:public-executor'), + ) {} + + /** + * Executes a public execution request. + * @param execution - The execution to run. + * @returns The result of the run plus all nested runs. + */ + public async execute(execution: PublicExecution): Promise { + const selectorHex = execution.functionData.functionSelector.toString('hex'); + this.log(`Executing public external function ${execution.contractAddress.toShortString()}:${selectorHex}`); + + const selector = execution.functionData.functionSelector; + const acir = await this.contractsDb.getBytecode(execution.contractAddress, selector); + if (!acir) throw new Error(`Bytecode not found for ${execution.contractAddress.toShortString()}:${selectorHex}`); + + const initialWitness = getInitialWitness(execution.args, execution.callContext); + const stateActions = new StateActionsCollector(this.stateDb, execution.contractAddress); + const nestedExecutions: PublicExecutionResult[] = []; + + const notAvailable = () => Promise.reject(`Built-in not available for public execution simulation`); + + const { partialWitness } = await acvm(acir, initialWitness, { + getSecretKey: notAvailable, + getNotes2: notAvailable, + getRandomField: notAvailable, + notifyCreatedNote: notAvailable, + notifyNullifiedNote: notAvailable, + callPrivateFunction: notAvailable, + viewNotesPage: notAvailable, + storageRead: async ([slot]) => { + const storageSlot = fromACVMField(slot); + const value = await stateActions.read(storageSlot); + this.log(`Oracle storage read: slot=${storageSlot.toShortString()} value=${value.toString()}`); + return [toACVMField(value)]; + }, + storageWrite: async ([slot, value]) => { + const storageSlot = fromACVMField(slot); + const newValue = fromACVMField(value); + await stateActions.write(storageSlot, newValue); + this.log(`Oracle storage write: slot=${storageSlot.toShortString()} value=${value.toString()}`); + return [toACVMField(newValue)]; + }, + callPublicFunction: async ([address, functionSelector, ...args]) => { + this.log(`Public function call: addr=${address} selector=${functionSelector} args=${args.join(',')}`); + const childExecutionResult = await this.callPublicFunction( + frToAztecAddress(fromACVMField(address)), + frToSelector(fromACVMField(functionSelector)), + args.map(f => fromACVMField(f)), + execution.callContext, + ); + + nestedExecutions.push(childExecutionResult); + this.log(`Returning from nested call: ret=${childExecutionResult.returnValues.join(', ')}`); + return padArrayEnd(childExecutionResult.returnValues, Fr.ZERO, NOIR_MAX_RETURN_VALUES).map(fr => fr.toString()); + }, + }); + + const returnValues = selectPublicWitnessFlattened(acir, partialWitness).map(fromACVMField); + const [stateReads, stateTransitions] = stateActions.collect(); + + return { + stateReads, + stateTransitions, + returnValues, + nestedExecutions, + }; + } + + /** + * Creates a PublicExecution out of a TxRequest to a public function. + * @param input - The TxRequest calling a public function. + * @returns A PublicExecution object that can be run via execute. + */ + public async getPublicExecution(input: TxRequest): Promise { + const contractAddress = input.to; + const portalContractAddress = (await this.contractsDb.getPortalContractAddress(contractAddress)) ?? EthAddress.ZERO; + const callContext: CallContext = new CallContext(input.from, input.to, portalContractAddress, false, false, false); + + return { callContext, contractAddress, functionData: input.functionData, args: input.args }; + } + + private async callPublicFunction( + targetContractAddress: AztecAddress, + targetFunctionSelector: Buffer, + targetArgs: Fr[], + callerContext: CallContext, + ) { + const portalAddress = (await this.contractsDb.getPortalContractAddress(targetContractAddress)) ?? EthAddress.ZERO; + const functionData = new FunctionData(targetFunctionSelector, false, false); + + const callContext = CallContext.from({ + msgSender: callerContext.storageContractAddress, + portalContractAddress: portalAddress, + storageContractAddress: targetContractAddress, + isContractDeployment: false, + isDelegateCall: false, + isStaticCall: false, + }); + + const nestedExecution: PublicExecution = { + args: targetArgs, + contractAddress: targetContractAddress, + functionData, + callContext, + }; + + return this.execute(nestedExecution); + } +} + +/** + * Generates the initial witness for a public function. + * @param args - The arguments to the function. + * @param callContext - The call context of the function. + * @param witnessStartIndex - The index where to start inserting the parameters. + * @returns The initial witness. + */ +function getInitialWitness(args: Fr[], callContext: CallContext, witnessStartIndex = 1) { + return toACVMWitness(witnessStartIndex, [ + callContext.isContractDeployment, + callContext.isDelegateCall, + callContext.isStaticCall, + callContext.msgSender, + callContext.portalContractAddress, + callContext.storageContractAddress, + ...args, + ]); +} diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index 4b8a31e441d..0539d23d0a9 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -1,30 +1,38 @@ import { Grumpkin } from '@aztec/barretenberg.js/crypto'; import { BarretenbergWasm } from '@aztec/barretenberg.js/wasm'; import { CallContext, FunctionData } from '@aztec/circuits.js'; +import { AztecAddress } from '@aztec/foundation/aztec-address'; +import { EthAddress } from '@aztec/foundation/eth-address'; +import { Fr } from '@aztec/foundation/fields'; import { FunctionAbi } from '@aztec/noir-contracts'; -import { PublicTokenContractAbi } from '@aztec/noir-contracts/examples'; +import { ChildAbi, ParentAbi, PublicTokenContractAbi } from '@aztec/noir-contracts/examples'; import { MockProxy, mock } from 'jest-mock-extended'; import { default as memdown, type MemDown } from 'memdown'; import { encodeArguments } from '../abi_coder/encoder.js'; import { NoirPoint, computeSlotForMapping, toPublicKey } from '../utils.js'; -import { PublicDB } from './db.js'; +import { PublicContractsDB, PublicStateDB } from './db.js'; import { PublicExecution } from './execution.js'; -import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { EthAddress } from '@aztec/foundation/eth-address'; -import { Fr } from '@aztec/foundation/fields'; +import { PublicExecutor } from './executor.js'; +import { toBigInt } from '@aztec/foundation/serialize'; +import { keccak } from '@aztec/foundation/crypto'; export const createMemDown = () => (memdown as any)() as MemDown; describe('ACIR public execution simulator', () => { let bbWasm: BarretenbergWasm; - let oracle: MockProxy; + let publicState: MockProxy; + let publicContracts: MockProxy; + let executor: PublicExecutor; beforeAll(async () => { bbWasm = await BarretenbergWasm.get(); }); beforeEach(() => { - oracle = mock(); + publicState = mock(); + publicContracts = mock(); + + executor = new PublicExecutor(publicState, publicContracts); }); describe('PublicToken contract', () => { @@ -54,13 +62,14 @@ describe('ACIR public execution simulator', () => { isStaticCall: false, }); + publicContracts.getBytecode.mockResolvedValue(Buffer.from(abi.bytecode, 'hex')); + // Mock the old value for the recipient balance to be 20 const previousBalance = new Fr(20n); - oracle.storageRead.mockResolvedValue(previousBalance); + publicState.storageRead.mockResolvedValue(previousBalance); - const bytecode = Buffer.from(abi.bytecode, 'hex'); - const execution = new PublicExecution(oracle, bytecode, contractAddress, functionData, args, callContext); - const result = await execution.run(); + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + const result = await executor.execute(execution); const expectedBalance = new Fr(160n); expect(result.returnValues).toEqual([expectedBalance]); @@ -83,6 +92,7 @@ describe('ACIR public execution simulator', () => { let callContext: CallContext; let recipientStorageSlot: Fr; let senderStorageSlot: Fr; + let execution: PublicExecution; beforeEach(() => { contractAddress = AztecAddress.random(); @@ -102,11 +112,15 @@ describe('ACIR public execution simulator', () => { recipientStorageSlot = computeSlotForMapping(new Fr(1n), recipient, bbWasm); senderStorageSlot = computeSlotForMapping(new Fr(1n), Fr.fromBuffer(sender.toBuffer()), bbWasm); + + publicContracts.getBytecode.mockResolvedValue(Buffer.from(abi.bytecode, 'hex')); + + execution = { contractAddress, functionData, args, callContext }; }); const mockStore = (senderBalance: Fr, recipientBalance: Fr) => { // eslint-disable-next-line require-await - oracle.storageRead.mockImplementation(async (_addr: AztecAddress, slot: Fr) => { + publicState.storageRead.mockImplementation(async (_addr: AztecAddress, slot: Fr) => { if (slot.equals(recipientStorageSlot)) { return recipientBalance; } else if (slot.equals(senderStorageSlot)) { @@ -122,9 +136,7 @@ describe('ACIR public execution simulator', () => { const recipientBalance = new Fr(20n); mockStore(senderBalance, recipientBalance); - const bytecode = Buffer.from(abi.bytecode, 'hex'); - const execution = new PublicExecution(oracle, bytecode, contractAddress, functionData, args, callContext); - const result = await execution.run(); + const result = await executor.execute(execution); const expectedRecipientBalance = new Fr(160n); const expectedSenderBalance = new Fr(60n); @@ -147,9 +159,7 @@ describe('ACIR public execution simulator', () => { const recipientBalance = new Fr(20n); mockStore(senderBalance, recipientBalance); - const bytecode = Buffer.from(abi.bytecode, 'hex'); - const execution = new PublicExecution(oracle, bytecode, contractAddress, functionData, args, callContext); - const result = await execution.run(); + const result = await executor.execute(execution); expect(result.returnValues).toEqual([recipientBalance]); @@ -162,4 +172,50 @@ describe('ACIR public execution simulator', () => { }); }); }); + + describe('Parent/Child contracts', () => { + it('calls the public entry point in the parent', async () => { + const parentContractAddress = AztecAddress.random(); + const parentEntryPointFn = ParentAbi.functions.find(f => f.name === 'pubEntryPoint')!; + const parentEntryPointFnSelector = keccak(Buffer.from(parentEntryPointFn.name)).subarray(0, 4); + + const childContractAddress = AztecAddress.random(); + const childValueFn = ChildAbi.functions.find(f => f.name === 'pubValue')!; + const childValueFnSelector = keccak(Buffer.from(childValueFn.name)).subarray(0, 4); + + const initialValue = 3n; + + const functionData = new FunctionData(parentEntryPointFnSelector, false, false); + const args = encodeArguments( + parentEntryPointFn, + [childContractAddress.toField().value, toBigInt(childValueFnSelector), initialValue], + false, + ); + + const callContext = CallContext.from({ + msgSender: AztecAddress.random(), + storageContractAddress: parentContractAddress, + portalContractAddress: EthAddress.random(), + isContractDeployment: false, + isDelegateCall: false, + isStaticCall: false, + }); + + // eslint-disable-next-line require-await + publicContracts.getBytecode.mockImplementation(async (addr: AztecAddress, selector: Buffer) => { + if (addr.equals(parentContractAddress) && selector.equals(parentEntryPointFnSelector)) { + return Buffer.from(parentEntryPointFn.bytecode, 'hex'); + } else if (addr.equals(childContractAddress) && selector.equals(childValueFnSelector)) { + return Buffer.from(childValueFn.bytecode, 'hex'); + } else { + return undefined; + } + }); + + const execution: PublicExecution = { contractAddress: parentContractAddress, functionData, args, callContext }; + const result = await executor.execute(execution); + + expect(result.returnValues).toEqual([new Fr(42n + initialValue)]); + }); + }); }); diff --git a/yarn-project/acir-simulator/src/public/index.ts b/yarn-project/acir-simulator/src/public/index.ts index 38e3eff5c4d..7a035d50765 100644 --- a/yarn-project/acir-simulator/src/public/index.ts +++ b/yarn-project/acir-simulator/src/public/index.ts @@ -1,2 +1,3 @@ -export * from './execution.js'; export * from './db.js'; +export { PublicExecution, PublicExecutionResult } from './execution.js'; +export { PublicExecutor } from './executor.js'; diff --git a/yarn-project/acir-simulator/src/public/state_actions.ts b/yarn-project/acir-simulator/src/public/state_actions.ts index 8e81ab77d57..6135c036d5e 100644 --- a/yarn-project/acir-simulator/src/public/state_actions.ts +++ b/yarn-project/acir-simulator/src/public/state_actions.ts @@ -1,7 +1,7 @@ -import { Fr } from '@aztec/foundation/fields'; -import { PublicDB } from './db.js'; import { StateRead, StateTransition } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; +import { Fr } from '@aztec/foundation/fields'; +import { PublicStateDB } from './db.js'; /** * Implements state read/write operations on a contract public storage, collecting @@ -18,7 +18,7 @@ export class StateActionsCollector { { /** The old value. */ oldValue: Fr; /** The updated value. */ newValue: Fr } > = new Map(); - constructor(private db: PublicDB, private address: AztecAddress) {} + constructor(private db: PublicStateDB, private address: AztecAddress) {} /** * Returns the current value of a slot according to the latest transition for it, diff --git a/yarn-project/foundation/package.json b/yarn-project/foundation/package.json index 4f022549161..3b6d0d4deac 100644 --- a/yarn-project/foundation/package.json +++ b/yarn-project/foundation/package.json @@ -10,6 +10,7 @@ "./prettier": "./.prettierrc.json", "./async-map": "./dest/async-map/index.js", "./aztec-address": "./dest/aztec-address/index.js", + "./collection": "./dest/collection/index.js", "./crypto": "./dest/crypto/index.js", "./error": "./dest/error/index.js", "./eth-address": "./dest/eth-address/index.js", diff --git a/yarn-project/foundation/src/bigint-buffer/bigint-buffer.test.ts b/yarn-project/foundation/src/bigint-buffer/bigint-buffer.test.ts new file mode 100644 index 00000000000..d40099941ed --- /dev/null +++ b/yarn-project/foundation/src/bigint-buffer/bigint-buffer.test.ts @@ -0,0 +1,17 @@ +import { toHex } from './index.js'; + +describe('bigint-buffer', () => { + describe('toHex', () => { + it('does not pad even length', () => { + expect(toHex(16n)).toEqual('0x10'); + }); + + it('pads odd length hex to even length', () => { + expect(toHex(10n)).toEqual('0x0a'); + }); + + it('pads zero to even length', () => { + expect(toHex(0n)).toEqual('0x00'); + }); + }); +}); diff --git a/yarn-project/foundation/src/bigint-buffer/index.ts b/yarn-project/foundation/src/bigint-buffer/index.ts index 7fddef15d72..8185cf557ea 100644 --- a/yarn-project/foundation/src/bigint-buffer/index.ts +++ b/yarn-project/foundation/src/bigint-buffer/index.ts @@ -51,3 +51,15 @@ export function toBufferBE(num: bigint, width: number): Buffer { if (buffer.length > width) throw new Error(`Number ${num.toString(16)} does not fit in ${width}`); return buffer; } + +/** + * Converts a BigInt to its hex representation. + * @param num - The BigInt to convert. + * @returns An even-length 0x-prefixed string. + */ +export function toHex(num: bigint): `0x${string}` { + const str = num.toString(16); + const targetLen = str.length % 2 === 0 ? str.length : str.length + 1; + const paddedStr = str.padStart(targetLen, '0'); + return `0x${paddedStr}`; +} diff --git a/yarn-project/foundation/src/collection/array.ts b/yarn-project/foundation/src/collection/array.ts new file mode 100644 index 00000000000..9efed6e8748 --- /dev/null +++ b/yarn-project/foundation/src/collection/array.ts @@ -0,0 +1,11 @@ +/** + * Pads an array to the target length by appending an element to its end. Throws if target length exceeds the input array length. Does not modify the input array. + * @param arr - Array with elements to pad. + * @param elem - Element to use for padding. + * @param length - Target length. + * @returns A new padded array. + */ +export function padArrayEnd(arr: T[], elem: T, length: number): T[] { + if (arr.length > length) throw new Error(`Array size exceeds target length`); + return [...arr, ...Array(length - arr.length).fill(elem)]; +} diff --git a/yarn-project/foundation/src/collection/index.ts b/yarn-project/foundation/src/collection/index.ts new file mode 100644 index 00000000000..1759a6df56a --- /dev/null +++ b/yarn-project/foundation/src/collection/index.ts @@ -0,0 +1 @@ +export * from './array.js'; diff --git a/yarn-project/foundation/src/fields/fields.ts b/yarn-project/foundation/src/fields/fields.ts index 4dc4e07892f..46aa0312b6e 100644 --- a/yarn-project/foundation/src/fields/fields.ts +++ b/yarn-project/foundation/src/fields/fields.ts @@ -1,7 +1,7 @@ import { randomBytes } from 'crypto'; import { BufferReader } from '../serialize/buffer_reader.js'; -import { toBigIntBE, toBufferBE } from '../bigint-buffer/index.js'; +import { toBigIntBE, toBufferBE, toHex } from '../bigint-buffer/index.js'; /** * Fr represents a field of integers modulo the prime number MODULUS. @@ -92,8 +92,8 @@ export class Fr { * * @returns A hex-encoded string representing the value of the class instance. */ - toString() { - return '0x' + this.value.toString(16); + toString(): `0x${string}` { + return toHex(this.value); } /** @@ -210,7 +210,7 @@ export class Fq { * @returns A hexadecimal string representing the Fq value. */ toString() { - return '0x' + this.value.toString(16); + return toHex(this.value); } /** diff --git a/yarn-project/noir-contracts/src/contracts/child_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/child_contract/src/main.nr index 0b6758a685d..7b362ef1c67 100644 --- a/yarn-project/noir-contracts/src/contracts/child_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/child_contract/src/main.nr @@ -1,8 +1,9 @@ contract Child { use dep::aztec3::abi; use dep::aztec3::abi::Inputs; + use dep::aztec3::abi::CallContext; use dep::aztec3::context::PrivateFunctionContext; - + fn constructor( inputs: pub Inputs, ) -> pub [Field; dep::aztec3::abi::PUBLIC_INPUTS_LENGTH] { @@ -20,4 +21,11 @@ contract Child { context.finish(inputs) } + + // Nested public functions always get called with MAX_ARGS, since we don't have the ABI available + // during execution time to know how many args are expected, hence the _padding argument. We should + // be able to remove it when we migrate to brillig. + open fn pubValue(_call_context: CallContext, value: Field, _padding: [Field; dep::aztec3::abi::MAX_ARGS - 1]) -> pub Field { + value + 42 + } } diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/lib.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/lib.nr index 57f4314987b..1a4295b6953 100644 --- a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/lib.nr +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/lib.nr @@ -5,6 +5,7 @@ mod state_vars; mod types; mod utils; mod private_call_stack_item; +mod public_call; global Nonce = 1; global NoteHash = 2; diff --git a/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/public_call.nr b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/public_call.nr new file mode 100644 index 00000000000..db04184f83e --- /dev/null +++ b/yarn-project/noir-contracts/src/contracts/noir-aztec3/src/public_call.nr @@ -0,0 +1,18 @@ +#[oracle(callPublicFunction)] +fn call_public_function_oracle( + _contract_address: Field, + _function_selector: Field, + _args: [Field; crate::abi::MAX_ARGS] +) -> [Field; crate::abi::MAX_RETURN_VALUES] {} + +unconstrained fn call_public_function( + contract_address: Field, + function_selector: Field, + args: [Field; crate::abi::MAX_ARGS] +) -> [Field; crate::abi::MAX_RETURN_VALUES] { + call_public_function_oracle( + contract_address, + function_selector, + args, + ) +} \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/contracts/parent_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/parent_contract/src/main.nr index e44327a9132..c904a398935 100644 --- a/yarn-project/noir-contracts/src/contracts/parent_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/parent_contract/src/main.nr @@ -1,9 +1,11 @@ contract Parent { use dep::aztec3::abi; use dep::aztec3::abi::Inputs; + use dep::aztec3::abi::CallContext; use dep::aztec3::context::PrivateFunctionContext; + use dep::aztec3::public_call; use dep::aztec3::private_call_stack_item::PrivateCallStackItem; - + fn constructor( inputs: pub Inputs, ) -> pub [Field; dep::aztec3::abi::PUBLIC_INPUTS_LENGTH] { @@ -26,4 +28,14 @@ contract Parent { context.finish(inputs) } + + open fn pubEntryPoint(_call_context: CallContext, targetContract: Field, targetSelector: Field, initValue: Field) -> pub Field { + // The call_public_function util always receives and returns MAX_ARGS and MAX_RETURN_VALUES. The caller + // needs to pad the arguments and extract the return values it needs. The callee needs to always accept + // MAX_ARGS, since the oracle doesn't have the info to know how many args to pass. However, the callee + // can return however many args it wants, since the oracle can take care of the padding. + let mut args = [0; dep::aztec3::abi::MAX_ARGS]; + args[0] = initValue; + public_call::call_public_function(targetContract, targetSelector, args)[0] + } } \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/examples/child_contract.json b/yarn-project/noir-contracts/src/examples/child_contract.json index 850e196b445..e8e60ad9442 100644 --- a/yarn-project/noir-contracts/src/examples/child_contract.json +++ b/yarn-project/noir-contracts/src/examples/child_contract.json @@ -9,6 +9,37 @@ "bytecode": "000000003e0000000d0000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000002f0000000e0000000f0000001000000011000000120000001300000015000000160000001700000018000000190000001a0000001b0000001c0000001d0000001e0000001f000000200000002100000022000000230000002400000025000000260000002700000028000000290000002a0000002b0000002c0000002d0000002e0000002f000000300000003100000032000000330000003400000035000000360000003700000038000000390000003a0000003b0000003c0000003d000000330000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000011000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000012000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000013000000000000000000000000000000000000000000000000000000000000000000000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000015000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000016000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000017000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000019000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000021000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000022000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000023000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000024000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000025000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000026000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000027000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000028000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000029000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000031000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000032000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000033000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000034000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000035000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000011400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000036000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000037000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000038000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000039000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000003d0000000000000000000000000000000000000000000000000000000000000000000000", "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" }, + { + "name": "pubValue", + "functionType": "open", + "parameters": [ + { + "name": "value", + "type": { + "kind": "field" + }, + "visibility": "private" + }, + { + "name": "_padding", + "type": { + "kind": "array", + "length": 7, + "type": { + "kind": "field" + } + }, + "visibility": "private" + } + ], + "returnTypes": [ + { + "kind": "field" + } + ], + "bytecode": "0000000011000000000000000100000010000000050000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000f000000000000000000000000000000000000000000000000000000000000000000002a00000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000100000000000000000000000000000000000000000000000000000000000000000000000", + "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" + }, { "name": "value", "functionType": "secret", diff --git a/yarn-project/noir-contracts/src/examples/parent_contract.json b/yarn-project/noir-contracts/src/examples/parent_contract.json index dbe064e2e72..869a94579d2 100644 --- a/yarn-project/noir-contracts/src/examples/parent_contract.json +++ b/yarn-project/noir-contracts/src/examples/parent_contract.json @@ -31,6 +31,40 @@ "returnTypes": [], "bytecode": "00000000bf0000000f0000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f0000002f0000008f0000009000000091000000920000009300000094000000950000009600000098000000990000009a0000009b0000009c0000009d0000009e0000009f000000a0000000a1000000a2000000a3000000a4000000a5000000a6000000a7000000a8000000a9000000aa000000ab000000ac000000ad000000ae000000af000000b0000000b1000000b2000000b3000000b4000000b5000000b6000000b7000000b8000000b9000000ba000000bb000000bc000000bd000000be000000af0000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000003000000000000000000000000000000000000000000000000000000000000000000000007030000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010e00000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000010f000000000000000000000000000000000000000000000000000000000000000000000001002c00000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000010033000000100000001100000012000000130000001400000015000000160000001700000018000000190000001a0000001b0000001c0000001d0000001e0000001f000000200000002100000022000000230000002400000025000000260000002700000028000000290000002a0000002b0000002c0000002d0000002e0000002f000000300000003100000032000000330000003400000035000000360000003700000038000000390000003a0000003b0000003c0000003d0000003e0000003f000000400000004100000042000000160200009981a34a4d509103a454726170a453746f7081a34d6f769281a85265676973746572cd023181a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030326581a64f7261636c6595b363616c6c5072697661746546756e6374696f6e9381b052656769737465724d656d496e64657881a85265676973746572cd022281b052656769737465724d656d496e64657881a85265676973746572cd022381a541727261799281a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030326308909181a541727261799281a8436f6e7374616e74d94030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303265339081a34d6f769281a85265676973746572cd023181a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030326581a34d6f769281a852656769737465720081a85265676973746572cd0231a843616c6c4261636b81a9426f6f7473747261709193cd0222cd0223cd0226010000000000000000000000000000000000000000000000000000000000000000000000000000000102010000000000010000000000000000000000000000000000000000000000000000000000000000000001120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024400000043000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001430000004300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004300000000000000000000000000000000000000000000000000000000000000000000000201000000000001000000000000000000000000000000000000000000000000000000000000000000000144000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000460000004500000000010b000100000045000000fc000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001460000004600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000046000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000044000000000000000000000000000000000000000000000000000000000000000000000145000000100000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000012000000000000000000000000000000000000000000000000000000000000000000000143000000000000000000000000000000000000000000000000000000000000000000000244000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024800000047000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001470000004700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000047000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001480000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000004a0000004900000000010b000100000049000000fc0000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000014a0000004a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004a000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004800000000000000000000000000000000000000000000000000000000000000000000014900000010000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000013000000000000000000000000000000000000000000000000000000000000000000000147000000000000000000000000000000000000000000000000000000000000000000000248000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024c0000004b0000000000010000000100000000000000000000000000000000000000000000000000000000000000000000014b0000004b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004b0000000000000000000000000000000000000000000000000000000000000000000000020100000000000100000000000000000000000000000000000000000000000000000000000000000000014c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000004e0000004d00000000010b00010000004d000000fc0000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000014e0000004e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004e000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004c00000000000000000000000000000000000000000000000000000000000000000000014d00000010000000000000000000000000000000000000000000000000000000000000004e000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001700000000000000000000000000000000000000000000000000000000000000000000014b00000000000000000000000000000000000000000000000000000000000000000000024c00000000000000000000000000000000000000000000000000000000000000000000000201000000000001000000000000000000000000000000000000000000000000000000000000000000000118000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002500000004f0000000000010000000100000000000000000000000000000000000000000000000000000000000000000000014f0000004f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004f00000000000000000000000000000000000000000000000000000000000000000000000201000000000001000000000000000000000000000000000000000000000000000000000000000000000150000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000520000005100000000010b000100000051000000fc000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001520000005200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000052000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000050000000000000000000000000000000000000000000000000000000000000000000000151000000100000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001800000000000000000000000000000000000000000000000000000000000000000000014f000000000000000000000000000000000000000000000000000000000000000000000250000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001190000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025400000053000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001530000005300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005300000000000000000000000000000000000000000000000000000000000000000000000201000000000001000000000000000000000000000000000000000000000000000000000000000000000154000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000560000005500000000010b000100000055000000fc000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001560000005600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000056000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000054000000000000000000000000000000000000000000000000000000000000000000000155000000100000000000000000000000000000000000000000000000000000000000000056000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000019000000000000000000000000000000000000000000000000000000000000000000000153000000000000000000000000000000000000000000000000000000000000000000000254000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000057000000000000000000000000000000000000000000000000000000000000000000000002000057000000580000000001000000010000000000000000000000000000000000000000000000000000000000000000000001570000005800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005900000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001570000005900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000570000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000159000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005a00000000000000000000000000000000000000000000000000000000000000000000000200005a0000005b00000000010000000100000000000000000000000000000000000000000000000000000000000000000000015a0000005b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005c000000000000000000000000000000000000000000000000000000000000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000015a0000005c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005a000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000015c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005d00000000000000000000000000000000000000000000000000000000000000000000000200005d0000005e00000000010000000100000000000000000000000000000000000000000000000000000000000000000000015d0000005e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005f000000000000000000000000000000000000000000000000000000000000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000015d0000005f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005d000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000015f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000060000000000000000000000000000000000000000000000000000000000000000000000002000060000000610000000001000000010000000000000000000000000000000000000000000000000000000000000000000001600000006100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001600000006200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000600000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000162000000000000000000000000000000000000000000000000000000000000000000000000000000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000063000000000000000000000000000000000000000000000000000000000000000000000002000063000000640000000001000000010000000000000000000000000000000000000000000000000000000000000000000001630000006400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006500000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001630000006500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000630000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000165000000000000000000000000000000000000000000000000000000000000000000000000000000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000066000000000000000000000000000000000000000000000000000000000000000000000002000066000000670000000001000000010000000000000000000000000000000000000000000000000000000000000000000001660000006700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006800000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001660000006800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000660000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000168000000000000000000000000000000000000000000000000000000000000000000000000000000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000690000000000000000000000000000000000000000000000000000000000000000000000020000690000006a0000000001000000010000000000000000000000000000000000000000000000000000000000000000000001690000006a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006b00000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001690000006b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000069000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000016b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000001f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006c00000000000000000000000000000000000000000000000000000000000000000000000200006c0000006d00000000010000000100000000000000000000000000000000000000000000000000000000000000000000016c0000006d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006e000000000000000000000000000000000000000000000000000000000000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000016c0000006e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006c000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000016e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006f00000000000000000000000000000000000000000000000000000000000000000000000200006f0000007000000000010000000100000000000000000000000000000000000000000000000000000000000000000000016f0000007000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000071000000000000000000000000000000000000000000000000000000000000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000016f0000007100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000006f0000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000171000000000000000000000000000000000000000000000000000000000000000000000000000000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000002100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000072000000000000000000000000000000000000000000000000000000000000000000000002000072000000730000000001000000010000000000000000000000000000000000000000000000000000000000000000000001720000007300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000007400000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001720000007400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000720000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000174000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000027600000075000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001750000007500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000007500000000000000000000000000000000000000000000000000000000000000000000000201000000000001000000000000000000000000000000000000000000000000000000000000000000000176000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000780000007700000000010b000100000077000000fc000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001780000007800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000078000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000076000000000000000000000000000000000000000000000000000000000000000000000177000000100000000000000000000000000000000000000000000000000000000000000078000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000043000000000000000000000000000000000000000000000000000000000000000000000175000000000000000000000000000000000000000000000000000000000000000000000276000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001470000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000027a00000079000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001790000007900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000790000000000000000000000000000000000000000000000000000000000000000000000020100000000000100000000000000000000000000000000000000000000000000000000000000000000017a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000007c0000007b00000000010b00010000007b000000fc0000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000017c0000007c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000007c000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000007a00000000000000000000000000000000000000000000000000000000000000000000017b00000010000000000000000000000000000000000000000000000000000000000000007c000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004700000000000000000000000000000000000000000000000000000000000000000000017900000000000000000000000000000000000000000000000000000000000000000000027a00000000000000000000000000000000000000000000000000000000000000000000000105000300000011000000fe00000075000000fe00000079000000fe000000020000007d0000007e000000020100000000000100000000000000000000000000000000000000000000000000000000000000000000014b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002800000007f0000000000010000000100000000000000000000000000000000000000000000000000000000000000000000017f0000007f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000007f00000000000000000000000000000000000000000000000000000000000000000000000201000000000001000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000820000008100000000010b000100000081000000fc000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001820000008200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000082000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000080000000000000000000000000000000000000000000000000000000000000000000000181000000100000000000000000000000000000000000000000000000000000000000000082000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004b00000000000000000000000000000000000000000000000000000000000000000000017f0000000000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000000000000020100000000000100000000000000000000000000000000000000000000000000000000000000000000014f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028400000083000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001830000008300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000008300000000000000000000000000000000000000000000000000000000000000000000000201000000000001000000000000000000000000000000000000000000000000000000000000000000000184000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000860000008500000000010b000100000085000000fc000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001860000008600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000086000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000084000000000000000000000000000000000000000000000000000000000000000000000185000000100000000000000000000000000000000000000000000000000000000000000086000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000004f000000000000000000000000000000000000000000000000000000000000000000000183000000000000000000000000000000000000000000000000000000000000000000000284000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001530000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028800000087000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001870000008700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000087000000000000000000000000000000000000000000000000000000000000000000000002010000000000010000000000000000000000000000000000000000000000000000000000000000000001880000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000008a0000008900000000010b000100000089000000fc0000000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000018a0000008a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000008a000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000008800000000000000000000000000000000000000000000000000000000000000000000018900000010000000000000000000000000000000000000000000000000000000000000008a000000000000000000000000000000000000000000000000000000000000000000000000000000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000005300000000000000000000000000000000000000000000000000000000000000000000018700000000000000000000000000000000000000000000000000000000000000000000028800000000000000000000000000000000000000000000000000000000000000000000000105002f00000014000000fe00000015000000fe00000016000000fe0000007f000000fe00000083000000fe00000087000000fe0000001a000000fe0000001b000000fe0000001c000000fe0000001d000000fe0000001e000000fe0000001f000000fe00000020000000fe00000021000000fe00000022000000fe00000023000000fe00000024000000fe00000025000000fe00000026000000fe00000027000000fe00000028000000fe00000029000000fe0000002a000000fe0000002b000000fe0000002c000000fe0000002d000000fe0000002e000000fe0000002f000000fe00000030000000fe00000031000000fe00000032000000fe00000033000000fe00000034000000fe00000035000000fe00000036000000fe00000037000000fe00000038000000fe00000039000000fe0000003a000000fe0000003b000000fe0000003c000000fe0000003d000000fe0000003e000000fe0000003f000000fe00000040000000fe00000041000000fe00000042000000fe000000020000008b0000008c0000000105000300000010000000fe0000007d000000fe0000008b000000fe000000020000008d0000008e00000000000000000200000000000000000000000000000000000000000000000000000000000000000000010400000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000008f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010600000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000090000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010500000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000091000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000092000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000093000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010e00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000095000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010f00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000096000000000000000000000000000000000000000000000000000000000000000000000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000097000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000098000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000099000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000009a000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000009b000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000009c000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000009d000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000012200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000009e000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000009f000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000a1000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000a2000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000a3000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000a4000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000a5000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000a6000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000a7000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000a8000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000a9000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000aa000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000ab000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000ac000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000ad000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000018d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000ae000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000af000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000b0000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000b1000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000b2000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000b3000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000b4000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000b5000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000b6000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000019700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000b7000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010d00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000b8000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010c00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000b9000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010b00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000ba000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010700000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000bb000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010900000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000bc000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010800000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000bd000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000010a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000be0000000000000000000000000000000000000000000000000000000000000000000000", "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" + }, + { + "name": "pubEntryPoint", + "functionType": "open", + "parameters": [ + { + "name": "targetContract", + "type": { + "kind": "field" + }, + "visibility": "private" + }, + { + "name": "targetSelector", + "type": { + "kind": "field" + }, + "visibility": "private" + }, + { + "name": "initValue", + "type": { + "kind": "field" + }, + "visibility": "private" + } + ], + "returnTypes": [ + { + "kind": "field" + } + ], + "bytecode": "000000000f00000000000000010000000e000000050000000001000000010000000000000000000000000000000000000000000000000000000000000000000001010000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000100000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001020000000200000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000200000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000001030000000300000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000300000000000000000000000000000000000000000000000000000000000000000000000703000000000000000000010000000000000000000000000000000000000000000000000000000000000000000001070000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000001080000000000000000000000000000000000000000000000000000000000000000000000010002000000080000000000000001000000000000000000000000000000000000000000000000000000000000000000000109000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000100040000000a0000000b0000000c0000000d000000050200009981a34a4d509103a454726170a453746f7081a34d6f769281a852656769737465724c81a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303481a64f7261636c6595b263616c6c5075626c696346756e6374696f6e9381b052656769737465724d656d496e64657881a852656769737465723d81b052656769737465724d656d496e64657881a852656769737465723e81a541727261799281a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303208909181a541727261799281a8436f6e7374616e74d94030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303034049081a34d6f769281a852656769737465724c81a8436f6e7374616e74d9403030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303481a34d6f769281a852656769737465720081a852656769737465724ca843616c6c4261636b81a9426f6f74737472617091933d3e41010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000200000000000000000000000000000000000000000000000000000000000000000000010a00000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000e0000000000000000000000000000000000000000000000000000000000000000000000", + "verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f" } ] } diff --git a/yarn-project/sequencer-client/src/client/sequencer-client.ts b/yarn-project/sequencer-client/src/client/sequencer-client.ts index 45aeffd57bb..52e2fc45aa8 100644 --- a/yarn-project/sequencer-client/src/client/sequencer-client.ts +++ b/yarn-project/sequencer-client/src/client/sequencer-client.ts @@ -43,7 +43,7 @@ export class SequencerClient { const publicProcessor = new PublicProcessor( merkleTreeDb, - new FakePublicCircuitSimulator(merkleTreeDb), + new FakePublicCircuitSimulator(merkleTreeDb, contractDataSource), new WasmPublicKernelCircuitSimulator(), new EmptyPublicProver(), contractDataSource, diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.ts index 4decc652192..2c9600d21a8 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.ts @@ -1,6 +1,4 @@ -import { pedersenGetHash } from '@aztec/barretenberg.js/crypto'; import { - CircuitsWasm, Fr, PUBLIC_CALL_STACK_LENGTH, PublicCallData, @@ -80,21 +78,14 @@ export class PublicProcessor { // any existing private execution information, and any subsequent calls. protected async processPublicTx(tx: PublicTx): Promise<[PublicKernelPublicInputs, Proof]> { const { txRequest } = tx.txRequest; - const contractAddress = txRequest.to; - const fn = await this.contractDataSource.getPublicFunction( - contractAddress, - txRequest.functionData.functionSelector, - ); - const functionSelector = txRequest.functionData.functionSelector; - if (!fn) throw new Error(`Bytecode not found for ${functionSelector}@${contractAddress}`); - const contractPublicData = await this.contractDataSource.getL2ContractPublicData(contractAddress); - if (!contractPublicData) throw new Error(`Portal contract address not found for contract ${contractAddress}`); - const { portalContractAddress } = contractPublicData.contractData; + // TODO: Determine how to calculate bytecode hash. Circuits just check it isn't zero for now. + // See https://github.com/AztecProtocol/aztec3-packages/issues/378 + const bytecodeHash = new Fr(1n); - const circuitOutput = await this.publicCircuit.publicCircuit(txRequest, fn.bytecode, portalContractAddress); + const circuitOutput = await this.publicCircuit.publicCircuit(txRequest); const circuitProof = await this.publicProver.getPublicCircuitProof(circuitOutput); - const publicCallData = await this.getPublicCallData(txRequest, fn.bytecode, circuitOutput, circuitProof); + const publicCallData = this.getPublicCallData(txRequest, bytecodeHash, circuitOutput, circuitProof); const publicKernelInput = new PublicKernelInputsNoPreviousKernel(tx.txRequest, publicCallData); const publicKernelOutput = await this.publicKernel.publicKernelCircuitNoInput(publicKernelInput); @@ -103,9 +94,9 @@ export class PublicProcessor { return [publicKernelOutput, publicKernelProof]; } - protected async getPublicCallData( + protected getPublicCallData( txRequest: TxRequest, - functionBytecode: Buffer, + bytecodeHash: Fr, publicCircuitOutput: PublicCircuitPublicInputs, publicCircuitProof: Proof, ) { @@ -113,6 +104,7 @@ export class PublicProcessor { const contractAddress = txRequest.to; const callStackItem = new PublicCallStackItem(contractAddress, txRequest.functionData, publicCircuitOutput); const publicCallStackPreimages: PublicCallStackItem[] = times(PUBLIC_CALL_STACK_LENGTH, PublicCallStackItem.empty); + const portalContractAddress = publicCircuitOutput.callContext.portalContractAddress.toField(); // set the msgSender for each call in the call stack for (let i = 0; i < publicCallStackPreimages.length; i++) { @@ -121,10 +113,6 @@ export class PublicProcessor { ? callStackItem.publicInputs.callContext.msgSender : callStackItem.contractAddress; } - // TODO: Determine how to calculate bytecode hash - // See https://github.com/AztecProtocol/aztec3-packages/issues/378 - const bytecodeHash = Fr.fromBuffer(pedersenGetHash(await CircuitsWasm.get(), functionBytecode)); - const portalContractAddress = publicCircuitOutput.callContext.portalContractAddress.toField(); return new PublicCallData( callStackItem, diff --git a/yarn-project/sequencer-client/src/simulator/fake_public.ts b/yarn-project/sequencer-client/src/simulator/fake_public.ts index 61c9bc923af..fe9a0ff788c 100644 --- a/yarn-project/sequencer-client/src/simulator/fake_public.ts +++ b/yarn-project/sequencer-client/src/simulator/fake_public.ts @@ -1,18 +1,24 @@ -import { PublicDB, PublicExecution } from '@aztec/acir-simulator'; +import { PublicStateDB, PublicExecution, PublicExecutor, PublicContractsDB } from '@aztec/acir-simulator'; import { BarretenbergWasm } from '@aztec/barretenberg.js/wasm'; import { AztecAddress, EthAddress, Fr, PublicCircuitPublicInputs, TxRequest } from '@aztec/circuits.js'; import { MerkleTreeId } from '@aztec/types'; import { MerkleTreeOperations, computePublicDataTreeLeafIndex } from '@aztec/world-state'; import { PublicCircuitSimulator } from './index.js'; +import { ContractDataSource } from '@aztec/types'; /** * Emulates the PublicCircuit simulator by executing ACIR as if it were Brillig opcodes. */ export class FakePublicCircuitSimulator implements PublicCircuitSimulator { - private readonly db: WorldStatePublicDB; + private readonly stateDb: WorldStatePublicDB; + private readonly contractsDb: ContractsDataSourcePublicDB; - constructor(private readonly merkleTree: MerkleTreeOperations) { - this.db = new WorldStatePublicDB(this.merkleTree); + constructor( + private readonly merkleTree: MerkleTreeOperations, + private readonly contractDataSource: ContractDataSource, + ) { + this.stateDb = new WorldStatePublicDB(this.merkleTree); + this.contractsDb = new ContractsDataSourcePublicDB(this.contractDataSource); } /** @@ -22,16 +28,14 @@ export class FakePublicCircuitSimulator implements PublicCircuitSimulator { * @param portalAddress - Corresponding portal address of the contract being run. * @returns The resulting PublicCircuitPublicInputs as if the circuit had been simulated. */ - public async publicCircuit( - tx: TxRequest, - functionBytecode: Buffer, - portalAddress: EthAddress, - ): Promise { + public async publicCircuit(tx: TxRequest): Promise { const publicDataTreeInfo = await this.merkleTree.getTreeInfo(MerkleTreeId.PUBLIC_DATA_TREE); const historicPublicDataTreeRoot = Fr.fromBuffer(publicDataTreeInfo.root); - const execution = PublicExecution.fromTransactionRequest(this.db, tx, functionBytecode, portalAddress); - const result = await execution.run(); + const executor = new PublicExecutor(this.stateDb, this.contractsDb); + const execution = await executor.getPublicExecution(tx); + const result = await executor.execute(execution); + return PublicCircuitPublicInputs.from({ args: tx.args, callContext: execution.callContext, @@ -48,9 +52,22 @@ export class FakePublicCircuitSimulator implements PublicCircuitSimulator { } /** - * Implements the PublicDB using a world-state database. + * Implements the PublicContractsDB using a ContractDataSource. + */ +class ContractsDataSourcePublicDB implements PublicContractsDB { + constructor(private db: ContractDataSource) {} + async getBytecode(address: AztecAddress, functionSelector: Buffer): Promise { + return (await this.db.getPublicFunction(address, functionSelector))?.bytecode; + } + async getPortalContractAddress(address: AztecAddress): Promise { + return (await this.db.getL2ContractInfo(address))?.portalContractAddress; + } +} + +/** + * Implements the PublicStateDB using a world-state database. */ -class WorldStatePublicDB implements PublicDB { +class WorldStatePublicDB implements PublicStateDB { constructor(private db: MerkleTreeOperations) {} /** diff --git a/yarn-project/sequencer-client/src/simulator/index.ts b/yarn-project/sequencer-client/src/simulator/index.ts index c93d04342d0..44e65e08a51 100644 --- a/yarn-project/sequencer-client/src/simulator/index.ts +++ b/yarn-project/sequencer-client/src/simulator/index.ts @@ -41,13 +41,11 @@ export interface RollupSimulator { */ export interface PublicCircuitSimulator { /** - * Simulates the public circuit given a public tx and bytecode to execute. + * Simulates the public circuit given a public tx. * @param tx - Transaction request to execute. - * @param functionBytecode - Corresponding bytecode to run. - * @param portalAddress - Portal contract address for the contract being run. * @returns The public inputs as outputs of the simulation. */ - publicCircuit(tx: TxRequest, functionBytecode: Buffer, portalAddress: EthAddress): Promise; + publicCircuit(tx: TxRequest): Promise; } /**