@aztec/prover-client 0.87.2-nightly.20250524 → 0.87.2-nightly.20250525
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_builder/light.d.ts +12 -4
- package/dest/block_builder/light.d.ts.map +1 -1
- package/dest/block_builder/light.js +27 -17
- package/dest/mocks/test_context.js +2 -2
- package/dest/orchestrator/block-building-helpers.d.ts +1 -1
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +1 -1
- package/dest/orchestrator/orchestrator.js +2 -2
- package/package.json +15 -15
- package/src/block_builder/light.ts +28 -15
- package/src/mocks/test_context.ts +2 -2
- package/src/orchestrator/block-building-helpers.ts +1 -1
- package/src/orchestrator/orchestrator.ts +2 -2
|
@@ -5,11 +5,19 @@ import { type GlobalVariables, type ProcessedTx } from '@aztec/stdlib/tx';
|
|
|
5
5
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
6
6
|
/**
|
|
7
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 `insertSideEffectsAndBuildBaseRollupHints` for you.
|
|
8
17
|
*/
|
|
9
18
|
export declare class LightweightBlockBuilder implements BlockBuilder {
|
|
10
19
|
private db;
|
|
11
20
|
private telemetry;
|
|
12
|
-
private spongeBlobState?;
|
|
13
21
|
private globalVariables?;
|
|
14
22
|
private l1ToL2Messages?;
|
|
15
23
|
private txs;
|
|
@@ -26,8 +34,8 @@ export declare class LightweightBlockBuilderFactory {
|
|
|
26
34
|
create(db: MerkleTreeWriteOperations): BlockBuilder;
|
|
27
35
|
}
|
|
28
36
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @param db - A db fork to use for block building.
|
|
37
|
+
* Inserts the processed transactions into the DB, then creates a block.
|
|
38
|
+
* @param db - A db fork to use for block building which WILL BE MODIFIED.
|
|
31
39
|
*/
|
|
32
|
-
export declare function
|
|
40
|
+
export declare function buildBlockWithCleanDB(txs: ProcessedTx[], globalVariables: GlobalVariables, l1ToL2Messages: Fr[], db: MerkleTreeWriteOperations, telemetry?: TelemetryClient): Promise<L2Block>;
|
|
33
41
|
//# sourceMappingURL=light.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"light.d.ts","sourceRoot":"","sources":["../../src/block_builder/light.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE/F,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAmB,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAQnF
|
|
1
|
+
{"version":3,"file":"light.d.ts","sourceRoot":"","sources":["../../src/block_builder/light.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE/F,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAmB,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAQnF;;;;;;;;;;;GAWG;AACH,qBAAa,uBAAwB,YAAW,YAAY;IASxD,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,SAAS;IATnB,OAAO,CAAC,eAAe,CAAC,CAAkB;IAC1C,OAAO,CAAC,cAAc,CAAC,CAAO;IAE9B,OAAO,CAAC,GAAG,CAA4B;IAEvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+C;gBAG5D,EAAE,EAAE,yBAAyB,EAC7B,SAAS,GAAE,eAAsC;IAGrD,aAAa,CAAC,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1F,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAWzC,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;YAIvB,UAAU;CAoBzB;AAED,qBAAa,8BAA8B;IAC7B,OAAO,CAAC,SAAS;gBAAT,SAAS,GAAE,eAAsC;IAErE,MAAM,CAAC,EAAE,EAAE,yBAAyB,GAAG,YAAY;CAGpD;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,WAAW,EAAE,EAClB,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,EAAE,EAAE,EACpB,EAAE,EAAE,yBAAyB,EAC7B,SAAS,GAAE,eAAsC,oBAUlD"}
|
|
@@ -7,13 +7,21 @@ import { L2Block } from '@aztec/stdlib/block';
|
|
|
7
7
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
8
8
|
import { toNumBlobFields } from '@aztec/stdlib/tx';
|
|
9
9
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
10
|
-
import {
|
|
10
|
+
import { buildHeaderAndBodyFromTxs, getTreeSnapshot, insertSideEffectsAndBuildBaseRollupHints } from '../orchestrator/block-building-helpers.js';
|
|
11
11
|
/**
|
|
12
12
|
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
13
|
+
*
|
|
14
|
+
* NOTE: the onus is ON THE CALLER to update the db that is passed in with the notes hashes, nullifiers, etc
|
|
15
|
+
* PRIOR to calling `buildBlock`.
|
|
16
|
+
*
|
|
17
|
+
* Why? Because if you are, e.g. building a block in practice from TxObjects, you are using the
|
|
18
|
+
* PublicProcessor which will do this for you as it processes transactions.
|
|
19
|
+
*
|
|
20
|
+
* If you haven't already inserted the side effects, e.g. because you are in a testing context, you can use the helper
|
|
21
|
+
* function `buildBlockWithCleanDB`, which calls `insertSideEffectsAndBuildBaseRollupHints` for you.
|
|
13
22
|
*/ export class LightweightBlockBuilder {
|
|
14
23
|
db;
|
|
15
24
|
telemetry;
|
|
16
|
-
spongeBlobState;
|
|
17
25
|
globalVariables;
|
|
18
26
|
l1ToL2Messages;
|
|
19
27
|
txs;
|
|
@@ -21,7 +29,6 @@ import { buildBaseRollupHints, buildHeaderAndBodyFromTxs, getTreeSnapshot } from
|
|
|
21
29
|
constructor(db, telemetry = getTelemetryClient()){
|
|
22
30
|
this.db = db;
|
|
23
31
|
this.telemetry = telemetry;
|
|
24
|
-
this.txs = [];
|
|
25
32
|
this.logger = createLogger('prover-client:block_builder');
|
|
26
33
|
}
|
|
27
34
|
async startNewBlock(globalVariables, l1ToL2Messages) {
|
|
@@ -31,26 +38,25 @@ import { buildBaseRollupHints, buildHeaderAndBodyFromTxs, getTreeSnapshot } from
|
|
|
31
38
|
});
|
|
32
39
|
this.globalVariables = globalVariables;
|
|
33
40
|
this.l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
34
|
-
this.txs =
|
|
35
|
-
this.spongeBlobState = undefined;
|
|
41
|
+
this.txs = undefined;
|
|
36
42
|
// Update L1 to L2 tree
|
|
37
43
|
await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages);
|
|
38
44
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this.txs.push(
|
|
46
|
-
await buildBaseRollupHints(tx, this.globalVariables, this.db, this.spongeBlobState);
|
|
45
|
+
addTxs(txs) {
|
|
46
|
+
// Most times, `addTxs` is only called once per block.
|
|
47
|
+
// So avoid copies.
|
|
48
|
+
if (this.txs === undefined) {
|
|
49
|
+
this.txs = txs;
|
|
50
|
+
} else {
|
|
51
|
+
this.txs.push(...txs);
|
|
47
52
|
}
|
|
53
|
+
return Promise.resolve();
|
|
48
54
|
}
|
|
49
55
|
setBlockCompleted() {
|
|
50
56
|
return this.buildBlock();
|
|
51
57
|
}
|
|
52
58
|
async buildBlock() {
|
|
53
|
-
const { header, body } = await buildHeaderAndBodyFromTxs(this.txs, this.globalVariables, this.l1ToL2Messages, this.db);
|
|
59
|
+
const { header, body } = await buildHeaderAndBodyFromTxs(this.txs ?? [], this.globalVariables, this.l1ToL2Messages, this.db);
|
|
54
60
|
await this.db.updateArchive(header);
|
|
55
61
|
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
56
62
|
const block = new L2Block(newArchive, header, body);
|
|
@@ -72,9 +78,13 @@ export class LightweightBlockBuilderFactory {
|
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
/**
|
|
75
|
-
*
|
|
76
|
-
* @param db - A db fork to use for block building.
|
|
77
|
-
*/ export async function
|
|
81
|
+
* Inserts the processed transactions into the DB, then creates a block.
|
|
82
|
+
* @param db - A db fork to use for block building which WILL BE MODIFIED.
|
|
83
|
+
*/ export async function buildBlockWithCleanDB(txs, globalVariables, l1ToL2Messages, db, telemetry = getTelemetryClient()) {
|
|
84
|
+
const spongeBlobState = SpongeBlob.init(toNumBlobFields(txs));
|
|
85
|
+
for (const tx of txs){
|
|
86
|
+
await insertSideEffectsAndBuildBaseRollupHints(tx, globalVariables, db, spongeBlobState);
|
|
87
|
+
}
|
|
78
88
|
const builder = new LightweightBlockBuilder(db, telemetry);
|
|
79
89
|
await builder.startNewBlock(globalVariables, l1ToL2Messages);
|
|
80
90
|
await builder.addTxs(txs);
|
|
@@ -16,7 +16,7 @@ import { promises as fs } from 'fs';
|
|
|
16
16
|
// TODO(#12613) This means of sharing test code is not ideal.
|
|
17
17
|
// eslint-disable-next-line import/no-relative-packages
|
|
18
18
|
import { TestCircuitProver } from '../../../bb-prover/src/test/test_circuit_prover.js';
|
|
19
|
-
import {
|
|
19
|
+
import { buildBlockWithCleanDB } from '../block_builder/light.js';
|
|
20
20
|
import { ProvingOrchestrator } from '../orchestrator/index.js';
|
|
21
21
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
22
22
|
import { TestBroker } from '../test/mock_prover.js';
|
|
@@ -151,7 +151,7 @@ export class TestContext {
|
|
|
151
151
|
...makeProcessedTxOpts(i)
|
|
152
152
|
}));
|
|
153
153
|
await this.setTreeRoots(txs);
|
|
154
|
-
const block = await
|
|
154
|
+
const block = await buildBlockWithCleanDB(txs, globalVariables, msgs, db);
|
|
155
155
|
this.headers.set(blockNum, block.header);
|
|
156
156
|
await this.worldState.handleL2BlockAndMessages(block, msgs);
|
|
157
157
|
return {
|
|
@@ -18,7 +18,7 @@ type BaseTreeNames = 'NoteHashTree' | 'ContractTree' | 'NullifierTree' | 'Public
|
|
|
18
18
|
* Type representing the names of the trees.
|
|
19
19
|
*/
|
|
20
20
|
export type TreeNames = BaseTreeNames | 'L1ToL2MessageTree' | 'Archive';
|
|
21
|
-
export declare const
|
|
21
|
+
export declare const insertSideEffectsAndBuildBaseRollupHints: (tx: ProcessedTx, globalVariables: GlobalVariables, db: MerkleTreeWriteOperations, startSpongeBlob: SpongeBlob) => Promise<PublicBaseRollupHints | PrivateBaseRollupHints>;
|
|
22
22
|
export declare function getPublicDataHint(db: MerkleTreeWriteOperations, leafSlot: bigint): Promise<PublicDataHint>;
|
|
23
23
|
export declare const buildBlobHints: (txEffects: TxEffect[]) => Promise<{
|
|
24
24
|
blobFields: Fr[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-building-helpers.d.ts","sourceRoot":"","sources":["../../src/orchestrator/block-building-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAiBxD,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,KAAK,EAAmD,MAAM,6BAA6B,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAqD,MAAM,yBAAyB,CAAC;AAI/G,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,iCAAiC,EACtC,kBAAkB,EAClB,sBAAsB,EAEtB,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,sBAAsB,EACtB,YAAY,EAKb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EAEX,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,WAAW,EAChB,cAAc,EACd,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEnE;;GAEG;AACH,KAAK,aAAa,GAAG,cAAc,GAAG,cAAc,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAC1F;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,mBAAmB,GAAG,SAAS,CAAC;AAGxE,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"block-building-helpers.d.ts","sourceRoot":"","sources":["../../src/orchestrator/block-building-helpers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,7 +17,7 @@ import { AppendOnlyTreeSnapshot, MerkleTreeId, NullifierLeafPreimage, PublicData
|
|
|
17
17
|
import { BlockHeader, ContentCommitment, PartialStateReference, StateReference, TxEffect } from '@aztec/stdlib/tx';
|
|
18
18
|
import { Attributes, runInSpan } from '@aztec/telemetry-client';
|
|
19
19
|
// Builds the hints for base rollup. Updating the contract, nullifier, and data trees in the process.
|
|
20
|
-
export const
|
|
20
|
+
export const insertSideEffectsAndBuildBaseRollupHints = runInSpan('BlockBuilderHelpers', 'buildBaseRollupHints', async (span, tx, globalVariables, db, startSpongeBlob)=>{
|
|
21
21
|
span.setAttribute(Attributes.TX_HASH, tx.hash.toString());
|
|
22
22
|
// Get trees info before any changes hit
|
|
23
23
|
const constants = await getConstantRollupData(globalVariables, db);
|
|
@@ -22,7 +22,7 @@ import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
|
22
22
|
import { toNumBlobFields } from '@aztec/stdlib/tx';
|
|
23
23
|
import { Attributes, getTelemetryClient, trackSpan, wrapCallbackInSpan } from '@aztec/telemetry-client';
|
|
24
24
|
import { inspect } from 'util';
|
|
25
|
-
import {
|
|
25
|
+
import { buildHeaderAndBodyFromTxs, getLastSiblingPath, getRootTreeSiblingPath, getSubtreeSiblingPath, getTreeSnapshot, insertSideEffectsAndBuildBaseRollupHints, validatePartialState, validateTx } from './block-building-helpers.js';
|
|
26
26
|
import { EpochProvingState } from './epoch-proving-state.js';
|
|
27
27
|
import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
|
|
28
28
|
import { TxProvingState } from './tx-proving-state.js';
|
|
@@ -333,7 +333,7 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
333
333
|
const db = this.dbs.get(provingState.blockNumber);
|
|
334
334
|
// We build the base rollup inputs using a mock proof and verification key.
|
|
335
335
|
// These will be overwritten later once we have proven the tube circuit and any public kernels
|
|
336
|
-
const [ms, hints] = await elapsed(
|
|
336
|
+
const [ms, hints] = await elapsed(insertSideEffectsAndBuildBaseRollupHints(tx, provingState.globalVariables, db, provingState.spongeBlobState));
|
|
337
337
|
this.metrics.recordBaseRollupInputs(ms);
|
|
338
338
|
const promises = [
|
|
339
339
|
MerkleTreeId.NOTE_HASH_TREE,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/prover-client",
|
|
3
|
-
"version": "0.87.2-nightly.
|
|
3
|
+
"version": "0.87.2-nightly.20250525",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -64,19 +64,19 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/bb-prover": "0.87.2-nightly.
|
|
68
|
-
"@aztec/blob-lib": "0.87.2-nightly.
|
|
69
|
-
"@aztec/constants": "0.87.2-nightly.
|
|
70
|
-
"@aztec/ethereum": "0.87.2-nightly.
|
|
71
|
-
"@aztec/foundation": "0.87.2-nightly.
|
|
72
|
-
"@aztec/kv-store": "0.87.2-nightly.
|
|
73
|
-
"@aztec/noir-protocol-circuits-types": "0.87.2-nightly.
|
|
74
|
-
"@aztec/noir-types": "0.87.2-nightly.
|
|
75
|
-
"@aztec/protocol-contracts": "0.87.2-nightly.
|
|
76
|
-
"@aztec/simulator": "0.87.2-nightly.
|
|
77
|
-
"@aztec/stdlib": "0.87.2-nightly.
|
|
78
|
-
"@aztec/telemetry-client": "0.87.2-nightly.
|
|
79
|
-
"@aztec/world-state": "0.87.2-nightly.
|
|
67
|
+
"@aztec/bb-prover": "0.87.2-nightly.20250525",
|
|
68
|
+
"@aztec/blob-lib": "0.87.2-nightly.20250525",
|
|
69
|
+
"@aztec/constants": "0.87.2-nightly.20250525",
|
|
70
|
+
"@aztec/ethereum": "0.87.2-nightly.20250525",
|
|
71
|
+
"@aztec/foundation": "0.87.2-nightly.20250525",
|
|
72
|
+
"@aztec/kv-store": "0.87.2-nightly.20250525",
|
|
73
|
+
"@aztec/noir-protocol-circuits-types": "0.87.2-nightly.20250525",
|
|
74
|
+
"@aztec/noir-types": "0.87.2-nightly.20250525",
|
|
75
|
+
"@aztec/protocol-contracts": "0.87.2-nightly.20250525",
|
|
76
|
+
"@aztec/simulator": "0.87.2-nightly.20250525",
|
|
77
|
+
"@aztec/stdlib": "0.87.2-nightly.20250525",
|
|
78
|
+
"@aztec/telemetry-client": "0.87.2-nightly.20250525",
|
|
79
|
+
"@aztec/world-state": "0.87.2-nightly.20250525",
|
|
80
80
|
"@google-cloud/storage": "^7.15.0",
|
|
81
81
|
"@iarna/toml": "^2.2.5",
|
|
82
82
|
"commander": "^12.1.0",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"zod": "^3.23.8"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@aztec/noir-contracts.js": "0.87.2-nightly.
|
|
89
|
+
"@aztec/noir-contracts.js": "0.87.2-nightly.20250525",
|
|
90
90
|
"@jest/globals": "^29.5.0",
|
|
91
91
|
"@types/jest": "^29.5.0",
|
|
92
92
|
"@types/node": "^22.15.17",
|
|
@@ -10,20 +10,28 @@ import { type GlobalVariables, type ProcessedTx, toNumBlobFields } from '@aztec/
|
|
|
10
10
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
|
-
buildBaseRollupHints,
|
|
14
13
|
buildHeaderAndBodyFromTxs,
|
|
15
14
|
getTreeSnapshot,
|
|
15
|
+
insertSideEffectsAndBuildBaseRollupHints,
|
|
16
16
|
} from '../orchestrator/block-building-helpers.js';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
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.
|
|
20
29
|
*/
|
|
21
30
|
export class LightweightBlockBuilder implements BlockBuilder {
|
|
22
|
-
private spongeBlobState?: SpongeBlob;
|
|
23
31
|
private globalVariables?: GlobalVariables;
|
|
24
32
|
private l1ToL2Messages?: Fr[];
|
|
25
33
|
|
|
26
|
-
private txs: ProcessedTx[]
|
|
34
|
+
private txs: ProcessedTx[] | undefined;
|
|
27
35
|
|
|
28
36
|
private readonly logger = createLogger('prover-client:block_builder');
|
|
29
37
|
|
|
@@ -36,20 +44,21 @@ export class LightweightBlockBuilder implements BlockBuilder {
|
|
|
36
44
|
this.logger.debug('Starting new block', { globalVariables: globalVariables.toInspect(), l1ToL2Messages });
|
|
37
45
|
this.globalVariables = globalVariables;
|
|
38
46
|
this.l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
39
|
-
this.txs =
|
|
40
|
-
this.spongeBlobState = undefined;
|
|
47
|
+
this.txs = undefined;
|
|
41
48
|
|
|
42
49
|
// Update L1 to L2 tree
|
|
43
50
|
await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages!);
|
|
44
51
|
}
|
|
45
52
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.txs
|
|
51
|
-
|
|
53
|
+
addTxs(txs: ProcessedTx[]): Promise<void> {
|
|
54
|
+
// Most times, `addTxs` is only called once per block.
|
|
55
|
+
// So avoid copies.
|
|
56
|
+
if (this.txs === undefined) {
|
|
57
|
+
this.txs = txs;
|
|
58
|
+
} else {
|
|
59
|
+
this.txs.push(...txs);
|
|
52
60
|
}
|
|
61
|
+
return Promise.resolve();
|
|
53
62
|
}
|
|
54
63
|
|
|
55
64
|
setBlockCompleted(): Promise<L2Block> {
|
|
@@ -58,7 +67,7 @@ export class LightweightBlockBuilder implements BlockBuilder {
|
|
|
58
67
|
|
|
59
68
|
private async buildBlock(): Promise<L2Block> {
|
|
60
69
|
const { header, body } = await buildHeaderAndBodyFromTxs(
|
|
61
|
-
this.txs,
|
|
70
|
+
this.txs ?? [],
|
|
62
71
|
this.globalVariables!,
|
|
63
72
|
this.l1ToL2Messages!,
|
|
64
73
|
this.db,
|
|
@@ -87,16 +96,20 @@ export class LightweightBlockBuilderFactory {
|
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
/**
|
|
90
|
-
*
|
|
91
|
-
* @param db - A db fork to use for block building.
|
|
99
|
+
* Inserts the processed transactions into the DB, then creates a block.
|
|
100
|
+
* @param db - A db fork to use for block building which WILL BE MODIFIED.
|
|
92
101
|
*/
|
|
93
|
-
export async function
|
|
102
|
+
export async function buildBlockWithCleanDB(
|
|
94
103
|
txs: ProcessedTx[],
|
|
95
104
|
globalVariables: GlobalVariables,
|
|
96
105
|
l1ToL2Messages: Fr[],
|
|
97
106
|
db: MerkleTreeWriteOperations,
|
|
98
107
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
99
108
|
) {
|
|
109
|
+
const spongeBlobState = SpongeBlob.init(toNumBlobFields(txs));
|
|
110
|
+
for (const tx of txs) {
|
|
111
|
+
await insertSideEffectsAndBuildBaseRollupHints(tx, globalVariables, db, spongeBlobState);
|
|
112
|
+
}
|
|
100
113
|
const builder = new LightweightBlockBuilder(db, telemetry);
|
|
101
114
|
await builder.startNewBlock(globalVariables, l1ToL2Messages);
|
|
102
115
|
await builder.addTxs(txs);
|
|
@@ -23,7 +23,7 @@ import { promises as fs } from 'fs';
|
|
|
23
23
|
// TODO(#12613) This means of sharing test code is not ideal.
|
|
24
24
|
// eslint-disable-next-line import/no-relative-packages
|
|
25
25
|
import { TestCircuitProver } from '../../../bb-prover/src/test/test_circuit_prover.js';
|
|
26
|
-
import {
|
|
26
|
+
import { buildBlockWithCleanDB } from '../block_builder/light.js';
|
|
27
27
|
import { ProvingOrchestrator } from '../orchestrator/index.js';
|
|
28
28
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
29
29
|
import { TestBroker } from '../test/mock_prover.js';
|
|
@@ -193,7 +193,7 @@ export class TestContext {
|
|
|
193
193
|
);
|
|
194
194
|
await this.setTreeRoots(txs);
|
|
195
195
|
|
|
196
|
-
const block = await
|
|
196
|
+
const block = await buildBlockWithCleanDB(txs, globalVariables, msgs, db);
|
|
197
197
|
this.headers.set(blockNum, block.header);
|
|
198
198
|
await this.worldState.handleL2BlockAndMessages(block, msgs);
|
|
199
199
|
return { block, txs, msgs };
|
|
@@ -64,7 +64,7 @@ type BaseTreeNames = 'NoteHashTree' | 'ContractTree' | 'NullifierTree' | 'Public
|
|
|
64
64
|
export type TreeNames = BaseTreeNames | 'L1ToL2MessageTree' | 'Archive';
|
|
65
65
|
|
|
66
66
|
// Builds the hints for base rollup. Updating the contract, nullifier, and data trees in the process.
|
|
67
|
-
export const
|
|
67
|
+
export const insertSideEffectsAndBuildBaseRollupHints = runInSpan(
|
|
68
68
|
'BlockBuilderHelpers',
|
|
69
69
|
'buildBaseRollupHints',
|
|
70
70
|
async (
|
|
@@ -47,12 +47,12 @@ import {
|
|
|
47
47
|
import { inspect } from 'util';
|
|
48
48
|
|
|
49
49
|
import {
|
|
50
|
-
buildBaseRollupHints,
|
|
51
50
|
buildHeaderAndBodyFromTxs,
|
|
52
51
|
getLastSiblingPath,
|
|
53
52
|
getRootTreeSiblingPath,
|
|
54
53
|
getSubtreeSiblingPath,
|
|
55
54
|
getTreeSnapshot,
|
|
55
|
+
insertSideEffectsAndBuildBaseRollupHints,
|
|
56
56
|
validatePartialState,
|
|
57
57
|
validateTx,
|
|
58
58
|
} from './block-building-helpers.js';
|
|
@@ -489,7 +489,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
489
489
|
// We build the base rollup inputs using a mock proof and verification key.
|
|
490
490
|
// These will be overwritten later once we have proven the tube circuit and any public kernels
|
|
491
491
|
const [ms, hints] = await elapsed(
|
|
492
|
-
|
|
492
|
+
insertSideEffectsAndBuildBaseRollupHints(tx, provingState.globalVariables, db, provingState.spongeBlobState),
|
|
493
493
|
);
|
|
494
494
|
|
|
495
495
|
this.metrics.recordBaseRollupInputs(ms);
|