diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index cc851ee4258..8ba10d55298 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -327,7 +327,7 @@ export class AztecNodeService implements AztecNode { * @returns The index of the given leaf in the given tree or undefined if not found. */ public async findLeafIndex( - blockNumber: number | 'latest', + blockNumber: BlockNumber, treeId: MerkleTreeId, leafValue: Fr, ): Promise { @@ -342,7 +342,7 @@ export class AztecNodeService implements AztecNode { * @returns The sibling path for the leaf index. */ public async getNullifierSiblingPath( - blockNumber: number | 'latest', + blockNumber: BlockNumber, leafIndex: bigint, ): Promise> { const committedDb = await this.#getWorldState(blockNumber); @@ -356,7 +356,7 @@ export class AztecNodeService implements AztecNode { * @returns The sibling path for the leaf index. */ public async getNoteHashSiblingPath( - blockNumber: number | 'latest', + blockNumber: BlockNumber, leafIndex: bigint, ): Promise> { const committedDb = await this.#getWorldState(blockNumber); @@ -393,7 +393,7 @@ export class AztecNodeService implements AztecNode { * @returns A tuple of the index and the sibling path of the L2ToL1Message. */ public async getL2ToL1MessageIndexAndSiblingPath( - blockNumber: number | 'latest', + blockNumber: BlockNumber, l2ToL1Message: Fr, ): Promise<[number, SiblingPath]> { const block = await this.blockSource.getBlock(blockNumber === 'latest' ? await this.getBlockNumber() : blockNumber); @@ -431,7 +431,7 @@ export class AztecNodeService implements AztecNode { * @returns The sibling path. */ public async getArchiveSiblingPath( - blockNumber: number | 'latest', + blockNumber: BlockNumber, leafIndex: bigint, ): Promise> { const committedDb = await this.#getWorldState(blockNumber); @@ -445,7 +445,7 @@ export class AztecNodeService implements AztecNode { * @returns The sibling path. */ public async getPublicDataSiblingPath( - blockNumber: number | 'latest', + blockNumber: BlockNumber, leafIndex: bigint, ): Promise> { const committedDb = await this.#getWorldState(blockNumber); @@ -459,7 +459,7 @@ export class AztecNodeService implements AztecNode { * @returns The nullifier membership witness (if found). */ public async getNullifierMembershipWitness( - blockNumber: number | 'latest', + blockNumber: BlockNumber, nullifier: Fr, ): Promise { const db = await this.#getWorldState(blockNumber); @@ -498,7 +498,7 @@ export class AztecNodeService implements AztecNode { * TODO: This is a confusing behavior and we should eventually address that. */ public async getLowNullifierMembershipWitness( - blockNumber: number | 'latest', + blockNumber: BlockNumber, nullifier: Fr, ): Promise { const committedDb = await this.#getWorldState(blockNumber); @@ -519,7 +519,7 @@ export class AztecNodeService implements AztecNode { return new NullifierMembershipWitness(BigInt(index), preimageData as NullifierLeafPreimage, siblingPath); } - async getPublicDataTreeWitness(blockNumber: number | 'latest', leafSlot: Fr): Promise { + async getPublicDataTreeWitness(blockNumber: BlockNumber, leafSlot: Fr): Promise { const committedDb = await this.#getWorldState(blockNumber); const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt()); if (!lowLeafResult) { @@ -631,7 +631,7 @@ export class AztecNodeService implements AztecNode { * @param blockNumber - The block number at which to get the data. * @returns An instance of a committed MerkleTreeOperations */ - async #getWorldState(blockNumber: number | 'latest') { + async #getWorldState(blockNumber: BlockNumber) { if (typeof blockNumber === 'number' && blockNumber < INITIAL_L2_BLOCK_NUM) { throw new Error('Invalid block number to get world state for: ' + blockNumber); } diff --git a/yarn-project/circuit-types/src/interfaces/aztec-node.ts b/yarn-project/circuit-types/src/interfaces/aztec-node.ts index dffadd90541..2d25ab3a0b8 100644 --- a/yarn-project/circuit-types/src/interfaces/aztec-node.ts +++ b/yarn-project/circuit-types/src/interfaces/aztec-node.ts @@ -17,13 +17,11 @@ import { MerkleTreeId } from '../merkle_tree_id.js'; import { SiblingPath } from '../sibling_path/index.js'; import { Tx, TxHash, TxReceipt } from '../tx/index.js'; import { TxEffect } from '../tx_effect.js'; +import { BlockNumber } from './block_number.js'; import { SequencerConfig } from './configs.js'; import { NullifierMembershipWitness } from './nullifier_tree.js'; import { PublicDataWitness } from './public_data_tree.js'; -/** Helper type for a specific L2 block number or the latest block number */ -export type BlockNumber = number | 'latest'; - /** * The aztec node. * We will probably implement the additional interfaces by means other than Aztec Node as it's currently a privacy leak diff --git a/yarn-project/circuit-types/src/interfaces/block_number.ts b/yarn-project/circuit-types/src/interfaces/block_number.ts new file mode 100644 index 00000000000..aaf0c954d66 --- /dev/null +++ b/yarn-project/circuit-types/src/interfaces/block_number.ts @@ -0,0 +1,2 @@ +/** Helper type for a specific L2 block number or the latest block number */ +export type BlockNumber = number | 'latest'; diff --git a/yarn-project/circuit-types/src/interfaces/index.ts b/yarn-project/circuit-types/src/interfaces/index.ts index f12dff9dfcd..9ec6483a806 100644 --- a/yarn-project/circuit-types/src/interfaces/index.ts +++ b/yarn-project/circuit-types/src/interfaces/index.ts @@ -1,4 +1,5 @@ export * from './aztec-node.js'; +export * from './block_number.js'; export * from './pxe.js'; export * from './deployed-contract.js'; export * from './sync-status.js';