From 346f3757bd4e1a56b25c8bd20f350ba78c8b635a Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 23 Jan 2024 15:59:18 +0000 Subject: [PATCH] WIP --- yarn-project/circuits.js/src/abis/abis.ts | 1 + .../src/block_builder/solo_block_builder.ts | 31 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/yarn-project/circuits.js/src/abis/abis.ts b/yarn-project/circuits.js/src/abis/abis.ts index dbf33e8e589e..7b08d311179a 100644 --- a/yarn-project/circuits.js/src/abis/abis.ts +++ b/yarn-project/circuits.js/src/abis/abis.ts @@ -308,6 +308,7 @@ export function computeBlockHashWithGlobals( * @param publicDataTreeRoot - The root of the public data tree. * @returns The block hash. */ +// TODO: nuke this and replace with `Header.hash()` export function computeBlockHash( globalsHash: Fr, noteHashTreeRoot: Fr, diff --git a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts index 6bb06f5c28b1..8a1bd311bd82 100644 --- a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts +++ b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts @@ -157,15 +157,15 @@ export class SoloBlockBuilder implements BlockBuilder { protected validateTxs(txs: ProcessedTx[]) { for (const tx of txs) { - for (const historicalTreeRoot of [ - 'noteHashTreeRoot', - 'contractTreeRoot', - 'nullifierTreeRoot', - 'l1ToL2MessageTreeRoot', - ] as const) { - if (tx.data.constants.header[historicalTreeRoot].isZero()) { - throw new Error(`Empty ${historicalTreeRoot} for tx: ${toFriendlyJSON(tx)}`); - } + const txHeader = tx.data.constants.header; + if ( + txHeader.state.l1ToL2MessageTree.isEmpty() || + txHeader.state.partial.noteHashTree.isEmpty() || + txHeader.state.partial.nullifierTree.isEmpty() || + txHeader.state.partial.contractTree.isEmpty() || + txHeader.state.partial.publicDataTree.isEmpty() + ) { + throw new Error(`Empty tree in tx: ${toFriendlyJSON(tx)}`); } } } @@ -487,14 +487,13 @@ export class SoloBlockBuilder implements BlockBuilder { protected getHistoricalTreesMembershipWitnessFor(tx: ProcessedTx) { const header = tx.data.constants.header; - const { noteHashTreeRoot, nullifierTreeRoot, contractTreeRoot, l1ToL2MessageTreeRoot, publicDataTreeRoot } = header; const blockHash = computeBlockHash( - header.globalVariablesHash, - noteHashTreeRoot, - nullifierTreeRoot, - contractTreeRoot, - l1ToL2MessageTreeRoot, - publicDataTreeRoot, + computeGlobalsHash(header.globalVariables), + header.state.partial.noteHashTree.root, + header.state.partial.nullifierTree.root, + header.state.partial.contractTree.root, + header.state.l1ToL2MessageTree.root, + header.state.partial.publicDataTree.root, ); return this.getMembershipWitnessFor(blockHash, MerkleTreeId.ARCHIVE, ARCHIVE_HEIGHT); }