diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index b1343a5f51e..cadb2afec9f 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -4,7 +4,6 @@ import { CallContext, CompleteAddress, ContractDeploymentData, - FieldsOf, FunctionData, L1_TO_L2_MSG_TREE_HEIGHT, MAX_NEW_COMMITMENTS_PER_CALL, @@ -29,6 +28,7 @@ import { pedersenHash } from '@aztec/foundation/crypto'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; import { DebugLogger, createDebugLogger } from '@aztec/foundation/log'; +import { FieldsOf } from '@aztec/foundation/types'; import { AppendOnlyTree, Pedersen, StandardTree, newTree } from '@aztec/merkle-tree'; import { ChildContractArtifact, diff --git a/yarn-project/archiver/src/archiver/eth_log_handlers.ts b/yarn-project/archiver/src/archiver/eth_log_handlers.ts index 312116f294c..ebdd62a3e98 100644 --- a/yarn-project/archiver/src/archiver/eth_log_handlers.ts +++ b/yarn-project/archiver/src/archiver/eth_log_handlers.ts @@ -1,5 +1,4 @@ import { - BufferReader, CancelledL1ToL2Message, ContractData, EncodedContractFunction, @@ -13,6 +12,7 @@ import { import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr, Point } from '@aztec/foundation/fields'; +import { BufferReader } from '@aztec/foundation/serialize'; import { ContractDeploymentEmitterAbi, InboxAbi, RollupAbi } from '@aztec/l1-artifacts'; import { Hex, Log, PublicClient, decodeFunctionData, getAbiItem, getAddress, hexToBytes } from 'viem'; diff --git a/yarn-project/aztec-node/package.json b/yarn-project/aztec-node/package.json index 8329e78d9ae..a2e602a03ff 100644 --- a/yarn-project/aztec-node/package.json +++ b/yarn-project/aztec-node/package.json @@ -43,6 +43,7 @@ "@aztec/merkle-tree": "workspace:^", "@aztec/p2p": "workspace:^", "@aztec/sequencer-client": "workspace:^", + "@aztec/types": "workspace:^", "@aztec/world-state": "workspace:^", "koa": "^2.14.2", "koa-router": "^12.0.0", diff --git a/yarn-project/aztec-node/src/aztec-node/http_rpc_server.ts b/yarn-project/aztec-node/src/aztec-node/http_rpc_server.ts index 4c037f13ab4..f5e99becbde 100644 --- a/yarn-project/aztec-node/src/aztec-node/http_rpc_server.ts +++ b/yarn-project/aztec-node/src/aztec-node/http_rpc_server.ts @@ -8,7 +8,6 @@ import { L2BlockL2Logs, L2Tx, LogId, - SiblingPath, Tx, TxHash, } from '@aztec/circuit-types'; @@ -17,6 +16,7 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { JsonRpcServer } from '@aztec/foundation/json-rpc/server'; +import { SiblingPath } from '@aztec/types/membership'; /** * Wrap an AztecNode instance with a JSON RPC HTTP server. diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index 12c11b9069f..1d24a3e17b4 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -19,7 +19,6 @@ import { NullifierMembershipWitness, PublicDataWitness, SequencerConfig, - SiblingPath, Tx, TxHash, } from '@aztec/circuit-types'; @@ -48,6 +47,7 @@ import { SequencerClient, getGlobalVariableBuilder, } from '@aztec/sequencer-client'; +import { SiblingPath } from '@aztec/types/membership'; import { MerkleTrees, ServerWorldStateSynchronizer, diff --git a/yarn-project/aztec-node/tsconfig.json b/yarn-project/aztec-node/tsconfig.json index 976b170d458..9979b01f137 100644 --- a/yarn-project/aztec-node/tsconfig.json +++ b/yarn-project/aztec-node/tsconfig.json @@ -36,6 +36,9 @@ { "path": "../sequencer-client" }, + { + "path": "../types" + }, { "path": "../world-state" } diff --git a/yarn-project/aztec.js/src/account_manager/deploy_account_sent_tx.ts b/yarn-project/aztec.js/src/account_manager/deploy_account_sent_tx.ts index b93ea97e515..5fd45b835a8 100644 --- a/yarn-project/aztec.js/src/account_manager/deploy_account_sent_tx.ts +++ b/yarn-project/aztec.js/src/account_manager/deploy_account_sent_tx.ts @@ -1,5 +1,5 @@ import { TxHash, TxReceipt } from '@aztec/circuit-types'; -import { FieldsOf } from '@aztec/circuits.js'; +import { FieldsOf } from '@aztec/foundation/types'; import { Wallet } from '../account/index.js'; import { DefaultWaitOpts, SentTx, WaitOpts } from '../contract/index.js'; diff --git a/yarn-project/aztec.js/src/contract/deploy_sent_tx.ts b/yarn-project/aztec.js/src/contract/deploy_sent_tx.ts index 3bd2f39486a..dab687bdc61 100644 --- a/yarn-project/aztec.js/src/contract/deploy_sent_tx.ts +++ b/yarn-project/aztec.js/src/contract/deploy_sent_tx.ts @@ -1,5 +1,6 @@ import { PXE, TxHash, TxReceipt } from '@aztec/circuit-types'; -import { AztecAddress, CompleteAddress, FieldsOf } from '@aztec/circuits.js'; +import { AztecAddress, CompleteAddress } from '@aztec/circuits.js'; +import { FieldsOf } from '@aztec/foundation/types'; import { Wallet } from '../account/index.js'; import { type Contract } from './contract.js'; diff --git a/yarn-project/aztec.js/src/contract/sent_tx.ts b/yarn-project/aztec.js/src/contract/sent_tx.ts index 9fcef7854c4..25f646be021 100644 --- a/yarn-project/aztec.js/src/contract/sent_tx.ts +++ b/yarn-project/aztec.js/src/contract/sent_tx.ts @@ -1,6 +1,6 @@ import { ExtendedNote, GetUnencryptedLogsResponse, PXE, TxHash, TxReceipt, TxStatus } from '@aztec/circuit-types'; -import { FieldsOf } from '@aztec/circuits.js'; import { retryUntil } from '@aztec/foundation/retry'; +import { FieldsOf } from '@aztec/foundation/types'; /** Options related to waiting for a tx. */ export type WaitOpts = { diff --git a/yarn-project/circuit-types/src/auth_witness.ts b/yarn-project/circuit-types/src/auth_witness.ts index 06f98da9306..59c575ac31f 100644 --- a/yarn-project/circuit-types/src/auth_witness.ts +++ b/yarn-project/circuit-types/src/auth_witness.ts @@ -1,6 +1,6 @@ import { Vector } from '@aztec/circuits.js'; -import { BufferReader, serializeToBuffer } from '@aztec/circuits.js/utils'; import { Fr } from '@aztec/foundation/fields'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; /** * An authentication witness. Used to authorize an action by a user. diff --git a/yarn-project/circuit-types/src/aztec_node/rpc/aztec_node_client.ts b/yarn-project/circuit-types/src/aztec_node/rpc/aztec_node_client.ts index f5ae65370b3..3a2f9ebb635 100644 --- a/yarn-project/circuit-types/src/aztec_node/rpc/aztec_node_client.ts +++ b/yarn-project/circuit-types/src/aztec_node/rpc/aztec_node_client.ts @@ -4,6 +4,7 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { createJsonRpcClient, defaultFetch } from '@aztec/foundation/json-rpc/client'; +import { SiblingPath } from '@aztec/types/membership'; import { ContractData, ExtendedContractData } from '../../contract_data.js'; import { AztecNode } from '../../interfaces/index.js'; @@ -11,7 +12,6 @@ import { L1ToL2MessageAndIndex } from '../../l1_to_l2_message.js'; import { L2Block } from '../../l2_block.js'; import { L2Tx } from '../../l2_tx.js'; import { ExtendedUnencryptedL2Log, L2BlockL2Logs, LogId } from '../../logs/index.js'; -import { SiblingPath } from '../../sibling_path.js'; import { Tx, TxHash } from '../../tx/index.js'; /** diff --git a/yarn-project/circuit-types/src/contract_dao.ts b/yarn-project/circuit-types/src/contract_dao.ts index 4d70d0aca4d..2817c1f2551 100644 --- a/yarn-project/circuit-types/src/contract_dao.ts +++ b/yarn-project/circuit-types/src/contract_dao.ts @@ -9,9 +9,9 @@ import { getFunctionDebugMetadata, } from '@aztec/foundation/abi'; import { EthAddress } from '@aztec/foundation/eth-address'; -import { prefixBufferWithLength } from '@aztec/foundation/serialize'; +import { BufferReader, prefixBufferWithLength } from '@aztec/foundation/serialize'; -import { BufferReader, EncodedContractFunction } from './contract_data.js'; +import { EncodedContractFunction } from './contract_data.js'; /** * A contract Data Access Object (DAO). diff --git a/yarn-project/circuit-types/src/contract_data.ts b/yarn-project/circuit-types/src/contract_data.ts index 093a14b0176..1da2b034bc3 100644 --- a/yarn-project/circuit-types/src/contract_data.ts +++ b/yarn-project/circuit-types/src/contract_data.ts @@ -7,13 +7,15 @@ import { Point, PublicKey, } from '@aztec/circuits.js'; -import { BufferReader, serializeToBuffer } from '@aztec/circuits.js/utils'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { randomBytes } from '@aztec/foundation/crypto'; import { EthAddress } from '@aztec/foundation/eth-address'; -import { numToInt32BE, serializeBufferArrayToVector } from '@aztec/foundation/serialize'; - -export { BufferReader } from '@aztec/circuits.js/utils'; +import { + BufferReader, + numToInt32BE, + serializeBufferArrayToVector, + serializeToBuffer, +} from '@aztec/foundation/serialize'; /** * Used for retrieval of contract data (A3 address, portal contract address, bytecode). diff --git a/yarn-project/circuit-types/src/index.ts b/yarn-project/circuit-types/src/index.ts index 149ec5a7a6a..85ea8cb627f 100644 --- a/yarn-project/circuit-types/src/index.ts +++ b/yarn-project/circuit-types/src/index.ts @@ -20,7 +20,6 @@ export * from './tx/index.js'; export * from './tx_execution_request.js'; export * from './packed_arguments.js'; export * from './interfaces/index.js'; -export * from './sibling_path.js'; export * from './auth_witness.js'; export * from './aztec_node/rpc/index.js'; export { CompleteAddress, PublicKey, PartialAddress, GrumpkinPrivateKey } from '@aztec/circuits.js'; diff --git a/yarn-project/circuit-types/src/interfaces/index.ts b/yarn-project/circuit-types/src/interfaces/index.ts index 411b81df6e3..398c73d1218 100644 --- a/yarn-project/circuit-types/src/interfaces/index.ts +++ b/yarn-project/circuit-types/src/interfaces/index.ts @@ -1,5 +1,4 @@ export * from './state_info_provider.js'; -export * from './hasher.js'; export * from './aztec-node.js'; export * from './pxe.js'; export * from './deployed-contract.js'; diff --git a/yarn-project/circuit-types/src/interfaces/nullifier_tree.ts b/yarn-project/circuit-types/src/interfaces/nullifier_tree.ts index b9f5af3df34..4a06400a8c7 100644 --- a/yarn-project/circuit-types/src/interfaces/nullifier_tree.ts +++ b/yarn-project/circuit-types/src/interfaces/nullifier_tree.ts @@ -1,6 +1,5 @@ import { Fr, NULLIFIER_TREE_HEIGHT, NullifierLeafPreimage } from '@aztec/circuits.js'; - -import { SiblingPath } from '../sibling_path.js'; +import { SiblingPath } from '@aztec/types/membership'; /** * Nullifier membership witness. diff --git a/yarn-project/circuit-types/src/interfaces/public_data_tree.ts b/yarn-project/circuit-types/src/interfaces/public_data_tree.ts index 944296fc7d1..5c5fc9c3054 100644 --- a/yarn-project/circuit-types/src/interfaces/public_data_tree.ts +++ b/yarn-project/circuit-types/src/interfaces/public_data_tree.ts @@ -1,6 +1,5 @@ import { Fr, PUBLIC_DATA_TREE_HEIGHT, PublicDataTreeLeafPreimage } from '@aztec/circuits.js'; - -import { SiblingPath } from '../sibling_path.js'; +import { SiblingPath } from '@aztec/types/membership'; /** * Public data witness. diff --git a/yarn-project/circuit-types/src/interfaces/state_info_provider.ts b/yarn-project/circuit-types/src/interfaces/state_info_provider.ts index 9384212bda4..3e7d83ece94 100644 --- a/yarn-project/circuit-types/src/interfaces/state_info_provider.ts +++ b/yarn-project/circuit-types/src/interfaces/state_info_provider.ts @@ -7,11 +7,11 @@ import { NULLIFIER_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, } from '@aztec/circuits.js'; +import { SiblingPath } from '@aztec/types/membership'; import { L1ToL2MessageAndIndex } from '../l1_to_l2_message.js'; import { L2Block } from '../l2_block.js'; import { MerkleTreeId } from '../merkle_tree_id.js'; -import { SiblingPath } from '../sibling_path.js'; import { NullifierMembershipWitness } from './nullifier_tree.js'; import { PublicDataWitness } from './public_data_tree.js'; diff --git a/yarn-project/circuit-types/src/l1_to_l2_message.ts b/yarn-project/circuit-types/src/l1_to_l2_message.ts index fffc5ca64c3..e6697384c6b 100644 --- a/yarn-project/circuit-types/src/l1_to_l2_message.ts +++ b/yarn-project/circuit-types/src/l1_to_l2_message.ts @@ -1,8 +1,8 @@ -import { BufferReader, serializeToBuffer } from '@aztec/circuits.js/utils'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; /** * Interface of classes allowing for the retrieval of L1 to L2 messages. diff --git a/yarn-project/circuit-types/src/l2_block.ts b/yarn-project/circuit-types/src/l2_block.ts index a9302688d66..f3d570d3705 100644 --- a/yarn-project/circuit-types/src/l2_block.ts +++ b/yarn-project/circuit-types/src/l2_block.ts @@ -13,10 +13,10 @@ import { StateReference, } from '@aztec/circuits.js'; import { makeAppendOnlyTreeSnapshot, makeGlobalVariables, makeHeader } from '@aztec/circuits.js/factories'; -import { BufferReader, serializeToBuffer } from '@aztec/circuits.js/utils'; import { keccak, sha256 } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import times from 'lodash.times'; diff --git a/yarn-project/circuit-types/src/logs/l1_note_payload/l1_note_payload.ts b/yarn-project/circuit-types/src/logs/l1_note_payload/l1_note_payload.ts index 76dcc729911..c233e2ba7bd 100644 --- a/yarn-project/circuit-types/src/logs/l1_note_payload/l1_note_payload.ts +++ b/yarn-project/circuit-types/src/logs/l1_note_payload/l1_note_payload.ts @@ -1,8 +1,7 @@ import { AztecAddress, GrumpkinPrivateKey, PublicKey } from '@aztec/circuits.js'; import { Grumpkin } from '@aztec/circuits.js/barretenberg'; -import { serializeToBuffer } from '@aztec/circuits.js/utils'; import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { decryptBuffer, encryptBuffer } from './encrypt_buffer.js'; import { Note } from './note.js'; diff --git a/yarn-project/circuit-types/src/packed_arguments.ts b/yarn-project/circuit-types/src/packed_arguments.ts index b14213f349d..aa327d2d516 100644 --- a/yarn-project/circuit-types/src/packed_arguments.ts +++ b/yarn-project/circuit-types/src/packed_arguments.ts @@ -1,6 +1,7 @@ -import { FieldsOf, Fr, Vector } from '@aztec/circuits.js'; +import { Fr, Vector } from '@aztec/circuits.js'; import { computeVarArgsHash } from '@aztec/circuits.js/abis'; -import { BufferReader, serializeToBuffer } from '@aztec/circuits.js/utils'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; +import { FieldsOf } from '@aztec/foundation/types'; /** * Packs a set of arguments into a hash. diff --git a/yarn-project/circuit-types/src/public_data_write.ts b/yarn-project/circuit-types/src/public_data_write.ts index dd1979e1c27..2b96e6777e8 100644 --- a/yarn-project/circuit-types/src/public_data_write.ts +++ b/yarn-project/circuit-types/src/public_data_write.ts @@ -1,7 +1,6 @@ import { STRING_ENCODING } from '@aztec/circuits.js'; -import { serializeToBuffer } from '@aztec/circuits.js/utils'; import { Fr } from '@aztec/foundation/fields'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; /** * Write operations on the public state tree. diff --git a/yarn-project/circuit-types/src/tx/tx.ts b/yarn-project/circuit-types/src/tx/tx.ts index c8d9c9f7977..ee8fb01d78a 100644 --- a/yarn-project/circuit-types/src/tx/tx.ts +++ b/yarn-project/circuit-types/src/tx/tx.ts @@ -1,7 +1,6 @@ import { MAX_NEW_CONTRACTS_PER_TX, PrivateKernelPublicInputsFinal, Proof, PublicCallRequest } from '@aztec/circuits.js'; -import { serializeToBuffer } from '@aztec/circuits.js/utils'; import { arrayNonEmptyLength } from '@aztec/foundation/collection'; -import { BufferReader, Tuple } from '@aztec/foundation/serialize'; +import { BufferReader, Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; import { ExtendedContractData } from '../contract_data.js'; import { GetUnencryptedLogsResponse } from '../logs/get_unencrypted_logs_response.js'; diff --git a/yarn-project/circuit-types/src/tx_execution_request.ts b/yarn-project/circuit-types/src/tx_execution_request.ts index 7cfbd9aab78..9f68f8fc6eb 100644 --- a/yarn-project/circuit-types/src/tx_execution_request.ts +++ b/yarn-project/circuit-types/src/tx_execution_request.ts @@ -1,5 +1,6 @@ -import { AztecAddress, FieldsOf, Fr, FunctionData, TxContext, TxRequest, Vector } from '@aztec/circuits.js'; -import { BufferReader, serializeToBuffer } from '@aztec/circuits.js/utils'; +import { AztecAddress, Fr, FunctionData, TxContext, TxRequest, Vector } from '@aztec/circuits.js'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; +import { FieldsOf } from '@aztec/foundation/types'; import { AuthWitness } from './auth_witness.js'; import { PackedArguments } from './packed_arguments.js'; diff --git a/yarn-project/circuits.js/src/abis/abis.ts b/yarn-project/circuits.js/src/abis/abis.ts index e5c142aecb6..a33a058a9d3 100644 --- a/yarn-project/circuits.js/src/abis/abis.ts +++ b/yarn-project/circuits.js/src/abis/abis.ts @@ -2,7 +2,7 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; import { padArrayEnd } from '@aztec/foundation/collection'; import { keccak, pedersenHash, pedersenHashBuffer } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; -import { numToUInt8, numToUInt16BE, numToUInt32BE } from '@aztec/foundation/serialize'; +import { boolToBuffer, numToUInt8, numToUInt16BE, numToUInt32BE } from '@aztec/foundation/serialize'; import { Buffer } from 'buffer'; import chunk from 'lodash.chunk'; @@ -35,7 +35,6 @@ import { VerificationKey, } from '../structs/index.js'; import { PublicKey } from '../types/index.js'; -import { boolToBuffer } from '../utils/serialize.js'; import { MerkleTreeCalculator } from './merkle_tree_calculator.js'; /** diff --git a/yarn-project/circuits.js/src/index.ts b/yarn-project/circuits.js/src/index.ts index ed17d138f99..91e7dd069b3 100644 --- a/yarn-project/circuits.js/src/index.ts +++ b/yarn-project/circuits.js/src/index.ts @@ -1,5 +1,4 @@ export * from './structs/index.js'; -export * from './utils/jsUtils.js'; export * from './contract/index.js'; export * from './types/index.js'; export * from './constants.gen.js'; diff --git a/yarn-project/circuits.js/src/structs/aggregation_object.ts b/yarn-project/circuits.js/src/structs/aggregation_object.ts index c00dd2795e0..798cc126b11 100644 --- a/yarn-project/circuits.js/src/structs/aggregation_object.ts +++ b/yarn-project/circuits.js/src/structs/aggregation_object.ts @@ -1,9 +1,8 @@ import { Fq, Fr } from '@aztec/foundation/fields'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import times from 'lodash.times'; -import { serializeToBuffer } from '../utils/serialize.js'; import { UInt32, Vector } from './shared.js'; import { G1AffineElement } from './verification_key.js'; diff --git a/yarn-project/circuits.js/src/structs/call_context.ts b/yarn-project/circuits.js/src/structs/call_context.ts index be12ebf4c13..266f715e3b8 100644 --- a/yarn-project/circuits.js/src/structs/call_context.ts +++ b/yarn-project/circuits.js/src/structs/call_context.ts @@ -1,9 +1,8 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; +import { FieldsOf } from '@aztec/foundation/types'; -import { FieldsOf } from '../utils/jsUtils.js'; -import { serializeToBuffer } from '../utils/serialize.js'; import { Fr, FunctionSelector } from './index.js'; /** diff --git a/yarn-project/circuits.js/src/structs/call_request.ts b/yarn-project/circuits.js/src/structs/call_request.ts index 185c48ef27a..08f9739d80c 100644 --- a/yarn-project/circuits.js/src/structs/call_request.ts +++ b/yarn-project/circuits.js/src/structs/call_request.ts @@ -1,10 +1,8 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { FieldsOf } from '@aztec/foundation/types'; -import { serializeToBuffer } from '../utils/serialize.js'; - /** * Caller context. */ diff --git a/yarn-project/circuits.js/src/structs/call_stack_item.ts b/yarn-project/circuits.js/src/structs/call_stack_item.ts index b6b1d99ee82..4752238d7bc 100644 --- a/yarn-project/circuits.js/src/structs/call_stack_item.ts +++ b/yarn-project/circuits.js/src/structs/call_stack_item.ts @@ -1,9 +1,8 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { computePrivateCallStackItemHash, computePublicCallStackItemHash } from '../abis/abis.js'; -import { serializeToBuffer } from '../utils/serialize.js'; import { CallRequest, CallerContext } from './call_request.js'; import { FunctionData } from './function_data.js'; import { PrivateCircuitPublicInputs } from './private_circuit_public_inputs.js'; diff --git a/yarn-project/circuits.js/src/structs/function_data.ts b/yarn-project/circuits.js/src/structs/function_data.ts index 9838417a13b..7bafa4c126a 100644 --- a/yarn-project/circuits.js/src/structs/function_data.ts +++ b/yarn-project/circuits.js/src/structs/function_data.ts @@ -1,8 +1,7 @@ import { FunctionAbi, FunctionSelector, FunctionType } from '@aztec/foundation/abi'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { ContractFunctionDao } from '../index.js'; -import { serializeToBuffer } from '../utils/serialize.js'; /** * Function description for circuit. diff --git a/yarn-project/circuits.js/src/structs/function_leaf_preimage.ts b/yarn-project/circuits.js/src/structs/function_leaf_preimage.ts index 0aed310a4e0..5bf3c7a1195 100644 --- a/yarn-project/circuits.js/src/structs/function_leaf_preimage.ts +++ b/yarn-project/circuits.js/src/structs/function_leaf_preimage.ts @@ -1,8 +1,6 @@ import { FunctionSelector } from '@aztec/foundation/abi'; import { Fr } from '@aztec/foundation/fields'; -import { BufferReader } from '@aztec/foundation/serialize'; - -import { serializeToBuffer } from '../utils/serialize.js'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; /** * A class representing the "preimage" of a function tree leaf. diff --git a/yarn-project/circuits.js/src/structs/global_variables.ts b/yarn-project/circuits.js/src/structs/global_variables.ts index e15b419da29..7fd59476772 100644 --- a/yarn-project/circuits.js/src/structs/global_variables.ts +++ b/yarn-project/circuits.js/src/structs/global_variables.ts @@ -1,9 +1,7 @@ import { Fr } from '@aztec/foundation/fields'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { FieldsOf } from '@aztec/foundation/types'; -import { serializeToBuffer } from '../utils/index.js'; - /** * Global variables of the L2 block. */ diff --git a/yarn-project/circuits.js/src/structs/header.ts b/yarn-project/circuits.js/src/structs/header.ts index 832d5328434..13e518a7306 100644 --- a/yarn-project/circuits.js/src/structs/header.ts +++ b/yarn-project/circuits.js/src/structs/header.ts @@ -1,8 +1,7 @@ import { Fr } from '@aztec/foundation/fields'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { NUM_FIELDS_PER_SHA256 } from '../constants.gen.js'; -import { serializeToBuffer } from '../utils/serialize.js'; import { GlobalVariables } from './global_variables.js'; import { AppendOnlyTreeSnapshot } from './rollup/append_only_tree_snapshot.js'; import { StateReference } from './state_reference.js'; diff --git a/yarn-project/circuits.js/src/structs/kernel/block_header.ts b/yarn-project/circuits.js/src/structs/kernel/block_header.ts index f2df70aba24..6cc1d35917a 100644 --- a/yarn-project/circuits.js/src/structs/kernel/block_header.ts +++ b/yarn-project/circuits.js/src/structs/kernel/block_header.ts @@ -1,8 +1,6 @@ import { Fr } from '@aztec/foundation/fields'; -import { BufferReader } from '@aztec/foundation/serialize'; - -import { FieldsOf } from '../../utils/jsUtils.js'; -import { serializeToBuffer } from '../../utils/serialize.js'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; +import { FieldsOf } from '@aztec/foundation/types'; /** * The string encoding used for serializing BlockHeader objects. diff --git a/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts b/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts index 6c0b31dc60f..0faefe3a5ba 100644 --- a/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts @@ -1,4 +1,5 @@ -import { BufferReader, Tuple } from '@aztec/foundation/serialize'; +import { makeTuple } from '@aztec/foundation/array'; +import { BufferReader, Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; import { MAX_NEW_COMMITMENTS_PER_TX, @@ -14,8 +15,6 @@ import { MAX_READ_REQUESTS_PER_TX, NUM_FIELDS_PER_SHA256, } from '../../constants.gen.js'; -import { makeTuple } from '../../index.js'; -import { serializeToBuffer } from '../../utils/serialize.js'; import { CallRequest } from '../call_request.js'; import { AggregationObject, diff --git a/yarn-project/circuits.js/src/structs/kernel/combined_constant_data.ts b/yarn-project/circuits.js/src/structs/kernel/combined_constant_data.ts index 2410d624191..6065e6ec04a 100644 --- a/yarn-project/circuits.js/src/structs/kernel/combined_constant_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/combined_constant_data.ts @@ -1,6 +1,5 @@ -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; -import { serializeToBuffer } from '../../utils/serialize.js'; import { TxContext } from '../tx_context.js'; import { BlockHeader } from './block_header.js'; diff --git a/yarn-project/circuits.js/src/structs/kernel/previous_kernel_data.ts b/yarn-project/circuits.js/src/structs/kernel/previous_kernel_data.ts index f03ad99fde8..331d6c5c8fe 100644 --- a/yarn-project/circuits.js/src/structs/kernel/previous_kernel_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/previous_kernel_data.ts @@ -1,8 +1,8 @@ +import { makeTuple } from '@aztec/foundation/array'; import { Fr } from '@aztec/foundation/fields'; -import { BufferReader, Tuple } from '@aztec/foundation/serialize'; +import { BufferReader, Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; -import { VK_TREE_HEIGHT, makeTuple } from '../../index.js'; -import { serializeToBuffer } from '../../utils/serialize.js'; +import { VK_TREE_HEIGHT } from '../../index.js'; import { Proof, makeEmptyProof } from '../proof.js'; import { UInt32 } from '../shared.js'; import { VerificationKey } from '../verification_key.js'; diff --git a/yarn-project/circuits.js/src/structs/kernel/private_kernel.ts b/yarn-project/circuits.js/src/structs/kernel/private_kernel.ts index 0690feff073..973928d7da8 100644 --- a/yarn-project/circuits.js/src/structs/kernel/private_kernel.ts +++ b/yarn-project/circuits.js/src/structs/kernel/private_kernel.ts @@ -1,5 +1,6 @@ import { Fr } from '@aztec/foundation/fields'; -import { BufferReader, Tuple } from '@aztec/foundation/serialize'; +import { BufferReader, Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; +import { FieldsOf } from '@aztec/foundation/types'; import { CONTRACT_TREE_HEIGHT, @@ -11,8 +12,6 @@ import { MAX_READ_REQUESTS_PER_CALL, MAX_READ_REQUESTS_PER_TX, } from '../../constants.gen.js'; -import { FieldsOf } from '../../utils/jsUtils.js'; -import { serializeToBuffer } from '../../utils/serialize.js'; import { CallRequest } from '../call_request.js'; import { PrivateCallStackItem } from '../call_stack_item.js'; import { MembershipWitness } from '../membership_witness.js'; diff --git a/yarn-project/circuits.js/src/structs/kernel/public_inputs.ts b/yarn-project/circuits.js/src/structs/kernel/public_inputs.ts index 9c712dd11cc..eb90a8ffe80 100644 --- a/yarn-project/circuits.js/src/structs/kernel/public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/kernel/public_inputs.ts @@ -1,6 +1,5 @@ -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; -import { serializeToBuffer } from '../../utils/serialize.js'; import { CombinedAccumulatedData } from './combined_accumulated_data.js'; import { CombinedConstantData } from './combined_constant_data.js'; diff --git a/yarn-project/circuits.js/src/structs/kernel/public_inputs_final.ts b/yarn-project/circuits.js/src/structs/kernel/public_inputs_final.ts index 60d7a3d2a18..af47ac9a846 100644 --- a/yarn-project/circuits.js/src/structs/kernel/public_inputs_final.ts +++ b/yarn-project/circuits.js/src/structs/kernel/public_inputs_final.ts @@ -1,6 +1,5 @@ -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; -import { serializeToBuffer } from '../../utils/serialize.js'; import { FinalAccumulatedData } from './combined_accumulated_data.js'; import { CombinedConstantData } from './combined_constant_data.js'; diff --git a/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts b/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts index 346f727e9ed..c9223b2c3a9 100644 --- a/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts +++ b/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts @@ -1,5 +1,6 @@ +import { assertMemberLength } from '@aztec/foundation/array'; import { Fr } from '@aztec/foundation/fields'; -import { Tuple } from '@aztec/foundation/serialize'; +import { Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; import { MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, @@ -7,8 +8,6 @@ import { MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PUBLIC_DATA_TREE_HEIGHT, } from '../../constants.gen.js'; -import { assertMemberLength } from '../../utils/jsUtils.js'; -import { serializeToBuffer } from '../../utils/serialize.js'; import { CallRequest } from '../call_request.js'; import { PublicCallStackItem } from '../call_stack_item.js'; import { MembershipWitness } from '../membership_witness.js'; diff --git a/yarn-project/circuits.js/src/structs/membership_witness.ts b/yarn-project/circuits.js/src/structs/membership_witness.ts index 1115daa76ed..c03fe7fe5d9 100644 --- a/yarn-project/circuits.js/src/structs/membership_witness.ts +++ b/yarn-project/circuits.js/src/structs/membership_witness.ts @@ -1,10 +1,7 @@ +import { assertMemberLength } from '@aztec/foundation/array'; import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer'; import { Fr } from '@aztec/foundation/fields'; -import { BufferReader, Tuple } from '@aztec/foundation/serialize'; - -import { NOTE_HASH_TREE_HEIGHT } from '../constants.gen.js'; -import { assertMemberLength, range } from '../utils/jsUtils.js'; -import { serializeToBuffer } from '../utils/serialize.js'; +import { BufferReader, Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; /** * Contains information which can be used to prove that a leaf is a member of a Merkle tree. @@ -31,14 +28,6 @@ export class MembershipWitness { return serializeToBuffer(toBufferBE(this.leafIndex, 32), ...this.siblingPath); } - static mock(size: number, start: number) { - return new MembershipWitness( - size, - BigInt(start), - range(size, start).map(x => new Fr(BigInt(x))) as Tuple, - ); - } - /** * Creates a random membership witness. Used for testing purposes. * @param pathSize - Number of fields in the sibling path. diff --git a/yarn-project/circuits.js/src/structs/partial_state_reference.ts b/yarn-project/circuits.js/src/structs/partial_state_reference.ts index 03d91394313..e6092a7246a 100644 --- a/yarn-project/circuits.js/src/structs/partial_state_reference.ts +++ b/yarn-project/circuits.js/src/structs/partial_state_reference.ts @@ -1,6 +1,5 @@ -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; -import { serializeToBuffer } from '../utils/serialize.js'; import { AppendOnlyTreeSnapshot } from './rollup/append_only_tree_snapshot.js'; /** diff --git a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts index e0cf7cfdd98..db10fdfb428 100644 --- a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts @@ -1,6 +1,8 @@ +import { makeTuple } from '@aztec/foundation/array'; import { isArrayEmpty } from '@aztec/foundation/collection'; import { Fr } from '@aztec/foundation/fields'; -import { BufferReader, Tuple } from '@aztec/foundation/serialize'; +import { BufferReader, Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; +import { FieldsOf } from '@aztec/foundation/types'; import { MAX_NEW_COMMITMENTS_PER_CALL, @@ -12,8 +14,6 @@ import { NUM_FIELDS_PER_SHA256, RETURN_VALUES_LENGTH, } from '../constants.gen.js'; -import { FieldsOf, makeTuple } from '../utils/jsUtils.js'; -import { serializeToBuffer } from '../utils/serialize.js'; import { CallContext } from './call_context.js'; import { BlockHeader, SideEffect, SideEffectLinkedToNoteHash } from './index.js'; import { ContractDeploymentData } from './tx_context.js'; diff --git a/yarn-project/circuits.js/src/structs/proof.ts b/yarn-project/circuits.js/src/structs/proof.ts index a1abedf33c1..c2a16b9616b 100644 --- a/yarn-project/circuits.js/src/structs/proof.ts +++ b/yarn-project/circuits.js/src/structs/proof.ts @@ -1,6 +1,4 @@ -import { BufferReader } from '@aztec/foundation/serialize'; - -import { serializeToBuffer } from '../utils/serialize.js'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; /** * The Proof class is a wrapper around the circuits proof. diff --git a/yarn-project/circuits.js/src/structs/public_call_request.ts b/yarn-project/circuits.js/src/structs/public_call_request.ts index 60c756c0033..ac5153aaa5f 100644 --- a/yarn-project/circuits.js/src/structs/public_call_request.ts +++ b/yarn-project/circuits.js/src/structs/public_call_request.ts @@ -1,8 +1,7 @@ -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; +import { FieldsOf } from '@aztec/foundation/types'; import { computeVarArgsHash } from '../abis/abis.js'; -import { FieldsOf } from '../index.js'; -import { serializeToBuffer } from '../utils/serialize.js'; import { CallerContext } from './call_request.js'; import { AztecAddress, diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index a89d04a11eb..134fcc1ceaa 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -1,7 +1,9 @@ +import { makeTuple } from '@aztec/foundation/array'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { isArrayEmpty } from '@aztec/foundation/collection'; import { Fr } from '@aztec/foundation/fields'; -import { BufferReader, Tuple } from '@aztec/foundation/serialize'; +import { BufferReader, Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; +import { FieldsOf } from '@aztec/foundation/types'; import { MAX_NEW_COMMITMENTS_PER_CALL, @@ -12,8 +14,6 @@ import { MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, RETURN_VALUES_LENGTH, } from '../constants.gen.js'; -import { FieldsOf, makeTuple } from '../utils/jsUtils.js'; -import { serializeToBuffer } from '../utils/serialize.js'; import { CallContext } from './call_context.js'; import { BlockHeader, SideEffect, SideEffectLinkedToNoteHash } from './index.js'; diff --git a/yarn-project/circuits.js/src/structs/read_request_membership_witness.ts b/yarn-project/circuits.js/src/structs/read_request_membership_witness.ts index f66d89ce2b4..008fc02ace0 100644 --- a/yarn-project/circuits.js/src/structs/read_request_membership_witness.ts +++ b/yarn-project/circuits.js/src/structs/read_request_membership_witness.ts @@ -1,10 +1,9 @@ +import { makeTuple, range } from '@aztec/foundation/array'; import { toBufferBE } from '@aztec/foundation/bigint-buffer'; import { Fr } from '@aztec/foundation/fields'; -import { BufferReader, Tuple } from '@aztec/foundation/serialize'; +import { BufferReader, Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; import { MAX_NEW_COMMITMENTS_PER_CALL, NOTE_HASH_TREE_HEIGHT } from '../constants.gen.js'; -import { makeTuple, range } from '../utils/jsUtils.js'; -import { serializeToBuffer } from '../utils/serialize.js'; import { MembershipWitness } from './membership_witness.js'; /** diff --git a/yarn-project/circuits.js/src/structs/rollup/append_only_tree_snapshot.ts b/yarn-project/circuits.js/src/structs/rollup/append_only_tree_snapshot.ts index 5bc2aaa19c8..ba845cbabd3 100644 --- a/yarn-project/circuits.js/src/structs/rollup/append_only_tree_snapshot.ts +++ b/yarn-project/circuits.js/src/structs/rollup/append_only_tree_snapshot.ts @@ -1,7 +1,6 @@ import { Fr } from '@aztec/foundation/fields'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; -import { serializeToBuffer } from '../../utils/serialize.js'; import { STRING_ENCODING, UInt32 } from '../shared.js'; /** diff --git a/yarn-project/circuits.js/src/structs/rollup/base_or_merge_rollup_public_inputs.ts b/yarn-project/circuits.js/src/structs/rollup/base_or_merge_rollup_public_inputs.ts index 921b0316b74..48d6f5200d6 100644 --- a/yarn-project/circuits.js/src/structs/rollup/base_or_merge_rollup_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/rollup/base_or_merge_rollup_public_inputs.ts @@ -1,8 +1,7 @@ import { Fr } from '@aztec/foundation/fields'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { NUM_FIELDS_PER_SHA256 } from '../../constants.gen.js'; -import { serializeToBuffer } from '../../utils/serialize.js'; import { AggregationObject } from '../aggregation_object.js'; import { PartialStateReference } from '../partial_state_reference.js'; import { RollupTypes } from '../shared.js'; diff --git a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts index 3707c39d105..32dbf7f7524 100644 --- a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts @@ -1,5 +1,6 @@ import { Fr } from '@aztec/foundation/fields'; -import { BufferReader, Tuple } from '@aztec/foundation/serialize'; +import { BufferReader, Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; +import { FieldsOf } from '@aztec/foundation/types'; import { ARCHIVE_HEIGHT, @@ -7,8 +8,6 @@ import { MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PUBLIC_DATA_TREE_HEIGHT, } from '../../constants.gen.js'; -import { FieldsOf } from '../../utils/jsUtils.js'; -import { serializeToBuffer } from '../../utils/serialize.js'; import { GlobalVariables } from '../global_variables.js'; import { PreviousKernelData } from '../kernel/previous_kernel_data.js'; import { MembershipWitness } from '../membership_witness.js'; diff --git a/yarn-project/circuits.js/src/structs/rollup/merge_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/merge_rollup.ts index 2db17d911a2..5c5f5f380d1 100644 --- a/yarn-project/circuits.js/src/structs/rollup/merge_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/merge_rollup.ts @@ -1,4 +1,5 @@ -import { serializeToBuffer } from '../../utils/serialize.js'; +import { serializeToBuffer } from '@aztec/foundation/serialize'; + import { PreviousRollupData } from './previous_rollup_data.js'; /** diff --git a/yarn-project/circuits.js/src/structs/rollup/previous_rollup_data.ts b/yarn-project/circuits.js/src/structs/rollup/previous_rollup_data.ts index 1689bfef60d..e5154b7a954 100644 --- a/yarn-project/circuits.js/src/structs/rollup/previous_rollup_data.ts +++ b/yarn-project/circuits.js/src/structs/rollup/previous_rollup_data.ts @@ -1,5 +1,6 @@ +import { serializeToBuffer } from '@aztec/foundation/serialize'; + import { ROLLUP_VK_TREE_HEIGHT } from '../../constants.gen.js'; -import { serializeToBuffer } from '../../utils/serialize.js'; import { MembershipWitness } from '../membership_witness.js'; import { Proof } from '../proof.js'; import { UInt32 } from '../shared.js'; diff --git a/yarn-project/circuits.js/src/structs/rollup/public_data_leaf/index.ts b/yarn-project/circuits.js/src/structs/rollup/public_data_leaf/index.ts index cad133b2ff9..7e36d112c48 100644 --- a/yarn-project/circuits.js/src/structs/rollup/public_data_leaf/index.ts +++ b/yarn-project/circuits.js/src/structs/rollup/public_data_leaf/index.ts @@ -1,10 +1,8 @@ import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer'; import { Fr } from '@aztec/foundation/fields'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { IndexedTreeLeaf, IndexedTreeLeafPreimage } from '@aztec/foundation/trees'; -import { serializeToBuffer } from '../../../utils/serialize.js'; - /** * Class containing the data of a preimage of a single leaf in the public data tree. * Note: It's called preimage because this data gets hashed before being inserted as a node into the `IndexedTree`. diff --git a/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts index e14aad00783..5a4b34df659 100644 --- a/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts @@ -1,5 +1,6 @@ import { Fr } from '@aztec/foundation/fields'; -import { BufferReader, Tuple } from '@aztec/foundation/serialize'; +import { BufferReader, Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; +import { FieldsOf } from '@aztec/foundation/types'; import { ARCHIVE_HEIGHT, @@ -7,8 +8,6 @@ import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, NUM_FIELDS_PER_SHA256, } from '../../constants.gen.js'; -import { FieldsOf } from '../../utils/jsUtils.js'; -import { serializeToBuffer } from '../../utils/serialize.js'; import { AggregationObject } from '../aggregation_object.js'; import { Header } from '../header.js'; import { AppendOnlyTreeSnapshot } from './append_only_tree_snapshot.js'; diff --git a/yarn-project/circuits.js/src/structs/rollup/state_diff_hints.ts b/yarn-project/circuits.js/src/structs/rollup/state_diff_hints.ts index 59189c42b63..a73b13372f7 100644 --- a/yarn-project/circuits.js/src/structs/rollup/state_diff_hints.ts +++ b/yarn-project/circuits.js/src/structs/rollup/state_diff_hints.ts @@ -1,5 +1,5 @@ import { Fr } from '@aztec/foundation/fields'; -import { Tuple } from '@aztec/foundation/serialize'; +import { Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; import { FieldsOf } from '@aztec/foundation/types'; import { @@ -10,7 +10,6 @@ import { NULLIFIER_TREE_HEIGHT, PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, } from '../../constants.gen.js'; -import { serializeToBuffer } from '../../utils/serialize.js'; import { MembershipWitness } from '../membership_witness.js'; import { NullifierLeafPreimage } from './nullifier_leaf/index.js'; diff --git a/yarn-project/circuits.js/src/structs/shared.ts b/yarn-project/circuits.js/src/structs/shared.ts index 449e1189a04..9b51ce8e1dd 100644 --- a/yarn-project/circuits.js/src/structs/shared.ts +++ b/yarn-project/circuits.js/src/structs/shared.ts @@ -1,4 +1,4 @@ -import { Bufferable, serializeToBuffer } from '../utils/serialize.js'; +import { Bufferable, serializeToBuffer } from '@aztec/foundation/serialize'; /** * Implementation of a vector. Matches how we are serializing and deserializing vectors in cpp (length in the first position, followed by the items). diff --git a/yarn-project/circuits.js/src/structs/side_effects.ts b/yarn-project/circuits.js/src/structs/side_effects.ts index 603b21a6c5e..c6b85800082 100644 --- a/yarn-project/circuits.js/src/structs/side_effects.ts +++ b/yarn-project/circuits.js/src/structs/side_effects.ts @@ -1,6 +1,5 @@ -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; -import { serializeToBuffer } from '../utils/serialize.js'; import { Fr } from './index.js'; /** diff --git a/yarn-project/circuits.js/src/structs/state_reference.ts b/yarn-project/circuits.js/src/structs/state_reference.ts index 90fae63b965..88b649f601b 100644 --- a/yarn-project/circuits.js/src/structs/state_reference.ts +++ b/yarn-project/circuits.js/src/structs/state_reference.ts @@ -1,6 +1,5 @@ -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; -import { serializeToBuffer } from '../utils/serialize.js'; import { PartialStateReference } from './partial_state_reference.js'; import { AppendOnlyTreeSnapshot } from './rollup/append_only_tree_snapshot.js'; diff --git a/yarn-project/circuits.js/src/structs/tx_context.ts b/yarn-project/circuits.js/src/structs/tx_context.ts index adab6ff8031..a5588130188 100644 --- a/yarn-project/circuits.js/src/structs/tx_context.ts +++ b/yarn-project/circuits.js/src/structs/tx_context.ts @@ -1,7 +1,7 @@ -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; +import { FieldsOf } from '@aztec/foundation/types'; -import { FieldsOf, PublicKey } from '../index.js'; -import { serializeToBuffer } from '../utils/serialize.js'; +import { PublicKey } from '../index.js'; import { AztecAddress, EthAddress, Fr, Point } from './index.js'; /** diff --git a/yarn-project/circuits.js/src/structs/tx_request.ts b/yarn-project/circuits.js/src/structs/tx_request.ts index 5e251120e04..5db6010997e 100644 --- a/yarn-project/circuits.js/src/structs/tx_request.ts +++ b/yarn-project/circuits.js/src/structs/tx_request.ts @@ -1,9 +1,8 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; +import { FieldsOf } from '@aztec/foundation/types'; -import { FieldsOf } from '../utils/jsUtils.js'; -import { serializeToBuffer } from '../utils/serialize.js'; import { FunctionData } from './function_data.js'; import { TxContext } from './tx_context.js'; diff --git a/yarn-project/circuits.js/src/structs/verification_key.ts b/yarn-project/circuits.js/src/structs/verification_key.ts index fbd38444458..91e773d843f 100644 --- a/yarn-project/circuits.js/src/structs/verification_key.ts +++ b/yarn-project/circuits.js/src/structs/verification_key.ts @@ -1,8 +1,7 @@ -import { BufferReader } from '@aztec/foundation/serialize'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import times from 'lodash.times'; -import { serializeToBuffer } from '../utils/serialize.js'; import { Fq } from './index.js'; import { CircuitType } from './shared.js'; diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 2dc490001e3..93439eea2bf 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -1,3 +1,4 @@ +import { makeHalfFullTuple, makeTuple, range } from '@aztec/foundation/array'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; import { numToUInt32BE } from '@aztec/foundation/serialize'; @@ -98,9 +99,6 @@ import { VK_TREE_HEIGHT, VerificationKey, WitnessedPublicCallData, - makeHalfFullTuple, - makeTuple, - range, } from '../index.js'; import { GlobalVariables } from '../structs/global_variables.js'; import { Header } from '../structs/header.js'; diff --git a/yarn-project/circuits.js/src/utils/index.ts b/yarn-project/circuits.js/src/utils/index.ts deleted file mode 100644 index bd7fd7dc223..00000000000 --- a/yarn-project/circuits.js/src/utils/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './serialize.js'; -export { BufferReader } from '@aztec/foundation/serialize'; diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index 25768e3f0a8..bd1e835e57d 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -38,6 +38,7 @@ "@aztec/p2p": "workspace:^", "@aztec/pxe": "workspace:^", "@aztec/sequencer-client": "workspace:^", + "@aztec/types": "workspace:^", "@aztec/world-state": "workspace:^", "@jest/globals": "^29.5.0", "@noble/curves": "^1.0.0", diff --git a/yarn-project/end-to-end/src/integration_l1_publisher.test.ts b/yarn-project/end-to-end/src/integration_l1_publisher.test.ts index 3c7e16ee370..a4f2156ad33 100644 --- a/yarn-project/end-to-end/src/integration_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/integration_l1_publisher.test.ts @@ -18,8 +18,6 @@ import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, PublicDataUpdateRequest, SideEffectLinkedToNoteHash, - makeTuple, - range, } from '@aztec/circuits.js'; import { fr, @@ -29,6 +27,7 @@ import { makeProof, } from '@aztec/circuits.js/factories'; import { createEthereumChain } from '@aztec/ethereum'; +import { makeTuple, range } from '@aztec/foundation/array'; import { DecoderHelperAbi, InboxAbi, OutboxAbi, RollupAbi } from '@aztec/l1-artifacts'; import { EmptyRollupProver, diff --git a/yarn-project/end-to-end/tsconfig.json b/yarn-project/end-to-end/tsconfig.json index b44d4c38dfb..2cd953c345d 100644 --- a/yarn-project/end-to-end/tsconfig.json +++ b/yarn-project/end-to-end/tsconfig.json @@ -51,6 +51,9 @@ { "path": "../sequencer-client" }, + { + "path": "../types" + }, { "path": "../world-state" } diff --git a/yarn-project/foundation/package.json b/yarn-project/foundation/package.json index e6e8c8e66c3..0851e5c79d5 100644 --- a/yarn-project/foundation/package.json +++ b/yarn-project/foundation/package.json @@ -36,7 +36,8 @@ "./url": "./dest/url/index.js", "./committable": "./dest/committable/index.js", "./noir": "./dest/noir/index.js", - "./testing": "./dest/testing/index.js" + "./testing": "./dest/testing/index.js", + "./array": "./dest/array/index.js" }, "scripts": { "build": "yarn clean && tsc -b", diff --git a/yarn-project/circuits.js/src/utils/jsUtils.ts b/yarn-project/foundation/src/array/array.ts similarity index 100% rename from yarn-project/circuits.js/src/utils/jsUtils.ts rename to yarn-project/foundation/src/array/array.ts diff --git a/yarn-project/foundation/src/array/index.ts b/yarn-project/foundation/src/array/index.ts new file mode 100644 index 00000000000..1759a6df56a --- /dev/null +++ b/yarn-project/foundation/src/array/index.ts @@ -0,0 +1 @@ +export * from './array.js'; diff --git a/yarn-project/foundation/src/serialize/buffer_reader.test.ts b/yarn-project/foundation/src/serialize/buffer_reader.test.ts index bd167a58a63..aadd4ac6ede 100644 --- a/yarn-project/foundation/src/serialize/buffer_reader.test.ts +++ b/yarn-project/foundation/src/serialize/buffer_reader.test.ts @@ -3,7 +3,7 @@ import { jest } from '@jest/globals'; import { randomBytes } from '../crypto/index.js'; import { Fq, Fr } from '../fields/fields.js'; import { BufferReader } from './buffer_reader.js'; -import { serializeBufferArrayToVector } from './free_funcs.js'; +import { serializeBufferArrayToVector } from './serialize.js'; const ARRAY = Array.from(Array(32)).map((_, idx) => (idx % 2 === 0 ? 0 : 1)); const BUFFER = Buffer.from(ARRAY); diff --git a/yarn-project/foundation/src/serialize/free_funcs.ts b/yarn-project/foundation/src/serialize/free_funcs.ts index 26bbd410108..6165657f0f9 100644 --- a/yarn-project/foundation/src/serialize/free_funcs.ts +++ b/yarn-project/foundation/src/serialize/free_funcs.ts @@ -1,4 +1,3 @@ -import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer'; import { Fr } from '@aztec/foundation/fields'; /** @@ -100,156 +99,6 @@ export function prefixBufferWithLength(buf: Buffer) { return Buffer.concat([lengthBuf, buf]); } -/** - * Serialize a BigInt value into a Buffer of specified width. - * The function converts the input BigInt into its big-endian representation and stores it in a Buffer of the given width. - * If the width is not provided, a default value of 32 bytes will be used. It is important to provide an appropriate width - * to avoid truncation or incorrect serialization of large BigInt values. - * - * @param n - The BigInt value to be serialized. - * @param width - The width (in bytes) of the output Buffer, optional with default value 32. - * @returns A Buffer containing the serialized BigInt value in big-endian format. - */ -export function serializeBigInt(n: bigint, width = 32) { - return toBufferBE(n, width); -} - -/** - * Deserialize a big integer from a buffer, given an offset and width. - * Reads the specified number of bytes from the buffer starting at the offset, converts it to a big integer, and returns the deserialized result along with the number of bytes read (advanced). - * - * @param buf - The buffer containing the big integer to be deserialized. - * @param offset - The position in the buffer where the big integer starts. Defaults to 0. - * @param width - The number of bytes to read from the buffer for the big integer. Defaults to 32. - * @returns An object containing the deserialized big integer value ('elem') and the number of bytes advanced ('adv'). - */ -export function deserializeBigInt(buf: Buffer, offset = 0, width = 32) { - return { elem: toBigIntBE(buf.subarray(offset, offset + width)), adv: width }; -} - -/** - * Serializes a Date object into a Buffer containing its timestamp as a big integer value. - * The resulting Buffer has a fixed width of 8 bytes, representing a 64-bit big-endian integer. - * This function is useful for converting date values into a binary format that can be stored or transmitted easily. - * - * @param date - The Date object to be serialized. - * @returns A Buffer containing the serialized timestamp of the input Date object. - */ -export function serializeDate(date: Date) { - return serializeBigInt(BigInt(date.getTime()), 8); -} - -/** - * Deserialize a boolean value from a given buffer at the specified offset. - * Reads a single byte at the provided offset in the buffer and returns - * the deserialized boolean value along with the number of bytes read (adv). - * - * @param buf - The buffer containing the serialized boolean value. - * @param offset - The position in the buffer to start reading the boolean value. - * @returns An object containing the deserialized boolean value (elem) and the number of bytes read (adv). - */ -export function deserializeBool(buf: Buffer, offset = 0) { - const adv = 1; - return { elem: buf.readUInt8(offset), adv }; -} - -/** - * Deserialize a 4-byte unsigned integer from a buffer, starting at the specified offset. - * The deserialization reads 4 bytes from the given buffer and converts it into a number. - * Returns an object containing the deserialized unsigned integer and the number of bytes advanced (4). - * - * @param buf - The buffer containing the serialized unsigned integer. - * @param offset - The starting position in the buffer to deserialize from (default is 0). - * @returns An object with the deserialized unsigned integer as 'elem' and the number of bytes advanced ('adv') as 4. - */ -export function deserializeUInt32(buf: Buffer, offset = 0) { - const adv = 4; - return { elem: buf.readUInt32BE(offset), adv }; -} - -/** - * Deserialize a signed 32-bit integer from a buffer at the given offset. - * The input 'buf' should be a Buffer containing binary data, and 'offset' should be the position in the buffer - * where the signed 32-bit integer starts. Returns an object with both the deserialized integer (elem) and the - * number of bytes advanced in the buffer (adv, always equal to 4). - * - * @param buf - The buffer containing the binary data. - * @param offset - Optional, the position in the buffer where the signed 32-bit integer starts (default is 0). - * @returns An object with the deserialized integer as 'elem' and the number of bytes advanced as 'adv'. - */ -export function deserializeInt32(buf: Buffer, offset = 0) { - const adv = 4; - return { elem: buf.readInt32BE(offset), adv }; -} - -/** - * Deserialize a field element from a buffer, starting at the given offset. - * The function reads 32 bytes from the buffer and converts it into a field element using Fr.fromBuffer. - * It returns an object containing the deserialized field element and the number of bytes read (adv). - * - * @param buf - The buffer containing the serialized field element. - * @param offset - The position in the buffer where the field element starts. Default is 0. - * @returns An object with 'elem' as the deserialized field element and 'adv' as the number of bytes read. - */ -export function deserializeField(buf: Buffer, offset = 0) { - const adv = 32; - return { elem: Fr.fromBuffer(buf.subarray(offset, offset + adv)), adv }; -} - -/** - * Serialize an array of Buffer instances into a single Buffer by concatenating the array length as a 4-byte unsigned integer - * and then the individual Buffer elements. The function is useful for storing or transmitting an array of binary data chunks - * (e.g., file parts) in a compact format. - * - * @param arr - An array of Buffer instances to be serialized into a single vector-like Buffer. - * @returns A Buffer containing the serialized array length followed by the concatenated elements of the input Buffer array. - */ -export function serializeBufferArrayToVector(arr: Buffer[]) { - const lengthBuf = Buffer.alloc(4); - lengthBuf.writeUInt32BE(arr.length, 0); - return Buffer.concat([lengthBuf, ...arr]); -} - -/** - * Deserialize an array of fixed length elements from a given buffer using a custom deserializer function. - * The deserializer function should take the buffer and an offset as arguments, and return an object containing - * the deserialized element and the number of bytes used to deserialize it (adv). - * - * @param deserialize - A custom deserializer function to extract individual elements from the buffer. - * @param vector - The input buffer containing the serialized array. - * @param offset - An optional starting position in the buffer for deserializing the array. - * @returns An object containing the deserialized array and the total number of bytes used during deserialization (adv). - * @deprecated User BufferReader instead. - */ -export function deserializeArrayFromVector( - deserialize: ( - buf: Buffer, - offset: number, - ) => { - /** - * The element. - */ - elem: T; - /** - * The advancement offset. - */ - adv: number; - }, - vector: Buffer, - offset = 0, -) { - let pos = offset; - const size = vector.readUInt32BE(pos); - pos += 4; - const arr = new Array(size); - for (let i = 0; i < size; ++i) { - const { elem, adv } = deserialize(vector, pos); - pos += adv; - arr[i] = elem; - } - return { elem: arr, adv: pos - offset }; -} - /** * Parse a buffer as a big integer. */ diff --git a/yarn-project/foundation/src/serialize/index.ts b/yarn-project/foundation/src/serialize/index.ts index 355994a86ab..669ab25f8e4 100644 --- a/yarn-project/foundation/src/serialize/index.ts +++ b/yarn-project/foundation/src/serialize/index.ts @@ -1,3 +1,4 @@ export * from './free_funcs.js'; export * from './buffer_reader.js'; export * from './types.js'; +export * from './serialize.js'; diff --git a/yarn-project/circuits.js/src/utils/serialize.ts b/yarn-project/foundation/src/serialize/serialize.ts similarity index 55% rename from yarn-project/circuits.js/src/utils/serialize.ts rename to yarn-project/foundation/src/serialize/serialize.ts index 8fbe39e1879..5ab8a8ac5c4 100644 --- a/yarn-project/circuits.js/src/utils/serialize.ts +++ b/yarn-project/foundation/src/serialize/serialize.ts @@ -1,3 +1,7 @@ +import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer'; + +import { numToUInt32BE } from './free_funcs.js'; + /** * For serializing an array of fixed length buffers. * TODO move to foundation pkg. @@ -62,30 +66,6 @@ export function deserializeArrayFromVector( return { elem: arr, adv: pos - offset }; } -/** - * Serializes a number to 32 bit little-endian form. - * @param n - The number to serialize. - * @param bufferSize - The size of the buffer to return. - * @returns Number in little-endian form. - */ -export function numToUInt32LE(n: number, bufferSize = 4): Buffer { - const buf = Buffer.alloc(bufferSize); - buf.writeUInt32LE(n, bufferSize - 4); - return buf; -} - -/** - * Serializes a number to 32 bit big-endian form. - * @param n - The number to serialize. - * @param bufferSize - The size of the buffer to return. - * @returns Number in big-endian form. - */ -export function numToUInt32BE(n: number, bufferSize = 4): Buffer { - const buf = Buffer.alloc(bufferSize); - buf.writeUInt32BE(n, bufferSize - 4); - return buf; -} - /** * Cast a uint8 array to a number. * @param array - The uint8 array. @@ -229,3 +209,85 @@ export function toFriendlyJSON(obj: object): string { 2, ); } + +/** + * Serialize a BigInt value into a Buffer of specified width. + * The function converts the input BigInt into its big-endian representation and stores it in a Buffer of the given width. + * If the width is not provided, a default value of 32 bytes will be used. It is important to provide an appropriate width + * to avoid truncation or incorrect serialization of large BigInt values. + * + * @param n - The BigInt value to be serialized. + * @param width - The width (in bytes) of the output Buffer, optional with default value 32. + * @returns A Buffer containing the serialized BigInt value in big-endian format. + */ +export function serializeBigInt(n: bigint, width = 32) { + return toBufferBE(n, width); +} + +/** + * Deserialize a big integer from a buffer, given an offset and width. + * Reads the specified number of bytes from the buffer starting at the offset, converts it to a big integer, and returns the deserialized result along with the number of bytes read (advanced). + * + * @param buf - The buffer containing the big integer to be deserialized. + * @param offset - The position in the buffer where the big integer starts. Defaults to 0. + * @param width - The number of bytes to read from the buffer for the big integer. Defaults to 32. + * @returns An object containing the deserialized big integer value ('elem') and the number of bytes advanced ('adv'). + */ +export function deserializeBigInt(buf: Buffer, offset = 0, width = 32) { + return { elem: toBigIntBE(buf.subarray(offset, offset + width)), adv: width }; +} + +/** + * Serializes a Date object into a Buffer containing its timestamp as a big integer value. + * The resulting Buffer has a fixed width of 8 bytes, representing a 64-bit big-endian integer. + * This function is useful for converting date values into a binary format that can be stored or transmitted easily. + * + * @param date - The Date object to be serialized. + * @returns A Buffer containing the serialized timestamp of the input Date object. + */ +export function serializeDate(date: Date) { + return serializeBigInt(BigInt(date.getTime()), 8); +} + +/** + * Deserialize a boolean value from a given buffer at the specified offset. + * Reads a single byte at the provided offset in the buffer and returns + * the deserialized boolean value along with the number of bytes read (adv). + * + * @param buf - The buffer containing the serialized boolean value. + * @param offset - The position in the buffer to start reading the boolean value. + * @returns An object containing the deserialized boolean value (elem) and the number of bytes read (adv). + */ +export function deserializeBool(buf: Buffer, offset = 0) { + const adv = 1; + return { elem: buf.readUInt8(offset), adv }; +} + +/** + * Deserialize a 4-byte unsigned integer from a buffer, starting at the specified offset. + * The deserialization reads 4 bytes from the given buffer and converts it into a number. + * Returns an object containing the deserialized unsigned integer and the number of bytes advanced (4). + * + * @param buf - The buffer containing the serialized unsigned integer. + * @param offset - The starting position in the buffer to deserialize from (default is 0). + * @returns An object with the deserialized unsigned integer as 'elem' and the number of bytes advanced ('adv') as 4. + */ +export function deserializeUInt32(buf: Buffer, offset = 0) { + const adv = 4; + return { elem: buf.readUInt32BE(offset), adv }; +} + +/** + * Deserialize a signed 32-bit integer from a buffer at the given offset. + * The input 'buf' should be a Buffer containing binary data, and 'offset' should be the position in the buffer + * where the signed 32-bit integer starts. Returns an object with both the deserialized integer (elem) and the + * number of bytes advanced in the buffer (adv, always equal to 4). + * + * @param buf - The buffer containing the binary data. + * @param offset - Optional, the position in the buffer where the signed 32-bit integer starts (default is 0). + * @returns An object with the deserialized integer as 'elem' and the number of bytes advanced as 'adv'. + */ +export function deserializeInt32(buf: Buffer, offset = 0) { + const adv = 4; + return { elem: buf.readInt32BE(offset), adv }; +} diff --git a/yarn-project/merkle-tree/package.json b/yarn-project/merkle-tree/package.json index cd00cbeaaba..d9c347ed115 100644 --- a/yarn-project/merkle-tree/package.json +++ b/yarn-project/merkle-tree/package.json @@ -34,6 +34,7 @@ "dependencies": { "@aztec/circuit-types": "workspace:^", "@aztec/foundation": "workspace:^", + "@aztec/types": "workspace:^", "levelup": "^5.1.1", "memdown": "^6.1.1", "sha256": "^0.2.0", diff --git a/yarn-project/merkle-tree/src/interfaces/indexed_tree.ts b/yarn-project/merkle-tree/src/interfaces/indexed_tree.ts index ab6ecf814e7..5e5531afacf 100644 --- a/yarn-project/merkle-tree/src/interfaces/indexed_tree.ts +++ b/yarn-project/merkle-tree/src/interfaces/indexed_tree.ts @@ -1,5 +1,5 @@ -import { SiblingPath } from '@aztec/circuit-types'; import { IndexedTreeLeafPreimage } from '@aztec/foundation/trees'; +import { SiblingPath } from '@aztec/types/membership'; import { AppendOnlyTree } from './append_only_tree.js'; diff --git a/yarn-project/merkle-tree/src/interfaces/merkle_tree.ts b/yarn-project/merkle-tree/src/interfaces/merkle_tree.ts index 5a30253e3a8..257e5d79761 100644 --- a/yarn-project/merkle-tree/src/interfaces/merkle_tree.ts +++ b/yarn-project/merkle-tree/src/interfaces/merkle_tree.ts @@ -1,4 +1,4 @@ -import { SiblingPath } from '@aztec/circuit-types'; +import { SiblingPath } from '@aztec/types/membership'; /** * Defines the interface for a source of sibling paths. diff --git a/yarn-project/merkle-tree/src/load_tree.ts b/yarn-project/merkle-tree/src/load_tree.ts index fb9e09d69eb..4d5bf606bb0 100644 --- a/yarn-project/merkle-tree/src/load_tree.ts +++ b/yarn-project/merkle-tree/src/load_tree.ts @@ -1,4 +1,4 @@ -import { Hasher } from '@aztec/circuit-types'; +import { Hasher } from '@aztec/types/interfaces'; import { LevelUp } from 'levelup'; diff --git a/yarn-project/merkle-tree/src/new_tree.ts b/yarn-project/merkle-tree/src/new_tree.ts index a3d16bc78b5..45e01ded402 100644 --- a/yarn-project/merkle-tree/src/new_tree.ts +++ b/yarn-project/merkle-tree/src/new_tree.ts @@ -1,4 +1,4 @@ -import { Hasher } from '@aztec/circuit-types'; +import { Hasher } from '@aztec/types/interfaces'; import { LevelUp } from 'levelup'; diff --git a/yarn-project/merkle-tree/src/pedersen.ts b/yarn-project/merkle-tree/src/pedersen.ts index 47a8b775963..2cc99004970 100644 --- a/yarn-project/merkle-tree/src/pedersen.ts +++ b/yarn-project/merkle-tree/src/pedersen.ts @@ -1,5 +1,5 @@ -import { Hasher } from '@aztec/circuit-types'; import { pedersenHash } from '@aztec/foundation/crypto'; +import { Hasher } from '@aztec/types/interfaces'; /** * A helper class encapsulating Pedersen hash functionality. diff --git a/yarn-project/merkle-tree/src/snapshots/append_only_snapshot.ts b/yarn-project/merkle-tree/src/snapshots/append_only_snapshot.ts index bcb39712c3c..113a01d2bee 100644 --- a/yarn-project/merkle-tree/src/snapshots/append_only_snapshot.ts +++ b/yarn-project/merkle-tree/src/snapshots/append_only_snapshot.ts @@ -1,4 +1,5 @@ -import { Hasher, SiblingPath } from '@aztec/circuit-types'; +import { Hasher } from '@aztec/types/interfaces'; +import { SiblingPath } from '@aztec/types/membership'; import { LevelUp } from 'levelup'; diff --git a/yarn-project/merkle-tree/src/snapshots/base_full_snapshot.ts b/yarn-project/merkle-tree/src/snapshots/base_full_snapshot.ts index 4a65cee3b01..8f49bb91582 100644 --- a/yarn-project/merkle-tree/src/snapshots/base_full_snapshot.ts +++ b/yarn-project/merkle-tree/src/snapshots/base_full_snapshot.ts @@ -1,4 +1,4 @@ -import { SiblingPath } from '@aztec/circuit-types'; +import { SiblingPath } from '@aztec/types/membership'; import { LevelUp, LevelUpChain } from 'levelup'; diff --git a/yarn-project/merkle-tree/src/snapshots/indexed_tree_snapshot.test.ts b/yarn-project/merkle-tree/src/snapshots/indexed_tree_snapshot.test.ts index 64cca7d3ee1..664c83e605d 100644 --- a/yarn-project/merkle-tree/src/snapshots/indexed_tree_snapshot.test.ts +++ b/yarn-project/merkle-tree/src/snapshots/indexed_tree_snapshot.test.ts @@ -1,5 +1,5 @@ -import { Hasher } from '@aztec/circuit-types'; import { Fr, NullifierLeaf, NullifierLeafPreimage } from '@aztec/circuits.js'; +import { Hasher } from '@aztec/types/interfaces'; import levelup, { LevelUp } from 'levelup'; diff --git a/yarn-project/merkle-tree/src/snapshots/snapshot_builder.ts b/yarn-project/merkle-tree/src/snapshots/snapshot_builder.ts index 5f8f98aed84..872395e134e 100644 --- a/yarn-project/merkle-tree/src/snapshots/snapshot_builder.ts +++ b/yarn-project/merkle-tree/src/snapshots/snapshot_builder.ts @@ -1,5 +1,5 @@ -import { SiblingPath } from '@aztec/circuit-types'; import { IndexedTreeLeafPreimage } from '@aztec/foundation/trees'; +import { SiblingPath } from '@aztec/types/membership'; /** * An interface for a tree that can record snapshots of its contents. diff --git a/yarn-project/merkle-tree/src/sparse_tree/sparse_tree.test.ts b/yarn-project/merkle-tree/src/sparse_tree/sparse_tree.test.ts index 5f9c5b558b3..a45acbb3412 100644 --- a/yarn-project/merkle-tree/src/sparse_tree/sparse_tree.test.ts +++ b/yarn-project/merkle-tree/src/sparse_tree/sparse_tree.test.ts @@ -1,5 +1,6 @@ -import { Hasher, SiblingPath } from '@aztec/circuit-types'; import { createDebugLogger } from '@aztec/foundation/log'; +import { Hasher } from '@aztec/types/interfaces'; +import { SiblingPath } from '@aztec/types/membership'; import { randomBytes } from 'crypto'; import { default as levelup } from 'levelup'; diff --git a/yarn-project/merkle-tree/src/standard_indexed_tree/standard_indexed_tree.ts b/yarn-project/merkle-tree/src/standard_indexed_tree/standard_indexed_tree.ts index eba0ff4d1d4..22297f55da9 100644 --- a/yarn-project/merkle-tree/src/standard_indexed_tree/standard_indexed_tree.ts +++ b/yarn-project/merkle-tree/src/standard_indexed_tree/standard_indexed_tree.ts @@ -1,9 +1,10 @@ -import { Hasher, SiblingPath } from '@aztec/circuit-types'; import { TreeInsertionStats } from '@aztec/circuit-types/stats'; import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer'; import { createDebugLogger } from '@aztec/foundation/log'; import { Timer } from '@aztec/foundation/timer'; import { IndexedTreeLeaf, IndexedTreeLeafPreimage } from '@aztec/foundation/trees'; +import { Hasher } from '@aztec/types/interfaces'; +import { SiblingPath } from '@aztec/types/membership'; import { LevelUp } from 'levelup'; diff --git a/yarn-project/merkle-tree/src/standard_indexed_tree/test/standard_indexed_tree.test.ts b/yarn-project/merkle-tree/src/standard_indexed_tree/test/standard_indexed_tree.test.ts index e650188db84..65d50a8eb49 100644 --- a/yarn-project/merkle-tree/src/standard_indexed_tree/test/standard_indexed_tree.test.ts +++ b/yarn-project/merkle-tree/src/standard_indexed_tree/test/standard_indexed_tree.test.ts @@ -1,4 +1,3 @@ -import { Hasher, SiblingPath } from '@aztec/circuit-types'; import { Fr, NullifierLeaf, @@ -7,6 +6,8 @@ import { PublicDataTreeLeafPreimage, } from '@aztec/circuits.js'; import { toBufferBE } from '@aztec/foundation/bigint-buffer'; +import { Hasher } from '@aztec/types/interfaces'; +import { SiblingPath } from '@aztec/types/membership'; import { default as levelup } from 'levelup'; diff --git a/yarn-project/merkle-tree/src/standard_tree/standard_tree.test.ts b/yarn-project/merkle-tree/src/standard_tree/standard_tree.test.ts index c417c254c51..34d8cc3b514 100644 --- a/yarn-project/merkle-tree/src/standard_tree/standard_tree.test.ts +++ b/yarn-project/merkle-tree/src/standard_tree/standard_tree.test.ts @@ -1,5 +1,5 @@ -import { Hasher } from '@aztec/circuit-types'; import { randomBytes } from '@aztec/foundation/crypto'; +import { Hasher } from '@aztec/types/interfaces'; import { default as levelup } from 'levelup'; diff --git a/yarn-project/merkle-tree/src/test/standard_based_test_suite.ts b/yarn-project/merkle-tree/src/test/standard_based_test_suite.ts index 86d145b48bf..29881831ee2 100644 --- a/yarn-project/merkle-tree/src/test/standard_based_test_suite.ts +++ b/yarn-project/merkle-tree/src/test/standard_based_test_suite.ts @@ -1,4 +1,5 @@ -import { Hasher, SiblingPath } from '@aztec/circuit-types'; +import { Hasher } from '@aztec/types/interfaces'; +import { SiblingPath } from '@aztec/types/membership'; import { randomBytes } from 'crypto'; import { default as levelup } from 'levelup'; diff --git a/yarn-project/merkle-tree/src/test/test_suite.ts b/yarn-project/merkle-tree/src/test/test_suite.ts index 3323c47fc8d..31ee72a9b0e 100644 --- a/yarn-project/merkle-tree/src/test/test_suite.ts +++ b/yarn-project/merkle-tree/src/test/test_suite.ts @@ -1,4 +1,5 @@ -import { Hasher, SiblingPath } from '@aztec/circuit-types'; +import { Hasher } from '@aztec/types/interfaces'; +import { SiblingPath } from '@aztec/types/membership'; import { default as levelup } from 'levelup'; diff --git a/yarn-project/merkle-tree/src/tree_base.ts b/yarn-project/merkle-tree/src/tree_base.ts index 4339804f150..2d32b032279 100644 --- a/yarn-project/merkle-tree/src/tree_base.ts +++ b/yarn-project/merkle-tree/src/tree_base.ts @@ -1,6 +1,7 @@ -import { Hasher, SiblingPath } from '@aztec/circuit-types'; import { toBigIntLE, toBufferLE } from '@aztec/foundation/bigint-buffer'; import { DebugLogger, createDebugLogger } from '@aztec/foundation/log'; +import { Hasher } from '@aztec/types/interfaces'; +import { SiblingPath } from '@aztec/types/membership'; import { LevelUp, LevelUpChain } from 'levelup'; diff --git a/yarn-project/merkle-tree/tsconfig.json b/yarn-project/merkle-tree/tsconfig.json index d2bc1df097f..413464d606d 100644 --- a/yarn-project/merkle-tree/tsconfig.json +++ b/yarn-project/merkle-tree/tsconfig.json @@ -12,6 +12,9 @@ { "path": "../foundation" }, + { + "path": "../types" + }, { "path": "../circuits.js" } diff --git a/yarn-project/noir-protocol-circuits/src/index.test.ts b/yarn-project/noir-protocol-circuits/src/index.test.ts index 623e0bc7b9b..1be172d23ac 100644 --- a/yarn-project/noir-protocol-circuits/src/index.test.ts +++ b/yarn-project/noir-protocol-circuits/src/index.test.ts @@ -52,9 +52,9 @@ import { VK_TREE_HEIGHT, VerificationKey, makeEmptyProof, - makeTuple, } from '@aztec/circuits.js'; import { computeCompleteAddress, computeFunctionLeaf, computeTxHash } from '@aztec/circuits.js/abis'; +import { makeTuple } from '@aztec/foundation/array'; import { Fr } from '@aztec/foundation/fields'; import { DebugLogger, createDebugLogger } from '@aztec/foundation/log'; import { fileURLToPath } from '@aztec/foundation/url'; diff --git a/yarn-project/pxe/src/database/deferred_note_dao.ts b/yarn-project/pxe/src/database/deferred_note_dao.ts index 9748587f6fe..575c13bea4c 100644 --- a/yarn-project/pxe/src/database/deferred_note_dao.ts +++ b/yarn-project/pxe/src/database/deferred_note_dao.ts @@ -1,6 +1,6 @@ -import { BufferReader, Note, TxHash } from '@aztec/circuit-types'; +import { Note, TxHash } from '@aztec/circuit-types'; import { AztecAddress, Fr, Point, PublicKey, Vector } from '@aztec/circuits.js'; -import { serializeToBuffer } from '@aztec/circuits.js/utils'; +import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; /** * A note that is intended for us, but we cannot decode it yet because the contract is not yet in our database. diff --git a/yarn-project/pxe/src/database/note_dao.ts b/yarn-project/pxe/src/database/note_dao.ts index eee77c986c7..1a7e3442dcd 100644 --- a/yarn-project/pxe/src/database/note_dao.ts +++ b/yarn-project/pxe/src/database/note_dao.ts @@ -1,7 +1,8 @@ import { NoteData } from '@aztec/acir-simulator'; -import { BufferReader, Note, TxHash } from '@aztec/circuit-types'; +import { Note, TxHash } from '@aztec/circuit-types'; import { AztecAddress, Fr, Point, PublicKey } from '@aztec/circuits.js'; import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer'; +import { BufferReader } from '@aztec/foundation/serialize'; /** * A note with contextual data. diff --git a/yarn-project/pxe/src/kernel_prover/kernel_prover.test.ts b/yarn-project/pxe/src/kernel_prover/kernel_prover.test.ts index f9bd279e259..e6cdfe590ab 100644 --- a/yarn-project/pxe/src/kernel_prover/kernel_prover.test.ts +++ b/yarn-project/pxe/src/kernel_prover/kernel_prover.test.ts @@ -16,9 +16,9 @@ import { VK_TREE_HEIGHT, VerificationKey, makeEmptyProof, - makeTuple, } from '@aztec/circuits.js'; import { makeTxRequest } from '@aztec/circuits.js/factories'; +import { makeTuple } from '@aztec/foundation/array'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; import { Tuple } from '@aztec/foundation/serialize'; diff --git a/yarn-project/pxe/src/kernel_prover/kernel_prover.ts b/yarn-project/pxe/src/kernel_prover/kernel_prover.ts index 307304e4888..0fe2966c80a 100644 --- a/yarn-project/pxe/src/kernel_prover/kernel_prover.ts +++ b/yarn-project/pxe/src/kernel_prover/kernel_prover.ts @@ -25,8 +25,8 @@ import { VK_TREE_HEIGHT, VerificationKey, makeEmptyProof, - makeTuple, } from '@aztec/circuits.js'; +import { makeTuple } from '@aztec/foundation/array'; import { padArrayEnd } from '@aztec/foundation/collection'; import { Tuple, assertLength, mapTuple } from '@aztec/foundation/serialize'; import { pushTestData } from '@aztec/foundation/testing'; diff --git a/yarn-project/sequencer-client/package.json b/yarn-project/sequencer-client/package.json index 9cb67d3eeae..879838cf052 100644 --- a/yarn-project/sequencer-client/package.json +++ b/yarn-project/sequencer-client/package.json @@ -41,6 +41,7 @@ "@aztec/merkle-tree": "workspace:^", "@aztec/noir-protocol-circuits": "workspace:^", "@aztec/p2p": "workspace:^", + "@aztec/types": "workspace:^", "@aztec/world-state": "workspace:^", "lodash.chunk": "^4.2.0", "lodash.pick": "^4.4.0", 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 d0e5b8ff6d6..5a390b36fa6 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 @@ -32,8 +32,6 @@ import { SideEffect, SideEffectLinkedToNoteHash, StateReference, - makeTuple, - range, } from '@aztec/circuits.js'; import { computeBlockHashWithGlobals, computeContractLeaf } from '@aztec/circuits.js/abis'; import { @@ -47,6 +45,7 @@ import { makePublicCallRequest, makeRootRollupPublicInputs, } from '@aztec/circuits.js/factories'; +import { makeTuple, range } from '@aztec/foundation/array'; import { toBufferBE } from '@aztec/foundation/bigint-buffer'; import { to2Fields } from '@aztec/foundation/serialize'; import { MerkleTreeOperations, MerkleTrees } from '@aztec/world-state'; diff --git a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts index 08d44b2c39f..d8958a6d409 100644 --- a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts +++ b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts @@ -41,7 +41,6 @@ import { StateReference, VK_TREE_HEIGHT, VerificationKey, - makeTuple, } from '@aztec/circuits.js'; import { computeBlockHash, @@ -49,12 +48,12 @@ import { computeContractLeaf, computeGlobalsHash, } from '@aztec/circuits.js/abis'; -import { toFriendlyJSON } from '@aztec/circuits.js/utils'; +import { makeTuple } from '@aztec/foundation/array'; import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; import { padArrayEnd } from '@aztec/foundation/collection'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; -import { Tuple, assertLength } from '@aztec/foundation/serialize'; +import { Tuple, assertLength, toFriendlyJSON } from '@aztec/foundation/serialize'; import { MerkleTreeOperations } from '@aztec/world-state'; import chunk from 'lodash.chunk'; diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts index 787554b6c5b..98db4d5e64e 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts @@ -3,7 +3,6 @@ import { ExtendedContractData, FunctionCall, FunctionL2Logs, - SiblingPath, SimulationError, Tx, TxL2Logs, @@ -27,7 +26,6 @@ import { PublicCallRequest, PublicKernelPublicInputs, makeEmptyProof, - makeTuple, } from '@aztec/circuits.js'; import { makeAztecAddress, @@ -35,7 +33,9 @@ import { makePublicCallRequest, makeSelector, } from '@aztec/circuits.js/factories'; +import { makeTuple } from '@aztec/foundation/array'; import { padArrayEnd } from '@aztec/foundation/collection'; +import { SiblingPath } from '@aztec/types/membership'; import { MerkleTreeOperations, TreeInfo } from '@aztec/world-state'; import { MockProxy, mock } from 'jest-mock-extended'; diff --git a/yarn-project/sequencer-client/tsconfig.json b/yarn-project/sequencer-client/tsconfig.json index 5d388dd4472..92a83cff65d 100644 --- a/yarn-project/sequencer-client/tsconfig.json +++ b/yarn-project/sequencer-client/tsconfig.json @@ -33,6 +33,9 @@ { "path": "../p2p" }, + { + "path": "../types" + }, { "path": "../world-state" } diff --git a/yarn-project/types/package.json b/yarn-project/types/package.json index 97f8acc0d8e..2ebd3ab048d 100644 --- a/yarn-project/types/package.json +++ b/yarn-project/types/package.json @@ -6,7 +6,8 @@ "main": "./dest/index.js", "types": "./dest/index.d.ts", "exports": { - "./interfaces": "./dest/interfaces/index.js" + "./interfaces": "./dest/interfaces/index.js", + "./membership": "./dest/sibling-path/index.js" }, "scripts": { "build": "yarn clean && tsc -b", @@ -29,7 +30,8 @@ "rootDir": "./src" }, "dependencies": { - "@aztec/ethereum": "workspace:^" + "@aztec/ethereum": "workspace:^", + "@aztec/foundation": "workspace:^" }, "devDependencies": { "@jest/globals": "^29.5.0", diff --git a/yarn-project/types/src/index.ts b/yarn-project/types/src/index.ts index a3df311a469..6815c4130c4 100644 --- a/yarn-project/types/src/index.ts +++ b/yarn-project/types/src/index.ts @@ -1 +1,2 @@ export * from './interfaces/index.js'; +export * from './sibling-path/index.js'; diff --git a/yarn-project/circuit-types/src/interfaces/hasher.ts b/yarn-project/types/src/interfaces/hasher.ts similarity index 100% rename from yarn-project/circuit-types/src/interfaces/hasher.ts rename to yarn-project/types/src/interfaces/hasher.ts diff --git a/yarn-project/types/src/interfaces/index.ts b/yarn-project/types/src/interfaces/index.ts index 46da7a96f90..1aab588e99b 100644 --- a/yarn-project/types/src/interfaces/index.ts +++ b/yarn-project/types/src/interfaces/index.ts @@ -1 +1,2 @@ export * from './node-info.js'; +export * from './hasher.js'; diff --git a/yarn-project/types/src/sibling-path/index.ts b/yarn-project/types/src/sibling-path/index.ts new file mode 100644 index 00000000000..f691de90659 --- /dev/null +++ b/yarn-project/types/src/sibling-path/index.ts @@ -0,0 +1 @@ +export * from './sibling-path.js'; diff --git a/yarn-project/circuit-types/src/sibling_path.ts b/yarn-project/types/src/sibling-path/sibling-path.ts similarity index 98% rename from yarn-project/circuit-types/src/sibling_path.ts rename to yarn-project/types/src/sibling-path/sibling-path.ts index bb31ffe3709..ae2db6fe133 100644 --- a/yarn-project/circuit-types/src/sibling_path.ts +++ b/yarn-project/types/src/sibling-path/sibling-path.ts @@ -1,4 +1,4 @@ -import { makeTuple } from '@aztec/circuits.js'; +import { makeTuple } from '@aztec/foundation/array'; import { Fr } from '@aztec/foundation/fields'; import { Tuple, @@ -7,7 +7,7 @@ import { serializeBufferArrayToVector, } from '@aztec/foundation/serialize'; -import { Hasher } from './interfaces/index.js'; +import { Hasher } from '../interfaces/index.js'; /** * Contains functionality to compute and serialize/deserialize a sibling path. diff --git a/yarn-project/types/tsconfig.json b/yarn-project/types/tsconfig.json index d59d9edb2a7..9a89aafcc3a 100644 --- a/yarn-project/types/tsconfig.json +++ b/yarn-project/types/tsconfig.json @@ -9,6 +9,9 @@ "references": [ { "path": "../ethereum" + }, + { + "path": "../foundation" } ] } diff --git a/yarn-project/world-state/package.json b/yarn-project/world-state/package.json index 402d3a6bd9c..f4d908eec5d 100644 --- a/yarn-project/world-state/package.json +++ b/yarn-project/world-state/package.json @@ -34,6 +34,7 @@ "@aztec/circuits.js": "workspace:^", "@aztec/foundation": "workspace:^", "@aztec/merkle-tree": "workspace:^", + "@aztec/types": "workspace:^", "levelup": "^5.1.1", "lodash.times": "^4.3.2", "memdown": "^6.1.1", diff --git a/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.test.ts b/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.test.ts index 6fc22d50528..65addf22ff3 100644 --- a/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.test.ts +++ b/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.test.ts @@ -1,8 +1,9 @@ -import { L2Block, L2BlockSource, MerkleTreeId, SiblingPath } from '@aztec/circuit-types'; +import { L2Block, L2BlockSource, MerkleTreeId } from '@aztec/circuit-types'; import { Fr } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { sleep } from '@aztec/foundation/sleep'; import { INITIAL_LEAF, Pedersen } from '@aztec/merkle-tree'; +import { SiblingPath } from '@aztec/types/membership'; import { jest } from '@jest/globals'; import { mock } from 'jest-mock-extended'; diff --git a/yarn-project/world-state/src/world-state-db/merkle_tree_operations.ts b/yarn-project/world-state/src/world-state-db/merkle_tree_operations.ts index c62b96d3db1..14fd49c4c1a 100644 --- a/yarn-project/world-state/src/world-state-db/merkle_tree_operations.ts +++ b/yarn-project/world-state/src/world-state-db/merkle_tree_operations.ts @@ -1,9 +1,10 @@ -import { L2Block, MerkleTreeId, SiblingPath } from '@aztec/circuit-types'; +import { L2Block, MerkleTreeId } from '@aztec/circuit-types'; import { NullifierLeafPreimage } from '@aztec/circuits.js'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; import { IndexedTreeLeafPreimage } from '@aztec/foundation/trees'; import { BatchInsertionResult } from '@aztec/merkle-tree'; +import { SiblingPath } from '@aztec/types/membership'; /** * Type alias for the nullifier tree ID. diff --git a/yarn-project/world-state/src/world-state-db/merkle_tree_operations_facade.ts b/yarn-project/world-state/src/world-state-db/merkle_tree_operations_facade.ts index 6d8127897d6..b58cd7f454d 100644 --- a/yarn-project/world-state/src/world-state-db/merkle_tree_operations_facade.ts +++ b/yarn-project/world-state/src/world-state-db/merkle_tree_operations_facade.ts @@ -1,8 +1,9 @@ -import { L2Block, MerkleTreeId, SiblingPath } from '@aztec/circuit-types'; +import { L2Block, MerkleTreeId } from '@aztec/circuit-types'; import { NullifierLeafPreimage } from '@aztec/circuits.js'; import { Fr } from '@aztec/foundation/fields'; import { IndexedTreeLeafPreimage } from '@aztec/foundation/trees'; import { BatchInsertionResult } from '@aztec/merkle-tree'; +import { SiblingPath } from '@aztec/types/membership'; import { MerkleTreeDb } from './merkle_tree_db.js'; import { CurrentTreeRoots, HandleL2BlockResult, MerkleTreeOperations, TreeInfo } from './merkle_tree_operations.js'; diff --git a/yarn-project/world-state/src/world-state-db/merkle_tree_snapshot_operations_facade.ts b/yarn-project/world-state/src/world-state-db/merkle_tree_snapshot_operations_facade.ts index 20289635ecf..53614bc1ed4 100644 --- a/yarn-project/world-state/src/world-state-db/merkle_tree_snapshot_operations_facade.ts +++ b/yarn-project/world-state/src/world-state-db/merkle_tree_snapshot_operations_facade.ts @@ -1,7 +1,8 @@ -import { MerkleTreeId, SiblingPath } from '@aztec/circuit-types'; +import { MerkleTreeId } from '@aztec/circuit-types'; import { Fr } from '@aztec/circuits.js'; import { IndexedTreeLeafPreimage } from '@aztec/foundation/trees'; import { BatchInsertionResult, IndexedTreeSnapshot, TreeSnapshot } from '@aztec/merkle-tree'; +import { SiblingPath } from '@aztec/types/membership'; import { MerkleTreeDb } from './merkle_tree_db.js'; import { CurrentTreeRoots, HandleL2BlockResult, MerkleTreeOperations, TreeInfo } from './merkle_tree_operations.js'; diff --git a/yarn-project/world-state/src/world-state-db/merkle_trees.ts b/yarn-project/world-state/src/world-state-db/merkle_trees.ts index 8bf0a576282..b8a0d5c44ee 100644 --- a/yarn-project/world-state/src/world-state-db/merkle_trees.ts +++ b/yarn-project/world-state/src/world-state-db/merkle_trees.ts @@ -1,4 +1,4 @@ -import { Hasher, L2Block, MerkleTreeId, SiblingPath } from '@aztec/circuit-types'; +import { L2Block, MerkleTreeId } from '@aztec/circuit-types'; import { ARCHIVE_HEIGHT, CONTRACT_TREE_HEIGHT, @@ -32,6 +32,8 @@ import { loadTree, newTree, } from '@aztec/merkle-tree'; +import { Hasher } from '@aztec/types/interfaces'; +import { SiblingPath } from '@aztec/types/membership'; import { default as levelup } from 'levelup'; diff --git a/yarn-project/world-state/tsconfig.json b/yarn-project/world-state/tsconfig.json index 2f4e3a853a2..5550de6775f 100644 --- a/yarn-project/world-state/tsconfig.json +++ b/yarn-project/world-state/tsconfig.json @@ -17,6 +17,9 @@ }, { "path": "../merkle-tree" + }, + { + "path": "../types" } ], "include": ["src"] diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 06f0a3f09e7..c5e752f4d2f 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -175,6 +175,7 @@ __metadata: "@aztec/merkle-tree": "workspace:^" "@aztec/p2p": "workspace:^" "@aztec/sequencer-client": "workspace:^" + "@aztec/types": "workspace:^" "@aztec/world-state": "workspace:^" "@jest/globals": ^29.5.0 "@types/jest": ^29.5.0 @@ -407,6 +408,7 @@ __metadata: "@aztec/p2p": "workspace:^" "@aztec/pxe": "workspace:^" "@aztec/sequencer-client": "workspace:^" + "@aztec/types": "workspace:^" "@aztec/world-state": "workspace:^" "@jest/globals": ^29.5.0 "@noble/curves": ^1.0.0 @@ -582,6 +584,7 @@ __metadata: "@aztec/circuit-types": "workspace:^" "@aztec/circuits.js": "workspace:^" "@aztec/foundation": "workspace:^" + "@aztec/types": "workspace:^" "@jest/globals": ^29.5.0 "@types/jest": ^29.5.0 "@types/levelup": ^5.1.2 @@ -820,6 +823,7 @@ __metadata: "@aztec/merkle-tree": "workspace:^" "@aztec/noir-protocol-circuits": "workspace:^" "@aztec/p2p": "workspace:^" + "@aztec/types": "workspace:^" "@aztec/world-state": "workspace:^" "@jest/globals": ^29.5.0 "@types/jest": ^29.5.0 @@ -852,6 +856,7 @@ __metadata: resolution: "@aztec/types@workspace:types" dependencies: "@aztec/ethereum": "workspace:^" + "@aztec/foundation": "workspace:^" "@jest/globals": ^29.5.0 "@types/debug": ^4.1.7 "@types/detect-node": ^2.0.0 @@ -882,6 +887,7 @@ __metadata: "@aztec/circuits.js": "workspace:^" "@aztec/foundation": "workspace:^" "@aztec/merkle-tree": "workspace:^" + "@aztec/types": "workspace:^" "@jest/globals": ^29.5.0 "@types/jest": ^29.5.0 "@types/levelup": ^5.1.2