@aztec/prover-client 0.0.0-test.1 → 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.js +1 -1
- 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 +36 -0
- package/dest/block-factory/light.d.ts.map +1 -0
- package/dest/{block_builder → block-factory}/light.js +35 -30
- 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 +3 -3
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +2 -2
- package/dest/mocks/test_context.d.ts +18 -13
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +44 -38
- package/dest/orchestrator/block-building-helpers.d.ts +18 -11
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +80 -63
- package/dest/orchestrator/block-proving-state.d.ts +19 -10
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +63 -46
- package/dest/orchestrator/epoch-proving-state.d.ts +13 -6
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +40 -14
- package/dest/orchestrator/orchestrator.d.ts +7 -5
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +78 -52
- 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 +2 -2
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +9 -20
- 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 +6 -4
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +4 -4
- package/dest/proving_broker/broker_prover_facade.d.ts +5 -3
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +31 -21
- 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/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/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 +6 -5
- 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 +53 -45
- 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 +7 -5
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +6 -3
- package/package.json +28 -27
- package/src/bin/get-proof-inputs.ts +1 -1
- package/src/block-factory/index.ts +1 -0
- package/src/{block_builder → block-factory}/light.ts +42 -29
- package/src/config.ts +24 -8
- package/src/mocks/fixtures.ts +5 -5
- package/src/mocks/test_context.ts +79 -59
- package/src/orchestrator/block-building-helpers.ts +96 -92
- package/src/orchestrator/block-proving-state.ts +78 -52
- package/src/orchestrator/epoch-proving-state.ts +51 -20
- package/src/orchestrator/orchestrator.ts +119 -60
- package/src/orchestrator/orchestrator_metrics.ts +20 -1
- package/src/orchestrator/tx-proving-state.ts +17 -24
- package/src/prover-client/prover-client.ts +16 -14
- package/src/prover-client/server-epoch-prover.ts +16 -7
- package/src/proving_broker/broker_prover_facade.ts +52 -36
- package/src/proving_broker/config.ts +17 -6
- package/src/proving_broker/factory.ts +2 -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/inline_proof_store.ts +1 -1
- package/src/proving_broker/proving_agent.ts +89 -47
- package/src/proving_broker/proving_broker.ts +16 -15
- 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 +56 -65
- package/src/proving_broker/rpc.ts +1 -6
- package/src/test/mock_proof_store.ts +14 -0
- package/src/test/mock_prover.ts +27 -5
- 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/src/block_builder/index.ts +0 -6
- /package/dest/{block_builder → block-factory}/index.js +0 -0
|
@@ -28,7 +28,7 @@ async function main() {
|
|
|
28
28
|
const input = await proofStore.getProofInput(uri);
|
|
29
29
|
logger.info(`Found inputs for ${ProvingRequestType[input.type]}`);
|
|
30
30
|
writeProofInputs(input, outDir);
|
|
31
|
-
console.log(
|
|
31
|
+
console.log(jsonParseWithSchema(jsonStringify(input), ProvingJobInputs).inputs);
|
|
32
32
|
}
|
|
33
33
|
// This mimics the behavior of bb-prover/src/bb/execute.ts
|
|
34
34
|
function writeProofInputs(input, outDir) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/block-factory/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
3
|
+
import type { IBlockFactory, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import { type GlobalVariables, type ProcessedTx } from '@aztec/stdlib/tx';
|
|
5
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
6
|
+
/**
|
|
7
|
+
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
8
|
+
*
|
|
9
|
+
* NOTE: the onus is ON THE CALLER to update the db that is passed in with the notes hashes, nullifiers, etc
|
|
10
|
+
* PRIOR to calling `buildBlock`.
|
|
11
|
+
*
|
|
12
|
+
* Why? Because if you are, e.g. building a block in practice from TxObjects, you are using the
|
|
13
|
+
* PublicProcessor which will do this for you as it processes transactions.
|
|
14
|
+
*
|
|
15
|
+
* If you haven't already inserted the side effects, e.g. because you are in a testing context, you can use the helper
|
|
16
|
+
* function `buildBlockWithCleanDB`, which calls `insertSideEffectsAndBuildBaseRollupHints` for you.
|
|
17
|
+
*/
|
|
18
|
+
export declare class LightweightBlockFactory implements IBlockFactory {
|
|
19
|
+
private db;
|
|
20
|
+
private telemetry;
|
|
21
|
+
private globalVariables?;
|
|
22
|
+
private l1ToL2Messages?;
|
|
23
|
+
private txs;
|
|
24
|
+
private readonly logger;
|
|
25
|
+
constructor(db: MerkleTreeWriteOperations, telemetry?: TelemetryClient);
|
|
26
|
+
startNewBlock(globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void>;
|
|
27
|
+
addTxs(txs: ProcessedTx[]): Promise<void>;
|
|
28
|
+
setBlockCompleted(): Promise<L2Block>;
|
|
29
|
+
private buildBlock;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Inserts the processed transactions into the DB, then creates a block.
|
|
33
|
+
* @param db - A db fork to use for block building which WILL BE MODIFIED.
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildBlockWithCleanDB(txs: ProcessedTx[], globalVariables: GlobalVariables, l1ToL2Messages: Fr[], db: MerkleTreeWriteOperations, telemetry?: TelemetryClient): Promise<L2Block>;
|
|
36
|
+
//# sourceMappingURL=light.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -7,13 +7,21 @@ import { L2Block } from '@aztec/stdlib/block';
|
|
|
7
7
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
8
8
|
import { toNumBlobFields } from '@aztec/stdlib/tx';
|
|
9
9
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
10
|
-
import {
|
|
10
|
+
import { buildHeaderAndBodyFromTxs, getTreeSnapshot, insertSideEffectsAndBuildBaseRollupHints } from '../orchestrator/block-building-helpers.js';
|
|
11
11
|
/**
|
|
12
12
|
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
13
|
-
|
|
13
|
+
*
|
|
14
|
+
* NOTE: the onus is ON THE CALLER to update the db that is passed in with the notes hashes, nullifiers, etc
|
|
15
|
+
* PRIOR to calling `buildBlock`.
|
|
16
|
+
*
|
|
17
|
+
* Why? Because if you are, e.g. building a block in practice from TxObjects, you are using the
|
|
18
|
+
* PublicProcessor which will do this for you as it processes transactions.
|
|
19
|
+
*
|
|
20
|
+
* If you haven't already inserted the side effects, e.g. because you are in a testing context, you can use the helper
|
|
21
|
+
* function `buildBlockWithCleanDB`, which calls `insertSideEffectsAndBuildBaseRollupHints` for you.
|
|
22
|
+
*/ export class LightweightBlockFactory {
|
|
14
23
|
db;
|
|
15
24
|
telemetry;
|
|
16
|
-
spongeBlobState;
|
|
17
25
|
globalVariables;
|
|
18
26
|
l1ToL2Messages;
|
|
19
27
|
txs;
|
|
@@ -21,8 +29,7 @@ import { buildBaseRollupHints, buildHeaderAndBodyFromTxs, getTreeSnapshot } from
|
|
|
21
29
|
constructor(db, telemetry = getTelemetryClient()){
|
|
22
30
|
this.db = db;
|
|
23
31
|
this.telemetry = telemetry;
|
|
24
|
-
this.
|
|
25
|
-
this.logger = createLogger('prover-client:block_builder');
|
|
32
|
+
this.logger = createLogger('lightweight-block-factory');
|
|
26
33
|
}
|
|
27
34
|
async startNewBlock(globalVariables, l1ToL2Messages) {
|
|
28
35
|
this.logger.debug('Starting new block', {
|
|
@@ -31,52 +38,50 @@ import { buildBaseRollupHints, buildHeaderAndBodyFromTxs, getTreeSnapshot } from
|
|
|
31
38
|
});
|
|
32
39
|
this.globalVariables = globalVariables;
|
|
33
40
|
this.l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
34
|
-
this.txs =
|
|
35
|
-
this.spongeBlobState = undefined;
|
|
41
|
+
this.txs = undefined;
|
|
36
42
|
// Update L1 to L2 tree
|
|
37
43
|
await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages);
|
|
38
44
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this.txs.push(
|
|
46
|
-
await buildBaseRollupHints(tx, this.globalVariables, this.db, this.spongeBlobState);
|
|
45
|
+
addTxs(txs) {
|
|
46
|
+
// Most times, `addTxs` is only called once per block.
|
|
47
|
+
// So avoid copies.
|
|
48
|
+
if (this.txs === undefined) {
|
|
49
|
+
this.txs = txs;
|
|
50
|
+
} else {
|
|
51
|
+
this.txs.push(...txs);
|
|
47
52
|
}
|
|
53
|
+
return Promise.resolve();
|
|
48
54
|
}
|
|
49
55
|
setBlockCompleted() {
|
|
50
56
|
return this.buildBlock();
|
|
51
57
|
}
|
|
52
58
|
async buildBlock() {
|
|
53
|
-
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);
|
|
60
|
+
header.state.validate();
|
|
54
61
|
await this.db.updateArchive(header);
|
|
55
62
|
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
56
63
|
const block = new L2Block(newArchive, header, body);
|
|
57
64
|
this.logger.debug(`Built block ${block.number}`, {
|
|
58
65
|
globalVariables: this.globalVariables?.toInspect(),
|
|
59
66
|
archiveRoot: newArchive.root.toString(),
|
|
60
|
-
|
|
67
|
+
stateReference: header.state.toInspect(),
|
|
68
|
+
blockHash: (await block.hash()).toString(),
|
|
69
|
+
txs: block.body.txEffects.map((tx)=>tx.txHash.toString())
|
|
61
70
|
});
|
|
62
71
|
return block;
|
|
63
72
|
}
|
|
64
73
|
}
|
|
65
|
-
export class LightweightBlockBuilderFactory {
|
|
66
|
-
telemetry;
|
|
67
|
-
constructor(telemetry = getTelemetryClient()){
|
|
68
|
-
this.telemetry = telemetry;
|
|
69
|
-
}
|
|
70
|
-
create(db) {
|
|
71
|
-
return new LightweightBlockBuilder(db, this.telemetry);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
76
|
-
* @param db - A db fork to use for block building.
|
|
77
|
-
*/ export async function
|
|
78
|
-
const
|
|
75
|
+
* Inserts the processed transactions into the DB, then creates a block.
|
|
76
|
+
* @param db - A db fork to use for block building which WILL BE MODIFIED.
|
|
77
|
+
*/ export async function buildBlockWithCleanDB(txs, globalVariables, l1ToL2Messages, db, telemetry = getTelemetryClient()) {
|
|
78
|
+
const spongeBlobState = SpongeBlob.init(toNumBlobFields(txs));
|
|
79
|
+
const builder = new LightweightBlockFactory(db, telemetry);
|
|
79
80
|
await builder.startNewBlock(globalVariables, l1ToL2Messages);
|
|
81
|
+
const l1ToL2MessageTree = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, db);
|
|
82
|
+
for (const tx of txs){
|
|
83
|
+
await insertSideEffectsAndBuildBaseRollupHints(tx, globalVariables, l1ToL2MessageTree, db, spongeBlobState);
|
|
84
|
+
}
|
|
80
85
|
await builder.addTxs(txs);
|
|
81
86
|
return await builder.setBlockCompleted();
|
|
82
87
|
}
|
package/dest/config.d.ts
CHANGED
|
@@ -2,16 +2,16 @@ import type { ACVMConfig, BBConfig } from '@aztec/bb-prover';
|
|
|
2
2
|
import { type ConfigMappingsType } from '@aztec/foundation/config';
|
|
3
3
|
import { type ProverConfig } from '@aztec/stdlib/interfaces/server';
|
|
4
4
|
import { type ProverAgentConfig, type ProverBrokerConfig } from './proving_broker/config.js';
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
export type ProverClientConfig =
|
|
5
|
+
/** The prover configuration as defined by the user. */
|
|
6
|
+
export type ProverClientUserConfig = ProverConfig & ProverAgentConfig & ProverBrokerConfig & BBConfig & ACVMConfig;
|
|
7
|
+
/** The prover configuration with all missing fields resolved. */
|
|
8
|
+
export type ProverClientConfig = ProverClientUserConfig & Required<Pick<ProverClientUserConfig, 'proverId'>>;
|
|
9
9
|
export declare const bbConfigMappings: ConfigMappingsType<BBConfig & ACVMConfig>;
|
|
10
|
-
export declare const proverClientConfigMappings: ConfigMappingsType<
|
|
10
|
+
export declare const proverClientConfigMappings: ConfigMappingsType<ProverClientUserConfig>;
|
|
11
11
|
/**
|
|
12
12
|
* Returns the prover configuration from the environment variables.
|
|
13
13
|
* Note: If an environment variable is not set, the default value is used.
|
|
14
14
|
* @returns The prover configuration.
|
|
15
15
|
*/
|
|
16
|
-
export declare function getProverEnvVars():
|
|
16
|
+
export declare function getProverEnvVars(): ProverClientUserConfig;
|
|
17
17
|
//# sourceMappingURL=config.d.ts.map
|
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,YAAY,EAAwB,MAAM,iCAAiC,CAAC;AAE1F,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EAGxB,MAAM,4BAA4B,CAAC;AAEpC,uDAAuD;AACvD,MAAM,MAAM,sBAAsB,GAAG,YAAY,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEnH,iEAAiE;AACjE,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG,QAAQ,CAAC,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC,CAAC;AAE7G,eAAO,MAAM,gBAAgB,EAAE,kBAAkB,CAAC,QAAQ,GAAG,UAAU,CAgCtE,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,kBAAkB,CAAC,sBAAsB,CAKjF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAEzD"}
|
package/dest/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
|
|
1
|
+
import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
|
|
2
2
|
import { proverConfigMappings } from '@aztec/stdlib/interfaces/server';
|
|
3
3
|
import { proverAgentConfigMappings, proverBrokerConfigMappings } from './proving_broker/config.js';
|
|
4
4
|
export const bbConfigMappings = {
|
|
@@ -22,6 +22,16 @@ export const bbConfigMappings = {
|
|
|
22
22
|
env: 'BB_SKIP_CLEANUP',
|
|
23
23
|
description: 'Whether to skip cleanup of bb temporary files',
|
|
24
24
|
...booleanConfigHelper(false)
|
|
25
|
+
},
|
|
26
|
+
numConcurrentIVCVerifiers: {
|
|
27
|
+
env: 'BB_NUM_IVC_VERIFIERS',
|
|
28
|
+
description: 'Max number of client IVC verifiers to run concurrently',
|
|
29
|
+
...numberConfigHelper(8)
|
|
30
|
+
},
|
|
31
|
+
bbIVCConcurrency: {
|
|
32
|
+
env: 'BB_IVC_CONCURRENCY',
|
|
33
|
+
description: 'Number of threads to use for IVC verification',
|
|
34
|
+
...numberConfigHelper(1)
|
|
25
35
|
}
|
|
26
36
|
};
|
|
27
37
|
export const proverClientConfigMappings = {
|
package/dest/mocks/fixtures.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
-
import { type
|
|
2
|
+
import { type CircuitSimulator } from '@aztec/simulator/server';
|
|
3
3
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
4
4
|
import type { ProcessedTx } from '@aztec/stdlib/tx';
|
|
5
5
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
@@ -11,10 +11,10 @@ export declare const getEnvironmentConfig: (logger: Logger) => Promise<{
|
|
|
11
11
|
directoryToCleanup: string | undefined;
|
|
12
12
|
bbSkipCleanup: boolean;
|
|
13
13
|
} | undefined>;
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function getSimulator(config: {
|
|
15
15
|
acvmWorkingDirectory: string | undefined;
|
|
16
16
|
acvmBinaryPath: string | undefined;
|
|
17
|
-
}, logger?: Logger): Promise<
|
|
17
|
+
}, logger?: Logger): Promise<CircuitSimulator>;
|
|
18
18
|
export declare const updateExpectedTreesFromTxs: (db: MerkleTreeWriteOperations, txs: ProcessedTx[]) => Promise<void>;
|
|
19
19
|
export declare const makeGlobals: (blockNumber: number) => GlobalVariables;
|
|
20
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;AAEpD,OAAO,
|
|
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
|
@@ -48,7 +48,7 @@ export const getEnvironmentConfig = async (logger)=>{
|
|
|
48
48
|
return undefined;
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
export async function
|
|
51
|
+
export async function getSimulator(config, logger) {
|
|
52
52
|
if (config.acvmBinaryPath && config.acvmWorkingDirectory) {
|
|
53
53
|
try {
|
|
54
54
|
await fs.access(config.acvmBinaryPath, fs.constants.R_OK);
|
|
@@ -73,5 +73,5 @@ export const updateExpectedTreesFromTxs = async (db, txs)=>{
|
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
export const makeGlobals = (blockNumber)=>{
|
|
76
|
-
return new GlobalVariables(Fr.ZERO, Fr.ZERO,
|
|
76
|
+
return new GlobalVariables(Fr.ZERO, Fr.ZERO, blockNumber /** block number */ , new Fr(blockNumber), BigInt(blockNumber), EthAddress.ZERO, AztecAddress.ZERO, GasFees.empty());
|
|
77
77
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
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 {
|
|
4
|
+
import { SimpleContractDataSource } from '@aztec/simulator/public/fixtures';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import type
|
|
6
|
+
import { type L2Block } from '@aztec/stdlib/block';
|
|
7
7
|
import type { ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
|
|
8
8
|
import { makeBloatedProcessedTx } from '@aztec/stdlib/testing';
|
|
9
9
|
import { type AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
@@ -13,9 +13,7 @@ import { ProvingOrchestrator } from '../orchestrator/index.js';
|
|
|
13
13
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
14
14
|
import { TestBroker } from '../test/mock_prover.js';
|
|
15
15
|
export declare class TestContext {
|
|
16
|
-
publicTxSimulator: PublicTxSimulator;
|
|
17
16
|
worldState: MerkleTreeAdminDatabase;
|
|
18
|
-
publicProcessor: PublicProcessor;
|
|
19
17
|
globalVariables: GlobalVariables;
|
|
20
18
|
prover: ServerCircuitProver;
|
|
21
19
|
broker: TestBroker;
|
|
@@ -24,28 +22,35 @@ export declare class TestContext {
|
|
|
24
22
|
blockNumber: number;
|
|
25
23
|
feePayer: AztecAddress;
|
|
26
24
|
directoriesToCleanup: string[];
|
|
27
|
-
tester: PublicTxSimulationTester;
|
|
28
25
|
logger: Logger;
|
|
29
26
|
private headers;
|
|
30
27
|
private feePayerBalance;
|
|
31
|
-
constructor(
|
|
28
|
+
constructor(worldState: MerkleTreeAdminDatabase, globalVariables: GlobalVariables, prover: ServerCircuitProver, broker: TestBroker, brokerProverFacade: BrokerCircuitProverFacade, orchestrator: TestProvingOrchestrator, blockNumber: number, feePayer: AztecAddress, initialFeePayerBalance: Fr, directoriesToCleanup: string[], logger: Logger);
|
|
32
29
|
get epochProver(): TestProvingOrchestrator;
|
|
33
|
-
static new(logger: Logger, proverCount
|
|
30
|
+
static new(logger: Logger, { proverCount, createProver, blockNumber, }?: {
|
|
31
|
+
proverCount?: number;
|
|
32
|
+
createProver?: (bbConfig: BBProverConfig) => Promise<ServerCircuitProver>;
|
|
33
|
+
blockNumber?: number;
|
|
34
|
+
}): Promise<TestContext>;
|
|
34
35
|
getFork(): Promise<import("@aztec/stdlib/trees").MerkleTreeWriteOperations>;
|
|
35
36
|
getBlockHeader(blockNumber: 0): BlockHeader;
|
|
36
37
|
getBlockHeader(blockNumber: number): BlockHeader | undefined;
|
|
38
|
+
setBlockHeader(header: BlockHeader, blockNumber: number): void;
|
|
37
39
|
getPreviousBlockHeader(currentBlockNumber?: number): BlockHeader;
|
|
38
40
|
cleanup(): Promise<void>;
|
|
39
|
-
makeProcessedTx
|
|
40
|
-
makeProcessedTx(seed?: number): Promise<ProcessedTx>;
|
|
41
|
+
private makeProcessedTx;
|
|
41
42
|
/** Creates a block with the given number of txs and adds it to world-state */
|
|
42
|
-
makePendingBlock(numTxs: number,
|
|
43
|
+
makePendingBlock(numTxs: number, numL1ToL2Messages?: number, blockNumOrGlobals?: GlobalVariables | number, makeProcessedTxOpts?: (index: number) => Partial<Parameters<typeof makeBloatedProcessedTx>[0]>): Promise<{
|
|
43
44
|
block: L2Block;
|
|
44
45
|
txs: ProcessedTx[];
|
|
45
|
-
|
|
46
|
+
l1ToL2Messages: Fr[];
|
|
46
47
|
}>;
|
|
47
|
-
processPublicFunctions(txs: Tx[], maxTransactions
|
|
48
|
-
|
|
48
|
+
processPublicFunctions(txs: Tx[], { maxTransactions, numL1ToL2Messages, contractDataSource, }?: {
|
|
49
|
+
maxTransactions?: number;
|
|
50
|
+
numL1ToL2Messages?: number;
|
|
51
|
+
contractDataSource?: SimpleContractDataSource;
|
|
52
|
+
}): Promise<[ProcessedTx[], import("@aztec/stdlib/tx").FailedTx[], Tx[], import("@aztec/stdlib/tx").NestedProcessReturnValues[]]>;
|
|
53
|
+
private setTreeRoots;
|
|
49
54
|
}
|
|
50
55
|
declare class TestProvingOrchestrator extends ProvingOrchestrator {
|
|
51
56
|
isVerifyBuiltBlockAgainstSyncedStateEnabled: boolean;
|
|
@@ -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,27 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
|
+
import { padArrayEnd, times, timesParallel } from '@aztec/foundation/collection';
|
|
2
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
4
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
4
5
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
5
6
|
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
6
7
|
import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
7
|
-
import {
|
|
8
|
+
import { SimpleContractDataSource } from '@aztec/simulator/public/fixtures';
|
|
9
|
+
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
8
10
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
9
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
|
+
import { EthAddress } from '@aztec/stdlib/block';
|
|
10
13
|
import { makeBloatedProcessedTx } from '@aztec/stdlib/testing';
|
|
11
|
-
import { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
14
|
+
import { MerkleTreeId, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
12
15
|
import { TreeSnapshots } from '@aztec/stdlib/tx';
|
|
13
16
|
import { NativeWorldStateService } from '@aztec/world-state/native';
|
|
14
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
|
|
15
20
|
import { TestCircuitProver } from '../../../bb-prover/src/test/test_circuit_prover.js';
|
|
16
|
-
import {
|
|
21
|
+
import { buildBlockWithCleanDB } from '../block-factory/light.js';
|
|
22
|
+
import { getTreeSnapshot } from '../orchestrator/block-building-helpers.js';
|
|
17
23
|
import { ProvingOrchestrator } from '../orchestrator/index.js';
|
|
18
24
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
19
25
|
import { TestBroker } from '../test/mock_prover.js';
|
|
20
|
-
import { getEnvironmentConfig,
|
|
26
|
+
import { getEnvironmentConfig, getSimulator, makeGlobals, updateExpectedTreesFromTxs } from './fixtures.js';
|
|
21
27
|
export class TestContext {
|
|
22
|
-
publicTxSimulator;
|
|
23
28
|
worldState;
|
|
24
|
-
publicProcessor;
|
|
25
29
|
globalVariables;
|
|
26
30
|
prover;
|
|
27
31
|
broker;
|
|
@@ -30,14 +34,11 @@ export class TestContext {
|
|
|
30
34
|
blockNumber;
|
|
31
35
|
feePayer;
|
|
32
36
|
directoriesToCleanup;
|
|
33
|
-
tester;
|
|
34
37
|
logger;
|
|
35
38
|
headers;
|
|
36
39
|
feePayerBalance;
|
|
37
|
-
constructor(
|
|
38
|
-
this.publicTxSimulator = publicTxSimulator;
|
|
40
|
+
constructor(worldState, globalVariables, prover, broker, brokerProverFacade, orchestrator, blockNumber, feePayer, initialFeePayerBalance, directoriesToCleanup, logger){
|
|
39
41
|
this.worldState = worldState;
|
|
40
|
-
this.publicProcessor = publicProcessor;
|
|
41
42
|
this.globalVariables = globalVariables;
|
|
42
43
|
this.prover = prover;
|
|
43
44
|
this.broker = broker;
|
|
@@ -46,7 +47,6 @@ export class TestContext {
|
|
|
46
47
|
this.blockNumber = blockNumber;
|
|
47
48
|
this.feePayer = feePayer;
|
|
48
49
|
this.directoriesToCleanup = directoriesToCleanup;
|
|
49
|
-
this.tester = tester;
|
|
50
50
|
this.logger = logger;
|
|
51
51
|
this.headers = new Map();
|
|
52
52
|
this.feePayerBalance = initialFeePayerBalance;
|
|
@@ -54,7 +54,7 @@ export class TestContext {
|
|
|
54
54
|
get epochProver() {
|
|
55
55
|
return this.orchestrator;
|
|
56
56
|
}
|
|
57
|
-
static async new(logger, proverCount = 4, createProver = async (bbConfig)=>new TestCircuitProver(await
|
|
57
|
+
static async new(logger, { proverCount = 4, createProver = async (bbConfig)=>new TestCircuitProver(await getSimulator(bbConfig, logger)), blockNumber = 1 } = {}) {
|
|
58
58
|
const directoriesToCleanup = [];
|
|
59
59
|
const globalVariables = makeGlobals(blockNumber);
|
|
60
60
|
const feePayer = AztecAddress.fromNumber(42222);
|
|
@@ -64,13 +64,7 @@ export class TestContext {
|
|
|
64
64
|
new PublicDataTreeLeaf(feePayerSlot, initialFeePayerBalance)
|
|
65
65
|
];
|
|
66
66
|
// Separated dbs for public processor and prover - see public_processor for context
|
|
67
|
-
const ws = await NativeWorldStateService.tmp(
|
|
68
|
-
const publicDb = await ws.fork();
|
|
69
|
-
const contractDataSource = new SimpleContractDataSource();
|
|
70
|
-
const worldStateDB = new WorldStateDB(publicDb, contractDataSource);
|
|
71
|
-
const tester = new PublicTxSimulationTester(worldStateDB, contractDataSource, publicDb);
|
|
72
|
-
const publicTxSimulator = new PublicTxSimulator(publicDb, worldStateDB, globalVariables, true);
|
|
73
|
-
const processor = new PublicProcessor(publicDb, globalVariables, worldStateDB, publicTxSimulator, new TestDateProvider());
|
|
67
|
+
const ws = await NativeWorldStateService.tmp(/*rollupAddress=*/ undefined, /*cleanupTmpDir=*/ true, prefilledPublicData);
|
|
74
68
|
let localProver;
|
|
75
69
|
const config = await getEnvironmentConfig(logger);
|
|
76
70
|
if (!config) {
|
|
@@ -81,7 +75,9 @@ export class TestContext {
|
|
|
81
75
|
acvmWorkingDirectory: config.acvmWorkingDirectory,
|
|
82
76
|
bbBinaryPath: config.expectedBBPath,
|
|
83
77
|
bbWorkingDirectory: config.bbWorkingDirectory,
|
|
84
|
-
bbSkipCleanup: config.bbSkipCleanup
|
|
78
|
+
bbSkipCleanup: config.bbSkipCleanup,
|
|
79
|
+
numConcurrentIVCVerifiers: 2,
|
|
80
|
+
bbIVCConcurrency: 1
|
|
85
81
|
};
|
|
86
82
|
localProver = await createProver(bbConfig);
|
|
87
83
|
}
|
|
@@ -90,10 +86,10 @@ export class TestContext {
|
|
|
90
86
|
}
|
|
91
87
|
const broker = new TestBroker(proverCount, localProver);
|
|
92
88
|
const facade = new BrokerCircuitProverFacade(broker);
|
|
93
|
-
const orchestrator = new TestProvingOrchestrator(ws, facade,
|
|
89
|
+
const orchestrator = new TestProvingOrchestrator(ws, facade, EthAddress.ZERO);
|
|
94
90
|
await broker.start();
|
|
95
91
|
facade.start();
|
|
96
|
-
return new this(
|
|
92
|
+
return new this(ws, globalVariables, localProver, broker, facade, orchestrator, blockNumber, feePayer, initialFeePayerBalance, directoriesToCleanup, logger);
|
|
97
93
|
}
|
|
98
94
|
getFork() {
|
|
99
95
|
return this.worldState.fork();
|
|
@@ -101,6 +97,9 @@ export class TestContext {
|
|
|
101
97
|
getBlockHeader(blockNumber = 0) {
|
|
102
98
|
return blockNumber === 0 ? this.worldState.getCommitted().getInitialHeader() : this.headers.get(blockNumber);
|
|
103
99
|
}
|
|
100
|
+
setBlockHeader(header, blockNumber) {
|
|
101
|
+
this.headers.set(blockNumber, header);
|
|
102
|
+
}
|
|
104
103
|
getPreviousBlockHeader(currentBlockNumber = this.blockNumber) {
|
|
105
104
|
return this.getBlockHeader(currentBlockNumber - 1);
|
|
106
105
|
}
|
|
@@ -119,11 +118,8 @@ export class TestContext {
|
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
|
-
async makeProcessedTx(
|
|
123
|
-
const
|
|
124
|
-
seed: seedOrOpts
|
|
125
|
-
} : seedOrOpts;
|
|
126
|
-
const blockNum = (opts?.globalVariables ?? this.globalVariables).blockNumber.toNumber();
|
|
121
|
+
async makeProcessedTx(opts) {
|
|
122
|
+
const blockNum = (opts?.globalVariables ?? this.globalVariables).blockNumber;
|
|
127
123
|
const header = this.getBlockHeader(blockNum - 1);
|
|
128
124
|
const tx = await makeBloatedProcessedTx({
|
|
129
125
|
header,
|
|
@@ -140,28 +136,37 @@ 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,
|
|
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 = ()=>({})) {
|
|
144
140
|
const globalVariables = typeof blockNumOrGlobals === 'number' ? makeGlobals(blockNumOrGlobals) : blockNumOrGlobals;
|
|
145
|
-
const blockNum = globalVariables.blockNumber
|
|
141
|
+
const blockNum = globalVariables.blockNumber;
|
|
146
142
|
const db = await this.worldState.fork();
|
|
147
|
-
const
|
|
143
|
+
const l1ToL2Messages = times(numL1ToL2Messages, (i)=>new Fr(blockNum * 100 + i));
|
|
144
|
+
const merkleTrees = await this.worldState.fork();
|
|
145
|
+
await merkleTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP));
|
|
146
|
+
const newL1ToL2Snapshot = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, merkleTrees);
|
|
148
147
|
const txs = await timesParallel(numTxs, (i)=>this.makeProcessedTx({
|
|
149
148
|
seed: i + blockNum * 1000,
|
|
150
149
|
globalVariables,
|
|
150
|
+
newL1ToL2Snapshot,
|
|
151
151
|
...makeProcessedTxOpts(i)
|
|
152
152
|
}));
|
|
153
153
|
await this.setTreeRoots(txs);
|
|
154
|
-
const block = await
|
|
154
|
+
const block = await buildBlockWithCleanDB(txs, globalVariables, l1ToL2Messages, db);
|
|
155
155
|
this.headers.set(blockNum, block.header);
|
|
156
|
-
await this.worldState.handleL2BlockAndMessages(block,
|
|
156
|
+
await this.worldState.handleL2BlockAndMessages(block, l1ToL2Messages);
|
|
157
157
|
return {
|
|
158
158
|
block,
|
|
159
159
|
txs,
|
|
160
|
-
|
|
160
|
+
l1ToL2Messages
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
|
-
async processPublicFunctions(txs, maxTransactions) {
|
|
164
|
-
|
|
163
|
+
async processPublicFunctions(txs, { maxTransactions = txs.length, numL1ToL2Messages = 0, contractDataSource } = {}) {
|
|
164
|
+
const l1ToL2Messages = times(numL1ToL2Messages, (i)=>new Fr(this.blockNumber * 100 + i));
|
|
165
|
+
const merkleTrees = await this.worldState.fork();
|
|
166
|
+
await merkleTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP));
|
|
167
|
+
const processorFactory = new PublicProcessorFactory(contractDataSource ?? new SimpleContractDataSource(), new TestDateProvider());
|
|
168
|
+
const publicProcessor = processorFactory.create(merkleTrees, this.globalVariables, /*skipFeeEnforcement=*/ false);
|
|
169
|
+
return await publicProcessor.process(txs, {
|
|
165
170
|
maxTransactions
|
|
166
171
|
});
|
|
167
172
|
}
|
|
@@ -174,8 +179,9 @@ export class TestContext {
|
|
|
174
179
|
]);
|
|
175
180
|
const endStateReference = await db.getStateReference();
|
|
176
181
|
if (tx.avmProvingRequest) {
|
|
177
|
-
tx.avmProvingRequest.inputs.publicInputs.startTreeSnapshots
|
|
178
|
-
tx.avmProvingRequest.inputs.publicInputs.
|
|
182
|
+
const l1ToL2MessageTree = tx.avmProvingRequest.inputs.publicInputs.startTreeSnapshots.l1ToL2MessageTree;
|
|
183
|
+
tx.avmProvingRequest.inputs.publicInputs.startTreeSnapshots = new TreeSnapshots(l1ToL2MessageTree, startStateReference.partial.noteHashTree, startStateReference.partial.nullifierTree, startStateReference.partial.publicDataTree);
|
|
184
|
+
tx.avmProvingRequest.inputs.publicInputs.endTreeSnapshots = new TreeSnapshots(l1ToL2MessageTree, endStateReference.partial.noteHashTree, endStateReference.partial.nullifierTree, endStateReference.partial.publicDataTree);
|
|
179
185
|
}
|
|
180
186
|
}
|
|
181
187
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { Blob, type SpongeBlob } from '@aztec/blob-lib';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
|
-
import type { Logger } from '@aztec/foundation/log';
|
|
1
|
+
import { BatchedBlobAccumulator, Blob, type SpongeBlob } from '@aztec/blob-lib';
|
|
2
|
+
import { BLS12Point, Fr } from '@aztec/foundation/fields';
|
|
6
3
|
import { type Tuple } from '@aztec/foundation/serialize';
|
|
7
4
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
8
5
|
import { PublicDataHint } from '@aztec/stdlib/avm';
|
|
9
6
|
import { Body } from '@aztec/stdlib/block';
|
|
10
7
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
11
8
|
import type { ParityPublicInputs } from '@aztec/stdlib/parity';
|
|
12
|
-
import { type BaseOrMergeRollupPublicInputs, type BlockRootOrBlockMergePublicInputs,
|
|
9
|
+
import { type BaseOrMergeRollupPublicInputs, type BlockRootOrBlockMergePublicInputs, PrivateBaseRollupHints, PublicBaseRollupHints } from '@aztec/stdlib/rollup';
|
|
13
10
|
import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
14
11
|
import { BlockHeader, type GlobalVariables, PartialStateReference, type ProcessedTx, StateReference, TxEffect } from '@aztec/stdlib/tx';
|
|
15
12
|
import type { MerkleTreeReadOperations } from '@aztec/world-state';
|
|
@@ -21,22 +18,33 @@ type BaseTreeNames = 'NoteHashTree' | 'ContractTree' | 'NullifierTree' | 'Public
|
|
|
21
18
|
* Type representing the names of the trees.
|
|
22
19
|
*/
|
|
23
20
|
export type TreeNames = BaseTreeNames | 'L1ToL2MessageTree' | 'Archive';
|
|
24
|
-
export declare const
|
|
21
|
+
export declare const insertSideEffectsAndBuildBaseRollupHints: (tx: ProcessedTx, globalVariables: GlobalVariables, newL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot, db: MerkleTreeWriteOperations, startSpongeBlob: SpongeBlob) => Promise<PublicBaseRollupHints | PrivateBaseRollupHints>;
|
|
25
22
|
export declare function getPublicDataHint(db: MerkleTreeWriteOperations, leafSlot: bigint): Promise<PublicDataHint>;
|
|
26
23
|
export declare const buildBlobHints: (txEffects: TxEffect[]) => Promise<{
|
|
27
24
|
blobFields: Fr[];
|
|
28
|
-
blobCommitments: [
|
|
25
|
+
blobCommitments: BLS12Point[];
|
|
29
26
|
blobs: Blob[];
|
|
30
27
|
blobsHash: Fr;
|
|
31
28
|
}>;
|
|
32
|
-
export declare const
|
|
29
|
+
export declare const accumulateBlobs: (txs: ProcessedTx[], startBlobAccumulator: BatchedBlobAccumulator) => Promise<BatchedBlobAccumulator>;
|
|
30
|
+
export declare const buildHeaderFromCircuitOutputs: (previousRollupData: BaseOrMergeRollupPublicInputs[], parityPublicInputs: ParityPublicInputs, rootRollupOutputs: BlockRootOrBlockMergePublicInputs, blobsHash: Fr, endState: StateReference) => BlockHeader;
|
|
33
31
|
export declare const buildHeaderAndBodyFromTxs: (txs: ProcessedTx[], globalVariables: GlobalVariables, l1ToL2Messages: Fr[], db: MerkleTreeReadOperations) => Promise<{
|
|
34
32
|
header: BlockHeader;
|
|
35
33
|
body: Body;
|
|
36
34
|
}>;
|
|
37
|
-
|
|
35
|
+
/** Computes the inHash for a block's ContentCommitment given its l1 to l2 messages. */
|
|
36
|
+
export declare function computeInHashFromL1ToL2Messages(unpaddedL1ToL2Messages: Fr[]): Promise<Fr>;
|
|
37
|
+
export declare function getBlobsHashFromBlobs(inputs: Blob[]): Fr;
|
|
38
|
+
export declare function getEmptyBlockBlobsHash(): Promise<Fr>;
|
|
38
39
|
export declare function validateBlockRootOutput(blockRootOutput: BlockRootOrBlockMergePublicInputs, blockHeader: BlockHeader, db: MerkleTreeReadOperations): Promise<void>;
|
|
39
40
|
export declare const validateState: (state: StateReference, db: MerkleTreeReadOperations) => Promise<void>;
|
|
41
|
+
export declare function getLastSiblingPath<TID extends MerkleTreeId>(treeId: TID, db: MerkleTreeReadOperations): Promise<Tuple<Fr, {
|
|
42
|
+
readonly 1: 40;
|
|
43
|
+
readonly 4: 29;
|
|
44
|
+
readonly 3: 39;
|
|
45
|
+
readonly 0: 40;
|
|
46
|
+
readonly 2: 40;
|
|
47
|
+
}[TID]>>;
|
|
40
48
|
export declare function getRootTreeSiblingPath<TID extends MerkleTreeId>(treeId: TID, db: MerkleTreeReadOperations): Promise<Tuple<Fr, {
|
|
41
49
|
readonly 1: 40;
|
|
42
50
|
readonly 4: 29;
|
|
@@ -44,7 +52,6 @@ export declare function getRootTreeSiblingPath<TID extends MerkleTreeId>(treeId:
|
|
|
44
52
|
readonly 0: 40;
|
|
45
53
|
readonly 2: 40;
|
|
46
54
|
}[TID]>>;
|
|
47
|
-
export declare const getConstantRollupData: (globalVariables: GlobalVariables, db: MerkleTreeReadOperations) => Promise<ConstantRollupData>;
|
|
48
55
|
export declare function getTreeSnapshot(id: MerkleTreeId, db: MerkleTreeReadOperations): Promise<AppendOnlyTreeSnapshot>;
|
|
49
56
|
export declare function makeEmptyMembershipWitness<N extends number>(height: N): MembershipWitness<N>;
|
|
50
57
|
export declare function getSubtreeSiblingPath(treeId: MerkleTreeId, subtreeHeight: number, db: MerkleTreeReadOperations): Promise<Fr[]>;
|