@aztec/prover-client 0.0.1-commit.96dac018d → 0.0.1-commit.993d52e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/light/lightweight_checkpoint_builder.d.ts +2 -5
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +7 -21
- package/dest/mocks/test_context.js +1 -1
- package/dest/orchestrator/block-building-helpers.d.ts +1 -1
- package/package.json +15 -16
- package/src/light/lightweight_checkpoint_builder.ts +14 -21
- package/src/mocks/test_context.ts +1 -1
|
@@ -41,11 +41,8 @@ export declare class LightweightCheckpointBuilder {
|
|
|
41
41
|
addBlock(globalVariables: GlobalVariables, txs: ProcessedTx[], opts?: {
|
|
42
42
|
insertTxsEffects?: boolean;
|
|
43
43
|
expectedEndState?: StateReference;
|
|
44
|
-
}): Promise<
|
|
45
|
-
block: L2Block;
|
|
46
|
-
timings: Record<string, number>;
|
|
47
|
-
}>;
|
|
44
|
+
}): Promise<L2Block>;
|
|
48
45
|
completeCheckpoint(): Promise<Checkpoint>;
|
|
49
46
|
clone(): LightweightCheckpointBuilder;
|
|
50
47
|
}
|
|
51
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
48
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlnaHR3ZWlnaHRfY2hlY2twb2ludF9idWlsZGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGlnaHQvbGlnaHR3ZWlnaHRfY2hlY2twb2ludF9idWlsZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUF5QixNQUFNLGlDQUFpQyxDQUFDO0FBRS9GLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLE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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lightweight_checkpoint_builder.d.ts","sourceRoot":"","sources":["../../src/light/lightweight_checkpoint_builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAyB,MAAM,iCAAiC,CAAC;AAE/F,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"lightweight_checkpoint_builder.d.ts","sourceRoot":"","sources":["../../src/light/lightweight_checkpoint_builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAyB,MAAM,iCAAiC,CAAC;AAE/F,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAQjF,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAQ1B;;;;;GAKG;AACH,qBAAa,4BAA4B;aASrB,gBAAgB,EAAE,gBAAgB;aAClC,SAAS,EAAE,yBAAyB;IAC7C,qBAAqB,EAAE,MAAM;aACpB,cAAc,EAAE,EAAE,EAAE;IACpC,OAAO,CAAC,QAAQ,CAAC,2BAA2B;aAC5B,EAAE,EAAE,yBAAyB;IAb/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,OAAO,CAAC,YAAY,CAAgC;IACpD,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,UAAU,CAAY;IA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|
|
5
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
6
|
import { createLogger } from '@aztec/foundation/log';
|
|
7
|
-
import { elapsed } from '@aztec/foundation/timer';
|
|
8
7
|
import { L2Block } from '@aztec/stdlib/block';
|
|
9
8
|
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
10
9
|
import { accumulateCheckpointOutHashes, computeCheckpointOutHash, computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
@@ -98,31 +97,24 @@ import { buildHeaderAndBodyFromTxs, getTreeSnapshot, insertSideEffects } from '.
|
|
|
98
97
|
* Adds a new block to the checkpoint. The tx effects must have already been inserted into the db if
|
|
99
98
|
* this is called after tx processing, if that's not the case, then set `insertTxsEffects` to true.
|
|
100
99
|
*/ async addBlock(globalVariables, txs, opts = {}) {
|
|
101
|
-
const timings = {};
|
|
102
100
|
const isFirstBlock = this.blocks.length === 0;
|
|
103
101
|
// Empty blocks are only allowed as the first block in a checkpoint
|
|
104
102
|
if (!isFirstBlock && txs.length === 0) {
|
|
105
103
|
throw new Error('Cannot add empty block that is not the first block in the checkpoint.');
|
|
106
104
|
}
|
|
107
105
|
if (isFirstBlock) {
|
|
108
|
-
|
|
109
|
-
this.lastArchives.push(initialArchive);
|
|
110
|
-
timings.getInitialArchive = msGetInitialArchive;
|
|
106
|
+
this.lastArchives.push(await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db));
|
|
111
107
|
}
|
|
112
108
|
const lastArchive = this.lastArchives.at(-1);
|
|
113
109
|
if (opts.insertTxsEffects) {
|
|
114
110
|
this.logger.debug(`Inserting side effects for ${txs.length} txs for block ${globalVariables.blockNumber} into db`, {
|
|
115
111
|
txs: txs.map((tx)=>tx.hash.toString())
|
|
116
112
|
});
|
|
117
|
-
let msInsertSideEffects = 0;
|
|
118
113
|
for (const tx of txs){
|
|
119
|
-
|
|
120
|
-
msInsertSideEffects += ms;
|
|
114
|
+
await insertSideEffects(tx, this.db);
|
|
121
115
|
}
|
|
122
|
-
timings.insertSideEffects = msInsertSideEffects;
|
|
123
116
|
}
|
|
124
|
-
const
|
|
125
|
-
timings.getEndState = msGetEndState;
|
|
117
|
+
const endState = await this.db.getStateReference();
|
|
126
118
|
if (opts.expectedEndState && !endState.equals(opts.expectedEndState)) {
|
|
127
119
|
this.logger.error('End state after processing txs does not match expected end state', {
|
|
128
120
|
globalVariables: globalVariables.toInspect(),
|
|
@@ -131,18 +123,15 @@ import { buildHeaderAndBodyFromTxs, getTreeSnapshot, insertSideEffects } from '.
|
|
|
131
123
|
});
|
|
132
124
|
throw new Error(`End state does not match expected end state when building block ${globalVariables.blockNumber}`);
|
|
133
125
|
}
|
|
134
|
-
const
|
|
135
|
-
timings.buildHeaderAndBody = msBuildHeaderAndBody;
|
|
126
|
+
const { header, body, blockBlobFields } = await buildHeaderAndBodyFromTxs(txs, lastArchive, endState, globalVariables, this.spongeBlob, isFirstBlock);
|
|
136
127
|
header.state.validate();
|
|
137
128
|
await this.db.updateArchive(header);
|
|
138
|
-
const
|
|
139
|
-
timings.updateArchive = msUpdateArchive;
|
|
129
|
+
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
140
130
|
this.lastArchives.push(newArchive);
|
|
141
131
|
const indexWithinCheckpoint = IndexWithinCheckpoint(this.blocks.length);
|
|
142
132
|
const block = new L2Block(newArchive, header, body, this.checkpointNumber, indexWithinCheckpoint);
|
|
143
133
|
this.blocks.push(block);
|
|
144
|
-
|
|
145
|
-
timings.spongeAbsorb = msSpongeAbsorb;
|
|
134
|
+
await this.spongeBlob.absorb(blockBlobFields);
|
|
146
135
|
this.blobFields.push(...blockBlobFields);
|
|
147
136
|
this.logger.debug(`Built block ${header.getBlockNumber()}`, {
|
|
148
137
|
globalVariables: globalVariables.toInspect(),
|
|
@@ -151,10 +140,7 @@ import { buildHeaderAndBodyFromTxs, getTreeSnapshot, insertSideEffects } from '.
|
|
|
151
140
|
blockHash: (await block.hash()).toString(),
|
|
152
141
|
txs: block.body.txEffects.map((tx)=>tx.txHash.toString())
|
|
153
142
|
});
|
|
154
|
-
return
|
|
155
|
-
block,
|
|
156
|
-
timings
|
|
157
|
-
};
|
|
143
|
+
return block;
|
|
158
144
|
}
|
|
159
145
|
async completeCheckpoint() {
|
|
160
146
|
if (!this.blocks.length) {
|
|
@@ -182,7 +182,7 @@ export class TestContext {
|
|
|
182
182
|
for(let i = 0; i < numBlocks; i++){
|
|
183
183
|
const txs = blockTxs[i];
|
|
184
184
|
const state = blockEndStates[i];
|
|
185
|
-
const
|
|
185
|
+
const block = await builder.addBlock(blockGlobalVariables[i], txs, {
|
|
186
186
|
expectedEndState: state,
|
|
187
187
|
insertTxsEffects: true
|
|
188
188
|
});
|
|
@@ -22,7 +22,7 @@ export declare const insertSideEffects: (tx: ProcessedTx, db: MerkleTreeWriteOpe
|
|
|
22
22
|
nullifierInsertionResult: import("@aztec/stdlib/trees").BatchInsertionResult<number, number>;
|
|
23
23
|
publicDataInsertionResult: import("@aztec/stdlib/trees").SequentialInsertionResult<number>;
|
|
24
24
|
}>;
|
|
25
|
-
export declare function getChonkProofFromTx(tx: Tx | ProcessedTx): RecursiveProof<
|
|
25
|
+
export declare function getChonkProofFromTx(tx: Tx | ProcessedTx): RecursiveProof<1935>;
|
|
26
26
|
export declare function getPublicChonkVerifierPrivateInputsFromTx(tx: Tx | ProcessedTx, proverId: Fr): PublicChonkVerifierPrivateInputs;
|
|
27
27
|
export declare const buildBlobHints: (blobFields: Fr[]) => Promise<{
|
|
28
28
|
blobCommitments: import("@aztec/foundation/curves/bls12").BLS12Point[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/prover-client",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.993d52e",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -68,20 +68,19 @@
|
|
|
68
68
|
]
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
72
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
73
|
-
"@aztec/constants": "0.0.1-commit.
|
|
74
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
75
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
76
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
77
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
78
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
79
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
80
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
81
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
82
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
83
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
84
|
-
"@google-cloud/storage": "^7.15.0",
|
|
71
|
+
"@aztec/bb-prover": "0.0.1-commit.993d52e",
|
|
72
|
+
"@aztec/blob-lib": "0.0.1-commit.993d52e",
|
|
73
|
+
"@aztec/constants": "0.0.1-commit.993d52e",
|
|
74
|
+
"@aztec/ethereum": "0.0.1-commit.993d52e",
|
|
75
|
+
"@aztec/foundation": "0.0.1-commit.993d52e",
|
|
76
|
+
"@aztec/kv-store": "0.0.1-commit.993d52e",
|
|
77
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.993d52e",
|
|
78
|
+
"@aztec/noir-types": "0.0.1-commit.993d52e",
|
|
79
|
+
"@aztec/protocol-contracts": "0.0.1-commit.993d52e",
|
|
80
|
+
"@aztec/simulator": "0.0.1-commit.993d52e",
|
|
81
|
+
"@aztec/stdlib": "0.0.1-commit.993d52e",
|
|
82
|
+
"@aztec/telemetry-client": "0.0.1-commit.993d52e",
|
|
83
|
+
"@aztec/world-state": "0.0.1-commit.993d52e",
|
|
85
84
|
"@iarna/toml": "^2.2.5",
|
|
86
85
|
"commander": "^12.1.0",
|
|
87
86
|
"lodash.chunk": "^4.2.0",
|
|
@@ -90,7 +89,7 @@
|
|
|
90
89
|
"zod": "^3.23.8"
|
|
91
90
|
},
|
|
92
91
|
"devDependencies": {
|
|
93
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
92
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.993d52e",
|
|
94
93
|
"@jest/globals": "^30.0.0",
|
|
95
94
|
"@types/jest": "^30.0.0",
|
|
96
95
|
"@types/node": "^22.15.17",
|
|
@@ -4,7 +4,6 @@ import { type CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/
|
|
|
4
4
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
5
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
6
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
7
|
-
import { elapsed } from '@aztec/foundation/timer';
|
|
8
7
|
import { L2Block } from '@aztec/stdlib/block';
|
|
9
8
|
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
10
9
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
@@ -162,8 +161,7 @@ export class LightweightCheckpointBuilder {
|
|
|
162
161
|
globalVariables: GlobalVariables,
|
|
163
162
|
txs: ProcessedTx[],
|
|
164
163
|
opts: { insertTxsEffects?: boolean; expectedEndState?: StateReference } = {},
|
|
165
|
-
): Promise<
|
|
166
|
-
const timings: Record<string, number> = {};
|
|
164
|
+
): Promise<L2Block> {
|
|
167
165
|
const isFirstBlock = this.blocks.length === 0;
|
|
168
166
|
|
|
169
167
|
// Empty blocks are only allowed as the first block in a checkpoint
|
|
@@ -172,9 +170,7 @@ export class LightweightCheckpointBuilder {
|
|
|
172
170
|
}
|
|
173
171
|
|
|
174
172
|
if (isFirstBlock) {
|
|
175
|
-
|
|
176
|
-
this.lastArchives.push(initialArchive);
|
|
177
|
-
timings.getInitialArchive = msGetInitialArchive;
|
|
173
|
+
this.lastArchives.push(await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db));
|
|
178
174
|
}
|
|
179
175
|
|
|
180
176
|
const lastArchive = this.lastArchives.at(-1)!;
|
|
@@ -184,17 +180,12 @@ export class LightweightCheckpointBuilder {
|
|
|
184
180
|
`Inserting side effects for ${txs.length} txs for block ${globalVariables.blockNumber} into db`,
|
|
185
181
|
{ txs: txs.map(tx => tx.hash.toString()) },
|
|
186
182
|
);
|
|
187
|
-
let msInsertSideEffects = 0;
|
|
188
183
|
for (const tx of txs) {
|
|
189
|
-
|
|
190
|
-
msInsertSideEffects += ms;
|
|
184
|
+
await insertSideEffects(tx, this.db);
|
|
191
185
|
}
|
|
192
|
-
timings.insertSideEffects = msInsertSideEffects;
|
|
193
186
|
}
|
|
194
187
|
|
|
195
|
-
const
|
|
196
|
-
timings.getEndState = msGetEndState;
|
|
197
|
-
|
|
188
|
+
const endState = await this.db.getStateReference();
|
|
198
189
|
if (opts.expectedEndState && !endState.equals(opts.expectedEndState)) {
|
|
199
190
|
this.logger.error('End state after processing txs does not match expected end state', {
|
|
200
191
|
globalVariables: globalVariables.toInspect(),
|
|
@@ -204,24 +195,26 @@ export class LightweightCheckpointBuilder {
|
|
|
204
195
|
throw new Error(`End state does not match expected end state when building block ${globalVariables.blockNumber}`);
|
|
205
196
|
}
|
|
206
197
|
|
|
207
|
-
const
|
|
208
|
-
|
|
198
|
+
const { header, body, blockBlobFields } = await buildHeaderAndBodyFromTxs(
|
|
199
|
+
txs,
|
|
200
|
+
lastArchive,
|
|
201
|
+
endState,
|
|
202
|
+
globalVariables,
|
|
203
|
+
this.spongeBlob,
|
|
204
|
+
isFirstBlock,
|
|
209
205
|
);
|
|
210
|
-
timings.buildHeaderAndBody = msBuildHeaderAndBody;
|
|
211
206
|
|
|
212
207
|
header.state.validate();
|
|
213
208
|
|
|
214
209
|
await this.db.updateArchive(header);
|
|
215
|
-
const
|
|
216
|
-
timings.updateArchive = msUpdateArchive;
|
|
210
|
+
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
217
211
|
this.lastArchives.push(newArchive);
|
|
218
212
|
|
|
219
213
|
const indexWithinCheckpoint = IndexWithinCheckpoint(this.blocks.length);
|
|
220
214
|
const block = new L2Block(newArchive, header, body, this.checkpointNumber, indexWithinCheckpoint);
|
|
221
215
|
this.blocks.push(block);
|
|
222
216
|
|
|
223
|
-
|
|
224
|
-
timings.spongeAbsorb = msSpongeAbsorb;
|
|
217
|
+
await this.spongeBlob.absorb(blockBlobFields);
|
|
225
218
|
this.blobFields.push(...blockBlobFields);
|
|
226
219
|
|
|
227
220
|
this.logger.debug(`Built block ${header.getBlockNumber()}`, {
|
|
@@ -232,7 +225,7 @@ export class LightweightCheckpointBuilder {
|
|
|
232
225
|
txs: block.body.txEffects.map(tx => tx.txHash.toString()),
|
|
233
226
|
});
|
|
234
227
|
|
|
235
|
-
return
|
|
228
|
+
return block;
|
|
236
229
|
}
|
|
237
230
|
|
|
238
231
|
async completeCheckpoint(): Promise<Checkpoint> {
|
|
@@ -262,7 +262,7 @@ export class TestContext {
|
|
|
262
262
|
const txs = blockTxs[i];
|
|
263
263
|
const state = blockEndStates[i];
|
|
264
264
|
|
|
265
|
-
const
|
|
265
|
+
const block = await builder.addBlock(blockGlobalVariables[i], txs, {
|
|
266
266
|
expectedEndState: state,
|
|
267
267
|
insertTxsEffects: true,
|
|
268
268
|
});
|