@aztec/archiver 0.0.1-commit.96dac018d → 0.0.1-commit.993d240
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/README.md +19 -11
- package/dest/archiver.d.ts +36 -17
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +257 -75
- package/dest/config.d.ts +6 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +23 -15
- package/dest/errors.d.ts +55 -9
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +81 -14
- package/dest/factory.d.ts +13 -9
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +47 -35
- package/dest/index.d.ts +11 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +10 -2
- package/dest/l1/calldata_retriever.d.ts +2 -1
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +15 -5
- package/dest/l1/data_retrieval.d.ts +24 -12
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +36 -37
- package/dest/l1/trace_tx.d.ts +12 -66
- package/dest/l1/trace_tx.d.ts.map +1 -1
- package/dest/l1/validate_historical_logs.d.ts +23 -0
- package/dest/l1/validate_historical_logs.d.ts.map +1 -0
- package/dest/l1/validate_historical_logs.js +108 -0
- package/dest/modules/contract_data_source_adapter.d.ts +25 -0
- package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
- package/dest/modules/contract_data_source_adapter.js +40 -0
- package/dest/modules/data_source_base.d.ts +70 -46
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +270 -135
- package/dest/modules/data_store_updater.d.ts +42 -17
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +191 -122
- package/dest/modules/instrumentation.d.ts +7 -2
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +25 -7
- package/dest/modules/l1_synchronizer.d.ts +12 -6
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +432 -205
- package/dest/modules/validation.d.ts +4 -3
- package/dest/modules/validation.d.ts.map +1 -1
- package/dest/modules/validation.js +6 -6
- package/dest/store/block_store.d.ts +174 -70
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +696 -250
- package/dest/store/contract_class_store.d.ts +17 -4
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +24 -68
- package/dest/store/contract_instance_store.d.ts +28 -1
- package/dest/store/contract_instance_store.d.ts.map +1 -1
- package/dest/store/contract_instance_store.js +37 -2
- package/dest/store/data_stores.d.ts +68 -0
- package/dest/store/data_stores.d.ts.map +1 -0
- package/dest/store/data_stores.js +54 -0
- package/dest/store/function_names_cache.d.ts +17 -0
- package/dest/store/function_names_cache.d.ts.map +1 -0
- package/dest/store/function_names_cache.js +30 -0
- package/dest/store/l2_tips_cache.d.ts +13 -7
- package/dest/store/l2_tips_cache.d.ts.map +1 -1
- package/dest/store/l2_tips_cache.js +13 -76
- package/dest/store/log_store.d.ts +42 -37
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +262 -408
- package/dest/store/log_store_codec.d.ts +70 -0
- package/dest/store/log_store_codec.d.ts.map +1 -0
- package/dest/store/log_store_codec.js +101 -0
- package/dest/store/message_store.d.ts +11 -1
- package/dest/store/message_store.d.ts.map +1 -1
- package/dest/store/message_store.js +51 -9
- package/dest/test/fake_l1_state.d.ts +20 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +114 -18
- package/dest/test/mock_l1_to_l2_message_source.d.ts +1 -1
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +2 -1
- package/dest/test/mock_l2_block_source.d.ts +52 -46
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +246 -170
- package/dest/test/mock_structs.d.ts +4 -1
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +13 -1
- package/dest/test/noop_l1_archiver.d.ts +12 -6
- package/dest/test/noop_l1_archiver.d.ts.map +1 -1
- package/dest/test/noop_l1_archiver.js +26 -9
- package/package.json +14 -14
- package/src/archiver.ts +313 -75
- package/src/config.ts +32 -12
- package/src/errors.ts +122 -21
- package/src/factory.ts +54 -29
- package/src/index.ts +18 -2
- package/src/l1/calldata_retriever.ts +16 -5
- package/src/l1/data_retrieval.ts +52 -53
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/modules/contract_data_source_adapter.ts +55 -0
- package/src/modules/data_source_base.ts +336 -171
- package/src/modules/data_store_updater.ts +224 -154
- package/src/modules/instrumentation.ts +28 -8
- package/src/modules/l1_synchronizer.ts +572 -248
- package/src/modules/validation.ts +10 -9
- package/src/store/block_store.ts +865 -290
- package/src/store/contract_class_store.ts +31 -103
- package/src/store/contract_instance_store.ts +51 -5
- package/src/store/data_stores.ts +104 -0
- package/src/store/function_names_cache.ts +37 -0
- package/src/store/l2_tips_cache.ts +16 -70
- package/src/store/log_store.ts +301 -559
- package/src/store/log_store_codec.ts +132 -0
- package/src/store/message_store.ts +60 -10
- package/src/structs/inbox_message.ts +1 -1
- package/src/test/fake_l1_state.ts +142 -29
- package/src/test/mock_l1_to_l2_message_source.ts +1 -0
- package/src/test/mock_l2_block_source.ts +309 -205
- package/src/test/mock_structs.ts +20 -6
- package/src/test/noop_l1_archiver.ts +39 -9
- package/dest/store/kv_archiver_store.d.ts +0 -354
- package/dest/store/kv_archiver_store.d.ts.map +0 -1
- package/dest/store/kv_archiver_store.js +0 -464
- package/src/store/kv_archiver_store.ts +0 -671
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
|
-
import type { ContractClassPublic,
|
|
3
|
+
import type { ContractClassPublic, ContractClassPublicWithCommitment } from '@aztec/stdlib/contract';
|
|
4
4
|
/**
|
|
5
5
|
* LMDB-based contract class storage for the archiver.
|
|
6
6
|
*/
|
|
@@ -8,11 +8,24 @@ export declare class ContractClassStore {
|
|
|
8
8
|
#private;
|
|
9
9
|
private db;
|
|
10
10
|
constructor(db: AztecAsyncKVStore);
|
|
11
|
+
/**
|
|
12
|
+
* Adds multiple contract classes to the store.
|
|
13
|
+
* @param data - Contract classes (with bytecode commitments) to add.
|
|
14
|
+
* @param blockNumber - L2 block number where the classes were registered.
|
|
15
|
+
* @returns True if every insert succeeded.
|
|
16
|
+
*/
|
|
17
|
+
addContractClasses(data: ContractClassPublicWithCommitment[], blockNumber: number): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Removes multiple contract classes from the store, but only if they were registered at or after the given block.
|
|
20
|
+
* @param data - Contract classes to delete.
|
|
21
|
+
* @param blockNumber - Lower bound on the block number at which the classes were registered.
|
|
22
|
+
* @returns True if every delete succeeded.
|
|
23
|
+
*/
|
|
24
|
+
deleteContractClasses(data: ContractClassPublic[], blockNumber: number): Promise<boolean>;
|
|
11
25
|
addContractClass(contractClass: ContractClassPublic, bytecodeCommitment: Fr, blockNumber: number): Promise<void>;
|
|
12
|
-
|
|
26
|
+
deleteContractClass(contractClass: ContractClassPublic, blockNumber: number): Promise<void>;
|
|
13
27
|
getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
|
|
14
28
|
getBytecodeCommitment(id: Fr): Promise<Fr | undefined>;
|
|
15
29
|
getContractClassIds(): Promise<Fr[]>;
|
|
16
|
-
addFunctions(contractClassId: Fr, newPrivateFunctions: ExecutablePrivateFunctionWithMembershipProof[], newUtilityFunctions: UtilityFunctionWithMembershipProof[]): Promise<boolean>;
|
|
17
30
|
}
|
|
18
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udH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UFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLG1CQUFtQixHQUFHLFNBQVMsQ0FBQyxDQUd2RTtJQUVLLHFCQUFxQixDQUFDLEVBQUUsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLEVBQUUsR0FBRyxTQUFTLENBQUMsQ0FHM0Q7SUFFSyxtQkFBbUIsSUFBSSxPQUFPLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FFekM7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_class_store.d.ts","sourceRoot":"","sources":["../../src/store/contract_class_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"contract_class_store.d.ts","sourceRoot":"","sources":["../../src/store/contract_class_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EACV,mBAAmB,EAEnB,iCAAiC,EAClC,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,qBAAa,kBAAkB;;IAIjB,OAAO,CAAC,EAAE;IAAtB,YAAoB,EAAE,EAAE,iBAAiB,EAGxC;IAED;;;;;OAKG;IACG,kBAAkB,CAAC,IAAI,EAAE,iCAAiC,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAIzG;IAED;;;;;OAKG;IACG,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE9F;IAEK,gBAAgB,CACpB,aAAa,EAAE,mBAAmB,EAClC,kBAAkB,EAAE,EAAE,EACtB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAYf;IAEK,mBAAmB,CAAC,aAAa,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQhG;IAEK,gBAAgB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAGvE;IAEK,qBAAqB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAG3D;IAEK,mBAAmB,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC,CAEzC;CACF"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { toArray } from '@aztec/foundation/iterable';
|
|
3
3
|
import { BufferReader, numToUInt8, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
-
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
|
-
import { Vector } from '@aztec/stdlib/types';
|
|
6
4
|
/**
|
|
7
5
|
* LMDB-based contract class storage for the archiver.
|
|
8
6
|
*/ export class ContractClassStore {
|
|
@@ -14,16 +12,36 @@ import { Vector } from '@aztec/stdlib/types';
|
|
|
14
12
|
this.#contractClasses = db.openMap('archiver_contract_classes');
|
|
15
13
|
this.#bytecodeCommitments = db.openMap('archiver_bytecode_commitments');
|
|
16
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Adds multiple contract classes to the store.
|
|
17
|
+
* @param data - Contract classes (with bytecode commitments) to add.
|
|
18
|
+
* @param blockNumber - L2 block number where the classes were registered.
|
|
19
|
+
* @returns True if every insert succeeded.
|
|
20
|
+
*/ async addContractClasses(data, blockNumber) {
|
|
21
|
+
return (await Promise.all(data.map((c)=>this.addContractClass(c, c.publicBytecodeCommitment, blockNumber)))).every(Boolean);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Removes multiple contract classes from the store, but only if they were registered at or after the given block.
|
|
25
|
+
* @param data - Contract classes to delete.
|
|
26
|
+
* @param blockNumber - Lower bound on the block number at which the classes were registered.
|
|
27
|
+
* @returns True if every delete succeeded.
|
|
28
|
+
*/ async deleteContractClasses(data, blockNumber) {
|
|
29
|
+
return (await Promise.all(data.map((c)=>this.deleteContractClass(c, blockNumber)))).every(Boolean);
|
|
30
|
+
}
|
|
17
31
|
async addContractClass(contractClass, bytecodeCommitment, blockNumber) {
|
|
18
32
|
await this.db.transactionAsync(async ()=>{
|
|
19
|
-
|
|
33
|
+
const key = contractClass.id.toString();
|
|
34
|
+
if (await this.#contractClasses.hasAsync(key)) {
|
|
35
|
+
throw new Error(`Contract class ${key} already exists, cannot add again at block ${blockNumber}`);
|
|
36
|
+
}
|
|
37
|
+
await this.#contractClasses.set(key, serializeContractClassPublic({
|
|
20
38
|
...contractClass,
|
|
21
39
|
l2BlockNumber: blockNumber
|
|
22
40
|
}));
|
|
23
|
-
await this.#bytecodeCommitments.
|
|
41
|
+
await this.#bytecodeCommitments.set(key, bytecodeCommitment.toBuffer());
|
|
24
42
|
});
|
|
25
43
|
}
|
|
26
|
-
async
|
|
44
|
+
async deleteContractClass(contractClass, blockNumber) {
|
|
27
45
|
const restoredContractClass = await this.#contractClasses.getAsync(contractClass.id.toString());
|
|
28
46
|
if (restoredContractClass && deserializeContractClassPublic(restoredContractClass).l2BlockNumber >= blockNumber) {
|
|
29
47
|
await this.db.transactionAsync(async ()=>{
|
|
@@ -46,38 +64,9 @@ import { Vector } from '@aztec/stdlib/types';
|
|
|
46
64
|
async getContractClassIds() {
|
|
47
65
|
return (await toArray(this.#contractClasses.keysAsync())).map((key)=>Fr.fromHexString(key));
|
|
48
66
|
}
|
|
49
|
-
async addFunctions(contractClassId, newPrivateFunctions, newUtilityFunctions) {
|
|
50
|
-
await this.db.transactionAsync(async ()=>{
|
|
51
|
-
const existingClassBuffer = await this.#contractClasses.getAsync(contractClassId.toString());
|
|
52
|
-
if (!existingClassBuffer) {
|
|
53
|
-
throw new Error(`Unknown contract class ${contractClassId} when adding private functions to store`);
|
|
54
|
-
}
|
|
55
|
-
const existingClass = deserializeContractClassPublic(existingClassBuffer);
|
|
56
|
-
const { privateFunctions: existingPrivateFns, utilityFunctions: existingUtilityFns } = existingClass;
|
|
57
|
-
const updatedClass = {
|
|
58
|
-
...existingClass,
|
|
59
|
-
privateFunctions: [
|
|
60
|
-
...existingPrivateFns,
|
|
61
|
-
...newPrivateFunctions.filter((newFn)=>!existingPrivateFns.some((f)=>f.selector.equals(newFn.selector)))
|
|
62
|
-
],
|
|
63
|
-
utilityFunctions: [
|
|
64
|
-
...existingUtilityFns,
|
|
65
|
-
...newUtilityFunctions.filter((newFn)=>!existingUtilityFns.some((f)=>f.selector.equals(newFn.selector)))
|
|
66
|
-
]
|
|
67
|
-
};
|
|
68
|
-
await this.#contractClasses.set(contractClassId.toString(), serializeContractClassPublic(updatedClass));
|
|
69
|
-
});
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
67
|
}
|
|
73
68
|
function serializeContractClassPublic(contractClass) {
|
|
74
|
-
return serializeToBuffer(contractClass.l2BlockNumber, numToUInt8(contractClass.version), contractClass.artifactHash, contractClass.
|
|
75
|
-
}
|
|
76
|
-
function serializePrivateFunction(fn) {
|
|
77
|
-
return serializeToBuffer(fn.selector, fn.vkHash, fn.bytecode.length, fn.bytecode, fn.functionMetadataHash, fn.artifactMetadataHash, fn.utilityFunctionsTreeRoot, new Vector(fn.privateFunctionTreeSiblingPath), fn.privateFunctionTreeLeafIndex, new Vector(fn.artifactTreeSiblingPath), fn.artifactTreeLeafIndex);
|
|
78
|
-
}
|
|
79
|
-
function serializeUtilityFunction(fn) {
|
|
80
|
-
return serializeToBuffer(fn.selector, fn.bytecode.length, fn.bytecode, fn.functionMetadataHash, fn.artifactMetadataHash, fn.privateFunctionsArtifactTreeRoot, new Vector(fn.artifactTreeSiblingPath), fn.artifactTreeLeafIndex);
|
|
69
|
+
return serializeToBuffer(contractClass.l2BlockNumber, numToUInt8(contractClass.version), contractClass.artifactHash, contractClass.packedBytecode.length, contractClass.packedBytecode, contractClass.privateFunctionsRoot);
|
|
81
70
|
}
|
|
82
71
|
function deserializeContractClassPublic(buffer) {
|
|
83
72
|
const reader = BufferReader.asReader(buffer);
|
|
@@ -85,40 +74,7 @@ function deserializeContractClassPublic(buffer) {
|
|
|
85
74
|
l2BlockNumber: reader.readNumber(),
|
|
86
75
|
version: reader.readUInt8(),
|
|
87
76
|
artifactHash: reader.readObject(Fr),
|
|
88
|
-
privateFunctions: reader.readVector({
|
|
89
|
-
fromBuffer: deserializePrivateFunction
|
|
90
|
-
}),
|
|
91
|
-
utilityFunctions: reader.readVector({
|
|
92
|
-
fromBuffer: deserializeUtilityFunction
|
|
93
|
-
}),
|
|
94
77
|
packedBytecode: reader.readBuffer(),
|
|
95
78
|
privateFunctionsRoot: reader.readObject(Fr)
|
|
96
79
|
};
|
|
97
80
|
}
|
|
98
|
-
function deserializePrivateFunction(buffer) {
|
|
99
|
-
const reader = BufferReader.asReader(buffer);
|
|
100
|
-
return {
|
|
101
|
-
selector: reader.readObject(FunctionSelector),
|
|
102
|
-
vkHash: reader.readObject(Fr),
|
|
103
|
-
bytecode: reader.readBuffer(),
|
|
104
|
-
functionMetadataHash: reader.readObject(Fr),
|
|
105
|
-
artifactMetadataHash: reader.readObject(Fr),
|
|
106
|
-
utilityFunctionsTreeRoot: reader.readObject(Fr),
|
|
107
|
-
privateFunctionTreeSiblingPath: reader.readVector(Fr),
|
|
108
|
-
privateFunctionTreeLeafIndex: reader.readNumber(),
|
|
109
|
-
artifactTreeSiblingPath: reader.readVector(Fr),
|
|
110
|
-
artifactTreeLeafIndex: reader.readNumber()
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function deserializeUtilityFunction(buffer) {
|
|
114
|
-
const reader = BufferReader.asReader(buffer);
|
|
115
|
-
return {
|
|
116
|
-
selector: reader.readObject(FunctionSelector),
|
|
117
|
-
bytecode: reader.readBuffer(),
|
|
118
|
-
functionMetadataHash: reader.readObject(Fr),
|
|
119
|
-
artifactMetadataHash: reader.readObject(Fr),
|
|
120
|
-
privateFunctionsArtifactTreeRoot: reader.readObject(Fr),
|
|
121
|
-
artifactTreeSiblingPath: reader.readVector(Fr),
|
|
122
|
-
artifactTreeLeafIndex: reader.readNumber()
|
|
123
|
-
};
|
|
124
|
-
}
|
|
@@ -11,6 +11,33 @@ export declare class ContractInstanceStore {
|
|
|
11
11
|
#private;
|
|
12
12
|
private db;
|
|
13
13
|
constructor(db: AztecAsyncKVStore);
|
|
14
|
+
/**
|
|
15
|
+
* Adds multiple contract instances to the store.
|
|
16
|
+
* @param data - Contract instances to add.
|
|
17
|
+
* @param blockNumber - L2 block number where the instances were deployed.
|
|
18
|
+
* @returns True if every insert succeeded.
|
|
19
|
+
*/
|
|
20
|
+
addContractInstances(data: ContractInstanceWithAddress[], blockNumber: number): Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Removes multiple contract instances from the store.
|
|
23
|
+
* @param data - Contract instances to delete.
|
|
24
|
+
* @returns True if every delete succeeded.
|
|
25
|
+
*/
|
|
26
|
+
deleteContractInstances(data: ContractInstanceWithAddress[]): Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* Adds multiple contract instance updates to the store.
|
|
29
|
+
* @param data - Contract instance updates to add.
|
|
30
|
+
* @param timestamp - Timestamp at which the updates were scheduled.
|
|
31
|
+
* @returns True if every insert succeeded.
|
|
32
|
+
*/
|
|
33
|
+
addContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], timestamp: UInt64): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Removes multiple contract instance updates from the store.
|
|
36
|
+
* @param data - Contract instance updates to delete.
|
|
37
|
+
* @param timestamp - Timestamp at which the updates were scheduled.
|
|
38
|
+
* @returns True if every delete succeeded.
|
|
39
|
+
*/
|
|
40
|
+
deleteContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], timestamp: UInt64): Promise<boolean>;
|
|
14
41
|
addContractInstance(contractInstance: ContractInstanceWithAddress, blockNumber: number): Promise<void>;
|
|
15
42
|
deleteContractInstance(contractInstance: ContractInstanceWithAddress): Promise<void>;
|
|
16
43
|
getUpdateKey(contractAddress: AztecAddress, timestamp: UInt64, logIndex?: number): ContractInstanceUpdateKey;
|
|
@@ -21,4 +48,4 @@ export declare class ContractInstanceStore {
|
|
|
21
48
|
getContractInstanceDeploymentBlockNumber(address: AztecAddress): Promise<number | undefined>;
|
|
22
49
|
}
|
|
23
50
|
export {};
|
|
24
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
51
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfaW5zdGFuY2Vfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yZS9jb250cmFjdF9pbnN0YW5jZV9zdG9yZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEVBQ0wsS0FBSyxpQ0FBaUMsRUFDdEMsS0FBSywyQkFBMkIsRUFHakMsTUFBTSx3QkFBd0IsQ0FBQztBQUNoQyxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUVsRCxLQUFLLHlCQUF5QixHQUFHLENBQUMsTUFBTSxFQUFFLE1BQU0sQ0FBQyxHQUFHLENBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxNQUFNLENBQUMsQ0FBQztBQUU3RTs7R0FFRztBQUNILHFCQUFhLHFCQUFxQjs7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AIlH;IAED,mBAAmB,CAAC,gBAAgB,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAWrG;IAED,sBAAsB,CAAC,gBAAgB,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAKnF;IAED,YAAY,CAAC,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,yBAAyB,CAM3G;IAED,yBAAyB,CACvB,sBAAsB,EAAE,iCAAiC,EACzD,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAKf;IAED,4BAA4B,CAC1B,sBAAsB,EAAE,iCAAiC,EACzD,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAEf;IAEK,iCAAiC,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,CAoBlH;IAEK,mBAAmB,CACvB,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAalD;IAED,wCAAwC,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE3F;CACF"}
|
|
@@ -12,10 +12,45 @@ import { SerializableContractInstance, SerializableContractInstanceUpdate } from
|
|
|
12
12
|
this.#contractInstancePublishedAt = db.openMap('archiver_contract_instances_publication_block_number');
|
|
13
13
|
this.#contractInstanceUpdates = db.openMap('archiver_contract_instance_updates');
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Adds multiple contract instances to the store.
|
|
17
|
+
* @param data - Contract instances to add.
|
|
18
|
+
* @param blockNumber - L2 block number where the instances were deployed.
|
|
19
|
+
* @returns True if every insert succeeded.
|
|
20
|
+
*/ async addContractInstances(data, blockNumber) {
|
|
21
|
+
return (await Promise.all(data.map((c)=>this.addContractInstance(c, blockNumber)))).every(Boolean);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Removes multiple contract instances from the store.
|
|
25
|
+
* @param data - Contract instances to delete.
|
|
26
|
+
* @returns True if every delete succeeded.
|
|
27
|
+
*/ async deleteContractInstances(data) {
|
|
28
|
+
return (await Promise.all(data.map((c)=>this.deleteContractInstance(c)))).every(Boolean);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Adds multiple contract instance updates to the store.
|
|
32
|
+
* @param data - Contract instance updates to add.
|
|
33
|
+
* @param timestamp - Timestamp at which the updates were scheduled.
|
|
34
|
+
* @returns True if every insert succeeded.
|
|
35
|
+
*/ async addContractInstanceUpdates(data, timestamp) {
|
|
36
|
+
return (await Promise.all(data.map((update, logIndex)=>this.addContractInstanceUpdate(update, timestamp, logIndex)))).every(Boolean);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Removes multiple contract instance updates from the store.
|
|
40
|
+
* @param data - Contract instance updates to delete.
|
|
41
|
+
* @param timestamp - Timestamp at which the updates were scheduled.
|
|
42
|
+
* @returns True if every delete succeeded.
|
|
43
|
+
*/ async deleteContractInstanceUpdates(data, timestamp) {
|
|
44
|
+
return (await Promise.all(data.map((update, logIndex)=>this.deleteContractInstanceUpdate(update, timestamp, logIndex)))).every(Boolean);
|
|
45
|
+
}
|
|
15
46
|
addContractInstance(contractInstance, blockNumber) {
|
|
16
47
|
return this.db.transactionAsync(async ()=>{
|
|
17
|
-
|
|
18
|
-
await this.#
|
|
48
|
+
const key = contractInstance.address.toString();
|
|
49
|
+
if (await this.#contractInstances.hasAsync(key)) {
|
|
50
|
+
throw new Error(`Contract instance at ${key} already exists (deployed at block ${await this.#contractInstancePublishedAt.getAsync(key)}), cannot add again at block ${blockNumber}`);
|
|
51
|
+
}
|
|
52
|
+
await this.#contractInstances.set(key, new SerializableContractInstance(contractInstance).toBuffer());
|
|
53
|
+
await this.#contractInstancePublishedAt.set(key, blockNumber);
|
|
19
54
|
});
|
|
20
55
|
}
|
|
21
56
|
deleteContractInstance(contractInstance) {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { L1BlockId } from '@aztec/ethereum/l1-types';
|
|
2
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
|
+
import type { BlockHash } from '@aztec/stdlib/block';
|
|
4
|
+
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
5
|
+
import { BlockStore } from './block_store.js';
|
|
6
|
+
import { ContractClassStore } from './contract_class_store.js';
|
|
7
|
+
import { ContractInstanceStore } from './contract_instance_store.js';
|
|
8
|
+
import { FunctionNamesCache } from './function_names_cache.js';
|
|
9
|
+
import { LogStore } from './log_store.js';
|
|
10
|
+
import { MessageStore } from './message_store.js';
|
|
11
|
+
export declare const ARCHIVER_DB_VERSION = 7;
|
|
12
|
+
/**
|
|
13
|
+
* Represents the latest L1 block processed by the archiver for various objects in L2.
|
|
14
|
+
*/
|
|
15
|
+
export type ArchiverL1SynchPoint = {
|
|
16
|
+
/** Number of the last L1 block that added a new L2 checkpoint metadata. */
|
|
17
|
+
blocksSynchedTo?: bigint;
|
|
18
|
+
/** Last L1 block checked for L1 to L2 messages. */
|
|
19
|
+
messagesSynchedTo?: L1BlockId;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Bundle of archiver-owned LMDB substores plus the in-memory caches that span them.
|
|
23
|
+
*
|
|
24
|
+
* Replaces the former `KVArchiverDataStore` pass-through wrapper. Callers reach into
|
|
25
|
+
* the relevant substore directly (e.g. `stores.blocks.getBlock`) and use
|
|
26
|
+
* {@link createArchiverDataStores} to wire them up against a shared KV store.
|
|
27
|
+
*/
|
|
28
|
+
export type ArchiverDataStores = {
|
|
29
|
+
/** The underlying key-value store. Use {@link AztecAsyncKVStore.transactionAsync} to compose updates atomically. */
|
|
30
|
+
db: AztecAsyncKVStore;
|
|
31
|
+
/** Blocks, checkpoints, tx effects, proven/finalized state. */
|
|
32
|
+
blocks: BlockStore;
|
|
33
|
+
/** Public, private and contract class logs. */
|
|
34
|
+
logs: LogStore;
|
|
35
|
+
/** L1 to L2 messages and message sync state. */
|
|
36
|
+
messages: MessageStore;
|
|
37
|
+
/** Contract classes (with bytecode commitments). */
|
|
38
|
+
contractClasses: ContractClassStore;
|
|
39
|
+
/** Contract instances and contract instance updates. */
|
|
40
|
+
contractInstances: ContractInstanceStore;
|
|
41
|
+
/** In-memory cache of public function selectors -> names. */
|
|
42
|
+
functionNames: FunctionNamesCache;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Wires up the archiver substores against a shared KV store and returns the
|
|
46
|
+
* {@link ArchiverDataStores} bundle.
|
|
47
|
+
*
|
|
48
|
+
* @param genesisBlockHash - Hash of the synthetic genesis block, forwarded to the {@link LogStore} so it
|
|
49
|
+
* can resolve a genesis `referenceBlock` (used by the PXE during early sync) instead of treating it as a
|
|
50
|
+
* reorg.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createArchiverDataStores(db: AztecAsyncKVStore, genesisBlockHash: BlockHash): ArchiverDataStores;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the L1 sync point of the archiver, combining the block sync point from {@link BlockStore}
|
|
55
|
+
* and the message sync point from {@link MessageStore}.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getArchiverSynchPoint(stores: ArchiverDataStores): Promise<ArchiverL1SynchPoint>;
|
|
58
|
+
/**
|
|
59
|
+
* Backs up the underlying KV store to the given folder. Returns the path to the resulting db file.
|
|
60
|
+
*/
|
|
61
|
+
export declare function backupArchiverDataStores(stores: ArchiverDataStores, path: string, compress?: boolean): Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Returns a {@link ContractDataSource} adapter over {@link ArchiverDataStores}.
|
|
64
|
+
* Used by contexts (e.g. offline epoch re-prover tools) that need a ContractDataSource
|
|
65
|
+
* but do not need a full archiver instance.
|
|
66
|
+
*/
|
|
67
|
+
export declare function createContractDataSource(stores: ArchiverDataStores): ContractDataSource;
|
|
68
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YV9zdG9yZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yZS9kYXRhX3N0b3Jlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUMxRCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3JELE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFLakUsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBQzlDLE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQy9ELE9BQU8sRUFBRSxxQkFBcUIsRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBQ3JFLE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQy9ELE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUMxQyxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFbEQsZUFBTyxNQUFNLG1CQUFtQixJQUFJLENBQUM7QUFFckM7O0dBRUc7QUFDSCxNQUFNLE1BQU0sb0JBQW9CLEdBQUc7SUFDakMsNEVBQTRFO0lBQzVFLGVBQWUsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUN6QixtREFBbUQ7SUFDbk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,wBAAwB,CAAC,EAAE,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,SAAS,GAAG,kBAAkB,CAW/G;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAMrG;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,MAAM,EACZ,QAAQ,UAAO,GACd,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CAEvF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { ArchiverContractDataSourceAdapter } from '../modules/contract_data_source_adapter.js';
|
|
3
|
+
import { BlockStore } from './block_store.js';
|
|
4
|
+
import { ContractClassStore } from './contract_class_store.js';
|
|
5
|
+
import { ContractInstanceStore } from './contract_instance_store.js';
|
|
6
|
+
import { FunctionNamesCache } from './function_names_cache.js';
|
|
7
|
+
import { LogStore } from './log_store.js';
|
|
8
|
+
import { MessageStore } from './message_store.js';
|
|
9
|
+
export const ARCHIVER_DB_VERSION = 7;
|
|
10
|
+
/**
|
|
11
|
+
* Wires up the archiver substores against a shared KV store and returns the
|
|
12
|
+
* {@link ArchiverDataStores} bundle.
|
|
13
|
+
*
|
|
14
|
+
* @param genesisBlockHash - Hash of the synthetic genesis block, forwarded to the {@link LogStore} so it
|
|
15
|
+
* can resolve a genesis `referenceBlock` (used by the PXE during early sync) instead of treating it as a
|
|
16
|
+
* reorg.
|
|
17
|
+
*/ export function createArchiverDataStores(db, genesisBlockHash) {
|
|
18
|
+
const blocks = new BlockStore(db);
|
|
19
|
+
return {
|
|
20
|
+
db,
|
|
21
|
+
blocks,
|
|
22
|
+
logs: new LogStore(db, blocks, genesisBlockHash),
|
|
23
|
+
messages: new MessageStore(db),
|
|
24
|
+
contractClasses: new ContractClassStore(db),
|
|
25
|
+
contractInstances: new ContractInstanceStore(db),
|
|
26
|
+
functionNames: new FunctionNamesCache()
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns the L1 sync point of the archiver, combining the block sync point from {@link BlockStore}
|
|
31
|
+
* and the message sync point from {@link MessageStore}.
|
|
32
|
+
*/ export async function getArchiverSynchPoint(stores) {
|
|
33
|
+
const [blocksSynchedTo, messagesSynchedTo] = await Promise.all([
|
|
34
|
+
stores.blocks.getSynchedL1BlockNumber(),
|
|
35
|
+
stores.messages.getSynchedL1Block()
|
|
36
|
+
]);
|
|
37
|
+
return {
|
|
38
|
+
blocksSynchedTo,
|
|
39
|
+
messagesSynchedTo
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Backs up the underlying KV store to the given folder. Returns the path to the resulting db file.
|
|
44
|
+
*/ export async function backupArchiverDataStores(stores, path, compress = true) {
|
|
45
|
+
await stores.db.backupTo(path, compress);
|
|
46
|
+
return join(path, 'data.mdb');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns a {@link ContractDataSource} adapter over {@link ArchiverDataStores}.
|
|
50
|
+
* Used by contexts (e.g. offline epoch re-prover tools) that need a ContractDataSource
|
|
51
|
+
* but do not need a full archiver instance.
|
|
52
|
+
*/ export function createContractDataSource(stores) {
|
|
53
|
+
return new ArchiverContractDataSourceAdapter(stores);
|
|
54
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
2
|
+
/**
|
|
3
|
+
* In-memory cache mapping public function selectors to function names.
|
|
4
|
+
*
|
|
5
|
+
* Populated opportunistically (e.g. by PXE registering signatures from artifacts) so the
|
|
6
|
+
* archiver can attach human-readable names to logs and traces. Bounded by
|
|
7
|
+
* {@link MAX_FUNCTION_SIGNATURES} to avoid unbounded growth from untrusted callers.
|
|
8
|
+
*/
|
|
9
|
+
export declare class FunctionNamesCache {
|
|
10
|
+
private readonly log;
|
|
11
|
+
private readonly names;
|
|
12
|
+
/** Adds the given public function signatures to the cache. */
|
|
13
|
+
register(signatures: string[]): Promise<void>;
|
|
14
|
+
/** Looks up a function name for the given selector, or returns undefined if not registered. */
|
|
15
|
+
get(selector: FunctionSelector): string | undefined;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnVuY3Rpb25fbmFtZXNfY2FjaGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yZS9mdW5jdGlvbl9uYW1lc19jYWNoZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUtyRDs7Ozs7O0dBTUc7QUFDSCxxQkFBYSxrQkFBa0I7SUFDN0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQXdDO0lBQzVELE9BQU8sQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFrQztJQUV4RCw4REFBOEQ7SUFDakQsUUFBUSxDQUFDLFVBQVUsRUFBRSxNQUFNLEVBQUUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBWXpEO0lBRUQsK0ZBQStGO0lBQ3hGLEdBQUcsQ0FBQyxRQUFRLEVBQUUsZ0JBQWdCLEdBQUcsTUFBTSxHQUFHLFNBQVMsQ0FFekQ7Q0FDRiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function_names_cache.d.ts","sourceRoot":"","sources":["../../src/store/function_names_cache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAKrD;;;;;;GAMG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAwC;IAC5D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkC;IAExD,8DAA8D;IACjD,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAYzD;IAED,+FAA+F;IACxF,GAAG,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAEzD;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
|
+
const MAX_FUNCTION_SIGNATURES = 1000;
|
|
4
|
+
const MAX_FUNCTION_NAME_LEN = 256;
|
|
5
|
+
/**
|
|
6
|
+
* In-memory cache mapping public function selectors to function names.
|
|
7
|
+
*
|
|
8
|
+
* Populated opportunistically (e.g. by PXE registering signatures from artifacts) so the
|
|
9
|
+
* archiver can attach human-readable names to logs and traces. Bounded by
|
|
10
|
+
* {@link MAX_FUNCTION_SIGNATURES} to avoid unbounded growth from untrusted callers.
|
|
11
|
+
*/ export class FunctionNamesCache {
|
|
12
|
+
log = createLogger('archiver:data-stores');
|
|
13
|
+
names = new Map();
|
|
14
|
+
/** Adds the given public function signatures to the cache. */ async register(signatures) {
|
|
15
|
+
for (const sig of signatures){
|
|
16
|
+
if (this.names.size > MAX_FUNCTION_SIGNATURES) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const selector = await FunctionSelector.fromSignature(sig);
|
|
21
|
+
this.names.set(selector.toString(), sig.slice(0, sig.indexOf('(')).slice(0, MAX_FUNCTION_NAME_LEN));
|
|
22
|
+
} catch {
|
|
23
|
+
this.log.warn(`Failed to parse signature: ${sig}. Ignoring`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Looks up a function name for the given selector, or returns undefined if not registered. */ get(selector) {
|
|
28
|
+
return this.names.get(selector.toString());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BlockHash, L2Tips } from '@aztec/stdlib/block';
|
|
2
2
|
import type { BlockStore } from './block_store.js';
|
|
3
3
|
/**
|
|
4
4
|
* In-memory cache for L2 chain tips (proposed, checkpointed, proven, finalized).
|
|
5
5
|
* Populated from the BlockStore on first access, then kept up-to-date by the ArchiverDataStoreUpdater.
|
|
6
|
-
* Refresh calls should happen
|
|
6
|
+
* Refresh calls should happen *after* the store transaction that mutates block data has committed,
|
|
7
|
+
* so the cache loads from committed state and is never replaced if the writer aborts.
|
|
7
8
|
*/
|
|
8
9
|
export declare class L2TipsCache {
|
|
9
10
|
#private;
|
|
10
11
|
private blockStore;
|
|
11
|
-
|
|
12
|
+
private readonly initialBlockHash;
|
|
13
|
+
/**
|
|
14
|
+
* The genesis block hash is dynamic — derived from the injected initial header, which depends on
|
|
15
|
+
* `genesisTimestamp` and any prefilled state — so it is supplied here rather than read from store.
|
|
16
|
+
* The genesis checkpoint hash, by contrast, is the static protocol constant and is resolved
|
|
17
|
+
* inside the block store.
|
|
18
|
+
*/
|
|
19
|
+
constructor(blockStore: BlockStore, initialBlockHash: BlockHash);
|
|
12
20
|
/** Returns the cached L2 tips. Loads from the block store on first call. */
|
|
13
21
|
getL2Tips(): Promise<L2Tips>;
|
|
14
|
-
/** Reloads the L2 tips from the block store. Should be called
|
|
22
|
+
/** Reloads the L2 tips from the block store. Should be called after the writer transaction has committed. */
|
|
15
23
|
refresh(): Promise<void>;
|
|
16
|
-
private loadFromStore;
|
|
17
|
-
private getCheckpointIdForBlock;
|
|
18
24
|
}
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
25
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDJfdGlwc19jYWNoZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3N0b3JlL2wyX3RpcHNfY2FjaGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRTdELE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRW5EOzs7OztHQUtHO0FBQ0gscUJBQWEsV0FBVzs7SUFVcEIsT0FBTyxDQUFDLFVBQVU7SUFDbEIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxnQkFBZ0I7SUFSbkM7Ozs7O09BS0c7SUFDSCxZQUNVLFVBQVUsRUFBRSxVQUFVLEVBQ2IsZ0JBQWdCLEVBQUUsU0FBUyxFQUMxQztJQUVKLDRFQUE0RTtJQUNyRSxTQUFTLElBQUksT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUVsQztJQUVELDZHQUE2RztJQUNoRyxPQUFPLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUdwQztDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"l2_tips_cache.d.ts","sourceRoot":"","sources":["../../src/store/l2_tips_cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"l2_tips_cache.d.ts","sourceRoot":"","sources":["../../src/store/l2_tips_cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;GAKG;AACH,qBAAa,WAAW;;IAUpB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IARnC;;;;;OAKG;IACH,YACU,UAAU,EAAE,UAAU,EACb,gBAAgB,EAAE,SAAS,EAC1C;IAEJ,4EAA4E;IACrE,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAElC;IAED,6GAA6G;IAChG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAGpC;CACF"}
|
|
@@ -1,89 +1,26 @@
|
|
|
1
|
-
import { GENESIS_BLOCK_HEADER_HASH, INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
|
-
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
|
-
import { GENESIS_CHECKPOINT_HEADER_HASH } from '@aztec/stdlib/block';
|
|
4
1
|
/**
|
|
5
2
|
* In-memory cache for L2 chain tips (proposed, checkpointed, proven, finalized).
|
|
6
3
|
* Populated from the BlockStore on first access, then kept up-to-date by the ArchiverDataStoreUpdater.
|
|
7
|
-
* Refresh calls should happen
|
|
4
|
+
* Refresh calls should happen *after* the store transaction that mutates block data has committed,
|
|
5
|
+
* so the cache loads from committed state and is never replaced if the writer aborts.
|
|
8
6
|
*/ export class L2TipsCache {
|
|
9
7
|
blockStore;
|
|
8
|
+
initialBlockHash;
|
|
10
9
|
#tipsPromise;
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The genesis block hash is dynamic — derived from the injected initial header, which depends on
|
|
12
|
+
* `genesisTimestamp` and any prefilled state — so it is supplied here rather than read from store.
|
|
13
|
+
* The genesis checkpoint hash, by contrast, is the static protocol constant and is resolved
|
|
14
|
+
* inside the block store.
|
|
15
|
+
*/ constructor(blockStore, initialBlockHash){
|
|
12
16
|
this.blockStore = blockStore;
|
|
17
|
+
this.initialBlockHash = initialBlockHash;
|
|
13
18
|
}
|
|
14
19
|
/** Returns the cached L2 tips. Loads from the block store on first call. */ getL2Tips() {
|
|
15
|
-
return this.#tipsPromise ??= this.
|
|
20
|
+
return this.#tipsPromise ??= this.blockStore.getL2TipsData(this.initialBlockHash);
|
|
16
21
|
}
|
|
17
|
-
/** Reloads the L2 tips from the block store. Should be called
|
|
18
|
-
this.#tipsPromise = this.
|
|
22
|
+
/** Reloads the L2 tips from the block store. Should be called after the writer transaction has committed. */ async refresh() {
|
|
23
|
+
this.#tipsPromise = this.blockStore.getL2TipsData(this.initialBlockHash);
|
|
19
24
|
await this.#tipsPromise;
|
|
20
25
|
}
|
|
21
|
-
async loadFromStore() {
|
|
22
|
-
const [latestBlockNumber, provenBlockNumber, checkpointedBlockNumber, finalizedBlockNumber] = await Promise.all([
|
|
23
|
-
this.blockStore.getLatestBlockNumber(),
|
|
24
|
-
this.blockStore.getProvenBlockNumber(),
|
|
25
|
-
this.blockStore.getCheckpointedL2BlockNumber(),
|
|
26
|
-
this.blockStore.getFinalizedL2BlockNumber()
|
|
27
|
-
]);
|
|
28
|
-
const genesisBlockHeader = {
|
|
29
|
-
blockHash: GENESIS_BLOCK_HEADER_HASH,
|
|
30
|
-
checkpointNumber: CheckpointNumber.ZERO
|
|
31
|
-
};
|
|
32
|
-
const beforeInitialBlockNumber = BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
33
|
-
const getBlockData = (blockNumber)=>blockNumber > beforeInitialBlockNumber ? this.blockStore.getBlockData(blockNumber) : genesisBlockHeader;
|
|
34
|
-
const [latestBlockData, provenBlockData, checkpointedBlockData, finalizedBlockData] = await Promise.all([
|
|
35
|
-
latestBlockNumber,
|
|
36
|
-
provenBlockNumber,
|
|
37
|
-
checkpointedBlockNumber,
|
|
38
|
-
finalizedBlockNumber
|
|
39
|
-
].map(getBlockData));
|
|
40
|
-
if (!latestBlockData || !provenBlockData || !finalizedBlockData || !checkpointedBlockData) {
|
|
41
|
-
throw new Error('Failed to load block data for L2 tips');
|
|
42
|
-
}
|
|
43
|
-
const [provenCheckpointId, finalizedCheckpointId, checkpointedCheckpointId] = await Promise.all([
|
|
44
|
-
this.getCheckpointIdForBlock(provenBlockData),
|
|
45
|
-
this.getCheckpointIdForBlock(finalizedBlockData),
|
|
46
|
-
this.getCheckpointIdForBlock(checkpointedBlockData)
|
|
47
|
-
]);
|
|
48
|
-
return {
|
|
49
|
-
proposed: {
|
|
50
|
-
number: latestBlockNumber,
|
|
51
|
-
hash: latestBlockData.blockHash.toString()
|
|
52
|
-
},
|
|
53
|
-
proven: {
|
|
54
|
-
block: {
|
|
55
|
-
number: provenBlockNumber,
|
|
56
|
-
hash: provenBlockData.blockHash.toString()
|
|
57
|
-
},
|
|
58
|
-
checkpoint: provenCheckpointId
|
|
59
|
-
},
|
|
60
|
-
finalized: {
|
|
61
|
-
block: {
|
|
62
|
-
number: finalizedBlockNumber,
|
|
63
|
-
hash: finalizedBlockData.blockHash.toString()
|
|
64
|
-
},
|
|
65
|
-
checkpoint: finalizedCheckpointId
|
|
66
|
-
},
|
|
67
|
-
checkpointed: {
|
|
68
|
-
block: {
|
|
69
|
-
number: checkpointedBlockNumber,
|
|
70
|
-
hash: checkpointedBlockData.blockHash.toString()
|
|
71
|
-
},
|
|
72
|
-
checkpoint: checkpointedCheckpointId
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
async getCheckpointIdForBlock(blockData) {
|
|
77
|
-
const checkpointData = await this.blockStore.getCheckpointData(blockData.checkpointNumber);
|
|
78
|
-
if (!checkpointData) {
|
|
79
|
-
return {
|
|
80
|
-
number: CheckpointNumber.ZERO,
|
|
81
|
-
hash: GENESIS_CHECKPOINT_HEADER_HASH.toString()
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
number: checkpointData.checkpointNumber,
|
|
86
|
-
hash: checkpointData.header.hash().toString()
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
26
|
}
|