@aztec/archiver 0.0.1-commit.e558bd1c → 0.0.1-commit.e5a3663dd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/dest/archiver.d.ts +26 -15
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +161 -153
- package/dest/config.d.ts +5 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +16 -4
- package/dest/errors.d.ts +61 -10
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +88 -14
- package/dest/factory.d.ts +6 -7
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +40 -32
- package/dest/index.d.ts +11 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +10 -2
- package/dest/l1/bin/retrieve-calldata.js +32 -28
- package/dest/l1/calldata_retriever.d.ts +74 -50
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +197 -260
- package/dest/l1/data_retrieval.d.ts +26 -17
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +42 -47
- package/dest/l1/spire_proposer.d.ts +5 -5
- package/dest/l1/spire_proposer.d.ts.map +1 -1
- package/dest/l1/spire_proposer.js +9 -17
- 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 +42 -0
- package/dest/modules/data_source_base.d.ts +27 -14
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +98 -125
- package/dest/modules/data_store_updater.d.ts +37 -17
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +155 -112
- package/dest/modules/instrumentation.d.ts +21 -3
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +41 -8
- package/dest/modules/l1_synchronizer.d.ts +13 -11
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +355 -182
- 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 +107 -31
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +477 -141
- 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 +50 -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 +20 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +109 -0
- package/dest/store/log_store.d.ts +6 -3
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +95 -20
- 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 +25 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +166 -32
- package/dest/test/mock_archiver.d.ts +1 -1
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +3 -2
- 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 +35 -5
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +182 -89
- 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 +7 -4
- package/dest/test/noop_l1_archiver.d.ts.map +1 -1
- package/dest/test/noop_l1_archiver.js +14 -8
- package/package.json +13 -13
- package/src/archiver.ts +199 -174
- package/src/config.ts +23 -2
- package/src/errors.ts +133 -22
- package/src/factory.ts +53 -30
- package/src/index.ts +18 -2
- package/src/l1/README.md +25 -68
- package/src/l1/bin/retrieve-calldata.ts +40 -27
- package/src/l1/calldata_retriever.ts +261 -379
- package/src/l1/data_retrieval.ts +58 -69
- package/src/l1/spire_proposer.ts +7 -15
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/modules/contract_data_source_adapter.ts +59 -0
- package/src/modules/data_source_base.ts +142 -144
- package/src/modules/data_store_updater.ts +187 -141
- package/src/modules/instrumentation.ts +56 -9
- package/src/modules/l1_synchronizer.ts +463 -218
- package/src/modules/validation.ts +10 -9
- package/src/store/block_store.ts +587 -177
- package/src/store/contract_class_store.ts +31 -103
- package/src/store/contract_instance_store.ts +51 -5
- package/src/store/data_stores.ts +108 -0
- package/src/store/function_names_cache.ts +37 -0
- package/src/store/l2_tips_cache.ts +134 -0
- package/src/store/log_store.ts +128 -32
- package/src/store/message_store.ts +60 -10
- package/src/structs/inbox_message.ts +1 -1
- package/src/test/fake_l1_state.ts +213 -42
- package/src/test/mock_archiver.ts +3 -2
- package/src/test/mock_l1_to_l2_message_source.ts +1 -0
- package/src/test/mock_l2_block_source.ts +230 -82
- package/src/test/mock_structs.ts +20 -6
- package/src/test/noop_l1_archiver.ts +16 -8
- package/dest/store/kv_archiver_store.d.ts +0 -340
- package/dest/store/kv_archiver_store.d.ts.map +0 -1
- package/dest/store/kv_archiver_store.js +0 -446
- package/src/store/kv_archiver_store.ts +0 -639
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfY2xhc3Nfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yZS9jb250cmFjdF9jbGFzc19zdG9yZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFHcEQsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQ1YsbUJBQW1CLEVBRW5CLGlDQUFpQyxFQUNsQyxNQUFNLHdCQUF3QixDQUFDO0FBRWhDOztHQUVHO0FBQ0gscUJBQWEsa0JBQWtCOztJQUlqQixPQUFPLENBQUMsRUFBRTtJQUF0QixZQUFvQixFQUFFLEVBQUUsaUJBQWlCLEVBR3hDO0lBRUQ7Ozs7O09BS0c7SUFDRyxrQkFBa0IsQ0FBQyxJQUFJLEVBQUUsaUNBQWlDLEVBQUUsRUFBRSxXQUFXLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FJekc7SUFFRDs7Ozs7T0FLRztJQUNHLHFCQUFxQixDQUFDLElBQUksRUFBRSxtQkFBbUIsRUFBRSxFQUFFLFdBQVcsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUU5RjtJQUVLLGdCQUFnQixDQUNwQixhQUFhLEVBQUUsbUJBQW1CLEVBQ2xDLGtCQUFrQixFQUFFLEVBQUUsRUFDdEIsV0FBVyxFQUFFLE1BQU0sR0FDbEIsT0FBTyxDQUFDLElBQUksQ0FBQyxDQVlmO0lBRUssbUJBQW1CLENBQUMsYUFBYSxFQUFFLG1CQUFtQixFQUFFLFdBQVcsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQVFoRztJQUVLLGdCQUFnQixDQUFDLEVBQUUsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLG1CQUFtQixHQUFHLFNBQVMsQ0FBQyxDQUd2RTtJQUVLLHFCQUFxQixDQUFDLEVBQUUsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLEVBQUUsR0FBRyxTQUFTLENBQUMsQ0FHM0Q7SUFFSyxtQkFBbUIsSUFBSSxPQUFPLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FFekM7Q0FDRiJ9
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfaW5zdGFuY2Vfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yZS9jb250cmFjdF9pbnN0YW5jZV9zdG9yZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEVBQ0wsS0FBSyxpQ0FBaUMsRUFDdEMsS0FBSywyQkFBMkIsRUFHakMsTUFBTSx3QkFBd0IsQ0FBQztBQUNoQyxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUVsRCxLQUFLLHlCQUF5QixHQUFHLENBQUM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AG,OAAO,CAAC,OAAO,CAAC,CAI/G;IAED;;;;;OAKG;IACG,6BAA6B,CAAC,IAAI,EAAE,iCAAiC,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAIlH;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 { ContractDataSource } from '@aztec/stdlib/contract';
|
|
4
|
+
import { BlockStore } from './block_store.js';
|
|
5
|
+
import { ContractClassStore } from './contract_class_store.js';
|
|
6
|
+
import { ContractInstanceStore } from './contract_instance_store.js';
|
|
7
|
+
import { FunctionNamesCache } from './function_names_cache.js';
|
|
8
|
+
import { LogStore } from './log_store.js';
|
|
9
|
+
import { MessageStore } from './message_store.js';
|
|
10
|
+
export declare const ARCHIVER_DB_VERSION = 6;
|
|
11
|
+
/**
|
|
12
|
+
* Represents the latest L1 block processed by the archiver for various objects in L2.
|
|
13
|
+
*/
|
|
14
|
+
export type ArchiverL1SynchPoint = {
|
|
15
|
+
/** Number of the last L1 block that added a new L2 checkpoint metadata. */
|
|
16
|
+
blocksSynchedTo?: bigint;
|
|
17
|
+
/** Last L1 block checked for L1 to L2 messages. */
|
|
18
|
+
messagesSynchedTo?: L1BlockId;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Bundle of archiver-owned LMDB substores plus the in-memory caches that span them.
|
|
22
|
+
*
|
|
23
|
+
* Replaces the former `KVArchiverDataStore` pass-through wrapper. Callers reach into
|
|
24
|
+
* the relevant substore directly (e.g. `stores.blocks.getBlock`) and use
|
|
25
|
+
* {@link createArchiverDataStores} to wire them up against a shared KV store.
|
|
26
|
+
*/
|
|
27
|
+
export type ArchiverDataStores = {
|
|
28
|
+
/** The underlying key-value store. Use {@link AztecAsyncKVStore.transactionAsync} to compose updates atomically. */
|
|
29
|
+
db: AztecAsyncKVStore;
|
|
30
|
+
/** Blocks, checkpoints, tx effects, proven/finalized state. */
|
|
31
|
+
blocks: BlockStore;
|
|
32
|
+
/** Public, private and contract class logs. */
|
|
33
|
+
logs: LogStore;
|
|
34
|
+
/** L1 to L2 messages and message sync state. */
|
|
35
|
+
messages: MessageStore;
|
|
36
|
+
/** Contract classes (with bytecode commitments). */
|
|
37
|
+
contractClasses: ContractClassStore;
|
|
38
|
+
/** Contract instances and contract instance updates. */
|
|
39
|
+
contractInstances: ContractInstanceStore;
|
|
40
|
+
/** In-memory cache of public function selectors -> names. */
|
|
41
|
+
functionNames: FunctionNamesCache;
|
|
42
|
+
};
|
|
43
|
+
/** Options used by {@link createArchiverDataStores}. */
|
|
44
|
+
export type CreateArchiverDataStoresOptions = {
|
|
45
|
+
/** Maximum number of logs returned per page when paginating tagged log queries. */
|
|
46
|
+
logsMaxPageSize?: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Wires up the archiver substores against a shared KV store and returns the
|
|
50
|
+
* {@link ArchiverDataStores} bundle.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createArchiverDataStores(db: AztecAsyncKVStore, opts?: CreateArchiverDataStoresOptions): 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YV9zdG9yZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yZS9kYXRhX3N0b3Jlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUMxRCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFLakUsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBQzlDLE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQy9ELE9BQU8sRUFBRSxxQkFBcUIsRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBQ3JFLE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQy9ELE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUMxQyxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFbEQsZUFBTyxNQUFNLG1CQUFtQixJQUFJLENBQUM7QUFFckM7O0dBRUc7QUFDSCxNQUFNLE1BQU0sb0JBQW9CLEdBQUc7SUFDakMsNEVBQTRFO0lBQzVFLGVBQWUsQ0FBQyxFQ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AAC;IACpC,wDAAwD;IACxD,iBAAiB,EAAE,qBAAqB,CAAC;IACzC,6DAA6D;IAC7D,aAAa,EAAE,kBAAkB,CAAC;CACnC,CAAC;AAEF,wDAAwD;AACxD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,mFAAmF;IACnF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,iBAAiB,EACrB,IAAI,GAAE,+BAAoC,GACzC,kBAAkB,CAWpB;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,50 @@
|
|
|
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 = 6;
|
|
10
|
+
/**
|
|
11
|
+
* Wires up the archiver substores against a shared KV store and returns the
|
|
12
|
+
* {@link ArchiverDataStores} bundle.
|
|
13
|
+
*/ export function createArchiverDataStores(db, opts = {}) {
|
|
14
|
+
const blocks = new BlockStore(db);
|
|
15
|
+
return {
|
|
16
|
+
db,
|
|
17
|
+
blocks,
|
|
18
|
+
logs: new LogStore(db, blocks, opts.logsMaxPageSize ?? 1000),
|
|
19
|
+
messages: new MessageStore(db),
|
|
20
|
+
contractClasses: new ContractClassStore(db),
|
|
21
|
+
contractInstances: new ContractInstanceStore(db),
|
|
22
|
+
functionNames: new FunctionNamesCache()
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the L1 sync point of the archiver, combining the block sync point from {@link BlockStore}
|
|
27
|
+
* and the message sync point from {@link MessageStore}.
|
|
28
|
+
*/ export async function getArchiverSynchPoint(stores) {
|
|
29
|
+
const [blocksSynchedTo, messagesSynchedTo] = await Promise.all([
|
|
30
|
+
stores.blocks.getSynchedL1BlockNumber(),
|
|
31
|
+
stores.messages.getSynchedL1Block()
|
|
32
|
+
]);
|
|
33
|
+
return {
|
|
34
|
+
blocksSynchedTo,
|
|
35
|
+
messagesSynchedTo
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Backs up the underlying KV store to the given folder. Returns the path to the resulting db file.
|
|
40
|
+
*/ export async function backupArchiverDataStores(stores, path, compress = true) {
|
|
41
|
+
await stores.db.backupTo(path, compress);
|
|
42
|
+
return join(path, 'data.mdb');
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns a {@link ContractDataSource} adapter over {@link ArchiverDataStores}.
|
|
46
|
+
* Used by contexts (e.g. offline epoch re-prover tools) that need a ContractDataSource
|
|
47
|
+
* but do not need a full archiver instance.
|
|
48
|
+
*/ export function createContractDataSource(stores) {
|
|
49
|
+
return new ArchiverContractDataSourceAdapter(stores);
|
|
50
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type L2Tips } from '@aztec/stdlib/block';
|
|
2
|
+
import type { BlockStore } from './block_store.js';
|
|
3
|
+
/**
|
|
4
|
+
* In-memory cache for L2 chain tips (proposed, checkpointed, proven, finalized).
|
|
5
|
+
* Populated from the BlockStore on first access, then kept up-to-date by the ArchiverDataStoreUpdater.
|
|
6
|
+
* Refresh calls should happen within the store transaction that mutates block data to ensure consistency.
|
|
7
|
+
*/
|
|
8
|
+
export declare class L2TipsCache {
|
|
9
|
+
#private;
|
|
10
|
+
private blockStore;
|
|
11
|
+
constructor(blockStore: BlockStore);
|
|
12
|
+
/** Returns the cached L2 tips. Loads from the block store on first call. */
|
|
13
|
+
getL2Tips(): Promise<L2Tips>;
|
|
14
|
+
/** Reloads the L2 tips from the block store. Should be called within the store transaction that mutates data. */
|
|
15
|
+
refresh(): Promise<void>;
|
|
16
|
+
private loadFromStore;
|
|
17
|
+
private getCheckpointIdForProposedCheckpoint;
|
|
18
|
+
private getCheckpointIdForBlock;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDJfdGlwc19jYWNoZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3N0b3JlL2wyX3RpcHNfY2FjaGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUtMLEtBQUssTUFBTSxFQUNaLE1BQU0scUJBQXFCLENBQUM7QUFFN0IsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFbkQ7Ozs7R0FJRztBQUNILHFCQUFhLFdBQVc7O0lBR1YsT0FBTyxDQUFDLFVBQVU7SUFBOUIsWUFBb0IsVUFBVSxFQUFFLFVBQVUsRUFBSTtJQUU5Qyw0RUFBNEU7SUFDckUsU0FBUyxJQUFJLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FFbEM7SUFFRCxpSEFBaUg7SUFDcEcsT0FBTyxJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FHcEM7WUFFYSxhQUFhO1lBMEViLG9DQUFvQztZQWFwQyx1QkFBdUI7Q0FhdEMifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"l2_tips_cache.d.ts","sourceRoot":"","sources":["../../src/store/l2_tips_cache.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,MAAM,EACZ,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;GAIG;AACH,qBAAa,WAAW;;IAGV,OAAO,CAAC,UAAU;IAA9B,YAAoB,UAAU,EAAE,UAAU,EAAI;IAE9C,4EAA4E;IACrE,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAElC;IAED,iHAAiH;IACpG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAGpC;YAEa,aAAa;YA0Eb,oCAAoC;YAapC,uBAAuB;CAatC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { GENESIS_BLOCK_HEADER_HASH, GENESIS_CHECKPOINT_HEADER_HASH } from '@aztec/stdlib/block';
|
|
4
|
+
/**
|
|
5
|
+
* In-memory cache for L2 chain tips (proposed, checkpointed, proven, finalized).
|
|
6
|
+
* Populated from the BlockStore on first access, then kept up-to-date by the ArchiverDataStoreUpdater.
|
|
7
|
+
* Refresh calls should happen within the store transaction that mutates block data to ensure consistency.
|
|
8
|
+
*/ export class L2TipsCache {
|
|
9
|
+
blockStore;
|
|
10
|
+
#tipsPromise;
|
|
11
|
+
constructor(blockStore){
|
|
12
|
+
this.blockStore = blockStore;
|
|
13
|
+
}
|
|
14
|
+
/** Returns the cached L2 tips. Loads from the block store on first call. */ getL2Tips() {
|
|
15
|
+
return this.#tipsPromise ??= this.loadFromStore();
|
|
16
|
+
}
|
|
17
|
+
/** Reloads the L2 tips from the block store. Should be called within the store transaction that mutates data. */ async refresh() {
|
|
18
|
+
this.#tipsPromise = this.loadFromStore();
|
|
19
|
+
await this.#tipsPromise;
|
|
20
|
+
}
|
|
21
|
+
async loadFromStore() {
|
|
22
|
+
const [latestBlockNumber, provenBlockNumber, proposedCheckpointBlockNumber, checkpointedBlockNumber, finalizedBlockNumber] = await Promise.all([
|
|
23
|
+
this.blockStore.getLatestL2BlockNumber(),
|
|
24
|
+
this.blockStore.getProvenBlockNumber(),
|
|
25
|
+
this.blockStore.getProposedCheckpointL2BlockNumber(),
|
|
26
|
+
this.blockStore.getCheckpointedL2BlockNumber(),
|
|
27
|
+
this.blockStore.getFinalizedL2BlockNumber()
|
|
28
|
+
]);
|
|
29
|
+
const genesisBlockHeader = {
|
|
30
|
+
blockHash: GENESIS_BLOCK_HEADER_HASH,
|
|
31
|
+
checkpointNumber: CheckpointNumber.ZERO
|
|
32
|
+
};
|
|
33
|
+
const beforeInitialBlockNumber = BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
34
|
+
const getBlockData = (blockNumber)=>blockNumber > beforeInitialBlockNumber ? this.blockStore.getBlockData(blockNumber) : genesisBlockHeader;
|
|
35
|
+
const [latestBlockData, provenBlockData, proposedCheckpointBlockData, checkpointedBlockData, finalizedBlockData] = await Promise.all([
|
|
36
|
+
latestBlockNumber,
|
|
37
|
+
provenBlockNumber,
|
|
38
|
+
proposedCheckpointBlockNumber,
|
|
39
|
+
checkpointedBlockNumber,
|
|
40
|
+
finalizedBlockNumber
|
|
41
|
+
].map(getBlockData));
|
|
42
|
+
if (!latestBlockData || !provenBlockData || !finalizedBlockData || !checkpointedBlockData || !proposedCheckpointBlockData) {
|
|
43
|
+
throw new Error('Failed to load block data for L2 tips');
|
|
44
|
+
}
|
|
45
|
+
const [provenCheckpointId, finalizedCheckpointId, proposedCheckpointId, checkpointedCheckpointId] = await Promise.all([
|
|
46
|
+
this.getCheckpointIdForBlock(provenBlockData),
|
|
47
|
+
this.getCheckpointIdForBlock(finalizedBlockData),
|
|
48
|
+
this.getCheckpointIdForProposedCheckpoint(checkpointedBlockData),
|
|
49
|
+
this.getCheckpointIdForBlock(checkpointedBlockData)
|
|
50
|
+
]);
|
|
51
|
+
return {
|
|
52
|
+
proposed: {
|
|
53
|
+
number: latestBlockNumber,
|
|
54
|
+
hash: latestBlockData.blockHash.toString()
|
|
55
|
+
},
|
|
56
|
+
proven: {
|
|
57
|
+
block: {
|
|
58
|
+
number: provenBlockNumber,
|
|
59
|
+
hash: provenBlockData.blockHash.toString()
|
|
60
|
+
},
|
|
61
|
+
checkpoint: provenCheckpointId
|
|
62
|
+
},
|
|
63
|
+
proposedCheckpoint: {
|
|
64
|
+
block: {
|
|
65
|
+
number: proposedCheckpointBlockNumber,
|
|
66
|
+
hash: proposedCheckpointBlockData.blockHash.toString()
|
|
67
|
+
},
|
|
68
|
+
checkpoint: proposedCheckpointId
|
|
69
|
+
},
|
|
70
|
+
finalized: {
|
|
71
|
+
block: {
|
|
72
|
+
number: finalizedBlockNumber,
|
|
73
|
+
hash: finalizedBlockData.blockHash.toString()
|
|
74
|
+
},
|
|
75
|
+
checkpoint: finalizedCheckpointId
|
|
76
|
+
},
|
|
77
|
+
checkpointed: {
|
|
78
|
+
block: {
|
|
79
|
+
number: checkpointedBlockNumber,
|
|
80
|
+
hash: checkpointedBlockData.blockHash.toString()
|
|
81
|
+
},
|
|
82
|
+
checkpoint: checkpointedCheckpointId
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
async getCheckpointIdForProposedCheckpoint(checkpointedBlockData) {
|
|
87
|
+
const checkpointData = await this.blockStore.getLastProposedCheckpoint();
|
|
88
|
+
if (!checkpointData) {
|
|
89
|
+
return this.getCheckpointIdForBlock(checkpointedBlockData);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
number: checkpointData.checkpointNumber,
|
|
93
|
+
hash: checkpointData.header.hash().toString()
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async getCheckpointIdForBlock(blockData) {
|
|
97
|
+
const checkpointData = await this.blockStore.getCheckpointData(blockData.checkpointNumber);
|
|
98
|
+
if (!checkpointData) {
|
|
99
|
+
return {
|
|
100
|
+
number: CheckpointNumber.ZERO,
|
|
101
|
+
hash: GENESIS_CHECKPOINT_HEADER_HASH.toString()
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
number: checkpointData.checkpointNumber,
|
|
106
|
+
hash: checkpointData.header.hash().toString()
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|