Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Oct 10, 2023
1 parent e57960d commit df2f9a1
Show file tree
Hide file tree
Showing 45 changed files with 324 additions and 308 deletions.
2 changes: 1 addition & 1 deletion yarn-project/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ COPY . .

# Generate Noir contract TypeScript artifacts.
COPY --from=noir /usr/src/yarn-project/noir-contracts/target /usr/src/yarn-project/noir-contracts/target
# Run yarn build to have the json ABIs available for the types generator, generate types, build again.
# Run yarn build to have the json artifacts available for the types generator, generate types, build again.
RUN apk add perl
RUN cd /usr/src/yarn-project/noir-contracts && yarn build && ./scripts/types_all.sh && yarn build
# Cleanup to reduce final image size.
Expand Down
20 changes: 10 additions & 10 deletions yarn-project/acir-simulator/src/client/client_execution_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ export class ClientExecutionContext extends ViewDataOracle {
`Calling private function ${this.contractAddress}:${functionSelector} from ${this.callContext.storageContractAddress}`,
);

const targetAbi = await this.db.getFunctionABI(targetContractAddress, functionSelector);
const targetFunctionData = FunctionData.fromAbi(targetAbi);
const targetArtifact = await this.db.getFunctionArtifact(targetContractAddress, functionSelector);
const targetFunctionData = FunctionData.fromAbi(targetArtifact);

const derivedTxContext = new TxContext(
false,
Expand All @@ -318,7 +318,7 @@ export class ClientExecutionContext extends ViewDataOracle {
this.txContext.version,
);

const derivedCallContext = await this.deriveCallContext(targetContractAddress, targetAbi, false, false);
const derivedCallContext = await this.deriveCallContext(targetContractAddress, targetArtifact, false, false);

const context = new ClientExecutionContext(
targetContractAddress,
Expand All @@ -336,7 +336,7 @@ export class ClientExecutionContext extends ViewDataOracle {

const childExecutionResult = await executePrivateFunction(
context,
targetAbi,
targetArtifact,
targetContractAddress,
targetFunctionData,
);
Expand All @@ -360,14 +360,14 @@ export class ClientExecutionContext extends ViewDataOracle {
functionSelector: FunctionSelector,
argsHash: Fr,
): Promise<PublicCallRequest> {
const targetAbi = await this.db.getFunctionABI(targetContractAddress, functionSelector);
const derivedCallContext = await this.deriveCallContext(targetContractAddress, targetAbi, false, false);
const targetArtifact = await this.db.getFunctionArtifact(targetContractAddress, functionSelector);
const derivedCallContext = await this.deriveCallContext(targetContractAddress, targetArtifact, false, false);
const args = this.packedArgsCache.unpack(argsHash);
const sideEffectCounter = this.sideEffectCounter.count();
const enqueuedRequest = PublicCallRequest.from({
args,
callContext: derivedCallContext,
functionData: FunctionData.fromAbi(targetAbi),
functionData: FunctionData.fromAbi(targetArtifact),
contractAddress: targetContractAddress,
sideEffectCounter,
});
Expand All @@ -388,14 +388,14 @@ export class ClientExecutionContext extends ViewDataOracle {
/**
* Derives the call context for a nested execution.
* @param targetContractAddress - The address of the contract being called.
* @param targetAbi - The ABI of the function being called.
* @param targetArtifact - The artifact of the function being called.
* @param isDelegateCall - Whether the call is a delegate call.
* @param isStaticCall - Whether the call is a static call.
* @returns The derived call context.
*/
private async deriveCallContext(
targetContractAddress: AztecAddress,
targetAbi: FunctionArtifact,
targetArtifact: FunctionArtifact,
isDelegateCall = false,
isStaticCall = false,
) {
Expand All @@ -404,7 +404,7 @@ export class ClientExecutionContext extends ViewDataOracle {
this.contractAddress,
targetContractAddress,
portalContractAddress,
FunctionSelector.fromNameAndParameters(targetAbi.name, targetAbi.parameters),
FunctionSelector.fromNameAndParameters(targetArtifact.name, targetArtifact.parameters),
isDelegateCall,
isStaticCall,
false,
Expand Down
13 changes: 8 additions & 5 deletions yarn-project/acir-simulator/src/client/db_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { NoteData } from '../acvm/index.js';
import { CommitmentsDB } from '../public/index.js';

/**
* A function ABI with optional debug metadata
* A function artifact with optional debug metadata
*/
export interface FunctionAbiWithDebugMetadata extends FunctionArtifact {
export interface FunctionArtifactWithDebugMetadata extends FunctionArtifact {
/**
* Debug metadata for the function.
*/
Expand Down Expand Up @@ -59,14 +59,17 @@ export interface DBOracle extends CommitmentsDB {
getNotes(contractAddress: AztecAddress, storageSlot: Fr): Promise<NoteData[]>;

/**
* Retrieve the ABI information of a specific function within a contract.
* Retrieve the artifact information of a specific function within a contract.
* The function is identified by its selector, which is a unique identifier generated from the function signature.
*
* @param contractAddress - The contract address.
* @param selector - The corresponding function selector.
* @returns A Promise that resolves to a FunctionAbi object containing the ABI information of the target function.
* @returns A Promise that resolves to a FunctionArtifact object containing the ARTIFACT information of the target function.
*/
getFunctionABI(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionAbiWithDebugMetadata>;
getFunctionArtifact(
contractAddress: AztecAddress,
selector: FunctionSelector,
): Promise<FunctionArtifactWithDebugMetadata>;

/**
* Retrieves the portal contract address associated with the given contract address.
Expand Down
Loading

0 comments on commit df2f9a1

Please sign in to comment.