Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Feb 9, 2024
1 parent 78099be commit ec2f8f7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 0 additions & 1 deletion yarn-project/noir-compiler/src/cli/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export function generateCode(outputPath: string, fileOrDirPath: string, opts: Ge
*/
function generateFromNoirAbi(outputPath: string, noirAbiPath: string, opts: GenerateCodeOptions = {}) {
const contract = JSON.parse(readFileSync(noirAbiPath, 'utf8'));

const aztecAbi = loadContractArtifact(contract);
const { nr, ts } = opts;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { JournalData } from './journal/journal.js';
* @param globalVariables
* @returns
*/
export function temporaryMapToExecutionEnvironment(
export function temporaryCreateAvmExecutionEnvironment(
current: PublicExecution,
globalVariables: GlobalVariables,
): AvmExecutionEnvironment {
Expand Down Expand Up @@ -54,7 +54,7 @@ export function temporaryMapToExecutionEnvironment(
* @param result
* @returns
*/
export function temporaryMapAvmReturnTypes(
export function temporaryConvertAvmResults(
execution: PublicExecution,
newWorldState: JournalData,
result: AvmContractCallResults,
Expand Down
9 changes: 6 additions & 3 deletions yarn-project/simulator/src/public/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { AvmMachineState } from '../avm/avm_machine_state.js';
import { AvmSimulator } from '../avm/avm_simulator.js';
import { HostStorage } from '../avm/journal/host_storage.js';
import { AvmWorldStateJournal } from '../avm/journal/index.js';
import { temporaryMapAvmReturnTypes, temporaryMapToExecutionEnvironment } from '../avm/temporary_executor_migration.js';
import {
temporaryConvertAvmResults,
temporaryCreateAvmExecutionEnvironment,
} from '../avm/temporary_executor_migration.js';
import { ExecutionError, createSimulationError } from '../common/errors.js';
import { SideEffectCounter } from '../common/index.js';
import { PackedArgsCache } from '../common/packed_args_cache.js';
Expand Down Expand Up @@ -142,14 +145,14 @@ export class PublicExecutor {
// These data structures will permiate across the simulator when the public executor is phased out
const hostStorage = new HostStorage(this.stateDb, this.contractsDb, this.commitmentsDb);
const worldStateJournal = new AvmWorldStateJournal(hostStorage);
const executionEnv = temporaryMapToExecutionEnvironment(execution, globalVariables);
const executionEnv = temporaryCreateAvmExecutionEnvironment(execution, globalVariables);
const machineState = new AvmMachineState(0, 0, 0);

const context = new AvmContext(worldStateJournal, executionEnv, machineState);
const simulator = new AvmSimulator(context);

const result = await simulator.execute();
const newWorldState = context.worldState.flush();
return temporaryMapAvmReturnTypes(execution, newWorldState, result);
return temporaryConvertAvmResults(execution, newWorldState, result);
}
}
5 changes: 5 additions & 0 deletions yarn-project/types/src/abi/contract_artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ function generateFunctionArtifact(fn: NoirCompiledContractFunction): FunctionArt

/**
* Returns true if the first parameter is kernel function inputs.
*
* Noir macros #[aztec(private|public)] inject the following code
* fn <name>(inputs: <Public|Private>ContextInputs, ...otherparams) {}
*
* Return true if this injected parameter is found
*/
function hasKernelFunctionInputs(params: ABIParameter[]): boolean {
const firstParam = params[0];
Expand Down

0 comments on commit ec2f8f7

Please sign in to comment.