From a4fd58845ce7ce732720b5ceb0186ebd1836ddef Mon Sep 17 00:00:00 2001 From: LHerskind Date: Thu, 22 Aug 2024 18:36:54 +0000 Subject: [PATCH] chore: address comments --- l1-contracts/src/core/Rollup.sol | 7 ++----- l1-contracts/src/core/libraries/ConstantsGen.sol | 2 ++ .../noir-protocol-circuits/crates/types/src/constants.nr | 4 ++++ yarn-project/circuits.js/src/constants.gen.ts | 1 + .../src/composed/integration_l1_publisher.test.ts | 5 +++-- yarn-project/ethereum/src/deploy_l1_contracts.ts | 3 ++- yarn-project/sequencer-client/src/publisher/config.ts | 1 + .../sequencer-client/src/publisher/l1-publisher.ts | 2 ++ yarn-project/sequencer-client/src/sequencer/sequencer.ts | 2 -- 9 files changed, 17 insertions(+), 10 deletions(-) diff --git a/l1-contracts/src/core/Rollup.sol b/l1-contracts/src/core/Rollup.sol index e37715ccb8a9..a074aedcb0ad 100644 --- a/l1-contracts/src/core/Rollup.sol +++ b/l1-contracts/src/core/Rollup.sol @@ -88,11 +88,8 @@ contract Rollup is Leonidas, IRollup, ITestRollup { VERSION = 1; // Genesis block - blocks[0] = BlockLog({ - archive: bytes32(0x1200a06aae1368abe36530b585bd7a4d2ba4de5037b82076412691a187d7621e), - slotNumber: 0, - isProven: true - }); + blocks[0] = + BlockLog({archive: bytes32(Constants.GENESIS_ARCHIVE_ROOT), slotNumber: 0, isProven: true}); pendingBlockCount = 1; provenBlockCount = 1; } diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index 6153b55b63d8..5a43d9abae22 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -103,6 +103,8 @@ library Constants { uint256 internal constant AZTEC_SLOT_DURATION = 12; uint256 internal constant AZTEC_EPOCH_DURATION = 48; uint256 internal constant IS_DEV_NET = 1; + uint256 internal constant GENESIS_ARCHIVE_ROOT = + 8142738430000951296386584486068033372964809139261822027365426310856631083550; uint256 internal constant FEE_JUICE_INITIAL_MINT = 20000000000; uint256 internal constant MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 20000; uint256 internal constant MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 3000; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index d3842a0bda04..bb4f873b846a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -132,9 +132,13 @@ global INITIALIZATION_SLOT_SEPARATOR: Field = 1000_000_000; global INITIAL_L2_BLOCK_NUM: Field = 1; global BLOB_SIZE_IN_BYTES: Field = 31 * 4096; global ETHEREUM_SLOT_DURATION: u32 = 12; +// AZTEC_SLOT_DURATION should be a multiple of ETHEREUM_SLOT_DURATION global AZTEC_SLOT_DURATION: u32 = ETHEREUM_SLOT_DURATION * 1; global AZTEC_EPOCH_DURATION: u32 = 48; global IS_DEV_NET: bool = true; +// The following is taken from building a block and looking at the `lastArchive` value in it. +// You can run the `integration_l1_publisher.test.ts` and look at the first blocks in the fixtures. +global GENESIS_ARCHIVE_ROOT: Field = 0x1200a06aae1368abe36530b585bd7a4d2ba4de5037b82076412691a187d7621e; // The following and the value in `deploy_l1_contracts´ must match. We should not have the code both places, but // we are running into circular dependency issues. #3342 global FEE_JUICE_INITIAL_MINT: Field = 20000000000; diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index c8358a58ead4..2a57e9ab9173 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -89,6 +89,7 @@ export const ETHEREUM_SLOT_DURATION = 12; export const AZTEC_SLOT_DURATION = 12; export const AZTEC_EPOCH_DURATION = 48; export const IS_DEV_NET = 1; +export const GENESIS_ARCHIVE_ROOT = 8142738430000951296386584486068033372964809139261822027365426310856631083550n; export const FEE_JUICE_INITIAL_MINT = 20000000000; export const MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 20000; export const MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 3000; diff --git a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts index fd8cb4eb86fe..b1c79f33c9b5 100644 --- a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts @@ -21,6 +21,7 @@ import { import { ETHEREUM_SLOT_DURATION, EthAddress, + GENESIS_ARCHIVE_ROOT, GasFees, type Header, KernelCircuitPublicInputs, @@ -351,7 +352,7 @@ describe('L1Publisher integration', () => { it(`Build ${numberOfConsecutiveBlocks} blocks of 4 bloated txs building on each other`, async () => { const archiveInRollup_ = await rollup.read.archive(); - expect(hexStringToBuffer(archiveInRollup_.toString())).toEqual(INITIAL_ARCHIVE); + expect(hexStringToBuffer(archiveInRollup_.toString())).toEqual(GENESIS_ARCHIVE_ROOT); const blockNumber = await publicClient.getBlockNumber(); // random recipient address, just kept consistent for easy testing ts/sol. @@ -475,7 +476,7 @@ describe('L1Publisher integration', () => { it(`Build ${numberOfConsecutiveBlocks} blocks of 2 empty txs building on each other`, async () => { const archiveInRollup_ = await rollup.read.archive(); - expect(hexStringToBuffer(archiveInRollup_.toString())).toEqual(INITIAL_ARCHIVE); + expect(hexStringToBuffer(archiveInRollup_.toString())).toEqual(GENESIS_ARCHIVE_ROOT); const blockNumber = await publicClient.getBlockNumber(); diff --git a/yarn-project/ethereum/src/deploy_l1_contracts.ts b/yarn-project/ethereum/src/deploy_l1_contracts.ts index a180e1fc48f6..ef2f85645726 100644 --- a/yarn-project/ethereum/src/deploy_l1_contracts.ts +++ b/yarn-project/ethereum/src/deploy_l1_contracts.ts @@ -242,7 +242,8 @@ export const deployL1Contracts = async ( client: walletClient, }); - // @note We make a time jump PAST the very first slot to not have to deal with the edge case of the first slot + // @note We make a time jump PAST the very first slot to not have to deal with the edge case of the first slot. + // The edge case being that the genesis block is already occupying slot 0, so we cannot have another block. try { // Need to get the time const currentSlot = (await rollup.read.getCurrentSlot([])) as bigint; diff --git a/yarn-project/sequencer-client/src/publisher/config.ts b/yarn-project/sequencer-client/src/publisher/config.ts index 65faaf37dc4e..b31fdd3b2519 100644 --- a/yarn-project/sequencer-client/src/publisher/config.ts +++ b/yarn-project/sequencer-client/src/publisher/config.ts @@ -26,6 +26,7 @@ export interface PublisherConfig { l1PublishRetryIntervalMS: number; /** * Whether the publisher is a time traveler and can warp the underlying chain + * @todo #8153 - Remove this flag once the time traveler is removed */ timeTraveler: boolean; } diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 620f674cbcf7..3af6b929f654 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -314,6 +314,8 @@ export class L1Publisher { // Time jumps only allowed into the future. // // If this is run on top of a real chain, the time lords will catch you. + // + // @todo #8153 if (!this.timeTraveler) { return; diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.ts index 929f30cd1694..d71c8f01551a 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.ts @@ -440,8 +440,6 @@ export class Sequencer { return true; } - async assertCanStillProposeBlock(): Promise {} - @trackSpan( 'Sequencer.buildBlockAndPublish', (_validTxs, newGlobalVariables, _historicalHeader, _chainTipArchive) => ({