From 60654381aec98f7630b1b02ac61a3874c98aa5f5 Mon Sep 17 00:00:00 2001
From: benesjan <janbenes1234@gmail.com>
Date: Mon, 4 Mar 2024 15:37:13 +0000
Subject: [PATCH] refactor: mocing types consts to constants.nr

---
 l1-contracts/src/core/libraries/ConstantsGen.sol   |  2 ++
 .../crates/types/src/constants.nr                  |  2 ++
 .../src/archiver/archiver_store_test_suite.ts      |  3 +--
 .../src/archiver/kv_archiver_store/block_store.ts  |  4 ++--
 .../src/archiver/kv_archiver_store/log_store.ts    |  2 +-
 .../memory_archiver_store/memory_archiver_store.ts |  3 +--
 yarn-project/aztec-node/src/aztec-node/server.ts   |  2 +-
 yarn-project/aztec.js/src/index.ts                 |  2 +-
 yarn-project/circuit-types/src/constants.ts        |  2 --
 yarn-project/circuit-types/src/index.ts            |  1 -
 .../src/l2_block_downloader/l2_block_downloader.ts |  2 +-
 yarn-project/circuit-types/src/logs/log_id.ts      |  3 +--
 yarn-project/circuits.js/src/constants.gen.ts      |  2 ++
 yarn-project/p2p/src/client/p2p_client.ts          | 11 ++---------
 yarn-project/pxe/src/config/index.ts               |  2 +-
 .../pxe/src/database/pxe_database_test_suite.ts    |  4 ++--
 .../pxe/src/note_processor/note_processor.test.ts  |  3 +--
 .../pxe/src/note_processor/note_processor.ts       | 12 ++----------
 .../pxe/src/pxe_service/test/pxe_service.test.ts   |  3 ++-
 .../pxe/src/pxe_service/test/pxe_test_suite.ts     | 14 ++++++++------
 .../pxe/src/synchronizer/synchronizer.test.ts      |  4 ++--
 yarn-project/pxe/src/synchronizer/synchronizer.ts  | 12 ++----------
 .../src/publisher/viem-tx-sender.ts                |  3 ++-
 23 files changed, 39 insertions(+), 59 deletions(-)
 delete mode 100644 yarn-project/circuit-types/src/constants.ts

diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol
index 622bace99a5e..ac03a298c97d 100644
--- a/l1-contracts/src/core/libraries/ConstantsGen.sol
+++ b/l1-contracts/src/core/libraries/ConstantsGen.sol
@@ -125,4 +125,6 @@ library Constants {
   uint256 internal constant CONTRACT_DATA_NUM_BYTES_PER_BASE_ROLLUP_UNPADDED = 52;
   uint256 internal constant L2_TO_L1_MSGS_NUM_BYTES_PER_BASE_ROLLUP = 64;
   uint256 internal constant LOGS_HASHES_NUM_BYTES_PER_BASE_ROLLUP = 64;
+  uint256 internal constant INITIAL_L2_BLOCK_NUM = 1;
+  uint256 internal constant BLOB_SIZE_IN_BYTES = 126976;
 }
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 85f4433e2e3e..bc8bc03b5c04 100644
--- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr
+++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr
@@ -104,6 +104,8 @@ global ARGS_HASH_CHUNK_COUNT: u64 = 32;
 // The initialization slot is computed by adding the constant bellow to the variable's storage slot. This constant has
 // to be large enough so that it's ensured that it doesn't collide with storage slots of other variables.
 global INITIALIZATION_SLOT_SEPARATOR: Field = 1000_000_000;
+global INITIAL_L2_BLOCK_NUM: Field = 1;
+global BLOB_SIZE_IN_BYTES: Field = 126976; // 31 * 4096;
 
 // CONTRACT CLASS CONSTANTS
 global MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS: u64 = 8000;
