@aztec/world-state 0.76.4 → 0.77.0-testnet-ignition.17
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/index.js +0 -1
- package/dest/instrumentation/instrumentation.d.ts +2 -0
- package/dest/instrumentation/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation/instrumentation.js +50 -22
- package/dest/native/fork_checkpoint.d.ts +10 -0
- package/dest/native/fork_checkpoint.d.ts.map +1 -0
- package/dest/native/fork_checkpoint.js +26 -0
- package/dest/native/index.d.ts +1 -0
- package/dest/native/index.d.ts.map +1 -1
- package/dest/native/index.js +1 -1
- package/dest/native/merkle_trees_facade.d.ts +6 -4
- package/dest/native/merkle_trees_facade.d.ts.map +1 -1
- package/dest/native/merkle_trees_facade.js +80 -75
- package/dest/native/message.d.ts +5 -3
- package/dest/native/message.d.ts.map +1 -1
- package/dest/native/message.js +33 -19
- package/dest/native/native_world_state.d.ts +9 -5
- package/dest/native/native_world_state.d.ts.map +1 -1
- package/dest/native/native_world_state.js +126 -74
- package/dest/native/native_world_state_instance.d.ts +3 -2
- package/dest/native/native_world_state_instance.d.ts.map +1 -1
- package/dest/native/native_world_state_instance.js +43 -40
- package/dest/native/world_state_ops_queue.js +18 -29
- package/dest/native/world_state_version.d.ts +1 -1
- package/dest/native/world_state_version.d.ts.map +1 -1
- package/dest/native/world_state_version.js +8 -9
- package/dest/synchronizer/config.js +12 -14
- package/dest/synchronizer/factory.d.ts +7 -5
- package/dest/synchronizer/factory.d.ts.map +1 -1
- package/dest/synchronizer/factory.js +8 -8
- package/dest/synchronizer/index.js +0 -1
- package/dest/synchronizer/server_world_state_synchronizer.d.ts +7 -4
- package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/server_world_state_synchronizer.js +86 -65
- package/dest/test/index.js +0 -1
- package/dest/test/utils.d.ts +4 -3
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +21 -17
- package/dest/testing.d.ts +10 -0
- package/dest/testing.d.ts.map +1 -0
- package/dest/testing.js +37 -0
- package/dest/world-state-db/index.d.ts +1 -1
- package/dest/world-state-db/index.d.ts.map +1 -1
- package/dest/world-state-db/index.js +0 -1
- package/dest/world-state-db/merkle_tree_db.d.ts +6 -5
- package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
- package/dest/world-state-db/merkle_tree_db.js +2 -4
- package/package.json +14 -12
- package/src/instrumentation/instrumentation.ts +29 -3
- package/src/native/fork_checkpoint.ts +30 -0
- package/src/native/index.ts +1 -0
- package/src/native/merkle_trees_facade.ts +15 -18
- package/src/native/message.ts +5 -3
- package/src/native/native_world_state.ts +82 -69
- package/src/native/native_world_state_instance.ts +7 -3
- package/src/native/world_state_version.ts +1 -1
- package/src/synchronizer/factory.ts +11 -5
- package/src/synchronizer/server_world_state_synchronizer.ts +43 -26
- package/src/test/utils.ts +6 -10
- package/src/testing.ts +60 -0
- package/src/world-state-db/index.ts +1 -1
- package/src/world-state-db/merkle_tree_db.ts +7 -5
package/src/testing.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { GENESIS_ARCHIVE_ROOT, GENESIS_BLOCK_HASH } from '@aztec/constants';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { MerkleTreeId, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
6
|
+
|
|
7
|
+
import { NativeWorldStateService } from './native/index.js';
|
|
8
|
+
|
|
9
|
+
async function generateGenesisValues(prefilledPublicData: PublicDataTreeLeaf[]) {
|
|
10
|
+
if (!prefilledPublicData.length) {
|
|
11
|
+
return {
|
|
12
|
+
genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT),
|
|
13
|
+
genesisBlockHash: new Fr(GENESIS_BLOCK_HASH),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Create a temporary world state to compute the genesis values.
|
|
18
|
+
const ws = await NativeWorldStateService.tmp(
|
|
19
|
+
undefined /* rollupAddress */,
|
|
20
|
+
true /* cleanupTmpDir */,
|
|
21
|
+
prefilledPublicData,
|
|
22
|
+
);
|
|
23
|
+
const initialHeader = ws.getInitialHeader();
|
|
24
|
+
const genesisBlockHash = await initialHeader.hash();
|
|
25
|
+
const genesisArchiveRoot = new Fr((await ws.getCommitted().getTreeInfo(MerkleTreeId.ARCHIVE)).root);
|
|
26
|
+
await ws.close();
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
genesisArchiveRoot,
|
|
30
|
+
genesisBlockHash,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const defaultInitialAccountFeeJuice = new Fr(10n ** 22n);
|
|
35
|
+
|
|
36
|
+
export async function getGenesisValues(
|
|
37
|
+
initialAccounts: AztecAddress[],
|
|
38
|
+
initialAccountFeeJuice = defaultInitialAccountFeeJuice,
|
|
39
|
+
genesisPublicData: PublicDataTreeLeaf[] = [],
|
|
40
|
+
) {
|
|
41
|
+
// Top up the accounts with fee juice.
|
|
42
|
+
let prefilledPublicData = await Promise.all(
|
|
43
|
+
initialAccounts.map(
|
|
44
|
+
async address => new PublicDataTreeLeaf(await computeFeePayerBalanceLeafSlot(address), initialAccountFeeJuice),
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
// Add user-defined public data
|
|
49
|
+
prefilledPublicData = prefilledPublicData.concat(genesisPublicData);
|
|
50
|
+
|
|
51
|
+
prefilledPublicData.sort((a, b) => (b.slot.lt(a.slot) ? 1 : -1));
|
|
52
|
+
|
|
53
|
+
const { genesisBlockHash, genesisArchiveRoot } = await generateGenesisValues(prefilledPublicData);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
genesisArchiveRoot,
|
|
57
|
+
genesisBlockHash,
|
|
58
|
+
prefilledPublicData,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { MAX_NULLIFIERS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX } from '@aztec/constants';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import type { IndexedTreeSnapshot, TreeSnapshot } from '@aztec/merkle-tree';
|
|
4
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
5
|
+
import type { ForkMerkleTreeOperations, MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import type { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
5
7
|
|
|
6
|
-
import {
|
|
8
|
+
import type { WorldStateStatusFull, WorldStateStatusSummary } from '../native/message.js';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
*
|