Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(noir): Use context instead of custom oracles for public functions #1754

Merged
merged 5 commits into from
Aug 23, 2023
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
3 changes: 0 additions & 3 deletions yarn-project/acir-simulator/src/acvm/acvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ type ORACLE_NAMES =
| 'enqueuePublicFunctionCall'
| 'storageRead'
| 'storageWrite'
| 'createCommitment'
| 'createL2ToL1Message'
| 'createNullifier'
| 'getCommitment'
| 'getL1ToL2Message'
| 'getPortalContractAddress'
Expand Down
29 changes: 10 additions & 19 deletions yarn-project/acir-simulator/src/public/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ export class PublicExecutor {

const initialWitness = getInitialWitness(execution.args, execution.callContext, this.blockData, globalVariables);
const storageActions = new ContractStorageActionsCollector(this.stateDb, execution.contractAddress);
const newCommitments: Fr[] = [];
const newL2ToL1Messages: Fr[] = [];
const newNullifiers: Fr[] = [];
const nestedExecutions: PublicExecutionResult[] = [];
const unencryptedLogs = new FunctionL2Logs([]);
// Functions can request to pack arguments before calling other functions.
Expand Down Expand Up @@ -116,21 +113,6 @@ export class PublicExecutor {
}
return newValues.map(v => toACVMField(v));
},
createCommitment: async ([commitment]) => {
this.log('Creating commitment: ' + commitment.toString());
newCommitments.push(fromACVMField(commitment));
return await Promise.resolve(ZERO_ACVM_FIELD);
},
createL2ToL1Message: async ([message]) => {
this.log('Creating L2 to L1 message: ' + message.toString());
newL2ToL1Messages.push(fromACVMField(message));
return await Promise.resolve(ZERO_ACVM_FIELD);
},
createNullifier: async ([nullifier]) => {
this.log('Creating nullifier: ' + nullifier.toString());
newNullifiers.push(fromACVMField(nullifier));
return await Promise.resolve(ZERO_ACVM_FIELD);
},
callPublicFunction: async ([address], [functionSelector], [argsHash]) => {
const args = packedArgs.unpack(fromACVMField(argsHash));
this.log(`Public function call: addr=${address} selector=${functionSelector} args=${args.join(',')}`);
Expand Down Expand Up @@ -161,7 +143,16 @@ export class PublicExecutor {
},
});

const { returnValues } = extractPublicCircuitPublicInputs(partialWitness, acir);
const {
returnValues,
newL2ToL1Msgs,
newCommitments: newCommitmentsPadded,
newNullifiers: newNullifiersPadded,
} = extractPublicCircuitPublicInputs(partialWitness, acir);

const newL2ToL1Messages = newL2ToL1Msgs.filter(v => !v.isZero());
const newCommitments = newCommitmentsPadded.filter(v => !v.isZero());
const newNullifiers = newNullifiersPadded.filter(v => !v.isZero());

const [contractStorageReads, contractStorageUpdateRequests] = storageActions.collect();
this.log(
Expand Down
Loading