Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 6 additions & 32 deletions yarn-project/foundation/src/abi/abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,14 @@ export interface FunctionAbi {
* The artifact entry of a function.
*/
export interface FunctionArtifact extends FunctionAbi {
/**
* The ACIR bytecode of the function.
*/
/** The ACIR bytecode of the function. */
bytecode: Buffer;
/**
* The verification key of the function.
*/
/** The verification key of the function. */
verificationKey?: string;
/**
* Maps opcodes to source code pointers
*/
/** Maps opcodes to source code pointers */
debugSymbols: string;
/** Debug metadata for the function. */
debug?: FunctionDebugMetadata;
}

/**
Expand Down Expand Up @@ -350,14 +346,8 @@ export interface FunctionDebugMetadata {
files: DebugFileMap;
}

/** A function artifact with optional debug metadata */
export interface FunctionArtifactWithDebugMetadata extends FunctionArtifact {
/** Debug metadata for the function. */
debug?: FunctionDebugMetadata;
}

/**
* Gets a function artifact given its name or selector.
* Gets a function artifact including debug metadata given its name or selector.
*/
export function getFunctionArtifact(
artifact: ContractArtifact,
Expand All @@ -371,22 +361,6 @@ export function getFunctionArtifact(
if (!functionArtifact) {
throw new Error(`Unknown function ${functionNameOrSelector}`);
}
return functionArtifact;
}

/** @deprecated Use getFunctionArtifact instead */
export function getFunctionArtifactWithSelector(artifact: ContractArtifact, selector: FunctionSelector) {
return getFunctionArtifact(artifact, selector);
}

/**
* Gets a function artifact including debug metadata given its name or selector.
*/
export function getFunctionArtifactWithDebugMetadata(
artifact: ContractArtifact,
functionNameOrSelector: string | FunctionSelector,
): FunctionArtifactWithDebugMetadata {
const functionArtifact = getFunctionArtifact(artifact, functionNameOrSelector);
const debugMetadata = getFunctionDebugMetadata(artifact, functionArtifact);
return { ...functionArtifact, debug: debugMetadata };
}
Expand Down
11 changes: 4 additions & 7 deletions yarn-project/pxe/src/simulator_oracle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
type Point,
} from '@aztec/circuits.js';
import { computeL1ToL2MessageNullifier } from '@aztec/circuits.js/hash';
import { type FunctionArtifactWithDebugMetadata, getFunctionArtifactWithDebugMetadata } from '@aztec/foundation/abi';
import { type FunctionArtifact, getFunctionArtifact } from '@aztec/foundation/abi';
import { createDebugLogger } from '@aztec/foundation/log';
import { type DBOracle, MessageLoadOracleInputs, type NullifierKeys } from '@aztec/simulator';
import { type ContractInstance } from '@aztec/types/contracts';
Expand Down Expand Up @@ -107,10 +107,7 @@ export class SimulatorOracle implements DBOracle {
}));
}

