@aztec/world-state 0.0.1-commit.e588bc7e5 → 0.0.1-commit.e5a3663dd
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.d.ts +3 -2
- package/dest/native/merkle_trees_facade.d.ts.map +1 -1
- package/dest/native/merkle_trees_facade.js +8 -3
- package/dest/native/message.d.ts +2 -3
- package/dest/native/message.d.ts.map +1 -1
- package/dest/native/native_world_state.d.ts +7 -5
- package/dest/native/native_world_state.d.ts.map +1 -1
- package/dest/native/native_world_state.js +17 -12
- package/dest/native/native_world_state_instance.d.ts +4 -4
- package/dest/native/native_world_state_instance.d.ts.map +1 -1
- package/dest/native/native_world_state_instance.js +7 -6
- package/dest/native/world_state_ops_queue.js +5 -5
- package/dest/synchronizer/config.d.ts +1 -1
- package/dest/synchronizer/config.d.ts.map +1 -1
- package/dest/synchronizer/config.js +9 -10
- package/dest/synchronizer/factory.d.ts +4 -4
- package/dest/synchronizer/factory.d.ts.map +1 -1
- package/dest/synchronizer/factory.js +6 -5
- 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 +2 -2
- package/dest/testing.d.ts +4 -3
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +10 -6
- package/package.json +9 -9
- package/src/native/merkle_trees_facade.ts +10 -5
- package/src/native/message.ts +1 -2
- package/src/native/native_world_state.ts +15 -21
- package/src/native/native_world_state_instance.ts +8 -4
- package/src/native/world_state_ops_queue.ts +5 -5
- package/src/synchronizer/config.ts +14 -10
- package/src/synchronizer/factory.ts +6 -6
- package/src/synchronizer/server_world_state_synchronizer.ts +2 -1
- package/src/testing.ts +8 -9
|
@@ -2,7 +2,7 @@ import type { LoggerBindings } from '@aztec/foundation/log';
|
|
|
2
2
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
3
3
|
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
4
4
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
5
|
-
import type
|
|
5
|
+
import { EMPTY_GENESIS_DATA, type GenesisData } from '@aztec/stdlib/world-state';
|
|
6
6
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
7
7
|
|
|
8
8
|
import { WorldStateInstrumentation } from '../instrumentation/instrumentation.js';
|
|
@@ -21,12 +21,12 @@ export interface WorldStateTreeMapSizes {
|
|
|
21
21
|
export async function createWorldStateSynchronizer(
|
|
22
22
|
config: WorldStateConfig & DataStoreConfig,
|
|
23
23
|
l2BlockSource: L2BlockSource & L1ToL2MessageSource,
|
|
24
|
-
|
|
24
|
+
genesis: GenesisData = EMPTY_GENESIS_DATA,
|
|
25
25
|
client: TelemetryClient = getTelemetryClient(),
|
|
26
26
|
bindings?: LoggerBindings,
|
|
27
27
|
) {
|
|
28
28
|
const instrumentation = new WorldStateInstrumentation(client);
|
|
29
|
-
const merkleTrees = await createWorldState(config,
|
|
29
|
+
const merkleTrees = await createWorldState(config, genesis, instrumentation, bindings);
|
|
30
30
|
return new ServerWorldStateSynchronizer(merkleTrees, l2BlockSource, config, instrumentation);
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -42,7 +42,7 @@ export async function createWorldState(
|
|
|
42
42
|
| 'publicDataTreeMapSizeKb'
|
|
43
43
|
> &
|
|
44
44
|
Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb' | 'l1Contracts'>,
|
|
45
|
-
|
|
45
|
+
genesis: GenesisData = EMPTY_GENESIS_DATA,
|
|
46
46
|
instrumentation: WorldStateInstrumentation = new WorldStateInstrumentation(getTelemetryClient()),
|
|
47
47
|
bindings?: LoggerBindings,
|
|
48
48
|
) {
|
|
@@ -66,14 +66,14 @@ export async function createWorldState(
|
|
|
66
66
|
config.l1Contracts.rollupAddress,
|
|
67
67
|
dataDirectory,
|
|
68
68
|
wsTreeMapSizes,
|
|
69
|
-
|
|
69
|
+
genesis,
|
|
70
70
|
instrumentation,
|
|
71
71
|
bindings,
|
|
72
72
|
)
|
|
73
73
|
: await NativeWorldStateService.tmp(
|
|
74
74
|
config.l1Contracts.rollupAddress,
|
|
75
75
|
!['true', '1'].includes(process.env.DEBUG_WORLD_STATE!),
|
|
76
|
-
|
|
76
|
+
genesis,
|
|
77
77
|
instrumentation,
|
|
78
78
|
bindings,
|
|
79
79
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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,
|
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(
|
|
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
|
|
47
|
+
const genesis: GenesisData = { prefilledPublicData, genesisTimestamp };
|
|
48
|
+
const { genesisArchiveRoot } = await generateGenesisValues(genesis);
|
|
50
49
|
|
|
51
50
|
return {
|
|
52
51
|
genesisArchiveRoot,
|
|
53
|
-
|
|
52
|
+
genesis,
|
|
54
53
|
fundingNeeded: BigInt(initialAccounts.length) * initialAccountFeeJuice.toBigInt(),
|
|
55
54
|
};
|
|
56
55
|
}
|