@aztec/prover-client 0.0.1-fake-c83136db25 → 0.0.2-commit.217f559981
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 +2 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +1 -1
- 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 +48 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
- package/dest/light/lightweight_checkpoint_builder.js +202 -0
- package/dest/mocks/fixtures.d.ts +1 -4
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +9 -18
- package/dest/mocks/test_context.d.ts +29 -46
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +119 -116
- package/dest/orchestrator/block-building-helpers.d.ts +18 -20
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +90 -115
- package/dest/orchestrator/block-proving-state.d.ts +20 -11
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +87 -19
- package/dest/orchestrator/checkpoint-proving-state.d.ts +22 -9
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +52 -20
- package/dest/orchestrator/epoch-proving-state.d.ts +12 -10
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +40 -4
- package/dest/orchestrator/index.d.ts +1 -1
- package/dest/orchestrator/orchestrator.d.ts +26 -11
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +562 -176
- package/dest/orchestrator/orchestrator_metrics.d.ts +1 -3
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +2 -15
- package/dest/orchestrator/tx-proving-state.d.ts +6 -5
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +7 -16
- 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 +5 -5
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +15 -10
- package/dest/prover-client/server-epoch-prover.d.ts +8 -7
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +2 -2
- package/dest/proving_broker/broker_prover_facade.d.ts +25 -23
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +9 -15
- package/dest/proving_broker/config.d.ts +24 -8
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +26 -3
- package/dest/proving_broker/factory.d.ts +1 -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 -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/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 +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 +35 -12
- 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/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 +392 -3
- 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 +5 -3
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +8 -6
- package/dest/proving_broker/rpc.d.ts +7 -5
- 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 +1 -1
- package/dest/test/mock_proof_store.d.ts.map +1 -1
- package/dest/test/mock_prover.d.ts +5 -6
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +4 -4
- package/package.json +20 -18
- package/src/config.ts +1 -1
- package/src/light/index.ts +1 -0
- package/src/light/lightweight_checkpoint_builder.ts +294 -0
- package/src/mocks/fixtures.ts +9 -31
- package/src/mocks/test_context.ts +158 -177
- package/src/orchestrator/block-building-helpers.ts +129 -209
- package/src/orchestrator/block-proving-state.ts +109 -22
- package/src/orchestrator/checkpoint-proving-state.ts +75 -25
- package/src/orchestrator/epoch-proving-state.ts +67 -15
- package/src/orchestrator/orchestrator.ts +172 -169
- package/src/orchestrator/orchestrator_metrics.ts +2 -25
- package/src/orchestrator/tx-proving-state.ts +10 -27
- package/src/prover-client/factory.ts +6 -2
- package/src/prover-client/prover-client.ts +31 -23
- package/src/prover-client/server-epoch-prover.ts +6 -7
- package/src/proving_broker/broker_prover_facade.ts +31 -37
- package/src/proving_broker/config.ts +30 -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 -1
- package/src/proving_broker/proving_agent.ts +6 -19
- package/src/proving_broker/proving_broker.ts +36 -10
- package/src/proving_broker/proving_broker_database/memory.ts +2 -1
- package/src/proving_broker/proving_broker_database/persisted.ts +20 -5
- 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 +13 -7
- package/src/proving_broker/rpc.ts +14 -0
- package/src/test/mock_prover.ts +2 -14
- 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 -94
- 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 -140
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
- package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { SpongeBlob } from '@aztec/blob-lib';
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import { L2Block } from '@aztec/stdlib/block';
|
|
4
|
-
import type { IBlockFactory, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
5
|
-
import type { GlobalVariables, ProcessedTx } from '@aztec/stdlib/tx';
|
|
6
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
7
|
-
/**
|
|
8
|
-
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
9
|
-
*
|
|
10
|
-
* NOTE: the onus is ON THE CALLER to update the db that is passed in with the notes hashes, nullifiers, etc
|
|
11
|
-
* PRIOR to calling `buildBlock`.
|
|
12
|
-
*
|
|
13
|
-
* Why? Because if you are, e.g. building a block in practice from TxObjects, you are using the
|
|
14
|
-
* PublicProcessor which will do this for you as it processes transactions.
|
|
15
|
-
*
|
|
16
|
-
* If you haven't already inserted the side effects, e.g. because you are in a testing context, you can use the helper
|
|
17
|
-
* function `buildBlockWithCleanDB`, which calls `insertSideEffectsAndBuildBaseRollupHints` for you.
|
|
18
|
-
*/
|
|
19
|
-
export declare class LightweightBlockFactory implements IBlockFactory {
|
|
20
|
-
private db;
|
|
21
|
-
private telemetry;
|
|
22
|
-
private globalVariables?;
|
|
23
|
-
private l1ToL2Messages?;
|
|
24
|
-
private startSpongeBlob?;
|
|
25
|
-
private txs;
|
|
26
|
-
private readonly logger;
|
|
27
|
-
constructor(db: MerkleTreeWriteOperations, telemetry?: TelemetryClient);
|
|
28
|
-
startNewBlock(globalVariables: GlobalVariables, l1ToL2Messages: Fr[], startSpongeBlob?: SpongeBlob, isFirstBlock?: boolean): 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, startSpongeBlob?: SpongeBlob, isFirstBlock?: boolean, telemetry?: TelemetryClient): Promise<L2Block>;
|
|
38
|
-
//# sourceMappingURL=light.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"light.d.ts","sourceRoot":"","sources":["../../src/block-factory/light.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEhG,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAQnF;;;;;;;;;;;GAWG;AACH,qBAAa,uBAAwB,YAAW,aAAa;IASzD,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,SAAS;IATnB,OAAO,CAAC,eAAe,CAAC,CAAkB;IAC1C,OAAO,CAAC,cAAc,CAAC,CAAO;IAC9B,OAAO,CAAC,eAAe,CAAC,CAAa;IACrC,OAAO,CAAC,GAAG,CAA4B;IAEvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6C;gBAG1D,EAAE,EAAE,yBAAyB,EAC7B,SAAS,GAAE,eAAsC;IAGrD,aAAa,CACjB,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,EAAE,EAAE,EAEpB,eAAe,CAAC,EAAE,UAAU,EAE5B,YAAY,UAAO,GAClB,OAAO,CAAC,IAAI,CAAC;IAYhB,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAWzC,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;YAIvB,UAAU;CA2BzB;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,WAAW,EAAE,EAClB,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,EAAE,EAAE,EACpB,EAAE,EAAE,yBAAyB,EAC7B,eAAe,CAAC,EAAE,UAAU,EAC5B,YAAY,UAAO,EACnB,SAAS,GAAE,eAAsC,oBAuBlD"}
|
|
@@ -1,94 +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 { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
8
|
-
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
9
|
-
import { buildHeaderAndBodyFromTxs, getTreeSnapshot, insertSideEffectsAndBuildBaseRollupHints } from '../orchestrator/block-building-helpers.js';
|
|
10
|
-
/**
|
|
11
|
-
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
12
|
-
*
|
|
13
|
-
* NOTE: the onus is ON THE CALLER to update the db that is passed in with the notes hashes, nullifiers, etc
|
|
14
|
-
* PRIOR to calling `buildBlock`.
|
|
15
|
-
*
|
|
16
|
-
* Why? Because if you are, e.g. building a block in practice from TxObjects, you are using the
|
|
17
|
-
* PublicProcessor which will do this for you as it processes transactions.
|
|
18
|
-
*
|
|
19
|
-
* If you haven't already inserted the side effects, e.g. because you are in a testing context, you can use the helper
|
|
20
|
-
* function `buildBlockWithCleanDB`, which calls `insertSideEffectsAndBuildBaseRollupHints` for you.
|
|
21
|
-
*/ export class LightweightBlockFactory {
|
|
22
|
-
db;
|
|
23
|
-
telemetry;
|
|
24
|
-
globalVariables;
|
|
25
|
-
l1ToL2Messages;
|
|
26
|
-
startSpongeBlob;
|
|
27
|
-
txs;
|
|
28
|
-
logger;
|
|
29
|
-
constructor(db, telemetry = getTelemetryClient()){
|
|
30
|
-
this.db = db;
|
|
31
|
-
this.telemetry = telemetry;
|
|
32
|
-
this.logger = createLogger('lightweight-block-factory');
|
|
33
|
-
}
|
|
34
|
-
async startNewBlock(globalVariables, l1ToL2Messages, // Must be provided to generate the correct spongeBlobHash for the block header if there's more than one block in the checkpoint.
|
|
35
|
-
startSpongeBlob, // Only insert l1 to l2 messages for the first block in a checkpoint.
|
|
36
|
-
isFirstBlock = true) {
|
|
37
|
-
this.logger.debug('Starting new block', {
|
|
38
|
-
globalVariables: globalVariables.toInspect(),
|
|
39
|
-
l1ToL2Messages
|
|
40
|
-
});
|
|
41
|
-
this.globalVariables = globalVariables;
|
|
42
|
-
this.l1ToL2Messages = isFirstBlock ? padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP) : [];
|
|
43
|
-
this.startSpongeBlob = startSpongeBlob;
|
|
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 { header, body } = await buildHeaderAndBodyFromTxs(this.txs ?? [], this.globalVariables, this.l1ToL2Messages, this.db, this.startSpongeBlob);
|
|
63
|
-
header.state.validate();
|
|
64
|
-
const blockHeader = header.toBlockHeader();
|
|
65
|
-
await this.db.updateArchive(blockHeader);
|
|
66
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
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
|
-
stateReference: header.state.toInspect(),
|
|
72
|
-
blockHash: (await block.hash()).toString(),
|
|
73
|
-
txs: block.body.txEffects.map((tx)=>tx.txHash.toString())
|
|
74
|
-
});
|
|
75
|
-
return block;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Inserts the processed transactions into the DB, then creates a block.
|
|
80
|
-
* @param db - A db fork to use for block building which WILL BE MODIFIED.
|
|
81
|
-
*/ export async function buildBlockWithCleanDB(txs, globalVariables, l1ToL2Messages, db, startSpongeBlob, isFirstBlock = true, telemetry = getTelemetryClient()) {
|
|
82
|
-
const lastArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
83
|
-
const builder = new LightweightBlockFactory(db, telemetry);
|
|
84
|
-
await builder.startNewBlock(globalVariables, l1ToL2Messages, startSpongeBlob, isFirstBlock);
|
|
85
|
-
const l1ToL2MessageTree = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, db);
|
|
86
|
-
for (const tx of txs){
|
|
87
|
-
// startSpongeBlob and proverId are only used for constructing private inputs of the base rollup.
|
|
88
|
-
// Their values don't matter here because we are not using the return private inputs to build the block.
|
|
89
|
-
const proverId = Fr.ZERO;
|
|
90
|
-
await insertSideEffectsAndBuildBaseRollupHints(tx, lastArchive, l1ToL2MessageTree, startSpongeBlob?.clone() ?? SpongeBlob.empty(), proverId, db);
|
|
91
|
-
}
|
|
92
|
-
await builder.addTxs(txs);
|
|
93
|
-
return await builder.setBlockCompleted();
|
|
94
|
-
}
|
|
@@ -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=gcs_proof_store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gcs_proof_store.d.ts","sourceRoot":"","sources":["../../../src/proving_broker/proof_store/gcs_proof_store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,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;gBAGf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM;IAKlB,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;IAOpB,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;IAIP,aAAa,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwBpE,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAG1D"}
|
|
@@ -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=proving_agent_instrumentation.d.ts.map
|
|
@@ -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;gBAEhB,MAAM,EAAE,eAAe,EAAE,IAAI,SAAiB;IAU1D,cAAc,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM;CAIzC"}
|
|
@@ -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,140 +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 { IBlockFactory, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
8
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
9
|
-
import type { GlobalVariables, ProcessedTx } from '@aztec/stdlib/tx';
|
|
10
|
-
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
buildHeaderAndBodyFromTxs,
|
|
14
|
-
getTreeSnapshot,
|
|
15
|
-
insertSideEffectsAndBuildBaseRollupHints,
|
|
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
|
-
* NOTE: the onus is ON THE CALLER to update the db that is passed in with the notes hashes, nullifiers, etc
|
|
22
|
-
* PRIOR to calling `buildBlock`.
|
|
23
|
-
*
|
|
24
|
-
* Why? Because if you are, e.g. building a block in practice from TxObjects, you are using the
|
|
25
|
-
* PublicProcessor which will do this for you as it processes transactions.
|
|
26
|
-
*
|
|
27
|
-
* If you haven't already inserted the side effects, e.g. because you are in a testing context, you can use the helper
|
|
28
|
-
* function `buildBlockWithCleanDB`, which calls `insertSideEffectsAndBuildBaseRollupHints` for you.
|
|
29
|
-
*/
|
|
30
|
-
export class LightweightBlockFactory implements IBlockFactory {
|
|
31
|
-
private globalVariables?: GlobalVariables;
|
|
32
|
-
private l1ToL2Messages?: Fr[];
|
|
33
|
-
private startSpongeBlob?: SpongeBlob;
|
|
34
|
-
private txs: ProcessedTx[] | undefined;
|
|
35
|
-
|
|
36
|
-
private readonly logger = createLogger('lightweight-block-factory');
|
|
37
|
-
|
|
38
|
-
constructor(
|
|
39
|
-
private db: MerkleTreeWriteOperations,
|
|
40
|
-
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
41
|
-
) {}
|
|
42
|
-
|
|
43
|
-
async startNewBlock(
|
|
44
|
-
globalVariables: GlobalVariables,
|
|
45
|
-
l1ToL2Messages: Fr[],
|
|
46
|
-
// Must be provided to generate the correct spongeBlobHash for the block header if there's more than one block in the checkpoint.
|
|
47
|
-
startSpongeBlob?: SpongeBlob,
|
|
48
|
-
// Only insert l1 to l2 messages for the first block in a checkpoint.
|
|
49
|
-
isFirstBlock = true,
|
|
50
|
-
): Promise<void> {
|
|
51
|
-
this.logger.debug('Starting new block', { globalVariables: globalVariables.toInspect(), l1ToL2Messages });
|
|
52
|
-
this.globalVariables = globalVariables;
|
|
53
|
-
this.l1ToL2Messages = isFirstBlock
|
|
54
|
-
? padArrayEnd<Fr, number>(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP)
|
|
55
|
-
: [];
|
|
56
|
-
this.startSpongeBlob = startSpongeBlob;
|
|
57
|
-
this.txs = undefined;
|
|
58
|
-
// Update L1 to L2 tree
|
|
59
|
-
await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages!);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
addTxs(txs: ProcessedTx[]): Promise<void> {
|
|
63
|
-
// Most times, `addTxs` is only called once per block.
|
|
64
|
-
// So avoid copies.
|
|
65
|
-
if (this.txs === undefined) {
|
|
66
|
-
this.txs = txs;
|
|
67
|
-
} else {
|
|
68
|
-
this.txs.push(...txs);
|
|
69
|
-
}
|
|
70
|
-
return Promise.resolve();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
setBlockCompleted(): Promise<L2Block> {
|
|
74
|
-
return this.buildBlock();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private async buildBlock(): Promise<L2Block> {
|
|
78
|
-
const { header, body } = await buildHeaderAndBodyFromTxs(
|
|
79
|
-
this.txs ?? [],
|
|
80
|
-
this.globalVariables!,
|
|
81
|
-
this.l1ToL2Messages!,
|
|
82
|
-
this.db,
|
|
83
|
-
this.startSpongeBlob,
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
header.state.validate();
|
|
87
|
-
|
|
88
|
-
const blockHeader = header.toBlockHeader();
|
|
89
|
-
await this.db.updateArchive(blockHeader);
|
|
90
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
91
|
-
|
|
92
|
-
const block = new L2Block(newArchive, header, body);
|
|
93
|
-
|
|
94
|
-
this.logger.debug(`Built block ${block.number}`, {
|
|
95
|
-
globalVariables: this.globalVariables?.toInspect(),
|
|
96
|
-
archiveRoot: newArchive.root.toString(),
|
|
97
|
-
stateReference: header.state.toInspect(),
|
|
98
|
-
blockHash: (await block.hash()).toString(),
|
|
99
|
-
txs: block.body.txEffects.map(tx => tx.txHash.toString()),
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return block;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Inserts the processed transactions into the DB, then creates a block.
|
|
108
|
-
* @param db - A db fork to use for block building which WILL BE MODIFIED.
|
|
109
|
-
*/
|
|
110
|
-
export async function buildBlockWithCleanDB(
|
|
111
|
-
txs: ProcessedTx[],
|
|
112
|
-
globalVariables: GlobalVariables,
|
|
113
|
-
l1ToL2Messages: Fr[],
|
|
114
|
-
db: MerkleTreeWriteOperations,
|
|
115
|
-
startSpongeBlob?: SpongeBlob,
|
|
116
|
-
isFirstBlock = true,
|
|
117
|
-
telemetry: TelemetryClient = getTelemetryClient(),
|
|
118
|
-
) {
|
|
119
|
-
const lastArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
120
|
-
const builder = new LightweightBlockFactory(db, telemetry);
|
|
121
|
-
await builder.startNewBlock(globalVariables, l1ToL2Messages, startSpongeBlob, isFirstBlock);
|
|
122
|
-
const l1ToL2MessageTree = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, db);
|
|
123
|
-
|
|
124
|
-
for (const tx of txs) {
|
|
125
|
-
// startSpongeBlob and proverId are only used for constructing private inputs of the base rollup.
|
|
126
|
-
// Their values don't matter here because we are not using the return private inputs to build the block.
|
|
127
|
-
const proverId = Fr.ZERO;
|
|
128
|
-
await insertSideEffectsAndBuildBaseRollupHints(
|
|
129
|
-
tx,
|
|
130
|
-
lastArchive,
|
|
131
|
-
l1ToL2MessageTree,
|
|
132
|
-
startSpongeBlob?.clone() ?? SpongeBlob.empty(),
|
|
133
|
-
proverId,
|
|
134
|
-
db,
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
await builder.addTxs(txs);
|
|
138
|
-
|
|
139
|
-
return await builder.setBlockCompleted();
|
|
140
|
-
}
|
|
@@ -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
|
-
}
|
|
@@ -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
|
-
}
|