@aztec/kv-store 3.0.0-nightly.20251202 → 3.0.0-nightly.20251204
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { L2BlockStreamEvent, L2BlockStreamEventHandler, L2BlockStreamLocalDataProvider, L2Tips } from '@aztec/stdlib/block';
|
|
2
3
|
import type { AztecAsyncKVStore } from '../interfaces/store.js';
|
|
3
4
|
/** Stores currently synced L2 tips and unfinalized block hashes. */
|
|
@@ -5,10 +6,10 @@ export declare class L2TipsKVStore implements L2BlockStreamEventHandler, L2Block
|
|
|
5
6
|
private readonly l2TipsStore;
|
|
6
7
|
private readonly l2BlockHashesStore;
|
|
7
8
|
constructor(store: AztecAsyncKVStore, namespace: string);
|
|
8
|
-
getL2BlockHash(number:
|
|
9
|
+
getL2BlockHash(number: BlockNumber): Promise<string | undefined>;
|
|
9
10
|
getL2Tips(): Promise<L2Tips>;
|
|
10
11
|
private getL2Tip;
|
|
11
12
|
handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void>;
|
|
12
13
|
private saveTag;
|
|
13
14
|
}
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDJfdGlwc19zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3N0b3Jlcy9sMl90aXBzX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUM5RCxPQUFPLEtBQUssRUFFVixrQkFBa0IsRUFDbEIseUJBQXlCLEVBQ3pCLDhCQUE4QixFQUU5QixNQUFNLEVBQ1AsTUFBTSxxQkFBcUIsQ0FBQztBQUc3QixPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRWhFLG9FQUFvRTtBQUNwRSxxQkFBYSxhQUFjLFlBQVcseUJBQXlCLEVBQUUsOEJBQThCO0lBQzdGLE9BQU8sQ0FBQyxRQUFRLENBQUMsV0FBVyxDQUF5QztJQUNyRSxPQUFPLENBQUMsUUFBUSxDQUFDLGtCQUFrQixDQUFxQztJQUV4RSxZQUFZLEtBQUssRUFBRSxpQkFBaUIsRUFBRSxTQUFTLEVBQUUsTUFBTSxFQUd0RDtJQUVNLGNBQWMsQ0FBQyxNQUFNLEVBQUUsV0FBVyxHQUFHLE9BQU8sQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFDLENBRXRFO0lBRVksU0FBUyxJQUFJLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FNeEM7WUFFYSxRQUFRO0lBYVQsc0JBQXNCLENBQUMsS0FBSyxFQUFFLGtCQUFrQixHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0F1QjVFO1lBRWEsT0FBTztDQU10QiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"l2_tips_store.d.ts","sourceRoot":"","sources":["../../src/stores/l2_tips_store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"l2_tips_store.d.ts","sourceRoot":"","sources":["../../src/stores/l2_tips_store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAEV,kBAAkB,EAClB,yBAAyB,EACzB,8BAA8B,EAE9B,MAAM,EACP,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,oEAAoE;AACpE,qBAAa,aAAc,YAAW,yBAAyB,EAAE,8BAA8B;IAC7F,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyC;IACrE,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAqC;IAExE,YAAY,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,EAGtD;IAEM,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEtE;IAEY,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAMxC;YAEa,QAAQ;IAaT,sBAAsB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB5E;YAEa,OAAO;CAMtB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
3
|
/** Stores currently synced L2 tips and unfinalized block hashes. */ export class L2TipsKVStore {
|
|
2
4
|
l2TipsStore;
|
|
3
5
|
l2BlockHashesStore;
|
|
@@ -25,8 +27,8 @@
|
|
|
25
27
|
const blockNumber = await this.l2TipsStore.getAsync(tag);
|
|
26
28
|
if (blockNumber === undefined || blockNumber === 0) {
|
|
27
29
|
return {
|
|
28
|
-
number:
|
|
29
|
-
hash:
|
|
30
|
+
number: BlockNumber.ZERO,
|
|
31
|
+
hash: GENESIS_BLOCK_HEADER_HASH.toString()
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
const blockHash = await this.l2BlockHashesStore.getAsync(blockNumber);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/kv-store",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251204",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/interfaces/index.js",
|
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
"./package.local.json"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@aztec/
|
|
28
|
-
"@aztec/
|
|
29
|
-
"@aztec/
|
|
30
|
-
"@aztec/
|
|
27
|
+
"@aztec/constants": "3.0.0-nightly.20251204",
|
|
28
|
+
"@aztec/ethereum": "3.0.0-nightly.20251204",
|
|
29
|
+
"@aztec/foundation": "3.0.0-nightly.20251204",
|
|
30
|
+
"@aztec/native": "3.0.0-nightly.20251204",
|
|
31
|
+
"@aztec/stdlib": "3.0.0-nightly.20251204",
|
|
31
32
|
"idb": "^8.0.0",
|
|
32
33
|
"lmdb": "^3.2.0",
|
|
33
34
|
"msgpackr": "^1.11.2",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
3
|
import type {
|
|
2
4
|
L2BlockId,
|
|
3
5
|
L2BlockStreamEvent,
|
|
@@ -12,15 +14,15 @@ import type { AztecAsyncKVStore } from '../interfaces/store.js';
|
|
|
12
14
|
|
|
13
15
|
/** Stores currently synced L2 tips and unfinalized block hashes. */
|
|
14
16
|
export class L2TipsKVStore implements L2BlockStreamEventHandler, L2BlockStreamLocalDataProvider {
|
|
15
|
-
private readonly l2TipsStore: AztecAsyncMap<L2BlockTag,
|
|
16
|
-
private readonly l2BlockHashesStore: AztecAsyncMap<
|
|
17
|
+
private readonly l2TipsStore: AztecAsyncMap<L2BlockTag, BlockNumber>;
|
|
18
|
+
private readonly l2BlockHashesStore: AztecAsyncMap<BlockNumber, string>;
|
|
17
19
|
|
|
18
20
|
constructor(store: AztecAsyncKVStore, namespace: string) {
|
|
19
21
|
this.l2TipsStore = store.openMap([namespace, 'l2_tips'].join('_'));
|
|
20
22
|
this.l2BlockHashesStore = store.openMap([namespace, 'l2_block_hashes'].join('_'));
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
public getL2BlockHash(number:
|
|
25
|
+
public getL2BlockHash(number: BlockNumber): Promise<string | undefined> {
|
|
24
26
|
return this.l2BlockHashesStore.getAsync(number);
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -35,7 +37,7 @@ export class L2TipsKVStore implements L2BlockStreamEventHandler, L2BlockStreamLo
|
|
|
35
37
|
private async getL2Tip(tag: L2BlockTag): Promise<L2BlockId> {
|
|
36
38
|
const blockNumber = await this.l2TipsStore.getAsync(tag);
|
|
37
39
|
if (blockNumber === undefined || blockNumber === 0) {
|
|
38
|
-
return { number:
|
|
40
|
+
return { number: BlockNumber.ZERO, hash: GENESIS_BLOCK_HEADER_HASH.toString() };
|
|
39
41
|
}
|
|
40
42
|
const blockHash = await this.l2BlockHashesStore.getAsync(blockNumber);
|
|
41
43
|
if (!blockHash) {
|