@aztec/prover-client 0.0.0-test.0 → 0.0.1-commit.0208eb9
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 +8 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +12 -2
- package/dest/index.d.ts +1 -1
- package/dest/light/index.d.ts +2 -0
- package/dest/light/index.d.ts.map +1 -0
- package/dest/light/index.js +1 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts +47 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
- package/dest/light/lightweight_checkpoint_builder.js +200 -0
- package/dest/mocks/fixtures.d.ts +8 -8
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +36 -17
- package/dest/mocks/test_context.d.ts +43 -32
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +149 -87
- package/dest/orchestrator/block-building-helpers.d.ts +37 -30
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +170 -189
- package/dest/orchestrator/block-proving-state.d.ts +70 -48
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +282 -177
- package/dest/orchestrator/checkpoint-proving-state.d.ts +76 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-proving-state.js +243 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +43 -28
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +177 -73
- package/dest/orchestrator/index.d.ts +1 -1
- package/dest/orchestrator/orchestrator.d.ts +53 -35
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +855 -302
- package/dest/orchestrator/orchestrator_metrics.d.ts +1 -1
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +2 -6
- package/dest/orchestrator/tx-proving-state.d.ts +15 -12
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +27 -44
- package/dest/prover-client/factory.d.ts +3 -3
- package/dest/prover-client/factory.d.ts.map +1 -1
- package/dest/prover-client/index.d.ts +1 -1
- package/dest/prover-client/prover-client.d.ts +7 -7
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +19 -13
- package/dest/prover-client/server-epoch-prover.d.ts +16 -12
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +11 -11
- package/dest/proving_broker/broker_prover_facade.d.ts +28 -19
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +62 -43
- package/dest/proving_broker/config.d.ts +31 -10
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +41 -7
- package/dest/proving_broker/factory.d.ts +2 -2
- package/dest/proving_broker/factory.d.ts.map +1 -1
- package/dest/proving_broker/factory.js +5 -1
- package/dest/proving_broker/fixtures.d.ts +3 -2
- package/dest/proving_broker/fixtures.d.ts.map +1 -1
- package/dest/proving_broker/fixtures.js +3 -2
- package/dest/proving_broker/index.d.ts +1 -1
- package/dest/proving_broker/proof_store/factory.d.ts +2 -5
- package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/factory.js +7 -30
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
- package/dest/proving_broker/proof_store/index.d.ts +2 -1
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -0
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts +1 -1
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/proof_store.d.ts +1 -1
- package/dest/proving_broker/proving_agent.d.ts +8 -12
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +86 -65
- package/dest/proving_broker/proving_broker.d.ts +17 -5
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +69 -34
- package/dest/proving_broker/proving_broker_database/memory.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/memory.js +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +5 -3
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +401 -11
- package/dest/proving_broker/proving_broker_database.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +15 -35
- package/dest/proving_broker/proving_job_controller.d.ts +11 -10
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +92 -62
- package/dest/proving_broker/rpc.d.ts +7 -7
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +9 -4
- package/dest/test/mock_proof_store.d.ts +9 -0
- package/dest/test/mock_proof_store.d.ts.map +1 -0
- package/dest/test/mock_proof_store.js +10 -0
- package/dest/test/mock_prover.d.ts +23 -17
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +38 -20
- package/package.json +33 -31
- package/src/config.ts +25 -9
- package/src/light/index.ts +1 -0
- package/src/light/lightweight_checkpoint_builder.ts +289 -0
- package/src/mocks/fixtures.ts +46 -40
- package/src/mocks/test_context.ts +223 -116
- package/src/orchestrator/block-building-helpers.ts +258 -334
- package/src/orchestrator/block-proving-state.ts +325 -231
- package/src/orchestrator/checkpoint-proving-state.ts +349 -0
- package/src/orchestrator/epoch-proving-state.ts +237 -111
- package/src/orchestrator/orchestrator.ts +653 -343
- package/src/orchestrator/orchestrator_metrics.ts +2 -6
- package/src/orchestrator/tx-proving-state.ts +48 -66
- package/src/prover-client/factory.ts +6 -2
- package/src/prover-client/prover-client.ts +47 -37
- package/src/prover-client/server-epoch-prover.ts +40 -22
- package/src/proving_broker/broker_prover_facade.ts +212 -131
- package/src/proving_broker/config.ts +47 -7
- package/src/proving_broker/factory.ts +2 -1
- package/src/proving_broker/fixtures.ts +8 -3
- package/src/proving_broker/proof_store/factory.ts +10 -32
- package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
- package/src/proving_broker/proof_store/index.ts +1 -0
- package/src/proving_broker/proof_store/inline_proof_store.ts +1 -1
- package/src/proving_broker/proving_agent.ts +95 -66
- package/src/proving_broker/proving_broker.ts +87 -42
- package/src/proving_broker/proving_broker_database/memory.ts +3 -2
- package/src/proving_broker/proving_broker_database/persisted.ts +29 -13
- package/src/proving_broker/proving_broker_database.ts +2 -1
- package/src/proving_broker/proving_broker_instrumentation.ts +14 -35
- package/src/proving_broker/proving_job_controller.ts +100 -83
- package/src/proving_broker/rpc.ts +14 -5
- package/src/test/mock_proof_store.ts +14 -0
- package/src/test/mock_prover.ts +156 -64
- package/dest/bin/get-proof-inputs.d.ts +0 -2
- package/dest/bin/get-proof-inputs.d.ts.map +0 -1
- package/dest/bin/get-proof-inputs.js +0 -51
- package/dest/block_builder/index.d.ts +0 -6
- package/dest/block_builder/index.d.ts.map +0 -1
- package/dest/block_builder/index.js +0 -1
- package/dest/block_builder/light.d.ts +0 -33
- package/dest/block_builder/light.d.ts.map +0 -1
- package/dest/block_builder/light.js +0 -82
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -51
- package/dest/proving_broker/proving_agent_instrumentation.d.ts +0 -8
- package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +0 -1
- package/dest/proving_broker/proving_agent_instrumentation.js +0 -16
- package/src/bin/get-proof-inputs.ts +0 -59
- package/src/block_builder/index.ts +0 -6
- package/src/block_builder/light.ts +0 -101
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -72
- package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import { AVM_INPUTS_FILENAME } from '@aztec/bb-prover';
|
|
3
|
-
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { type ProofUri, ProvingJobInputs } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
7
|
-
|
|
8
|
-
import { mkdirSync, writeFileSync } from 'fs';
|
|
9
|
-
|
|
10
|
-
import { createProofStoreForUri } from '../proving_broker/index.js';
|
|
11
|
-
|
|
12
|
-
const logger = createLogger('prover-client:get-proof-inputs');
|
|
13
|
-
|
|
14
|
-
function printUsage() {
|
|
15
|
-
console.error('Usage: get-proof-inputs <proof-uri> [out-dir=.]');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async function main() {
|
|
19
|
-
if (process.argv[2] === '--help') {
|
|
20
|
-
printUsage();
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const uri = process.argv[2];
|
|
25
|
-
const outDir = process.argv[3] || '.';
|
|
26
|
-
if (!uri) {
|
|
27
|
-
printUsage();
|
|
28
|
-
throw new Error('Missing proof URI');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
mkdirSync(outDir, { recursive: true });
|
|
32
|
-
|
|
33
|
-
const proofStore = createProofStoreForUri(uri);
|
|
34
|
-
logger.info(`Processing uri ${uri}`);
|
|
35
|
-
const input = await proofStore.getProofInput(uri as ProofUri);
|
|
36
|
-
logger.info(`Found inputs for ${ProvingRequestType[input.type]}`);
|
|
37
|
-
writeProofInputs(input, outDir);
|
|
38
|
-
|
|
39
|
-
console.log((await jsonParseWithSchema(jsonStringify(input), ProvingJobInputs)).inputs);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// This mimics the behavior of bb-prover/src/bb/execute.ts
|
|
43
|
-
function writeProofInputs(input: ProvingJobInputs, outDir: string) {
|
|
44
|
-
switch (input.type) {
|
|
45
|
-
case ProvingRequestType.PUBLIC_VM: {
|
|
46
|
-
writeFileSync(`${outDir}/${AVM_INPUTS_FILENAME}`, input.inputs.serializeWithMessagePack());
|
|
47
|
-
logger.info(`Wrote AVM inputs to ${AVM_INPUTS_FILENAME}`);
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
default: {
|
|
51
|
-
throw new Error(`Unimplemented proving request type: ${ProvingRequestType[input.type]}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
main().catch(err => {
|
|
57
|
-
console.error(err);
|
|
58
|
-
process.exit(1);
|
|
59
|
-
});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { SpongeBlob } from '@aztec/blob-lib';
|
|
2
|
-
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
3
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
-
import { L2Block } from '@aztec/stdlib/block';
|
|
7
|
-
import type { BlockBuilder, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
8
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
9
|
-
import { type GlobalVariables, type ProcessedTx, toNumBlobFields } from '@aztec/stdlib/tx';
|
|
10
|
-
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
buildBaseRollupHints,
|
|
14
|
-
buildHeaderAndBodyFromTxs,
|
|
15
|
-
getTreeSnapshot,
|
|
16
|
-
} from '../orchestrator/block-building-helpers.js';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
20
|
-
*/
|
|
21
|
-
export class LightweightBlockBuilder implements BlockBuilder {
|
|
22
|
-
private spongeBlobState?: SpongeBlob;
|
|
23
|
-
private globalVariables?: GlobalVariables;
|
|
24
|
-
private l1ToL2Messages?: Fr[];
|
|
25
|
-
|
|
26
|
-
private txs: ProcessedTx[] = [];
|
|
27
|
-
|
|
28
|
-
private readonly logger = createLogger('prover-client:block_builder');
|
|
29
|
-
|
|
30
|
-
constructor(private db: MerkleTreeWriteOperations, private telemetry: TelemetryClient = getTelemetryClient()) {}
|
|
31
|
-
|
|
32
|
-
async startNewBlock(globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void> {
|
|
33
|
-
this.logger.debug('Starting new block', { globalVariables: globalVariables.toInspect(), l1ToL2Messages });
|
|
34
|
-
this.globalVariables = globalVariables;
|
|
35
|
-
this.l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
36
|
-
this.txs = [];
|
|
37
|
-
this.spongeBlobState = undefined;
|
|
38
|
-
|
|
39
|
-
// Update L1 to L2 tree
|
|
40
|
-
await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages!);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async addTxs(txs: ProcessedTx[]): Promise<void> {
|
|
44
|
-
this.spongeBlobState = SpongeBlob.init(toNumBlobFields(txs));
|
|
45
|
-
for (const tx of txs) {
|
|
46
|
-
this.logger.debug('Adding new tx to block', { txHash: tx.hash.toString() });
|
|
47
|
-
this.txs.push(tx);
|
|
48
|
-
await buildBaseRollupHints(tx, this.globalVariables!, this.db, this.spongeBlobState!);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
setBlockCompleted(): Promise<L2Block> {
|
|
53
|
-
return this.buildBlock();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
private async buildBlock(): Promise<L2Block> {
|
|
57
|
-
const { header, body } = await buildHeaderAndBodyFromTxs(
|
|
58
|
-
this.txs,
|
|
59
|
-
this.globalVariables!,
|
|
60
|
-
this.l1ToL2Messages!,
|
|
61
|
-
this.db,
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
await this.db.updateArchive(header);
|
|
65
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
66
|
-
|
|
67
|
-
const block = new L2Block(newArchive, header, body);
|
|
68
|
-
this.logger.debug(`Built block ${block.number}`, {
|
|
69
|
-
globalVariables: this.globalVariables?.toInspect(),
|
|
70
|
-
archiveRoot: newArchive.root.toString(),
|
|
71
|
-
blockHash: block.hash.toString(),
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
return block;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export class LightweightBlockBuilderFactory {
|
|
79
|
-
constructor(private telemetry: TelemetryClient = getTelemetryClient()) {}
|
|
80
|
-
|
|
81
|
-
create(db: MerkleTreeWriteOperations): BlockBuilder {
|
|
82
|
-
return new LightweightBlockBuilder(db, this.telemetry);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Creates a block builder under the hood with the given txs and messages and creates a block.
|
|
88
|
-
* @param db - A db fork to use for block building.
|
|
89
|
-
*/
|
|
90
|
-
export async function buildBlock(
|
|
91
|
-
txs: ProcessedTx[],
|
|
92
|
-
globalVariables: GlobalVariables,
|
|
93
|
-
l1ToL2Messages: Fr[],
|
|
94
|
-
db: MerkleTreeWriteOperations,
|
|
95
|
-
telemetry: TelemetryClient = getTelemetryClient(),
|
|
96
|
-
) {
|
|
97
|
-
const builder = new LightweightBlockBuilder(db, telemetry);
|
|
98
|
-
await builder.startNewBlock(globalVariables, l1ToL2Messages);
|
|
99
|
-
await builder.addTxs(txs);
|
|
100
|
-
return await builder.setBlockCompleted();
|
|
101
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ProofUri,
|
|
3
|
-
type ProvingJobId,
|
|
4
|
-
type ProvingJobInputs,
|
|
5
|
-
type ProvingJobInputsMap,
|
|
6
|
-
type ProvingJobResult,
|
|
7
|
-
type ProvingJobResultsMap,
|
|
8
|
-
getProvingJobInputClassFor,
|
|
9
|
-
} from '@aztec/stdlib/interfaces/server';
|
|
10
|
-
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
11
|
-
|
|
12
|
-
import { Storage } from '@google-cloud/storage';
|
|
13
|
-
import { join } from 'path';
|
|
14
|
-
|
|
15
|
-
import type { ProofStore } from './proof_store.js';
|
|
16
|
-
|
|
17
|
-
const INPUTS_PATH = 'inputs';
|
|
18
|
-
|
|
19
|
-
export class GoogleCloudStorageProofStore implements ProofStore {
|
|
20
|
-
private readonly storage: Storage;
|
|
21
|
-
|
|
22
|
-
constructor(private readonly bucketName: string, private readonly path: string) {
|
|
23
|
-
this.storage = new Storage();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public async saveProofInput<T extends ProvingRequestType>(
|
|
27
|
-
id: ProvingJobId,
|
|
28
|
-
type: T,
|
|
29
|
-
inputs: ProvingJobInputsMap[T],
|
|
30
|
-
): Promise<ProofUri> {
|
|
31
|
-
const path = join(this.path, INPUTS_PATH, ProvingRequestType[type], id);
|
|
32
|
-
const file = this.storage.bucket(this.bucketName).file(path);
|
|
33
|
-
await file.save(inputs.toBuffer());
|
|
34
|
-
return file.cloudStorageURI.toString() as ProofUri;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
saveProofOutput<T extends ProvingRequestType>(
|
|
38
|
-
_id: ProvingJobId,
|
|
39
|
-
_type: T,
|
|
40
|
-
_result: ProvingJobResultsMap[T],
|
|
41
|
-
): Promise<ProofUri> {
|
|
42
|
-
throw new Error('Not implemented');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public async getProofInput(uri: ProofUri): Promise<ProvingJobInputs> {
|
|
46
|
-
try {
|
|
47
|
-
const url = new URL(uri);
|
|
48
|
-
const bucket = this.storage.bucket(url.host);
|
|
49
|
-
const path = url.pathname.replace(/^\/+/, '');
|
|
50
|
-
const file = bucket.file(path);
|
|
51
|
-
if (!(await file.exists())) {
|
|
52
|
-
throw new Error(`File at ${uri} does not exist`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const typeString = path.split('/').at(-2);
|
|
56
|
-
const type = typeString ? ProvingRequestType[typeString as keyof typeof ProvingRequestType] : undefined;
|
|
57
|
-
if (type === undefined) {
|
|
58
|
-
throw new Error(`Unrecognized proof type ${type} in path ${path}`);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const contents = await file.download();
|
|
62
|
-
const inputs = getProvingJobInputClassFor(type).fromBuffer(contents[0]);
|
|
63
|
-
return { inputs, type } as ProvingJobInputs;
|
|
64
|
-
} catch (err) {
|
|
65
|
-
throw new Error(`Error getting proof input at ${uri}: ${err}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
getProofOutput(_uri: ProofUri): Promise<ProvingJobResult> {
|
|
70
|
-
throw new Error('Not implemented');
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Timer } from '@aztec/foundation/timer';
|
|
2
|
-
import { type Histogram, Metrics, type TelemetryClient, ValueType } from '@aztec/telemetry-client';
|
|
3
|
-
|
|
4
|
-
export class ProvingAgentInstrumentation {
|
|
5
|
-
private idleTime: Histogram;
|
|
6
|
-
|
|
7
|
-
constructor(client: TelemetryClient, name = 'ProvingAgent') {
|
|
8
|
-
const meter = client.getMeter(name);
|
|
9
|
-
|
|
10
|
-
this.idleTime = meter.createHistogram(Metrics.PROVING_AGENT_IDLE, {
|
|
11
|
-
description: 'Records how long an agent was idle',
|
|
12
|
-
unit: 's',
|
|
13
|
-
valueType: ValueType.DOUBLE,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
recordIdleTime(msOrTimer: Timer | number) {
|
|
18
|
-
const duration = typeof msOrTimer === 'number' ? msOrTimer : msOrTimer.ms();
|
|
19
|
-
this.idleTime.record(duration / 1000);
|
|
20
|
-
}
|
|
21
|
-
}
|