Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Jan 24, 2024
1 parent fef1fbd commit 346f375
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
1 change: 1 addition & 0 deletions yarn-project/circuits.js/src/abis/abis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`);
}
}
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 346f375

Please sign in to comment.