async getFunctionArtifact(
contractAddress: AztecAddress,
selector: FunctionSelector,
): Promise<FunctionArtifactWithDebugMetadata> {
async getFunctionArtifact(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionArtifact> {
const artifact = await this.contractDataOracle.getFunctionArtifact(contractAddress, selector);
const debug = await this.contractDataOracle.getFunctionDebugMetadata(contractAddress, selector);
return {
Expand All @@ -122,10 +119,10 @@ export class SimulatorOracle implements DBOracle {
async getFunctionArtifactByName(
contractAddress: AztecAddress,
functionName: string,
): Promise<FunctionArtifactWithDebugMetadata | undefined> {
): Promise<FunctionArtifact | undefined> {
const instance = await this.contractDataOracle.getContractInstance(contractAddress);
const artifact = await this.contractDataOracle.getContractArtifact(instance.contractClassId);
return artifact && getFunctionArtifactWithDebugMetadata(artifact, functionName);
return artifact && getFunctionArtifact(artifact, functionName);
}

/**
Expand Down
12 changes: 3 additions & 9 deletions yarn-project/simulator/src/client/db_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type PublicDataWitness,
} from '@aztec/circuit-types';
import { type CompleteAddress, type Header } from '@aztec/circuits.js';
import { type FunctionArtifactWithDebugMetadata, type FunctionSelector } from '@aztec/foundation/abi';
import { type FunctionArtifact, type FunctionSelector } from '@aztec/foundation/abi';
import { type AztecAddress } from '@aztec/foundation/aztec-address';
import { type Fr, type Point } from '@aztec/foundation/fields';
import { type ContractInstance } from '@aztec/types/contracts';
Expand Down Expand Up @@ -102,10 +102,7 @@ export interface DBOracle extends CommitmentsDB {
* @param selector - The corresponding function selector.
* @returns A Promise that resolves to a FunctionArtifact object.
*/
getFunctionArtifact(
contractAddress: AztecAddress,
selector: FunctionSelector,
): Promise<FunctionArtifactWithDebugMetadata>;
getFunctionArtifact(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionArtifact>;

/**
* Retrieves the artifact of a specified function within a given contract.
Expand All @@ -115,10 +112,7 @@ export interface DBOracle extends CommitmentsDB {
* @param functionName - The name of the function.
* @returns The corresponding function's artifact as an object.
*/
getFunctionArtifactByName(
contractAddress: AztecAddress,
functionName: string,
): Promise<FunctionArtifactWithDebugMetadata | undefined>;
getFunctionArtifactByName(contractAddress: AztecAddress, functionName: string): Promise<FunctionArtifact | undefined>;

/**
* Gets the index of a nullifier in the nullifier tree.
Expand Down
10 changes: 2 additions & 8 deletions yarn-project/simulator/src/client/private_execution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ import {
} from '@aztec/circuits.js';
import { computeCommitmentNonce, computeSecretHash, computeVarArgsHash } from '@aztec/circuits.js/hash';
import { makeHeader } from '@aztec/circuits.js/testing';
import {
type FunctionArtifact,
FunctionSelector,
encodeArguments,
getFunctionArtifact,
getFunctionArtifactWithSelector,
} from '@aztec/foundation/abi';
import { type FunctionArtifact, FunctionSelector, encodeArguments, getFunctionArtifact } from '@aztec/foundation/abi';
import { asyncMap } from '@aztec/foundation/async-map';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { times } from '@aztec/foundation/collection';
Expand Down Expand Up @@ -871,7 +865,7 @@ describe('Private Execution test suite', () => {

beforeEach(() => {
oracle.getFunctionArtifact.mockImplementation((_, selector) =>
Promise.resolve(getFunctionArtifactWithSelector(PendingNoteHashesContractArtifact, selector)),
Promise.resolve(getFunctionArtifact(PendingNoteHashesContractArtifact, selector)),
);
oracle.getFunctionArtifactByName.mockImplementation((_, functionName: string) =>
Promise.resolve(getFunctionArtifact(PendingNoteHashesContractArtifact, functionName)),
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/simulator/src/client/private_execution.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type FunctionData, PrivateCallStackItem, PrivateCircuitPublicInputs } from '@aztec/circuits.js';
import { type FunctionArtifactWithDebugMetadata } from '@aztec/foundation/abi';
import { type FunctionArtifact } from '@aztec/foundation/abi';
import { type AztecAddress } from '@aztec/foundation/aztec-address';
import { createDebugLogger } from '@aztec/foundation/log';

Expand All @@ -15,7 +15,7 @@ import { AcirSimulator } from './simulator.js';
*/
export async function executePrivateFunction(
context: ClientExecutionContext,
artifact: FunctionArtifactWithDebugMetadata,
artifact: FunctionArtifact,
contractAddress: AztecAddress,
functionData: FunctionData,
log = createDebugLogger('aztec:simulator:secret_execution'),
Expand Down
10 changes: 3 additions & 7 deletions yarn-project/simulator/src/client/simulator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import {
computeUniqueNoteHash,
siloNoteHash,
} from '@aztec/circuits.js/hash';
import {
ABIParameterVisibility,
type FunctionArtifactWithDebugMetadata,
getFunctionArtifact,
} from '@aztec/foundation/abi';
import { ABIParameterVisibility, type FunctionArtifact, getFunctionArtifact } from '@aztec/foundation/abi';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { poseidon2Hash } from '@aztec/foundation/crypto';
import { Fr } from '@aztec/foundation/fields';
Expand Down Expand Up @@ -100,7 +96,7 @@ describe('Simulator', () => {
it('throw if "compute_note_hash_and_nullifier" has the wrong number of parameters', async () => {
const note = createNote();

const modifiedArtifact: FunctionArtifactWithDebugMetadata = {
const modifiedArtifact: FunctionArtifact = {
...artifact,
parameters: artifact.parameters.slice(1),
};
Expand All @@ -119,7 +115,7 @@ describe('Simulator', () => {
const note = createNote();
const wrongPreimageLength = note.length - 1;

const modifiedArtifact: FunctionArtifactWithDebugMetadata = {
const modifiedArtifact: FunctionArtifact = {
...artifact,
parameters: [
...artifact.parameters.slice(0, -1),
Expand Down
8 changes: 4 additions & 4 deletions yarn-project/simulator/src/client/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type AztecNode, type FunctionCall, type Note, type TxExecutionRequest }
import { CallContext, FunctionData } from '@aztec/circuits.js';
import {
type ArrayType,
type FunctionArtifactWithDebugMetadata,
type FunctionArtifact,
FunctionSelector,
FunctionType,
encodeArguments,
Expand Down Expand Up @@ -65,7 +65,7 @@ export class AcirSimulator {
*/
public async run(
request: TxExecutionRequest,
entryPointArtifact: FunctionArtifactWithDebugMetadata,
entryPointArtifact: FunctionArtifact,
contractAddress: AztecAddress,
msgSender = AztecAddress.ZERO,
): Promise<ExecutionResult> {
Expand Down Expand Up @@ -129,7 +129,7 @@ export class AcirSimulator {
*/
public async runUnconstrained(
request: FunctionCall,
entryPointArtifact: FunctionArtifactWithDebugMetadata,
entryPointArtifact: FunctionArtifact,
contractAddress: AztecAddress,
) {
if (entryPointArtifact.functionType !== FunctionType.UNCONSTRAINED) {
Expand Down Expand Up @@ -167,7 +167,7 @@ export class AcirSimulator {
noteTypeId: Fr,
note: Note,
) {
const artifact: FunctionArtifactWithDebugMetadata | undefined = await this.db.getFunctionArtifactByName(
const artifact: FunctionArtifact | undefined = await this.db.getFunctionArtifactByName(
contractAddress,
'compute_note_hash_and_nullifier',
);
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/simulator/src/client/unconstrained_execution.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type FunctionData } from '@aztec/circuits.js';
import { type DecodedReturn, type FunctionArtifactWithDebugMetadata, decodeReturnValues } from '@aztec/foundation/abi';
import { type DecodedReturn, type FunctionArtifact, decodeReturnValues } from '@aztec/foundation/abi';
import { type AztecAddress } from '@aztec/foundation/aztec-address';
import { type Fr } from '@aztec/foundation/fields';
import { createDebugLogger } from '@aztec/foundation/log';
Expand All @@ -16,7 +16,7 @@ import { type ViewDataOracle } from './view_data_oracle.js';
*/
export async function executeUnconstrainedFunction(
oracle: ViewDataOracle,
artifact: FunctionArtifactWithDebugMetadata,
artifact: FunctionArtifact,
contractAddress: AztecAddress,
functionData: FunctionData,
args: Fr[],
Expand Down