diff --git a/docs/docs/migration_notes.md b/docs/docs/migration_notes.md index 9bc471aa1d5..90e2994bc43 100644 --- a/docs/docs/migration_notes.md +++ b/docs/docs/migration_notes.md @@ -8,6 +8,14 @@ Aztec is in full-speed development. Literally every version breaks compatibility ## TBD +### [Aztec.js] Removed `L2Block.fromFields` +`L2Block.fromFields` was a syntactic sugar which is causing [issues](https://github.com/AztecProtocol/aztec-packages/issues/8340) so we've removed it. + +```diff +-const l2Block = L2Block.fromFields({ header, archive, body }); ++const l2Block = new L2Block(archive, header, body); +``` + ### [Aztec.nr] Removed `SharedMutablePrivateGetter` This state variable was deleted due to it being difficult to use safely. diff --git a/yarn-project/archiver/src/archiver/kv_archiver_store/block_store.ts b/yarn-project/archiver/src/archiver/kv_archiver_store/block_store.ts index 42701f53d14..7c650c0e1d2 100644 --- a/yarn-project/archiver/src/archiver/kv_archiver_store/block_store.ts +++ b/yarn-project/archiver/src/archiver/kv_archiver_store/block_store.ts @@ -149,7 +149,7 @@ export class BlockStore { } const body = Body.fromBuffer(blockBodyBuffer); - const l2Block = L2Block.fromFields({ header, archive, body }); + const l2Block = new L2Block(archive, header, body); return { data: l2Block, l1: blockStorage.l1 }; } diff --git a/yarn-project/circuit-types/src/l2_block.ts b/yarn-project/circuit-types/src/l2_block.ts index 0fa89491bae..092b3fdf2de 100644 --- a/yarn-project/circuit-types/src/l2_block.ts +++ b/yarn-project/circuit-types/src/l2_block.ts @@ -19,21 +19,6 @@ export class L2Block { public body: Body, ) {} - /** - * Constructs a new instance from named fields. - * @param fields - Fields to pass to the constructor. - * @returns A new instance. - */ - static fromFields(fields: { - /** Snapshot of archive tree after the block is applied. */ - archive: AppendOnlyTreeSnapshot; - /** L2 block header. */ - header: Header; - body: Body; - }) { - return new this(fields.archive, fields.header, fields.body); - } - /** * Deserializes a block from a buffer * @returns A deserialized L2 block. @@ -44,11 +29,7 @@ export class L2Block { const archive = reader.readObject(AppendOnlyTreeSnapshot); const body = reader.readObject(Body); - return L2Block.fromFields({ - archive, - header, - body, - }); + return new L2Block(archive, header, body); } /** @@ -107,11 +88,11 @@ export class L2Block { const txsEffectsHash = body.getTxsEffectsHash(); - return L2Block.fromFields({ - archive: makeAppendOnlyTreeSnapshot(l2BlockNum + 1), - header: makeHeader(0, l2BlockNum, slotNumber ?? l2BlockNum, txsEffectsHash, inHash), + return new L2Block( + makeAppendOnlyTreeSnapshot(l2BlockNum + 1), + makeHeader(0, l2BlockNum, slotNumber ?? l2BlockNum, txsEffectsHash, inHash), body, - }); + ); } /** @@ -119,11 +100,7 @@ export class L2Block { * @returns The L2 block. */ static empty(): L2Block { - return L2Block.fromFields({ - archive: AppendOnlyTreeSnapshot.zero(), - header: Header.empty(), - body: Body.empty(), - }); + return new L2Block(AppendOnlyTreeSnapshot.zero(), Header.empty(), Body.empty()); } get number(): number { diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator.ts b/yarn-project/prover-client/src/orchestrator/orchestrator.ts index 38978fab21c..f1d5304400e 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator.ts @@ -437,7 +437,7 @@ export class ProvingOrchestrator implements EpochProver { // Assemble the L2 block const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db); - const l2Block = L2Block.fromFields({ archive: newArchive, header, body }); + const l2Block = new L2Block(newArchive, header, body); if (!l2Block.body.getTxsEffectsHash().equals(header.contentCommitment.txsEffectsHash)) { throw new Error( diff --git a/yarn-project/pxe/src/synchronizer/synchronizer.test.ts b/yarn-project/pxe/src/synchronizer/synchronizer.test.ts index ea2d1d86c39..66ae6d0d88d 100644 --- a/yarn-project/pxe/src/synchronizer/synchronizer.test.ts +++ b/yarn-project/pxe/src/synchronizer/synchronizer.test.ts @@ -97,21 +97,9 @@ describe('Synchronizer', () => { .mockResolvedValueOnce([blocks[1].body.encryptedLogs]); aztecNode.getBlocks - // called by synchronizer.work, we are testing fromFields in this first call - .mockResolvedValueOnce([ - L2Block.fromFields({ - archive: blocks[0].archive, - header: blocks[0].header, - body: blocks[0].body, - }), - ]) - .mockResolvedValueOnce([ - L2Block.fromFields({ - archive: blocks[1].archive, - header: blocks[1].header, - body: blocks[1].body, - }), - ]) + // called by synchronizer.work, + .mockResolvedValueOnce([blocks[0]]) + .mockResolvedValueOnce([blocks[1]]) // called by synchronizer.workNoteProcessorCatchUp .mockResolvedValueOnce([blocks[0]]) .mockResolvedValueOnce([blocks[1]]);