diff --git a/yarn-project/circuit-types/src/l2_block.ts b/yarn-project/circuit-types/src/l2_block.ts index 620659b01f13..0f7dc8844e84 100644 --- a/yarn-project/circuit-types/src/l2_block.ts +++ b/yarn-project/circuit-types/src/l2_block.ts @@ -9,7 +9,7 @@ import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, STRING_ENCODING, } from '@aztec/circuits.js'; -import { makeAppendOnlyTreeSnapshot, makeGlobalVariables, makeHeader } from '@aztec/circuits.js/factories'; +import { makeAppendOnlyTreeSnapshot, makeHeader } from '@aztec/circuits.js/factories'; import { times } from '@aztec/foundation/collection'; import { keccak, sha256 } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; @@ -139,8 +139,6 @@ export class L2Block { numEncryptedLogsPerCall = 2, numUnencryptedLogsPerCall = 1, ): L2Block { - const globalVariables = makeGlobalVariables(0, l2BlockNum); - const newNullifiers = times(MAX_NEW_NULLIFIERS_PER_TX * txsPerBlock, Fr.random); const newCommitments = times(MAX_NEW_COMMITMENTS_PER_TX * txsPerBlock, Fr.random); const newContracts = times(MAX_NEW_CONTRACTS_PER_TX * txsPerBlock, Fr.random); @@ -164,7 +162,7 @@ export class L2Block { return L2Block.fromFields( { archive: makeAppendOnlyTreeSnapshot(1), - header: makeHeader(0, globalVariables), + header: makeHeader(0, l2BlockNum), newCommitments, newNullifiers, newContracts, diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index dc56fe364597..f56175e9d095 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -888,18 +888,17 @@ export function makeRootRollupInputs(seed = 0, globalVariables?: GlobalVariables /** * Makes root rollup public inputs. * @param seed - The seed to use for generating the root rollup public inputs. - * @param blockNumber - The block number to use for generating the root rollup public inputs. - * if blockNumber is undefined, it will be set to seed + 2. + * @param blockNumber - The block number to use in the global variables of a header. * @returns A root rollup public inputs. */ export function makeRootRollupPublicInputs( seed = 0, - globalVariables: GlobalVariables | undefined = undefined, + blockNumber: number | undefined = undefined, ): RootRollupPublicInputs { return RootRollupPublicInputs.from({ aggregationObject: makeAggregationObject(seed), archive: makeAppendOnlyTreeSnapshot(seed + 0x100), - header: makeHeader(seed + 0x200, globalVariables), + header: makeHeader(seed + 0x200, blockNumber), l1ToL2MessagesHash: [new Fr(3n), new Fr(4n)], }); } @@ -907,14 +906,12 @@ export function makeRootRollupPublicInputs( /** * Makes header. */ -// TODO(benesjan): is passing in global vars separately really used? -// would it be better to just allow for setting block num? -export function makeHeader(seed = 0, globalVariables: GlobalVariables | undefined): Header { +export function makeHeader(seed = 0, blockNumber: number | undefined = undefined): Header { return new Header( makeAppendOnlyTreeSnapshot(seed + 0x100), toBufferBE(BigInt(seed + 0x200), NUM_BYTES_PER_SHA256), makeStateReference(seed + 0x300), - globalVariables ?? makeGlobalVariables((seed += 0x400)), + makeGlobalVariables((seed += 0x400), blockNumber), ); } diff --git a/yarn-project/pxe/src/database/pxe_database_test_suite.ts b/yarn-project/pxe/src/database/pxe_database_test_suite.ts index f52d60897044..3583d2a20814 100644 --- a/yarn-project/pxe/src/database/pxe_database_test_suite.ts +++ b/yarn-project/pxe/src/database/pxe_database_test_suite.ts @@ -156,10 +156,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { describe('block header', () => { it('stores and retrieves the block header', async () => { - // TODO(benesjan): make this more straightforward? - const randomInt = () => Math.floor(Math.random() * 1000); - const globalVariables = makeGlobalVariables(randomInt(), INITIAL_L2_BLOCK_NUM); - const header = makeHeader(randomInt(), globalVariables); + const header = makeHeader(Math.floor(Math.random() * 1000), INITIAL_L2_BLOCK_NUM); await database.setHeader(header); expect(database.getHeader()).toEqual(header); diff --git a/yarn-project/pxe/src/synchronizer/synchronizer.test.ts b/yarn-project/pxe/src/synchronizer/synchronizer.test.ts index 42524fb8dd81..3b0fb55f767c 100644 --- a/yarn-project/pxe/src/synchronizer/synchronizer.test.ts +++ b/yarn-project/pxe/src/synchronizer/synchronizer.test.ts @@ -1,7 +1,7 @@ import { AztecNode, INITIAL_L2_BLOCK_NUM, L2Block } from '@aztec/circuit-types'; import { CompleteAddress, Fr, GrumpkinScalar, Header } from '@aztec/circuits.js'; import { Grumpkin } from '@aztec/circuits.js/barretenberg'; -import { makeGlobalVariables, makeHeader } from '@aztec/circuits.js/factories'; +import { makeHeader } from '@aztec/circuits.js/factories'; import { SerialQueue } from '@aztec/foundation/fifo'; import { TestKeyStore } from '@aztec/key-store'; import { AztecLmdbStore } from '@aztec/kv-store'; @@ -22,10 +22,7 @@ describe('Synchronizer', () => { let headerBlock3: Header; beforeEach(async () => { - // TODO(benesjan): make this more straightforward? - const randomInt = () => Math.floor(Math.random() * 1000); - const globalVariables = makeGlobalVariables(randomInt(), initialSyncBlockNumber); - headerBlock3 = makeHeader(randomInt(), globalVariables); + headerBlock3 = makeHeader(Math.floor(Math.random() * 1000), initialSyncBlockNumber); aztecNode = mock(); database = new KVPxeDatabase(await AztecLmdbStore.openTmp()); diff --git a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts index f3f2b1ecc357..27f6e78a20b9 100644 --- a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts +++ b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts @@ -109,7 +109,8 @@ describe('sequencer/solo_block_builder', () => { // Create mock outputs for simulator baseRollupOutputLeft = makeBaseOrMergeRollupPublicInputs(0, globalVariables); baseRollupOutputRight = makeBaseOrMergeRollupPublicInputs(0, globalVariables); - rootRollupOutput = makeRootRollupPublicInputs(0, globalVariables); + rootRollupOutput = makeRootRollupPublicInputs(0); + rootRollupOutput.header.globalVariables = globalVariables; // Set up mocks prover.getBaseRollupProof.mockResolvedValue(emptyProof);