From 433babdadfc3fa5e14634e43aafb9efd9c3c2313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bene=C5=A1?= Date: Thu, 1 Feb 2024 16:57:37 +0100 Subject: [PATCH] refactor: typing contents of `MessageLoadOracleInputs` (#4351) To be able to use `SiblingPath` in `MessageLoadOracleInputs` I had to move it to circuits-types from types. Since this results in a lot of changes I decided to make it a separate PR from the one down the stack. --- .../src/acvm/oracle/typed_oracle.ts | 25 +++++++++++-------- .../src/client/private_execution.test.ts | 8 +----- yarn-project/acir-simulator/src/public/db.ts | 4 +-- .../acir-simulator/src/public/index.test.ts | 14 +++++++---- .../src/aztec-node/http_rpc_server.ts | 2 +- .../aztec-node/src/aztec-node/server.ts | 2 +- .../src/aztec_node/rpc/aztec_node_client.ts | 2 +- yarn-project/circuit-types/src/index.ts | 1 + .../src/interfaces/nullifier_tree.ts | 3 ++- .../src/interfaces/public_data_tree.ts | 3 ++- .../src/interfaces/state_info_provider.ts | 2 +- .../src/sibling_path}/index.ts | 0 .../src/sibling_path}/sibling-path.ts | 3 +-- .../src/interfaces/indexed_tree.ts | 2 +- .../merkle-tree/src/interfaces/merkle_tree.ts | 2 +- .../src/snapshots/append_only_snapshot.ts | 2 +- .../src/snapshots/base_full_snapshot.ts | 2 +- .../src/snapshots/snapshot_builder.ts | 2 +- .../src/sparse_tree/sparse_tree.test.ts | 2 +- .../standard_indexed_tree.ts | 2 +- .../test/standard_indexed_tree.test.ts | 2 +- .../src/test/standard_based_test_suite.ts | 2 +- .../merkle-tree/src/test/test_suite.ts | 2 +- yarn-project/merkle-tree/src/tree_base.ts | 2 +- .../pxe/src/simulator_oracle/index.ts | 16 +++++++++--- .../src/sequencer/public_processor.test.ts | 2 +- .../src/simulator/public_executor.ts | 18 ++++++++++--- yarn-project/types/src/index.ts | 1 - .../server_world_state_synchronizer.test.ts | 3 +-- .../world-state-db/merkle_tree_operations.ts | 3 +-- .../merkle_tree_operations_facade.ts | 3 +-- .../merkle_tree_snapshot_operations_facade.ts | 3 +-- .../src/world-state-db/merkle_trees.ts | 3 +-- 33 files changed, 80 insertions(+), 63 deletions(-) rename yarn-project/{types/src/sibling-path => circuit-types/src/sibling_path}/index.ts (100%) rename yarn-project/{types/src/sibling-path => circuit-types/src/sibling_path}/sibling-path.ts (99%) diff --git a/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts b/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts index f4c58c9d33d..e19424a24ca 100644 --- a/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts +++ b/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts @@ -1,14 +1,22 @@ import { CompleteAddress, + L1ToL2Message, MerkleTreeId, Note, NoteStatus, NullifierMembershipWitness, PublicDataWitness, PublicKey, + SiblingPath, UnencryptedL2Log, } from '@aztec/circuit-types'; -import { GrumpkinPrivateKey, Header, PrivateCallStackItem, PublicCallRequest } from '@aztec/circuits.js'; +import { + GrumpkinPrivateKey, + Header, + L1_TO_L2_MSG_TREE_HEIGHT, + PrivateCallStackItem, + PublicCallRequest, +} from '@aztec/circuits.js'; import { FunctionSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; @@ -48,21 +56,18 @@ export interface NoteData { index?: bigint; } -export class MessageLoadOracleInputs { +export class MessageLoadOracleInputs { constructor( - /** - * An collapsed array of fields containing all of the l1 to l2 message components. - * `l1ToL2Message.toFieldArray()` -\> [sender, chainId, recipient, version, content, secretHash, deadline, fee] - */ - public message: Fr[], + /** The message. */ + public message: L1ToL2Message, /** The index of the message commitment in the merkle tree. */ public index: bigint, /** The path in the merkle tree to the message. */ - public siblingPath: Fr[], + public siblingPath: SiblingPath, ) {} toFields(): Fr[] { - return [...this.message, new Fr(this.index), ...this.siblingPath]; + return [...this.message.toFieldArray(), new Fr(this.index), ...this.siblingPath.toFieldArray()]; } } @@ -154,7 +159,7 @@ export abstract class TypedOracle { throw new Error('Not available.'); } - getL1ToL2Message(_msgKey: Fr): Promise { + getL1ToL2Message(_msgKey: Fr): Promise> { throw new Error('Not available.'); } 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 b3ace37240b..62860247a85 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -544,13 +544,7 @@ describe('Private Execution test suite', () => { const mockOracles = async () => { const tree = await insertLeaves([messageKey ?? preimage.hash()], 'l1ToL2Messages'); oracle.getL1ToL2Message.mockImplementation(async () => { - return Promise.resolve( - new MessageLoadOracleInputs( - preimage.toFieldArray(), - 0n, - (await tree.getSiblingPath(0n, false)).toFieldArray(), - ), - ); + return Promise.resolve(new MessageLoadOracleInputs(preimage, 0n, await tree.getSiblingPath(0n, false))); }); }; diff --git a/yarn-project/acir-simulator/src/public/db.ts b/yarn-project/acir-simulator/src/public/db.ts index a001a4d4ab8..26923cc366e 100644 --- a/yarn-project/acir-simulator/src/public/db.ts +++ b/yarn-project/acir-simulator/src/public/db.ts @@ -1,4 +1,4 @@ -import { EthAddress, FunctionSelector } from '@aztec/circuits.js'; +import { EthAddress, FunctionSelector, L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; @@ -74,7 +74,7 @@ export interface CommitmentsDB { * @param msgKey - The message Key. * @returns - The l1 to l2 message object */ - getL1ToL2Message(msgKey: Fr): Promise; + getL1ToL2Message(msgKey: Fr): Promise>; /** * Gets the index of a commitment in the note hash tree. diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index 4d7fdb81c92..e96cd2ecaa9 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -1,4 +1,4 @@ -import { L1ToL2Message } from '@aztec/circuit-types'; +import { L1ToL2Message, SiblingPath } from '@aztec/circuit-types'; import { AppendOnlyTreeSnapshot, CallContext, @@ -455,13 +455,17 @@ describe('ACIR public execution simulator', () => { publicContracts.getBytecode.mockResolvedValue(Buffer.from(mintPublicArtifact.bytecode, 'base64')); publicState.storageRead.mockResolvedValue(Fr.ZERO); - const siblingPath = Array(L1_TO_L2_MSG_TREE_HEIGHT).fill(Fr.random()); + const siblingPathBuffers = Array(L1_TO_L2_MSG_TREE_HEIGHT) + .fill(Fr.random()) + .map(f => f.toBuffer()); + const siblingPath = new SiblingPath(L1_TO_L2_MSG_TREE_HEIGHT, siblingPathBuffers); + let root = messageKey ?? preimage.hash(); - for (const sibling of siblingPath) { - root = Fr.fromBuffer(pedersenHash([root.toBuffer(), sibling.toBuffer()])); + for (const sibling of siblingPathBuffers) { + root = Fr.fromBuffer(pedersenHash([root.toBuffer(), sibling])); } commitmentsDb.getL1ToL2Message.mockImplementation(() => { - return Promise.resolve(new MessageLoadOracleInputs(preimage.toFieldArray(), 0n, siblingPath)); + return Promise.resolve(new MessageLoadOracleInputs(preimage, 0n, siblingPath)); }); return new AppendOnlyTreeSnapshot( 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 0b4d6f7236b..fbbbed51794 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,6 +8,7 @@ import { L2BlockL2Logs, L2Tx, LogId, + SiblingPath, Tx, TxHash, } from '@aztec/circuit-types'; @@ -16,7 +17,6 @@ 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 2ccd40baa00..5f55ade4850 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -19,6 +19,7 @@ import { NullifierMembershipWitness, PublicDataWitness, SequencerConfig, + SiblingPath, Tx, TxHash, } from '@aztec/circuit-types'; @@ -46,7 +47,6 @@ import { SequencerClient, getGlobalVariableBuilder, } from '@aztec/sequencer-client'; -import { SiblingPath } from '@aztec/types/membership'; import { MerkleTrees, ServerWorldStateSynchronizer, 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 c78a6cdeb08..2ac789ffe38 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,7 +4,6 @@ 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'; @@ -12,6 +11,7 @@ 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/index.js'; import { Tx, TxHash } from '../../tx/index.js'; /** diff --git a/yarn-project/circuit-types/src/index.ts b/yarn-project/circuit-types/src/index.ts index 85ea8cb627f..a61e91fc27d 100644 --- a/yarn-project/circuit-types/src/index.ts +++ b/yarn-project/circuit-types/src/index.ts @@ -16,6 +16,7 @@ export * from './merkle_tree_id.js'; export * from './mocks.js'; export * from './public_data_write.js'; export * from './simulation_error.js'; +export * from './sibling_path/index.js'; export * from './tx/index.js'; export * from './tx_execution_request.js'; export * from './packed_arguments.js'; diff --git a/yarn-project/circuit-types/src/interfaces/nullifier_tree.ts b/yarn-project/circuit-types/src/interfaces/nullifier_tree.ts index 4a06400a8c7..81b49d7dd46 100644 --- a/yarn-project/circuit-types/src/interfaces/nullifier_tree.ts +++ b/yarn-project/circuit-types/src/interfaces/nullifier_tree.ts @@ -1,5 +1,6 @@ import { Fr, NULLIFIER_TREE_HEIGHT, NullifierLeafPreimage } from '@aztec/circuits.js'; -import { SiblingPath } from '@aztec/types/membership'; + +import { SiblingPath } from '../sibling_path/index.js'; /** * 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 5c5fc9c3054..5ea517fc84a 100644 --- a/yarn-project/circuit-types/src/interfaces/public_data_tree.ts +++ b/yarn-project/circuit-types/src/interfaces/public_data_tree.ts @@ -1,5 +1,6 @@ import { Fr, PUBLIC_DATA_TREE_HEIGHT, PublicDataTreeLeafPreimage } from '@aztec/circuits.js'; -import { SiblingPath } from '@aztec/types/membership'; + +import { SiblingPath } from '../sibling_path/index.js'; /** * 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 3e7d83ece94..d653a2284c8 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/index.js'; import { NullifierMembershipWitness } from './nullifier_tree.js'; import { PublicDataWitness } from './public_data_tree.js'; diff --git a/yarn-project/types/src/sibling-path/index.ts b/yarn-project/circuit-types/src/sibling_path/index.ts similarity index 100% rename from yarn-project/types/src/sibling-path/index.ts rename to yarn-project/circuit-types/src/sibling_path/index.ts diff --git a/yarn-project/types/src/sibling-path/sibling-path.ts b/yarn-project/circuit-types/src/sibling_path/sibling-path.ts similarity index 99% rename from yarn-project/types/src/sibling-path/sibling-path.ts rename to yarn-project/circuit-types/src/sibling_path/sibling-path.ts index ae2db6fe133..f0a8ee22a43 100644 --- a/yarn-project/types/src/sibling-path/sibling-path.ts +++ b/yarn-project/circuit-types/src/sibling_path/sibling-path.ts @@ -6,8 +6,7 @@ import { deserializeArrayFromVector, serializeBufferArrayToVector, } from '@aztec/foundation/serialize'; - -import { Hasher } from '../interfaces/index.js'; +import { Hasher } from '@aztec/types/interfaces'; /** * Contains functionality to compute and serialize/deserialize a sibling path. diff --git a/yarn-project/merkle-tree/src/interfaces/indexed_tree.ts b/yarn-project/merkle-tree/src/interfaces/indexed_tree.ts index 651f734f09e..13c14f059dc 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 { IndexedTreeLeaf, 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 209656f885d..752c07c3142 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/types/membership'; +import { SiblingPath } from '@aztec/circuit-types'; /** * Defines the interface for a source of sibling paths. 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 06d6e4b3194..3096688b806 100644 --- a/yarn-project/merkle-tree/src/snapshots/append_only_snapshot.ts +++ b/yarn-project/merkle-tree/src/snapshots/append_only_snapshot.ts @@ -1,6 +1,6 @@ +import { SiblingPath } from '@aztec/circuit-types'; import { AztecKVStore, AztecMap } from '@aztec/kv-store'; import { Hasher } from '@aztec/types/interfaces'; -import { SiblingPath } from '@aztec/types/membership'; import { AppendOnlyTree } from '../interfaces/append_only_tree.js'; import { TreeBase } from '../tree_base.js'; 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 5f1e250c569..01518cfd3f2 100644 --- a/yarn-project/merkle-tree/src/snapshots/base_full_snapshot.ts +++ b/yarn-project/merkle-tree/src/snapshots/base_full_snapshot.ts @@ -1,5 +1,5 @@ +import { SiblingPath } from '@aztec/circuit-types'; import { AztecKVStore, AztecMap } from '@aztec/kv-store'; -import { SiblingPath } from '@aztec/types/membership'; import { TreeBase } from '../tree_base.js'; import { TreeSnapshot, TreeSnapshotBuilder } from './snapshot_builder.js'; diff --git a/yarn-project/merkle-tree/src/snapshots/snapshot_builder.ts b/yarn-project/merkle-tree/src/snapshots/snapshot_builder.ts index 98bbb9051d8..5feb1a2ef00 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 2de1db97d34..21ce5c2b767 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,7 +1,7 @@ +import { SiblingPath } from '@aztec/circuit-types'; import { createDebugLogger } from '@aztec/foundation/log'; import { AztecKVStore, AztecLmdbStore } from '@aztec/kv-store'; import { Hasher } from '@aztec/types/interfaces'; -import { SiblingPath } from '@aztec/types/membership'; import { randomBytes } from 'crypto'; 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 316bc2a62df..68a3f588ae2 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,10 +1,10 @@ +import { SiblingPath } from '@aztec/circuit-types'; import { TreeInsertionStats } from '@aztec/circuit-types/stats'; import { toBufferBE } from '@aztec/foundation/bigint-buffer'; import { Timer } from '@aztec/foundation/timer'; import { IndexedTreeLeaf, IndexedTreeLeafPreimage } from '@aztec/foundation/trees'; import { AztecKVStore, AztecMap } from '@aztec/kv-store'; import { Hasher } from '@aztec/types/interfaces'; -import { SiblingPath } from '@aztec/types/membership'; import { BatchInsertionResult, IndexedTree, LowLeafWitnessData, PreimageFactory } from '../interfaces/indexed_tree.js'; import { IndexedTreeSnapshotBuilder } from '../snapshots/indexed_tree_snapshot.js'; 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 1e793daf656..6543283df8c 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,3 +1,4 @@ +import { SiblingPath } from '@aztec/circuit-types'; import { Fr, NullifierLeaf, @@ -8,7 +9,6 @@ import { import { toBufferBE } from '@aztec/foundation/bigint-buffer'; import { AztecKVStore, AztecLmdbStore } from '@aztec/kv-store'; import { Hasher } from '@aztec/types/interfaces'; -import { SiblingPath } from '@aztec/types/membership'; import { INITIAL_LEAF, MerkleTree, Pedersen, loadTree, newTree } from '../../index.js'; import { treeTestSuite } from '../../test/test_suite.js'; 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 bfd95e7b349..f970a9c89aa 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,6 +1,6 @@ +import { SiblingPath } from '@aztec/circuit-types'; import { AztecKVStore, AztecLmdbStore } from '@aztec/kv-store'; import { Hasher } from '@aztec/types/interfaces'; -import { SiblingPath } from '@aztec/types/membership'; import { randomBytes } from 'crypto'; diff --git a/yarn-project/merkle-tree/src/test/test_suite.ts b/yarn-project/merkle-tree/src/test/test_suite.ts index fd2d5b038fb..c7fdd51b103 100644 --- a/yarn-project/merkle-tree/src/test/test_suite.ts +++ b/yarn-project/merkle-tree/src/test/test_suite.ts @@ -1,6 +1,6 @@ +import { SiblingPath } from '@aztec/circuit-types'; import { AztecKVStore, AztecLmdbStore } from '@aztec/kv-store'; import { Hasher } from '@aztec/types/interfaces'; -import { SiblingPath } from '@aztec/types/membership'; import { Pedersen } from '../index.js'; import { AppendOnlyTree } from '../interfaces/append_only_tree.js'; diff --git a/yarn-project/merkle-tree/src/tree_base.ts b/yarn-project/merkle-tree/src/tree_base.ts index 972cdf19cc5..21baacdc041 100644 --- a/yarn-project/merkle-tree/src/tree_base.ts +++ b/yarn-project/merkle-tree/src/tree_base.ts @@ -1,8 +1,8 @@ +import { SiblingPath } from '@aztec/circuit-types'; import { toBigIntLE, toBufferLE } from '@aztec/foundation/bigint-buffer'; import { DebugLogger, createDebugLogger } from '@aztec/foundation/log'; import { AztecKVStore, AztecMap, AztecSingleton } from '@aztec/kv-store'; import { Hasher } from '@aztec/types/interfaces'; -import { SiblingPath } from '@aztec/types/membership'; import { HasherWithStats } from './hasher_with_stats.js'; import { MerkleTree } from './interfaces/merkle_tree.js'; diff --git a/yarn-project/pxe/src/simulator_oracle/index.ts b/yarn-project/pxe/src/simulator_oracle/index.ts index 6077752fdcb..57d53e21ad4 100644 --- a/yarn-project/pxe/src/simulator_oracle/index.ts +++ b/yarn-project/pxe/src/simulator_oracle/index.ts @@ -8,7 +8,15 @@ import { PublicDataWitness, StateInfoProvider, } from '@aztec/circuit-types'; -import { AztecAddress, CompleteAddress, EthAddress, Fr, FunctionSelector, Header } from '@aztec/circuits.js'; +import { + AztecAddress, + CompleteAddress, + EthAddress, + Fr, + FunctionSelector, + Header, + L1_TO_L2_MSG_TREE_HEIGHT, +} from '@aztec/circuits.js'; import { FunctionArtifactWithDebugMetadata } from '@aztec/foundation/abi'; import { createDebugLogger } from '@aztec/foundation/log'; @@ -118,12 +126,12 @@ export class SimulatorOracle implements DBOracle { * @returns A promise that resolves to the message data, a sibling path and the * index of the message in the l1ToL2MessageTree */ - async getL1ToL2Message(msgKey: Fr): Promise { + async getL1ToL2Message(msgKey: Fr): Promise> { const messageAndIndex = await this.stateInfoProvider.getL1ToL2MessageAndIndex(msgKey); - const message = messageAndIndex.message.toFieldArray(); + const message = messageAndIndex.message; const index = messageAndIndex.index; const siblingPath = await this.stateInfoProvider.getL1ToL2MessageSiblingPath('latest', index); - return new MessageLoadOracleInputs(message, index, siblingPath.toFieldArray()); + return new MessageLoadOracleInputs(message, index, siblingPath); } /** 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 5bb68a03ec3..89d30f0c393 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts @@ -3,6 +3,7 @@ import { ExtendedContractData, FunctionCall, FunctionL2Logs, + SiblingPath, SimulationError, Tx, TxL2Logs, @@ -35,7 +36,6 @@ import { } from '@aztec/circuits.js/factories'; import { makeTuple } from '@aztec/foundation/array'; import { padArrayEnd, times } 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/src/simulator/public_executor.ts b/yarn-project/sequencer-client/src/simulator/public_executor.ts index de082839ab0..7ee16c8e0bd 100644 --- a/yarn-project/sequencer-client/src/simulator/public_executor.ts +++ b/yarn-project/sequencer-client/src/simulator/public_executor.ts @@ -1,6 +1,13 @@ import { CommitmentsDB, MessageLoadOracleInputs, PublicContractsDB, PublicStateDB } from '@aztec/acir-simulator'; import { ContractDataSource, ExtendedContractData, L1ToL2MessageSource, MerkleTreeId, Tx } from '@aztec/circuit-types'; -import { AztecAddress, EthAddress, Fr, FunctionSelector, PublicDataTreeLeafPreimage } from '@aztec/circuits.js'; +import { + AztecAddress, + EthAddress, + Fr, + FunctionSelector, + L1_TO_L2_MSG_TREE_HEIGHT, + PublicDataTreeLeafPreimage, +} from '@aztec/circuits.js'; import { computePublicDataTreeLeafSlot } from '@aztec/circuits.js/abis'; import { MerkleTreeOperations } from '@aztec/world-state'; @@ -144,13 +151,16 @@ export class WorldStatePublicDB implements PublicStateDB { export class WorldStateDB implements CommitmentsDB { constructor(private db: MerkleTreeOperations, private l1ToL2MessageSource: L1ToL2MessageSource) {} - public async getL1ToL2Message(messageKey: Fr): Promise { + public async getL1ToL2Message(messageKey: Fr): Promise> { // todo: #697 - make this one lookup. const message = await this.l1ToL2MessageSource.getConfirmedL1ToL2Message(messageKey); const index = (await this.db.findLeafIndex(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, messageKey.toBuffer()))!; - const siblingPath = await this.db.getSiblingPath(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, index); + const siblingPath = await this.db.getSiblingPath( + MerkleTreeId.L1_TO_L2_MESSAGE_TREE, + index, + ); - return new MessageLoadOracleInputs(message.toFieldArray(), index, siblingPath.toFieldArray()); + return new MessageLoadOracleInputs(message, index, siblingPath); } public async getCommitmentIndex(commitment: Fr): Promise { diff --git a/yarn-project/types/src/index.ts b/yarn-project/types/src/index.ts index 6815c4130c4..a3df311a469 100644 --- a/yarn-project/types/src/index.ts +++ b/yarn-project/types/src/index.ts @@ -1,2 +1 @@ export * from './interfaces/index.js'; -export * from './sibling-path/index.js'; 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 8c0f0e23351..684e46a84a6 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,10 +1,9 @@ -import { L2Block, L2BlockSource, MerkleTreeId } from '@aztec/circuit-types'; +import { L2Block, L2BlockSource, MerkleTreeId, SiblingPath } from '@aztec/circuit-types'; import { Fr } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { sleep } from '@aztec/foundation/sleep'; import { AztecKVStore, AztecLmdbStore } from '@aztec/kv-store'; 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 8a59832253a..560906b4d69 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,8 @@ -import { L2Block, MerkleTreeId } from '@aztec/circuit-types'; +import { L2Block, MerkleTreeId, SiblingPath } from '@aztec/circuit-types'; import { Header, NullifierLeafPreimage, StateReference } from '@aztec/circuits.js'; 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 f36513f6e78..26c3cceb896 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,7 @@ -import { L2Block, MerkleTreeId } from '@aztec/circuit-types'; +import { L2Block, MerkleTreeId, SiblingPath } from '@aztec/circuit-types'; import { Header, NullifierLeafPreimage, StateReference } from '@aztec/circuits.js'; 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 { 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 79e7a01d16f..8c645dc6ca7 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,8 +1,7 @@ -import { MerkleTreeId } from '@aztec/circuit-types'; +import { MerkleTreeId, SiblingPath } from '@aztec/circuit-types'; import { AppendOnlyTreeSnapshot, Fr, Header, PartialStateReference, StateReference } 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 { 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 3a55636c273..102946f05b2 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 { L2Block, MerkleTreeId } from '@aztec/circuit-types'; +import { L2Block, MerkleTreeId, SiblingPath } from '@aztec/circuit-types'; import { ARCHIVE_HEIGHT, AppendOnlyTreeSnapshot, @@ -37,7 +37,6 @@ import { newTree, } from '@aztec/merkle-tree'; import { Hasher } from '@aztec/types/interfaces'; -import { SiblingPath } from '@aztec/types/membership'; import { INITIAL_NULLIFIER_TREE_SIZE, INITIAL_PUBLIC_DATA_TREE_SIZE, MerkleTreeDb } from './merkle_tree_db.js'; import { HandleL2BlockResult, IndexedTreeId, MerkleTreeOperations, TreeInfo } from './merkle_tree_operations.js';