From 05d94904ab8cd1848dc36924a633799df6bbb026 Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 6 Nov 2023 08:50:59 +0000 Subject: [PATCH] fix --- yarn-project/types/src/l2_block.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/yarn-project/types/src/l2_block.ts b/yarn-project/types/src/l2_block.ts index 8df578bd6d0..f144e0ed148 100644 --- a/yarn-project/types/src/l2_block.ts +++ b/yarn-project/types/src/l2_block.ts @@ -151,7 +151,14 @@ export class L2Block { this.attachLogs(newUnencryptedLogs, LogType.UNENCRYPTED); } - this.numberOfTxs = Math.floor(this.newCommitments.length / MAX_NEW_COMMITMENTS_PER_TX); + // Since the block is padded to always contain a fixed number of nullifiers we get number of txs by counting number + // of non-zero tx hashes --> tx hash is set to be the first nullifier in the tx. + this.numberOfTxs = 0; + for (let i = 0; i < this.newNullifiers.length; i += MAX_NEW_NULLIFIERS_PER_TX) { + if (!this.newNullifiers[i].equals(Fr.zero())) { + this.numberOfTxs++; + } + } } /** @@ -711,6 +718,7 @@ export class L2Block { const newNullifiers = this.newNullifiers .slice(MAX_NEW_NULLIFIERS_PER_TX * txIndex, MAX_NEW_NULLIFIERS_PER_TX * (txIndex + 1)) .filter(x => !x.isZero()); + console.log('newNullifiers', newNullifiers); const newPublicDataWrites = this.newPublicDataWrites .slice(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * txIndex, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * (txIndex + 1)) .filter(x => !x.isEmpty()); @@ -738,7 +746,7 @@ export class L2Block { /** * Get all the transaction in an L2 block. - * @returns The txx. + * @returns The tx. */ getTxs() { return Array(this.numberOfTxs)