@aztec/prover-client 1.0.0-nightly.20250611 → 1.0.0-nightly.20250612
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/mocks/fixtures.js +1 -1
- package/dest/orchestrator/block-building-helpers.d.ts +3 -2
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +21 -16
- package/dest/orchestrator/block-proving-state.d.ts +1 -1
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +6 -9
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +4 -3
- package/package.json +15 -15
- package/src/mocks/fixtures.ts +1 -1
- package/src/orchestrator/block-building-helpers.ts +29 -28
- package/src/orchestrator/block-proving-state.ts +14 -14
- package/src/orchestrator/orchestrator.ts +6 -4
package/dest/mocks/fixtures.js
CHANGED
|
@@ -73,5 +73,5 @@ export const updateExpectedTreesFromTxs = async (db, txs)=>{
|
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
export const makeGlobals = (blockNumber)=>{
|
|
76
|
-
return new GlobalVariables(Fr.ZERO, Fr.ZERO, new Fr(blockNumber), new Fr(blockNumber),
|
|
76
|
+
return new GlobalVariables(Fr.ZERO, Fr.ZERO, new Fr(blockNumber), new Fr(blockNumber), BigInt(blockNumber), EthAddress.ZERO, AztecAddress.ZERO, GasFees.empty());
|
|
77
77
|
};
|
|
@@ -27,12 +27,13 @@ export declare const buildBlobHints: (txEffects: TxEffect[]) => Promise<{
|
|
|
27
27
|
blobsHash: Fr;
|
|
28
28
|
}>;
|
|
29
29
|
export declare const accumulateBlobs: (txs: ProcessedTx[], startBlobAccumulator: BatchedBlobAccumulator) => Promise<BatchedBlobAccumulator>;
|
|
30
|
-
export declare const buildHeaderFromCircuitOutputs: (previousRollupData: BaseOrMergeRollupPublicInputs[], parityPublicInputs: ParityPublicInputs, rootRollupOutputs: BlockRootOrBlockMergePublicInputs, blobsHash:
|
|
30
|
+
export declare const buildHeaderFromCircuitOutputs: (previousRollupData: BaseOrMergeRollupPublicInputs[], parityPublicInputs: ParityPublicInputs, rootRollupOutputs: BlockRootOrBlockMergePublicInputs, blobsHash: Fr, endState: StateReference) => BlockHeader;
|
|
31
31
|
export declare const buildHeaderAndBodyFromTxs: (txs: ProcessedTx[], globalVariables: GlobalVariables, l1ToL2Messages: Fr[], db: MerkleTreeReadOperations) => Promise<{
|
|
32
32
|
header: BlockHeader;
|
|
33
33
|
body: Body;
|
|
34
34
|
}>;
|
|
35
|
-
export declare function getBlobsHashFromBlobs(inputs: Blob[]):
|
|
35
|
+
export declare function getBlobsHashFromBlobs(inputs: Blob[]): Fr;
|
|
36
|
+
export declare function getEmptyBlockBlobsHash(): Promise<Fr>;
|
|
36
37
|
export declare function validateBlockRootOutput(blockRootOutput: BlockRootOrBlockMergePublicInputs, blockHeader: BlockHeader, db: MerkleTreeReadOperations): Promise<void>;
|
|
37
38
|
export declare const validateState: (state: StateReference, db: MerkleTreeReadOperations) => Promise<void>;
|
|
38
39
|
export declare function getLastSiblingPath<TID extends MerkleTreeId>(treeId: TID, db: MerkleTreeReadOperations): Promise<Tuple<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,sBAAsB,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAiBhF,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"block-building-helpers.d.ts","sourceRoot":"","sources":["../../src/orchestrator/block-building-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,MA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ob } from '@aztec/blob-lib';
|
|
|
2
2
|
import { ARCHIVE_HEIGHT, MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NOTE_HASH_SUBTREE_HEIGHT, NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_SUBTREE_HEIGHT, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, PUBLIC_DATA_TREE_HEIGHT } from '@aztec/constants';
|
|
3
3
|
import { makeTuple } from '@aztec/foundation/array';
|
|
4
4
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
5
|
-
import { sha256Trunc } from '@aztec/foundation/crypto';
|
|
5
|
+
import { sha256ToField, sha256Trunc } from '@aztec/foundation/crypto';
|
|
6
6
|
import { BLS12Point, Fr } from '@aztec/foundation/fields';
|
|
7
|
-
import { assertLength,
|
|
7
|
+
import { assertLength, toFriendlyJSON } from '@aztec/foundation/serialize';
|
|
8
8
|
import { MembershipWitness, MerkleTreeCalculator, computeUnbalancedMerkleRoot } from '@aztec/foundation/trees';
|
|
9
9
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
10
10
|
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
@@ -114,7 +114,7 @@ export async function getPublicDataHint(db, leafSlot) {
|
|
|
114
114
|
}
|
|
115
115
|
export const buildBlobHints = runInSpan('BlockBuilderHelpers', 'buildBlobHints', async (_span, txEffects)=>{
|
|
116
116
|
const blobFields = txEffects.flatMap((tx)=>tx.toBlobFields());
|
|
117
|
-
const blobs = await Blob.
|
|
117
|
+
const blobs = await Blob.getBlobsPerBlock(blobFields);
|
|
118
118
|
// TODO(#13430): The blobsHash is confusingly similar to blobCommitmentsHash, calculated from below blobCommitments:
|
|
119
119
|
// - blobsHash := sha256([blobhash_0, ..., blobhash_m]) = a hash of all blob hashes in a block with m+1 blobs inserted into the header, exists so a user can cross check blobs.
|
|
120
120
|
// - blobCommitmentsHash := sha256( ...sha256(sha256(C_0), C_1) ... C_n) = iteratively calculated hash of all blob commitments in an epoch with n+1 blobs (see calculateBlobCommitmentsHash()),
|
|
@@ -131,7 +131,7 @@ export const buildBlobHints = runInSpan('BlockBuilderHelpers', 'buildBlobHints',
|
|
|
131
131
|
});
|
|
132
132
|
export const accumulateBlobs = runInSpan('BlockBuilderHelpers', 'accumulateBlobs', async (_span, txs, startBlobAccumulator)=>{
|
|
133
133
|
const blobFields = txs.flatMap((tx)=>tx.txEffect.toBlobFields());
|
|
134
|
-
const blobs = await Blob.
|
|
134
|
+
const blobs = await Blob.getBlobsPerBlock(blobFields);
|
|
135
135
|
const endBlobAccumulator = startBlobAccumulator.accumulateBlobs(blobs);
|
|
136
136
|
return endBlobAccumulator;
|
|
137
137
|
});
|
|
@@ -139,12 +139,11 @@ export const buildHeaderFromCircuitOutputs = runInSpan('BlockBuilderHelpers', 'b
|
|
|
139
139
|
if (previousRollupData.length > 2) {
|
|
140
140
|
throw new Error(`There can't be more than 2 previous rollups. Received ${previousRollupData.length}.`);
|
|
141
141
|
}
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
previousRollupData[
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const contentCommitment = new ContentCommitment(new Fr(numTxs), blobsHash, parityPublicInputs.shaRoot.toBuffer(), outHash);
|
|
142
|
+
const outHash = previousRollupData.length === 0 ? Fr.ZERO : previousRollupData.length === 1 ? previousRollupData[0].outHash : sha256ToField([
|
|
143
|
+
previousRollupData[0].outHash,
|
|
144
|
+
previousRollupData[1].outHash
|
|
145
|
+
]);
|
|
146
|
+
const contentCommitment = new ContentCommitment(blobsHash, parityPublicInputs.shaRoot, outHash);
|
|
148
147
|
const accumulatedFees = previousRollupData.reduce((sum, d)=>sum.add(d.accumulatedFees), Fr.ZERO);
|
|
149
148
|
const accumulatedManaUsed = previousRollupData.reduce((sum, d)=>sum.add(d.accumulatedManaUsed), Fr.ZERO);
|
|
150
149
|
return new BlockHeader(rootRollupOutputs.previousArchive, contentCommitment, endState, rootRollupOutputs.endGlobalVariables, accumulatedFees, accumulatedManaUsed);
|
|
@@ -156,7 +155,7 @@ export const buildHeaderAndBodyFromTxs = runInSpan('BlockBuilderHelpers', 'build
|
|
|
156
155
|
const txEffects = txs.map((tx)=>tx.txEffect);
|
|
157
156
|
const body = new Body(txEffects);
|
|
158
157
|
const numTxs = body.txEffects.length;
|
|
159
|
-
const outHash = numTxs === 0 ? Fr.ZERO
|
|
158
|
+
const outHash = numTxs === 0 ? Fr.ZERO : numTxs === 1 ? new Fr(body.txEffects[0].txOutHash()) : new Fr(computeUnbalancedMerkleRoot(body.txEffects.map((tx)=>tx.txOutHash()), TxEffect.empty().txOutHash()));
|
|
160
159
|
l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
161
160
|
const hasher = (left, right)=>Promise.resolve(sha256Trunc(Buffer.concat([
|
|
162
161
|
left,
|
|
@@ -164,9 +163,9 @@ export const buildHeaderAndBodyFromTxs = runInSpan('BlockBuilderHelpers', 'build
|
|
|
164
163
|
])));
|
|
165
164
|
const parityHeight = Math.ceil(Math.log2(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP));
|
|
166
165
|
const parityCalculator = await MerkleTreeCalculator.create(parityHeight, Fr.ZERO.toBuffer(), hasher);
|
|
167
|
-
const parityShaRoot = await parityCalculator.computeTreeRoot(l1ToL2Messages.map((msg)=>msg.toBuffer()));
|
|
168
|
-
const blobsHash = getBlobsHashFromBlobs(await Blob.
|
|
169
|
-
const contentCommitment = new ContentCommitment(
|
|
166
|
+
const parityShaRoot = new Fr(await parityCalculator.computeTreeRoot(l1ToL2Messages.map((msg)=>msg.toBuffer())));
|
|
167
|
+
const blobsHash = getBlobsHashFromBlobs(await Blob.getBlobsPerBlock(body.toBlobFields()));
|
|
168
|
+
const contentCommitment = new ContentCommitment(blobsHash, parityShaRoot, outHash);
|
|
170
169
|
const fees = body.txEffects.reduce((acc, tx)=>acc.add(tx.transactionFee), Fr.ZERO);
|
|
171
170
|
const manaUsed = txs.reduce((acc, tx)=>acc.add(new Fr(tx.gasUsed.billedGas.l2Gas)), Fr.ZERO);
|
|
172
171
|
const header = new BlockHeader(previousArchive, contentCommitment, stateReference, globalVariables, fees, manaUsed);
|
|
@@ -176,8 +175,14 @@ export const buildHeaderAndBodyFromTxs = runInSpan('BlockBuilderHelpers', 'build
|
|
|
176
175
|
};
|
|
177
176
|
});
|
|
178
177
|
export function getBlobsHashFromBlobs(inputs) {
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
return sha256ToField(inputs.map((b)=>b.getEthVersionedBlobHash()));
|
|
179
|
+
}
|
|
180
|
+
// Note: tested against the constant values in block_root/empty_block_root_rollup_inputs.nr, set by block_building_helpers.test.ts.
|
|
181
|
+
// Having this separate fn hopefully makes it clear how we treat empty blocks and their blobs, and won't break if we decide to change how
|
|
182
|
+
// getBlobsPerBlock() works on empty input.
|
|
183
|
+
export async function getEmptyBlockBlobsHash() {
|
|
184
|
+
const blobHash = (await Blob.getBlobsPerBlock([])).map((b)=>b.getEthVersionedBlobHash());
|
|
185
|
+
return sha256ToField(blobHash);
|
|
181
186
|
}
|
|
182
187
|
// Validate that the roots of all local trees match the output of the root circuit simulation
|
|
183
188
|
// TODO: does this get called?
|
|
@@ -38,7 +38,7 @@ export declare class BlockProvingState {
|
|
|
38
38
|
spongeBlobState: SpongeBlob | undefined;
|
|
39
39
|
startBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
40
40
|
endBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
41
|
-
blobsHash:
|
|
41
|
+
blobsHash: Fr | undefined;
|
|
42
42
|
totalNumTxs: number;
|
|
43
43
|
private txs;
|
|
44
44
|
error: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-proving-state.d.ts","sourceRoot":"","sources":["../../src/orchestrator/block-proving-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"block-proving-state.d.ts","sourceRoot":"","sources":["../../src/orchestrator/block-proving-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAA+B,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClG,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,wCAAwC,EAC7C,KAAK,yCAAyC,EAG/C,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAc,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,KAAK,gBAAgB,EAAuB,MAAM,yBAAyB,CAAC;AAGrF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAAE,KAAK,kBAAkB,EAAmB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,EACL,KAAK,6BAA6B,EAElC,KAAK,iCAAiC,EAGtC,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,EAEjB,6BAA6B,EAC9B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAkB,MAAM,kBAAkB,CAAC;AAS1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC;AAEtE;;;GAGG;AACH,qBAAa,iBAAiB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AAC,MAAM,EAAE,MAAM;CA0D7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BatchedBlobAccumulator, SpongeBlob } from '@aztec/blob-lib';
|
|
1
|
+
import { BatchedBlobAccumulator, BlobAccumulatorPublicInputs, SpongeBlob } from '@aztec/blob-lib';
|
|
2
2
|
import { BLOBS_PER_BLOCK, FIELDS_PER_BLOB, NUM_BASE_PARITY_PER_ROOT_PARITY } from '@aztec/constants';
|
|
3
3
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
4
4
|
import { BLS12Point, Fr } from '@aztec/foundation/fields';
|
|
@@ -9,7 +9,7 @@ import { RootParityInput, RootParityInputs } from '@aztec/stdlib/parity';
|
|
|
9
9
|
import { BlockConstantData, BlockRootRollupBlobData, BlockRootRollupData, BlockRootRollupInputs, EmptyBlockRootRollupInputs, MergeRollupInputs, PreviousRollupData, SingleTxBlockRootRollupInputs } from '@aztec/stdlib/rollup';
|
|
10
10
|
import { StateReference } from '@aztec/stdlib/tx';
|
|
11
11
|
import { VkData } from '@aztec/stdlib/vks';
|
|
12
|
-
import { accumulateBlobs, buildBlobHints, buildHeaderFromCircuitOutputs } from './block-building-helpers.js';
|
|
12
|
+
import { accumulateBlobs, buildBlobHints, buildHeaderFromCircuitOutputs, getEmptyBlockBlobsHash } from './block-building-helpers.js';
|
|
13
13
|
/**
|
|
14
14
|
* The current state of the proving schedule for a given block. Managed by ProvingState.
|
|
15
15
|
* Contains the raw inputs and intermediate state to generate every constituent proof in the tree.
|
|
@@ -157,6 +157,7 @@ import { accumulateBlobs, buildBlobHints, buildHeaderFromCircuitOutputs } from '
|
|
|
157
157
|
vkTreeRoot: getVKTreeRoot(),
|
|
158
158
|
protocolContractTreeRoot
|
|
159
159
|
});
|
|
160
|
+
this.blobsHash = await getEmptyBlockBlobsHash();
|
|
160
161
|
return {
|
|
161
162
|
rollupType: 'empty-block-root-rollup',
|
|
162
163
|
inputs: EmptyBlockRootRollupInputs.from({
|
|
@@ -168,7 +169,7 @@ import { accumulateBlobs, buildBlobHints, buildHeaderFromCircuitOutputs } from '
|
|
|
168
169
|
}
|
|
169
170
|
const previousRollupData = await Promise.all(nonEmptyProofs.map((p)=>this.#getPreviousRollupData(p)));
|
|
170
171
|
const blobData = await this.#getBlockRootRollupBlobData();
|
|
171
|
-
this.blobsHash = blobData.blobsHash
|
|
172
|
+
this.blobsHash = blobData.blobsHash;
|
|
172
173
|
if (previousRollupData.length === 1) {
|
|
173
174
|
return {
|
|
174
175
|
rollupType: 'single-tx-block-root-rollup',
|
|
@@ -198,7 +199,7 @@ import { accumulateBlobs, buildBlobHints, buildHeaderFromCircuitOutputs } from '
|
|
|
198
199
|
previousArchiveSiblingPath: this.lastArchiveSiblingPath,
|
|
199
200
|
newArchiveSiblingPath: this.newArchiveSiblingPath,
|
|
200
201
|
previousBlockHeader,
|
|
201
|
-
startBlobAccumulator: this.endBlobAccumulator
|
|
202
|
+
startBlobAccumulator: BlobAccumulatorPublicInputs.fromBatchedBlobAccumulator(this.endBlobAccumulator),
|
|
202
203
|
finalBlobChallenges: this.endBlobAccumulator.finalBlobChallenges,
|
|
203
204
|
proverId
|
|
204
205
|
});
|
|
@@ -238,10 +239,6 @@ import { accumulateBlobs, buildBlobHints, buildHeaderFromCircuitOutputs } from '
|
|
|
238
239
|
endPartialState = lastRollup.inputs.end;
|
|
239
240
|
}
|
|
240
241
|
const endState = new StateReference(this.l1ToL2MessageTreeSnapshotAfterInsertion, endPartialState);
|
|
241
|
-
// TODO(MW): cleanup
|
|
242
|
-
if (!this.blobsHash) {
|
|
243
|
-
this.blobsHash = (await buildBlobHints(this.txs.map((txProvingState)=>txProvingState.processedTx.txEffect))).blobsHash.toBuffer();
|
|
244
|
-
}
|
|
245
242
|
return buildHeaderFromCircuitOutputs(previousRollupData.map((d)=>d.baseOrMergeRollupPublicInputs), this.rootParityProvingOutput.inputs, this.blockRootProvingOutput.inputs, this.blobsHash, endState);
|
|
246
243
|
}
|
|
247
244
|
isReadyForMergeRollup(location) {
|
|
@@ -274,7 +271,7 @@ import { accumulateBlobs, buildBlobHints, buildHeaderFromCircuitOutputs } from '
|
|
|
274
271
|
previousArchiveSiblingPath: this.lastArchiveSiblingPath,
|
|
275
272
|
newArchiveSiblingPath: this.newArchiveSiblingPath,
|
|
276
273
|
previousBlockHeader: this.previousBlockHeader,
|
|
277
|
-
startBlobAccumulator: this.startBlobAccumulator
|
|
274
|
+
startBlobAccumulator: BlobAccumulatorPublicInputs.fromBatchedBlobAccumulator(this.startBlobAccumulator),
|
|
278
275
|
finalBlobChallenges: this.startBlobAccumulator.finalBlobChallenges,
|
|
279
276
|
proverId
|
|
280
277
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/orchestrator/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/orchestrator/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAU3F,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAS9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EAGxB,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAUzC,OAAO,EAAE,KAAK,sBAAsB,EAAgB,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,KAAK,EAAE,EAAmB,MAAM,kBAAkB,CAAC;AACtH,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,MAAM,EAIZ,MAAM,yBAAyB,CAAC;AAqBjC;;;;;;;;;GASG;AAEH;;GAEG;AACH,qBAAa,mBAAoB,YAAW,WAAW;IASnD,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC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CAAC,iBAAiB;IA8CzB,OAAO,CAAC,gBAAgB;IA0BxB,OAAO,CAAC,aAAa;IA4BrB,OAAO,CAAC,kBAAkB;YA0BZ,sBAAsB;IAgFpC,OAAO,CAAC,wBAAwB;IAuBhC,OAAO,CAAC,gCAAgC;IAUxC,OAAO,CAAC,wBAAwB;IA2BhC,OAAO,CAAC,uBAAuB;YAwBjB,mBAAmB;IA6BjC,OAAO,CAAC,iBAAiB;YA4BX,8BAA8B;YAa9B,8BAA8B;IA2B5C,OAAO,CAAC,mCAAmC;IAa3C,OAAO,CAAC,yBAAyB;IASjC;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAmDjB,OAAO,CAAC,4BAA4B;CAWrC"}
|
|
@@ -4,6 +4,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
4
4
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
}
|
|
7
|
+
import { BlobAccumulatorPublicInputs } from '@aztec/blob-lib';
|
|
7
8
|
import { L1_TO_L2_MSG_SUBTREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, NUM_BASE_PARITY_PER_ROOT_PARITY } from '@aztec/constants';
|
|
8
9
|
import { padArrayEnd, times } from '@aztec/foundation/collection';
|
|
9
10
|
import { AbortError } from '@aztec/foundation/error';
|
|
@@ -485,10 +486,10 @@ const logger = createLogger('prover-client:orchestrator');
|
|
|
485
486
|
logger.error(`New archive root mismatch.\nCircuit: ${result.inputs.newArchive.root}\nComputed: ${dbArchiveRoot}`);
|
|
486
487
|
provingState.reject(`New archive root mismatch.`);
|
|
487
488
|
}
|
|
488
|
-
const
|
|
489
|
+
const endBlobAccumulatorPublicInputs = BlobAccumulatorPublicInputs.fromBatchedBlobAccumulator(provingState.endBlobAccumulator);
|
|
489
490
|
const circuitEndBlobAccumulatorState = result.inputs.blobPublicInputs.endBlobAccumulator;
|
|
490
|
-
if (!circuitEndBlobAccumulatorState.equals(
|
|
491
|
-
logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(
|
|
491
|
+
if (!circuitEndBlobAccumulatorState.equals(endBlobAccumulatorPublicInputs)) {
|
|
492
|
+
logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(endBlobAccumulatorPublicInputs)}`);
|
|
492
493
|
provingState.reject(`Blob accumulator state mismatch.`);
|
|
493
494
|
}
|
|
494
495
|
logger.debug(`Completed ${rollupType} proof for block ${provingState.block.number}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/prover-client",
|
|
3
|
-
"version": "1.0.0-nightly.
|
|
3
|
+
"version": "1.0.0-nightly.20250612",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -65,19 +65,19 @@
|
|
|
65
65
|
"testEnvironment": "../../foundation/src/jest/env.mjs"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@aztec/bb-prover": "1.0.0-nightly.
|
|
69
|
-
"@aztec/blob-lib": "1.0.0-nightly.
|
|
70
|
-
"@aztec/constants": "1.0.0-nightly.
|
|
71
|
-
"@aztec/ethereum": "1.0.0-nightly.
|
|
72
|
-
"@aztec/foundation": "1.0.0-nightly.
|
|
73
|
-
"@aztec/kv-store": "1.0.0-nightly.
|
|
74
|
-
"@aztec/noir-protocol-circuits-types": "1.0.0-nightly.
|
|
75
|
-
"@aztec/noir-types": "1.0.0-nightly.
|
|
76
|
-
"@aztec/protocol-contracts": "1.0.0-nightly.
|
|
77
|
-
"@aztec/simulator": "1.0.0-nightly.
|
|
78
|
-
"@aztec/stdlib": "1.0.0-nightly.
|
|
79
|
-
"@aztec/telemetry-client": "1.0.0-nightly.
|
|
80
|
-
"@aztec/world-state": "1.0.0-nightly.
|
|
68
|
+
"@aztec/bb-prover": "1.0.0-nightly.20250612",
|
|
69
|
+
"@aztec/blob-lib": "1.0.0-nightly.20250612",
|
|
70
|
+
"@aztec/constants": "1.0.0-nightly.20250612",
|
|
71
|
+
"@aztec/ethereum": "1.0.0-nightly.20250612",
|
|
72
|
+
"@aztec/foundation": "1.0.0-nightly.20250612",
|
|
73
|
+
"@aztec/kv-store": "1.0.0-nightly.20250612",
|
|
74
|
+
"@aztec/noir-protocol-circuits-types": "1.0.0-nightly.20250612",
|
|
75
|
+
"@aztec/noir-types": "1.0.0-nightly.20250612",
|
|
76
|
+
"@aztec/protocol-contracts": "1.0.0-nightly.20250612",
|
|
77
|
+
"@aztec/simulator": "1.0.0-nightly.20250612",
|
|
78
|
+
"@aztec/stdlib": "1.0.0-nightly.20250612",
|
|
79
|
+
"@aztec/telemetry-client": "1.0.0-nightly.20250612",
|
|
80
|
+
"@aztec/world-state": "1.0.0-nightly.20250612",
|
|
81
81
|
"@google-cloud/storage": "^7.15.0",
|
|
82
82
|
"@iarna/toml": "^2.2.5",
|
|
83
83
|
"commander": "^12.1.0",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"zod": "^3.23.8"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
|
-
"@aztec/noir-contracts.js": "1.0.0-nightly.
|
|
90
|
+
"@aztec/noir-contracts.js": "1.0.0-nightly.20250612",
|
|
91
91
|
"@jest/globals": "^29.5.0",
|
|
92
92
|
"@types/jest": "^29.5.0",
|
|
93
93
|
"@types/node": "^22.15.17",
|
package/src/mocks/fixtures.ts
CHANGED
|
@@ -109,7 +109,7 @@ export const makeGlobals = (blockNumber: number) => {
|
|
|
109
109
|
Fr.ZERO,
|
|
110
110
|
new Fr(blockNumber) /** block number */,
|
|
111
111
|
new Fr(blockNumber) /** slot number */,
|
|
112
|
-
|
|
112
|
+
BigInt(blockNumber) /** block number as pseudo-timestamp for testing */,
|
|
113
113
|
EthAddress.ZERO,
|
|
114
114
|
AztecAddress.ZERO,
|
|
115
115
|
GasFees.empty(),
|
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
} from '@aztec/constants';
|
|
15
15
|
import { makeTuple } from '@aztec/foundation/array';
|
|
16
16
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
17
|
-
import { sha256Trunc } from '@aztec/foundation/crypto';
|
|
17
|
+
import { sha256ToField, sha256Trunc } from '@aztec/foundation/crypto';
|
|
18
18
|
import { BLS12Point, Fr } from '@aztec/foundation/fields';
|
|
19
|
-
import { type Tuple, assertLength,
|
|
19
|
+
import { type Tuple, assertLength, toFriendlyJSON } from '@aztec/foundation/serialize';
|
|
20
20
|
import { MembershipWitness, MerkleTreeCalculator, computeUnbalancedMerkleRoot } from '@aztec/foundation/trees';
|
|
21
21
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
22
22
|
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
@@ -253,7 +253,7 @@ export const buildBlobHints = runInSpan(
|
|
|
253
253
|
'buildBlobHints',
|
|
254
254
|
async (_span: Span, txEffects: TxEffect[]) => {
|
|
255
255
|
const blobFields = txEffects.flatMap(tx => tx.toBlobFields());
|
|
256
|
-
const blobs = await Blob.
|
|
256
|
+
const blobs = await Blob.getBlobsPerBlock(blobFields);
|
|
257
257
|
// TODO(#13430): The blobsHash is confusingly similar to blobCommitmentsHash, calculated from below blobCommitments:
|
|
258
258
|
// - blobsHash := sha256([blobhash_0, ..., blobhash_m]) = a hash of all blob hashes in a block with m+1 blobs inserted into the header, exists so a user can cross check blobs.
|
|
259
259
|
// - blobCommitmentsHash := sha256( ...sha256(sha256(C_0), C_1) ... C_n) = iteratively calculated hash of all blob commitments in an epoch with n+1 blobs (see calculateBlobCommitmentsHash()),
|
|
@@ -270,7 +270,7 @@ export const accumulateBlobs = runInSpan(
|
|
|
270
270
|
'accumulateBlobs',
|
|
271
271
|
async (_span: Span, txs: ProcessedTx[], startBlobAccumulator: BatchedBlobAccumulator) => {
|
|
272
272
|
const blobFields = txs.flatMap(tx => tx.txEffect.toBlobFields());
|
|
273
|
-
const blobs = await Blob.
|
|
273
|
+
const blobs = await Blob.getBlobsPerBlock(blobFields);
|
|
274
274
|
const endBlobAccumulator = startBlobAccumulator.accumulateBlobs(blobs);
|
|
275
275
|
return endBlobAccumulator;
|
|
276
276
|
},
|
|
@@ -284,28 +284,20 @@ export const buildHeaderFromCircuitOutputs = runInSpan(
|
|
|
284
284
|
previousRollupData: BaseOrMergeRollupPublicInputs[],
|
|
285
285
|
parityPublicInputs: ParityPublicInputs,
|
|
286
286
|
rootRollupOutputs: BlockRootOrBlockMergePublicInputs,
|
|
287
|
-
blobsHash:
|
|
287
|
+
blobsHash: Fr,
|
|
288
288
|
endState: StateReference,
|
|
289
289
|
) => {
|
|
290
290
|
if (previousRollupData.length > 2) {
|
|
291
291
|
throw new Error(`There can't be more than 2 previous rollups. Received ${previousRollupData.length}.`);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
const numTxs = previousRollupData.reduce((sum, d) => sum + d.numTxs, 0);
|
|
295
294
|
const outHash =
|
|
296
295
|
previousRollupData.length === 0
|
|
297
|
-
? Fr.ZERO
|
|
296
|
+
? Fr.ZERO
|
|
298
297
|
: previousRollupData.length === 1
|
|
299
|
-
? previousRollupData[0].outHash
|
|
300
|
-
:
|
|
301
|
-
|
|
302
|
-
);
|
|
303
|
-
const contentCommitment = new ContentCommitment(
|
|
304
|
-
new Fr(numTxs),
|
|
305
|
-
blobsHash,
|
|
306
|
-
parityPublicInputs.shaRoot.toBuffer(),
|
|
307
|
-
outHash,
|
|
308
|
-
);
|
|
298
|
+
? previousRollupData[0].outHash
|
|
299
|
+
: sha256ToField([previousRollupData[0].outHash, previousRollupData[1].outHash]);
|
|
300
|
+
const contentCommitment = new ContentCommitment(blobsHash, parityPublicInputs.shaRoot, outHash);
|
|
309
301
|
|
|
310
302
|
const accumulatedFees = previousRollupData.reduce((sum, d) => sum.add(d.accumulatedFees), Fr.ZERO);
|
|
311
303
|
const accumulatedManaUsed = previousRollupData.reduce((sum, d) => sum.add(d.accumulatedManaUsed), Fr.ZERO);
|
|
@@ -349,12 +341,14 @@ export const buildHeaderAndBodyFromTxs = runInSpan(
|
|
|
349
341
|
const numTxs = body.txEffects.length;
|
|
350
342
|
const outHash =
|
|
351
343
|
numTxs === 0
|
|
352
|
-
? Fr.ZERO
|
|
344
|
+
? Fr.ZERO
|
|
353
345
|
: numTxs === 1
|
|
354
|
-
? body.txEffects[0].txOutHash()
|
|
355
|
-
:
|
|
356
|
-
|
|
357
|
-
|
|
346
|
+
? new Fr(body.txEffects[0].txOutHash())
|
|
347
|
+
: new Fr(
|
|
348
|
+
computeUnbalancedMerkleRoot(
|
|
349
|
+
body.txEffects.map(tx => tx.txOutHash()),
|
|
350
|
+
TxEffect.empty().txOutHash(),
|
|
351
|
+
),
|
|
358
352
|
);
|
|
359
353
|
|
|
360
354
|
l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
@@ -366,10 +360,10 @@ export const buildHeaderAndBodyFromTxs = runInSpan(
|
|
|
366
360
|
Fr.ZERO.toBuffer() as Buffer<ArrayBuffer>,
|
|
367
361
|
hasher,
|
|
368
362
|
);
|
|
369
|
-
const parityShaRoot = await parityCalculator.computeTreeRoot(l1ToL2Messages.map(msg => msg.toBuffer()));
|
|
370
|
-
const blobsHash = getBlobsHashFromBlobs(await Blob.
|
|
363
|
+
const parityShaRoot = new Fr(await parityCalculator.computeTreeRoot(l1ToL2Messages.map(msg => msg.toBuffer())));
|
|
364
|
+
const blobsHash = getBlobsHashFromBlobs(await Blob.getBlobsPerBlock(body.toBlobFields()));
|
|
371
365
|
|
|
372
|
-
const contentCommitment = new ContentCommitment(
|
|
366
|
+
const contentCommitment = new ContentCommitment(blobsHash, parityShaRoot, outHash);
|
|
373
367
|
|
|
374
368
|
const fees = body.txEffects.reduce((acc, tx) => acc.add(tx.transactionFee), Fr.ZERO);
|
|
375
369
|
const manaUsed = txs.reduce((acc, tx) => acc.add(new Fr(tx.gasUsed.billedGas.l2Gas)), Fr.ZERO);
|
|
@@ -380,9 +374,16 @@ export const buildHeaderAndBodyFromTxs = runInSpan(
|
|
|
380
374
|
},
|
|
381
375
|
);
|
|
382
376
|
|
|
383
|
-
export function getBlobsHashFromBlobs(inputs: Blob[]):
|
|
384
|
-
|
|
385
|
-
|
|
377
|
+
export function getBlobsHashFromBlobs(inputs: Blob[]): Fr {
|
|
378
|
+
return sha256ToField(inputs.map(b => b.getEthVersionedBlobHash()));
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// Note: tested against the constant values in block_root/empty_block_root_rollup_inputs.nr, set by block_building_helpers.test.ts.
|
|
382
|
+
// Having this separate fn hopefully makes it clear how we treat empty blocks and their blobs, and won't break if we decide to change how
|
|
383
|
+
// getBlobsPerBlock() works on empty input.
|
|
384
|
+
export async function getEmptyBlockBlobsHash(): Promise<Fr> {
|
|
385
|
+
const blobHash = (await Blob.getBlobsPerBlock([])).map(b => b.getEthVersionedBlobHash());
|
|
386
|
+
return sha256ToField(blobHash);
|
|
386
387
|
}
|
|
387
388
|
|
|
388
389
|
// Validate that the roots of all local trees match the output of the root circuit simulation
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BatchedBlobAccumulator, SpongeBlob } from '@aztec/blob-lib';
|
|
1
|
+
import { BatchedBlobAccumulator, BlobAccumulatorPublicInputs, SpongeBlob } from '@aztec/blob-lib';
|
|
2
2
|
import {
|
|
3
3
|
type ARCHIVE_HEIGHT,
|
|
4
4
|
BLOBS_PER_BLOCK,
|
|
@@ -34,7 +34,12 @@ import type { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
|
34
34
|
import { type BlockHeader, type GlobalVariables, StateReference } from '@aztec/stdlib/tx';
|
|
35
35
|
import { VkData } from '@aztec/stdlib/vks';
|
|
36
36
|
|
|
37
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
accumulateBlobs,
|
|
39
|
+
buildBlobHints,
|
|
40
|
+
buildHeaderFromCircuitOutputs,
|
|
41
|
+
getEmptyBlockBlobsHash,
|
|
42
|
+
} from './block-building-helpers.js';
|
|
38
43
|
import type { EpochProvingState } from './epoch-proving-state.js';
|
|
39
44
|
import type { TxProvingState } from './tx-proving-state.js';
|
|
40
45
|
|
|
@@ -58,7 +63,7 @@ export class BlockProvingState {
|
|
|
58
63
|
public spongeBlobState: SpongeBlob | undefined;
|
|
59
64
|
public startBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
60
65
|
public endBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
61
|
-
public blobsHash:
|
|
66
|
+
public blobsHash: Fr | undefined;
|
|
62
67
|
public totalNumTxs: number;
|
|
63
68
|
private txs: TxProvingState[] = [];
|
|
64
69
|
public error: string | undefined;
|
|
@@ -221,6 +226,8 @@ export class BlockProvingState {
|
|
|
221
226
|
protocolContractTreeRoot,
|
|
222
227
|
});
|
|
223
228
|
|
|
229
|
+
this.blobsHash = await getEmptyBlockBlobsHash();
|
|
230
|
+
|
|
224
231
|
return {
|
|
225
232
|
rollupType: 'empty-block-root-rollup' satisfies CircuitName,
|
|
226
233
|
inputs: EmptyBlockRootRollupInputs.from({
|
|
@@ -233,7 +240,7 @@ export class BlockProvingState {
|
|
|
233
240
|
|
|
234
241
|
const previousRollupData = await Promise.all(nonEmptyProofs.map(p => this.#getPreviousRollupData(p!)));
|
|
235
242
|
const blobData = await this.#getBlockRootRollupBlobData();
|
|
236
|
-
this.blobsHash = blobData.blobsHash
|
|
243
|
+
this.blobsHash = blobData.blobsHash;
|
|
237
244
|
|
|
238
245
|
if (previousRollupData.length === 1) {
|
|
239
246
|
return {
|
|
@@ -272,7 +279,7 @@ export class BlockProvingState {
|
|
|
272
279
|
previousArchiveSiblingPath: this.lastArchiveSiblingPath,
|
|
273
280
|
newArchiveSiblingPath: this.newArchiveSiblingPath,
|
|
274
281
|
previousBlockHeader,
|
|
275
|
-
startBlobAccumulator: this.endBlobAccumulator
|
|
282
|
+
startBlobAccumulator: BlobAccumulatorPublicInputs.fromBatchedBlobAccumulator(this.endBlobAccumulator),
|
|
276
283
|
finalBlobChallenges: this.endBlobAccumulator.finalBlobChallenges,
|
|
277
284
|
proverId,
|
|
278
285
|
});
|
|
@@ -325,18 +332,11 @@ export class BlockProvingState {
|
|
|
325
332
|
}
|
|
326
333
|
const endState = new StateReference(this.l1ToL2MessageTreeSnapshotAfterInsertion, endPartialState);
|
|
327
334
|
|
|
328
|
-
// TODO(MW): cleanup
|
|
329
|
-
if (!this.blobsHash) {
|
|
330
|
-
this.blobsHash = (
|
|
331
|
-
await buildBlobHints(this.txs.map(txProvingState => txProvingState.processedTx.txEffect))
|
|
332
|
-
).blobsHash.toBuffer();
|
|
333
|
-
}
|
|
334
|
-
|
|
335
335
|
return buildHeaderFromCircuitOutputs(
|
|
336
336
|
previousRollupData.map(d => d.baseOrMergeRollupPublicInputs),
|
|
337
337
|
this.rootParityProvingOutput!.inputs,
|
|
338
338
|
this.blockRootProvingOutput!.inputs,
|
|
339
|
-
this.blobsHash
|
|
339
|
+
this.blobsHash!,
|
|
340
340
|
endState,
|
|
341
341
|
);
|
|
342
342
|
}
|
|
@@ -382,7 +382,7 @@ export class BlockProvingState {
|
|
|
382
382
|
previousArchiveSiblingPath: this.lastArchiveSiblingPath,
|
|
383
383
|
newArchiveSiblingPath: this.newArchiveSiblingPath,
|
|
384
384
|
previousBlockHeader: this.previousBlockHeader,
|
|
385
|
-
startBlobAccumulator: this.startBlobAccumulator
|
|
385
|
+
startBlobAccumulator: BlobAccumulatorPublicInputs.fromBatchedBlobAccumulator(this.startBlobAccumulator!),
|
|
386
386
|
finalBlobChallenges: this.startBlobAccumulator!.finalBlobChallenges,
|
|
387
387
|
proverId,
|
|
388
388
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FinalBlobBatchingChallenges } from '@aztec/blob-lib';
|
|
1
|
+
import { BlobAccumulatorPublicInputs, FinalBlobBatchingChallenges } from '@aztec/blob-lib';
|
|
2
2
|
import {
|
|
3
3
|
L1_TO_L2_MSG_SUBTREE_HEIGHT,
|
|
4
4
|
L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
|
|
@@ -726,12 +726,14 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
726
726
|
provingState.reject(`New archive root mismatch.`);
|
|
727
727
|
}
|
|
728
728
|
|
|
729
|
-
const
|
|
729
|
+
const endBlobAccumulatorPublicInputs = BlobAccumulatorPublicInputs.fromBatchedBlobAccumulator(
|
|
730
|
+
provingState.endBlobAccumulator!,
|
|
731
|
+
);
|
|
730
732
|
const circuitEndBlobAccumulatorState = result.inputs.blobPublicInputs.endBlobAccumulator;
|
|
731
|
-
if (!circuitEndBlobAccumulatorState.equals(
|
|
733
|
+
if (!circuitEndBlobAccumulatorState.equals(endBlobAccumulatorPublicInputs)) {
|
|
732
734
|
logger.error(
|
|
733
735
|
`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(
|
|
734
|
-
|
|
736
|
+
endBlobAccumulatorPublicInputs,
|
|
735
737
|
)}`,
|
|
736
738
|
);
|
|
737
739
|
provingState.reject(`Blob accumulator state mismatch.`);
|