@aztec/prover-client 0.0.0-test.1 → 0.0.1-commit.21caa21
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/block-factory/index.d.ts +2 -0
- package/dest/block-factory/index.d.ts.map +1 -0
- package/dest/block-factory/light.d.ts +38 -0
- package/dest/block-factory/light.d.ts.map +1 -0
- package/dest/block-factory/light.js +108 -0
- package/dest/config.d.ts +7 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +11 -1
- package/dest/index.d.ts +1 -1
- package/dest/light/lightweight_checkpoint_builder.d.ts +28 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
- package/dest/light/lightweight_checkpoint_builder.js +107 -0
- package/dest/mocks/fixtures.d.ts +8 -8
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +32 -14
- package/dest/mocks/test_context.d.ts +40 -31
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +134 -86
- package/dest/orchestrator/block-building-helpers.d.ts +36 -29
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +168 -188
- package/dest/orchestrator/block-proving-state.d.ts +68 -47
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +281 -176
- package/dest/orchestrator/checkpoint-proving-state.d.ts +62 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-proving-state.js +208 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +40 -26
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +143 -73
- package/dest/orchestrator/index.d.ts +1 -1
- package/dest/orchestrator/orchestrator.d.ts +35 -32
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +389 -239
- package/dest/orchestrator/orchestrator_metrics.d.ts +3 -1
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +9 -0
- package/dest/orchestrator/tx-proving-state.d.ts +13 -11
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +23 -40
- package/dest/prover-client/factory.d.ts +1 -1
- package/dest/prover-client/index.d.ts +1 -1
- package/dest/prover-client/prover-client.d.ts +4 -4
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +5 -4
- package/dest/prover-client/server-epoch-prover.d.ts +15 -11
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +11 -11
- package/dest/proving_broker/broker_prover_facade.d.ts +23 -16
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +67 -41
- package/dest/proving_broker/config.d.ts +18 -9
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +22 -5
- package/dest/proving_broker/factory.d.ts +2 -2
- package/dest/proving_broker/factory.d.ts.map +1 -1
- package/dest/proving_broker/factory.js +5 -1
- package/dest/proving_broker/fixtures.d.ts +3 -2
- package/dest/proving_broker/fixtures.d.ts.map +1 -1
- package/dest/proving_broker/fixtures.js +2 -1
- 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/factory.js +1 -1
- 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/gcs_proof_store.js +1 -0
- package/dest/proving_broker/proof_store/index.d.ts +2 -1
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -0
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts +1 -1
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/proof_store.d.ts +1 -1
- package/dest/proving_broker/proving_agent.d.ts +4 -4
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +83 -47
- package/dest/proving_broker/proving_agent_instrumentation.d.ts +1 -1
- package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.d.ts +13 -4
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +36 -23
- package/dest/proving_broker/proving_broker_database/memory.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/memory.js +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +12 -10
- 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_job_controller.d.ts +9 -9
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +89 -61
- package/dest/proving_broker/rpc.d.ts +4 -6
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +1 -4
- package/dest/test/mock_proof_store.d.ts +9 -0
- package/dest/test/mock_proof_store.d.ts.map +1 -0
- package/dest/test/mock_proof_store.js +10 -0
- package/dest/test/mock_prover.d.ts +23 -17
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +38 -20
- package/package.json +32 -31
- package/src/block-factory/index.ts +1 -0
- package/src/block-factory/light.ts +137 -0
- package/src/config.ts +24 -8
- package/src/light/lightweight_checkpoint_builder.ts +142 -0
- package/src/mocks/fixtures.ts +42 -37
- package/src/mocks/test_context.ts +207 -115
- package/src/orchestrator/block-building-helpers.ts +256 -333
- package/src/orchestrator/block-proving-state.ts +323 -230
- package/src/orchestrator/checkpoint-proving-state.ts +301 -0
- package/src/orchestrator/epoch-proving-state.ts +187 -112
- package/src/orchestrator/orchestrator.ts +592 -299
- package/src/orchestrator/orchestrator_metrics.ts +20 -1
- package/src/orchestrator/tx-proving-state.ts +50 -64
- package/src/prover-client/prover-client.ts +16 -14
- package/src/prover-client/server-epoch-prover.ts +39 -21
- package/src/proving_broker/broker_prover_facade.ts +214 -126
- package/src/proving_broker/config.ts +24 -6
- package/src/proving_broker/factory.ts +2 -1
- package/src/proving_broker/fixtures.ts +7 -2
- package/src/proving_broker/proof_store/factory.ts +1 -1
- package/src/proving_broker/proof_store/gcs_proof_store.ts +5 -1
- package/src/proving_broker/proof_store/index.ts +1 -0
- package/src/proving_broker/proof_store/inline_proof_store.ts +1 -1
- package/src/proving_broker/proving_agent.ts +89 -47
- package/src/proving_broker/proving_broker.ts +53 -33
- package/src/proving_broker/proving_broker_database/memory.ts +3 -2
- package/src/proving_broker/proving_broker_database/persisted.ts +14 -12
- package/src/proving_broker/proving_broker_database.ts +2 -1
- package/src/proving_broker/proving_job_controller.ts +94 -82
- package/src/proving_broker/rpc.ts +1 -6
- package/src/test/mock_proof_store.ts +14 -0
- package/src/test/mock_prover.ts +164 -60
- package/dest/bin/get-proof-inputs.d.ts +0 -2
- package/dest/bin/get-proof-inputs.d.ts.map +0 -1
- package/dest/bin/get-proof-inputs.js +0 -51
- package/dest/block_builder/index.d.ts +0 -6
- package/dest/block_builder/index.d.ts.map +0 -1
- package/dest/block_builder/light.d.ts +0 -33
- package/dest/block_builder/light.d.ts.map +0 -1
- package/dest/block_builder/light.js +0 -82
- package/src/bin/get-proof-inputs.ts +0 -59
- package/src/block_builder/index.ts +0 -6
- package/src/block_builder/light.ts +0 -101
- /package/dest/{block_builder → block-factory}/index.js +0 -0
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/prover-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1-commit.21caa21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
7
|
-
"./block-
|
|
7
|
+
"./block-factory": "./dest/block-factory/index.js",
|
|
8
8
|
"./broker": "./dest/proving_broker/index.js",
|
|
9
9
|
"./orchestrator": "./dest/orchestrator/index.js",
|
|
10
10
|
"./helpers": "./dest/orchestrator/block-building-helpers.js",
|
|
@@ -22,15 +22,12 @@
|
|
|
22
22
|
"./package.local.json"
|
|
23
23
|
],
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "yarn clean &&
|
|
26
|
-
"build:dev": "
|
|
25
|
+
"build": "yarn clean && tsgo -b",
|
|
26
|
+
"build:dev": "tsgo -b --watch",
|
|
27
27
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
28
|
-
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
29
|
-
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
30
28
|
"bb": "node --no-warnings ./dest/bb/index.js",
|
|
31
29
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=3500000 --forceExit",
|
|
32
|
-
"test:debug": "LOG_LEVEL=debug NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=1500000 --forceExit --testNamePattern prover/bb_prover/parity"
|
|
33
|
-
"get-proof-inputs": "node --no-warnings ./dest/bin/get-proof-inputs.js"
|
|
30
|
+
"test:debug": "LOG_LEVEL=debug NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=1500000 --forceExit --testNamePattern prover/bb_prover/parity"
|
|
34
31
|
},
|
|
35
32
|
"jest": {
|
|
36
33
|
"moduleNameMapper": {
|
|
@@ -63,42 +60,46 @@
|
|
|
63
60
|
"testTimeout": 120000,
|
|
64
61
|
"setupFiles": [
|
|
65
62
|
"../../foundation/src/jest/setup.mjs"
|
|
63
|
+
],
|
|
64
|
+
"testEnvironment": "../../foundation/src/jest/env.mjs",
|
|
65
|
+
"setupFilesAfterEnv": [
|
|
66
|
+
"../../foundation/src/jest/setupAfterEnv.mjs"
|
|
66
67
|
]
|
|
67
68
|
},
|
|
68
69
|
"dependencies": {
|
|
69
|
-
"@aztec/bb-prover": "0.0.
|
|
70
|
-
"@aztec/blob-lib": "0.0.
|
|
71
|
-
"@aztec/constants": "0.0.
|
|
72
|
-
"@aztec/ethereum": "0.0.
|
|
73
|
-
"@aztec/foundation": "0.0.
|
|
74
|
-
"@aztec/kv-store": "0.0.
|
|
75
|
-
"@aztec/noir-protocol-circuits-types": "0.0.
|
|
76
|
-
"@aztec/
|
|
77
|
-
"@aztec/
|
|
78
|
-
"@aztec/
|
|
79
|
-
"@aztec/
|
|
80
|
-
"@aztec/
|
|
70
|
+
"@aztec/bb-prover": "0.0.1-commit.21caa21",
|
|
71
|
+
"@aztec/blob-lib": "0.0.1-commit.21caa21",
|
|
72
|
+
"@aztec/constants": "0.0.1-commit.21caa21",
|
|
73
|
+
"@aztec/ethereum": "0.0.1-commit.21caa21",
|
|
74
|
+
"@aztec/foundation": "0.0.1-commit.21caa21",
|
|
75
|
+
"@aztec/kv-store": "0.0.1-commit.21caa21",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.21caa21",
|
|
77
|
+
"@aztec/noir-types": "0.0.1-commit.21caa21",
|
|
78
|
+
"@aztec/protocol-contracts": "0.0.1-commit.21caa21",
|
|
79
|
+
"@aztec/simulator": "0.0.1-commit.21caa21",
|
|
80
|
+
"@aztec/stdlib": "0.0.1-commit.21caa21",
|
|
81
|
+
"@aztec/telemetry-client": "0.0.1-commit.21caa21",
|
|
82
|
+
"@aztec/world-state": "0.0.1-commit.21caa21",
|
|
81
83
|
"@google-cloud/storage": "^7.15.0",
|
|
82
84
|
"@iarna/toml": "^2.2.5",
|
|
83
85
|
"commander": "^12.1.0",
|
|
84
86
|
"lodash.chunk": "^4.2.0",
|
|
85
87
|
"source-map-support": "^0.5.21",
|
|
86
88
|
"tslib": "^2.4.0",
|
|
87
|
-
"zod": "^3.23.8"
|
|
88
|
-
"@aztec/noir-types": "0.0.0-test.1"
|
|
89
|
+
"zod": "^3.23.8"
|
|
89
90
|
},
|
|
90
91
|
"devDependencies": {
|
|
91
|
-
"@aztec/noir-contracts.js": "0.0.
|
|
92
|
-
"@jest/globals": "^
|
|
93
|
-
"@types/jest": "^
|
|
94
|
-
"@types/
|
|
95
|
-
"@types/node": "^18.7.23",
|
|
92
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.21caa21",
|
|
93
|
+
"@jest/globals": "^30.0.0",
|
|
94
|
+
"@types/jest": "^30.0.0",
|
|
95
|
+
"@types/node": "^22.15.17",
|
|
96
96
|
"@types/source-map-support": "^0.5.10",
|
|
97
|
+
"@typescript/native-preview": "7.0.0-dev.20251126.1",
|
|
97
98
|
"get-port": "^7.1.0",
|
|
98
|
-
"jest": "^
|
|
99
|
-
"jest-mock-extended": "^
|
|
99
|
+
"jest": "^30.0.0",
|
|
100
|
+
"jest-mock-extended": "^4.0.0",
|
|
100
101
|
"ts-node": "^10.9.1",
|
|
101
|
-
"typescript": "^5.
|
|
102
|
+
"typescript": "^5.3.3"
|
|
102
103
|
},
|
|
103
104
|
"files": [
|
|
104
105
|
"dest",
|
|
@@ -107,6 +108,6 @@
|
|
|
107
108
|
],
|
|
108
109
|
"types": "./dest/index.d.ts",
|
|
109
110
|
"engines": {
|
|
110
|
-
"node": ">=
|
|
111
|
+
"node": ">=20.10"
|
|
111
112
|
}
|
|
112
113
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './light.js';
|
|
@@ -0,0 +1,137 @@
|
|
|
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/fields';
|
|
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
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { ACVMConfig, BBConfig } from '@aztec/bb-prover';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type ConfigMappingsType,
|
|
4
|
+
booleanConfigHelper,
|
|
5
|
+
getConfigFromMappings,
|
|
6
|
+
numberConfigHelper,
|
|
7
|
+
} from '@aztec/foundation/config';
|
|
3
8
|
import { type ProverConfig, proverConfigMappings } from '@aztec/stdlib/interfaces/server';
|
|
4
9
|
|
|
5
10
|
import {
|
|
@@ -9,10 +14,11 @@ import {
|
|
|
9
14
|
proverBrokerConfigMappings,
|
|
10
15
|
} from './proving_broker/config.js';
|
|
11
16
|
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
/** The prover configuration as defined by the user. */
|
|
18
|
+
export type ProverClientUserConfig = ProverConfig & ProverAgentConfig & ProverBrokerConfig & BBConfig & ACVMConfig;
|
|
19
|
+
|
|
20
|
+
/** The prover configuration with all missing fields resolved. */
|
|
21
|
+
export type ProverClientConfig = ProverClientUserConfig & Required<Pick<ProverClientUserConfig, 'proverId'>>;
|
|
16
22
|
|
|
17
23
|
export const bbConfigMappings: ConfigMappingsType<BBConfig & ACVMConfig> = {
|
|
18
24
|
acvmWorkingDirectory: {
|
|
@@ -36,9 +42,19 @@ export const bbConfigMappings: ConfigMappingsType<BBConfig & ACVMConfig> = {
|
|
|
36
42
|
description: 'Whether to skip cleanup of bb temporary files',
|
|
37
43
|
...booleanConfigHelper(false),
|
|
38
44
|
},
|
|
45
|
+
numConcurrentIVCVerifiers: {
|
|
46
|
+
env: 'BB_NUM_IVC_VERIFIERS',
|
|
47
|
+
description: 'Max number of chonk verifiers to run concurrently',
|
|
48
|
+
...numberConfigHelper(8),
|
|
49
|
+
},
|
|
50
|
+
bbIVCConcurrency: {
|
|
51
|
+
env: 'BB_IVC_CONCURRENCY',
|
|
52
|
+
description: 'Number of threads to use for IVC verification',
|
|
53
|
+
...numberConfigHelper(1),
|
|
54
|
+
},
|
|
39
55
|
};
|
|
40
56
|
|
|
41
|
-
export const proverClientConfigMappings: ConfigMappingsType<
|
|
57
|
+
export const proverClientConfigMappings: ConfigMappingsType<ProverClientUserConfig> = {
|
|
42
58
|
...bbConfigMappings,
|
|
43
59
|
...proverConfigMappings,
|
|
44
60
|
...proverAgentConfigMappings,
|
|
@@ -50,6 +66,6 @@ export const proverClientConfigMappings: ConfigMappingsType<ProverClientConfig>
|
|
|
50
66
|
* Note: If an environment variable is not set, the default value is used.
|
|
51
67
|
* @returns The prover configuration.
|
|
52
68
|
*/
|
|
53
|
-
export function getProverEnvVars():
|
|
54
|
-
return getConfigFromMappings<
|
|
69
|
+
export function getProverEnvVars(): ProverClientUserConfig {
|
|
70
|
+
return getConfigFromMappings<ProverClientUserConfig>(proverClientConfigMappings);
|
|
55
71
|
}
|
|
@@ -0,0 +1,142 @@
|
|
|
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/fields';
|
|
5
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
+
import { L2BlockNew } from '@aztec/stdlib/block';
|
|
7
|
+
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
8
|
+
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
9
|
+
import { computeCheckpointOutHash, computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
10
|
+
import { CheckpointConstantData, CheckpointHeader, computeBlockHeadersHash } from '@aztec/stdlib/rollup';
|
|
11
|
+
import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
12
|
+
import { ContentCommitment, type GlobalVariables, type ProcessedTx, StateReference } from '@aztec/stdlib/tx';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
buildHeaderAndBodyFromTxs,
|
|
16
|
+
getTreeSnapshot,
|
|
17
|
+
insertSideEffects,
|
|
18
|
+
} from '../orchestrator/block-building-helpers.js';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Builds a checkpoint and its header and the blocks in it from a set of processed tx without running any circuits.
|
|
22
|
+
*
|
|
23
|
+
* It updates the l1-to-l2 message tree when starting a new checkpoint, inserts the side effects to note hash,
|
|
24
|
+
* nullifier, and public data trees, then updates the archive tree when a block is added.
|
|
25
|
+
*/
|
|
26
|
+
export class LightweightCheckpointBuilder {
|
|
27
|
+
private readonly logger = createLogger('lightweight-checkpoint-builder');
|
|
28
|
+
private lastArchives: AppendOnlyTreeSnapshot[] = [];
|
|
29
|
+
private spongeBlob: SpongeBlob;
|
|
30
|
+
private blocks: L2BlockNew[] = [];
|
|
31
|
+
private blobFields: Fr[] = [];
|
|
32
|
+
|
|
33
|
+
constructor(
|
|
34
|
+
private checkpointNumber: number,
|
|
35
|
+
private constants: CheckpointConstantData,
|
|
36
|
+
private l1ToL2Messages: Fr[],
|
|
37
|
+
private db: MerkleTreeWriteOperations,
|
|
38
|
+
) {
|
|
39
|
+
this.spongeBlob = SpongeBlob.init();
|
|
40
|
+
this.logger.debug('Starting new checkpoint', { constants: constants.toInspect(), l1ToL2Messages });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static async startNewCheckpoint(
|
|
44
|
+
checkpointNumber: number,
|
|
45
|
+
constants: CheckpointConstantData,
|
|
46
|
+
l1ToL2Messages: Fr[],
|
|
47
|
+
db: MerkleTreeWriteOperations,
|
|
48
|
+
): Promise<LightweightCheckpointBuilder> {
|
|
49
|
+
// Insert l1-to-l2 messages into the tree.
|
|
50
|
+
await db.appendLeaves(
|
|
51
|
+
MerkleTreeId.L1_TO_L2_MESSAGE_TREE,
|
|
52
|
+
padArrayEnd<Fr, number>(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return new LightweightCheckpointBuilder(checkpointNumber, constants, l1ToL2Messages, db);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async addBlock(globalVariables: GlobalVariables, endState: StateReference, txs: ProcessedTx[]): Promise<L2BlockNew> {
|
|
59
|
+
const isFirstBlock = this.blocks.length === 0;
|
|
60
|
+
if (isFirstBlock) {
|
|
61
|
+
this.lastArchives.push(await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const lastArchive = this.lastArchives.at(-1)!;
|
|
65
|
+
|
|
66
|
+
for (const tx of txs) {
|
|
67
|
+
await insertSideEffects(tx, this.db);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const { header, body, blockBlobFields } = await buildHeaderAndBodyFromTxs(
|
|
71
|
+
txs,
|
|
72
|
+
lastArchive,
|
|
73
|
+
endState,
|
|
74
|
+
globalVariables,
|
|
75
|
+
this.spongeBlob,
|
|
76
|
+
isFirstBlock,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
await this.db.updateArchive(header);
|
|
80
|
+
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
81
|
+
this.lastArchives.push(newArchive);
|
|
82
|
+
|
|
83
|
+
const block = new L2BlockNew(newArchive, header, body);
|
|
84
|
+
this.blocks.push(block);
|
|
85
|
+
|
|
86
|
+
await this.spongeBlob.absorb(blockBlobFields);
|
|
87
|
+
this.blobFields.push(...blockBlobFields);
|
|
88
|
+
|
|
89
|
+
this.logger.debug(`Built block ${header.getBlockNumber()}`, {
|
|
90
|
+
globalVariables: globalVariables.toInspect(),
|
|
91
|
+
archiveRoot: newArchive.root.toString(),
|
|
92
|
+
stateReference: header.state.toInspect(),
|
|
93
|
+
blockHash: (await block.hash()).toString(),
|
|
94
|
+
txs: block.body.txEffects.map(tx => tx.txHash.toString()),
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return block;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async completeCheckpoint(): Promise<Checkpoint> {
|
|
101
|
+
if (!this.blocks.length) {
|
|
102
|
+
throw new Error('No blocks added to checkpoint.');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const numBlobFields = this.blobFields.length + 1; // +1 for the checkpoint end marker.
|
|
106
|
+
const checkpointEndMarker = encodeCheckpointEndMarker({ numBlobFields });
|
|
107
|
+
this.blobFields.push(checkpointEndMarker);
|
|
108
|
+
|
|
109
|
+
const blocks = this.blocks;
|
|
110
|
+
const blockHeadersHash = await computeBlockHeadersHash(blocks.map(block => block.header));
|
|
111
|
+
|
|
112
|
+
const newArchive = this.lastArchives[this.lastArchives.length - 1];
|
|
113
|
+
|
|
114
|
+
const blobs = getBlobsPerL1Block(this.blobFields);
|
|
115
|
+
const blobsHash = computeBlobsHashFromBlobs(blobs);
|
|
116
|
+
|
|
117
|
+
const inHash = computeInHashFromL1ToL2Messages(this.l1ToL2Messages);
|
|
118
|
+
|
|
119
|
+
const outHash = computeCheckpointOutHash(blocks.map(block => block.body.txEffects.map(tx => tx.l2ToL1Msgs)));
|
|
120
|
+
|
|
121
|
+
const constants = this.constants!;
|
|
122
|
+
|
|
123
|
+
// timestamp of a checkpoint is the timestamp of the last block in the checkpoint.
|
|
124
|
+
const timestamp = blocks[blocks.length - 1].timestamp;
|
|
125
|
+
|
|
126
|
+
const totalManaUsed = blocks.reduce((acc, block) => acc.add(block.header.totalManaUsed), Fr.ZERO);
|
|
127
|
+
|
|
128
|
+
const header = CheckpointHeader.from({
|
|
129
|
+
lastArchiveRoot: this.lastArchives[0].root,
|
|
130
|
+
blockHeadersHash,
|
|
131
|
+
contentCommitment: new ContentCommitment(blobsHash, inHash, outHash),
|
|
132
|
+
slotNumber: constants.slotNumber,
|
|
133
|
+
timestamp,
|
|
134
|
+
coinbase: constants.coinbase,
|
|
135
|
+
feeRecipient: constants.feeRecipient,
|
|
136
|
+
gasFees: constants.gasFees,
|
|
137
|
+
totalManaUsed,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
return new Checkpoint(newArchive, header, blocks, this.checkpointNumber);
|
|
141
|
+
}
|
|
142
|
+
}
|
package/src/mocks/fixtures.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
1
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
2
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
4
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
6
5
|
import type { Logger } from '@aztec/foundation/log';
|
|
6
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
7
7
|
import { fileURLToPath } from '@aztec/foundation/url';
|
|
8
|
-
import {
|
|
8
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
9
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
10
|
+
import { type CircuitSimulator, NativeACVMSimulator, WASMSimulatorWithBlobs } from '@aztec/simulator/server';
|
|
9
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
12
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
11
|
-
import
|
|
12
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
13
|
-
import type { ProcessedTx } from '@aztec/stdlib/tx';
|
|
13
|
+
import { CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
14
14
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
15
15
|
|
|
16
16
|
import { promises as fs } from 'fs';
|
|
@@ -32,7 +32,7 @@ export const getEnvironmentConfig = async (logger: Logger) => {
|
|
|
32
32
|
try {
|
|
33
33
|
const expectedBBPath = BB_BINARY_PATH
|
|
34
34
|
? BB_BINARY_PATH
|
|
35
|
-
: `${path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../barretenberg/', BB_RELEASE_DIR)}/bb`;
|
|
35
|
+
: `${path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../barretenberg/', BB_RELEASE_DIR)}/bb-avm`;
|
|
36
36
|
await fs.access(expectedBBPath, fs.constants.R_OK);
|
|
37
37
|
const tempWorkingDirectory = `${TEMP_DIR}/${randomBytes(4).toString('hex')}`;
|
|
38
38
|
const bbWorkingDirectory = BB_WORKING_DIRECTORY ? BB_WORKING_DIRECTORY : `${tempWorkingDirectory}/bb`;
|
|
@@ -64,10 +64,10 @@ export const getEnvironmentConfig = async (logger: Logger) => {
|
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
export async function
|
|
67
|
+
export async function getSimulator(
|
|
68
68
|
config: { acvmWorkingDirectory: string | undefined; acvmBinaryPath: string | undefined },
|
|
69
69
|
logger?: Logger,
|
|
70
|
-
): Promise<
|
|
70
|
+
): Promise<CircuitSimulator> {
|
|
71
71
|
if (config.acvmBinaryPath && config.acvmWorkingDirectory) {
|
|
72
72
|
try {
|
|
73
73
|
await fs.access(config.acvmBinaryPath, fs.constants.R_OK);
|
|
@@ -84,34 +84,39 @@ export async function getSimulationProvider(
|
|
|
84
84
|
return new WASMSimulatorWithBlobs();
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
87
|
+
export const makeGlobals = (
|
|
88
|
+
blockNumber: number,
|
|
89
|
+
slotNumber = blockNumber,
|
|
90
|
+
overrides: Partial<FieldsOf<GlobalVariables> & FieldsOf<CheckpointConstantData>> = {},
|
|
91
|
+
) => {
|
|
92
|
+
const checkpointConstants = makeCheckpointConstants(slotNumber, overrides);
|
|
93
|
+
return GlobalVariables.from({
|
|
94
|
+
chainId: checkpointConstants.chainId,
|
|
95
|
+
version: checkpointConstants.version,
|
|
96
|
+
blockNumber /** block number */,
|
|
97
|
+
slotNumber: SlotNumber(slotNumber) /** slot number */,
|
|
98
|
+
timestamp: BigInt(blockNumber * 123) /** block number * 123 as pseudo-timestamp for testing */,
|
|
99
|
+
coinbase: checkpointConstants.coinbase,
|
|
100
|
+
feeRecipient: checkpointConstants.feeRecipient,
|
|
101
|
+
gasFees: checkpointConstants.gasFees,
|
|
102
|
+
...overrides,
|
|
103
|
+
});
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
export const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
export const makeCheckpointConstants = (
|
|
107
|
+
slotNumber: number,
|
|
108
|
+
overrides: Partial<FieldsOf<CheckpointConstantData>> = {},
|
|
109
|
+
) => {
|
|
110
|
+
return CheckpointConstantData.from({
|
|
111
|
+
chainId: Fr.ZERO,
|
|
112
|
+
version: Fr.ZERO,
|
|
113
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
114
|
+
protocolContractsHash,
|
|
115
|
+
proverId: Fr.ZERO,
|
|
116
|
+
slotNumber: SlotNumber(slotNumber),
|
|
117
|
+
coinbase: EthAddress.ZERO,
|
|
118
|
+
feeRecipient: AztecAddress.ZERO,
|
|
119
|
+
gasFees: GasFees.empty(),
|
|
120
|
+
...overrides,
|
|
121
|
+
});
|
|
117
122
|
};
|