@aztec/prover-client 0.0.1-fake-c83136db25 → 0.0.1-fake-ceab37513c
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/bin/get-proof-inputs.d.ts +2 -0
- package/dest/bin/get-proof-inputs.d.ts.map +1 -0
- package/dest/bin/get-proof-inputs.js +51 -0
- package/dest/block-factory/light.d.ts +3 -5
- package/dest/block-factory/light.d.ts.map +1 -1
- package/dest/block-factory/light.js +9 -16
- package/dest/config.js +1 -1
- package/dest/mocks/fixtures.d.ts +1 -4
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +3 -31
- package/dest/mocks/test_context.d.ts +9 -32
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +22 -78
- package/dest/orchestrator/block-building-helpers.d.ts +31 -33
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +137 -126
- package/dest/orchestrator/block-proving-state.d.ts +53 -60
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +187 -214
- package/dest/orchestrator/epoch-proving-state.d.ts +28 -34
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +84 -128
- package/dest/orchestrator/orchestrator.d.ts +30 -31
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +236 -368
- package/dest/orchestrator/tx-proving-state.d.ts +9 -11
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +23 -26
- package/dest/prover-client/server-epoch-prover.d.ts +8 -9
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +9 -9
- package/dest/proving_broker/broker_prover_facade.d.ts +15 -20
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +21 -36
- package/dest/proving_broker/fixtures.js +1 -1
- package/dest/proving_broker/proof_store/index.d.ts +0 -1
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +0 -1
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +18 -29
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +18 -38
- package/dest/test/mock_prover.d.ts +17 -22
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +20 -35
- package/package.json +17 -16
- package/src/bin/get-proof-inputs.ts +59 -0
- package/src/block-factory/light.ts +9 -35
- package/src/config.ts +1 -1
- package/src/mocks/fixtures.ts +11 -39
- package/src/mocks/test_context.ts +31 -137
- package/src/orchestrator/block-building-helpers.ts +211 -211
- package/src/orchestrator/block-proving-state.ts +245 -235
- package/src/orchestrator/epoch-proving-state.ts +127 -172
- package/src/orchestrator/orchestrator.ts +303 -545
- package/src/orchestrator/tx-proving-state.ts +43 -49
- package/src/prover-client/server-epoch-prover.ts +18 -28
- package/src/proving_broker/broker_prover_facade.ts +86 -157
- package/src/proving_broker/fixtures.ts +1 -1
- package/src/proving_broker/proof_store/index.ts +0 -1
- package/src/proving_broker/proving_broker.ts +18 -36
- package/src/proving_broker/proving_job_controller.ts +18 -38
- package/src/test/mock_prover.ts +60 -142
- package/dest/orchestrator/checkpoint-proving-state.d.ts +0 -63
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +0 -1
- package/dest/orchestrator/checkpoint-proving-state.js +0 -211
- package/src/orchestrator/checkpoint-proving-state.ts +0 -299
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-proof-inputs.d.ts","sourceRoot":"","sources":["../../src/bin/get-proof-inputs.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* eslint-disable no-console */ import { AVM_INPUTS_FILENAME } from '@aztec/bb-prover';
|
|
2
|
+
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { ProvingJobInputs } from '@aztec/stdlib/interfaces/server';
|
|
5
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
6
|
+
import { mkdirSync, writeFileSync } from 'fs';
|
|
7
|
+
import { createProofStoreForUri } from '../proving_broker/index.js';
|
|
8
|
+
const logger = createLogger('prover-client:get-proof-inputs');
|
|
9
|
+
function printUsage() {
|
|
10
|
+
console.error('Usage: get-proof-inputs <proof-uri> [out-dir=.]');
|
|
11
|
+
}
|
|
12
|
+
async function main() {
|
|
13
|
+
if (process.argv[2] === '--help') {
|
|
14
|
+
printUsage();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const uri = process.argv[2];
|
|
18
|
+
const outDir = process.argv[3] || '.';
|
|
19
|
+
if (!uri) {
|
|
20
|
+
printUsage();
|
|
21
|
+
throw new Error('Missing proof URI');
|
|
22
|
+
}
|
|
23
|
+
mkdirSync(outDir, {
|
|
24
|
+
recursive: true
|
|
25
|
+
});
|
|
26
|
+
const proofStore = createProofStoreForUri(uri);
|
|
27
|
+
logger.info(`Processing uri ${uri}`);
|
|
28
|
+
const input = await proofStore.getProofInput(uri);
|
|
29
|
+
logger.info(`Found inputs for ${ProvingRequestType[input.type]}`);
|
|
30
|
+
writeProofInputs(input, outDir);
|
|
31
|
+
console.log(jsonParseWithSchema(jsonStringify(input), ProvingJobInputs).inputs);
|
|
32
|
+
}
|
|
33
|
+
// This mimics the behavior of bb-prover/src/bb/execute.ts
|
|
34
|
+
function writeProofInputs(input, outDir) {
|
|
35
|
+
switch(input.type){
|
|
36
|
+
case ProvingRequestType.PUBLIC_VM:
|
|
37
|
+
{
|
|
38
|
+
writeFileSync(`${outDir}/${AVM_INPUTS_FILENAME}`, input.inputs.serializeWithMessagePack());
|
|
39
|
+
logger.info(`Wrote AVM inputs to ${AVM_INPUTS_FILENAME}`);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
default:
|
|
43
|
+
{
|
|
44
|
+
throw new Error(`Unimplemented proving request type: ${ProvingRequestType[input.type]}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
main().catch((err)=>{
|
|
49
|
+
console.error(err);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { SpongeBlob } from '@aztec/blob-lib';
|
|
2
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
2
|
import { L2Block } from '@aztec/stdlib/block';
|
|
4
3
|
import type { IBlockFactory, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
5
|
-
import type
|
|
4
|
+
import { type GlobalVariables, type ProcessedTx } from '@aztec/stdlib/tx';
|
|
6
5
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
7
6
|
/**
|
|
8
7
|
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
@@ -21,11 +20,10 @@ export declare class LightweightBlockFactory implements IBlockFactory {
|
|
|
21
20
|
private telemetry;
|
|
22
21
|
private globalVariables?;
|
|
23
22
|
private l1ToL2Messages?;
|
|
24
|
-
private startSpongeBlob?;
|
|
25
23
|
private txs;
|
|
26
24
|
private readonly logger;
|
|
27
25
|
constructor(db: MerkleTreeWriteOperations, telemetry?: TelemetryClient);
|
|
28
|
-
startNewBlock(globalVariables: GlobalVariables, l1ToL2Messages: Fr[]
|
|
26
|
+
startNewBlock(globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void>;
|
|
29
27
|
addTxs(txs: ProcessedTx[]): Promise<void>;
|
|
30
28
|
setBlockCompleted(): Promise<L2Block>;
|
|
31
29
|
private buildBlock;
|
|
@@ -34,5 +32,5 @@ export declare class LightweightBlockFactory implements IBlockFactory {
|
|
|
34
32
|
* Inserts the processed transactions into the DB, then creates a block.
|
|
35
33
|
* @param db - A db fork to use for block building which WILL BE MODIFIED.
|
|
36
34
|
*/
|
|
37
|
-
export declare function buildBlockWithCleanDB(txs: ProcessedTx[], globalVariables: GlobalVariables, l1ToL2Messages: Fr[], db: MerkleTreeWriteOperations,
|
|
35
|
+
export declare function buildBlockWithCleanDB(txs: ProcessedTx[], globalVariables: GlobalVariables, l1ToL2Messages: Fr[], db: MerkleTreeWriteOperations, telemetry?: TelemetryClient): Promise<L2Block>;
|
|
38
36
|
//# sourceMappingURL=light.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"light.d.ts","sourceRoot":"","sources":["../../src/block-factory/light.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"light.d.ts","sourceRoot":"","sources":["../../src/block-factory/light.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEhG,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAmB,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAQnF;;;;;;;;;;;GAWG;AACH,qBAAa,uBAAwB,YAAW,aAAa;IASzD,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,SAAS;IATnB,OAAO,CAAC,eAAe,CAAC,CAAkB;IAC1C,OAAO,CAAC,cAAc,CAAC,CAAO;IAE9B,OAAO,CAAC,GAAG,CAA4B;IAEvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6C;gBAG1D,EAAE,EAAE,yBAAyB,EAC7B,SAAS,GAAE,eAAsC;IAGrD,aAAa,CAAC,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1F,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAWzC,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;YAIvB,UAAU;CAwBzB;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,WAAW,EAAE,EAClB,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,EAAE,EAAE,EACpB,EAAE,EAAE,yBAAyB,EAC7B,SAAS,GAAE,eAAsC,oBAWlD"}
|
|
@@ -5,6 +5,7 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { L2Block } from '@aztec/stdlib/block';
|
|
7
7
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
8
|
+
import { toNumBlobFields } from '@aztec/stdlib/tx';
|
|
8
9
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
9
10
|
import { buildHeaderAndBodyFromTxs, getTreeSnapshot, insertSideEffectsAndBuildBaseRollupHints } from '../orchestrator/block-building-helpers.js';
|
|
10
11
|
/**
|
|
@@ -23,7 +24,6 @@ import { buildHeaderAndBodyFromTxs, getTreeSnapshot, insertSideEffectsAndBuildBa
|
|
|
23
24
|
telemetry;
|
|
24
25
|
globalVariables;
|
|
25
26
|
l1ToL2Messages;
|
|
26
|
-
startSpongeBlob;
|
|
27
27
|
txs;
|
|
28
28
|
logger;
|
|
29
29
|
constructor(db, telemetry = getTelemetryClient()){
|
|
@@ -31,16 +31,13 @@ import { buildHeaderAndBodyFromTxs, getTreeSnapshot, insertSideEffectsAndBuildBa
|
|
|
31
31
|
this.telemetry = telemetry;
|
|
32
32
|
this.logger = createLogger('lightweight-block-factory');
|
|
33
33
|
}
|
|
34
|
-
async startNewBlock(globalVariables, l1ToL2Messages
|
|
35
|
-
startSpongeBlob, // Only insert l1 to l2 messages for the first block in a checkpoint.
|
|
36
|
-
isFirstBlock = true) {
|
|
34
|
+
async startNewBlock(globalVariables, l1ToL2Messages) {
|
|
37
35
|
this.logger.debug('Starting new block', {
|
|
38
36
|
globalVariables: globalVariables.toInspect(),
|
|
39
37
|
l1ToL2Messages
|
|
40
38
|
});
|
|
41
39
|
this.globalVariables = globalVariables;
|
|
42
|
-
this.l1ToL2Messages =
|
|
43
|
-
this.startSpongeBlob = startSpongeBlob;
|
|
40
|
+
this.l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
44
41
|
this.txs = undefined;
|
|
45
42
|
// Update L1 to L2 tree
|
|
46
43
|
await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages);
|
|
@@ -59,10 +56,9 @@ import { buildHeaderAndBodyFromTxs, getTreeSnapshot, insertSideEffectsAndBuildBa
|
|
|
59
56
|
return this.buildBlock();
|
|
60
57
|
}
|
|
61
58
|
async buildBlock() {
|
|
62
|
-
const { header, body } = await buildHeaderAndBodyFromTxs(this.txs ?? [], this.globalVariables, this.l1ToL2Messages, this.db
|
|
59
|
+
const { header, body } = await buildHeaderAndBodyFromTxs(this.txs ?? [], this.globalVariables, this.l1ToL2Messages, this.db);
|
|
63
60
|
header.state.validate();
|
|
64
|
-
|
|
65
|
-
await this.db.updateArchive(blockHeader);
|
|
61
|
+
await this.db.updateArchive(header);
|
|
66
62
|
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
67
63
|
const block = new L2Block(newArchive, header, body);
|
|
68
64
|
this.logger.debug(`Built block ${block.number}`, {
|
|
@@ -78,16 +74,13 @@ import { buildHeaderAndBodyFromTxs, getTreeSnapshot, insertSideEffectsAndBuildBa
|
|
|
78
74
|
/**
|
|
79
75
|
* Inserts the processed transactions into the DB, then creates a block.
|
|
80
76
|
* @param db - A db fork to use for block building which WILL BE MODIFIED.
|
|
81
|
-
*/ export async function buildBlockWithCleanDB(txs, globalVariables, l1ToL2Messages, db,
|
|
82
|
-
const
|
|
77
|
+
*/ export async function buildBlockWithCleanDB(txs, globalVariables, l1ToL2Messages, db, telemetry = getTelemetryClient()) {
|
|
78
|
+
const spongeBlobState = SpongeBlob.init(toNumBlobFields(txs));
|
|
83
79
|
const builder = new LightweightBlockFactory(db, telemetry);
|
|
84
|
-
await builder.startNewBlock(globalVariables, l1ToL2Messages
|
|
80
|
+
await builder.startNewBlock(globalVariables, l1ToL2Messages);
|
|
85
81
|
const l1ToL2MessageTree = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, db);
|
|
86
82
|
for (const tx of txs){
|
|
87
|
-
|
|
88
|
-
// Their values don't matter here because we are not using the return private inputs to build the block.
|
|
89
|
-
const proverId = Fr.ZERO;
|
|
90
|
-
await insertSideEffectsAndBuildBaseRollupHints(tx, lastArchive, l1ToL2MessageTree, startSpongeBlob?.clone() ?? SpongeBlob.empty(), proverId, db);
|
|
83
|
+
await insertSideEffectsAndBuildBaseRollupHints(tx, globalVariables, l1ToL2MessageTree, db, spongeBlobState);
|
|
91
84
|
}
|
|
92
85
|
await builder.addTxs(txs);
|
|
93
86
|
return await builder.setBlockCompleted();
|
package/dest/config.js
CHANGED
|
@@ -25,7 +25,7 @@ export const bbConfigMappings = {
|
|
|
25
25
|
},
|
|
26
26
|
numConcurrentIVCVerifiers: {
|
|
27
27
|
env: 'BB_NUM_IVC_VERIFIERS',
|
|
28
|
-
description: 'Max number of
|
|
28
|
+
description: 'Max number of client IVC verifiers to run concurrently',
|
|
29
29
|
...numberConfigHelper(8)
|
|
30
30
|
},
|
|
31
31
|
bbIVCConcurrency: {
|
package/dest/mocks/fixtures.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
2
|
import { type CircuitSimulator } from '@aztec/simulator/server';
|
|
4
3
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
5
|
-
import { CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
6
4
|
import type { ProcessedTx } from '@aztec/stdlib/tx';
|
|
7
5
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
8
6
|
export declare const getEnvironmentConfig: (logger: Logger) => Promise<{
|
|
@@ -18,6 +16,5 @@ export declare function getSimulator(config: {
|
|
|
18
16
|
acvmBinaryPath: string | undefined;
|
|
19
17
|
}, logger?: Logger): Promise<CircuitSimulator>;
|
|
20
18
|
export declare const updateExpectedTreesFromTxs: (db: MerkleTreeWriteOperations, txs: ProcessedTx[]) => Promise<void>;
|
|
21
|
-
export declare const makeGlobals: (blockNumber: number
|
|
22
|
-
export declare const makeCheckpointConstants: (slotNumber: number, overrides?: Partial<FieldsOf<CheckpointConstantData>>) => CheckpointConstantData;
|
|
19
|
+
export declare const makeGlobals: (blockNumber: number) => GlobalVariables;
|
|
23
20
|
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/mocks/fixtures.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/mocks/fixtures.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,KAAK,gBAAgB,EAA+C,MAAM,yBAAyB,CAAC;AAG7G,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAiBnD,eAAO,MAAM,oBAAoB,GAAU,QAAQ,MAAM;;;;;;;cAkCxD,CAAC;AAEF,wBAAsB,YAAY,CAChC,MAAM,EAAE;IAAE,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EACxF,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,CAAC,CAe3B;AAGD,eAAO,MAAM,0BAA0B,GAAU,IAAI,yBAAyB,EAAE,KAAK,WAAW,EAAE,kBAgBjG,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,aAAa,MAAM,oBAW9C,CAAC"}
|
package/dest/mocks/fixtures.js
CHANGED
|
@@ -4,12 +4,9 @@ import { randomBytes } from '@aztec/foundation/crypto';
|
|
|
4
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
6
6
|
import { fileURLToPath } from '@aztec/foundation/url';
|
|
7
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
8
|
-
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
9
7
|
import { NativeACVMSimulator, WASMSimulatorWithBlobs } from '@aztec/simulator/server';
|
|
10
8
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
9
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
12
|
-
import { CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
13
10
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
14
11
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
15
12
|
import { promises as fs } from 'fs';
|
|
@@ -18,7 +15,7 @@ const { BB_RELEASE_DIR = 'cpp/build/bin', TEMP_DIR = '/tmp', BB_BINARY_PATH = ''
|
|
|
18
15
|
// Determines if we have access to the bb binary and a tmp folder for temp files
|
|
19
16
|
export const getEnvironmentConfig = async (logger)=>{
|
|
20
17
|
try {
|
|
21
|
-
const expectedBBPath = BB_BINARY_PATH ? BB_BINARY_PATH : `${path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../barretenberg/', BB_RELEASE_DIR)}/bb
|
|
18
|
+
const expectedBBPath = BB_BINARY_PATH ? BB_BINARY_PATH : `${path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../barretenberg/', BB_RELEASE_DIR)}/bb`;
|
|
22
19
|
await fs.access(expectedBBPath, fs.constants.R_OK);
|
|
23
20
|
const tempWorkingDirectory = `${TEMP_DIR}/${randomBytes(4).toString('hex')}`;
|
|
24
21
|
const bbWorkingDirectory = BB_WORKING_DIRECTORY ? BB_WORKING_DIRECTORY : `${tempWorkingDirectory}/bb`;
|
|
@@ -75,31 +72,6 @@ export const updateExpectedTreesFromTxs = async (db, txs)=>{
|
|
|
75
72
|
await db.sequentialInsert(MerkleTreeId.PUBLIC_DATA_TREE, tx.txEffect.publicDataWrites.map((write)=>write.toBuffer()));
|
|
76
73
|
}
|
|
77
74
|
};
|
|
78
|
-
export const makeGlobals = (blockNumber
|
|
79
|
-
|
|
80
|
-
return GlobalVariables.from({
|
|
81
|
-
chainId: checkpointConstants.chainId,
|
|
82
|
-
version: checkpointConstants.version,
|
|
83
|
-
blockNumber,
|
|
84
|
-
slotNumber: new Fr(slotNumber),
|
|
85
|
-
timestamp: BigInt(blockNumber),
|
|
86
|
-
coinbase: checkpointConstants.coinbase,
|
|
87
|
-
feeRecipient: checkpointConstants.feeRecipient,
|
|
88
|
-
gasFees: checkpointConstants.gasFees,
|
|
89
|
-
...overrides
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
export const makeCheckpointConstants = (slotNumber, overrides = {})=>{
|
|
93
|
-
return CheckpointConstantData.from({
|
|
94
|
-
chainId: Fr.ZERO,
|
|
95
|
-
version: Fr.ZERO,
|
|
96
|
-
vkTreeRoot: getVKTreeRoot(),
|
|
97
|
-
protocolContractsHash,
|
|
98
|
-
proverId: Fr.ZERO,
|
|
99
|
-
slotNumber: new Fr(slotNumber),
|
|
100
|
-
coinbase: EthAddress.ZERO,
|
|
101
|
-
feeRecipient: AztecAddress.ZERO,
|
|
102
|
-
gasFees: GasFees.empty(),
|
|
103
|
-
...overrides
|
|
104
|
-
});
|
|
75
|
+
export const makeGlobals = (blockNumber)=>{
|
|
76
|
+
return new GlobalVariables(Fr.ZERO, Fr.ZERO, blockNumber /** block number */ , new Fr(blockNumber), BigInt(blockNumber), EthAddress.ZERO, AztecAddress.ZERO, GasFees.empty());
|
|
105
77
|
};
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import type { BBProverConfig } from '@aztec/bb-prover';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
4
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
5
4
|
import { SimpleContractDataSource } from '@aztec/simulator/public/fixtures';
|
|
6
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
import { type L2Block } from '@aztec/stdlib/block';
|
|
7
7
|
import type { ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
|
|
8
|
-
import type { CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
9
8
|
import { makeBloatedProcessedTx } from '@aztec/stdlib/testing';
|
|
9
|
+
import { type AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
10
10
|
import { type BlockHeader, type GlobalVariables, type ProcessedTx, type Tx } from '@aztec/stdlib/tx';
|
|
11
11
|
import type { MerkleTreeAdminDatabase } from '@aztec/world-state';
|
|
12
|
-
import type { BlockProvingState } from '../orchestrator/block-proving-state.js';
|
|
13
12
|
import { ProvingOrchestrator } from '../orchestrator/index.js';
|
|
14
13
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
15
14
|
import { TestBroker } from '../test/mock_prover.js';
|
|
16
15
|
export declare class TestContext {
|
|
17
16
|
worldState: MerkleTreeAdminDatabase;
|
|
18
|
-
firstCheckpointNumber: Fr;
|
|
19
17
|
globalVariables: GlobalVariables;
|
|
20
18
|
prover: ServerCircuitProver;
|
|
21
19
|
broker: TestBroker;
|
|
@@ -27,47 +25,26 @@ export declare class TestContext {
|
|
|
27
25
|
logger: Logger;
|
|
28
26
|
private headers;
|
|
29
27
|
private feePayerBalance;
|
|
30
|
-
constructor(worldState: MerkleTreeAdminDatabase,
|
|
28
|
+
constructor(worldState: MerkleTreeAdminDatabase, globalVariables: GlobalVariables, prover: ServerCircuitProver, broker: TestBroker, brokerProverFacade: BrokerCircuitProverFacade, orchestrator: TestProvingOrchestrator, blockNumber: number, feePayer: AztecAddress, initialFeePayerBalance: Fr, directoriesToCleanup: string[], logger: Logger);
|
|
31
29
|
get epochProver(): TestProvingOrchestrator;
|
|
32
|
-
|
|
33
|
-
static new(logger: Logger, { proverCount, createProver, slotNumber, blockNumber, }?: {
|
|
30
|
+
static new(logger: Logger, { proverCount, createProver, blockNumber, }?: {
|
|
34
31
|
proverCount?: number;
|
|
35
32
|
createProver?: (bbConfig: BBProverConfig) => Promise<ServerCircuitProver>;
|
|
36
|
-
slotNumber?: number;
|
|
37
33
|
blockNumber?: number;
|
|
38
34
|
}): Promise<TestContext>;
|
|
39
35
|
getFork(): Promise<import("@aztec/stdlib/trees").MerkleTreeWriteOperations>;
|
|
40
36
|
getBlockHeader(blockNumber: 0): BlockHeader;
|
|
41
37
|
getBlockHeader(blockNumber: number): BlockHeader | undefined;
|
|
38
|
+
setBlockHeader(header: BlockHeader, blockNumber: number): void;
|
|
42
39
|
getPreviousBlockHeader(currentBlockNumber?: number): BlockHeader;
|
|
43
40
|
cleanup(): Promise<void>;
|
|
44
|
-
makeProcessedTx
|
|
41
|
+
private makeProcessedTx;
|
|
45
42
|
/** Creates a block with the given number of txs and adds it to world-state */
|
|
46
|
-
makePendingBlock(numTxs: number,
|
|
47
|
-
|
|
48
|
-
numL1ToL2Messages?: number;
|
|
49
|
-
blockNumber?: number;
|
|
50
|
-
makeProcessedTxOpts?: (index: number) => Partial<Parameters<typeof makeBloatedProcessedTx>[0]>;
|
|
51
|
-
}): Promise<{
|
|
52
|
-
block: import("@aztec/stdlib/block").L2Block;
|
|
43
|
+
makePendingBlock(numTxs: number, numL1ToL2Messages?: number, blockNumOrGlobals?: GlobalVariables | number, makeProcessedTxOpts?: (index: number) => Partial<Parameters<typeof makeBloatedProcessedTx>[0]>): Promise<{
|
|
44
|
+
block: L2Block;
|
|
53
45
|
txs: ProcessedTx[];
|
|
54
46
|
l1ToL2Messages: Fr[];
|
|
55
47
|
}>;
|
|
56
|
-
makePendingBlocksInCheckpoint(numBlocks: number, { checkpointIndex, numTxsPerBlock, numL1ToL2Messages, firstBlockNumber, makeGlobalVariablesOpts, makeProcessedTxOpts, }?: {
|
|
57
|
-
checkpointIndex?: number;
|
|
58
|
-
numTxsPerBlock?: number | number[];
|
|
59
|
-
numL1ToL2Messages?: number;
|
|
60
|
-
firstBlockNumber?: number;
|
|
61
|
-
makeGlobalVariablesOpts?: (blockNumber: number, checkpointIndex: number) => Partial<FieldsOf<GlobalVariables> & FieldsOf<CheckpointConstantData>>;
|
|
62
|
-
makeProcessedTxOpts?: (blockGlobalVariables: GlobalVariables, txIndex: number) => Partial<Parameters<typeof makeBloatedProcessedTx>[0]>;
|
|
63
|
-
}): Promise<{
|
|
64
|
-
blocks: {
|
|
65
|
-
header: BlockHeader;
|
|
66
|
-
txs: ProcessedTx[];
|
|
67
|
-
}[];
|
|
68
|
-
l1ToL2Messages: Fr[];
|
|
69
|
-
blobFields: Fr[];
|
|
70
|
-
}>;
|
|
71
48
|
processPublicFunctions(txs: Tx[], { maxTransactions, numL1ToL2Messages, contractDataSource, }?: {
|
|
72
49
|
maxTransactions?: number;
|
|
73
50
|
numL1ToL2Messages?: number;
|
|
@@ -77,7 +54,7 @@ export declare class TestContext {
|
|
|
77
54
|
}
|
|
78
55
|
declare class TestProvingOrchestrator extends ProvingOrchestrator {
|
|
79
56
|
isVerifyBuiltBlockAgainstSyncedStateEnabled: boolean;
|
|
80
|
-
protected verifyBuiltBlockAgainstSyncedState(
|
|
57
|
+
protected verifyBuiltBlockAgainstSyncedState(l2Block: L2Block, newArchive: AppendOnlyTreeSnapshot): Promise<void>;
|
|
81
58
|
}
|
|
82
59
|
export {};
|
|
83
60
|
//# sourceMappingURL=test_context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_context.d.ts","sourceRoot":"","sources":["../../src/mocks/test_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"test_context.d.ts","sourceRoot":"","sources":["../../src/mocks/test_context.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
import { TestCircuitProver } from '@aztec/bb-prover';
|
|
2
|
-
import { SpongeBlob } from '@aztec/blob-lib';
|
|
3
1
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
4
2
|
import { padArrayEnd, times, timesParallel } from '@aztec/foundation/collection';
|
|
5
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
6
4
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
7
5
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
8
|
-
import {
|
|
6
|
+
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
9
7
|
import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
10
8
|
import { SimpleContractDataSource } from '@aztec/simulator/public/fixtures';
|
|
11
9
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
12
10
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
13
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
12
|
import { EthAddress } from '@aztec/stdlib/block';
|
|
15
|
-
import { getCheckpointBlobFields } from '@aztec/stdlib/checkpoint';
|
|
16
13
|
import { makeBloatedProcessedTx } from '@aztec/stdlib/testing';
|
|
17
14
|
import { MerkleTreeId, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
18
15
|
import { TreeSnapshots } from '@aztec/stdlib/tx';
|
|
19
16
|
import { NativeWorldStateService } from '@aztec/world-state/native';
|
|
20
17
|
import { promises as fs } from 'fs';
|
|
18
|
+
// TODO(#12613) This means of sharing test code is not ideal.
|
|
19
|
+
// eslint-disable-next-line import/no-relative-packages
|
|
20
|
+
import { TestCircuitProver } from '../../../bb-prover/src/test/test_circuit_prover.js';
|
|
21
21
|
import { buildBlockWithCleanDB } from '../block-factory/light.js';
|
|
22
22
|
import { getTreeSnapshot } from '../orchestrator/block-building-helpers.js';
|
|
23
23
|
import { ProvingOrchestrator } from '../orchestrator/index.js';
|
|
24
24
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
25
25
|
import { TestBroker } from '../test/mock_prover.js';
|
|
26
|
-
import { getEnvironmentConfig, getSimulator,
|
|
26
|
+
import { getEnvironmentConfig, getSimulator, makeGlobals, updateExpectedTreesFromTxs } from './fixtures.js';
|
|
27
27
|
export class TestContext {
|
|
28
28
|
worldState;
|
|
29
|
-
firstCheckpointNumber;
|
|
30
29
|
globalVariables;
|
|
31
30
|
prover;
|
|
32
31
|
broker;
|
|
@@ -38,9 +37,8 @@ export class TestContext {
|
|
|
38
37
|
logger;
|
|
39
38
|
headers;
|
|
40
39
|
feePayerBalance;
|
|
41
|
-
constructor(worldState,
|
|
40
|
+
constructor(worldState, globalVariables, prover, broker, brokerProverFacade, orchestrator, blockNumber, feePayer, initialFeePayerBalance, directoriesToCleanup, logger){
|
|
42
41
|
this.worldState = worldState;
|
|
43
|
-
this.firstCheckpointNumber = firstCheckpointNumber;
|
|
44
42
|
this.globalVariables = globalVariables;
|
|
45
43
|
this.prover = prover;
|
|
46
44
|
this.broker = broker;
|
|
@@ -56,13 +54,9 @@ export class TestContext {
|
|
|
56
54
|
get epochProver() {
|
|
57
55
|
return this.orchestrator;
|
|
58
56
|
}
|
|
59
|
-
|
|
60
|
-
return makeCheckpointConstants(this.firstCheckpointNumber.toNumber() + checkpointIndex);
|
|
61
|
-
}
|
|
62
|
-
static async new(logger, { proverCount = 4, createProver = async (bbConfig)=>new TestCircuitProver(await getSimulator(bbConfig, logger)), slotNumber = 1, blockNumber = 1 } = {}) {
|
|
57
|
+
static async new(logger, { proverCount = 4, createProver = async (bbConfig)=>new TestCircuitProver(await getSimulator(bbConfig, logger)), blockNumber = 1 } = {}) {
|
|
63
58
|
const directoriesToCleanup = [];
|
|
64
|
-
const
|
|
65
|
-
const globalVariables = makeGlobals(blockNumber, slotNumber);
|
|
59
|
+
const globalVariables = makeGlobals(blockNumber);
|
|
66
60
|
const feePayer = AztecAddress.fromNumber(42222);
|
|
67
61
|
const initialFeePayerBalance = new Fr(10n ** 20n);
|
|
68
62
|
const feePayerSlot = await computeFeePayerBalanceLeafSlot(feePayer);
|
|
@@ -95,7 +89,7 @@ export class TestContext {
|
|
|
95
89
|
const orchestrator = new TestProvingOrchestrator(ws, facade, EthAddress.ZERO);
|
|
96
90
|
await broker.start();
|
|
97
91
|
facade.start();
|
|
98
|
-
return new this(ws,
|
|
92
|
+
return new this(ws, globalVariables, localProver, broker, facade, orchestrator, blockNumber, feePayer, initialFeePayerBalance, directoriesToCleanup, logger);
|
|
99
93
|
}
|
|
100
94
|
getFork() {
|
|
101
95
|
return this.worldState.fork();
|
|
@@ -103,6 +97,9 @@ export class TestContext {
|
|
|
103
97
|
getBlockHeader(blockNumber = 0) {
|
|
104
98
|
return blockNumber === 0 ? this.worldState.getCommitted().getInitialHeader() : this.headers.get(blockNumber);
|
|
105
99
|
}
|
|
100
|
+
setBlockHeader(header, blockNumber) {
|
|
101
|
+
this.headers.set(blockNumber, header);
|
|
102
|
+
}
|
|
106
103
|
getPreviousBlockHeader(currentBlockNumber = this.blockNumber) {
|
|
107
104
|
return this.getBlockHeader(currentBlockNumber - 1);
|
|
108
105
|
}
|
|
@@ -122,14 +119,13 @@ export class TestContext {
|
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
121
|
async makeProcessedTx(opts) {
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
const header = opts?.header ?? this.getBlockHeader(blockNumber - 1);
|
|
122
|
+
const blockNum = (opts?.globalVariables ?? this.globalVariables).blockNumber;
|
|
123
|
+
const header = this.getBlockHeader(blockNum - 1);
|
|
128
124
|
const tx = await makeBloatedProcessedTx({
|
|
129
125
|
header,
|
|
130
126
|
vkTreeRoot: getVKTreeRoot(),
|
|
131
|
-
|
|
132
|
-
globalVariables,
|
|
127
|
+
protocolContractTreeRoot,
|
|
128
|
+
globalVariables: this.globalVariables,
|
|
133
129
|
feePayer: this.feePayer,
|
|
134
130
|
...opts
|
|
135
131
|
});
|
|
@@ -140,9 +136,8 @@ export class TestContext {
|
|
|
140
136
|
}
|
|
141
137
|
return tx;
|
|
142
138
|
}
|
|
143
|
-
/** Creates a block with the given number of txs and adds it to world-state */ async makePendingBlock(numTxs,
|
|
144
|
-
const
|
|
145
|
-
const globalVariables = makeGlobals(blockNumber, slotNumber);
|
|
139
|
+
/** Creates a block with the given number of txs and adds it to world-state */ async makePendingBlock(numTxs, numL1ToL2Messages = 0, blockNumOrGlobals = this.globalVariables, makeProcessedTxOpts = ()=>({})) {
|
|
140
|
+
const globalVariables = typeof blockNumOrGlobals === 'number' ? makeGlobals(blockNumOrGlobals) : blockNumOrGlobals;
|
|
146
141
|
const blockNum = globalVariables.blockNumber;
|
|
147
142
|
const db = await this.worldState.fork();
|
|
148
143
|
const l1ToL2Messages = times(numL1ToL2Messages, (i)=>new Fr(blockNum * 100 + i));
|
|
@@ -157,7 +152,7 @@ export class TestContext {
|
|
|
157
152
|
}));
|
|
158
153
|
await this.setTreeRoots(txs);
|
|
159
154
|
const block = await buildBlockWithCleanDB(txs, globalVariables, l1ToL2Messages, db);
|
|
160
|
-
this.headers.set(blockNum, block.
|
|
155
|
+
this.headers.set(blockNum, block.header);
|
|
161
156
|
await this.worldState.handleL2BlockAndMessages(block, l1ToL2Messages);
|
|
162
157
|
return {
|
|
163
158
|
block,
|
|
@@ -165,63 +160,12 @@ export class TestContext {
|
|
|
165
160
|
l1ToL2Messages
|
|
166
161
|
};
|
|
167
162
|
}
|
|
168
|
-
async makePendingBlocksInCheckpoint(numBlocks, { checkpointIndex = 0, numTxsPerBlock = 1, numL1ToL2Messages = 0, firstBlockNumber = this.blockNumber + checkpointIndex * numBlocks, makeGlobalVariablesOpts = ()=>({}), makeProcessedTxOpts = ()=>({}) } = {}) {
|
|
169
|
-
const slotNumber = this.firstCheckpointNumber.toNumber() + checkpointIndex;
|
|
170
|
-
const l1ToL2Messages = times(numL1ToL2Messages, (i)=>new Fr(slotNumber * 100 + i));
|
|
171
|
-
const merkleTrees = await this.worldState.fork();
|
|
172
|
-
await merkleTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP));
|
|
173
|
-
const newL1ToL2Snapshot = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, merkleTrees);
|
|
174
|
-
const blockGlobalVariables = times(numBlocks, (i)=>makeGlobals(firstBlockNumber + i, slotNumber, makeGlobalVariablesOpts(firstBlockNumber + i, checkpointIndex)));
|
|
175
|
-
let totalTxs = 0;
|
|
176
|
-
const blockTxs = await timesParallel(numBlocks, (blockIndex)=>{
|
|
177
|
-
const txIndexOffset = totalTxs;
|
|
178
|
-
const numTxs = typeof numTxsPerBlock === 'number' ? numTxsPerBlock : numTxsPerBlock[blockIndex];
|
|
179
|
-
totalTxs += numTxs;
|
|
180
|
-
return timesParallel(numTxs, (txIndex)=>this.makeProcessedTx({
|
|
181
|
-
seed: (txIndexOffset + txIndex + 1) * 321 + (checkpointIndex + 1) * 123456,
|
|
182
|
-
globalVariables: blockGlobalVariables[blockIndex],
|
|
183
|
-
header: this.getBlockHeader(firstBlockNumber - 1),
|
|
184
|
-
newL1ToL2Snapshot,
|
|
185
|
-
...makeProcessedTxOpts(blockGlobalVariables[blockIndex], txIndexOffset + txIndex)
|
|
186
|
-
}));
|
|
187
|
-
});
|
|
188
|
-
const blobFields = getCheckpointBlobFields(blockTxs.map((txs)=>txs.map((tx)=>tx.txEffect)));
|
|
189
|
-
const spongeBlobState = await SpongeBlob.init(blobFields.length);
|
|
190
|
-
const blocks = [];
|
|
191
|
-
for(let i = 0; i < numBlocks; i++){
|
|
192
|
-
const isFirstBlock = i === 0;
|
|
193
|
-
const blockNumber = firstBlockNumber + i;
|
|
194
|
-
const globalVariables = blockGlobalVariables[i];
|
|
195
|
-
const txs = blockTxs[i];
|
|
196
|
-
await this.setTreeRoots(txs);
|
|
197
|
-
const fork = await this.worldState.fork();
|
|
198
|
-
const blockMsgs = isFirstBlock ? l1ToL2Messages : [];
|
|
199
|
-
const block = await buildBlockWithCleanDB(txs, globalVariables, blockMsgs, fork, spongeBlobState, isFirstBlock);
|
|
200
|
-
const header = block.getBlockHeader();
|
|
201
|
-
this.headers.set(blockNumber, header);
|
|
202
|
-
await this.worldState.handleL2BlockAndMessages(block, blockMsgs, isFirstBlock);
|
|
203
|
-
const blockBlobFields = block.body.toBlobFields();
|
|
204
|
-
await spongeBlobState.absorb(blockBlobFields);
|
|
205
|
-
blocks.push({
|
|
206
|
-
header,
|
|
207
|
-
txs
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
return {
|
|
211
|
-
blocks,
|
|
212
|
-
l1ToL2Messages,
|
|
213
|
-
blobFields
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
163
|
async processPublicFunctions(txs, { maxTransactions = txs.length, numL1ToL2Messages = 0, contractDataSource } = {}) {
|
|
217
164
|
const l1ToL2Messages = times(numL1ToL2Messages, (i)=>new Fr(this.blockNumber * 100 + i));
|
|
218
165
|
const merkleTrees = await this.worldState.fork();
|
|
219
166
|
await merkleTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP));
|
|
220
167
|
const processorFactory = new PublicProcessorFactory(contractDataSource ?? new SimpleContractDataSource(), new TestDateProvider());
|
|
221
|
-
const publicProcessor = processorFactory.create(merkleTrees, this.globalVariables,
|
|
222
|
-
skipFeeEnforcement: false,
|
|
223
|
-
clientInitiatedSimulation: false
|
|
224
|
-
});
|
|
168
|
+
const publicProcessor = processorFactory.create(merkleTrees, this.globalVariables, /*skipFeeEnforcement=*/ false);
|
|
225
169
|
return await publicProcessor.process(txs, {
|
|
226
170
|
maxTransactions
|
|
227
171
|
});
|
|
@@ -246,9 +190,9 @@ class TestProvingOrchestrator extends ProvingOrchestrator {
|
|
|
246
190
|
isVerifyBuiltBlockAgainstSyncedStateEnabled = false;
|
|
247
191
|
// Disable this check by default, since it requires seeding world state with the block being built
|
|
248
192
|
// This is only enabled in some tests with multiple blocks that populate the pending chain via makePendingBlock
|
|
249
|
-
verifyBuiltBlockAgainstSyncedState(
|
|
193
|
+
verifyBuiltBlockAgainstSyncedState(l2Block, newArchive) {
|
|
250
194
|
if (this.isVerifyBuiltBlockAgainstSyncedStateEnabled) {
|
|
251
|
-
return super.verifyBuiltBlockAgainstSyncedState(
|
|
195
|
+
return super.verifyBuiltBlockAgainstSyncedState(l2Block, newArchive);
|
|
252
196
|
}
|
|
253
197
|
return Promise.resolve();
|
|
254
198
|
}
|