@aztec/prover-node 0.67.1 → 0.68.1
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/config.d.ts +7 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +7 -7
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +7 -8
- package/dest/job/epoch-proving-job.d.ts +3 -1
- package/dest/job/epoch-proving-job.d.ts.map +1 -1
- package/dest/job/epoch-proving-job.js +146 -121
- package/dest/metrics.d.ts +4 -1
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +13 -2
- package/dest/monitors/claims-monitor.d.ts +4 -2
- package/dest/monitors/claims-monitor.d.ts.map +1 -1
- package/dest/monitors/claims-monitor.js +51 -34
- package/dest/monitors/epoch-monitor.d.ts +4 -2
- package/dest/monitors/epoch-monitor.d.ts.map +1 -1
- package/dest/monitors/epoch-monitor.js +47 -31
- package/dest/prover-coordination/factory.d.ts +2 -0
- package/dest/prover-coordination/factory.d.ts.map +1 -1
- package/dest/prover-coordination/factory.js +4 -4
- package/dest/prover-node.d.ts +8 -8
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +225 -212
- package/package.json +22 -20
- package/src/config.ts +7 -7
- package/src/factory.ts +6 -8
- package/src/job/epoch-proving-job.ts +34 -24
- package/src/metrics.ts +14 -2
- package/src/monitors/claims-monitor.ts +13 -3
- package/src/monitors/epoch-monitor.ts +11 -3
- package/src/prover-coordination/factory.ts +11 -2
- package/src/prover-node.ts +26 -22
- package/dest/prover-cache/cache_manager.d.ts +0 -15
- package/dest/prover-cache/cache_manager.d.ts.map +0 -1
- package/dest/prover-cache/cache_manager.js +0 -57
- package/dest/prover-cache/kv_cache.d.ts +0 -11
- package/dest/prover-cache/kv_cache.d.ts.map +0 -1
- package/dest/prover-cache/kv_cache.js +0 -20
- package/src/prover-cache/cache_manager.ts +0 -69
- package/src/prover-cache/kv_cache.ts +0 -27
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { type ProverCache } from '@aztec/circuit-types';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { AztecLmdbStore } from '@aztec/kv-store/lmdb';
|
|
4
|
-
import { InMemoryProverCache } from '@aztec/prover-client';
|
|
5
|
-
|
|
6
|
-
import { type Dirent } from 'fs';
|
|
7
|
-
import { mkdir, readFile, readdir, rm, writeFile } from 'fs/promises';
|
|
8
|
-
import { join } from 'path';
|
|
9
|
-
|
|
10
|
-
import { KVProverCache } from './kv_cache.js';
|
|
11
|
-
|
|
12
|
-
const EPOCH_DIR_PREFIX = 'epoch';
|
|
13
|
-
const EPOCH_DIR_SEPARATOR = '_';
|
|
14
|
-
const EPOCH_HASH_FILENAME = 'epoch_hash.txt';
|
|
15
|
-
|
|
16
|
-
export class ProverCacheManager {
|
|
17
|
-
constructor(private cacheDir?: string, private log = createLogger('prover-node:cache-manager')) {}
|
|
18
|
-
|
|
19
|
-
public async openCache(epochNumber: bigint, epochHash: Buffer): Promise<ProverCache> {
|
|
20
|
-
if (!this.cacheDir) {
|
|
21
|
-
return new InMemoryProverCache();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const epochDir = EPOCH_DIR_PREFIX + EPOCH_DIR_SEPARATOR + epochNumber;
|
|
25
|
-
const dataDir = join(this.cacheDir, epochDir);
|
|
26
|
-
|
|
27
|
-
const storedEpochHash = await readFile(join(dataDir, EPOCH_HASH_FILENAME), 'hex').catch(() => Buffer.alloc(0));
|
|
28
|
-
if (storedEpochHash.toString() !== epochHash.toString()) {
|
|
29
|
-
await rm(dataDir, { recursive: true, force: true });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
await mkdir(dataDir, { recursive: true });
|
|
33
|
-
await writeFile(join(dataDir, EPOCH_HASH_FILENAME), epochHash.toString('hex'));
|
|
34
|
-
|
|
35
|
-
const store = AztecLmdbStore.open(dataDir);
|
|
36
|
-
this.log.debug(`Created new database for epoch ${epochNumber} at ${dataDir}`);
|
|
37
|
-
const cleanup = () => store.close();
|
|
38
|
-
return new KVProverCache(store, cleanup);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Removes all caches for epochs older than the given epoch (including)
|
|
43
|
-
* @param upToAndIncludingEpoch - The epoch number up to which to remove caches
|
|
44
|
-
*/
|
|
45
|
-
public async removeStaleCaches(upToAndIncludingEpoch: bigint): Promise<void> {
|
|
46
|
-
if (!this.cacheDir) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const entries: Dirent[] = await readdir(this.cacheDir, { withFileTypes: true }).catch(() => []);
|
|
51
|
-
|
|
52
|
-
for (const item of entries) {
|
|
53
|
-
if (!item.isDirectory()) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const [prefix, epochNumber] = item.name.split(EPOCH_DIR_SEPARATOR);
|
|
58
|
-
if (prefix !== EPOCH_DIR_PREFIX) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const epochNumberInt = BigInt(epochNumber);
|
|
63
|
-
if (epochNumberInt <= upToAndIncludingEpoch) {
|
|
64
|
-
this.log.info(`Removing old epoch database for epoch ${epochNumberInt} at ${join(this.cacheDir, item.name)}`);
|
|
65
|
-
await rm(join(this.cacheDir, item.name), { recursive: true });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { ProverCache, ProvingJobStatus } from '@aztec/circuit-types';
|
|
2
|
-
import type { AztecKVStore, AztecMap } from '@aztec/kv-store';
|
|
3
|
-
|
|
4
|
-
export class KVProverCache implements ProverCache {
|
|
5
|
-
private proofs: AztecMap<string, string>;
|
|
6
|
-
|
|
7
|
-
constructor(store: AztecKVStore, private cleanup?: () => Promise<void>) {
|
|
8
|
-
this.proofs = store.openMap('prover_node_proof_status');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
getProvingJobStatus(jobId: string): Promise<ProvingJobStatus> {
|
|
12
|
-
const item = this.proofs.get(jobId);
|
|
13
|
-
if (!item) {
|
|
14
|
-
return Promise.resolve({ status: 'not-found' });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return Promise.resolve(JSON.parse(item));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
setProvingJobStatus(jobId: string, status: ProvingJobStatus): Promise<void> {
|
|
21
|
-
return this.proofs.set(jobId, JSON.stringify(status));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async close(): Promise<void> {
|
|
25
|
-
await this.cleanup?.();
|
|
26
|
-
}
|
|
27
|
-
}
|