diff --git a/yarn-project/aztec-node/src/aztec-node/aztec-node.ts b/yarn-project/aztec-node/src/aztec-node/aztec-node.ts index f6258e855c8..4cf78477af5 100644 --- a/yarn-project/aztec-node/src/aztec-node/aztec-node.ts +++ b/yarn-project/aztec-node/src/aztec-node/aztec-node.ts @@ -142,6 +142,6 @@ export class AztecNode { } public getDataTreePath(leafIndex: bigint): Promise { - return this.merkleTreeDB.getSiblingPath(MerkleTreeId.DATA_TREE, leafIndex, false); + return this.merkleTreeDB.getSiblingPath(MerkleTreeId.PRIVATE_DATA_TREE, leafIndex, false); } } diff --git a/yarn-project/sequencer-client/src/block_builder/circuit_block_builder.test.ts b/yarn-project/sequencer-client/src/block_builder/circuit_block_builder.test.ts index 982a73f1b7d..d54812c1d20 100644 --- a/yarn-project/sequencer-client/src/block_builder/circuit_block_builder.test.ts +++ b/yarn-project/sequencer-client/src/block_builder/circuit_block_builder.test.ts @@ -83,7 +83,7 @@ describe('sequencer/circuit_block_builder', () => { const updateRootTrees = async () => { for (const [newTree, rootTree] of [ - [MerkleTreeId.DATA_TREE, MerkleTreeId.DATA_TREE_ROOTS_TREE], + [MerkleTreeId.PRIVATE_DATA_TREE, MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE], [MerkleTreeId.CONTRACT_TREE, MerkleTreeId.CONTRACT_TREE_ROOTS_TREE], ] as const) { const newTreeInfo = await expectsDb.getTreeInfo(newTree); @@ -95,7 +95,7 @@ describe('sequencer/circuit_block_builder', () => { const updateExpectedTreesFromTxs = async (txs: PrivateTx[]) => { const newContracts = flatMap(txs, tx => tx.data.end.newContracts.map(n => computeContractLeaf(wasm, n))); for (const [tree, leaves] of [ - [MerkleTreeId.DATA_TREE, flatMap(txs, tx => tx.data.end.newCommitments.map(l => l.toBuffer()))], + [MerkleTreeId.PRIVATE_DATA_TREE, flatMap(txs, tx => tx.data.end.newCommitments.map(l => l.toBuffer()))], [MerkleTreeId.CONTRACT_TREE, newContracts.map(x => x.toBuffer())], [MerkleTreeId.NULLIFIER_TREE, flatMap(txs, tx => tx.data.end.newNullifiers.map(l => l.toBuffer()))], ] as const) { @@ -110,7 +110,7 @@ describe('sequencer/circuit_block_builder', () => { const setTxHistoricTreeRoots = async (tx: PrivateTx) => { for (const [name, id] of [ - ['privateDataTreeRoot', MerkleTreeId.DATA_TREE], + ['privateDataTreeRoot', MerkleTreeId.PRIVATE_DATA_TREE], ['contractTreeRoot', MerkleTreeId.CONTRACT_TREE], ['nullifierTreeRoot', MerkleTreeId.NULLIFIER_TREE], ] as const) { @@ -136,24 +136,24 @@ describe('sequencer/circuit_block_builder', () => { await updateExpectedTreesFromTxs(txsLeft); baseRollupOutputLeft.endContractTreeSnapshot = await getTreeSnapshot(MerkleTreeId.CONTRACT_TREE); baseRollupOutputLeft.endNullifierTreeSnapshot = await getTreeSnapshot(MerkleTreeId.NULLIFIER_TREE); - baseRollupOutputLeft.endPrivateDataTreeSnapshot = await getTreeSnapshot(MerkleTreeId.DATA_TREE); + baseRollupOutputLeft.endPrivateDataTreeSnapshot = await getTreeSnapshot(MerkleTreeId.PRIVATE_DATA_TREE); // Same for the two txs on the right await updateExpectedTreesFromTxs(txsRight); baseRollupOutputRight.endContractTreeSnapshot = await getTreeSnapshot(MerkleTreeId.CONTRACT_TREE); baseRollupOutputRight.endNullifierTreeSnapshot = await getTreeSnapshot(MerkleTreeId.NULLIFIER_TREE); - baseRollupOutputRight.endPrivateDataTreeSnapshot = await getTreeSnapshot(MerkleTreeId.DATA_TREE); + baseRollupOutputRight.endPrivateDataTreeSnapshot = await getTreeSnapshot(MerkleTreeId.PRIVATE_DATA_TREE); // And update the root trees now to create proper output to the root rollup circuit await updateRootTrees(); rootRollupOutput.endContractTreeSnapshot = await getTreeSnapshot(MerkleTreeId.CONTRACT_TREE); rootRollupOutput.endNullifierTreeSnapshot = await getTreeSnapshot(MerkleTreeId.NULLIFIER_TREE); - rootRollupOutput.endPrivateDataTreeSnapshot = await getTreeSnapshot(MerkleTreeId.DATA_TREE); + rootRollupOutput.endPrivateDataTreeSnapshot = await getTreeSnapshot(MerkleTreeId.PRIVATE_DATA_TREE); rootRollupOutput.endTreeOfHistoricContractTreeRootsSnapshot = await getTreeSnapshot( MerkleTreeId.CONTRACT_TREE_ROOTS_TREE, ); rootRollupOutput.endTreeOfHistoricPrivateDataTreeRootsSnapshot = await getTreeSnapshot( - MerkleTreeId.DATA_TREE_ROOTS_TREE, + MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE, ); // Actually build a block! diff --git a/yarn-project/sequencer-client/src/block_builder/circuit_block_builder.ts b/yarn-project/sequencer-client/src/block_builder/circuit_block_builder.ts index 803b99ac52f..8eb3f00d89e 100644 --- a/yarn-project/sequencer-client/src/block_builder/circuit_block_builder.ts +++ b/yarn-project/sequencer-client/src/block_builder/circuit_block_builder.ts @@ -91,10 +91,10 @@ export class CircuitBlockBuilder implements BlockBuilder { startTreeOfHistoricContractTreeRootsSnapshot, ] = await Promise.all( [ - MerkleTreeId.DATA_TREE, + MerkleTreeId.PRIVATE_DATA_TREE, MerkleTreeId.NULLIFIER_TREE, MerkleTreeId.CONTRACT_TREE, - MerkleTreeId.DATA_TREE_ROOTS_TREE, + MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE, MerkleTreeId.CONTRACT_TREE_ROOTS_TREE, ].map(tree => this.getTreeSnapshot(tree)), ); @@ -235,7 +235,7 @@ export class CircuitBlockBuilder implements BlockBuilder { // Updates our roots trees with the new generated trees after the rollup updates protected async updateRootTrees() { for (const [newTree, rootTree] of [ - [MerkleTreeId.DATA_TREE, MerkleTreeId.DATA_TREE_ROOTS_TREE], + [MerkleTreeId.PRIVATE_DATA_TREE, MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE], [MerkleTreeId.CONTRACT_TREE, MerkleTreeId.CONTRACT_TREE_ROOTS_TREE], ] as const) { const newTreeInfo = await this.db.getTreeInfo(newTree); @@ -247,7 +247,7 @@ export class CircuitBlockBuilder implements BlockBuilder { protected async validateTrees(rollupOutput: BaseOrMergeRollupPublicInputs | RootRollupPublicInputs) { await Promise.all([ this.validateTree(rollupOutput, MerkleTreeId.CONTRACT_TREE, 'Contract'), - this.validateTree(rollupOutput, MerkleTreeId.DATA_TREE, 'PrivateData'), + this.validateTree(rollupOutput, MerkleTreeId.PRIVATE_DATA_TREE, 'PrivateData'), this.validateTree(rollupOutput, MerkleTreeId.NULLIFIER_TREE, 'Nullifier'), ]); } @@ -257,7 +257,7 @@ export class CircuitBlockBuilder implements BlockBuilder { await Promise.all([ this.validateTrees(rootOutput), this.validateRootTree(rootOutput, MerkleTreeId.CONTRACT_TREE_ROOTS_TREE, 'Contract'), - this.validateRootTree(rootOutput, MerkleTreeId.DATA_TREE_ROOTS_TREE, 'PrivateData'), + this.validateRootTree(rootOutput, MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE, 'PrivateData'), ]); } @@ -326,7 +326,9 @@ export class CircuitBlockBuilder implements BlockBuilder { const newHistoricContractDataTreeRootSiblingPath = await getRootTreeSiblingPath( MerkleTreeId.CONTRACT_TREE_ROOTS_TREE, ); - const newHistoricPrivateDataTreeRootSiblingPath = await getRootTreeSiblingPath(MerkleTreeId.DATA_TREE_ROOTS_TREE); + const newHistoricPrivateDataTreeRootSiblingPath = await getRootTreeSiblingPath( + MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE, + ); return RootRollupInputs.from({ previousRollupData, @@ -398,7 +400,7 @@ export class CircuitBlockBuilder implements BlockBuilder { protected getDataMembershipWitnessFor(tx: PrivateTx) { return this.getMembershipWitnessFor( tx.data.constants.historicTreeRoots.privateDataTreeRoot, - MerkleTreeId.DATA_TREE_ROOTS_TREE, + MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE, PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT, ); } @@ -410,7 +412,9 @@ export class CircuitBlockBuilder implements BlockBuilder { privateKernelVkTreeRoot: FUTURE_FR, publicKernelVkTreeRoot: FUTURE_FR, startTreeOfHistoricContractTreeRootsSnapshot: await this.getTreeSnapshot(MerkleTreeId.CONTRACT_TREE_ROOTS_TREE), - startTreeOfHistoricPrivateDataTreeRootsSnapshot: await this.getTreeSnapshot(MerkleTreeId.DATA_TREE_ROOTS_TREE), + startTreeOfHistoricPrivateDataTreeRootsSnapshot: await this.getTreeSnapshot( + MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE, + ), treeOfHistoricL1ToL2MsgTreeRootsSnapshot: new AppendOnlyTreeSnapshot(DELETE_FR, DELETE_NUM), }); } @@ -685,7 +689,7 @@ export class CircuitBlockBuilder implements BlockBuilder { const constants = await this.getConstantBaseRollupData(); const startNullifierTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.NULLIFIER_TREE); const startContractTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.CONTRACT_TREE); - const startPrivateDataTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.DATA_TREE); + const startPrivateDataTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.PRIVATE_DATA_TREE); // Update the contract and data trees with the new items being inserted to get the new roots // that will be used by the next iteration of the base rollup circuit, skipping the empty ones @@ -697,7 +701,7 @@ export class CircuitBlockBuilder implements BlockBuilder { newContracts.map(x => x.toBuffer()), ); - await this.db.appendLeaves(MerkleTreeId.DATA_TREE, newCommitments); + await this.db.appendLeaves(MerkleTreeId.PRIVATE_DATA_TREE, newCommitments); // Update the nullifier tree, capturing the low nullifier info for each individual operation const newNullifiers = [...tx1.data.end.newNullifiers, ...tx2.data.end.newNullifiers]; @@ -713,7 +717,7 @@ export class CircuitBlockBuilder implements BlockBuilder { // Get the subtree sibling paths for the circuit const newCommitmentsSubtreeSiblingPath = await this.getSubtreeSiblingPath( - MerkleTreeId.DATA_TREE, + MerkleTreeId.PRIVATE_DATA_TREE, BaseRollupInputs.PRIVATE_DATA_SUBTREE_HEIGHT, ); const newContractsSubtreeSiblingPath = await this.getSubtreeSiblingPath( diff --git a/yarn-project/sequencer-client/src/block_builder/standalone_block_builder.ts b/yarn-project/sequencer-client/src/block_builder/standalone_block_builder.ts index 2a7d4400be0..1fca04dd540 100644 --- a/yarn-project/sequencer-client/src/block_builder/standalone_block_builder.ts +++ b/yarn-project/sequencer-client/src/block_builder/standalone_block_builder.ts @@ -31,11 +31,11 @@ export class StandaloneBlockBuilder implements BlockBuilder { constructor(private db: MerkleTreeOperations, private log = createDebugLogger('aztec:block_builder')) {} async buildL2Block(blockNumber: number, txs: PrivateTx[]): Promise<[L2Block, Proof]> { - const startPrivateDataTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.DATA_TREE); + const startPrivateDataTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.PRIVATE_DATA_TREE); const startNullifierTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.NULLIFIER_TREE); const startContractTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.CONTRACT_TREE); const startTreeOfHistoricPrivateDataTreeRootsSnapshot = await this.getTreeSnapshot( - MerkleTreeId.DATA_TREE_ROOTS_TREE, + MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE, ); const startTreeOfHistoricContractTreeRootsSnapshot = await this.getTreeSnapshot( MerkleTreeId.CONTRACT_TREE_ROOTS_TREE, @@ -47,10 +47,12 @@ export class StandaloneBlockBuilder implements BlockBuilder { await this.updateRootTrees(); - const endPrivateDataTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.DATA_TREE); + const endPrivateDataTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.PRIVATE_DATA_TREE); const endNullifierTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.NULLIFIER_TREE); const endContractTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.CONTRACT_TREE); - const endTreeOfHistoricPrivateDataTreeRootsSnapshot = await this.getTreeSnapshot(MerkleTreeId.DATA_TREE_ROOTS_TREE); + const endTreeOfHistoricPrivateDataTreeRootsSnapshot = await this.getTreeSnapshot( + MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE, + ); const endTreeOfHistoricContractTreeRootsSnapshot = await this.getTreeSnapshot( MerkleTreeId.CONTRACT_TREE_ROOTS_TREE, ); @@ -89,7 +91,7 @@ export class StandaloneBlockBuilder implements BlockBuilder { ); for (let i = 0; i < KERNEL_NEW_COMMITMENTS_LENGTH; i++) { - await this.db.appendLeaves(MerkleTreeId.DATA_TREE, [dataTreeLeaves[i]]); + await this.db.appendLeaves(MerkleTreeId.PRIVATE_DATA_TREE, [dataTreeLeaves[i]]); } for (let i = 0; i < KERNEL_NEW_NULLIFIERS_LENGTH; i++) { await this.db.appendLeaves(MerkleTreeId.NULLIFIER_TREE, [nullifierTreeLeaves[i]]); @@ -100,9 +102,9 @@ export class StandaloneBlockBuilder implements BlockBuilder { } private async updateRootTrees() { - const newDataTreeInfo = await this.getTreeSnapshot(MerkleTreeId.DATA_TREE); + const newDataTreeInfo = await this.getTreeSnapshot(MerkleTreeId.PRIVATE_DATA_TREE); const newContractsTreeInfo = await this.getTreeSnapshot(MerkleTreeId.CONTRACT_TREE); await this.db.appendLeaves(MerkleTreeId.CONTRACT_TREE_ROOTS_TREE, [newContractsTreeInfo.root.toBuffer()]); - await this.db.appendLeaves(MerkleTreeId.DATA_TREE_ROOTS_TREE, [newDataTreeInfo.root.toBuffer()]); + await this.db.appendLeaves(MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE, [newDataTreeInfo.root.toBuffer()]); } } diff --git a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.ts b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.ts index cb55070587f..bdc57ce53d5 100644 --- a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.ts +++ b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.ts @@ -126,14 +126,14 @@ export class ServerWorldStateSynchroniser implements WorldStateSynchroniser { const rootChecks = await Promise.all([ compareRoot(l2Block.endContractTreeSnapshot.root.toBuffer(), MerkleTreeId.CONTRACT_TREE), compareRoot(l2Block.endNullifierTreeSnapshot.root.toBuffer(), MerkleTreeId.NULLIFIER_TREE), - compareRoot(l2Block.endPrivateDataTreeSnapshot.root.toBuffer(), MerkleTreeId.DATA_TREE), + compareRoot(l2Block.endPrivateDataTreeSnapshot.root.toBuffer(), MerkleTreeId.PRIVATE_DATA_TREE), compareRoot( l2Block.endTreeOfHistoricContractTreeRootsSnapshot.root.toBuffer(), MerkleTreeId.CONTRACT_TREE_ROOTS_TREE, ), compareRoot( l2Block.endTreeOfHistoricPrivateDataTreeRootsSnapshot.root.toBuffer(), - MerkleTreeId.DATA_TREE_ROOTS_TREE, + MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE, ), ]); const ourBlock = rootChecks.every(x => x); @@ -147,7 +147,7 @@ export class ServerWorldStateSynchroniser implements WorldStateSynchroniser { for (const [tree, leaves] of [ [MerkleTreeId.CONTRACT_TREE, l2Block.newContracts], [MerkleTreeId.NULLIFIER_TREE, l2Block.newNullifiers], - [MerkleTreeId.DATA_TREE, l2Block.newCommitments], + [MerkleTreeId.PRIVATE_DATA_TREE, l2Block.newCommitments], ] as const) { await this.merkleTreeDb.appendLeaves( tree, @@ -156,7 +156,7 @@ export class ServerWorldStateSynchroniser implements WorldStateSynchroniser { } for (const [newTree, rootTree] of [ - [MerkleTreeId.DATA_TREE, MerkleTreeId.DATA_TREE_ROOTS_TREE], + [MerkleTreeId.PRIVATE_DATA_TREE, MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE], [MerkleTreeId.CONTRACT_TREE, MerkleTreeId.CONTRACT_TREE_ROOTS_TREE], ] as const) { const newTreeInfo = await this.merkleTreeDb.getTreeInfo(newTree, true); diff --git a/yarn-project/world-state/src/world-state-db/index.ts b/yarn-project/world-state/src/world-state-db/index.ts index 6dddfdd8024..ec634207215 100644 --- a/yarn-project/world-state/src/world-state-db/index.ts +++ b/yarn-project/world-state/src/world-state-db/index.ts @@ -10,8 +10,8 @@ export enum MerkleTreeId { CONTRACT_TREE = 0, CONTRACT_TREE_ROOTS_TREE = 1, NULLIFIER_TREE = 2, - DATA_TREE = 3, - DATA_TREE_ROOTS_TREE = 4, + PRIVATE_DATA_TREE = 3, + PRIVATE_DATA_TREE_ROOTS_TREE = 4, PUBLIC_DATA_TREE = 5, } 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 96223951994..9814b377c99 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 @@ -74,14 +74,14 @@ export class MerkleTrees implements MerkleTreeDb { StandardTree, this.db, hasher, - `${MerkleTreeId[MerkleTreeId.DATA_TREE]}`, + `${MerkleTreeId[MerkleTreeId.PRIVATE_DATA_TREE]}`, PRIVATE_DATA_TREE_HEIGHT, ); const privateDataTreeRootsTree: AppendOnlyTree = await newTree( StandardTree, this.db, hasher, - `${MerkleTreeId[MerkleTreeId.DATA_TREE_ROOTS_TREE]}`, + `${MerkleTreeId[MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE]}`, PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT, ); const publicDataTree: UpdateOnlyTree = await newTree(