@aztec/prover-client 0.0.0-test.0 → 0.0.1-fake-c83136db25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/block-factory/index.d.ts +2 -0
- package/dest/block-factory/index.d.ts.map +1 -0
- package/dest/block-factory/light.d.ts +38 -0
- package/dest/block-factory/light.d.ts.map +1 -0
- package/dest/block-factory/light.js +94 -0
- package/dest/config.d.ts +6 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +11 -1
- package/dest/mocks/fixtures.d.ts +7 -4
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +32 -4
- package/dest/mocks/test_context.d.ts +43 -15
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +110 -48
- package/dest/orchestrator/block-building-helpers.d.ts +37 -28
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +156 -150
- package/dest/orchestrator/block-proving-state.d.ts +62 -46
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +223 -179
- package/dest/orchestrator/checkpoint-proving-state.d.ts +63 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-proving-state.js +211 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +37 -24
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +143 -73
- package/dest/orchestrator/orchestrator.d.ts +34 -31
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +392 -234
- package/dest/orchestrator/orchestrator_metrics.d.ts +2 -0
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +9 -0
- package/dest/orchestrator/tx-proving-state.d.ts +12 -10
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +30 -38
- package/dest/prover-client/prover-client.d.ts +3 -3
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +5 -4
- package/dest/prover-client/server-epoch-prover.d.ts +13 -10
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +11 -11
- package/dest/proving_broker/broker_prover_facade.d.ts +22 -15
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +64 -39
- package/dest/proving_broker/config.d.ts +9 -4
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +15 -4
- package/dest/proving_broker/factory.d.ts +1 -1
- package/dest/proving_broker/factory.d.ts.map +1 -1
- package/dest/proving_broker/factory.js +5 -1
- package/dest/proving_broker/fixtures.js +1 -1
- package/dest/proving_broker/proof_store/factory.js +1 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.js +1 -0
- package/dest/proving_broker/proof_store/index.d.ts +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_agent.d.ts +3 -3
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +83 -47
- package/dest/proving_broker/proving_broker.d.ts +11 -2
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +34 -22
- package/dest/proving_broker/proving_broker_database/memory.js +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +9 -8
- package/dest/proving_broker/proving_job_controller.d.ts +7 -8
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +89 -61
- package/dest/proving_broker/rpc.d.ts +3 -5
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +1 -4
- package/dest/test/mock_proof_store.d.ts +9 -0
- package/dest/test/mock_proof_store.d.ts.map +1 -0
- package/dest/test/mock_proof_store.js +10 -0
- package/dest/test/mock_prover.d.ts +23 -16
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +38 -20
- package/package.json +29 -29
- package/src/block-factory/index.ts +1 -0
- package/src/block-factory/light.ts +140 -0
- package/src/config.ts +24 -8
- package/src/mocks/fixtures.ts +43 -15
- package/src/mocks/test_context.ts +201 -75
- package/src/orchestrator/block-building-helpers.ts +247 -243
- package/src/orchestrator/block-proving-state.ts +247 -231
- package/src/orchestrator/checkpoint-proving-state.ts +299 -0
- package/src/orchestrator/epoch-proving-state.ts +187 -111
- package/src/orchestrator/orchestrator.ts +590 -289
- package/src/orchestrator/orchestrator_metrics.ts +20 -1
- package/src/orchestrator/tx-proving-state.ts +60 -61
- package/src/prover-client/prover-client.ts +16 -14
- package/src/prover-client/server-epoch-prover.ts +40 -21
- package/src/proving_broker/broker_prover_facade.ts +200 -113
- package/src/proving_broker/config.ts +17 -6
- package/src/proving_broker/factory.ts +2 -1
- package/src/proving_broker/fixtures.ts +1 -1
- package/src/proving_broker/proof_store/factory.ts +1 -1
- package/src/proving_broker/proof_store/gcs_proof_store.ts +5 -1
- package/src/proving_broker/proof_store/index.ts +1 -0
- package/src/proving_broker/proof_store/inline_proof_store.ts +1 -1
- package/src/proving_broker/proving_agent.ts +89 -47
- package/src/proving_broker/proving_broker.ts +51 -32
- package/src/proving_broker/proving_broker_database/memory.ts +1 -1
- package/src/proving_broker/proving_broker_database/persisted.ts +9 -8
- package/src/proving_broker/proving_job_controller.ts +92 -81
- package/src/proving_broker/rpc.ts +1 -6
- package/src/test/mock_proof_store.ts +14 -0
- package/src/test/mock_prover.ts +164 -60
- package/dest/bin/get-proof-inputs.d.ts +0 -2
- package/dest/bin/get-proof-inputs.d.ts.map +0 -1
- package/dest/bin/get-proof-inputs.js +0 -51
- package/dest/block_builder/index.d.ts +0 -6
- package/dest/block_builder/index.d.ts.map +0 -1
- package/dest/block_builder/light.d.ts +0 -33
- package/dest/block_builder/light.d.ts.map +0 -1
- package/dest/block_builder/light.js +0 -82
- package/src/bin/get-proof-inputs.ts +0 -59
- package/src/block_builder/index.ts +0 -6
- package/src/block_builder/light.ts +0 -101
- /package/dest/{block_builder → block-factory}/index.js +0 -0
|
@@ -1,45 +1,52 @@
|
|
|
1
1
|
import type { BBProverConfig } from '@aztec/bb-prover';
|
|
2
|
-
import {
|
|
2
|
+
import { TestCircuitProver } from '@aztec/bb-prover';
|
|
3
|
+
import { SpongeBlob } from '@aztec/blob-lib';
|
|
4
|
+
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
5
|
+
import { padArrayEnd, times, timesParallel } from '@aztec/foundation/collection';
|
|
3
6
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
7
|
import type { Logger } from '@aztec/foundation/log';
|
|
5
8
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
9
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
6
10
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
7
|
-
import {
|
|
11
|
+
import { ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
8
12
|
import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
PublicTxSimulationTester,
|
|
12
|
-
PublicTxSimulator,
|
|
13
|
-
SimpleContractDataSource,
|
|
14
|
-
WorldStateDB,
|
|
15
|
-
} from '@aztec/simulator/server';
|
|
13
|
+
import { SimpleContractDataSource } from '@aztec/simulator/public/fixtures';
|
|
14
|
+
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
16
15
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
17
16
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
18
|
-
import
|
|
17
|
+
import { EthAddress } from '@aztec/stdlib/block';
|
|
18
|
+
import { getCheckpointBlobFields } from '@aztec/stdlib/checkpoint';
|
|
19
19
|
import type { ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
|
|
20
|
+
import type { CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
20
21
|
import { makeBloatedProcessedTx } from '@aztec/stdlib/testing';
|
|
21
|
-
import {
|
|
22
|
+
import { MerkleTreeId, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
22
23
|
import { type BlockHeader, type GlobalVariables, type ProcessedTx, TreeSnapshots, type Tx } from '@aztec/stdlib/tx';
|
|
23
24
|
import type { MerkleTreeAdminDatabase } from '@aztec/world-state';
|
|
24
25
|
import { NativeWorldStateService } from '@aztec/world-state/native';
|
|
25
26
|
|
|
26
27
|
import { promises as fs } from 'fs';
|
|
27
28
|
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
29
|
+
import { buildBlockWithCleanDB } from '../block-factory/light.js';
|
|
30
|
+
import { getTreeSnapshot } from '../orchestrator/block-building-helpers.js';
|
|
31
|
+
import type { BlockProvingState } from '../orchestrator/block-proving-state.js';
|
|
30
32
|
import { ProvingOrchestrator } from '../orchestrator/index.js';
|
|
31
33
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
32
34
|
import { TestBroker } from '../test/mock_prover.js';
|
|
33
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
getEnvironmentConfig,
|
|
37
|
+
getSimulator,
|
|
38
|
+
makeCheckpointConstants,
|
|
39
|
+
makeGlobals,
|
|
40
|
+
updateExpectedTreesFromTxs,
|
|
41
|
+
} from './fixtures.js';
|
|
34
42
|
|
|
35
43
|
export class TestContext {
|
|
36
44
|
private headers: Map<number, BlockHeader> = new Map();
|
|
37
45
|
private feePayerBalance: Fr;
|
|
38
46
|
|
|
39
47
|
constructor(
|
|
40
|
-
public publicTxSimulator: PublicTxSimulator,
|
|
41
48
|
public worldState: MerkleTreeAdminDatabase,
|
|
42
|
-
public
|
|
49
|
+
public firstCheckpointNumber: Fr,
|
|
43
50
|
public globalVariables: GlobalVariables,
|
|
44
51
|
public prover: ServerCircuitProver,
|
|
45
52
|
public broker: TestBroker,
|
|
@@ -49,7 +56,6 @@ export class TestContext {
|
|
|
49
56
|
public feePayer: AztecAddress,
|
|
50
57
|
initialFeePayerBalance: Fr,
|
|
51
58
|
public directoriesToCleanup: string[],
|
|
52
|
-
public tester: PublicTxSimulationTester,
|
|
53
59
|
public logger: Logger,
|
|
54
60
|
) {
|
|
55
61
|
this.feePayerBalance = initialFeePayerBalance;
|
|
@@ -59,15 +65,27 @@ export class TestContext {
|
|
|
59
65
|
return this.orchestrator;
|
|
60
66
|
}
|
|
61
67
|
|
|
68
|
+
public getCheckpointConstants(checkpointIndex = 0): CheckpointConstantData {
|
|
69
|
+
return makeCheckpointConstants(this.firstCheckpointNumber.toNumber() + checkpointIndex);
|
|
70
|
+
}
|
|
71
|
+
|
|
62
72
|
static async new(
|
|
63
73
|
logger: Logger,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
new TestCircuitProver(await
|
|
67
|
-
|
|
74
|
+
{
|
|
75
|
+
proverCount = 4,
|
|
76
|
+
createProver = async (bbConfig: BBProverConfig) => new TestCircuitProver(await getSimulator(bbConfig, logger)),
|
|
77
|
+
slotNumber = 1,
|
|
78
|
+
blockNumber = 1,
|
|
79
|
+
}: {
|
|
80
|
+
proverCount?: number;
|
|
81
|
+
createProver?: (bbConfig: BBProverConfig) => Promise<ServerCircuitProver>;
|
|
82
|
+
slotNumber?: number;
|
|
83
|
+
blockNumber?: number;
|
|
84
|
+
} = {},
|
|
68
85
|
) {
|
|
69
86
|
const directoriesToCleanup: string[] = [];
|
|
70
|
-
const
|
|
87
|
+
const firstCheckpointNumber = new Fr(slotNumber);
|
|
88
|
+
const globalVariables = makeGlobals(blockNumber, slotNumber);
|
|
71
89
|
|
|
72
90
|
const feePayer = AztecAddress.fromNumber(42222);
|
|
73
91
|
const initialFeePayerBalance = new Fr(10n ** 20n);
|
|
@@ -76,25 +94,10 @@ export class TestContext {
|
|
|
76
94
|
|
|
77
95
|
// Separated dbs for public processor and prover - see public_processor for context
|
|
78
96
|
const ws = await NativeWorldStateService.tmp(
|
|
79
|
-
|
|
80
|
-
|
|
97
|
+
/*rollupAddress=*/ undefined,
|
|
98
|
+
/*cleanupTmpDir=*/ true,
|
|
81
99
|
prefilledPublicData,
|
|
82
100
|
);
|
|
83
|
-
const publicDb = await ws.fork();
|
|
84
|
-
|
|
85
|
-
const contractDataSource = new SimpleContractDataSource();
|
|
86
|
-
const worldStateDB = new WorldStateDB(publicDb, contractDataSource);
|
|
87
|
-
|
|
88
|
-
const tester = new PublicTxSimulationTester(worldStateDB, contractDataSource, publicDb);
|
|
89
|
-
|
|
90
|
-
const publicTxSimulator = new PublicTxSimulator(publicDb, worldStateDB, globalVariables, true);
|
|
91
|
-
const processor = new PublicProcessor(
|
|
92
|
-
publicDb,
|
|
93
|
-
globalVariables,
|
|
94
|
-
worldStateDB,
|
|
95
|
-
publicTxSimulator,
|
|
96
|
-
new TestDateProvider(),
|
|
97
|
-
);
|
|
98
101
|
|
|
99
102
|
let localProver: ServerCircuitProver;
|
|
100
103
|
const config = await getEnvironmentConfig(logger);
|
|
@@ -107,6 +110,8 @@ export class TestContext {
|
|
|
107
110
|
bbBinaryPath: config.expectedBBPath,
|
|
108
111
|
bbWorkingDirectory: config.bbWorkingDirectory,
|
|
109
112
|
bbSkipCleanup: config.bbSkipCleanup,
|
|
113
|
+
numConcurrentIVCVerifiers: 2,
|
|
114
|
+
bbIVCConcurrency: 1,
|
|
110
115
|
};
|
|
111
116
|
localProver = await createProver(bbConfig);
|
|
112
117
|
}
|
|
@@ -117,15 +122,14 @@ export class TestContext {
|
|
|
117
122
|
|
|
118
123
|
const broker = new TestBroker(proverCount, localProver);
|
|
119
124
|
const facade = new BrokerCircuitProverFacade(broker);
|
|
120
|
-
const orchestrator = new TestProvingOrchestrator(ws, facade,
|
|
125
|
+
const orchestrator = new TestProvingOrchestrator(ws, facade, EthAddress.ZERO);
|
|
121
126
|
|
|
122
127
|
await broker.start();
|
|
123
128
|
facade.start();
|
|
124
129
|
|
|
125
130
|
return new this(
|
|
126
|
-
publicTxSimulator,
|
|
127
131
|
ws,
|
|
128
|
-
|
|
132
|
+
firstCheckpointNumber,
|
|
129
133
|
globalVariables,
|
|
130
134
|
localProver,
|
|
131
135
|
broker,
|
|
@@ -135,7 +139,6 @@ export class TestContext {
|
|
|
135
139
|
feePayer,
|
|
136
140
|
initialFeePayerBalance,
|
|
137
141
|
directoriesToCleanup,
|
|
138
|
-
tester,
|
|
139
142
|
logger,
|
|
140
143
|
);
|
|
141
144
|
}
|
|
@@ -146,7 +149,7 @@ export class TestContext {
|
|
|
146
149
|
|
|
147
150
|
public getBlockHeader(blockNumber: 0): BlockHeader;
|
|
148
151
|
public getBlockHeader(blockNumber: number): BlockHeader | undefined;
|
|
149
|
-
public getBlockHeader(blockNumber = 0) {
|
|
152
|
+
public getBlockHeader(blockNumber = 0): BlockHeader | undefined {
|
|
150
153
|
return blockNumber === 0 ? this.worldState.getCommitted().getInitialHeader() : this.headers.get(blockNumber);
|
|
151
154
|
}
|
|
152
155
|
|
|
@@ -166,19 +169,15 @@ export class TestContext {
|
|
|
166
169
|
}
|
|
167
170
|
}
|
|
168
171
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
): Promise<ProcessedTx> {
|
|
174
|
-
const opts = typeof seedOrOpts === 'number' ? { seed: seedOrOpts } : seedOrOpts;
|
|
175
|
-
const blockNum = (opts?.globalVariables ?? this.globalVariables).blockNumber.toNumber();
|
|
176
|
-
const header = this.getBlockHeader(blockNum - 1);
|
|
172
|
+
async makeProcessedTx(opts?: Parameters<typeof makeBloatedProcessedTx>[0]): Promise<ProcessedTx> {
|
|
173
|
+
const globalVariables = opts?.globalVariables ?? this.globalVariables;
|
|
174
|
+
const blockNumber = globalVariables.blockNumber;
|
|
175
|
+
const header = opts?.header ?? this.getBlockHeader(blockNumber - 1);
|
|
177
176
|
const tx = await makeBloatedProcessedTx({
|
|
178
177
|
header,
|
|
179
178
|
vkTreeRoot: getVKTreeRoot(),
|
|
180
|
-
|
|
181
|
-
globalVariables
|
|
179
|
+
protocolContracts: ProtocolContractsList,
|
|
180
|
+
globalVariables,
|
|
182
181
|
feePayer: this.feePayer,
|
|
183
182
|
...opts,
|
|
184
183
|
});
|
|
@@ -193,44 +192,174 @@ export class TestContext {
|
|
|
193
192
|
/** Creates a block with the given number of txs and adds it to world-state */
|
|
194
193
|
public async makePendingBlock(
|
|
195
194
|
numTxs: number,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
{
|
|
196
|
+
checkpointIndex = 0,
|
|
197
|
+
numL1ToL2Messages = 0,
|
|
198
|
+
blockNumber = this.blockNumber,
|
|
199
|
+
makeProcessedTxOpts = () => ({}),
|
|
200
|
+
}: {
|
|
201
|
+
checkpointIndex?: number;
|
|
202
|
+
numL1ToL2Messages?: number;
|
|
203
|
+
blockNumber?: number;
|
|
204
|
+
makeProcessedTxOpts?: (index: number) => Partial<Parameters<typeof makeBloatedProcessedTx>[0]>;
|
|
205
|
+
} = {},
|
|
199
206
|
) {
|
|
200
|
-
const
|
|
201
|
-
const
|
|
207
|
+
const slotNumber = this.firstCheckpointNumber.toNumber() + checkpointIndex;
|
|
208
|
+
const globalVariables = makeGlobals(blockNumber, slotNumber);
|
|
209
|
+
const blockNum = globalVariables.blockNumber;
|
|
202
210
|
const db = await this.worldState.fork();
|
|
203
|
-
const
|
|
211
|
+
const l1ToL2Messages = times(numL1ToL2Messages, i => new Fr(blockNum * 100 + i));
|
|
212
|
+
const merkleTrees = await this.worldState.fork();
|
|
213
|
+
await merkleTrees.appendLeaves(
|
|
214
|
+
MerkleTreeId.L1_TO_L2_MESSAGE_TREE,
|
|
215
|
+
padArrayEnd<Fr, number>(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP),
|
|
216
|
+
);
|
|
217
|
+
const newL1ToL2Snapshot = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, merkleTrees);
|
|
204
218
|
const txs = await timesParallel(numTxs, i =>
|
|
205
|
-
this.makeProcessedTx({
|
|
219
|
+
this.makeProcessedTx({
|
|
220
|
+
seed: i + blockNum * 1000,
|
|
221
|
+
globalVariables,
|
|
222
|
+
newL1ToL2Snapshot,
|
|
223
|
+
...makeProcessedTxOpts(i),
|
|
224
|
+
}),
|
|
206
225
|
);
|
|
207
226
|
await this.setTreeRoots(txs);
|
|
208
227
|
|
|
209
|
-
const block = await
|
|
210
|
-
this.headers.set(blockNum, block.
|
|
211
|
-
await this.worldState.handleL2BlockAndMessages(block,
|
|
212
|
-
return { block, txs,
|
|
228
|
+
const block = await buildBlockWithCleanDB(txs, globalVariables, l1ToL2Messages, db);
|
|
229
|
+
this.headers.set(blockNum, block.getBlockHeader());
|
|
230
|
+
await this.worldState.handleL2BlockAndMessages(block, l1ToL2Messages);
|
|
231
|
+
return { block, txs, l1ToL2Messages };
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
public async makePendingBlocksInCheckpoint(
|
|
235
|
+
numBlocks: number,
|
|
236
|
+
{
|
|
237
|
+
checkpointIndex = 0,
|
|
238
|
+
numTxsPerBlock = 1,
|
|
239
|
+
numL1ToL2Messages = 0,
|
|
240
|
+
firstBlockNumber = this.blockNumber + checkpointIndex * numBlocks,
|
|
241
|
+
makeGlobalVariablesOpts = () => ({}),
|
|
242
|
+
makeProcessedTxOpts = () => ({}),
|
|
243
|
+
}: {
|
|
244
|
+
checkpointIndex?: number;
|
|
245
|
+
numTxsPerBlock?: number | number[];
|
|
246
|
+
numL1ToL2Messages?: number;
|
|
247
|
+
firstBlockNumber?: number;
|
|
248
|
+
makeGlobalVariablesOpts?: (
|
|
249
|
+
blockNumber: number,
|
|
250
|
+
checkpointIndex: number,
|
|
251
|
+
) => Partial<FieldsOf<GlobalVariables> & FieldsOf<CheckpointConstantData>>;
|
|
252
|
+
makeProcessedTxOpts?: (
|
|
253
|
+
blockGlobalVariables: GlobalVariables,
|
|
254
|
+
txIndex: number,
|
|
255
|
+
) => Partial<Parameters<typeof makeBloatedProcessedTx>[0]>;
|
|
256
|
+
} = {},
|
|
257
|
+
) {
|
|
258
|
+
const slotNumber = this.firstCheckpointNumber.toNumber() + checkpointIndex;
|
|
259
|
+
const l1ToL2Messages = times(numL1ToL2Messages, i => new Fr(slotNumber * 100 + i));
|
|
260
|
+
const merkleTrees = await this.worldState.fork();
|
|
261
|
+
await merkleTrees.appendLeaves(
|
|
262
|
+
MerkleTreeId.L1_TO_L2_MESSAGE_TREE,
|
|
263
|
+
padArrayEnd<Fr, number>(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP),
|
|
264
|
+
);
|
|
265
|
+
const newL1ToL2Snapshot = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, merkleTrees);
|
|
266
|
+
|
|
267
|
+
const blockGlobalVariables = times(numBlocks, i =>
|
|
268
|
+
makeGlobals(firstBlockNumber + i, slotNumber, makeGlobalVariablesOpts(firstBlockNumber + i, checkpointIndex)),
|
|
269
|
+
);
|
|
270
|
+
let totalTxs = 0;
|
|
271
|
+
const blockTxs = await timesParallel(numBlocks, blockIndex => {
|
|
272
|
+
const txIndexOffset = totalTxs;
|
|
273
|
+
const numTxs = typeof numTxsPerBlock === 'number' ? numTxsPerBlock : numTxsPerBlock[blockIndex];
|
|
274
|
+
totalTxs += numTxs;
|
|
275
|
+
return timesParallel(numTxs, txIndex =>
|
|
276
|
+
this.makeProcessedTx({
|
|
277
|
+
seed: (txIndexOffset + txIndex + 1) * 321 + (checkpointIndex + 1) * 123456,
|
|
278
|
+
globalVariables: blockGlobalVariables[blockIndex],
|
|
279
|
+
header: this.getBlockHeader(firstBlockNumber - 1),
|
|
280
|
+
newL1ToL2Snapshot,
|
|
281
|
+
...makeProcessedTxOpts(blockGlobalVariables[blockIndex], txIndexOffset + txIndex),
|
|
282
|
+
}),
|
|
283
|
+
);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
const blobFields = getCheckpointBlobFields(blockTxs.map(txs => txs.map(tx => tx.txEffect)));
|
|
287
|
+
const spongeBlobState = await SpongeBlob.init(blobFields.length);
|
|
288
|
+
|
|
289
|
+
const blocks: { header: BlockHeader; txs: ProcessedTx[] }[] = [];
|
|
290
|
+
for (let i = 0; i < numBlocks; i++) {
|
|
291
|
+
const isFirstBlock = i === 0;
|
|
292
|
+
const blockNumber = firstBlockNumber + i;
|
|
293
|
+
const globalVariables = blockGlobalVariables[i];
|
|
294
|
+
const txs = blockTxs[i];
|
|
295
|
+
|
|
296
|
+
await this.setTreeRoots(txs);
|
|
297
|
+
|
|
298
|
+
const fork = await this.worldState.fork();
|
|
299
|
+
const blockMsgs = isFirstBlock ? l1ToL2Messages : [];
|
|
300
|
+
const block = await buildBlockWithCleanDB(txs, globalVariables, blockMsgs, fork, spongeBlobState, isFirstBlock);
|
|
301
|
+
|
|
302
|
+
const header = block.getBlockHeader();
|
|
303
|
+
this.headers.set(blockNumber, header);
|
|
304
|
+
|
|
305
|
+
await this.worldState.handleL2BlockAndMessages(block, blockMsgs, isFirstBlock);
|
|
306
|
+
|
|
307
|
+
const blockBlobFields = block.body.toBlobFields();
|
|
308
|
+
await spongeBlobState.absorb(blockBlobFields);
|
|
309
|
+
|
|
310
|
+
blocks.push({ header, txs });
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return { blocks, l1ToL2Messages, blobFields };
|
|
213
314
|
}
|
|
214
315
|
|
|
215
|
-
public async processPublicFunctions(
|
|
216
|
-
|
|
316
|
+
public async processPublicFunctions(
|
|
317
|
+
txs: Tx[],
|
|
318
|
+
{
|
|
319
|
+
maxTransactions = txs.length,
|
|
320
|
+
numL1ToL2Messages = 0,
|
|
321
|
+
contractDataSource,
|
|
322
|
+
}: {
|
|
323
|
+
maxTransactions?: number;
|
|
324
|
+
numL1ToL2Messages?: number;
|
|
325
|
+
contractDataSource?: SimpleContractDataSource;
|
|
326
|
+
} = {},
|
|
327
|
+
) {
|
|
328
|
+
const l1ToL2Messages = times(numL1ToL2Messages, i => new Fr(this.blockNumber * 100 + i));
|
|
329
|
+
const merkleTrees = await this.worldState.fork();
|
|
330
|
+
await merkleTrees.appendLeaves(
|
|
331
|
+
MerkleTreeId.L1_TO_L2_MESSAGE_TREE,
|
|
332
|
+
padArrayEnd<Fr, number>(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP),
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
const processorFactory = new PublicProcessorFactory(
|
|
336
|
+
contractDataSource ?? new SimpleContractDataSource(),
|
|
337
|
+
new TestDateProvider(),
|
|
338
|
+
);
|
|
339
|
+
const publicProcessor = processorFactory.create(merkleTrees, this.globalVariables, {
|
|
340
|
+
skipFeeEnforcement: false,
|
|
341
|
+
clientInitiatedSimulation: false,
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
return await publicProcessor.process(txs, { maxTransactions });
|
|
217
345
|
}
|
|
218
346
|
|
|
219
|
-
|
|
347
|
+
private async setTreeRoots(txs: ProcessedTx[]) {
|
|
220
348
|
const db = await this.worldState.fork();
|
|
221
349
|
for (const tx of txs) {
|
|
222
350
|
const startStateReference = await db.getStateReference();
|
|
223
351
|
await updateExpectedTreesFromTxs(db, [tx]);
|
|
224
352
|
const endStateReference = await db.getStateReference();
|
|
225
353
|
if (tx.avmProvingRequest) {
|
|
354
|
+
const l1ToL2MessageTree = tx.avmProvingRequest.inputs.publicInputs.startTreeSnapshots.l1ToL2MessageTree;
|
|
226
355
|
tx.avmProvingRequest.inputs.publicInputs.startTreeSnapshots = new TreeSnapshots(
|
|
227
|
-
|
|
356
|
+
l1ToL2MessageTree,
|
|
228
357
|
startStateReference.partial.noteHashTree,
|
|
229
358
|
startStateReference.partial.nullifierTree,
|
|
230
359
|
startStateReference.partial.publicDataTree,
|
|
231
360
|
);
|
|
232
361
|
tx.avmProvingRequest.inputs.publicInputs.endTreeSnapshots = new TreeSnapshots(
|
|
233
|
-
|
|
362
|
+
l1ToL2MessageTree,
|
|
234
363
|
endStateReference.partial.noteHashTree,
|
|
235
364
|
endStateReference.partial.nullifierTree,
|
|
236
365
|
endStateReference.partial.publicDataTree,
|
|
@@ -245,12 +374,9 @@ class TestProvingOrchestrator extends ProvingOrchestrator {
|
|
|
245
374
|
|
|
246
375
|
// Disable this check by default, since it requires seeding world state with the block being built
|
|
247
376
|
// This is only enabled in some tests with multiple blocks that populate the pending chain via makePendingBlock
|
|
248
|
-
protected override verifyBuiltBlockAgainstSyncedState(
|
|
249
|
-
l2Block: L2Block,
|
|
250
|
-
newArchive: AppendOnlyTreeSnapshot,
|
|
251
|
-
): Promise<void> {
|
|
377
|
+
protected override verifyBuiltBlockAgainstSyncedState(provingState: BlockProvingState): Promise<void> {
|
|
252
378
|
if (this.isVerifyBuiltBlockAgainstSyncedStateEnabled) {
|
|
253
|
-
return super.verifyBuiltBlockAgainstSyncedState(
|
|
379
|
+
return super.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
254
380
|
}
|
|
255
381
|
return Promise.resolve();
|
|
256
382
|
}
|