@aztec/world-state 0.0.1-commit.f5d02921e → 0.0.1-commit.f7ea82942
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.js +7 -7
- 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 +7 -7
- 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 { type GenesisData } from '@aztec/stdlib/world-state';
|
|
6
6
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
7
7
|
import { WorldStateInstrumentation } from '../instrumentation/instrumentation.js';
|
|
8
8
|
import { NativeWorldStateService } from '../native/native_world_state.js';
|
|
@@ -15,6 +15,6 @@ export interface WorldStateTreeMapSizes {
|
|
|
15
15
|
messageTreeMapSizeKb: number;
|
|
16
16
|
publicDataTreeMapSizeKb: number;
|
|
17
17
|
}
|
|
18
|
-
export declare function createWorldStateSynchronizer(config: WorldStateConfig & DataStoreConfig, l2BlockSource: L2BlockSource & L1ToL2MessageSource,
|
|
19
|
-
export declare function createWorldState(config: Pick<WorldStateConfig, 'worldStateDataDirectory' | 'worldStateDbMapSizeKb' | 'archiveTreeMapSizeKb' | 'nullifierTreeMapSizeKb' | 'noteHashTreeMapSizeKb' | 'messageTreeMapSizeKb' | 'publicDataTreeMapSizeKb'> & Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb' | 'l1Contracts'>,
|
|
20
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
18
|
+
export declare function createWorldStateSynchronizer(config: WorldStateConfig & DataStoreConfig, l2BlockSource: L2BlockSource & L1ToL2MessageSource, genesis?: GenesisData, client?: TelemetryClient, bindings?: LoggerBindings): Promise<ServerWorldStateSynchronizer>;
|
|
19
|
+
export declare function createWorldState(config: Pick<WorldStateConfig, 'worldStateDataDirectory' | 'worldStateDbMapSizeKb' | 'archiveTreeMapSizeKb' | 'nullifierTreeMapSizeKb' | 'noteHashTreeMapSizeKb' | 'messageTreeMapSizeKb' | 'publicDataTreeMapSizeKb'> & Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb' | 'l1Contracts'>, genesis?: GenesisData, instrumentation?: WorldStateInstrumentation, bindings?: LoggerBindings): Promise<NativeWorldStateService>;
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,ey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2hELE1BQU0sRUFBRSxnQkFBZ0IsR0FBRyxlQUFlLEVBQzFDLGFBQWEsRUFBRSxhQUFhLEdBQUcsbUJBQW1CLEVBQ2xELE9BQU8sR0FBRSxXQUFnQyxFQUN6QyxNQUFNLEdBQUUsZUFBc0MsRUFDOUMsUUFBUSxDQUFDLEVBQUUsY0FBYyx5Q0FLMUI7QUFFRCx3QkFBc0IsZ0JBQWdCLENBQ3BDLE1BQU0sRUFBRSxJQUFJLENBQ1YsZ0JBQWdCLEVBQ2QseUJBQXlCLEdBQ3pCLHVCQUF1QixHQUN2QixzQkFBc0IsR0FDdEIsd0JBQXdCLEdBQ3hCLHVCQUF1QixHQUN2QixzQkFBc0IsR0FDdEIseUJBQXlCLENBQzVCLEdBQ0MsSUFBSSxDQUFDLGVBQWUsRUFBRSxlQUFlLEdBQUcsb0JBQW9CLEdBQUcsYUFBYSxDQUFDLEVBQy9FLE9BQU8sR0FBRSxXQUFnQyxFQUN6QyxlQUFlLEdBQUUseUJBQStFLEVBQ2hHLFFBQVEsQ0FBQyxFQUFFLGNBQWMsb0NBbUMxQiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/synchronizer/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/synchronizer/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,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_DATA } from '@aztec/stdlib/world-state';
|
|
1
2
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
2
3
|
import { WorldStateInstrumentation } from '../instrumentation/instrumentation.js';
|
|
3
4
|
import { NativeWorldStateService } from '../native/native_world_state.js';
|
|
4
5
|
import { ServerWorldStateSynchronizer } from './server_world_state_synchronizer.js';
|
|
5
|
-
export async function createWorldStateSynchronizer(config, l2BlockSource,
|
|
6
|
+
export async function createWorldStateSynchronizer(config, l2BlockSource, genesis = EMPTY_GENESIS_DATA, client = getTelemetryClient(), bindings) {
|
|
6
7
|
const instrumentation = new WorldStateInstrumentation(client);
|
|
7
|
-
const merkleTrees = await createWorldState(config,
|
|
8
|
+
const merkleTrees = await createWorldState(config, genesis, instrumentation, bindings);
|
|
8
9
|
return new ServerWorldStateSynchronizer(merkleTrees, l2BlockSource, config, instrumentation);
|
|
9
10
|
}
|
|
10
|
-
export async function createWorldState(config,
|
|
11
|
+
export async function createWorldState(config, genesis = EMPTY_GENESIS_DATA, instrumentation = new WorldStateInstrumentation(getTelemetryClient()), bindings) {
|
|
11
12
|
const dataDirectory = config.worldStateDataDirectory ?? config.dataDirectory;
|
|
12
13
|
const dataStoreMapSizeKb = config.worldStateDbMapSizeKb ?? config.dataStoreMapSizeKb;
|
|
13
14
|
const wsTreeMapSizes = {
|
|
@@ -21,9 +22,9 @@ export async function createWorldState(config, prefilledPublicData = [], instrum
|
|
|
21
22
|
throw new Error('Rollup address is required to create a world state synchronizer.');
|
|
22
23
|
}
|
|
23
24
|
// If a data directory is provided in config, then create a persistent store.
|
|
24
|
-
const merkleTrees = dataDirectory ? await NativeWorldStateService.new(config.l1Contracts.rollupAddress, dataDirectory, wsTreeMapSizes,
|
|
25
|
+
const merkleTrees = dataDirectory ? await NativeWorldStateService.new(config.l1Contracts.rollupAddress, dataDirectory, wsTreeMapSizes, genesis, instrumentation, bindings) : await NativeWorldStateService.tmp(config.l1Contracts.rollupAddress, ![
|
|
25
26
|
'true',
|
|
26
27
|
'1'
|
|
27
|
-
].includes(process.env.DEBUG_WORLD_STATE),
|
|
28
|
+
].includes(process.env.DEBUG_WORLD_STATE), genesis, instrumentation, bindings);
|
|
28
29
|
return merkleTrees;
|
|
29
30
|
}
|
|
@@ -66,4 +66,4 @@ export declare class ServerWorldStateSynchronizer implements WorldStateSynchroni
|
|
|
66
66
|
*/
|
|
67
67
|
private setCurrentState;
|
|
68
68
|
}
|
|
69
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
69
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmVyX3dvcmxkX3N0YXRlX3N5bmNocm9uaXplci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3N5bmNocm9uaXplci9zZXJ2ZXJfd29ybGRfc3RhdGVfc3luY2hyb25pemVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxXQUFXLEVBQW9CLE1BQU0saUNBQWlDLENBQUM7QUFFaEYsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBR2xFLE9BQU8sRUFDTCxLQUFLLFNBQVMsRUFLZCxLQUFLLGFBQWEsRUFDbEIsYUFBYSxFQUNiLEtBQUssa0JBQWtCLEVBQ3ZCLEtBQUsseUJBQXlCLEVBQzlCLEtBQUssOEJBQThCLEVBQ25DLEtBQUssTUFBTSxFQUNaLE1BQU0scUJBQXFCLENBQUM7QUFDN0IsT0FBTyxFQUdMLEtBQUssc0JBQXNCLEVBQzNCLEtBQUssNEJBQTRCLEVBQ2xDLE1BQU0saUNBQWlDLENBQUM7QUFDekMsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBRWhFLE9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RUQsZ0dBQWdHO0lBQ25GLFNBQVMsSUFBSSxPQUFPLENBQUMsTUFBTSxDQUFDLENBdUN4QztJQUVELG9EQUFvRDtJQUN2QyxzQkFBc0IsQ0FBQyxLQUFLLEVBQUUsa0JBQWtCLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQWU1RTtZQU9hLGNBQWM7WUF5Q2QsYUFBYTtZQWtCYixvQkFBb0I7SUEwRGxDLE9BQU8sQ0FBQyxpQkFBaUI7WUFNWCxpQkFBaUI7SUFTL0I7OztPQUdHO0lBQ0gsT0FBTyxDQUFDLGVBQWU7Q0FJeEIifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server_world_state_synchronizer.d.ts","sourceRoot":"","sources":["../../src/synchronizer/server_world_state_synchronizer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAoB,MAAM,iCAAiC,CAAC;AAEhF,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EACL,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"server_world_state_synchronizer.d.ts","sourceRoot":"","sources":["../../src/synchronizer/server_world_state_synchronizer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAoB,MAAM,iCAAiC,CAAC;AAEhF,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EACL,KAAK,SAAS,EAKd,KAAK,aAAa,EAClB,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,8BAA8B,EACnC,KAAK,MAAM,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EAClC,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CA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AAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC,CAElH;IAEM,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE5B;IAEY,KAAK,mFA4BjB;IAED,SAAS,CAAC,iBAAiB,IAAI,aAAa,CAO3C;IAEY,IAAI,kBAOhB;IAEY,MAAM,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAa3D;IAEY,oBAAoB,yBAEhC;IAEY,QAAQ,kBAIpB;IAEM,UAAU,SAOhB;IAED;;;;;OAKG;IACU,aAAa,CAAC,iBAAiB,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CA2EvG;IAED,oGAAoG;IACvF,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAK5E;IAED,gGAAgG;IACnF,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAuCxC;IAED,oDAAoD;IACvC,sBAAsB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAe5E;YAOa,cAAc;YAyCd,aAAa;YAkBb,oBAAoB;IA0DlC,OAAO,CAAC,iBAAiB;YAMX,iBAAiB;IAS/B;;;OAGG;IACH,OAAO,CAAC,eAAe;CAIxB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
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 { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
5
5
|
import { elapsed } from '@aztec/foundation/timer';
|
|
6
|
-
import { GENESIS_CHECKPOINT_HEADER_HASH, L2BlockStream } from '@aztec/stdlib/block';
|
|
6
|
+
import { GENESIS_BLOCK_HEADER_HASH, GENESIS_CHECKPOINT_HEADER_HASH, L2BlockStream } from '@aztec/stdlib/block';
|
|
7
7
|
import { WorldStateRunningState } from '@aztec/stdlib/interfaces/server';
|
|
8
8
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
9
9
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
package/dest/testing.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
4
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
4
5
|
export declare const defaultInitialAccountFeeJuice: Fr;
|
|
5
|
-
export declare function getGenesisValues(initialAccounts: AztecAddress[], initialAccountFeeJuice?: Fr, genesisPublicData?: PublicDataTreeLeaf[]): Promise<{
|
|
6
|
+
export declare function getGenesisValues(initialAccounts: AztecAddress[], initialAccountFeeJuice?: Fr, genesisPublicData?: PublicDataTreeLeaf[], genesisTimestamp?: bigint): Promise<{
|
|
6
7
|
genesisArchiveRoot: Fr;
|
|
7
|
-
|
|
8
|
+
genesis: GenesisData;
|
|
8
9
|
fundingNeeded: bigint;
|
|
9
10
|
}>;
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3Rlc3RpbmcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRXBELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sRUFBZ0Isa0JBQWtCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUN2RSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQXFCN0QsZUFBTyxNQUFNLDZCQUE2QixJQUFxQixDQUFDO0FBRWhFLHdCQUFzQixnQkFBZ0IsQ0FDcEMsZUFBZSxFQUFFLFlBQVksRUFBRSxFQUMvQixzQkFBc0IsS0FBZ0MsRUFDdEQsaUJBQWlCLEdBQUUsa0JBQWtCLEVBQU8sRUFDNUMsZ0JBQWdCLEdBQUUsTUFBVzs7OztHQXNCOUIifQ==
|
package/dest/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAgB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAgB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAqB7D,eAAO,MAAM,6BAA6B,IAAqB,CAAC;AAEhE,wBAAsB,gBAAgB,CACpC,eAAe,EAAE,YAAY,EAAE,EAC/B,sBAAsB,KAAgC,EACtD,iBAAiB,GAAE,kBAAkB,EAAO,EAC5C,gBAAgB,GAAE,MAAW;;;;GAsB9B"}
|
package/dest/testing.js
CHANGED
|
@@ -3,14 +3,14 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
4
4
|
import { MerkleTreeId, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
5
5
|
import { NativeWorldStateService } from './native/index.js';
|
|
6
|
-
async function generateGenesisValues(
|
|
7
|
-
if (!prefilledPublicData.length) {
|
|
6
|
+
async function generateGenesisValues(genesis) {
|
|
7
|
+
if (!genesis.prefilledPublicData.length && genesis.genesisTimestamp === 0n) {
|
|
8
8
|
return {
|
|
9
9
|
genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT)
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
// Create a temporary world state to compute the genesis values.
|
|
13
|
-
const ws = await NativeWorldStateService.tmp(undefined /* rollupAddress */ , true,
|
|
13
|
+
const ws = await NativeWorldStateService.tmp(undefined /* rollupAddress */ , true, genesis);
|
|
14
14
|
const genesisArchiveRoot = new Fr((await ws.getCommitted().getTreeInfo(MerkleTreeId.ARCHIVE)).root);
|
|
15
15
|
await ws.close();
|
|
16
16
|
return {
|
|
@@ -18,16 +18,20 @@ async function generateGenesisValues(prefilledPublicData) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
export const defaultInitialAccountFeeJuice = new Fr(10n ** 22n);
|
|
21
|
-
export async function getGenesisValues(initialAccounts, initialAccountFeeJuice = defaultInitialAccountFeeJuice, genesisPublicData = []) {
|
|
21
|
+
export async function getGenesisValues(initialAccounts, initialAccountFeeJuice = defaultInitialAccountFeeJuice, genesisPublicData = [], genesisTimestamp = 0n) {
|
|
22
22
|
// Top up the accounts with fee juice.
|
|
23
23
|
let prefilledPublicData = await Promise.all(initialAccounts.map(async (address)=>new PublicDataTreeLeaf(await computeFeePayerBalanceLeafSlot(address), initialAccountFeeJuice)));
|
|
24
24
|
// Add user-defined public data
|
|
25
25
|
prefilledPublicData = prefilledPublicData.concat(genesisPublicData);
|
|
26
26
|
prefilledPublicData.sort((a, b)=>b.slot.lt(a.slot) ? 1 : -1);
|
|
27
|
-
const
|
|
27
|
+
const genesis = {
|
|
28
|
+
prefilledPublicData,
|
|
29
|
+
genesisTimestamp
|
|
30
|
+
};
|
|
31
|
+
const { genesisArchiveRoot } = await generateGenesisValues(genesis);
|
|
28
32
|
return {
|
|
29
33
|
genesisArchiveRoot,
|
|
30
|
-
|
|
34
|
+
genesis,
|
|
31
35
|
fundingNeeded: BigInt(initialAccounts.length) * initialAccountFeeJuice.toBigInt()
|
|
32
36
|
};
|
|
33
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/world-state",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.f7ea82942",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -64,18 +64,18 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/constants": "0.0.1-commit.
|
|
68
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
69
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
70
|
-
"@aztec/native": "0.0.1-commit.
|
|
71
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
72
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
73
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
67
|
+
"@aztec/constants": "0.0.1-commit.f7ea82942",
|
|
68
|
+
"@aztec/foundation": "0.0.1-commit.f7ea82942",
|
|
69
|
+
"@aztec/kv-store": "0.0.1-commit.f7ea82942",
|
|
70
|
+
"@aztec/native": "0.0.1-commit.f7ea82942",
|
|
71
|
+
"@aztec/protocol-contracts": "0.0.1-commit.f7ea82942",
|
|
72
|
+
"@aztec/stdlib": "0.0.1-commit.f7ea82942",
|
|
73
|
+
"@aztec/telemetry-client": "0.0.1-commit.f7ea82942",
|
|
74
74
|
"tslib": "^2.4.0",
|
|
75
75
|
"zod": "^3.23.8"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
78
|
+
"@aztec/archiver": "0.0.1-commit.f7ea82942",
|
|
79
79
|
"@jest/globals": "^30.0.0",
|
|
80
80
|
"@types/jest": "^30.0.0",
|
|
81
81
|
"@types/node": "^22.15.17",
|
|
@@ -4,6 +4,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
4
4
|
import { serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
5
|
import { sleep } from '@aztec/foundation/sleep';
|
|
6
6
|
import { type IndexedTreeLeafPreimage, SiblingPath } from '@aztec/foundation/trees';
|
|
7
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
7
8
|
import type {
|
|
8
9
|
BatchInsertionResult,
|
|
9
10
|
IndexedTreeId,
|
|
@@ -118,7 +119,7 @@ export class MerkleTreesFacade implements MerkleTreeReadOperations {
|
|
|
118
119
|
|
|
119
120
|
const leaf = deserializeLeafValue(resp);
|
|
120
121
|
if (leaf instanceof Fr) {
|
|
121
|
-
return leaf as any;
|
|
122
|
+
return treeId === MerkleTreeId.ARCHIVE ? (new BlockHash(leaf) as any) : (leaf as any);
|
|
122
123
|
} else {
|
|
123
124
|
return leaf.toBuffer() as any;
|
|
124
125
|
}
|
|
@@ -228,7 +229,7 @@ export class MerkleTreesForkFacade extends MerkleTreesFacade implements MerkleTr
|
|
|
228
229
|
|
|
229
230
|
async appendLeaves<ID extends MerkleTreeId>(treeId: ID, leaves: MerkleTreeLeafType<ID>[]): Promise<void> {
|
|
230
231
|
await this.instance.call(WorldStateMessageType.APPEND_LEAVES, {
|
|
231
|
-
leaves: leaves.map(leaf => leaf as any),
|
|
232
|
+
leaves: leaves.map(leaf => serializeLeaf(hydrateLeaf(treeId, leaf as any))),
|
|
232
233
|
forkId: this.revision.forkId,
|
|
233
234
|
treeId,
|
|
234
235
|
});
|
|
@@ -352,9 +353,11 @@ export class MerkleTreesForkFacade extends MerkleTreesFacade implements MerkleTr
|
|
|
352
353
|
}
|
|
353
354
|
}
|
|
354
355
|
|
|
355
|
-
function hydrateLeaf
|
|
356
|
+
function hydrateLeaf(treeId: MerkleTreeId, leaf: Fr | BlockHash | Buffer) {
|
|
356
357
|
if (leaf instanceof Fr) {
|
|
357
358
|
return leaf;
|
|
359
|
+
} else if (leaf instanceof BlockHash) {
|
|
360
|
+
return leaf.toFr();
|
|
358
361
|
} else if (treeId === MerkleTreeId.NULLIFIER_TREE) {
|
|
359
362
|
return NullifierLeaf.fromBuffer(leaf);
|
|
360
363
|
} else if (treeId === MerkleTreeId.PUBLIC_DATA_TREE) {
|
|
@@ -364,8 +367,10 @@ function hydrateLeaf<ID extends MerkleTreeId>(treeId: ID, leaf: Fr | Buffer) {
|
|
|
364
367
|
}
|
|
365
368
|
}
|
|
366
369
|
|
|
367
|
-
export function serializeLeaf(leaf: Fr | NullifierLeaf | PublicDataTreeLeaf): SerializedLeafValue {
|
|
368
|
-
if (leaf instanceof
|
|
370
|
+
export function serializeLeaf(leaf: Fr | BlockHash | NullifierLeaf | PublicDataTreeLeaf): SerializedLeafValue {
|
|
371
|
+
if (leaf instanceof BlockHash) {
|
|
372
|
+
return leaf.toBuffer();
|
|
373
|
+
} else if (leaf instanceof Fr) {
|
|
369
374
|
return leaf.toBuffer();
|
|
370
375
|
} else if (leaf instanceof NullifierLeaf) {
|
|
371
376
|
return { nullifier: leaf.nullifier.toBuffer() };
|
package/src/native/message.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
4
|
-
import type { BlockHash } from '@aztec/stdlib/block';
|
|
5
4
|
import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
6
5
|
import type { StateReference } from '@aztec/stdlib/tx';
|
|
7
6
|
import type { UInt32 } from '@aztec/stdlib/types';
|
|
@@ -423,7 +422,7 @@ interface UpdateArchiveRequest extends WithForkId {
|
|
|
423
422
|
interface SyncBlockRequest extends WithCanonicalForkId {
|
|
424
423
|
blockNumber: BlockNumber;
|
|
425
424
|
blockStateRef: BlockStateReference;
|
|
426
|
-
blockHeaderHash:
|
|
425
|
+
blockHeaderHash: Buffer;
|
|
427
426
|
paddedNoteHashes: readonly SerializedLeafValue[];
|
|
428
427
|
paddedL1ToL2Messages: readonly SerializedLeafValue[];
|
|
429
428
|
paddedNullifiers: readonly SerializedLeafValue[];
|
|
@@ -14,8 +14,8 @@ import type {
|
|
|
14
14
|
} from '@aztec/stdlib/interfaces/server';
|
|
15
15
|
import type { SnapshotDataKeys } from '@aztec/stdlib/snapshots';
|
|
16
16
|
import { MerkleTreeId, NullifierLeaf, type NullifierLeafPreimage, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
17
|
-
import { BlockHeader, PartialStateReference, StateReference } from '@aztec/stdlib/tx';
|
|
18
|
-
import { WorldStateRevision } from '@aztec/stdlib/world-state';
|
|
17
|
+
import { BlockHeader, GlobalVariables, PartialStateReference, StateReference } from '@aztec/stdlib/tx';
|
|
18
|
+
import { EMPTY_GENESIS_DATA, type GenesisData, WorldStateRevision } from '@aztec/stdlib/world-state';
|
|
19
19
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
20
20
|
|
|
21
21
|
import assert from 'assert/strict';
|
|
@@ -53,6 +53,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
53
53
|
protected instance: NativeWorldState,
|
|
54
54
|
protected readonly worldStateInstrumentation: WorldStateInstrumentation,
|
|
55
55
|
protected readonly log: Logger,
|
|
56
|
+
private readonly genesis: GenesisData = EMPTY_GENESIS_DATA,
|
|
56
57
|
private readonly cleanup = () => Promise.resolve(),
|
|
57
58
|
) {}
|
|
58
59
|
|
|
@@ -60,7 +61,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
60
61
|
rollupAddress: EthAddress,
|
|
61
62
|
dataDir: string,
|
|
62
63
|
wsTreeMapSizes: WorldStateTreeMapSizes,
|
|
63
|
-
|
|
64
|
+
genesis: GenesisData = EMPTY_GENESIS_DATA,
|
|
64
65
|
instrumentation = new WorldStateInstrumentation(getTelemetryClient()),
|
|
65
66
|
bindings?: LoggerBindings,
|
|
66
67
|
cleanup = () => Promise.resolve(),
|
|
@@ -73,14 +74,12 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
73
74
|
rollupAddress,
|
|
74
75
|
dataDirectory: worldStateDirectory,
|
|
75
76
|
onOpen: (dir: string) => {
|
|
76
|
-
return Promise.resolve(
|
|
77
|
-
new NativeWorldState(dir, wsTreeMapSizes, prefilledPublicData, instrumentation, bindings),
|
|
78
|
-
);
|
|
77
|
+
return Promise.resolve(new NativeWorldState(dir, wsTreeMapSizes, genesis, instrumentation, bindings));
|
|
79
78
|
},
|
|
80
79
|
});
|
|
81
80
|
|
|
82
81
|
const [instance] = await versionManager.open();
|
|
83
|
-
const worldState = new this(instance, instrumentation, log, cleanup);
|
|
82
|
+
const worldState = new this(instance, instrumentation, log, genesis, cleanup);
|
|
84
83
|
try {
|
|
85
84
|
await worldState.init();
|
|
86
85
|
} catch (e) {
|
|
@@ -94,7 +93,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
94
93
|
static async tmp(
|
|
95
94
|
rollupAddress = EthAddress.ZERO,
|
|
96
95
|
cleanupTmpDir = true,
|
|
97
|
-
|
|
96
|
+
genesis: GenesisData = EMPTY_GENESIS_DATA,
|
|
98
97
|
instrumentation = new WorldStateInstrumentation(getTelemetryClient()),
|
|
99
98
|
bindings?: LoggerBindings,
|
|
100
99
|
): Promise<NativeWorldStateService> {
|
|
@@ -120,15 +119,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
120
119
|
}
|
|
121
120
|
};
|
|
122
121
|
|
|
123
|
-
return this.new(
|
|
124
|
-
rollupAddress,
|
|
125
|
-
dataDir,
|
|
126
|
-
worldStateTreeMapSizes,
|
|
127
|
-
prefilledPublicData,
|
|
128
|
-
instrumentation,
|
|
129
|
-
bindings,
|
|
130
|
-
cleanup,
|
|
131
|
-
);
|
|
122
|
+
return this.new(rollupAddress, dataDir, worldStateTreeMapSizes, genesis, instrumentation, bindings, cleanup);
|
|
132
123
|
}
|
|
133
124
|
|
|
134
125
|
protected async init() {
|
|
@@ -147,7 +138,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
147
138
|
|
|
148
139
|
// the initial header _must_ be the first element in the archive tree
|
|
149
140
|
// if this assertion fails, check that the hashing done in Header in yarn-project matches the initial header hash done in world_state.cpp
|
|
150
|
-
const indices = await committed.findLeafIndices(MerkleTreeId.ARCHIVE, [
|
|
141
|
+
const indices = await committed.findLeafIndices(MerkleTreeId.ARCHIVE, [await this.initialHeader.hash()]);
|
|
151
142
|
const initialHeaderIndex = indices[0];
|
|
152
143
|
assert.strictEqual(initialHeaderIndex, 0n, 'Invalid initial archive state');
|
|
153
144
|
}
|
|
@@ -185,7 +176,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
185
176
|
this.initialHeader!,
|
|
186
177
|
new WorldStateRevision(
|
|
187
178
|
/*forkId=*/ resp.forkId,
|
|
188
|
-
/* blockNumber=*/
|
|
179
|
+
/* blockNumber=*/ WorldStateRevision.LATEST,
|
|
189
180
|
/* includeUncommitted=*/ true,
|
|
190
181
|
),
|
|
191
182
|
opts,
|
|
@@ -232,7 +223,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
232
223
|
WorldStateMessageType.SYNC_BLOCK,
|
|
233
224
|
{
|
|
234
225
|
blockNumber: l2Block.number,
|
|
235
|
-
blockHeaderHash: await l2Block.hash(),
|
|
226
|
+
blockHeaderHash: (await l2Block.hash()).toBuffer(),
|
|
236
227
|
paddedL1ToL2Messages: paddedL1ToL2Messages.map(serializeLeaf),
|
|
237
228
|
paddedNoteHashes: paddedNoteHashes.map(serializeLeaf),
|
|
238
229
|
paddedNullifiers: paddedNullifiers.map(serializeLeaf),
|
|
@@ -256,7 +247,10 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
256
247
|
|
|
257
248
|
private async buildInitialHeader(): Promise<BlockHeader> {
|
|
258
249
|
const state = await this.getInitialStateReference();
|
|
259
|
-
return BlockHeader.empty({
|
|
250
|
+
return BlockHeader.empty({
|
|
251
|
+
state,
|
|
252
|
+
globalVariables: GlobalVariables.empty({ timestamp: this.genesis.genesisTimestamp }),
|
|
253
|
+
});
|
|
260
254
|
}
|
|
261
255
|
|
|
262
256
|
private sanitizeAndCacheSummaryFromFull(response: WorldStateStatusFull) {
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
12
12
|
import { NativeWorldState as BaseNativeWorldState, MsgpackChannel } from '@aztec/native';
|
|
13
13
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
14
|
-
import type
|
|
14
|
+
import { EMPTY_GENESIS_DATA, type GenesisData } from '@aztec/stdlib/world-state';
|
|
15
15
|
|
|
16
16
|
import assert from 'assert';
|
|
17
17
|
import { cpus } from 'os';
|
|
@@ -55,7 +55,7 @@ export class NativeWorldState implements NativeWorldStateInstance {
|
|
|
55
55
|
constructor(
|
|
56
56
|
private readonly dataDir: string,
|
|
57
57
|
private readonly wsTreeMapSizes: WorldStateTreeMapSizes,
|
|
58
|
-
private readonly
|
|
58
|
+
private readonly genesis: GenesisData = EMPTY_GENESIS_DATA,
|
|
59
59
|
private readonly instrumentation: WorldStateInstrumentation,
|
|
60
60
|
bindings?: LoggerBindings,
|
|
61
61
|
private readonly log: Logger = createLogger('world-state:database', bindings),
|
|
@@ -66,7 +66,10 @@ export class NativeWorldState implements NativeWorldStateInstance {
|
|
|
66
66
|
wsTreeMapSizes,
|
|
67
67
|
)} and ${threads} threads.`,
|
|
68
68
|
);
|
|
69
|
-
const prefilledPublicDataBufferArray = prefilledPublicData.map(d => [
|
|
69
|
+
const prefilledPublicDataBufferArray = genesis.prefilledPublicData.map(d => [
|
|
70
|
+
d.slot.toBuffer(),
|
|
71
|
+
d.value.toBuffer(),
|
|
72
|
+
]);
|
|
70
73
|
const ws = new BaseNativeWorldState(
|
|
71
74
|
dataDir,
|
|
72
75
|
{
|
|
@@ -82,6 +85,7 @@ export class NativeWorldState implements NativeWorldStateInstance {
|
|
|
82
85
|
},
|
|
83
86
|
prefilledPublicDataBufferArray,
|
|
84
87
|
DomainSeparator.BLOCK_HEADER_HASH,
|
|
88
|
+
Number(genesis.genesisTimestamp),
|
|
85
89
|
{
|
|
86
90
|
[MerkleTreeId.NULLIFIER_TREE]: wsTreeMapSizes.nullifierTreeMapSizeKb,
|
|
87
91
|
[MerkleTreeId.NOTE_HASH_TREE]: wsTreeMapSizes.noteHashTreeMapSizeKb,
|
|
@@ -104,7 +108,7 @@ export class NativeWorldState implements NativeWorldStateInstance {
|
|
|
104
108
|
return new NativeWorldState(
|
|
105
109
|
this.dataDir,
|
|
106
110
|
this.wsTreeMapSizes,
|
|
107
|
-
this.
|
|
111
|
+
this.genesis,
|
|
108
112
|
this.instrumentation,
|
|
109
113
|
this.log.getBindings(),
|
|
110
114
|
this.log,
|
|
@@ -96,7 +96,7 @@ export class WorldStateOpsQueue {
|
|
|
96
96
|
// then send the request immediately
|
|
97
97
|
// If a mutating request is in flight then we must wait
|
|
98
98
|
// If a mutating request is not in flight but something is queued then it must be a mutating request
|
|
99
|
-
if (this.inFlightMutatingCount
|
|
99
|
+
if (this.inFlightMutatingCount === 0 && this.requests.length === 0) {
|
|
100
100
|
this.sendEnqueuedRequest(op);
|
|
101
101
|
} else {
|
|
102
102
|
this.requests.push(op);
|
|
@@ -122,7 +122,7 @@ export class WorldStateOpsQueue {
|
|
|
122
122
|
--this.inFlightCount;
|
|
123
123
|
|
|
124
124
|
// If there are still requests in flight then do nothing further
|
|
125
|
-
if (this.inFlightCount
|
|
125
|
+
if (this.inFlightCount !== 0) {
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -134,7 +134,7 @@ export class WorldStateOpsQueue {
|
|
|
134
134
|
while (this.requests.length > 0) {
|
|
135
135
|
const next = this.requests[0];
|
|
136
136
|
if (next.mutating) {
|
|
137
|
-
if (this.inFlightCount
|
|
137
|
+
if (this.inFlightCount === 0) {
|
|
138
138
|
// send the mutating request
|
|
139
139
|
this.requests.shift();
|
|
140
140
|
this.sendEnqueuedRequest(next);
|
|
@@ -149,7 +149,7 @@ export class WorldStateOpsQueue {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
// If the queue is empty, there is nothing in flight and we have been told to stop, then resolve the stop promise
|
|
152
|
-
if (this.inFlightCount
|
|
152
|
+
if (this.inFlightCount === 0 && this.stopResolve !== undefined) {
|
|
153
153
|
this.stopResolve();
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -182,7 +182,7 @@ export class WorldStateOpsQueue {
|
|
|
182
182
|
});
|
|
183
183
|
|
|
184
184
|
// If no outstanding requests then immediately resolve the promise
|
|
185
|
-
if (this.requests.length
|
|
185
|
+
if (this.requests.length === 0 && this.inFlightCount === 0 && this.stopResolve !== undefined) {
|
|
186
186
|
this.stopResolve();
|
|
187
187
|
}
|
|
188
188
|
return this.stopPromise;
|
|
@@ -42,41 +42,41 @@ export const worldStateConfigMappings: ConfigMappingsType<WorldStateConfig> = {
|
|
|
42
42
|
},
|
|
43
43
|
worldStateBlockRequestBatchSize: {
|
|
44
44
|
env: 'WS_BLOCK_REQUEST_BATCH_SIZE',
|
|
45
|
-
parseEnv: (val: string
|
|
45
|
+
parseEnv: (val: string) => +val,
|
|
46
46
|
description: 'Size of the batch for each get-blocks request from the synchronizer to the archiver.',
|
|
47
47
|
},
|
|
48
48
|
worldStateDbMapSizeKb: {
|
|
49
49
|
env: 'WS_DB_MAP_SIZE_KB',
|
|
50
|
-
parseEnv: (val: string
|
|
50
|
+
parseEnv: (val: string) => +val,
|
|
51
51
|
description: 'The maximum possible size of the world state DB in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
52
52
|
},
|
|
53
53
|
archiveTreeMapSizeKb: {
|
|
54
54
|
env: 'ARCHIVE_TREE_MAP_SIZE_KB',
|
|
55
|
-
parseEnv: (val: string
|
|
55
|
+
parseEnv: (val: string) => +val,
|
|
56
56
|
description:
|
|
57
57
|
'The maximum possible size of the world state archive tree in KB. Overwrites the general worldStateDbMapSizeKb.',
|
|
58
58
|
},
|
|
59
59
|
nullifierTreeMapSizeKb: {
|
|
60
60
|
env: 'NULLIFIER_TREE_MAP_SIZE_KB',
|
|
61
|
-
parseEnv: (val: string
|
|
61
|
+
parseEnv: (val: string) => +val,
|
|
62
62
|
description:
|
|
63
63
|
'The maximum possible size of the world state nullifier tree in KB. Overwrites the general worldStateDbMapSizeKb.',
|
|
64
64
|
},
|
|
65
65
|
noteHashTreeMapSizeKb: {
|
|
66
66
|
env: 'NOTE_HASH_TREE_MAP_SIZE_KB',
|
|
67
|
-
parseEnv: (val: string
|
|
67
|
+
parseEnv: (val: string) => +val,
|
|
68
68
|
description:
|
|
69
69
|
'The maximum possible size of the world state note hash tree in KB. Overwrites the general worldStateDbMapSizeKb.',
|
|
70
70
|
},
|
|
71
71
|
messageTreeMapSizeKb: {
|
|
72
72
|
env: 'MESSAGE_TREE_MAP_SIZE_KB',
|
|
73
|
-
parseEnv: (val: string
|
|
73
|
+
parseEnv: (val: string) => +val,
|
|
74
74
|
description:
|
|
75
75
|
'The maximum possible size of the world state message tree in KB. Overwrites the general worldStateDbMapSizeKb.',
|
|
76
76
|
},
|
|
77
77
|
publicDataTreeMapSizeKb: {
|
|
78
78
|
env: 'PUBLIC_DATA_TREE_MAP_SIZE_KB',
|
|
79
|
-
parseEnv: (val: string
|
|
79
|
+
parseEnv: (val: string) => +val,
|
|
80
80
|
description:
|
|
81
81
|
'The maximum possible size of the world state public data tree in KB. Overwrites the general worldStateDbMapSizeKb.',
|
|
82
82
|
},
|
|
@@ -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,
|