diff --git a/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts b/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts
index cc3bd95f588a..62fc03b93c39 100644
--- a/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts
+++ b/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts
@@ -1,6 +1,5 @@
 import {
   ExtendedContractData,
-  INITIAL_L2_BLOCK_NUM,
   L1ToL2Message,
   L2Block,
   L2BlockContext,
@@ -10,7 +9,7 @@ import {
   UnencryptedL2Log,
 } from '@aztec/circuit-types';
 import '@aztec/circuit-types/jest';
-import { AztecAddress, Fr } from '@aztec/circuits.js';
+import { AztecAddress, Fr, INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js';
 import { makeContractClassPublic } from '@aztec/circuits.js/testing';
 import { randomBytes } from '@aztec/foundation/crypto';
 import { ContractClassPublic, ContractInstanceWithAddress, SerializableContractInstance } from '@aztec/types/contracts';
diff --git a/yarn-project/archiver/src/archiver/kv_archiver_store/block_store.ts b/yarn-project/archiver/src/archiver/kv_archiver_store/block_store.ts
index f4ed7069d4ef..6b1bd3c47c52 100644
--- a/yarn-project/archiver/src/archiver/kv_archiver_store/block_store.ts
+++ b/yarn-project/archiver/src/archiver/kv_archiver_store/block_store.ts
@@ -1,5 +1,5 @@
-import { INITIAL_L2_BLOCK_NUM, L2Block, TxEffect, TxHash, TxReceipt, TxStatus } from '@aztec/circuit-types';
-import { AppendOnlyTreeSnapshot, AztecAddress, Header } from '@aztec/circuits.js';
+import { L2Block, TxEffect, TxHash, TxReceipt, TxStatus } from '@aztec/circuit-types';
+import { AppendOnlyTreeSnapshot, AztecAddress, Header, INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js';
 import { createDebugLogger } from '@aztec/foundation/log';
 import { AztecKVStore, AztecMap, Range } from '@aztec/kv-store';
 
diff --git a/yarn-project/archiver/src/archiver/kv_archiver_store/log_store.ts b/yarn-project/archiver/src/archiver/kv_archiver_store/log_store.ts
index c5cc67a7c514..6c30395d7129 100644
--- a/yarn-project/archiver/src/archiver/kv_archiver_store/log_store.ts
+++ b/yarn-project/archiver/src/archiver/kv_archiver_store/log_store.ts
@@ -1,13 +1,13 @@
 import {
   ExtendedUnencryptedL2Log,
   GetUnencryptedLogsResponse,
-  INITIAL_L2_BLOCK_NUM,
   L2BlockL2Logs,
   LogFilter,
   LogId,
   LogType,
   UnencryptedL2Log,
 } from '@aztec/circuit-types';
+import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js/constants';
 import { createDebugLogger } from '@aztec/foundation/log';
 import { AztecKVStore, AztecMap } from '@aztec/kv-store';
 
diff --git a/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts b/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts
index 2d4682d52299..755be8eb8cff 100644
--- a/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts
+++ b/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts
@@ -4,7 +4,6 @@ import {
   ExtendedContractData,
   ExtendedUnencryptedL2Log,
   GetUnencryptedLogsResponse,
-  INITIAL_L2_BLOCK_NUM,
   L1ToL2Message,
   L2Block,
   L2BlockContext,
@@ -18,7 +17,7 @@ import {
   TxStatus,
   UnencryptedL2Log,
 } from '@aztec/circuit-types';
-import { Fr, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/circuits.js';
+import { Fr, INITIAL_L2_BLOCK_NUM, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/circuits.js';
 import { AztecAddress } from '@aztec/foundation/aztec-address';
 import { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/types/contracts';
 
diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts
index 9a15fa6502bf..794ee11874be 100644
--- a/yarn-project/aztec-node/src/aztec-node/server.ts
+++ b/yarn-project/aztec-node/src/aztec-node/server.ts
@@ -5,7 +5,6 @@ import {
   ContractDataSource,
   ExtendedContractData,
   GetUnencryptedLogsResponse,
-  INITIAL_L2_BLOCK_NUM,
   L1ToL2MessageAndIndex,
   L1ToL2MessageSource,
   L2Block,
@@ -31,6 +30,7 @@ import {
   EthAddress,
   Fr,
   Header,
+  INITIAL_L2_BLOCK_NUM,
   L1_TO_L2_MSG_TREE_HEIGHT,
   NOTE_HASH_TREE_HEIGHT,
   NULLIFIER_TREE_HEIGHT,
diff --git a/yarn-project/aztec.js/src/index.ts b/yarn-project/aztec.js/src/index.ts
index ad595229f963..1c7812aa56fb 100644
--- a/yarn-project/aztec.js/src/index.ts
+++ b/yarn-project/aztec.js/src/index.ts
@@ -71,6 +71,7 @@ export {
   Point,
   getContractInstanceFromDeployParams,
   getContractClassFromArtifact,
+  INITIAL_L2_BLOCK_NUM,
 } from '@aztec/circuits.js';
 
 export { computeMessageSecretHash } from '@aztec/circuits.js/hash';
@@ -88,7 +89,6 @@ export {
   ExtendedNote,
   FunctionCall,
   GrumpkinPrivateKey,
-  INITIAL_L2_BLOCK_NUM,
   L1ToL2Message,
   L1Actor,
   L2Actor,
diff --git a/yarn-project/circuit-types/src/constants.ts b/yarn-project/circuit-types/src/constants.ts
deleted file mode 100644
index bd7f22b154c3..000000000000
--- a/yarn-project/circuit-types/src/constants.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export const INITIAL_L2_BLOCK_NUM = 1;
-export const BLOB_SIZE_IN_BYTES = 31 * 4096;
diff --git a/yarn-project/circuit-types/src/index.ts b/yarn-project/circuit-types/src/index.ts
index fbcdc2343e5a..d627698950ea 100644
--- a/yarn-project/circuit-types/src/index.ts
+++ b/yarn-project/circuit-types/src/index.ts
@@ -1,4 +1,3 @@
-export * from './constants.js';
 export * from './contract_dao.js';
 export * from './contract_database.js';
 export * from './contract_data.js';
diff --git a/yarn-project/circuit-types/src/l2_block_downloader/l2_block_downloader.ts b/yarn-project/circuit-types/src/l2_block_downloader/l2_block_downloader.ts
index e1e03d9a278e..fb322129b5e5 100644
--- a/yarn-project/circuit-types/src/l2_block_downloader/l2_block_downloader.ts
+++ b/yarn-project/circuit-types/src/l2_block_downloader/l2_block_downloader.ts
@@ -1,8 +1,8 @@
+import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js/constants';
 import { MemoryFifo, Semaphore, SerialQueue } from '@aztec/foundation/fifo';
 import { createDebugLogger } from '@aztec/foundation/log';
 import { InterruptibleSleep } from '@aztec/foundation/sleep';
 
-import { INITIAL_L2_BLOCK_NUM } from '../constants.js';
 import { L2Block } from '../l2_block.js';
 import { L2BlockSource } from '../l2_block_source.js';
 
diff --git a/yarn-project/circuit-types/src/logs/log_id.ts b/yarn-project/circuit-types/src/logs/log_id.ts
index 00ab59c2c523..9d0d06fd3023 100644
--- a/yarn-project/circuit-types/src/logs/log_id.ts
+++ b/yarn-project/circuit-types/src/logs/log_id.ts
@@ -1,8 +1,7 @@
+import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js/constants';
 import { toBufferBE } from '@aztec/foundation/bigint-buffer';
 import { BufferReader } from '@aztec/foundation/serialize';
 
-import { INITIAL_L2_BLOCK_NUM } from '../constants.js';
-
 /** A globally unique log id. */
 export class LogId {
   /**
diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts
index a53f6979ca6e..aabdaca00813 100644
--- a/yarn-project/circuits.js/src/constants.gen.ts
+++ b/yarn-project/circuits.js/src/constants.gen.ts
@@ -150,3 +150,5 @@ export enum GeneratorIndex {
   AUTHWIT_INNER = 45,
   AUTHWIT_OUTER = 46,
 }
+export const INITIAL_L2_BLOCK_NUM = 1;
+export const BLOB_SIZE_IN_BYTES = 126976;
diff --git a/yarn-project/p2p/src/client/p2p_client.ts b/yarn-project/p2p/src/client/p2p_client.ts
index 8fb1b520cb03..c93931afc1e0 100644
--- a/yarn-project/p2p/src/client/p2p_client.ts
+++ b/yarn-project/p2p/src/client/p2p_client.ts
@@ -1,12 +1,5 @@
-import {
-  INITIAL_L2_BLOCK_NUM,
-  L2Block,
-  L2BlockContext,
-  L2BlockDownloader,
-  L2BlockSource,
-  Tx,
-  TxHash,
-} from '@aztec/circuit-types';
+import { L2Block, L2BlockContext, L2BlockDownloader, L2BlockSource, Tx, TxHash } from '@aztec/circuit-types';
+import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js/constants';
 import { createDebugLogger } from '@aztec/foundation/log';
 import { AztecKVStore, AztecSingleton } from '@aztec/kv-store';
 
diff --git a/yarn-project/pxe/src/config/index.ts b/yarn-project/pxe/src/config/index.ts
index 3f22e3caab26..6bfe020a16e6 100644
--- a/yarn-project/pxe/src/config/index.ts
+++ b/yarn-project/pxe/src/config/index.ts
@@ -1,4 +1,4 @@
-import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuit-types';
+import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js/constants';
 
 import { readFileSync } from 'fs';
 import { dirname, resolve } from 'path';
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 4cc6a6a5497d..5ff7e6ce7114 100644
--- a/yarn-project/pxe/src/database/pxe_database_test_suite.ts
+++ b/yarn-project/pxe/src/database/pxe_database_test_suite.ts
@@ -1,5 +1,5 @@
-import { INITIAL_L2_BLOCK_NUM, NoteFilter, NoteStatus, randomTxHash } from '@aztec/circuit-types';
-import { AztecAddress, CompleteAddress } from '@aztec/circuits.js';
+import { NoteFilter, NoteStatus, randomTxHash } from '@aztec/circuit-types';
+import { AztecAddress, CompleteAddress, INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js';
 import { makeHeader } from '@aztec/circuits.js/testing';
 import { Fr, Point } from '@aztec/foundation/fields';
 import { BenchmarkingContractArtifact } from '@aztec/noir-contracts.js/Benchmarking';
diff --git a/yarn-project/pxe/src/note_processor/note_processor.test.ts b/yarn-project/pxe/src/note_processor/note_processor.test.ts
index e96143f5f1f6..e7de9c66bf81 100644
--- a/yarn-project/pxe/src/note_processor/note_processor.test.ts
+++ b/yarn-project/pxe/src/note_processor/note_processor.test.ts
@@ -1,7 +1,6 @@
 import {
   AztecNode,
   FunctionL2Logs,
-  INITIAL_L2_BLOCK_NUM,
   KeyPair,
   KeyStore,
   L1NotePayload,
@@ -12,7 +11,7 @@ import {
   TaggedNote,
   TxL2Logs,
 } from '@aztec/circuit-types';
-import { Fr, MAX_NEW_NOTE_HASHES_PER_TX } from '@aztec/circuits.js';
+import { Fr, INITIAL_L2_BLOCK_NUM, MAX_NEW_NOTE_HASHES_PER_TX } from '@aztec/circuits.js';
 import { Grumpkin } from '@aztec/circuits.js/barretenberg';
 import { pedersenHash } from '@aztec/foundation/crypto';
 import { Point } from '@aztec/foundation/fields';
diff --git a/yarn-project/pxe/src/note_processor/note_processor.ts b/yarn-project/pxe/src/note_processor/note_processor.ts
index cf5ecaae3fe4..82a02a36151b 100644
--- a/yarn-project/pxe/src/note_processor/note_processor.ts
+++ b/yarn-project/pxe/src/note_processor/note_processor.ts
@@ -1,14 +1,6 @@
-import {
-  AztecNode,
-  INITIAL_L2_BLOCK_NUM,
-  KeyStore,
-  L1NotePayload,
-  L2BlockContext,
-  L2BlockL2Logs,
-  TaggedNote,
-} from '@aztec/circuit-types';
+import { AztecNode, KeyStore, L1NotePayload, L2BlockContext, L2BlockL2Logs, TaggedNote } from '@aztec/circuit-types';
 import { NoteProcessorStats } from '@aztec/circuit-types/stats';
-import { MAX_NEW_NOTE_HASHES_PER_TX, PublicKey } from '@aztec/circuits.js';
+import { INITIAL_L2_BLOCK_NUM, MAX_NEW_NOTE_HASHES_PER_TX, PublicKey } from '@aztec/circuits.js';
 import { Grumpkin } from '@aztec/circuits.js/barretenberg';
 import { Fr } from '@aztec/foundation/fields';
 import { createDebugLogger } from '@aztec/foundation/log';
diff --git a/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts b/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts
index 55f38ec30361..43048e9e31fb 100644
--- a/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts
+++ b/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts
@@ -1,5 +1,6 @@
-import { AztecNode, INITIAL_L2_BLOCK_NUM, PXE, TxEffect, mockTx } from '@aztec/circuit-types';
+import { AztecNode, PXE, TxEffect, mockTx } from '@aztec/circuit-types';
 import { Grumpkin } from '@aztec/circuits.js/barretenberg';
+import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js/constants';
 import { L1ContractAddresses } from '@aztec/ethereum';
 import { EthAddress } from '@aztec/foundation/eth-address';
 import { TestKeyStore } from '@aztec/key-store';
diff --git a/yarn-project/pxe/src/pxe_service/test/pxe_test_suite.ts b/yarn-project/pxe/src/pxe_service/test/pxe_test_suite.ts
index 872cf865cc39..0c75a143be92 100644
--- a/yarn-project/pxe/src/pxe_service/test/pxe_test_suite.ts
+++ b/yarn-project/pxe/src/pxe_service/test/pxe_test_suite.ts
@@ -1,11 +1,13 @@
+import { DeployedContract, PXE, TxExecutionRequest, randomDeployedContract } from '@aztec/circuit-types';
 import {
-  DeployedContract,
+  AztecAddress,
+  CompleteAddress,
+  Fr,
+  FunctionData,
   INITIAL_L2_BLOCK_NUM,
-  PXE,
-  TxExecutionRequest,
-  randomDeployedContract,
-} from '@aztec/circuit-types';
-import { AztecAddress, CompleteAddress, Fr, FunctionData, Point, TxContext } from '@aztec/circuits.js';
+  Point,
+  TxContext,
+} from '@aztec/circuits.js';
 import { Grumpkin } from '@aztec/circuits.js/barretenberg';
 import { ConstantKeyPair } from '@aztec/key-store';
 
diff --git a/yarn-project/pxe/src/synchronizer/synchronizer.test.ts b/yarn-project/pxe/src/synchronizer/synchronizer.test.ts
index 7b0677f98d8c..9287c3087000 100644
--- a/yarn-project/pxe/src/synchronizer/synchronizer.test.ts
+++ b/yarn-project/pxe/src/synchronizer/synchronizer.test.ts
@@ -1,5 +1,5 @@
-import { AztecNode, INITIAL_L2_BLOCK_NUM, L2Block } from '@aztec/circuit-types';
-import { CompleteAddress, Fr, GrumpkinScalar, Header } from '@aztec/circuits.js';
+import { AztecNode, L2Block } from '@aztec/circuit-types';
+import { CompleteAddress, Fr, GrumpkinScalar, Header, INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js';
 import { Grumpkin } from '@aztec/circuits.js/barretenberg';
 import { makeHeader } from '@aztec/circuits.js/testing';
 import { SerialQueue } from '@aztec/foundation/fifo';
diff --git a/yarn-project/pxe/src/synchronizer/synchronizer.ts b/yarn-project/pxe/src/synchronizer/synchronizer.ts
index 69f97237b951..7ae66192402b 100644
--- a/yarn-project/pxe/src/synchronizer/synchronizer.ts
+++ b/yarn-project/pxe/src/synchronizer/synchronizer.ts
@@ -1,14 +1,6 @@
-import {
-  AztecNode,
-  INITIAL_L2_BLOCK_NUM,
-  KeyStore,
-  L2BlockContext,
-  L2BlockL2Logs,
-  MerkleTreeId,
-  TxHash,
-} from '@aztec/circuit-types';
+import { AztecNode, KeyStore, L2BlockContext, L2BlockL2Logs, MerkleTreeId, TxHash } from '@aztec/circuit-types';
 import { NoteProcessorCaughtUpStats } from '@aztec/circuit-types/stats';
-import { AztecAddress, Fr, PublicKey } from '@aztec/circuits.js';
+import { AztecAddress, Fr, INITIAL_L2_BLOCK_NUM, PublicKey } from '@aztec/circuits.js';
 import { SerialQueue } from '@aztec/foundation/fifo';
 import { DebugLogger, createDebugLogger } from '@aztec/foundation/log';
 import { RunningPromise } from '@aztec/foundation/running-promise';
diff --git a/yarn-project/sequencer-client/src/publisher/viem-tx-sender.ts b/yarn-project/sequencer-client/src/publisher/viem-tx-sender.ts
index ad2bad81794e..1593297d5c5c 100644
--- a/yarn-project/sequencer-client/src/publisher/viem-tx-sender.ts
+++ b/yarn-project/sequencer-client/src/publisher/viem-tx-sender.ts
@@ -1,4 +1,5 @@
-import { BLOB_SIZE_IN_BYTES, ExtendedContractData, L2Block } from '@aztec/circuit-types';
+import { ExtendedContractData, L2Block } from '@aztec/circuit-types';
+import { BLOB_SIZE_IN_BYTES } from '@aztec/circuits.js/constants';
 import { createEthereumChain } from '@aztec/ethereum';
 import { createDebugLogger } from '@aztec/foundation/log';
 import { AvailabilityOracleAbi, ContractDeploymentEmitterAbi, RollupAbi } from '@aztec/l1-artifacts';