Skip to content

Commit

Permalink
fixed naming
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Mar 21, 2024
1 parent 11cc0a7 commit 7feb37d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<HandleL2BlockResult> {
private async handleL2BlockAndMessages(
l2Block: L2Block,
l1ToL2Messages: Fr[],
): Promise<HandleL2BlockAndMessagesResult> {
// 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<HandleL2BlockResult>;
handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise<HandleL2BlockAndMessagesResult>;

/**
* Commits pending changes to the underlying store.
Expand All @@ -155,8 +155,8 @@ export interface MerkleTreeOperations {
rollback(): Promise<void>;
}

/** 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;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<HandleL2BlockResult> {
public handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise<HandleL2BlockAndMessagesResult> {
return this.trees.handleL2BlockAndMessages(block, l1ToL2Messages);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -130,7 +130,7 @@ export class MerkleTreeSnapshotOperationsFacade implements MerkleTreeOperations
return Promise.reject(new Error('Tree snapshot operations are read-only'));
}

handleL2BlockAndMessages(): Promise<HandleL2BlockResult> {
handleL2BlockAndMessages(): Promise<HandleL2BlockAndMessagesResult> {
return Promise.reject(new Error('Tree snapshot operations are read-only'));
}

Expand Down
11 changes: 8 additions & 3 deletions yarn-project/world-state/src/world-state-db/merkle_trees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -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<HandleL2BlockResult> {
public async handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise<HandleL2BlockAndMessagesResult> {
return await this.synchronize(() => this.#handleL2BlockAndMessages(block, l1ToL2Messages));
}

Expand Down Expand Up @@ -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<HandleL2BlockResult> {
async #handleL2BlockAndMessages(l2Block: L2Block, l1ToL2Messages: Fr[]): Promise<HandleL2BlockAndMessagesResult> {
const treeRootWithIdPairs = [
[l2Block.header.state.partial.nullifierTree.root, MerkleTreeId.NULLIFIER_TREE],
[l2Block.header.state.partial.noteHashTree.root, MerkleTreeId.NOTE_HASH_TREE],
Expand Down

0 comments on commit 7feb37d

Please sign in to comment.