@aztec/world-state 0.0.1-commit.7035c9bd6 → 0.0.1-commit.71324e566

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.
Files changed (32) hide show
  1. package/dest/native/merkle_trees_facade.d.ts +3 -2
  2. package/dest/native/merkle_trees_facade.d.ts.map +1 -1
  3. package/dest/native/merkle_trees_facade.js +8 -3
  4. package/dest/native/message.d.ts +2 -3
  5. package/dest/native/message.d.ts.map +1 -1
  6. package/dest/native/native_world_state.d.ts +7 -5
  7. package/dest/native/native_world_state.d.ts.map +1 -1
  8. package/dest/native/native_world_state.js +16 -11
  9. package/dest/native/native_world_state_instance.d.ts +4 -4
  10. package/dest/native/native_world_state_instance.d.ts.map +1 -1
  11. package/dest/native/native_world_state_instance.js +7 -6
  12. package/dest/native/world_state_ops_queue.js +5 -5
  13. package/dest/synchronizer/config.js +7 -7
  14. package/dest/synchronizer/factory.d.ts +4 -4
  15. package/dest/synchronizer/factory.d.ts.map +1 -1
  16. package/dest/synchronizer/factory.js +6 -5
  17. package/dest/synchronizer/server_world_state_synchronizer.d.ts +1 -1
  18. package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
  19. package/dest/synchronizer/server_world_state_synchronizer.js +15 -3
  20. package/dest/testing.d.ts +4 -3
  21. package/dest/testing.d.ts.map +1 -1
  22. package/dest/testing.js +10 -6
  23. package/package.json +9 -9
  24. package/src/native/merkle_trees_facade.ts +10 -5
  25. package/src/native/message.ts +1 -2
  26. package/src/native/native_world_state.ts +14 -20
  27. package/src/native/native_world_state_instance.ts +8 -4
  28. package/src/native/world_state_ops_queue.ts +5 -5
  29. package/src/synchronizer/config.ts +7 -7
  30. package/src/synchronizer/factory.ts +6 -6
  31. package/src/synchronizer/server_world_state_synchronizer.ts +9 -2
  32. package/src/testing.ts +8 -9
@@ -1,4 +1,4 @@
1
- import { GENESIS_BLOCK_HEADER_HASH, INITIAL_CHECKPOINT_NUMBER, INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
1
+ import { INITIAL_CHECKPOINT_NUMBER, INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
2
2
  import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
3
3
  import type { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { type Logger, createLogger } from '@aztec/foundation/log';
@@ -6,6 +6,7 @@ import { promiseWithResolvers } from '@aztec/foundation/promise';
6
6
  import { elapsed } from '@aztec/foundation/timer';
7
7
  import {
8
8
  type BlockHash,
9
+ GENESIS_BLOCK_HEADER_HASH,
9
10
  GENESIS_CHECKPOINT_HEADER_HASH,
10
11
  type L2Block,
11
12
  type L2BlockId,
@@ -293,6 +294,10 @@ export class ServerWorldStateSynchronizer
293
294
  block: { number: INITIAL_L2_BLOCK_NUM, hash: GENESIS_BLOCK_HEADER_HASH.toString() },
294
295
  checkpoint: { number: INITIAL_CHECKPOINT_NUMBER, hash: genesisCheckpointHeaderHash },
295
296
  },
297
+ proposedCheckpoint: {
298
+ block: { number: INITIAL_L2_BLOCK_NUM, hash: GENESIS_BLOCK_HEADER_HASH.toString() },
299
+ checkpoint: { number: INITIAL_CHECKPOINT_NUMBER, hash: genesisCheckpointHeaderHash },
300
+ },
296
301
  finalized: {
297
302
  block: { number: status.finalizedBlockNumber, hash: finalizedBlockHash ?? '' },
298
303
  checkpoint: { number: INITIAL_CHECKPOINT_NUMBER, hash: genesisCheckpointHeaderHash },
@@ -453,7 +458,9 @@ export class ServerWorldStateSynchronizer
453
458
  private async handleChainPruned(blockNumber: BlockNumber) {
454
459
  this.log.info(`Chain pruned to block ${blockNumber}`);
455
460
  const status = await this.merkleTreeDb.unwindBlocks(blockNumber);
456
- this.provenBlockNumber = undefined;
461
+ if (this.provenBlockNumber !== undefined && this.provenBlockNumber > blockNumber) {
462
+ this.provenBlockNumber = undefined;
463
+ }
457
464
  this.instrumentation.updateWorldStateMetrics(status);
458
465
  }
459
466
 
package/src/testing.ts CHANGED
@@ -3,22 +3,19 @@ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
4
4
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
  import { MerkleTreeId, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
6
+ import type { GenesisData } from '@aztec/stdlib/world-state';
6
7
 
7
8
  import { NativeWorldStateService } from './native/index.js';
8
9
 
9
- async function generateGenesisValues(prefilledPublicData: PublicDataTreeLeaf[]) {
10
- if (!prefilledPublicData.length) {
10
+ async function generateGenesisValues(genesis: GenesisData) {
11
+ if (!genesis.prefilledPublicData.length && genesis.genesisTimestamp === 0n) {
11
12
  return {
12
13
  genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT),
13
14
  };
14
15
  }
15
16
 
16
17
  // Create a temporary world state to compute the genesis values.
17
- const ws = await NativeWorldStateService.tmp(
18
- undefined /* rollupAddress */,
19
- true /* cleanupTmpDir */,
20
- prefilledPublicData,
21
- );
18
+ const ws = await NativeWorldStateService.tmp(undefined /* rollupAddress */, true /* cleanupTmpDir */, genesis);
22
19
  const genesisArchiveRoot = new Fr((await ws.getCommitted().getTreeInfo(MerkleTreeId.ARCHIVE)).root);
23
20
  await ws.close();
24
21
 
@@ -33,6 +30,7 @@ export async function getGenesisValues(
33
30
  initialAccounts: AztecAddress[],
34
31
  initialAccountFeeJuice = defaultInitialAccountFeeJuice,
35
32
  genesisPublicData: PublicDataTreeLeaf[] = [],
33
+ genesisTimestamp: bigint = 0n,
36
34
  ) {
37
35
  // Top up the accounts with fee juice.
38
36
  let prefilledPublicData = await Promise.all(
@@ -46,11 +44,12 @@ export async function getGenesisValues(
46
44
 
47
45
  prefilledPublicData.sort((a, b) => (b.slot.lt(a.slot) ? 1 : -1));
48
46
 
49
- const { genesisArchiveRoot } = await generateGenesisValues(prefilledPublicData);
47
+ const genesis: GenesisData = { prefilledPublicData, genesisTimestamp };
48
+ const { genesisArchiveRoot } = await generateGenesisValues(genesis);
50
49
 
51
50
  return {
52
51
  genesisArchiveRoot,
53
- prefilledPublicData,
52
+ genesis,
54
53
  fundingNeeded: BigInt(initialAccounts.length) * initialAccountFeeJuice.toBigInt(),
55
54
  };
56
55
  }