@aztec/prover-client 0.76.4 → 0.77.0-testnet-ignition.21
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/bin/get-proof-inputs.js +18 -17
- package/dest/block_builder/index.d.ts +1 -1
- package/dest/block_builder/index.d.ts.map +1 -1
- package/dest/block_builder/index.js +0 -1
- package/dest/block_builder/light.d.ts +4 -2
- package/dest/block_builder/light.d.ts.map +1 -1
- package/dest/block_builder/light.js +28 -15
- package/dest/config.d.ts +2 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +10 -12
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/mocks/fixtures.d.ts +4 -3
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +37 -30
- package/dest/mocks/test_context.d.ts +16 -12
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +85 -62
- package/dest/orchestrator/block-building-helpers.d.ts +12 -7
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +98 -87
- package/dest/orchestrator/block-proving-state.d.ts +13 -8
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +101 -73
- package/dest/orchestrator/epoch-proving-state.d.ts +10 -6
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +57 -41
- package/dest/orchestrator/index.js +0 -1
- package/dest/orchestrator/orchestrator.d.ts +7 -5
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +656 -654
- package/dest/orchestrator/orchestrator_metrics.js +4 -3
- package/dest/orchestrator/tx-proving-state.d.ts +7 -4
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +54 -52
- package/dest/prover-client/factory.d.ts +2 -2
- package/dest/prover-client/factory.d.ts.map +1 -1
- package/dest/prover-client/factory.js +0 -1
- package/dest/prover-client/index.js +0 -1
- package/dest/prover-client/prover-client.d.ts +3 -3
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +31 -26
- package/dest/prover-client/server-epoch-prover.d.ts +8 -5
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +4 -4
- package/dest/proving_broker/broker_prover_facade.d.ts +5 -3
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +80 -67
- package/dest/proving_broker/config.d.ts +15 -2
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +49 -44
- 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 +1 -6
- package/dest/proving_broker/fixtures.d.ts +1 -1
- package/dest/proving_broker/fixtures.d.ts.map +1 -1
- package/dest/proving_broker/fixtures.js +2 -2
- package/dest/proving_broker/index.js +0 -1
- package/dest/proving_broker/proof_store/factory.d.ts +1 -1
- package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/factory.js +9 -12
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +3 -2
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.js +12 -7
- package/dest/proving_broker/proof_store/index.js +0 -1
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts +3 -2
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/inline_proof_store.js +11 -7
- package/dest/proving_broker/proof_store/proof_store.d.ts +2 -1
- package/dest/proving_broker/proof_store/proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/proof_store.js +3 -2
- package/dest/proving_broker/proving_agent.d.ts +3 -2
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +121 -124
- package/dest/proving_broker/proving_agent_instrumentation.d.ts +1 -1
- package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent_instrumentation.js +6 -6
- package/dest/proving_broker/proving_broker.d.ts +4 -11
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +490 -446
- package/dest/proving_broker/proving_broker_database/memory.d.ts +2 -2
- package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/memory.js +19 -13
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -3
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +62 -29
- package/dest/proving_broker/proving_broker_database.d.ts +1 -1
- package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database.js +3 -2
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +6 -2
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +47 -22
- package/dest/proving_broker/proving_job_controller.d.ts +2 -1
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +81 -62
- package/dest/proving_broker/rpc.d.ts +4 -3
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +29 -25
- package/dest/test/mock_prover.d.ts +7 -5
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +13 -9
- package/package.json +16 -15
- package/src/bin/get-proof-inputs.ts +5 -6
- package/src/block_builder/index.ts +1 -1
- package/src/block_builder/light.ts +7 -10
- package/src/config.ts +2 -2
- package/src/index.ts +1 -1
- package/src/mocks/fixtures.ts +13 -15
- package/src/mocks/test_context.ts +60 -102
- package/src/orchestrator/block-building-helpers.ts +50 -45
- package/src/orchestrator/block-proving-state.ts +18 -22
- package/src/orchestrator/epoch-proving-state.ts +11 -16
- package/src/orchestrator/orchestrator.ts +26 -33
- package/src/orchestrator/tx-proving-state.ts +10 -13
- package/src/prover-client/factory.ts +2 -2
- package/src/prover-client/prover-client.ts +12 -12
- package/src/prover-client/server-epoch-prover.ts +8 -5
- package/src/proving_broker/broker_prover_facade.ts +29 -31
- package/src/proving_broker/config.ts +31 -3
- package/src/proving_broker/factory.ts +3 -11
- package/src/proving_broker/fixtures.ts +2 -1
- package/src/proving_broker/proof_store/factory.ts +1 -1
- package/src/proving_broker/proof_store/gcs_proof_store.ts +3 -3
- package/src/proving_broker/proof_store/inline_proof_store.ts +5 -5
- package/src/proving_broker/proof_store/proof_store.ts +9 -9
- package/src/proving_broker/proving_agent.ts +11 -11
- package/src/proving_broker/proving_agent_instrumentation.ts +5 -5
- package/src/proving_broker/proving_broker.ts +35 -32
- package/src/proving_broker/proving_broker_database/memory.ts +2 -2
- package/src/proving_broker/proving_broker_database/persisted.ts +8 -8
- package/src/proving_broker/proving_broker_database.ts +1 -1
- package/src/proving_broker/proving_broker_instrumentation.ts +24 -2
- package/src/proving_broker/proving_job_controller.ts +7 -7
- package/src/proving_broker/rpc.ts +6 -7
- package/src/test/mock_prover.ts +28 -30
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ForkMerkleTreeOperations, ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
2
2
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { ProverClientConfig } from '../config.js';
|
|
5
5
|
import { ProverClient } from './prover-client.js';
|
|
6
6
|
|
|
7
7
|
export function createProverClient(
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { type ACVMConfig, type BBConfig, BBNativeRollupProver, TestCircuitProver } from '@aztec/bb-prover';
|
|
2
|
-
import {
|
|
3
|
-
type ActualProverConfig,
|
|
4
|
-
type EpochProver,
|
|
5
|
-
type EpochProverManager,
|
|
6
|
-
type ForkMerkleTreeOperations,
|
|
7
|
-
type ProvingJobBroker,
|
|
8
|
-
type ProvingJobConsumer,
|
|
9
|
-
type ProvingJobProducer,
|
|
10
|
-
type ServerCircuitProver,
|
|
11
|
-
} from '@aztec/circuit-types/interfaces';
|
|
12
|
-
import { Fr } from '@aztec/circuits.js';
|
|
13
2
|
import { times } from '@aztec/foundation/collection';
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
14
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
15
5
|
import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
6
|
+
import type {
|
|
7
|
+
ActualProverConfig,
|
|
8
|
+
EpochProver,
|
|
9
|
+
EpochProverManager,
|
|
10
|
+
ForkMerkleTreeOperations,
|
|
11
|
+
ProvingJobBroker,
|
|
12
|
+
ProvingJobConsumer,
|
|
13
|
+
ProvingJobProducer,
|
|
14
|
+
ServerCircuitProver,
|
|
15
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
16
16
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import type { ProverClientConfig } from '../config.js';
|
|
19
19
|
import { ProvingOrchestrator } from '../orchestrator/orchestrator.js';
|
|
20
20
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
21
21
|
import { InlineProofStore, type ProofStore, createProofStore } from '../proving_broker/proof_store/index.js';
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
3
|
+
import type { EpochProver } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { Proof } from '@aztec/stdlib/proofs';
|
|
5
|
+
import type { RootRollupPublicInputs } from '@aztec/stdlib/rollup';
|
|
6
|
+
import type { BlockHeader, GlobalVariables, ProcessedTx, Tx } from '@aztec/stdlib/tx';
|
|
4
7
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
8
|
+
import type { ProvingOrchestrator } from '../orchestrator/orchestrator.js';
|
|
9
|
+
import type { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
7
10
|
|
|
8
11
|
/** Encapsulates the proving orchestrator and the broker facade */
|
|
9
12
|
export class ServerEpochProver implements EpochProver {
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AVM_PROOF_LENGTH_IN_FIELDS,
|
|
3
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
4
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
5
|
+
RECURSIVE_PROOF_LENGTH,
|
|
6
|
+
TUBE_PROOF_LENGTH,
|
|
7
|
+
} from '@aztec/constants';
|
|
8
|
+
import { sha256 } from '@aztec/foundation/crypto';
|
|
9
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
10
|
+
import { type PromiseWithResolvers, RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
11
|
+
import { truncate } from '@aztec/foundation/string';
|
|
12
|
+
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
1
13
|
import {
|
|
2
14
|
type ProofAndVerificationKey,
|
|
3
15
|
type ProofUri,
|
|
@@ -6,40 +18,26 @@ import {
|
|
|
6
18
|
type ProvingJobProducer,
|
|
7
19
|
type ProvingJobResultsMap,
|
|
8
20
|
type ProvingJobStatus,
|
|
9
|
-
ProvingRequestType,
|
|
10
21
|
type PublicInputsAndRecursiveProof,
|
|
11
22
|
type ServerCircuitProver,
|
|
12
23
|
makeProvingJobId,
|
|
13
|
-
} from '@aztec/
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
type EmptyBlockRootRollupInputs,
|
|
31
|
-
type MergeRollupInputs,
|
|
32
|
-
type PrivateBaseRollupInputs,
|
|
33
|
-
type PublicBaseRollupInputs,
|
|
34
|
-
type RootRollupInputs,
|
|
35
|
-
type RootRollupPublicInputs,
|
|
36
|
-
type SingleTxBlockRootRollupInputs,
|
|
37
|
-
type TubeInputs,
|
|
38
|
-
} from '@aztec/circuits.js/rollup';
|
|
39
|
-
import { sha256 } from '@aztec/foundation/crypto';
|
|
40
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
41
|
-
import { RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
42
|
-
import { truncate } from '@aztec/foundation/string';
|
|
24
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
25
|
+
import type { BaseParityInputs, ParityPublicInputs, RootParityInputs } from '@aztec/stdlib/parity';
|
|
26
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
27
|
+
import type {
|
|
28
|
+
BaseOrMergeRollupPublicInputs,
|
|
29
|
+
BlockMergeRollupInputs,
|
|
30
|
+
BlockRootOrBlockMergePublicInputs,
|
|
31
|
+
BlockRootRollupInputs,
|
|
32
|
+
EmptyBlockRootRollupInputs,
|
|
33
|
+
MergeRollupInputs,
|
|
34
|
+
PrivateBaseRollupInputs,
|
|
35
|
+
PublicBaseRollupInputs,
|
|
36
|
+
RootRollupInputs,
|
|
37
|
+
RootRollupPublicInputs,
|
|
38
|
+
SingleTxBlockRootRollupInputs,
|
|
39
|
+
TubeInputs,
|
|
40
|
+
} from '@aztec/stdlib/rollup';
|
|
43
41
|
|
|
44
42
|
import { InlineProofStore, type ProofStore } from './proof_store/index.js';
|
|
45
43
|
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type ConfigMappingsType,
|
|
3
|
+
booleanConfigHelper,
|
|
4
|
+
getDefaultConfig,
|
|
5
|
+
numberConfigHelper,
|
|
6
|
+
} from '@aztec/foundation/config';
|
|
3
7
|
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
8
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
4
9
|
|
|
5
10
|
import { z } from 'zod';
|
|
6
11
|
|
|
@@ -19,6 +24,8 @@ export const ProverBrokerConfig = z.object({
|
|
|
19
24
|
proverBrokerBatchSize: z.number(),
|
|
20
25
|
/** How often the job batches get flushed */
|
|
21
26
|
proverBrokerBatchIntervalMs: z.number(),
|
|
27
|
+
/** The maximum number of epochs to keep results for */
|
|
28
|
+
proverBrokerMaxEpochsToKeepResultsFor: z.number(),
|
|
22
29
|
});
|
|
23
30
|
|
|
24
31
|
export type ProverBrokerConfig = z.infer<typeof ProverBrokerConfig> &
|
|
@@ -50,9 +57,16 @@ export const proverBrokerConfigMappings: ConfigMappingsType<ProverBrokerConfig>
|
|
|
50
57
|
description: 'How often to flush batches to disk',
|
|
51
58
|
...numberConfigHelper(50),
|
|
52
59
|
},
|
|
60
|
+
proverBrokerMaxEpochsToKeepResultsFor: {
|
|
61
|
+
env: 'PROVER_BROKER_MAX_EPOCHS_TO_KEEP_RESULTS_FOR',
|
|
62
|
+
description: 'The maximum number of epochs to keep results for',
|
|
63
|
+
...numberConfigHelper(1),
|
|
64
|
+
},
|
|
53
65
|
...dataConfigMappings,
|
|
54
66
|
};
|
|
55
67
|
|
|
68
|
+
export const defaultProverBrokerConfig: ProverBrokerConfig = getDefaultConfig(proverBrokerConfigMappings);
|
|
69
|
+
|
|
56
70
|
export const ProverAgentConfig = z.object({
|
|
57
71
|
/** The number of prover agents to start */
|
|
58
72
|
proverAgentCount: z.number(),
|
|
@@ -64,8 +78,12 @@ export const ProverAgentConfig = z.object({
|
|
|
64
78
|
proverBrokerUrl: z.string().optional(),
|
|
65
79
|
/** Whether to construct real proofs */
|
|
66
80
|
realProofs: z.boolean(),
|
|
67
|
-
/**
|
|
81
|
+
/** The type of artificial delay to introduce */
|
|
82
|
+
proverTestDelayType: z.enum(['fixed', 'realistic']),
|
|
83
|
+
/** If using fixed delay, the time each operation takes. */
|
|
68
84
|
proverTestDelayMs: z.number(),
|
|
85
|
+
/** If using realistic delays, what percentage of realistic times to apply. */
|
|
86
|
+
proverTestDelayFactor: z.number(),
|
|
69
87
|
});
|
|
70
88
|
|
|
71
89
|
export type ProverAgentConfig = z.infer<typeof ProverAgentConfig>;
|
|
@@ -99,9 +117,19 @@ export const proverAgentConfigMappings: ConfigMappingsType<ProverAgentConfig> =
|
|
|
99
117
|
description: 'Whether to construct real proofs',
|
|
100
118
|
...booleanConfigHelper(false),
|
|
101
119
|
},
|
|
120
|
+
proverTestDelayType: {
|
|
121
|
+
env: 'PROVER_TEST_DELAY_TYPE',
|
|
122
|
+
description: 'The type of artificial delay to introduce',
|
|
123
|
+
defaultValue: 'fixed',
|
|
124
|
+
},
|
|
102
125
|
proverTestDelayMs: {
|
|
103
126
|
env: 'PROVER_TEST_DELAY_MS',
|
|
104
127
|
description: 'Artificial delay to introduce to all operations to the test prover.',
|
|
105
128
|
...numberConfigHelper(0),
|
|
106
129
|
},
|
|
130
|
+
proverTestDelayFactor: {
|
|
131
|
+
env: 'PROVER_TEST_DELAY_FACTOR',
|
|
132
|
+
description: 'If using realistic delays, what percentage of realistic times to apply.',
|
|
133
|
+
...numberConfigHelper(1),
|
|
134
|
+
},
|
|
107
135
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import type { ProverBrokerConfig } from './config.js';
|
|
4
4
|
import { ProvingBroker } from './proving_broker.js';
|
|
5
5
|
import { InMemoryBrokerDatabase } from './proving_broker_database/memory.js';
|
|
6
6
|
import { KVBrokerDatabase } from './proving_broker_database/persisted.js';
|
|
@@ -11,15 +11,7 @@ export async function createAndStartProvingBroker(
|
|
|
11
11
|
): Promise<ProvingBroker> {
|
|
12
12
|
const database = config.dataDirectory ? await KVBrokerDatabase.new(config, client) : new InMemoryBrokerDatabase();
|
|
13
13
|
|
|
14
|
-
const broker = new ProvingBroker(
|
|
15
|
-
database,
|
|
16
|
-
{
|
|
17
|
-
jobTimeoutMs: config.proverBrokerJobTimeoutMs,
|
|
18
|
-
maxRetries: config.proverBrokerJobMaxRetries,
|
|
19
|
-
timeoutIntervalMs: config.proverBrokerPollIntervalMs,
|
|
20
|
-
},
|
|
21
|
-
client,
|
|
22
|
-
);
|
|
14
|
+
const broker = new ProvingBroker(database, config, client);
|
|
23
15
|
|
|
24
16
|
await broker.start();
|
|
25
17
|
return broker;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type ProofUri, type ProvingJobId, ProvingRequestType, makeProvingJobId } from '@aztec/circuit-types';
|
|
2
1
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
2
|
+
import { type ProofUri, type ProvingJobId, makeProvingJobId } from '@aztec/stdlib/interfaces/server';
|
|
3
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
3
4
|
|
|
4
5
|
export function makeRandomProvingJobId(epochNumber?: number): ProvingJobId {
|
|
5
6
|
return makeProvingJobId(epochNumber ?? 1, ProvingRequestType.BASE_PARITY, randomBytes(8).toString('hex'));
|
|
@@ -2,7 +2,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
2
2
|
|
|
3
3
|
import { GoogleCloudStorageProofStore } from './gcs_proof_store.js';
|
|
4
4
|
import { InlineProofStore } from './inline_proof_store.js';
|
|
5
|
-
import {
|
|
5
|
+
import type { ProofStore } from './proof_store.js';
|
|
6
6
|
|
|
7
7
|
export function createProofStore(config: string | undefined, logger = createLogger('prover-client:proof-store')) {
|
|
8
8
|
if (config === undefined) {
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
type ProvingJobInputsMap,
|
|
6
6
|
type ProvingJobResult,
|
|
7
7
|
type ProvingJobResultsMap,
|
|
8
|
-
ProvingRequestType,
|
|
9
8
|
getProvingJobInputClassFor,
|
|
10
|
-
} from '@aztec/
|
|
9
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
10
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
11
11
|
|
|
12
12
|
import { Storage } from '@google-cloud/storage';
|
|
13
13
|
import { join } from 'path';
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import type { ProofStore } from './proof_store.js';
|
|
16
16
|
|
|
17
17
|
const INPUTS_PATH = 'inputs';
|
|
18
18
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
1
2
|
import {
|
|
2
3
|
type ProofUri,
|
|
3
4
|
type ProvingJobId,
|
|
@@ -5,12 +6,11 @@ import {
|
|
|
5
6
|
type ProvingJobInputsMap,
|
|
6
7
|
ProvingJobResult,
|
|
7
8
|
type ProvingJobResultsMap,
|
|
8
|
-
|
|
9
|
-
} from '@aztec/
|
|
10
|
-
import {
|
|
11
|
-
import { type ZodFor } from '@aztec/foundation/schemas';
|
|
9
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
10
|
+
import type { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
11
|
+
import type { ZodFor } from '@aztec/stdlib/schemas';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import type { ProofStore } from './proof_store.js';
|
|
14
14
|
|
|
15
15
|
// use an ASCII encoded data uri https://datatracker.ietf.org/doc/html/rfc2397#section-2
|
|
16
16
|
// we do this to avoid double encoding to base64 (since the inputs already serialize to a base64 string)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from '@aztec/
|
|
1
|
+
import type {
|
|
2
|
+
ProofUri,
|
|
3
|
+
ProvingJobId,
|
|
4
|
+
ProvingJobInputs,
|
|
5
|
+
ProvingJobInputsMap,
|
|
6
|
+
ProvingJobResult,
|
|
7
|
+
ProvingJobResultsMap,
|
|
8
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
9
|
+
import type { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* A database for storing proof inputs and outputs.
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ProvingError,
|
|
3
|
-
type ProvingJob,
|
|
4
|
-
type ProvingJobConsumer,
|
|
5
|
-
type ProvingJobId,
|
|
6
|
-
type ProvingJobInputs,
|
|
7
|
-
type ProvingJobResultsMap,
|
|
8
|
-
ProvingRequestType,
|
|
9
|
-
type ServerCircuitProver,
|
|
10
|
-
} from '@aztec/circuit-types';
|
|
11
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
12
2
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
13
3
|
import { truncate } from '@aztec/foundation/string';
|
|
14
4
|
import { Timer } from '@aztec/foundation/timer';
|
|
5
|
+
import { ProvingError } from '@aztec/stdlib/errors';
|
|
6
|
+
import type {
|
|
7
|
+
ProvingJob,
|
|
8
|
+
ProvingJobConsumer,
|
|
9
|
+
ProvingJobId,
|
|
10
|
+
ProvingJobInputs,
|
|
11
|
+
ProvingJobResultsMap,
|
|
12
|
+
ServerCircuitProver,
|
|
13
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
14
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
15
15
|
import {
|
|
16
16
|
type TelemetryClient,
|
|
17
17
|
type Traceable,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
trackSpan,
|
|
21
21
|
} from '@aztec/telemetry-client';
|
|
22
22
|
|
|
23
|
-
import {
|
|
23
|
+
import type { ProofStore } from './proof_store/index.js';
|
|
24
24
|
import { ProvingAgentInstrumentation } from './proving_agent_instrumentation.js';
|
|
25
25
|
import { ProvingJobController, ProvingJobControllerStatus } from './proving_job_controller.js';
|
|
26
26
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Timer } from '@aztec/foundation/timer';
|
|
2
2
|
import { type Histogram, Metrics, type TelemetryClient, ValueType } from '@aztec/telemetry-client';
|
|
3
3
|
|
|
4
4
|
export class ProvingAgentInstrumentation {
|
|
@@ -9,13 +9,13 @@ export class ProvingAgentInstrumentation {
|
|
|
9
9
|
|
|
10
10
|
this.idleTime = meter.createHistogram(Metrics.PROVING_AGENT_IDLE, {
|
|
11
11
|
description: 'Records how long an agent was idle',
|
|
12
|
-
unit: '
|
|
13
|
-
valueType: ValueType.
|
|
12
|
+
unit: 's',
|
|
13
|
+
valueType: ValueType.DOUBLE,
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
recordIdleTime(msOrTimer: Timer | number) {
|
|
18
|
-
const duration = typeof msOrTimer === 'number' ? msOrTimer :
|
|
19
|
-
this.idleTime.record(duration);
|
|
18
|
+
const duration = typeof msOrTimer === 'number' ? msOrTimer : msOrTimer.ms();
|
|
19
|
+
this.idleTime.record(duration / 1000);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type GetProvingJobResponse,
|
|
3
|
-
type ProofUri,
|
|
4
|
-
type ProvingJob,
|
|
5
|
-
type ProvingJobConsumer,
|
|
6
|
-
type ProvingJobFilter,
|
|
7
|
-
type ProvingJobId,
|
|
8
|
-
type ProvingJobProducer,
|
|
9
|
-
type ProvingJobSettledResult,
|
|
10
|
-
type ProvingJobStatus,
|
|
11
|
-
ProvingRequestType,
|
|
12
|
-
} from '@aztec/circuit-types';
|
|
13
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
14
2
|
import { type PromiseWithResolvers, RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
15
3
|
import { PriorityMemoryQueue } from '@aztec/foundation/queue';
|
|
16
4
|
import { Timer } from '@aztec/foundation/timer';
|
|
5
|
+
import type {
|
|
6
|
+
GetProvingJobResponse,
|
|
7
|
+
ProofUri,
|
|
8
|
+
ProvingJob,
|
|
9
|
+
ProvingJobConsumer,
|
|
10
|
+
ProvingJobFilter,
|
|
11
|
+
ProvingJobId,
|
|
12
|
+
ProvingJobProducer,
|
|
13
|
+
ProvingJobSettledResult,
|
|
14
|
+
ProvingJobStatus,
|
|
15
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
16
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
17
17
|
import {
|
|
18
18
|
type TelemetryClient,
|
|
19
19
|
type Traceable,
|
|
@@ -24,7 +24,8 @@ import {
|
|
|
24
24
|
|
|
25
25
|
import assert from 'assert';
|
|
26
26
|
|
|
27
|
-
import { type
|
|
27
|
+
import { type ProverBrokerConfig, defaultProverBrokerConfig } from './config.js';
|
|
28
|
+
import type { ProvingBrokerDatabase } from './proving_broker_database.js';
|
|
28
29
|
import { type MonitorCallback, ProvingBrokerInstrumentation } from './proving_broker_instrumentation.js';
|
|
29
30
|
|
|
30
31
|
type InProgressMetadata = {
|
|
@@ -33,14 +34,6 @@ type InProgressMetadata = {
|
|
|
33
34
|
lastUpdatedAt: number;
|
|
34
35
|
};
|
|
35
36
|
|
|
36
|
-
type ProofRequestBrokerConfig = {
|
|
37
|
-
timeoutIntervalMs?: number;
|
|
38
|
-
jobTimeoutMs?: number;
|
|
39
|
-
maxRetries?: number;
|
|
40
|
-
maxEpochsToKeepResultsFor?: number;
|
|
41
|
-
maxParallelCleanUps?: number;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
37
|
type EnqueuedProvingJob = Pick<ProvingJob, 'id' | 'epochNumber'>;
|
|
45
38
|
|
|
46
39
|
/**
|
|
@@ -115,20 +108,28 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
115
108
|
public constructor(
|
|
116
109
|
private database: ProvingBrokerDatabase,
|
|
117
110
|
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}:
|
|
111
|
+
proverBrokerJobTimeoutMs,
|
|
112
|
+
proverBrokerPollIntervalMs,
|
|
113
|
+
proverBrokerJobMaxRetries,
|
|
114
|
+
proverBrokerMaxEpochsToKeepResultsFor,
|
|
115
|
+
}: Required<
|
|
116
|
+
Pick<
|
|
117
|
+
ProverBrokerConfig,
|
|
118
|
+
| 'proverBrokerJobTimeoutMs'
|
|
119
|
+
| 'proverBrokerPollIntervalMs'
|
|
120
|
+
| 'proverBrokerJobMaxRetries'
|
|
121
|
+
| 'proverBrokerMaxEpochsToKeepResultsFor'
|
|
122
|
+
>
|
|
123
|
+
> = defaultProverBrokerConfig,
|
|
123
124
|
client: TelemetryClient = getTelemetryClient(),
|
|
124
125
|
private logger = createLogger('prover-client:proving-broker'),
|
|
125
126
|
) {
|
|
126
127
|
this.tracer = client.getTracer('ProvingBroker');
|
|
127
128
|
this.instrumentation = new ProvingBrokerInstrumentation(client);
|
|
128
|
-
this.cleanupPromise = new RunningPromise(this.cleanupPass.bind(this), this.logger,
|
|
129
|
-
this.jobTimeoutMs =
|
|
130
|
-
this.maxRetries =
|
|
131
|
-
this.maxEpochsToKeepResultsFor =
|
|
129
|
+
this.cleanupPromise = new RunningPromise(this.cleanupPass.bind(this), this.logger, proverBrokerPollIntervalMs);
|
|
130
|
+
this.jobTimeoutMs = proverBrokerJobTimeoutMs!;
|
|
131
|
+
this.maxRetries = proverBrokerJobMaxRetries!;
|
|
132
|
+
this.maxEpochsToKeepResultsFor = proverBrokerMaxEpochsToKeepResultsFor!;
|
|
132
133
|
}
|
|
133
134
|
|
|
134
135
|
private measureQueueDepth: MonitorCallback = (type: ProvingRequestType) => {
|
|
@@ -237,10 +238,11 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
237
238
|
if (this.jobsCache.has(job.id)) {
|
|
238
239
|
const existing = this.jobsCache.get(job.id);
|
|
239
240
|
assert.deepStrictEqual(job, existing, 'Duplicate proving job ID');
|
|
240
|
-
this.logger.
|
|
241
|
+
this.logger.warn(`Cached proving job id=${job.id} epochNumber=${job.epochNumber}. Not enqueuing again`, {
|
|
241
242
|
provingJobId: job.id,
|
|
242
243
|
});
|
|
243
|
-
|
|
244
|
+
this.instrumentation.incCachedJobs(job.type);
|
|
245
|
+
return jobStatus;
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
if (this.isJobStale(job)) {
|
|
@@ -256,6 +258,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
|
|
|
256
258
|
this.jobsCache.set(job.id, job);
|
|
257
259
|
await this.database.addProvingJob(job);
|
|
258
260
|
this.enqueueJobInternal(job);
|
|
261
|
+
this.instrumentation.incTotalJobs(job.type);
|
|
259
262
|
} catch (err) {
|
|
260
263
|
this.logger.error(`Failed to save proving job id=${job.id}: ${err}`, err, { provingJobId: job.id });
|
|
261
264
|
this.jobsCache.delete(job.id);
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
type ProvingJobId,
|
|
5
5
|
type ProvingJobSettledResult,
|
|
6
6
|
getEpochFromProvingJobId,
|
|
7
|
-
} from '@aztec/
|
|
7
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import type { ProvingBrokerDatabase } from '../proving_broker_database.js';
|
|
10
10
|
|
|
11
11
|
export class InMemoryBrokerDatabase implements ProvingBrokerDatabase {
|
|
12
12
|
private jobs = new Map<ProvingJobId, ProvingJob>();
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
+
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
2
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { BatchQueue } from '@aztec/foundation/queue';
|
|
4
|
+
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
5
|
+
import { AztecLMDBStoreV2 } from '@aztec/kv-store/lmdb-v2';
|
|
1
6
|
import {
|
|
2
7
|
type ProofUri,
|
|
3
8
|
ProvingJob,
|
|
4
9
|
type ProvingJobId,
|
|
5
10
|
ProvingJobSettledResult,
|
|
6
11
|
getEpochFromProvingJobId,
|
|
7
|
-
} from '@aztec/
|
|
8
|
-
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
9
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
10
|
-
import { BatchQueue } from '@aztec/foundation/queue';
|
|
11
|
-
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
12
|
-
import { AztecLMDBStoreV2 } from '@aztec/kv-store/lmdb-v2';
|
|
12
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
13
13
|
import { Attributes, LmdbMetrics, type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
14
|
|
|
15
15
|
import { mkdir, readdir } from 'fs/promises';
|
|
16
16
|
import { join } from 'path';
|
|
17
17
|
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
18
|
+
import type { ProverBrokerConfig } from '../config.js';
|
|
19
|
+
import type { ProvingBrokerDatabase } from '../proving_broker_database.js';
|
|
20
20
|
|
|
21
21
|
class SingleEpochDatabase {
|
|
22
22
|
private jobs: AztecAsyncMap<ProvingJobId, string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ProofUri, ProvingJob, ProvingJobId, ProvingJobSettledResult } from '@aztec/stdlib/interfaces/server';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A database for storing proof requests and their results
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Timer } from '@aztec/foundation/timer';
|
|
2
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
3
3
|
import {
|
|
4
4
|
Attributes,
|
|
5
5
|
type Histogram,
|
|
@@ -19,6 +19,8 @@ export class ProvingBrokerInstrumentation {
|
|
|
19
19
|
private resolvedJobs: UpDownCounter;
|
|
20
20
|
private rejectedJobs: UpDownCounter;
|
|
21
21
|
private timedOutJobs: UpDownCounter;
|
|
22
|
+
private cachedJobs: UpDownCounter;
|
|
23
|
+
private totalJobs: UpDownCounter;
|
|
22
24
|
private jobWait: Histogram;
|
|
23
25
|
private jobDuration: Histogram;
|
|
24
26
|
private retriedJobs: UpDownCounter;
|
|
@@ -50,6 +52,14 @@ export class ProvingBrokerInstrumentation {
|
|
|
50
52
|
valueType: ValueType.INT,
|
|
51
53
|
});
|
|
52
54
|
|
|
55
|
+
this.cachedJobs = meter.createUpDownCounter(Metrics.PROVING_QUEUE_CACHED_JOBS, {
|
|
56
|
+
valueType: ValueType.INT,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
this.totalJobs = meter.createUpDownCounter(Metrics.PROVING_QUEUE_TOTAL_JOBS, {
|
|
60
|
+
valueType: ValueType.INT,
|
|
61
|
+
});
|
|
62
|
+
|
|
53
63
|
this.jobWait = meter.createHistogram(Metrics.PROVING_QUEUE_JOB_WAIT, {
|
|
54
64
|
description: 'Records how long a job sits in the queue',
|
|
55
65
|
unit: 'ms',
|
|
@@ -95,6 +105,18 @@ export class ProvingBrokerInstrumentation {
|
|
|
95
105
|
});
|
|
96
106
|
}
|
|
97
107
|
|
|
108
|
+
incCachedJobs(proofType: ProvingRequestType) {
|
|
109
|
+
this.cachedJobs.add(1, {
|
|
110
|
+
[Attributes.PROVING_JOB_TYPE]: ProvingRequestType[proofType],
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
incTotalJobs(proofType: ProvingRequestType) {
|
|
115
|
+
this.totalJobs.add(1, {
|
|
116
|
+
[Attributes.PROVING_JOB_TYPE]: ProvingRequestType[proofType],
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
98
120
|
recordJobWait(proofType: ProvingRequestType, msOrTimer: Timer | number) {
|
|
99
121
|
const duration = typeof msOrTimer === 'number' ? msOrTimer : Math.floor(msOrTimer.ms());
|
|
100
122
|
this.jobWait.record(duration, {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '@aztec/
|
|
1
|
+
import type {
|
|
2
|
+
ProvingJobId,
|
|
3
|
+
ProvingJobInputs,
|
|
4
|
+
ProvingJobResultsMap,
|
|
5
|
+
ServerCircuitProver,
|
|
6
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
7
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
8
8
|
|
|
9
9
|
export enum ProvingJobControllerStatus {
|
|
10
10
|
IDLE = 'idle',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { createSafeJsonRpcClient } from '@aztec/foundation/json-rpc/client';
|
|
2
|
+
import type { SafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
1
3
|
import {
|
|
2
|
-
type ComponentsVersions,
|
|
3
4
|
type GetProvingJobResponse,
|
|
4
5
|
ProofUri,
|
|
5
6
|
ProvingJob,
|
|
@@ -8,12 +9,10 @@ import {
|
|
|
8
9
|
ProvingJobId,
|
|
9
10
|
type ProvingJobProducer,
|
|
10
11
|
ProvingJobStatus,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from '@aztec/
|
|
14
|
-
import {
|
|
15
|
-
import { type SafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
16
|
-
import { type ApiSchemaFor, optional } from '@aztec/foundation/schemas';
|
|
12
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
13
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
14
|
+
import { type ApiSchemaFor, optional } from '@aztec/stdlib/schemas';
|
|
15
|
+
import { type ComponentsVersions, getVersioningResponseHandler } from '@aztec/stdlib/versioning';
|
|
17
16
|
import { createTracedJsonRpcServer, makeTracedFetch } from '@aztec/telemetry-client';
|
|
18
17
|
|
|
19
18
|
import { z } from 'zod';
|