Skip to content

Commit

Permalink
nuked toACVMGlobalVariables
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Jan 31, 2024
1 parent 27f7811 commit 9e96729
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 22 deletions.
17 changes: 1 addition & 16 deletions yarn-project/acir-simulator/src/acvm/serialize.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {
GlobalVariables,
PrivateCallStackItem,
PrivateCircuitPublicInputs,
PublicCallRequest,
PublicCallRequest
} from '@aztec/circuits.js';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { EthAddress } from '@aztec/foundation/eth-address';
Expand Down Expand Up @@ -49,20 +48,6 @@ export function toACVMField(
// Utilities to write TS classes to ACVM Field arrays
// In the order that the ACVM expects them

/**
* Converts global variables into ACVM fields
* @param globalVariables - The global variables object to convert.
* @returns The ACVM fields
*/
export function toACVMGlobalVariables(globalVariables: GlobalVariables): ACVMField[] {
return [
toACVMField(globalVariables.chainId),
toACVMField(globalVariables.version),
toACVMField(globalVariables.blockNumber),
toACVMField(globalVariables.timestamp),
];
}

/**
* Converts the public inputs structure to ACVM fields.
* @param publicInputs - The public inputs to convert.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { createDebugLogger } from '@aztec/foundation/log';

import { TypedOracle, toACVMField, toACVMGlobalVariables, toACVMWitness } from '../acvm/index.js';
import { TypedOracle, toACVMWitness } from '../acvm/index.js';
import { PackedArgsCache, SideEffectCounter } from '../common/index.js';
import { CommitmentsDB, PublicContractsDB, PublicStateDB } from './db.js';
import { PublicExecution, PublicExecutionResult } from './execution.js';
Expand Down Expand Up @@ -50,9 +50,9 @@ export class PublicExecutionContext extends TypedOracle {
public getInitialWitness(witnessStartIndex = 0) {
const { callContext, args } = this.execution;
const fields = [
...callContext.toFields().map(toACVMField),
...this.header.toFields().map(toACVMField),
...toACVMGlobalVariables(this.globalVariables),
...callContext.toFields(),
...this.header.toFields(),
...this.globalVariables.toFields(),

...args,
];
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/structs/global_variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class GlobalVariables {
return serializeToBuffer(...GlobalVariables.getFields(this));
}

toFieldArray() {
toFields() {
return GlobalVariables.getFields(this);
}

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/structs/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class Header {
...this.lastArchive.toFieldArray(),
...to2Fields(this.bodyHash),
...this.state.toFieldArray(),
...this.globalVariables.toFieldArray(),
...this.globalVariables.toFields(),
];
if (serialized.length !== HEADER_LENGTH) {
throw new Error(`Expected header to have ${HEADER_LENGTH} fields, but it has ${serialized.length} fields`);
Expand Down

0 comments on commit 9e96729

Please sign in to comment.