@aztec/prover-client 3.0.0-nightly.20250917 → 3.0.0-nightly.20250919
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/light.d.ts +5 -3
- package/dest/block-factory/light.d.ts.map +1 -1
- package/dest/block-factory/light.js +16 -9
- package/dest/mocks/fixtures.d.ts +3 -1
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +19 -2
- package/dest/mocks/test_context.d.ts +30 -9
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +68 -15
- package/dest/orchestrator/block-building-helpers.d.ts +16 -14
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +69 -66
- package/dest/orchestrator/block-proving-state.d.ts +59 -52
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +215 -187
- 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 +32 -25
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +132 -81
- package/dest/orchestrator/orchestrator.d.ts +25 -24
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +331 -203
- package/dest/orchestrator/tx-proving-state.d.ts +3 -3
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +5 -5
- package/dest/prover-client/server-epoch-prover.d.ts +8 -7
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +7 -7
- package/dest/proving_broker/broker_prover_facade.d.ts +18 -13
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +36 -21
- package/dest/proving_broker/fixtures.js +1 -1
- package/dest/proving_broker/proof_store/index.d.ts +1 -0
- 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/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +27 -16
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +34 -14
- package/dest/test/mock_prover.d.ts +18 -13
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +31 -16
- package/package.json +16 -17
- package/src/block-factory/light.ts +33 -9
- package/src/mocks/fixtures.ts +25 -7
- package/src/mocks/test_context.ts +113 -21
- package/src/orchestrator/block-building-helpers.ts +107 -93
- package/src/orchestrator/block-proving-state.ts +232 -244
- package/src/orchestrator/checkpoint-proving-state.ts +294 -0
- package/src/orchestrator/epoch-proving-state.ts +169 -121
- package/src/orchestrator/orchestrator.ts +483 -262
- package/src/orchestrator/tx-proving-state.ts +6 -6
- package/src/prover-client/server-epoch-prover.ts +30 -16
- package/src/proving_broker/broker_prover_facade.ts +151 -83
- package/src/proving_broker/fixtures.ts +1 -1
- package/src/proving_broker/proof_store/index.ts +1 -0
- package/src/proving_broker/proving_broker.ts +34 -16
- package/src/proving_broker/proving_job_controller.ts +34 -14
- package/src/test/mock_prover.ts +125 -54
- 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/src/bin/get-proof-inputs.ts +0 -59
package/dest/test/mock_prover.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED, AVM_V2_VERIFICATION_KEY_LENGTH_IN
|
|
|
2
2
|
import { times } from '@aztec/foundation/collection';
|
|
3
3
|
import { makeProofAndVerificationKey, makePublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
4
4
|
import { makeEmptyRecursiveProof, makeRecursiveProof } from '@aztec/stdlib/proofs';
|
|
5
|
-
import {
|
|
5
|
+
import { makeBlockRollupPublicInputs, makeCheckpointRollupPublicInputs, makeParityPublicInputs, makePrivateToPublicKernelCircuitPublicInputs, makeRootRollupPublicInputs, makeTxRollupPublicInputs } from '@aztec/stdlib/testing';
|
|
6
6
|
import { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
7
7
|
import { InlineProofStore } from '../proving_broker/proof_store/index.js';
|
|
8
8
|
import { ProvingAgent } from '../proving_broker/proving_agent.js';
|
|
@@ -55,29 +55,44 @@ export class MockProver {
|
|
|
55
55
|
getPublicTubeProof(_inputs, _signal, _epochNumber) {
|
|
56
56
|
return Promise.resolve(makePublicInputsAndRecursiveProof(makePrivateToPublicKernelCircuitPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()));
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
return Promise.resolve(makePublicInputsAndRecursiveProof(
|
|
58
|
+
getPrivateTxBaseRollupProof(_baseRollupInput, _signal, _epochNumber) {
|
|
59
|
+
return Promise.resolve(makePublicInputsAndRecursiveProof(makeTxRollupPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()));
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
return Promise.resolve(makePublicInputsAndRecursiveProof(
|
|
61
|
+
getPublicTxBaseRollupProof(_inputs, _signal, _epochNumber) {
|
|
62
|
+
return Promise.resolve(makePublicInputsAndRecursiveProof(makeTxRollupPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()));
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
return Promise.resolve(makePublicInputsAndRecursiveProof(
|
|
64
|
+
getTxMergeRollupProof(_input, _signal, _epochNumber) {
|
|
65
|
+
return Promise.resolve(makePublicInputsAndRecursiveProof(makeTxRollupPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()));
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
return Promise.resolve(makePublicInputsAndRecursiveProof(
|
|
67
|
+
getBlockRootFirstRollupProof(_input, _signal, _epochNumber) {
|
|
68
|
+
return Promise.resolve(makePublicInputsAndRecursiveProof(makeBlockRollupPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()));
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
return Promise.resolve(makePublicInputsAndRecursiveProof(
|
|
70
|
+
getBlockRootSingleTxFirstRollupProof(_input, _signal, _epochNumber) {
|
|
71
|
+
return Promise.resolve(makePublicInputsAndRecursiveProof(makeBlockRollupPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeHonk()));
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
return Promise.resolve(makePublicInputsAndRecursiveProof(
|
|
73
|
+
getBlockRootEmptyTxFirstRollupProof(_input, _signal, _epochNumber) {
|
|
74
|
+
return Promise.resolve(makePublicInputsAndRecursiveProof(makeBlockRollupPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()));
|
|
75
75
|
}
|
|
76
76
|
getBlockRootRollupProof(_input, _signal, _epochNumber) {
|
|
77
|
-
return Promise.resolve(makePublicInputsAndRecursiveProof(
|
|
77
|
+
return Promise.resolve(makePublicInputsAndRecursiveProof(makeBlockRollupPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()));
|
|
78
|
+
}
|
|
79
|
+
getBlockRootSingleTxRollupProof(_input, _signal, _epochNumber) {
|
|
80
|
+
return Promise.resolve(makePublicInputsAndRecursiveProof(makeBlockRollupPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeHonk()));
|
|
81
|
+
}
|
|
82
|
+
getBlockMergeRollupProof(_input, _signal, _epochNumber) {
|
|
83
|
+
return Promise.resolve(makePublicInputsAndRecursiveProof(makeBlockRollupPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()));
|
|
84
|
+
}
|
|
85
|
+
getCheckpointRootRollupProof(_input, _signal, _epochNumber) {
|
|
86
|
+
return Promise.resolve(makePublicInputsAndRecursiveProof(makeCheckpointRollupPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()));
|
|
87
|
+
}
|
|
88
|
+
getCheckpointRootSingleBlockRollupProof(_input, _signal, _epochNumber) {
|
|
89
|
+
return Promise.resolve(makePublicInputsAndRecursiveProof(makeCheckpointRollupPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()));
|
|
90
|
+
}
|
|
91
|
+
getCheckpointMergeRollupProof(_input, _signal, _epochNumber) {
|
|
92
|
+
return Promise.resolve(makePublicInputsAndRecursiveProof(makeCheckpointRollupPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()));
|
|
78
93
|
}
|
|
79
|
-
|
|
80
|
-
return Promise.resolve(makePublicInputsAndRecursiveProof(
|
|
94
|
+
getCheckpointPaddingRollupProof(_input, _signal, _epochNumber) {
|
|
95
|
+
return Promise.resolve(makePublicInputsAndRecursiveProof(makeCheckpointRollupPublicInputs(), makeRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()));
|
|
81
96
|
}
|
|
82
97
|
getRootRollupProof(_input, _signal, _epochNumber) {
|
|
83
98
|
return Promise.resolve(makePublicInputsAndRecursiveProof(makeRootRollupPublicInputs(), makeRecursiveProof(RECURSIVE_PROOF_LENGTH), VerificationKeyData.makeFakeHonk()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/prover-client",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20250919",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -27,8 +27,7 @@
|
|
|
27
27
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
28
28
|
"bb": "node --no-warnings ./dest/bb/index.js",
|
|
29
29
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=3500000 --forceExit",
|
|
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"
|
|
31
|
-
"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"
|
|
32
31
|
},
|
|
33
32
|
"jest": {
|
|
34
33
|
"moduleNameMapper": {
|
|
@@ -68,19 +67,19 @@
|
|
|
68
67
|
]
|
|
69
68
|
},
|
|
70
69
|
"dependencies": {
|
|
71
|
-
"@aztec/bb-prover": "3.0.0-nightly.
|
|
72
|
-
"@aztec/blob-lib": "3.0.0-nightly.
|
|
73
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
74
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
75
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
76
|
-
"@aztec/kv-store": "3.0.0-nightly.
|
|
77
|
-
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.
|
|
78
|
-
"@aztec/noir-types": "3.0.0-nightly.
|
|
79
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
80
|
-
"@aztec/simulator": "3.0.0-nightly.
|
|
81
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
82
|
-
"@aztec/telemetry-client": "3.0.0-nightly.
|
|
83
|
-
"@aztec/world-state": "3.0.0-nightly.
|
|
70
|
+
"@aztec/bb-prover": "3.0.0-nightly.20250919",
|
|
71
|
+
"@aztec/blob-lib": "3.0.0-nightly.20250919",
|
|
72
|
+
"@aztec/constants": "3.0.0-nightly.20250919",
|
|
73
|
+
"@aztec/ethereum": "3.0.0-nightly.20250919",
|
|
74
|
+
"@aztec/foundation": "3.0.0-nightly.20250919",
|
|
75
|
+
"@aztec/kv-store": "3.0.0-nightly.20250919",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20250919",
|
|
77
|
+
"@aztec/noir-types": "3.0.0-nightly.20250919",
|
|
78
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20250919",
|
|
79
|
+
"@aztec/simulator": "3.0.0-nightly.20250919",
|
|
80
|
+
"@aztec/stdlib": "3.0.0-nightly.20250919",
|
|
81
|
+
"@aztec/telemetry-client": "3.0.0-nightly.20250919",
|
|
82
|
+
"@aztec/world-state": "3.0.0-nightly.20250919",
|
|
84
83
|
"@google-cloud/storage": "^7.15.0",
|
|
85
84
|
"@iarna/toml": "^2.2.5",
|
|
86
85
|
"commander": "^12.1.0",
|
|
@@ -90,7 +89,7 @@
|
|
|
90
89
|
"zod": "^3.23.8"
|
|
91
90
|
},
|
|
92
91
|
"devDependencies": {
|
|
93
|
-
"@aztec/noir-contracts.js": "3.0.0-nightly.
|
|
92
|
+
"@aztec/noir-contracts.js": "3.0.0-nightly.20250919",
|
|
94
93
|
"@jest/globals": "^30.0.0",
|
|
95
94
|
"@types/jest": "^30.0.0",
|
|
96
95
|
"@types/node": "^22.15.17",
|
|
@@ -6,7 +6,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
6
6
|
import { L2Block } from '@aztec/stdlib/block';
|
|
7
7
|
import type { IBlockFactory, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
8
8
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
9
|
-
import {
|
|
9
|
+
import type { GlobalVariables, ProcessedTx } from '@aztec/stdlib/tx';
|
|
10
10
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
11
11
|
|
|
12
12
|
import {
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
export class LightweightBlockFactory implements IBlockFactory {
|
|
31
31
|
private globalVariables?: GlobalVariables;
|
|
32
32
|
private l1ToL2Messages?: Fr[];
|
|
33
|
-
|
|
33
|
+
private startSpongeBlob?: SpongeBlob;
|
|
34
34
|
private txs: ProcessedTx[] | undefined;
|
|
35
35
|
|
|
36
36
|
private readonly logger = createLogger('lightweight-block-factory');
|
|
@@ -40,12 +40,19 @@ export class LightweightBlockFactory implements IBlockFactory {
|
|
|
40
40
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
41
41
|
) {}
|
|
42
42
|
|
|
43
|
-
async startNewBlock(
|
|
43
|
+
async startNewBlock(
|
|
44
|
+
globalVariables: GlobalVariables,
|
|
45
|
+
l1ToL2Messages: Fr[],
|
|
46
|
+
// Must be provided to generate the correct spongeBlobHash for the block header if there's more than one block in the checkpoint.
|
|
47
|
+
startSpongeBlob?: SpongeBlob,
|
|
48
|
+
// Only insert l1 to l2 messages for the first block in a checkpoint.
|
|
49
|
+
isFirstBlock = true,
|
|
50
|
+
): Promise<void> {
|
|
44
51
|
this.logger.debug('Starting new block', { globalVariables: globalVariables.toInspect(), l1ToL2Messages });
|
|
45
52
|
this.globalVariables = globalVariables;
|
|
46
|
-
this.l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
53
|
+
this.l1ToL2Messages = isFirstBlock ? padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP) : [];
|
|
54
|
+
this.startSpongeBlob = startSpongeBlob;
|
|
47
55
|
this.txs = undefined;
|
|
48
|
-
|
|
49
56
|
// Update L1 to L2 tree
|
|
50
57
|
await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages!);
|
|
51
58
|
}
|
|
@@ -71,14 +78,17 @@ export class LightweightBlockFactory implements IBlockFactory {
|
|
|
71
78
|
this.globalVariables!,
|
|
72
79
|
this.l1ToL2Messages!,
|
|
73
80
|
this.db,
|
|
81
|
+
this.startSpongeBlob,
|
|
74
82
|
);
|
|
75
83
|
|
|
76
84
|
header.state.validate();
|
|
77
85
|
|
|
78
|
-
|
|
86
|
+
const blockHeader = header.toBlockHeader();
|
|
87
|
+
await this.db.updateArchive(blockHeader);
|
|
79
88
|
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
80
89
|
|
|
81
90
|
const block = new L2Block(newArchive, header, body);
|
|
91
|
+
|
|
82
92
|
this.logger.debug(`Built block ${block.number}`, {
|
|
83
93
|
globalVariables: this.globalVariables?.toInspect(),
|
|
84
94
|
archiveRoot: newArchive.root.toString(),
|
|
@@ -100,15 +110,29 @@ export async function buildBlockWithCleanDB(
|
|
|
100
110
|
globalVariables: GlobalVariables,
|
|
101
111
|
l1ToL2Messages: Fr[],
|
|
102
112
|
db: MerkleTreeWriteOperations,
|
|
113
|
+
startSpongeBlob?: SpongeBlob,
|
|
114
|
+
isFirstBlock = true,
|
|
103
115
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
104
116
|
) {
|
|
105
|
-
const
|
|
117
|
+
const lastArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
|
|
106
118
|
const builder = new LightweightBlockFactory(db, telemetry);
|
|
107
|
-
await builder.startNewBlock(globalVariables, l1ToL2Messages);
|
|
119
|
+
await builder.startNewBlock(globalVariables, l1ToL2Messages, startSpongeBlob, isFirstBlock);
|
|
108
120
|
const l1ToL2MessageTree = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, db);
|
|
121
|
+
|
|
109
122
|
for (const tx of txs) {
|
|
110
|
-
|
|
123
|
+
// startSpongeBlob and proverId are only used for constructing private inputs of the base rollup.
|
|
124
|
+
// Their values don't matter here because we are not using the return private inputs to build the block.
|
|
125
|
+
const proverId = Fr.ZERO;
|
|
126
|
+
await insertSideEffectsAndBuildBaseRollupHints(
|
|
127
|
+
tx,
|
|
128
|
+
lastArchive,
|
|
129
|
+
l1ToL2MessageTree,
|
|
130
|
+
startSpongeBlob?.clone() ?? SpongeBlob.init(0),
|
|
131
|
+
proverId,
|
|
132
|
+
db,
|
|
133
|
+
);
|
|
111
134
|
}
|
|
112
135
|
await builder.addTxs(txs);
|
|
136
|
+
|
|
113
137
|
return await builder.setBlockCompleted();
|
|
114
138
|
}
|
package/src/mocks/fixtures.ts
CHANGED
|
@@ -5,10 +5,13 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
6
6
|
import type { Logger } from '@aztec/foundation/log';
|
|
7
7
|
import { fileURLToPath } from '@aztec/foundation/url';
|
|
8
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
9
|
+
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
8
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
13
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
14
|
+
import { CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
12
15
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
13
16
|
import type { ProcessedTx } from '@aztec/stdlib/tx';
|
|
14
17
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
@@ -103,15 +106,30 @@ export const updateExpectedTreesFromTxs = async (db: MerkleTreeWriteOperations,
|
|
|
103
106
|
}
|
|
104
107
|
};
|
|
105
108
|
|
|
106
|
-
export const makeGlobals = (blockNumber: number) => {
|
|
109
|
+
export const makeGlobals = (blockNumber: number, slotNumber = blockNumber) => {
|
|
110
|
+
const checkpointConstants = makeCheckpointConstants(slotNumber);
|
|
107
111
|
return new GlobalVariables(
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
checkpointConstants.chainId,
|
|
113
|
+
checkpointConstants.version,
|
|
110
114
|
blockNumber /** block number */,
|
|
111
|
-
new Fr(
|
|
115
|
+
new Fr(slotNumber) /** slot number */,
|
|
112
116
|
BigInt(blockNumber) /** block number as pseudo-timestamp for testing */,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
checkpointConstants.coinbase,
|
|
118
|
+
checkpointConstants.feeRecipient,
|
|
119
|
+
checkpointConstants.gasFees,
|
|
116
120
|
);
|
|
117
121
|
};
|
|
122
|
+
|
|
123
|
+
export const makeCheckpointConstants = (slotNumber: number) => {
|
|
124
|
+
return CheckpointConstantData.from({
|
|
125
|
+
chainId: Fr.ZERO,
|
|
126
|
+
version: Fr.ZERO,
|
|
127
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
128
|
+
protocolContractTreeRoot,
|
|
129
|
+
proverId: Fr.ZERO,
|
|
130
|
+
slotNumber: new Fr(slotNumber),
|
|
131
|
+
coinbase: EthAddress.ZERO,
|
|
132
|
+
feeRecipient: AztecAddress.ZERO,
|
|
133
|
+
gasFees: GasFees.empty(),
|
|
134
|
+
});
|
|
135
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BBProverConfig } from '@aztec/bb-prover';
|
|
2
|
+
import { SpongeBlob } from '@aztec/blob-lib';
|
|
2
3
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
3
4
|
import { padArrayEnd, times, timesParallel } from '@aztec/foundation/collection';
|
|
4
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -11,10 +12,11 @@ import { SimpleContractDataSource } from '@aztec/simulator/public/fixtures';
|
|
|
11
12
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
12
13
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
13
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
|
-
import { EthAddress,
|
|
15
|
+
import { EthAddress, getBlockBlobFields } from '@aztec/stdlib/block';
|
|
15
16
|
import type { ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
|
|
17
|
+
import type { CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
16
18
|
import { makeBloatedProcessedTx } from '@aztec/stdlib/testing';
|
|
17
|
-
import {
|
|
19
|
+
import { MerkleTreeId, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
18
20
|
import { type BlockHeader, type GlobalVariables, type ProcessedTx, TreeSnapshots, type Tx } from '@aztec/stdlib/tx';
|
|
19
21
|
import type { MerkleTreeAdminDatabase } from '@aztec/world-state';
|
|
20
22
|
import { NativeWorldStateService } from '@aztec/world-state/native';
|
|
@@ -26,10 +28,17 @@ import { promises as fs } from 'fs';
|
|
|
26
28
|
import { TestCircuitProver } from '../../../bb-prover/src/test/test_circuit_prover.js';
|
|
27
29
|
import { buildBlockWithCleanDB } from '../block-factory/light.js';
|
|
28
30
|
import { getTreeSnapshot } from '../orchestrator/block-building-helpers.js';
|
|
31
|
+
import type { BlockProvingState } from '../orchestrator/block-proving-state.js';
|
|
29
32
|
import { ProvingOrchestrator } from '../orchestrator/index.js';
|
|
30
33
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
31
34
|
import { TestBroker } from '../test/mock_prover.js';
|
|
32
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
getEnvironmentConfig,
|
|
37
|
+
getSimulator,
|
|
38
|
+
makeCheckpointConstants,
|
|
39
|
+
makeGlobals,
|
|
40
|
+
updateExpectedTreesFromTxs,
|
|
41
|
+
} from './fixtures.js';
|
|
33
42
|
|
|
34
43
|
export class TestContext {
|
|
35
44
|
private headers: Map<number, BlockHeader> = new Map();
|
|
@@ -37,6 +46,7 @@ export class TestContext {
|
|
|
37
46
|
|
|
38
47
|
constructor(
|
|
39
48
|
public worldState: MerkleTreeAdminDatabase,
|
|
49
|
+
public firstCheckpointNumber: Fr,
|
|
40
50
|
public globalVariables: GlobalVariables,
|
|
41
51
|
public prover: ServerCircuitProver,
|
|
42
52
|
public broker: TestBroker,
|
|
@@ -55,20 +65,27 @@ export class TestContext {
|
|
|
55
65
|
return this.orchestrator;
|
|
56
66
|
}
|
|
57
67
|
|
|
68
|
+
public getCheckpointConstants(checkpointIndex = 0): CheckpointConstantData {
|
|
69
|
+
return makeCheckpointConstants(this.firstCheckpointNumber.toNumber() + checkpointIndex);
|
|
70
|
+
}
|
|
71
|
+
|
|
58
72
|
static async new(
|
|
59
73
|
logger: Logger,
|
|
60
74
|
{
|
|
61
75
|
proverCount = 4,
|
|
62
76
|
createProver = async (bbConfig: BBProverConfig) => new TestCircuitProver(await getSimulator(bbConfig, logger)),
|
|
77
|
+
slotNumber = 1,
|
|
63
78
|
blockNumber = 1,
|
|
64
79
|
}: {
|
|
65
80
|
proverCount?: number;
|
|
66
81
|
createProver?: (bbConfig: BBProverConfig) => Promise<ServerCircuitProver>;
|
|
82
|
+
slotNumber?: number;
|
|
67
83
|
blockNumber?: number;
|
|
68
84
|
} = {},
|
|
69
85
|
) {
|
|
70
86
|
const directoriesToCleanup: string[] = [];
|
|
71
|
-
const
|
|
87
|
+
const firstCheckpointNumber = new Fr(slotNumber);
|
|
88
|
+
const globalVariables = makeGlobals(blockNumber, slotNumber);
|
|
72
89
|
|
|
73
90
|
const feePayer = AztecAddress.fromNumber(42222);
|
|
74
91
|
const initialFeePayerBalance = new Fr(10n ** 20n);
|
|
@@ -112,6 +129,7 @@ export class TestContext {
|
|
|
112
129
|
|
|
113
130
|
return new this(
|
|
114
131
|
ws,
|
|
132
|
+
firstCheckpointNumber,
|
|
115
133
|
globalVariables,
|
|
116
134
|
localProver,
|
|
117
135
|
broker,
|
|
@@ -131,14 +149,10 @@ export class TestContext {
|
|
|
131
149
|
|
|
132
150
|
public getBlockHeader(blockNumber: 0): BlockHeader;
|
|
133
151
|
public getBlockHeader(blockNumber: number): BlockHeader | undefined;
|
|
134
|
-
public getBlockHeader(blockNumber = 0) {
|
|
152
|
+
public getBlockHeader(blockNumber = 0): BlockHeader | undefined {
|
|
135
153
|
return blockNumber === 0 ? this.worldState.getCommitted().getInitialHeader() : this.headers.get(blockNumber);
|
|
136
154
|
}
|
|
137
155
|
|
|
138
|
-
public setBlockHeader(header: BlockHeader, blockNumber: number) {
|
|
139
|
-
this.headers.set(blockNumber, header);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
156
|
public getPreviousBlockHeader(currentBlockNumber = this.blockNumber): BlockHeader {
|
|
143
157
|
return this.getBlockHeader(currentBlockNumber - 1)!;
|
|
144
158
|
}
|
|
@@ -155,9 +169,9 @@ export class TestContext {
|
|
|
155
169
|
}
|
|
156
170
|
}
|
|
157
171
|
|
|
158
|
-
|
|
172
|
+
async makeProcessedTx(opts?: Parameters<typeof makeBloatedProcessedTx>[0]): Promise<ProcessedTx> {
|
|
159
173
|
const blockNum = (opts?.globalVariables ?? this.globalVariables).blockNumber;
|
|
160
|
-
const header = this.getBlockHeader(blockNum - 1);
|
|
174
|
+
const header = opts?.header ?? this.getBlockHeader(blockNum - 1);
|
|
161
175
|
const tx = await makeBloatedProcessedTx({
|
|
162
176
|
header,
|
|
163
177
|
vkTreeRoot: getVKTreeRoot(),
|
|
@@ -177,11 +191,20 @@ export class TestContext {
|
|
|
177
191
|
/** Creates a block with the given number of txs and adds it to world-state */
|
|
178
192
|
public async makePendingBlock(
|
|
179
193
|
numTxs: number,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
194
|
+
{
|
|
195
|
+
checkpointIndex = 0,
|
|
196
|
+
numL1ToL2Messages = 0,
|
|
197
|
+
blockNumber = this.blockNumber,
|
|
198
|
+
makeProcessedTxOpts = () => ({}),
|
|
199
|
+
}: {
|
|
200
|
+
checkpointIndex?: number;
|
|
201
|
+
numL1ToL2Messages?: number;
|
|
202
|
+
blockNumber?: number;
|
|
203
|
+
makeProcessedTxOpts?: (index: number) => Partial<Parameters<typeof makeBloatedProcessedTx>[0]>;
|
|
204
|
+
} = {},
|
|
183
205
|
) {
|
|
184
|
-
const
|
|
206
|
+
const slotNumber = this.firstCheckpointNumber.toNumber() + checkpointIndex;
|
|
207
|
+
const globalVariables = makeGlobals(blockNumber, slotNumber);
|
|
185
208
|
const blockNum = globalVariables.blockNumber;
|
|
186
209
|
const db = await this.worldState.fork();
|
|
187
210
|
const l1ToL2Messages = times(numL1ToL2Messages, i => new Fr(blockNum * 100 + i));
|
|
@@ -202,11 +225,83 @@ export class TestContext {
|
|
|
202
225
|
await this.setTreeRoots(txs);
|
|
203
226
|
|
|
204
227
|
const block = await buildBlockWithCleanDB(txs, globalVariables, l1ToL2Messages, db);
|
|
205
|
-
this.headers.set(blockNum, block.
|
|
228
|
+
this.headers.set(blockNum, block.getBlockHeader());
|
|
206
229
|
await this.worldState.handleL2BlockAndMessages(block, l1ToL2Messages);
|
|
207
230
|
return { block, txs, l1ToL2Messages };
|
|
208
231
|
}
|
|
209
232
|
|
|
233
|
+
public async makePendingBlocksInCheckpoint(
|
|
234
|
+
numBlocks: number,
|
|
235
|
+
{
|
|
236
|
+
checkpointIndex = 0,
|
|
237
|
+
numTxsPerBlock = 1,
|
|
238
|
+
numL1ToL2Messages = 0,
|
|
239
|
+
firstBlockNumber = this.blockNumber + checkpointIndex * numBlocks,
|
|
240
|
+
makeProcessedTxOpts = () => ({}),
|
|
241
|
+
}: {
|
|
242
|
+
checkpointIndex?: number;
|
|
243
|
+
numTxsPerBlock?: number | number[];
|
|
244
|
+
numL1ToL2Messages?: number;
|
|
245
|
+
firstBlockNumber?: number;
|
|
246
|
+
makeProcessedTxOpts?: (index: number) => Partial<Parameters<typeof makeBloatedProcessedTx>[0]>;
|
|
247
|
+
} = {},
|
|
248
|
+
) {
|
|
249
|
+
const slotNumber = this.firstCheckpointNumber.toNumber() + checkpointIndex;
|
|
250
|
+
const l1ToL2Messages = times(numL1ToL2Messages, i => new Fr(slotNumber * 100 + i));
|
|
251
|
+
const merkleTrees = await this.worldState.fork();
|
|
252
|
+
await merkleTrees.appendLeaves(
|
|
253
|
+
MerkleTreeId.L1_TO_L2_MESSAGE_TREE,
|
|
254
|
+
padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP),
|
|
255
|
+
);
|
|
256
|
+
const newL1ToL2Snapshot = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, merkleTrees);
|
|
257
|
+
|
|
258
|
+
const blockGlobalVariables = times(numBlocks, i => makeGlobals(firstBlockNumber + i, slotNumber));
|
|
259
|
+
let totalTxs = 0;
|
|
260
|
+
const blockTxs = await timesParallel(numBlocks, blockIndex => {
|
|
261
|
+
const txIndexOffset = totalTxs;
|
|
262
|
+
const numTxs = typeof numTxsPerBlock === 'number' ? numTxsPerBlock : numTxsPerBlock[blockIndex];
|
|
263
|
+
totalTxs += numTxs;
|
|
264
|
+
return timesParallel(numTxs, txIndex =>
|
|
265
|
+
this.makeProcessedTx({
|
|
266
|
+
seed: (txIndexOffset + txIndex + 1) * 321 + (checkpointIndex + 1) * 123456,
|
|
267
|
+
globalVariables: blockGlobalVariables[blockIndex],
|
|
268
|
+
header: this.getBlockHeader(firstBlockNumber - 1),
|
|
269
|
+
newL1ToL2Snapshot,
|
|
270
|
+
...makeProcessedTxOpts(txIndexOffset + txIndex),
|
|
271
|
+
}),
|
|
272
|
+
);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
const blockBlobFields = blockTxs.map(txs => getBlockBlobFields(txs.map(tx => tx.txEffect)));
|
|
276
|
+
const totalNumBlobFields = blockBlobFields.reduce((acc, curr) => acc + curr.length, 0);
|
|
277
|
+
const spongeBlobState = SpongeBlob.init(totalNumBlobFields);
|
|
278
|
+
|
|
279
|
+
const blocks: { header: BlockHeader; txs: ProcessedTx[] }[] = [];
|
|
280
|
+
for (let i = 0; i < numBlocks; i++) {
|
|
281
|
+
const isFirstBlock = i === 0;
|
|
282
|
+
const blockNumber = firstBlockNumber + i;
|
|
283
|
+
const globalVariables = blockGlobalVariables[i];
|
|
284
|
+
const txs = blockTxs[i];
|
|
285
|
+
|
|
286
|
+
await this.setTreeRoots(txs);
|
|
287
|
+
|
|
288
|
+
const fork = await this.worldState.fork();
|
|
289
|
+
const blockMsgs = isFirstBlock ? l1ToL2Messages : [];
|
|
290
|
+
const block = await buildBlockWithCleanDB(txs, globalVariables, blockMsgs, fork, spongeBlobState, isFirstBlock);
|
|
291
|
+
|
|
292
|
+
const header = block.getBlockHeader();
|
|
293
|
+
this.headers.set(blockNumber, header);
|
|
294
|
+
|
|
295
|
+
await this.worldState.handleL2BlockAndMessages(block, blockMsgs, isFirstBlock);
|
|
296
|
+
|
|
297
|
+
await spongeBlobState.absorb(blockBlobFields[i]);
|
|
298
|
+
|
|
299
|
+
blocks.push({ header, txs });
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return { blocks, l1ToL2Messages, blobFields: blockBlobFields.flat() };
|
|
303
|
+
}
|
|
304
|
+
|
|
210
305
|
public async processPublicFunctions(
|
|
211
306
|
txs: Tx[],
|
|
212
307
|
{
|
|
@@ -265,12 +360,9 @@ class TestProvingOrchestrator extends ProvingOrchestrator {
|
|
|
265
360
|
|
|
266
361
|
// Disable this check by default, since it requires seeding world state with the block being built
|
|
267
362
|
// This is only enabled in some tests with multiple blocks that populate the pending chain via makePendingBlock
|
|
268
|
-
protected override verifyBuiltBlockAgainstSyncedState(
|
|
269
|
-
l2Block: L2Block,
|
|
270
|
-
newArchive: AppendOnlyTreeSnapshot,
|
|
271
|
-
): Promise<void> {
|
|
363
|
+
protected override verifyBuiltBlockAgainstSyncedState(provingState: BlockProvingState): Promise<void> {
|
|
272
364
|
if (this.isVerifyBuiltBlockAgainstSyncedStateEnabled) {
|
|
273
|
-
return super.verifyBuiltBlockAgainstSyncedState(
|
|
365
|
+
return super.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
274
366
|
}
|
|
275
367
|
return Promise.resolve();
|
|
276
368
|
}
|