@aztec/world-state 0.71.0 → 0.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/native/merkle_trees_facade.js +2 -2
- package/dest/native/message.d.ts +0 -30
- package/dest/native/message.d.ts.map +1 -1
- package/dest/native/message.js +1 -23
- package/dest/native/native_world_state.js +3 -3
- package/dest/native/native_world_state_instance.d.ts +1 -13
- package/dest/native/native_world_state_instance.d.ts.map +1 -1
- package/dest/native/native_world_state_instance.js +27 -94
- package/dest/native/world_state_version.js +2 -2
- package/dest/synchronizer/server_world_state_synchronizer.d.ts +1 -1
- package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/server_world_state_synchronizer.js +6 -6
- package/dest/test/utils.js +2 -2
- package/dest/world-state-db/merkle_trees.js +3 -3
- package/package.json +12 -17
- package/src/native/merkle_trees_facade.ts +1 -1
- package/src/native/message.ts +0 -44
- package/src/native/native_world_state.ts +2 -2
- package/src/native/native_world_state_instance.ts +28 -124
- package/src/native/world_state_version.ts +1 -1
- package/src/synchronizer/server_world_state_synchronizer.ts +6 -6
- package/src/test/utils.ts +1 -1
- package/src/world-state-db/merkle_trees.ts +2 -2
|
@@ -170,7 +170,7 @@ export class ServerWorldStateSynchronizer
|
|
|
170
170
|
/** Returns the L2 block hash for a given number. Used by the L2BlockStream for detecting reorgs. */
|
|
171
171
|
public async getL2BlockHash(number: number): Promise<string | undefined> {
|
|
172
172
|
if (number === 0) {
|
|
173
|
-
return
|
|
173
|
+
return (await this.merkleTreeCommitted.getInitialHeader().hash()).toString();
|
|
174
174
|
}
|
|
175
175
|
if (this.latestBlockHashQuery?.hash === undefined || number !== this.latestBlockHashQuery.blockNumber) {
|
|
176
176
|
this.latestBlockHashQuery = {
|
|
@@ -257,7 +257,7 @@ export class ServerWorldStateSynchronizer
|
|
|
257
257
|
// Note that we cannot optimize this check by checking the root of the subtree after inserting the messages
|
|
258
258
|
// to the real L1_TO_L2_MESSAGE_TREE (like we do in merkleTreeDb.handleL2BlockAndMessages(...)) because that
|
|
259
259
|
// tree uses pedersen and we don't have access to the converted root.
|
|
260
|
-
this.verifyMessagesHashToInHash(l1ToL2Messages, l2Block.header.contentCommitment.inHash);
|
|
260
|
+
await this.verifyMessagesHashToInHash(l1ToL2Messages, l2Block.header.contentCommitment.inHash);
|
|
261
261
|
|
|
262
262
|
// If the above check succeeds, we can proceed to handle the block.
|
|
263
263
|
const result = await this.merkleTreeDb.handleL2BlockAndMessages(l2Block, l1ToL2Messages);
|
|
@@ -311,14 +311,14 @@ export class ServerWorldStateSynchronizer
|
|
|
311
311
|
* @param inHash - The inHash of the block.
|
|
312
312
|
* @throws If the L1 to L2 messages do not hash to the block inHash.
|
|
313
313
|
*/
|
|
314
|
-
protected verifyMessagesHashToInHash(l1ToL2Messages: Fr[], inHash: Buffer) {
|
|
315
|
-
const treeCalculator =
|
|
314
|
+
protected async verifyMessagesHashToInHash(l1ToL2Messages: Fr[], inHash: Buffer) {
|
|
315
|
+
const treeCalculator = await MerkleTreeCalculator.create(
|
|
316
316
|
L1_TO_L2_MSG_SUBTREE_HEIGHT,
|
|
317
317
|
Buffer.alloc(32),
|
|
318
|
-
new SHA256Trunc().hash,
|
|
318
|
+
(lhs, rhs) => Promise.resolve(new SHA256Trunc().hash(lhs, rhs)),
|
|
319
319
|
);
|
|
320
320
|
|
|
321
|
-
const root = treeCalculator.computeTreeRoot(l1ToL2Messages.map(msg => msg.toBuffer()));
|
|
321
|
+
const root = await treeCalculator.computeTreeRoot(l1ToL2Messages.map(msg => msg.toBuffer()));
|
|
322
322
|
|
|
323
323
|
if (!root.equals(inHash)) {
|
|
324
324
|
throw new Error('Obtained L1 to L2 messages failed to be hashed to the block inHash');
|
package/src/test/utils.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { padArrayEnd } from '@aztec/foundation/collection';
|
|
|
17
17
|
import { type NativeWorldStateService } from '../native/native_world_state.js';
|
|
18
18
|
|
|
19
19
|
export async function mockBlock(blockNum: number, size: number, fork: MerkleTreeWriteOperations) {
|
|
20
|
-
const l2Block = L2Block.random(blockNum, size);
|
|
20
|
+
const l2Block = await L2Block.random(blockNum, size);
|
|
21
21
|
const l1ToL2Messages = Array(16).fill(0).map(Fr.random);
|
|
22
22
|
|
|
23
23
|
// Sync the append only trees
|
|
@@ -531,7 +531,7 @@ export class MerkleTrees implements MerkleTreeAdminDatabase {
|
|
|
531
531
|
throw new Error('State in header does not match current state');
|
|
532
532
|
}
|
|
533
533
|
|
|
534
|
-
const blockHash = header.hash();
|
|
534
|
+
const blockHash = await header.hash();
|
|
535
535
|
await this.#appendLeaves(MerkleTreeId.ARCHIVE, [blockHash]);
|
|
536
536
|
}
|
|
537
537
|
|
|
@@ -709,7 +709,7 @@ export class MerkleTrees implements MerkleTreeAdminDatabase {
|
|
|
709
709
|
}
|
|
710
710
|
await this.#snapshot(l2Block.number);
|
|
711
711
|
|
|
712
|
-
this.metrics.recordDbSize(this.store.estimateSize().actualSize);
|
|
712
|
+
this.metrics.recordDbSize((await this.store.estimateSize()).actualSize);
|
|
713
713
|
this.metrics.recordSyncDuration('commit', timer);
|
|
714
714
|
return buildEmptyWorldStateStatusFull();
|
|
715
715
|
}
|