From 7feb37db571dcaf1ce3a43745143c648b08abade Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 21 Mar 2024 09:51:26 +0000 Subject: [PATCH] fixed naming --- .../synchronizer/server_world_state_synchronizer.ts | 8 ++++++-- .../src/world-state-db/merkle_tree_operations.ts | 6 +++--- .../world-state-db/merkle_tree_operations_facade.ts | 4 ++-- .../merkle_tree_snapshot_operations_facade.ts | 4 ++-- .../world-state/src/world-state-db/merkle_trees.ts | 11 ++++++++--- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.ts b/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.ts index f4e0186ec95..6a43188d8f1 100644 --- a/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.ts +++ b/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.ts @@ -9,7 +9,7 @@ import { AztecKVStore, AztecSingleton } from '@aztec/kv-store'; import { openTmpStore } from '@aztec/kv-store/utils'; import { SHA256, StandardTree } from '@aztec/merkle-tree'; -import { HandleL2BlockResult, MerkleTreeOperations, MerkleTrees } from '../world-state-db/index.js'; +import { HandleL2BlockAndMessagesResult, MerkleTreeOperations, MerkleTrees } from '../world-state-db/index.js'; import { MerkleTreeOperationsFacade } from '../world-state-db/merkle_tree_operations_facade.js'; import { MerkleTreeSnapshotOperationsFacade } from '../world-state-db/merkle_tree_snapshot_operations_facade.js'; import { WorldStateConfig } from './config.js'; @@ -199,8 +199,12 @@ export class ServerWorldStateSynchronizer implements WorldStateSynchronizer { * Handles a single L2 block (i.e. Inserts the new note hashes into the merkle tree). * @param l2Block - The L2 block to handle. * @param l1ToL2Messages - The L1 to L2 messages for the block. + * @returns Whether the block handled was produced by this same node. */ - private async handleL2BlockAndMessages(l2Block: L2Block, l1ToL2Messages: Fr[]): Promise { + private async handleL2BlockAndMessages( + l2Block: L2Block, + l1ToL2Messages: Fr[], + ): Promise { // First we check that the L1 to L2 messages hash to the block inHash. // Note that we cannot optimize this check by checking the root of the subtree after inserting the messages // to the real L1_TO_L2_MESSAGE_TREE (like we do in merkleTreeDb.handleL2BlockAndMessages(...)) because that 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 2feda9e9d17..e317aa25e67 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 @@ -142,7 +142,7 @@ export interface MerkleTreeOperations { * @param block - The L2 block to handle. * @param l1ToL2Messages - The L1 to L2 messages for the block. */ - handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise; + handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise; /** * Commits pending changes to the underlying store. @@ -155,8 +155,8 @@ export interface MerkleTreeOperations { rollback(): Promise; } -/** Return type for handleL2Block */ -export type HandleL2BlockResult = { +/** Return type for handleL2BlockAndMessages */ +export type HandleL2BlockAndMessagesResult = { /** Whether the block processed was emitted by our sequencer */ isBlockOurs: boolean; }; 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 a0357e885c3..5e32cc757f0 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 @@ -4,7 +4,7 @@ import { IndexedTreeLeafPreimage } from '@aztec/foundation/trees'; import { BatchInsertionResult } from '@aztec/merkle-tree'; import { MerkleTreeDb } from './merkle_tree_db.js'; -import { HandleL2BlockResult, MerkleTreeOperations, TreeInfo } from './merkle_tree_operations.js'; +import { HandleL2BlockAndMessagesResult, MerkleTreeOperations, TreeInfo } from './merkle_tree_operations.js'; /** * Wraps a MerkleTreeDbOperations to call all functions with a preset includeUncommitted flag. @@ -146,7 +146,7 @@ export class MerkleTreeOperationsFacade implements MerkleTreeOperations { * @param l1ToL2Messages - The L1 to L2 messages for the block. * @returns Whether the block handled was produced by this same node. */ - public handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise { + public handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise { return this.trees.handleL2BlockAndMessages(block, l1ToL2Messages); } 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 f82efd68650..144ee20e29c 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 @@ -4,7 +4,7 @@ import { IndexedTreeLeafPreimage } from '@aztec/foundation/trees'; import { BatchInsertionResult, IndexedTreeSnapshot, TreeSnapshot } from '@aztec/merkle-tree'; import { MerkleTreeDb } from './merkle_tree_db.js'; -import { HandleL2BlockResult, MerkleTreeOperations, TreeInfo } from './merkle_tree_operations.js'; +import { HandleL2BlockAndMessagesResult, MerkleTreeOperations, TreeInfo } from './merkle_tree_operations.js'; /** * Merkle tree operations on readonly tree snapshots. @@ -130,7 +130,7 @@ export class MerkleTreeSnapshotOperationsFacade implements MerkleTreeOperations return Promise.reject(new Error('Tree snapshot operations are read-only')); } - handleL2BlockAndMessages(): Promise { + handleL2BlockAndMessages(): Promise { return Promise.reject(new Error('Tree snapshot operations are read-only')); } 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 f783dab4cd8..aa37afcf4f4 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 @@ -39,7 +39,12 @@ import { import { Hasher } from '@aztec/types/interfaces'; 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'; +import { + HandleL2BlockAndMessagesResult, + IndexedTreeId, + MerkleTreeOperations, + TreeInfo, +} from './merkle_tree_operations.js'; import { MerkleTreeOperationsFacade } from './merkle_tree_operations_facade.js'; /** @@ -349,7 +354,7 @@ export class MerkleTrees implements MerkleTreeDb { * @param l1ToL2Messages - The L1 to L2 messages for the block. * @returns Whether the block handled was produced by this same node. */ - public async handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise { + public async handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise { return await this.synchronize(() => this.#handleL2BlockAndMessages(block, l1ToL2Messages)); } @@ -480,7 +485,7 @@ export class MerkleTrees implements MerkleTreeDb { * @param l2Block - The L2 block to handle. * @param l1ToL2Messages - The L1 to L2 messages for the block. */ - async #handleL2BlockAndMessages(l2Block: L2Block, l1ToL2Messages: Fr[]): Promise { + async #handleL2BlockAndMessages(l2Block: L2Block, l1ToL2Messages: Fr[]): Promise { const treeRootWithIdPairs = [ [l2Block.header.state.partial.nullifierTree.root, MerkleTreeId.NULLIFIER_TREE], [l2Block.header.state.partial.noteHashTree.root, MerkleTreeId.NOTE_HASH_TREE],