From a091566732a66b2fa9169ad7fd55f980fcee5551 Mon Sep 17 00:00:00 2001 From: LHerskind Date: Tue, 1 Aug 2023 09:26:51 +0000 Subject: [PATCH 1/5] feat: add FunctionData.fromAbi --- .../acir-simulator/src/client/private_execution.ts | 4 ++-- .../src/aztec_rpc_server/aztec_rpc_server.ts | 13 ++----------- yarn-project/aztec-rpc/src/contract_tree/index.ts | 3 +-- .../src/account_impl/single_key_account_contract.ts | 3 +-- .../src/account_impl/stored_key_account_contract.ts | 3 +-- .../src/contract/contract_function_interaction.ts | 9 +-------- .../src/contract/contract_deployment_info.ts | 3 +-- .../circuits.js/src/structs/function_data.ts | 12 ++++++++++++ 8 files changed, 21 insertions(+), 29 deletions(-) diff --git a/yarn-project/acir-simulator/src/client/private_execution.ts b/yarn-project/acir-simulator/src/client/private_execution.ts index 00015976e2b..894975c0ca4 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.ts @@ -266,7 +266,7 @@ export class PrivateFunctionExecution { curve: Grumpkin, ) { const targetAbi = await this.context.db.getFunctionABI(targetContractAddress, targetFunctionSelector); - const targetFunctionData = new FunctionData(targetFunctionSelector, targetAbi.isInternal, true, false); + const targetFunctionData = FunctionData.fromAbi(targetAbi); const derivedCallContext = await this.deriveCallContext(callerContext, targetContractAddress, false, false); const context = this.context.extend(); @@ -304,7 +304,7 @@ export class PrivateFunctionExecution { return PublicCallRequest.from({ args: targetArgs, callContext: derivedCallContext, - functionData: new FunctionData(targetFunctionSelector, targetAbi.isInternal, false, false), + functionData: FunctionData.fromAbi(targetAbi), contractAddress: targetContractAddress, }); } diff --git a/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts b/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts index 488b25eb683..828a5ffecd8 100644 --- a/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts +++ b/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts @@ -385,19 +385,10 @@ export class AztecRPCServer implements AztecRPC { throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`); } - const flatArgs = encodeArguments(functionDao, args); - - const functionData = new FunctionData( - functionDao.selector, - functionDao.isInternal, - functionDao.functionType === FunctionType.SECRET, - false, - ); - return { - args: flatArgs, + args: encodeArguments(functionDao, args), from, - functionData, + functionData: FunctionData.fromAbi(functionDao), to, }; } diff --git a/yarn-project/aztec-rpc/src/contract_tree/index.ts b/yarn-project/aztec-rpc/src/contract_tree/index.ts index 1fef0ea17ac..acf6052ed50 100644 --- a/yarn-project/aztec-rpc/src/contract_tree/index.ts +++ b/yarn-project/aztec-rpc/src/contract_tree/index.ts @@ -89,8 +89,7 @@ export class ContractTree { })); const leaves = generateFunctionLeaves(functions, wasm); const root = computeFunctionTreeRoot(wasm, leaves); - const constructorSelector = generateFunctionSelector(constructorAbi.name, constructorAbi.parameters); - const functionData = new FunctionData(constructorSelector, false, true, true); + const functionData = FunctionData.fromAbi(constructorAbi); const vkHash = hashVKStr(constructorAbi.verificationKey, wasm); const argsHash = await computeVarArgsHash(wasm, args); const constructorHash = hashConstructor(wasm, functionData, argsHash, vkHash); diff --git a/yarn-project/aztec.js/src/account_impl/single_key_account_contract.ts b/yarn-project/aztec.js/src/account_impl/single_key_account_contract.ts index 7cc652bff39..601cc66c7e2 100644 --- a/yarn-project/aztec.js/src/account_impl/single_key_account_contract.ts +++ b/yarn-project/aztec.js/src/account_impl/single_key_account_contract.ts @@ -50,12 +50,11 @@ export class SingleKeyAccountContract implements AccountImplementation { const publicKey = await generatePublicKey(this.privateKey); const args = [payload, publicKey.toBuffer(), signature, this.partialContractAddress]; const abi = this.getEntrypointAbi(); - const selector = generateFunctionSelector(abi.name, abi.parameters); const packedArgs = await PackedArguments.fromArgs(encodeArguments(abi, args), wasm); const txRequest = TxExecutionRequest.from({ argsHash: packedArgs.hash, origin: this.address, - functionData: new FunctionData(selector, abi.isInternal, true, false), + functionData: FunctionData.fromAbi(abi), txContext, packedArguments: [...callsPackedArguments, packedArgs], }); diff --git a/yarn-project/aztec.js/src/account_impl/stored_key_account_contract.ts b/yarn-project/aztec.js/src/account_impl/stored_key_account_contract.ts index 09f17966838..4a06c5bdf8d 100644 --- a/yarn-project/aztec.js/src/account_impl/stored_key_account_contract.ts +++ b/yarn-project/aztec.js/src/account_impl/stored_key_account_contract.ts @@ -41,12 +41,11 @@ export class StoredKeyAccountContract implements AccountImplementation { const args = [payload, signature]; const abi = this.getEntrypointAbi(); - const selector = generateFunctionSelector(abi.name, abi.parameters); const packedArgs = await PackedArguments.fromArgs(encodeArguments(abi, args), wasm); const txRequest = TxExecutionRequest.from({ argsHash: packedArgs.hash, origin: this.address, - functionData: new FunctionData(selector, abi.isInternal, true, false), + functionData: FunctionData.fromAbi(abi), txContext, packedArguments: [...callsPackedArguments, packedArgs], }); diff --git a/yarn-project/aztec.js/src/contract/contract_function_interaction.ts b/yarn-project/aztec.js/src/contract/contract_function_interaction.ts index 53803cd6395..63a9ea326df 100644 --- a/yarn-project/aztec.js/src/contract/contract_function_interaction.ts +++ b/yarn-project/aztec.js/src/contract/contract_function_interaction.ts @@ -98,16 +98,9 @@ export class ContractFunctionInteraction { const flatArgs = encodeArguments(this.functionDao, this.args); from = from ?? this.wallet.getAddress(); - const functionData = new FunctionData( - generateFunctionSelector(this.functionDao.name, this.functionDao.parameters), - this.functionDao.isInternal, - this.functionDao.functionType === FunctionType.SECRET, - this.functionDao.name === 'constructor', - ); - return { args: flatArgs, - functionData, + functionData: FunctionData.fromAbi(this.functionDao), to, from, }; diff --git a/yarn-project/circuits.js/src/contract/contract_deployment_info.ts b/yarn-project/circuits.js/src/contract/contract_deployment_info.ts index a95d57ba909..41c60ce738d 100644 --- a/yarn-project/circuits.js/src/contract/contract_deployment_info.ts +++ b/yarn-project/circuits.js/src/contract/contract_deployment_info.ts @@ -41,8 +41,7 @@ export async function getContractDeploymentInfo( })); const leaves = generateFunctionLeaves(functions, wasm); const functionTreeRoot = computeFunctionTreeRoot(wasm, leaves); - const constructorSelector = generateFunctionSelector(constructorAbi.name, constructorAbi.parameters); - const functionData = new FunctionData(constructorSelector, false, true, true); + const functionData = FunctionData.fromAbi(constructorAbi); const flatArgs = encodeArguments(constructorAbi, args); const argsHash = await computeVarArgsHash(wasm, flatArgs); const constructorHash = hashConstructor(wasm, functionData, argsHash, constructorVkHash.toBuffer()); diff --git a/yarn-project/circuits.js/src/structs/function_data.ts b/yarn-project/circuits.js/src/structs/function_data.ts index bc6c0ccbdb5..8411c6fcc72 100644 --- a/yarn-project/circuits.js/src/structs/function_data.ts +++ b/yarn-project/circuits.js/src/structs/function_data.ts @@ -1,5 +1,7 @@ +import { FunctionAbi, FunctionType, generateFunctionSelector } from '@aztec/foundation/abi'; import { BufferReader, deserializeUInt32, numToUInt32BE } from '@aztec/foundation/serialize'; +import { ContractFunctionDao } from '../index.js'; import { serializeToBuffer } from '../utils/serialize.js'; const FUNCTION_SELECTOR_LENGTH = 4; @@ -40,6 +42,16 @@ export class FunctionData { this.functionSelectorBuffer = numToUInt32BE(functionSelector); } } + + static fromAbi(abi: FunctionAbi | ContractFunctionDao): FunctionData { + return new FunctionData( + generateFunctionSelector(abi.name, abi.parameters), + abi.isInternal, + abi.functionType === FunctionType.SECRET, + abi.name === 'constructor', + ); + } + // For serialization, must match function_selector name in C++ and return as number // TODO(AD) somehow remove this cruft, probably by using a buffer selector in C++ get functionSelector(): number { From b39e14b6d8bedcdbd8d34f8274975ae1d20516fb Mon Sep 17 00:00:00 2001 From: LHerskind Date: Tue, 1 Aug 2023 10:48:13 +0000 Subject: [PATCH 2/5] chore: linter --- .../src/client/private_execution.test.ts | 14 +++++++------- .../acir-simulator/src/client/private_execution.ts | 3 +++ .../src/aztec_rpc_server/aztec_rpc_server.ts | 2 +- .../account_impl/single_key_account_contract.ts | 2 +- .../account_impl/stored_key_account_contract.ts | 2 +- .../src/contract/contract_function_interaction.ts | 2 +- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index 67878fc5b14..111a0bc741d 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -86,21 +86,20 @@ describe('Private Execution test suite', () => { args = [], origin = AztecAddress.random(), contractAddress = defaultContractAddress, - isConstructor = false, txContext = {}, }: { abi: FunctionAbi; origin?: AztecAddress; contractAddress?: AztecAddress; - isConstructor?: boolean; args?: any[]; txContext?: Partial>; }) => { const packedArguments = await PackedArguments.fromArgs(encodeArguments(abi, args), circuitsWasm); + const functionData = FunctionData.fromAbi(abi); const txRequest = TxExecutionRequest.from({ origin, argsHash: packedArguments.hash, - functionData: new FunctionData(Buffer.alloc(4), false, true, isConstructor), + functionData, txContext: TxContext.from({ ...txContextFields, ...txContext }), packedArguments: [packedArguments], }); @@ -110,7 +109,7 @@ describe('Private Execution test suite', () => { return acirSimulator.run( txRequest, abi, - isConstructor ? AztecAddress.ZERO : contractAddress, + functionData.isConstructor ? AztecAddress.ZERO : contractAddress, EthAddress.ZERO, historicRoots, ); @@ -156,7 +155,7 @@ describe('Private Execution test suite', () => { const abi = TestContractAbi.functions[0]; const contractDeploymentData = makeContractDeploymentData(100); const txContext = { isContractDeploymentTx: true, contractDeploymentData }; - const result = await runSimulator({ abi, isConstructor: true, txContext }); + const result = await runSimulator({ abi, txContext }); const emptyCommitments = new Array(MAX_NEW_COMMITMENTS_PER_CALL).fill(Fr.ZERO); expect(result.callStackItem.publicInputs.newCommitments).toEqual(emptyCommitments); @@ -239,10 +238,11 @@ describe('Private Execution test suite', () => { }); }); - it('should a constructor with arguments that inserts notes', async () => { + it.only('should a constructor with arguments that inserts notes', async () => { const abi = ZkTokenContractAbi.functions.find(f => f.name === 'constructor')!; - const result = await runSimulator({ args: [140, owner], abi, isConstructor: true }); + const result = await runSimulator({ args: [140, owner], abi }); + console.log(result.callStackItem.publicInputs); expect(result.preimages.newNotes).toHaveLength(1); const newNote = result.preimages.newNotes[0]; diff --git a/yarn-project/acir-simulator/src/client/private_execution.ts b/yarn-project/acir-simulator/src/client/private_execution.ts index 894975c0ca4..3ccbdeca0d6 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.ts @@ -267,6 +267,7 @@ export class PrivateFunctionExecution { ) { const targetAbi = await this.context.db.getFunctionABI(targetContractAddress, targetFunctionSelector); const targetFunctionData = FunctionData.fromAbi(targetAbi); + console.log(`callPrivateFunction `, targetFunctionData); const derivedCallContext = await this.deriveCallContext(callerContext, targetContractAddress, false, false); const context = this.context.extend(); @@ -301,6 +302,8 @@ export class PrivateFunctionExecution { ): Promise { const targetAbi = await this.context.db.getFunctionABI(targetContractAddress, targetFunctionSelector); const derivedCallContext = await this.deriveCallContext(callerContext, targetContractAddress, false, false); + + console.log(`enqueuePublicFunctionCall() `, FunctionData.fromAbi(targetAbi)); return PublicCallRequest.from({ args: targetArgs, callContext: derivedCallContext, diff --git a/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts b/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts index 828a5ffecd8..625b57abcfc 100644 --- a/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts +++ b/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts @@ -11,7 +11,7 @@ import { PrivateKey, PublicKey, } from '@aztec/circuits.js'; -import { FunctionType, encodeArguments } from '@aztec/foundation/abi'; +import { encodeArguments } from '@aztec/foundation/abi'; import { Fr } from '@aztec/foundation/fields'; import { DebugLogger, createDebugLogger } from '@aztec/foundation/log'; import { diff --git a/yarn-project/aztec.js/src/account_impl/single_key_account_contract.ts b/yarn-project/aztec.js/src/account_impl/single_key_account_contract.ts index 601cc66c7e2..8145f3e8754 100644 --- a/yarn-project/aztec.js/src/account_impl/single_key_account_contract.ts +++ b/yarn-project/aztec.js/src/account_impl/single_key_account_contract.ts @@ -7,7 +7,7 @@ import { TxContext, } from '@aztec/circuits.js'; import { Signer } from '@aztec/circuits.js/barretenberg'; -import { ContractAbi, encodeArguments, generateFunctionSelector } from '@aztec/foundation/abi'; +import { ContractAbi, encodeArguments } from '@aztec/foundation/abi'; import { ExecutionRequest, PackedArguments, TxExecutionRequest } from '@aztec/types'; import partition from 'lodash.partition'; diff --git a/yarn-project/aztec.js/src/account_impl/stored_key_account_contract.ts b/yarn-project/aztec.js/src/account_impl/stored_key_account_contract.ts index 4a06c5bdf8d..1345417b0e1 100644 --- a/yarn-project/aztec.js/src/account_impl/stored_key_account_contract.ts +++ b/yarn-project/aztec.js/src/account_impl/stored_key_account_contract.ts @@ -1,6 +1,6 @@ import { AztecAddress, CircuitsWasm, FunctionData, PrivateKey, TxContext } from '@aztec/circuits.js'; import { Signer } from '@aztec/circuits.js/barretenberg'; -import { ContractAbi, encodeArguments, generateFunctionSelector } from '@aztec/foundation/abi'; +import { ContractAbi, encodeArguments } from '@aztec/foundation/abi'; import { DebugLogger, createDebugLogger } from '@aztec/foundation/log'; import { ExecutionRequest, PackedArguments, TxExecutionRequest } from '@aztec/types'; diff --git a/yarn-project/aztec.js/src/contract/contract_function_interaction.ts b/yarn-project/aztec.js/src/contract/contract_function_interaction.ts index 63a9ea326df..f4f74d247cf 100644 --- a/yarn-project/aztec.js/src/contract/contract_function_interaction.ts +++ b/yarn-project/aztec.js/src/contract/contract_function_interaction.ts @@ -1,5 +1,5 @@ import { AztecAddress, Fr, FunctionData, TxContext } from '@aztec/circuits.js'; -import { FunctionAbi, FunctionType, encodeArguments, generateFunctionSelector } from '@aztec/foundation/abi'; +import { FunctionAbi, FunctionType, encodeArguments } from '@aztec/foundation/abi'; import { ExecutionRequest, Tx, TxExecutionRequest } from '@aztec/types'; import { Wallet } from '../aztec_rpc_client/wallet.js'; From 43fd125bdf335f212c6dee2f10e8e8668ad0ad0a Mon Sep 17 00:00:00 2001 From: LHerskind Date: Tue, 1 Aug 2023 12:15:54 +0000 Subject: [PATCH 3/5] chore: test use non-hardcoded --- .../src/client/private_execution.test.ts | 16 ++++++++++------ .../src/client/private_execution.ts | 2 -- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index 111a0bc741d..ca14cc0633e 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -238,11 +238,10 @@ describe('Private Execution test suite', () => { }); }); - it.only('should a constructor with arguments that inserts notes', async () => { + it('should a constructor with arguments that inserts notes', async () => { const abi = ZkTokenContractAbi.functions.find(f => f.name === 'constructor')!; const result = await runSimulator({ args: [140, owner], abi }); - console.log(result.callStackItem.publicInputs); expect(result.preimages.newNotes).toHaveLength(1); const newNote = result.preimages.newNotes[0]; @@ -398,7 +397,7 @@ describe('Private Execution test suite', () => { const parentAbi = ParentContractAbi.functions.find(f => f.name === 'entryPoint')!; const parentAddress = AztecAddress.random(); const childAddress = AztecAddress.random(); - const childSelector = Buffer.alloc(4, 1); // should match the call + const childSelector = generateFunctionSelector(childAbi.name, childAbi.parameters); oracle.getFunctionABI.mockImplementation(() => Promise.resolve(childAbi)); oracle.getPortalContractAddress.mockImplementation(() => Promise.resolve(EthAddress.ZERO)); @@ -512,13 +511,14 @@ describe('Private Execution test suite', () => { describe('enqueued calls', () => { it.each([false, true])('parent should enqueue call to child', async isInternal => { const parentAbi = ParentContractAbi.functions.find(f => f.name === 'enqueueCallToChild')!; + const childContractAbi = ParentContractAbi.functions[0]; const childAddress = AztecAddress.random(); const childPortalContractAddress = EthAddress.random(); - const childSelector = Buffer.alloc(4, 1); // should match the call + const childSelector = generateFunctionSelector(childContractAbi.name, childContractAbi.parameters); const parentAddress = AztecAddress.random(); oracle.getPortalContractAddress.mockImplementation(() => Promise.resolve(childPortalContractAddress)); - oracle.getFunctionABI.mockImplementation(() => Promise.resolve({ ...ChildContractAbi.functions[0], isInternal })); + oracle.getFunctionABI.mockImplementation(() => Promise.resolve({ ...childContractAbi, isInternal })); const args = [Fr.fromBuffer(childAddress.toBuffer()), Fr.fromBuffer(childSelector), 42n]; const result = await runSimulator({ @@ -527,10 +527,14 @@ describe('Private Execution test suite', () => { abi: parentAbi, args, }); + + // Alter function data (abi) to match the manipulated oracle + const functionData = FunctionData.fromAbi(childContractAbi); + functionData.isInternal = isInternal; const publicCallRequest = PublicCallRequest.from({ contractAddress: childAddress, - functionData: new FunctionData(childSelector, isInternal, false, false), + functionData: functionData, args: [new Fr(42n)], callContext: CallContext.from({ msgSender: parentAddress, diff --git a/yarn-project/acir-simulator/src/client/private_execution.ts b/yarn-project/acir-simulator/src/client/private_execution.ts index 3ccbdeca0d6..57fb3c34bc3 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.ts @@ -267,7 +267,6 @@ export class PrivateFunctionExecution { ) { const targetAbi = await this.context.db.getFunctionABI(targetContractAddress, targetFunctionSelector); const targetFunctionData = FunctionData.fromAbi(targetAbi); - console.log(`callPrivateFunction `, targetFunctionData); const derivedCallContext = await this.deriveCallContext(callerContext, targetContractAddress, false, false); const context = this.context.extend(); @@ -303,7 +302,6 @@ export class PrivateFunctionExecution { const targetAbi = await this.context.db.getFunctionABI(targetContractAddress, targetFunctionSelector); const derivedCallContext = await this.deriveCallContext(callerContext, targetContractAddress, false, false); - console.log(`enqueuePublicFunctionCall() `, FunctionData.fromAbi(targetAbi)); return PublicCallRequest.from({ args: targetArgs, callContext: derivedCallContext, From 1ebc91cfabd8d03415b1a10b2f08d94a22a235e8 Mon Sep 17 00:00:00 2001 From: LHerskind Date: Tue, 1 Aug 2023 12:25:00 +0000 Subject: [PATCH 4/5] =?UTF-8?q?chore:=20linter=20=F0=9F=A7=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acir-simulator/src/client/private_execution.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index ca14cc0633e..f748e38c567 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -527,7 +527,7 @@ describe('Private Execution test suite', () => { abi: parentAbi, args, }); - + // Alter function data (abi) to match the manipulated oracle const functionData = FunctionData.fromAbi(childContractAbi); functionData.isInternal = isInternal; From 827848877e3a5031536a847a5fe5d209caa3df7f Mon Sep 17 00:00:00 2001 From: LHerskind Date: Tue, 1 Aug 2023 12:37:57 +0000 Subject: [PATCH 5/5] chore: more bad selectors in tests --- yarn-project/acir-simulator/src/public/index.test.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index 0056a166468..a243a3185e7 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -7,9 +7,8 @@ import { PrivateHistoricTreeRoots, } from '@aztec/circuits.js'; import { pedersenPlookupCommitInputs } from '@aztec/circuits.js/barretenberg'; -import { FunctionAbi, encodeArguments } from '@aztec/foundation/abi'; +import { FunctionAbi, encodeArguments, generateFunctionSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { keccak } from '@aztec/foundation/crypto'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { toBigInt } from '@aztec/foundation/serialize'; @@ -63,7 +62,7 @@ describe('ACIR public execution simulator', () => { it('should run the mint function', async () => { const contractAddress = AztecAddress.random(); const mintAbi = PublicTokenContractAbi.functions.find(f => f.name === 'mint')!; - const functionData = new FunctionData(Buffer.alloc(4), false, false, false); + const functionData = FunctionData.fromAbi(mintAbi); const args = encodeArguments(mintAbi, [140, recipient]); const callContext = CallContext.from({ @@ -192,11 +191,14 @@ describe('ACIR public execution simulator', () => { async isInternal => { const parentContractAddress = AztecAddress.random(); const parentEntryPointFn = ParentContractAbi.functions.find(f => f.name === 'pubEntryPoint')!; - const parentEntryPointFnSelector = keccak(Buffer.from(parentEntryPointFn.name)).subarray(0, 4); + const parentEntryPointFnSelector = generateFunctionSelector( + parentEntryPointFn.name, + parentEntryPointFn.parameters, + ); const childContractAddress = AztecAddress.random(); const childValueFn = ChildContractAbi.functions.find(f => f.name === 'pubValue')!; - const childValueFnSelector = keccak(Buffer.from(childValueFn.name)).subarray(0, 4); + const childValueFnSelector = generateFunctionSelector(childValueFn.name, childValueFn.parameters); const initialValue = 3n;