@aztec/archiver 0.67.1 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/archiver/archiver.d.ts +5 -9
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +570 -563
- package/dest/archiver/archiver_store.d.ts +2 -3
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/config.d.ts +2 -0
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +6 -1
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +30 -9
- package/dest/archiver/instrumentation.d.ts +4 -1
- package/dest/archiver/instrumentation.d.ts.map +1 -1
- package/dest/archiver/instrumentation.js +9 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +3 -4
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +9 -17
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +4 -5
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +8 -15
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +13 -4
- package/package.json +16 -15
- package/src/archiver/archiver.ts +28 -33
- package/src/archiver/archiver_store.ts +2 -4
- package/src/archiver/config.ts +8 -0
- package/src/archiver/data_retrieval.ts +49 -16
- package/src/archiver/instrumentation.ts +14 -0
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +8 -15
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +9 -19
- package/src/factory.ts +14 -3
- package/dest/archiver/kv_archiver_store/contract_artifacts_store.d.ts +0 -10
- package/dest/archiver/kv_archiver_store/contract_artifacts_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_artifacts_store.js +0 -19
- package/src/archiver/kv_archiver_store/contract_artifacts_store.ts +0 -22
|
@@ -8,11 +8,14 @@ import {
|
|
|
8
8
|
type LmdbStatsCallback,
|
|
9
9
|
Metrics,
|
|
10
10
|
type TelemetryClient,
|
|
11
|
+
type Tracer,
|
|
11
12
|
type UpDownCounter,
|
|
12
13
|
ValueType,
|
|
13
14
|
} from '@aztec/telemetry-client';
|
|
14
15
|
|
|
15
16
|
export class ArchiverInstrumentation {
|
|
17
|
+
public readonly tracer: Tracer;
|
|
18
|
+
|
|
16
19
|
private blockHeight: Gauge;
|
|
17
20
|
private blockSize: Gauge;
|
|
18
21
|
private syncDuration: Histogram;
|
|
@@ -20,10 +23,12 @@ export class ArchiverInstrumentation {
|
|
|
20
23
|
private proofsSubmittedDelay: Histogram;
|
|
21
24
|
private proofsSubmittedCount: UpDownCounter;
|
|
22
25
|
private dbMetrics: LmdbMetrics;
|
|
26
|
+
private pruneCount: UpDownCounter;
|
|
23
27
|
|
|
24
28
|
private log = createLogger('archiver:instrumentation');
|
|
25
29
|
|
|
26
30
|
private constructor(private telemetry: TelemetryClient, lmdbStats?: LmdbStatsCallback) {
|
|
31
|
+
this.tracer = telemetry.getTracer('Archiver');
|
|
27
32
|
const meter = telemetry.getMeter('Archiver');
|
|
28
33
|
this.blockHeight = meter.createGauge(Metrics.ARCHIVER_BLOCK_HEIGHT, {
|
|
29
34
|
description: 'The height of the latest block processed by the archiver',
|
|
@@ -64,6 +69,11 @@ export class ArchiverInstrumentation {
|
|
|
64
69
|
},
|
|
65
70
|
lmdbStats,
|
|
66
71
|
);
|
|
72
|
+
|
|
73
|
+
this.pruneCount = meter.createUpDownCounter(Metrics.ARCHIVER_PRUNE_COUNT, {
|
|
74
|
+
description: 'Number of prunes detected',
|
|
75
|
+
valueType: ValueType.INT,
|
|
76
|
+
});
|
|
67
77
|
}
|
|
68
78
|
|
|
69
79
|
public static async new(telemetry: TelemetryClient, lmdbStats?: LmdbStatsCallback) {
|
|
@@ -89,6 +99,10 @@ export class ArchiverInstrumentation {
|
|
|
89
99
|
}
|
|
90
100
|
}
|
|
91
101
|
|
|
102
|
+
public processPrune() {
|
|
103
|
+
this.pruneCount.add(1);
|
|
104
|
+
}
|
|
105
|
+
|
|
92
106
|
public updateLastProvenBlock(blockNumber: number) {
|
|
93
107
|
this.blockHeight.record(blockNumber, { [Attributes.STATUS]: 'proven' });
|
|
94
108
|
}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
type PrivateLog,
|
|
18
18
|
type UnconstrainedFunctionWithMembershipProof,
|
|
19
19
|
} from '@aztec/circuits.js';
|
|
20
|
-
import { type
|
|
20
|
+
import { type FunctionSelector } from '@aztec/foundation/abi';
|
|
21
21
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
22
22
|
import { createLogger } from '@aztec/foundation/log';
|
|
23
23
|
import { type AztecKVStore } from '@aztec/kv-store';
|
|
@@ -26,7 +26,6 @@ import { type ArchiverDataStore, type ArchiverL1SynchPoint } from '../archiver_s
|
|
|
26
26
|
import { type DataRetrieval } from '../structs/data_retrieval.js';
|
|
27
27
|
import { type L1Published } from '../structs/published.js';
|
|
28
28
|
import { BlockStore } from './block_store.js';
|
|
29
|
-
import { ContractArtifactsStore } from './contract_artifacts_store.js';
|
|
30
29
|
import { ContractClassStore } from './contract_class_store.js';
|
|
31
30
|
import { ContractInstanceStore } from './contract_instance_store.js';
|
|
32
31
|
import { LogStore } from './log_store.js';
|
|
@@ -43,7 +42,6 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
43
42
|
#messageStore: MessageStore;
|
|
44
43
|
#contractClassStore: ContractClassStore;
|
|
45
44
|
#contractInstanceStore: ContractInstanceStore;
|
|
46
|
-
#contractArtifactStore: ContractArtifactsStore;
|
|
47
45
|
private functionNames = new Map<string, string>();
|
|
48
46
|
|
|
49
47
|
#log = createLogger('archiver:data-store');
|
|
@@ -54,27 +52,22 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
54
52
|
this.#messageStore = new MessageStore(db);
|
|
55
53
|
this.#contractClassStore = new ContractClassStore(db);
|
|
56
54
|
this.#contractInstanceStore = new ContractInstanceStore(db);
|
|
57
|
-
this.#contractArtifactStore = new ContractArtifactsStore(db);
|
|
58
55
|
this.#nullifierStore = new NullifierStore(db);
|
|
59
56
|
}
|
|
60
57
|
|
|
61
|
-
getContractArtifact(address: AztecAddress): Promise<ContractArtifact | undefined> {
|
|
62
|
-
return Promise.resolve(this.#contractArtifactStore.getContractArtifact(address));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
58
|
// TODO: These function names are in memory only as they are for development/debugging. They require the full contract
|
|
66
59
|
// artifact supplied to the node out of band. This should be reviewed and potentially removed as part of
|
|
67
60
|
// the node api cleanup process.
|
|
68
|
-
getContractFunctionName(
|
|
61
|
+
getContractFunctionName(_address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
69
62
|
return Promise.resolve(this.functionNames.get(selector.toString()));
|
|
70
63
|
}
|
|
71
64
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
65
|
+
registerContractFunctionName(_address: AztecAddress, names: Record<string, string>): Promise<void> {
|
|
66
|
+
for (const [selector, name] of Object.entries(names)) {
|
|
67
|
+
this.functionNames.set(selector, name);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return Promise.resolve();
|
|
78
71
|
}
|
|
79
72
|
|
|
80
73
|
getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
type PrivateLog,
|
|
29
29
|
type UnconstrainedFunctionWithMembershipProof,
|
|
30
30
|
} from '@aztec/circuits.js';
|
|
31
|
-
import { type
|
|
31
|
+
import { type FunctionSelector } from '@aztec/foundation/abi';
|
|
32
32
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
33
33
|
import { createLogger } from '@aztec/foundation/log';
|
|
34
34
|
|
|
@@ -68,8 +68,6 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
68
68
|
*/
|
|
69
69
|
private l1ToL2Messages = new L1ToL2MessageStore();
|
|
70
70
|
|
|
71
|
-
private contractArtifacts: Map<string, ContractArtifact> = new Map();
|
|
72
|
-
|
|
73
71
|
private contractClasses: Map<string, ContractClassPublicWithBlockNumber> = new Map();
|
|
74
72
|
|
|
75
73
|
private bytecodeCommitments: Map<string, Fr> = new Map();
|
|
@@ -86,6 +84,8 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
86
84
|
private lastProvenL2BlockNumber: number = 0;
|
|
87
85
|
private lastProvenL2EpochNumber: number = 0;
|
|
88
86
|
|
|
87
|
+
private functionNames = new Map<string, string>();
|
|
88
|
+
|
|
89
89
|
#log = createLogger('archiver:data-store');
|
|
90
90
|
|
|
91
91
|
constructor(
|
|
@@ -730,26 +730,16 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
730
730
|
});
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
-
public
|
|
734
|
-
this.
|
|
735
|
-
return Promise.resolve();
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
public getContractArtifact(address: AztecAddress): Promise<ContractArtifact | undefined> {
|
|
739
|
-
return Promise.resolve(this.contractArtifacts.get(address.toString()));
|
|
733
|
+
public getContractFunctionName(_address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
734
|
+
return Promise.resolve(this.functionNames.get(selector.toString()));
|
|
740
735
|
}
|
|
741
736
|
|
|
742
|
-
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
if (!artifact) {
|
|
746
|
-
return undefined;
|
|
737
|
+
public registerContractFunctionName(_address: AztecAddress, names: Record<string, string>): Promise<void> {
|
|
738
|
+
for (const [selector, name] of Object.entries(names)) {
|
|
739
|
+
this.functionNames.set(selector, name);
|
|
747
740
|
}
|
|
748
741
|
|
|
749
|
-
|
|
750
|
-
FunctionSelector.fromNameAndParameters({ name: f.name, parameters: f.parameters }).equals(selector),
|
|
751
|
-
);
|
|
752
|
-
return Promise.resolve(func?.name);
|
|
742
|
+
return Promise.resolve();
|
|
753
743
|
}
|
|
754
744
|
|
|
755
745
|
public estimateSize(): { mappingSize: number; actualSize: number; numItems: number } {
|
package/src/factory.ts
CHANGED
|
@@ -4,12 +4,15 @@ import {
|
|
|
4
4
|
computePublicBytecodeCommitment,
|
|
5
5
|
getContractClassFromArtifact,
|
|
6
6
|
} from '@aztec/circuits.js';
|
|
7
|
+
import { FunctionSelector, FunctionType } from '@aztec/foundation/abi';
|
|
7
8
|
import { createLogger } from '@aztec/foundation/log';
|
|
8
9
|
import { type Maybe } from '@aztec/foundation/types';
|
|
9
10
|
import { type DataStoreConfig } from '@aztec/kv-store/config';
|
|
10
11
|
import { createStore } from '@aztec/kv-store/lmdb';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
12
|
+
import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
|
|
13
|
+
import { TokenBridgeContractArtifact } from '@aztec/noir-contracts.js/TokenBridge';
|
|
14
|
+
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
15
|
+
import { getCanonicalProtocolContract } from '@aztec/protocol-contracts/bundle';
|
|
13
16
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
14
17
|
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
|
|
15
18
|
|
|
@@ -43,7 +46,15 @@ async function registerProtocolContracts(store: KVArchiverDataStore) {
|
|
|
43
46
|
privateFunctions: [],
|
|
44
47
|
unconstrainedFunctions: [],
|
|
45
48
|
};
|
|
46
|
-
|
|
49
|
+
|
|
50
|
+
const functionNames: Record<string, string> = {};
|
|
51
|
+
for (const fn of contract.artifact.functions) {
|
|
52
|
+
if (fn.functionType === FunctionType.PUBLIC) {
|
|
53
|
+
functionNames[FunctionSelector.fromNameAndParameters(fn.name, fn.parameters).toString()] = fn.name;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
await store.registerContractFunctionName(contract.address, functionNames);
|
|
47
58
|
const bytecodeCommitment = computePublicBytecodeCommitment(contractClassPublic.packedBytecode);
|
|
48
59
|
await store.addContractClasses([contractClassPublic], [bytecodeCommitment], blockNumber);
|
|
49
60
|
await store.addContractInstances([contract.instance], blockNumber);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type AztecAddress } from '@aztec/circuits.js';
|
|
2
|
-
import { type ContractArtifact } from '@aztec/foundation/abi';
|
|
3
|
-
import { type AztecKVStore } from '@aztec/kv-store';
|
|
4
|
-
export declare class ContractArtifactsStore {
|
|
5
|
-
#private;
|
|
6
|
-
constructor(db: AztecKVStore);
|
|
7
|
-
addContractArtifact(address: AztecAddress, contractArtifact: ContractArtifact): Promise<void>;
|
|
8
|
-
getContractArtifact(address: AztecAddress): ContractArtifact | undefined;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=contract_artifacts_store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract_artifacts_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/kv_archiver_store/contract_artifacts_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,KAAK,YAAY,EAAiB,MAAM,iBAAiB,CAAC;AAGnE,qBAAa,sBAAsB;;gBAGrB,EAAE,EAAE,YAAY;IAI5B,mBAAmB,CAAC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7F,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,gBAAgB,GAAG,SAAS;CAKzE"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var _ContractArtifactsStore_contractArtifacts;
|
|
2
|
-
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
-
import { contractArtifactFromBuffer, contractArtifactToBuffer } from '@aztec/types/abi';
|
|
4
|
-
export class ContractArtifactsStore {
|
|
5
|
-
constructor(db) {
|
|
6
|
-
_ContractArtifactsStore_contractArtifacts.set(this, void 0);
|
|
7
|
-
__classPrivateFieldSet(this, _ContractArtifactsStore_contractArtifacts, db.openMap('archiver_contract_artifacts'), "f");
|
|
8
|
-
}
|
|
9
|
-
addContractArtifact(address, contractArtifact) {
|
|
10
|
-
return __classPrivateFieldGet(this, _ContractArtifactsStore_contractArtifacts, "f").set(address.toString(), contractArtifactToBuffer(contractArtifact));
|
|
11
|
-
}
|
|
12
|
-
getContractArtifact(address) {
|
|
13
|
-
const contractArtifact = __classPrivateFieldGet(this, _ContractArtifactsStore_contractArtifacts, "f").get(address.toString());
|
|
14
|
-
// TODO(@spalladino): AztecMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
|
|
15
|
-
return contractArtifact && contractArtifactFromBuffer(Buffer.from(contractArtifact));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
_ContractArtifactsStore_contractArtifacts = new WeakMap();
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfYXJ0aWZhY3RzX3N0b3JlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FyY2hpdmVyL2t2X2FyY2hpdmVyX3N0b3JlL2NvbnRyYWN0X2FydGlmYWN0c19zdG9yZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUdBLE9BQU8sRUFBRSwwQkFBMEIsRUFBRSx3QkFBd0IsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRXhGLE1BQU0sT0FBTyxzQkFBc0I7SUFHakMsWUFBWSxFQUFnQjtRQUY1Qiw0REFBNkM7UUFHM0MsdUJBQUEsSUFBSSw2Q0FBc0IsRUFBRSxDQUFDLE9BQU8sQ0FBQyw2QkFBNkIsQ0FBQyxNQUFBLENBQUM7SUFDdEUsQ0FBQztJQUVELG1CQUFtQixDQUFDLE9BQXFCLEVBQUUsZ0JBQWtDO1FBQzNFLE9BQU8sdUJBQUEsSUFBSSxpREFBbUIsQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLFFBQVEsRUFBRSxFQUFFLHdCQUF3QixDQUFDLGdCQUFnQixDQUFDLENBQUMsQ0FBQztJQUNyRyxDQUFDO0lBRUQsbUJBQW1CLENBQUMsT0FBcUI7UUFDdkMsTUFBTSxnQkFBZ0IsR0FBRyx1QkFBQSxJQUFJLGlEQUFtQixDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsUUFBUSxFQUFFLENBQUMsQ0FBQztRQUN6RSw0R0FBNEc7UUFDNUcsT0FBTyxnQkFBZ0IsSUFBSSwwQkFBMEIsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLGdCQUFnQixDQUFDLENBQUMsQ0FBQztJQUN2RixDQUFDO0NBQ0YifQ==
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type AztecAddress } from '@aztec/circuits.js';
|
|
2
|
-
import { type ContractArtifact } from '@aztec/foundation/abi';
|
|
3
|
-
import { type AztecKVStore, type AztecMap } from '@aztec/kv-store';
|
|
4
|
-
import { contractArtifactFromBuffer, contractArtifactToBuffer } from '@aztec/types/abi';
|
|
5
|
-
|
|
6
|
-
export class ContractArtifactsStore {
|
|
7
|
-
#contractArtifacts: AztecMap<string, Buffer>;
|
|
8
|
-
|
|
9
|
-
constructor(db: AztecKVStore) {
|
|
10
|
-
this.#contractArtifacts = db.openMap('archiver_contract_artifacts');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
addContractArtifact(address: AztecAddress, contractArtifact: ContractArtifact): Promise<void> {
|
|
14
|
-
return this.#contractArtifacts.set(address.toString(), contractArtifactToBuffer(contractArtifact));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getContractArtifact(address: AztecAddress): ContractArtifact | undefined {
|
|
18
|
-
const contractArtifact = this.#contractArtifacts.get(address.toString());
|
|
19
|
-
// TODO(@spalladino): AztecMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
|
|
20
|
-
return contractArtifact && contractArtifactFromBuffer(Buffer.from(contractArtifact));
|
|
21
|
-
}
|
|
22
|
-
}
|