@aztec/prover-client 0.0.1-commit.b655e406 → 0.0.1-commit.d1f2d6c
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 +44 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
- package/dest/light/lightweight_checkpoint_builder.js +194 -0
- package/dest/mocks/fixtures.d.ts +1 -4
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +7 -17
- 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 +116 -116
- package/dest/orchestrator/block-building-helpers.d.ts +17 -19
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +87 -112
- package/dest/orchestrator/block-proving-state.d.ts +17 -11
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +81 -20
- 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 +49 -17
- 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 +38 -4
- package/dest/orchestrator/index.d.ts +1 -1
- package/dest/orchestrator/orchestrator.d.ts +24 -11
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +496 -102
- 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 +3 -3
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +2 -2
- 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 +22 -21
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +6 -12
- package/dest/proving_broker/config.d.ts +16 -8
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +14 -2
- 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 -2
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +1 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.d.ts +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 +3 -8
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +1 -16
- package/dest/proving_broker/proving_broker.d.ts +2 -2
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +6 -11
- 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 +11 -35
- package/dest/proving_broker/proving_job_controller.d.ts +3 -2
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +2 -3
- package/dest/proving_broker/rpc.d.ts +4 -4
- 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 +3 -4
- 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 +274 -0
- package/src/mocks/fixtures.ts +7 -30
- package/src/mocks/test_context.ts +158 -177
- package/src/orchestrator/block-building-helpers.ts +126 -206
- package/src/orchestrator/block-proving-state.ts +103 -25
- package/src/orchestrator/checkpoint-proving-state.ts +71 -21
- package/src/orchestrator/epoch-proving-state.ts +64 -14
- package/src/orchestrator/orchestrator.ts +97 -89
- 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 +11 -12
- package/src/prover-client/server-epoch-prover.ts +6 -7
- package/src/proving_broker/broker_prover_facade.ts +25 -34
- package/src/proving_broker/config.ts +17 -1
- package/src/proving_broker/fixtures.ts +8 -3
- package/src/proving_broker/proving_agent.ts +1 -17
- package/src/proving_broker/proving_broker.ts +6 -9
- 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 +10 -35
- package/src/proving_broker/proving_job_controller.ts +4 -4
- 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/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/proving_agent_instrumentation.ts +0 -21
|
@@ -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,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,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
|
-
}
|