@aztec/prover-client 0.0.1-commit.fcb71a6 → 0.0.1-commit.ff7989d6c
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/light/lightweight_checkpoint_builder.d.ts +18 -6
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +73 -18
- package/dest/mocks/fixtures.d.ts +1 -1
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +2 -1
- package/dest/mocks/test_context.d.ts +4 -2
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +17 -3
- package/dest/orchestrator/block-building-helpers.d.ts +5 -5
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +4 -4
- package/dest/orchestrator/block-proving-state.d.ts +4 -1
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +7 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts +17 -4
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +37 -4
- package/dest/orchestrator/epoch-proving-state.d.ts +7 -6
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +37 -1
- package/dest/orchestrator/orchestrator.d.ts +18 -3
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +541 -126
- 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 +5 -4
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +6 -6
- 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 +15 -10
- package/dest/proving_broker/broker_prover_facade.d.ts +7 -5
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +3 -3
- package/dest/proving_broker/config.d.ts +13 -1
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +19 -2
- 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 -2
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -1
- package/dest/proving_broker/proving_agent.d.ts +5 -9
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +4 -19
- package/dest/proving_broker/proving_broker.d.ts +7 -4
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +30 -11
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +389 -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 +4 -3
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +6 -3
- package/dest/proving_broker/rpc.d.ts +4 -2
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +8 -0
- package/dest/test/mock_proof_store.d.ts +3 -3
- package/dest/test/mock_proof_store.d.ts.map +1 -1
- package/dest/test/mock_prover.d.ts +5 -5
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +3 -3
- package/package.json +16 -17
- package/src/light/lightweight_checkpoint_builder.ts +115 -19
- package/src/mocks/fixtures.ts +2 -1
- package/src/mocks/test_context.ts +12 -2
- package/src/orchestrator/block-building-helpers.ts +4 -4
- package/src/orchestrator/block-proving-state.ts +9 -0
- package/src/orchestrator/checkpoint-proving-state.ts +51 -5
- package/src/orchestrator/epoch-proving-state.ts +59 -9
- package/src/orchestrator/orchestrator.ts +141 -106
- package/src/orchestrator/orchestrator_metrics.ts +2 -6
- package/src/orchestrator/tx-proving-state.ts +8 -11
- package/src/prover-client/prover-client.ts +28 -21
- package/src/proving_broker/broker_prover_facade.ts +8 -6
- package/src/proving_broker/config.ts +22 -0
- 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 -1
- package/src/proving_broker/proving_agent.ts +6 -19
- package/src/proving_broker/proving_broker.ts +31 -9
- package/src/proving_broker/proving_broker_database/persisted.ts +15 -1
- package/src/proving_broker/proving_broker_instrumentation.ts +14 -35
- package/src/proving_broker/proving_job_controller.ts +9 -3
- package/src/proving_broker/rpc.ts +14 -0
- package/src/test/mock_prover.ts +1 -8
- package/dest/block-factory/index.d.ts +0 -2
- package/dest/block-factory/index.d.ts.map +0 -1
- package/dest/block-factory/index.js +0 -1
- package/dest/block-factory/light.d.ts +0 -38
- package/dest/block-factory/light.d.ts.map +0 -1
- package/dest/block-factory/light.js +0 -108
- 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 -52
- 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/block-factory/index.ts +0 -1
- package/src/block-factory/light.ts +0 -137
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
- package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
type ObservableResult,
|
|
9
9
|
type TelemetryClient,
|
|
10
10
|
type UpDownCounter,
|
|
11
|
-
|
|
11
|
+
createUpDownCounterWithDefault,
|
|
12
12
|
} from '@aztec/telemetry-client';
|
|
13
13
|
|
|
14
14
|
export type MonitorCallback = (proofType: ProvingRequestType) => number;
|
|
@@ -28,49 +28,28 @@ export class ProvingBrokerInstrumentation {
|
|
|
28
28
|
constructor(client: TelemetryClient, name = 'ProvingBroker') {
|
|
29
29
|
const meter = client.getMeter(name);
|
|
30
30
|
|
|
31
|
-
this.queueSize = meter.createObservableGauge(Metrics.PROVING_QUEUE_SIZE
|
|
32
|
-
valueType: ValueType.INT,
|
|
33
|
-
});
|
|
31
|
+
this.queueSize = meter.createObservableGauge(Metrics.PROVING_QUEUE_SIZE);
|
|
34
32
|
|
|
35
|
-
this.activeJobs = meter.createObservableGauge(Metrics.PROVING_QUEUE_ACTIVE_JOBS
|
|
36
|
-
valueType: ValueType.INT,
|
|
37
|
-
});
|
|
33
|
+
this.activeJobs = meter.createObservableGauge(Metrics.PROVING_QUEUE_ACTIVE_JOBS);
|
|
38
34
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
35
|
+
const provingJobTypes = Object.values(ProvingRequestType).filter(v => typeof v === 'string');
|
|
36
|
+
const provingJobAttrs = { [Attributes.PROVING_JOB_TYPE]: provingJobTypes };
|
|
42
37
|
|
|
43
|
-
this.
|
|
44
|
-
valueType: ValueType.INT,
|
|
45
|
-
});
|
|
38
|
+
this.resolvedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_RESOLVED_JOBS, provingJobAttrs);
|
|
46
39
|
|
|
47
|
-
this.
|
|
48
|
-
valueType: ValueType.INT,
|
|
49
|
-
});
|
|
40
|
+
this.rejectedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_REJECTED_JOBS, provingJobAttrs);
|
|
50
41
|
|
|
51
|
-
this.
|
|
52
|
-
valueType: ValueType.INT,
|
|
53
|
-
});
|
|
42
|
+
this.retriedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_RETRIED_JOBS, provingJobAttrs);
|
|
54
43
|
|
|
55
|
-
this.
|
|
56
|
-
valueType: ValueType.INT,
|
|
57
|
-
});
|
|
44
|
+
this.timedOutJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_TIMED_OUT_JOBS, provingJobAttrs);
|
|
58
45
|
|
|
59
|
-
this.
|
|
60
|
-
valueType: ValueType.INT,
|
|
61
|
-
});
|
|
46
|
+
this.cachedJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_CACHED_JOBS, provingJobAttrs);
|
|
62
47
|
|
|
63
|
-
this.
|
|
64
|
-
description: 'Records how long a job sits in the queue',
|
|
65
|
-
unit: 'ms',
|
|
66
|
-
valueType: ValueType.INT,
|
|
67
|
-
});
|
|
48
|
+
this.totalJobs = createUpDownCounterWithDefault(meter, Metrics.PROVING_QUEUE_TOTAL_JOBS, provingJobAttrs);
|
|
68
49
|
|
|
69
|
-
this.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
valueType: ValueType.INT,
|
|
73
|
-
});
|
|
50
|
+
this.jobWait = meter.createHistogram(Metrics.PROVING_QUEUE_JOB_WAIT);
|
|
51
|
+
|
|
52
|
+
this.jobDuration = meter.createHistogram(Metrics.PROVING_QUEUE_JOB_DURATION);
|
|
74
53
|
}
|
|
75
54
|
|
|
76
55
|
monitorQueueDepth(fn: MonitorCallback) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
3
3
|
import { AbortError } from '@aztec/foundation/error';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import type {
|
|
6
6
|
ProvingJobId,
|
|
7
7
|
ProvingJobInputs,
|
|
@@ -21,6 +21,7 @@ export class ProvingJobController {
|
|
|
21
21
|
private promise?: Promise<void>;
|
|
22
22
|
private abortController = new AbortController();
|
|
23
23
|
private result?: ProvingJobResultsMap[ProvingRequestType] | Error;
|
|
24
|
+
private log: Logger;
|
|
24
25
|
|
|
25
26
|
constructor(
|
|
26
27
|
private jobId: ProvingJobId,
|
|
@@ -29,8 +30,13 @@ export class ProvingJobController {
|
|
|
29
30
|
private startedAt: number,
|
|
30
31
|
private circuitProver: ServerCircuitProver,
|
|
31
32
|
private onComplete: () => void,
|
|
32
|
-
|
|
33
|
-
) {
|
|
33
|
+
bindings?: LoggerBindings,
|
|
34
|
+
) {
|
|
35
|
+
this.log = createLogger('prover-client:proving-agent:job-controller', {
|
|
36
|
+
instanceId: randomBytes(4).toString('hex'),
|
|
37
|
+
...bindings,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
34
40
|
|
|
35
41
|
public start(): void {
|
|
36
42
|
if (this.status !== ProvingJobControllerStatus.IDLE) {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { EpochNumberSchema } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { createSafeJsonRpcClient } from '@aztec/foundation/json-rpc/client';
|
|
2
3
|
import {
|
|
3
4
|
type GetProvingJobResponse,
|
|
4
5
|
ProofUri,
|
|
5
6
|
ProvingJob,
|
|
6
7
|
type ProvingJobBroker,
|
|
8
|
+
type ProvingJobBrokerDebug,
|
|
7
9
|
type ProvingJobConsumer,
|
|
8
10
|
ProvingJobId,
|
|
9
11
|
type ProvingJobProducer,
|
|
@@ -53,6 +55,18 @@ export const ProvingJobBrokerSchema: ApiSchemaFor<ProvingJobBroker> = {
|
|
|
53
55
|
...ProvingJobProducerSchema,
|
|
54
56
|
};
|
|
55
57
|
|
|
58
|
+
export const ProvingJobBrokerDebugSchema: ApiSchemaFor<ProvingJobBrokerDebug> = {
|
|
59
|
+
replayProvingJob: z
|
|
60
|
+
.function()
|
|
61
|
+
.args(ProvingJobId, z.nativeEnum(ProvingRequestType), EpochNumberSchema, ProofUri)
|
|
62
|
+
.returns(ProvingJobStatus),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const ProvingJobBrokerSchemaWithDebug: ApiSchemaFor<ProvingJobBroker & ProvingJobBrokerDebug> = {
|
|
66
|
+
...ProvingJobBrokerSchema,
|
|
67
|
+
...ProvingJobBrokerDebugSchema,
|
|
68
|
+
};
|
|
69
|
+
|
|
56
70
|
export function createProvingJobBrokerClient(
|
|
57
71
|
url: string,
|
|
58
72
|
versions: Partial<ComponentsVersions>,
|
package/src/test/mock_prover.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED,
|
|
3
|
-
AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED,
|
|
4
3
|
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
5
4
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
6
5
|
RECURSIVE_PROOF_LENGTH,
|
|
@@ -14,7 +13,6 @@ import {
|
|
|
14
13
|
type ProvingJobStatus,
|
|
15
14
|
type PublicInputsAndRecursiveProof,
|
|
16
15
|
type ServerCircuitProver,
|
|
17
|
-
makeProofAndVerificationKey,
|
|
18
16
|
makePublicInputsAndRecursiveProof,
|
|
19
17
|
} from '@aztec/stdlib/interfaces/server';
|
|
20
18
|
import type { ParityBasePrivateInputs, ParityRootPrivateInputs } from '@aztec/stdlib/parity';
|
|
@@ -106,12 +104,7 @@ export class MockProver implements ServerCircuitProver {
|
|
|
106
104
|
constructor() {}
|
|
107
105
|
|
|
108
106
|
getAvmProof(_inputs: AvmCircuitInputs, _signal?: AbortSignal, _epochNumber?: number) {
|
|
109
|
-
return Promise.resolve(
|
|
110
|
-
makeProofAndVerificationKey(
|
|
111
|
-
makeEmptyRecursiveProof(AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED),
|
|
112
|
-
VerificationKeyData.makeFake(AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED),
|
|
113
|
-
),
|
|
114
|
-
);
|
|
107
|
+
return Promise.resolve(makeEmptyRecursiveProof(AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED));
|
|
115
108
|
}
|
|
116
109
|
|
|
117
110
|
getBaseParityProof(_inputs: ParityBasePrivateInputs, _signal?: AbortSignal, _epochNumber?: number) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/block-factory/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './light.js';
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { L2Block } from '@aztec/stdlib/block';
|
|
3
|
-
import type { IBlockFactory, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
4
|
-
import { type GlobalVariables, type ProcessedTx } from '@aztec/stdlib/tx';
|
|
5
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
6
|
-
/**
|
|
7
|
-
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
8
|
-
*
|
|
9
|
-
* NOTE: the onus is ON THE CALLER to update the db that is passed in with the notes hashes, nullifiers, etc
|
|
10
|
-
* PRIOR to calling `buildBlock`.
|
|
11
|
-
*
|
|
12
|
-
* Why? Because if you are, e.g. building a block in practice from TxObjects, you are using the
|
|
13
|
-
* PublicProcessor which will do this for you as it processes transactions.
|
|
14
|
-
*
|
|
15
|
-
* If you haven't already inserted the side effects, e.g. because you are in a testing context, you can use the helper
|
|
16
|
-
* function `buildBlockWithCleanDB`, which calls `insertSideEffects` for you.
|
|
17
|
-
*
|
|
18
|
-
* @deprecated Use LightweightCheckpointBuilder instead. This only works for one block per checkpoint.
|
|
19
|
-
*/
|
|
20
|
-
export declare class LightweightBlockFactory implements IBlockFactory {
|
|
21
|
-
private db;
|
|
22
|
-
private telemetry;
|
|
23
|
-
private globalVariables?;
|
|
24
|
-
private l1ToL2Messages?;
|
|
25
|
-
private txs;
|
|
26
|
-
private readonly logger;
|
|
27
|
-
constructor(db: MerkleTreeWriteOperations, telemetry?: TelemetryClient);
|
|
28
|
-
startNewBlock(globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void>;
|
|
29
|
-
addTxs(txs: ProcessedTx[]): Promise<void>;
|
|
30
|
-
setBlockCompleted(): Promise<L2Block>;
|
|
31
|
-
private buildBlock;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Inserts the processed transactions into the DB, then creates a block.
|
|
35
|
-
* @param db - A db fork to use for block building which WILL BE MODIFIED.
|
|
36
|
-
*/
|
|
37
|
-
export declare function buildBlockWithCleanDB(txs: ProcessedTx[], globalVariables: GlobalVariables, l1ToL2Messages: Fr[], db: MerkleTreeWriteOperations, telemetry?: TelemetryClient): Promise<L2Block>;
|
|
38
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlnaHQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ibG9jay1mYWN0b3J5L2xpZ2h0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUVwRCxPQUFPLEVBQUUsT0FBTyxFQUFpQixNQUFNLHFCQUFxQixDQUFDO0FBQz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|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { SpongeBlob, computeBlobsHashFromBlobs, encodeCheckpointEndMarker, getBlobsPerL1Block } 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/curves/bn254';
|
|
5
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
-
import { L2Block, L2BlockHeader } from '@aztec/stdlib/block';
|
|
7
|
-
import { computeBlockOutHash, computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
8
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
9
|
-
import { ContentCommitment } from '@aztec/stdlib/tx';
|
|
10
|
-
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
11
|
-
import { buildHeaderAndBodyFromTxs, getTreeSnapshot, insertSideEffects } from '../orchestrator/block-building-helpers.js';
|
|
12
|
-
/**
|
|
13
|
-
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
14
|
-
*
|
|
15
|
-
* NOTE: the onus is ON THE CALLER to update the db that is passed in with the notes hashes, nullifiers, etc
|
|
16
|
-
* PRIOR to calling `buildBlock`.
|
|
17
|
-
*
|
|
18
|
-
* Why? Because if you are, e.g. building a block in practice from TxObjects, you are using the
|
|
19
|
-
* PublicProcessor which will do this for you as it processes transactions.
|
|
20
|
-
*
|
|
21
|
-
* If you haven't already inserted the side effects, e.g. because you are in a testing context, you can use the helper
|
|
22
|
-
* function `buildBlockWithCleanDB`, which calls `insertSideEffects` for you.
|
|
23
|
-
*
|
|
24
|
-
* @deprecated Use LightweightCheckpointBuilder instead. This only works for one block per checkpoint.
|
|
25
|
-
*/ export class LightweightBlockFactory {
|
|
26
|
-
db;
|
|
27
|
-
telemetry;
|
|
28
|
-
globalVariables;
|
|
29
|
-
l1ToL2Messages;
|
|
30
|
-
txs;
|
|
31
|
-
logger;
|
|
32
|
-
constructor(db, telemetry = getTelemetryClient()){
|
|
33
|
-
this.db = db;
|
|
34
|
-
this.telemetry = telemetry;
|
|
35
|
-
this.logger = createLogger('lightweight-block-factory');
|
|
36
|
-
}
|
|
37
|
-
async startNewBlock(globalVariables, l1ToL2Messages) {
|
|
38
|
-
this.logger.debug('Starting new block', {
|
|
39
|
-
globalVariables: globalVariables.toInspect(),
|
|
40
|
-
l1ToL2Messages
|
|
41
|
-
});
|
|
42
|
-
this.globalVariables = globalVariables;
|
|
43
|
-
this.l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
44
|
-
this.txs = undefined;
|
|
45
|
-
// Update L1 to L2 tree
|
|
46
|
-
await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages);
|
|
47
|
-
}
|
|
48
|
-
addTxs(txs) {
|
|
49
|
-
// Most times, `addTxs` is only called once per block.
|
|
50
|
-
// So avoid copies.
|
|
51
|
-
if (this.txs === undefined) {
|
|
52
|
-
this.txs = txs;
|
|
53
|
-
} else {
|
|
54
|
-
this.txs.push(...txs);
|
|
55
|
-
}
|
|
56
|
-
return Promise.resolve();
|
|
57
|
-
}
|
|
58
|
-
setBlockCompleted() {
|
|
59
|
-
return this.buildBlock();
|
|
60
|
-
}
|
|
61
|
-
async buildBlock() {
|
|
62
|
-
const lastArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
63
|
-
const state = await this.db.getStateReference();
|
|
64
|
-
const txs = this.txs ?? [];
|
|
65
|
-
const startSpongeBlob = SpongeBlob.init();
|
|
66
|
-
const { header, body, blockBlobFields } = await buildHeaderAndBodyFromTxs(txs, lastArchive, state, this.globalVariables, startSpongeBlob, true);
|
|
67
|
-
header.state.validate();
|
|
68
|
-
await this.db.updateArchive(header);
|
|
69
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
70
|
-
const outHash = computeBlockOutHash(txs.map((tx)=>tx.txEffect.l2ToL1Msgs));
|
|
71
|
-
const inHash = computeInHashFromL1ToL2Messages(this.l1ToL2Messages);
|
|
72
|
-
const numBlobFields = blockBlobFields.length + 1;
|
|
73
|
-
const blobFields = blockBlobFields.concat([
|
|
74
|
-
encodeCheckpointEndMarker({
|
|
75
|
-
numBlobFields
|
|
76
|
-
})
|
|
77
|
-
]);
|
|
78
|
-
const blobsHash = computeBlobsHashFromBlobs(getBlobsPerL1Block(blobFields));
|
|
79
|
-
const blockHeaderHash = await header.hash();
|
|
80
|
-
const contentCommitment = new ContentCommitment(blobsHash, inHash, outHash);
|
|
81
|
-
const l2BlockHeader = L2BlockHeader.from({
|
|
82
|
-
...header,
|
|
83
|
-
blockHeadersHash: blockHeaderHash,
|
|
84
|
-
contentCommitment
|
|
85
|
-
});
|
|
86
|
-
const block = new L2Block(newArchive, l2BlockHeader, body);
|
|
87
|
-
this.logger.debug(`Built block ${block.number}`, {
|
|
88
|
-
globalVariables: this.globalVariables?.toInspect(),
|
|
89
|
-
archiveRoot: newArchive.root.toString(),
|
|
90
|
-
stateReference: header.state.toInspect(),
|
|
91
|
-
blockHash: (await block.hash()).toString(),
|
|
92
|
-
txs: block.body.txEffects.map((tx)=>tx.txHash.toString())
|
|
93
|
-
});
|
|
94
|
-
return block;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Inserts the processed transactions into the DB, then creates a block.
|
|
99
|
-
* @param db - A db fork to use for block building which WILL BE MODIFIED.
|
|
100
|
-
*/ export async function buildBlockWithCleanDB(txs, globalVariables, l1ToL2Messages, db, telemetry = getTelemetryClient()) {
|
|
101
|
-
const builder = new LightweightBlockFactory(db, telemetry);
|
|
102
|
-
await builder.startNewBlock(globalVariables, l1ToL2Messages);
|
|
103
|
-
for (const tx of txs){
|
|
104
|
-
await insertSideEffects(tx, db);
|
|
105
|
-
}
|
|
106
|
-
await builder.addTxs(txs);
|
|
107
|
-
return await builder.setBlockCompleted();
|
|
108
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type ProofUri, type ProvingJobId, type ProvingJobInputs, type ProvingJobInputsMap, type ProvingJobResult, type ProvingJobResultsMap } from '@aztec/stdlib/interfaces/server';
|
|
2
|
-
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
3
|
-
import type { ProofStore } from './proof_store.js';
|
|
4
|
-
export declare class GoogleCloudStorageProofStore implements ProofStore {
|
|
5
|
-
private readonly bucketName;
|
|
6
|
-
private readonly path;
|
|
7
|
-
private readonly storage;
|
|
8
|
-
constructor(bucketName: string, path: string);
|
|
9
|
-
saveProofInput<T extends ProvingRequestType>(id: ProvingJobId, type: T, inputs: ProvingJobInputsMap[T]): Promise<ProofUri>;
|
|
10
|
-
saveProofOutput<T extends ProvingRequestType>(_id: ProvingJobId, _type: T, _result: ProvingJobResultsMap[T]): Promise<ProofUri>;
|
|
11
|
-
getProofInput(uri: ProofUri): Promise<ProvingJobInputs>;
|
|
12
|
-
getProofOutput(_uri: ProofUri): Promise<ProvingJobResult>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2NzX3Byb29mX3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcHJvdmluZ19icm9rZXIvcHJvb2Zfc3RvcmUvZ2NzX3Byb29mX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDTCxLQUFLLFFBQVEsRUFDYixLQUFLLFlBQVksRUFDakIsS0FBSyxnQkFBZ0IsRUFDckIsS0FBSyxtQkFBbUIsRUFDeEIsS0FBSyxnQkFBZ0IsRUFDckIsS0FBSyxvQkFBb0IsRUFFMUIsTUFBTSxpQ0FBaUMsQ0FBQztBQUN6QyxPQUFPLEVBQ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K,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAE1B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAK1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKnD,qBAAa,4BAA6B,YAAW,UAAU;IAI3D,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAElC,YACmB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAG9B;IAEY,cAAc,CAAC,CAAC,SAAS,kBAAkB,EACtD,EAAE,EAAE,YAAY,EAChB,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAC7B,OAAO,CAAC,QAAQ,CAAC,CAKnB;IAED,eAAe,CAAC,CAAC,SAAS,kBAAkB,EAC1C,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC/B,OAAO,CAAC,QAAQ,CAAC,CAEnB;IAEY,aAAa,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAsBnE;IAED,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAExD;CACF"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { getProvingJobInputClassFor } from '@aztec/stdlib/interfaces/server';
|
|
2
|
-
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
3
|
-
import { Storage } from '@google-cloud/storage';
|
|
4
|
-
import { join } from 'path';
|
|
5
|
-
const INPUTS_PATH = 'inputs';
|
|
6
|
-
// REFACTOR(#13067): Use the stdlib/file-store instead of referencing google-cloud-storage directly.
|
|
7
|
-
export class GoogleCloudStorageProofStore {
|
|
8
|
-
bucketName;
|
|
9
|
-
path;
|
|
10
|
-
storage;
|
|
11
|
-
constructor(bucketName, path){
|
|
12
|
-
this.bucketName = bucketName;
|
|
13
|
-
this.path = path;
|
|
14
|
-
this.storage = new Storage();
|
|
15
|
-
}
|
|
16
|
-
async saveProofInput(id, type, inputs) {
|
|
17
|
-
const path = join(this.path, INPUTS_PATH, ProvingRequestType[type], id);
|
|
18
|
-
const file = this.storage.bucket(this.bucketName).file(path);
|
|
19
|
-
await file.save(inputs.toBuffer());
|
|
20
|
-
return file.cloudStorageURI.toString();
|
|
21
|
-
}
|
|
22
|
-
saveProofOutput(_id, _type, _result) {
|
|
23
|
-
throw new Error('Not implemented');
|
|
24
|
-
}
|
|
25
|
-
async getProofInput(uri) {
|
|
26
|
-
try {
|
|
27
|
-
const url = new URL(uri);
|
|
28
|
-
const bucket = this.storage.bucket(url.host);
|
|
29
|
-
const path = url.pathname.replace(/^\/+/, '');
|
|
30
|
-
const file = bucket.file(path);
|
|
31
|
-
if (!await file.exists()) {
|
|
32
|
-
throw new Error(`File at ${uri} does not exist`);
|
|
33
|
-
}
|
|
34
|
-
const typeString = path.split('/').at(-2);
|
|
35
|
-
const type = typeString ? ProvingRequestType[typeString] : undefined;
|
|
36
|
-
if (type === undefined) {
|
|
37
|
-
throw new Error(`Unrecognized proof type ${type} in path ${path}`);
|
|
38
|
-
}
|
|
39
|
-
const contents = await file.download();
|
|
40
|
-
const inputs = getProvingJobInputClassFor(type).fromBuffer(contents[0]);
|
|
41
|
-
return {
|
|
42
|
-
inputs,
|
|
43
|
-
type
|
|
44
|
-
};
|
|
45
|
-
} catch (err) {
|
|
46
|
-
throw new Error(`Error getting proof input at ${uri}: ${err}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
getProofOutput(_uri) {
|
|
50
|
-
throw new Error('Not implemented');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Timer } from '@aztec/foundation/timer';
|
|
2
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
3
|
-
export declare class ProvingAgentInstrumentation {
|
|
4
|
-
private idleTime;
|
|
5
|
-
constructor(client: TelemetryClient, name?: string);
|
|
6
|
-
recordIdleTime(msOrTimer: Timer | number): void;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdmluZ19hZ2VudF9pbnN0cnVtZW50YXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wcm92aW5nX2Jyb2tlci9wcm92aW5nX2FnZW50X2luc3RydW1lbnRhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUNyRCxPQUFPLEVBQTJCLEtBQUssZUFBZSxFQUFhLE1BQU0seUJBQXlCLENBQUM7QUFFbkcscUJBQWEsMkJBQTJCO0lBQ3RDLE9BQU8sQ0FBQyxRQUFRLENBQVk7SUFFNUIsWUFBWSxNQUFNLEVBQUUsZUFBZSxFQUFFLElBQUksU0FBaUIsRUFRekQ7SUFFRCxjQUFjLENBQUMsU0FBUyxFQUFFLEtBQUssR0FBRyxNQUFNLFFBR3ZDO0NBQ0YifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proving_agent_instrumentation.d.ts","sourceRoot":"","sources":["../../src/proving_broker/proving_agent_instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAA2B,KAAK,eAAe,EAAa,MAAM,yBAAyB,CAAC;AAEnG,qBAAa,2BAA2B;IACtC,OAAO,CAAC,QAAQ,CAAY;IAE5B,YAAY,MAAM,EAAE,eAAe,EAAE,IAAI,SAAiB,EAQzD;IAED,cAAc,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM,QAGvC;CACF"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Metrics, ValueType } from '@aztec/telemetry-client';
|
|
2
|
-
export class ProvingAgentInstrumentation {
|
|
3
|
-
idleTime;
|
|
4
|
-
constructor(client, name = 'ProvingAgent'){
|
|
5
|
-
const meter = client.getMeter(name);
|
|
6
|
-
this.idleTime = meter.createHistogram(Metrics.PROVING_AGENT_IDLE, {
|
|
7
|
-
description: 'Records how long an agent was idle',
|
|
8
|
-
unit: 's',
|
|
9
|
-
valueType: ValueType.DOUBLE
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
recordIdleTime(msOrTimer) {
|
|
13
|
-
const duration = typeof msOrTimer === 'number' ? msOrTimer : msOrTimer.ms();
|
|
14
|
-
this.idleTime.record(duration / 1000);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './light.js';
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { SpongeBlob, computeBlobsHashFromBlobs, encodeCheckpointEndMarker, getBlobsPerL1Block } 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/curves/bn254';
|
|
5
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
-
import { L2Block, L2BlockHeader } from '@aztec/stdlib/block';
|
|
7
|
-
import type { IBlockFactory, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
8
|
-
import { computeBlockOutHash, computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
9
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
10
|
-
import { ContentCommitment, type GlobalVariables, type ProcessedTx } from '@aztec/stdlib/tx';
|
|
11
|
-
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
buildHeaderAndBodyFromTxs,
|
|
15
|
-
getTreeSnapshot,
|
|
16
|
-
insertSideEffects,
|
|
17
|
-
} from '../orchestrator/block-building-helpers.js';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
21
|
-
*
|
|
22
|
-
* NOTE: the onus is ON THE CALLER to update the db that is passed in with the notes hashes, nullifiers, etc
|
|
23
|
-
* PRIOR to calling `buildBlock`.
|
|
24
|
-
*
|
|
25
|
-
* Why? Because if you are, e.g. building a block in practice from TxObjects, you are using the
|
|
26
|
-
* PublicProcessor which will do this for you as it processes transactions.
|
|
27
|
-
*
|
|
28
|
-
* If you haven't already inserted the side effects, e.g. because you are in a testing context, you can use the helper
|
|
29
|
-
* function `buildBlockWithCleanDB`, which calls `insertSideEffects` for you.
|
|
30
|
-
*
|
|
31
|
-
* @deprecated Use LightweightCheckpointBuilder instead. This only works for one block per checkpoint.
|
|
32
|
-
*/
|
|
33
|
-
export class LightweightBlockFactory implements IBlockFactory {
|
|
34
|
-
private globalVariables?: GlobalVariables;
|
|
35
|
-
private l1ToL2Messages?: Fr[];
|
|
36
|
-
private txs: ProcessedTx[] | undefined;
|
|
37
|
-
|
|
38
|
-
private readonly logger = createLogger('lightweight-block-factory');
|
|
39
|
-
|
|
40
|
-
constructor(
|
|
41
|
-
private db: MerkleTreeWriteOperations,
|
|
42
|
-
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
43
|
-
) {}
|
|
44
|
-
|
|
45
|
-
async startNewBlock(globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void> {
|
|
46
|
-
this.logger.debug('Starting new block', { globalVariables: globalVariables.toInspect(), l1ToL2Messages });
|
|
47
|
-
this.globalVariables = globalVariables;
|
|
48
|
-
this.l1ToL2Messages = padArrayEnd<Fr, number>(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
49
|
-
this.txs = undefined;
|
|
50
|
-
// Update L1 to L2 tree
|
|
51
|
-
await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages!);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
addTxs(txs: ProcessedTx[]): Promise<void> {
|
|
55
|
-
// Most times, `addTxs` is only called once per block.
|
|
56
|
-
// So avoid copies.
|
|
57
|
-
if (this.txs === undefined) {
|
|
58
|
-
this.txs = txs;
|
|
59
|
-
} else {
|
|
60
|
-
this.txs.push(...txs);
|
|
61
|
-
}
|
|
62
|
-
return Promise.resolve();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
setBlockCompleted(): Promise<L2Block> {
|
|
66
|
-
return this.buildBlock();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private async buildBlock(): Promise<L2Block> {
|
|
70
|
-
const lastArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
71
|
-
const state = await this.db.getStateReference();
|
|
72
|
-
|
|
73
|
-
const txs = this.txs ?? [];
|
|
74
|
-
const startSpongeBlob = SpongeBlob.init();
|
|
75
|
-
|
|
76
|
-
const { header, body, blockBlobFields } = await buildHeaderAndBodyFromTxs(
|
|
77
|
-
txs,
|
|
78
|
-
lastArchive,
|
|
79
|
-
state,
|
|
80
|
-
this.globalVariables!,
|
|
81
|
-
startSpongeBlob,
|
|
82
|
-
true,
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
header.state.validate();
|
|
86
|
-
|
|
87
|
-
await this.db.updateArchive(header);
|
|
88
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
89
|
-
|
|
90
|
-
const outHash = computeBlockOutHash(txs.map(tx => tx.txEffect.l2ToL1Msgs));
|
|
91
|
-
const inHash = computeInHashFromL1ToL2Messages(this.l1ToL2Messages!);
|
|
92
|
-
const numBlobFields = blockBlobFields.length + 1;
|
|
93
|
-
const blobFields = blockBlobFields.concat([encodeCheckpointEndMarker({ numBlobFields })]);
|
|
94
|
-
const blobsHash = computeBlobsHashFromBlobs(getBlobsPerL1Block(blobFields));
|
|
95
|
-
const blockHeaderHash = await header.hash();
|
|
96
|
-
const contentCommitment = new ContentCommitment(blobsHash, inHash, outHash);
|
|
97
|
-
const l2BlockHeader = L2BlockHeader.from({
|
|
98
|
-
...header,
|
|
99
|
-
blockHeadersHash: blockHeaderHash,
|
|
100
|
-
contentCommitment,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const block = new L2Block(newArchive, l2BlockHeader, body);
|
|
104
|
-
|
|
105
|
-
this.logger.debug(`Built block ${block.number}`, {
|
|
106
|
-
globalVariables: this.globalVariables?.toInspect(),
|
|
107
|
-
archiveRoot: newArchive.root.toString(),
|
|
108
|
-
stateReference: header.state.toInspect(),
|
|
109
|
-
blockHash: (await block.hash()).toString(),
|
|
110
|
-
txs: block.body.txEffects.map(tx => tx.txHash.toString()),
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
return block;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Inserts the processed transactions into the DB, then creates a block.
|
|
119
|
-
* @param db - A db fork to use for block building which WILL BE MODIFIED.
|
|
120
|
-
*/
|
|
121
|
-
export async function buildBlockWithCleanDB(
|
|
122
|
-
txs: ProcessedTx[],
|
|
123
|
-
globalVariables: GlobalVariables,
|
|
124
|
-
l1ToL2Messages: Fr[],
|
|
125
|
-
db: MerkleTreeWriteOperations,
|
|
126
|
-
telemetry: TelemetryClient = getTelemetryClient(),
|
|
127
|
-
) {
|
|
128
|
-
const builder = new LightweightBlockFactory(db, telemetry);
|
|
129
|
-
await builder.startNewBlock(globalVariables, l1ToL2Messages);
|
|
130
|
-
|
|
131
|
-
for (const tx of txs) {
|
|
132
|
-
await insertSideEffects(tx, db);
|
|
133
|
-
}
|
|
134
|
-
await builder.addTxs(txs);
|
|
135
|
-
|
|
136
|
-
return await builder.setBlockCompleted();
|
|
137
|
-
}
|
|
@@ -1,76 +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
|
-
// REFACTOR(#13067): Use the stdlib/file-store instead of referencing google-cloud-storage directly.
|
|
20
|
-
export class GoogleCloudStorageProofStore implements ProofStore {
|
|
21
|
-
private readonly storage: Storage;
|
|
22
|
-
|
|
23
|
-
constructor(
|
|
24
|
-
private readonly bucketName: string,
|
|
25
|
-
private readonly path: string,
|
|
26
|
-
) {
|
|
27
|
-
this.storage = new Storage();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public async saveProofInput<T extends ProvingRequestType>(
|
|
31
|
-
id: ProvingJobId,
|
|
32
|
-
type: T,
|
|
33
|
-
inputs: ProvingJobInputsMap[T],
|
|
34
|
-
): Promise<ProofUri> {
|
|
35
|
-
const path = join(this.path, INPUTS_PATH, ProvingRequestType[type], id);
|
|
36
|
-
const file = this.storage.bucket(this.bucketName).file(path);
|
|
37
|
-
await file.save(inputs.toBuffer());
|
|
38
|
-
return file.cloudStorageURI.toString() as ProofUri;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
saveProofOutput<T extends ProvingRequestType>(
|
|
42
|
-
_id: ProvingJobId,
|
|
43
|
-
_type: T,
|
|
44
|
-
_result: ProvingJobResultsMap[T],
|
|
45
|
-
): Promise<ProofUri> {
|
|
46
|
-
throw new Error('Not implemented');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public async getProofInput(uri: ProofUri): Promise<ProvingJobInputs> {
|
|
50
|
-
try {
|
|
51
|
-
const url = new URL(uri);
|
|
52
|
-
const bucket = this.storage.bucket(url.host);
|
|
53
|
-
const path = url.pathname.replace(/^\/+/, '');
|
|
54
|
-
const file = bucket.file(path);
|
|
55
|
-
if (!(await file.exists())) {
|
|
56
|
-
throw new Error(`File at ${uri} does not exist`);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const typeString = path.split('/').at(-2);
|
|
60
|
-
const type = typeString ? ProvingRequestType[typeString as keyof typeof ProvingRequestType] : undefined;
|
|
61
|
-
if (type === undefined) {
|
|
62
|
-
throw new Error(`Unrecognized proof type ${type} in path ${path}`);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const contents = await file.download();
|
|
66
|
-
const inputs = getProvingJobInputClassFor(type).fromBuffer(contents[0]);
|
|
67
|
-
return { inputs, type } as ProvingJobInputs;
|
|
68
|
-
} catch (err) {
|
|
69
|
-
throw new Error(`Error getting proof input at ${uri}: ${err}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
getProofOutput(_uri: ProofUri): Promise<ProvingJobResult> {
|
|
74
|
-
throw new Error('Not implemented');
|
|
75
|
-
}
|
|
76
|
-
}
|