Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Nov 6, 2023
1 parent 42e8661 commit 05d9490
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions yarn-project/types/src/l2_block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
}

/**
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 05d9490

Please sign in to comment.