@aztec/prover-client 0.65.2 → 0.67.0
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_builder/index.d.ts +6 -0
- package/dest/block_builder/index.d.ts.map +1 -0
- package/dest/block_builder/index.js +2 -0
- package/dest/block_builder/light.d.ts +32 -0
- package/dest/block_builder/light.d.ts.map +1 -0
- package/dest/block_builder/light.js +75 -0
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -3
- package/dest/mocks/fixtures.d.ts +4 -5
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +4 -8
- package/dest/mocks/test_context.d.ts +30 -12
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +61 -24
- package/dest/orchestrator/block-building-helpers.d.ts +5 -5
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +10 -11
- package/dest/orchestrator/epoch-proving-state.d.ts +5 -6
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +10 -12
- package/dest/orchestrator/orchestrator.d.ts +8 -6
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +85 -74
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +2 -5
- package/dest/orchestrator/tx-proving-state.d.ts +0 -1
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +2 -34
- package/dest/prover-agent/memory-proving-queue.d.ts.map +1 -1
- package/dest/prover-agent/memory-proving-queue.js +5 -4
- package/dest/prover-agent/prover-agent.d.ts.map +1 -1
- package/dest/prover-agent/prover-agent.js +3 -3
- package/dest/prover-client/factory.d.ts +6 -0
- package/dest/prover-client/factory.d.ts.map +1 -0
- package/dest/prover-client/factory.js +6 -0
- package/dest/prover-client/index.d.ts +3 -0
- package/dest/prover-client/index.d.ts.map +1 -0
- package/dest/prover-client/index.js +3 -0
- package/dest/{tx-prover/tx-prover.d.ts → prover-client/prover-client.d.ts} +8 -11
- package/dest/prover-client/prover-client.d.ts.map +1 -0
- package/dest/prover-client/prover-client.js +107 -0
- package/dest/proving_broker/caching_broker_facade.d.ts +12 -12
- package/dest/proving_broker/caching_broker_facade.d.ts.map +1 -1
- package/dest/proving_broker/caching_broker_facade.js +32 -29
- package/dest/proving_broker/factory.d.ts +2 -1
- package/dest/proving_broker/factory.d.ts.map +1 -1
- package/dest/proving_broker/factory.js +4 -4
- package/dest/proving_broker/proving_agent.d.ts +5 -0
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +15 -4
- package/dest/proving_broker/proving_agent_instrumentation.d.ts +8 -0
- package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +1 -0
- package/dest/proving_broker/proving_agent_instrumentation.js +16 -0
- package/dest/proving_broker/proving_broker.d.ts +29 -5
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +142 -41
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +6 -2
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +25 -0
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -0
- package/dest/proving_broker/proving_broker_instrumentation.js +85 -0
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +3 -2
- package/dest/test/mock_prover.d.ts +3 -2
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +9 -5
- package/package.json +18 -13
- package/src/block_builder/index.ts +6 -0
- package/src/block_builder/light.ts +120 -0
- package/src/index.ts +1 -2
- package/src/mocks/fixtures.ts +6 -18
- package/src/mocks/test_context.ts +85 -29
- package/src/orchestrator/block-building-helpers.ts +13 -14
- package/src/orchestrator/epoch-proving-state.ts +10 -13
- package/src/orchestrator/orchestrator.ts +101 -81
- package/src/orchestrator/orchestrator_metrics.ts +1 -11
- package/src/orchestrator/tx-proving-state.ts +1 -56
- package/src/prover-agent/memory-proving-queue.ts +4 -3
- package/src/prover-agent/prover-agent.ts +2 -2
- package/src/{tx-prover → prover-client}/factory.ts +4 -3
- package/src/prover-client/index.ts +2 -0
- package/src/{tx-prover/tx-prover.ts → prover-client/prover-client.ts} +25 -15
- package/src/proving_broker/caching_broker_facade.ts +31 -15
- package/src/proving_broker/factory.ts +7 -3
- package/src/proving_broker/proving_agent.ts +18 -3
- package/src/proving_broker/proving_agent_instrumentation.ts +21 -0
- package/src/proving_broker/proving_broker.ts +182 -50
- package/src/proving_broker/proving_broker_database/persisted.ts +11 -2
- package/src/proving_broker/proving_broker_instrumentation.ts +123 -0
- package/src/proving_broker/rpc.ts +2 -1
- package/src/test/mock_prover.ts +8 -4
- package/dest/tx-prover/factory.d.ts +0 -6
- package/dest/tx-prover/factory.d.ts.map +0 -1
- package/dest/tx-prover/factory.js +0 -6
- package/dest/tx-prover/tx-prover.d.ts.map +0 -1
- package/dest/tx-prover/tx-prover.js +0 -110
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock_prover.d.ts","sourceRoot":"","sources":["../../src/test/mock_prover.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EAGzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,6BAA6B,EAClC,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,iCAAiC,EACtC,KAAK,qBAAqB,E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MAAM;IAUrG,4BAA4B,CAC1B,MAAM,EAAE,0BAA0B,EAClC,OAAO,CAAC,EAAE,WAAW,EACrB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,6BAA6B,CAAC,iCAAiC,CAAC,CAAC;IAU5E,uBAAuB,CACrB,MAAM,EAAE,qBAAqB,EAC7B,OAAO,CAAC,EAAE,WAAW,EACrB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,6BAA6B,CAAC,iCAAiC,CAAC,CAAC;IAU5E,0BAA0B,CACxB,OAAO,EAAE,2BAA2B,EACpC,OAAO,CAAC,EAAE,WAAW,EACrB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,6BAA6B,CAAC,yBAAyB,CAAC,CAAC;IAUpE,kBAAkB,CAChB,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,WAAW,EACrB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,6BAA6B,CAAC,sBAAsB,CAAC,CAAC;IAUjE,YAAY,IAAI,OAAO,CAAC,uBAAuB,CAAC,OAAO,iBAAiB,CAAC,CAAC;CAK3E"}
|
package/dest/test/mock_prover.js
CHANGED
|
@@ -2,6 +2,7 @@ import { makeProofAndVerificationKey, makePublicInputsAndRecursiveProof, } from
|
|
|
2
2
|
import { AVM_PROOF_LENGTH_IN_FIELDS, AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS, NESTED_RECURSIVE_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH, TUBE_PROOF_LENGTH, VerificationKeyData, makeEmptyRecursiveProof, makeRecursiveProof, } from '@aztec/circuits.js';
|
|
3
3
|
import { makeBaseOrMergeRollupPublicInputs, makeBlockRootOrBlockMergeRollupPublicInputs, makeKernelCircuitPublicInputs, makeParityPublicInputs, makeRootRollupPublicInputs, } from '@aztec/circuits.js/testing';
|
|
4
4
|
import { times } from '@aztec/foundation/collection';
|
|
5
|
+
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
|
|
5
6
|
import { InlineProofStore } from '../proving_broker/proof_store.js';
|
|
6
7
|
import { ProvingAgent } from '../proving_broker/proving_agent.js';
|
|
7
8
|
import { ProvingBroker } from '../proving_broker/proving_broker.js';
|
|
@@ -9,8 +10,8 @@ import { InMemoryBrokerDatabase } from '../proving_broker/proving_broker_databas
|
|
|
9
10
|
export class TestBroker {
|
|
10
11
|
constructor(agentCount, prover, proofStore = new InlineProofStore()) {
|
|
11
12
|
this.proofStore = proofStore;
|
|
12
|
-
this.broker = new ProvingBroker(new InMemoryBrokerDatabase());
|
|
13
|
-
this.agents = times(agentCount, () => new ProvingAgent(this.broker, proofStore, prover));
|
|
13
|
+
this.broker = new ProvingBroker(new InMemoryBrokerDatabase(), new NoopTelemetryClient());
|
|
14
|
+
this.agents = times(agentCount, () => new ProvingAgent(this.broker, proofStore, prover, new NoopTelemetryClient()));
|
|
14
15
|
}
|
|
15
16
|
async start() {
|
|
16
17
|
await this.broker.start();
|
|
@@ -29,8 +30,11 @@ export class TestBroker {
|
|
|
29
30
|
getProvingJobStatus(id) {
|
|
30
31
|
return this.broker.getProvingJobStatus(id);
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
return this.broker.
|
|
33
|
+
cleanUpProvingJobState(id) {
|
|
34
|
+
return this.broker.cleanUpProvingJobState(id);
|
|
35
|
+
}
|
|
36
|
+
cancelProvingJob(id) {
|
|
37
|
+
return this.broker.cancelProvingJob(id);
|
|
34
38
|
}
|
|
35
39
|
waitForJobToSettle(id) {
|
|
36
40
|
return this.broker.waitForJobToSettle(id);
|
|
@@ -75,4 +79,4 @@ export class MockProver {
|
|
|
75
79
|
return Promise.resolve(makeProofAndVerificationKey(makeRecursiveProof(TUBE_PROOF_LENGTH), VerificationKeyData.makeFake()));
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
82
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlI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UFDLFlBQVksRUFBRSxDQUNuQyxDQUNGLENBQUM7SUFDSixDQUFDO0lBRUQsWUFBWTtRQUNWLE9BQU8sT0FBTyxDQUFDLE9BQU8sQ0FDcEIsMkJBQTJCLENBQUMsa0JBQWtCLENBQUMsaUJBQWlCLENBQUMsRUFBRSxtQkFBbUIsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUNuRyxDQUFDO0lBQ0osQ0FBQztDQUNGIn0=
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/prover-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.67.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
7
|
+
"./block-builder": "./dest/block_builder/index.js",
|
|
7
8
|
"./broker": "./dest/proving_broker/index.js",
|
|
8
9
|
"./prover-agent": "./dest/prover-agent/index.js",
|
|
9
10
|
"./orchestrator": "./dest/orchestrator/index.js",
|
|
@@ -27,8 +28,8 @@
|
|
|
27
28
|
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
28
29
|
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
29
30
|
"bb": "node --no-warnings ./dest/bb/index.js",
|
|
30
|
-
"test": "
|
|
31
|
-
"test:debug": "LOG_LEVEL=debug
|
|
31
|
+
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=1500000 --forceExit",
|
|
32
|
+
"test:debug": "LOG_LEVEL=debug NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=1500000 --forceExit --testNamePattern prover/bb_prover/parity"
|
|
32
33
|
},
|
|
33
34
|
"jest": {
|
|
34
35
|
"moduleNameMapper": {
|
|
@@ -62,19 +63,23 @@
|
|
|
62
63
|
"summaryThreshold": 9999
|
|
63
64
|
}
|
|
64
65
|
]
|
|
66
|
+
],
|
|
67
|
+
"testTimeout": 30000,
|
|
68
|
+
"setupFiles": [
|
|
69
|
+
"../../foundation/src/jest/setup.mjs"
|
|
65
70
|
]
|
|
66
71
|
},
|
|
67
72
|
"dependencies": {
|
|
68
|
-
"@aztec/bb-prover": "0.
|
|
69
|
-
"@aztec/circuit-types": "0.
|
|
70
|
-
"@aztec/circuits.js": "0.
|
|
71
|
-
"@aztec/foundation": "0.
|
|
72
|
-
"@aztec/kv-store": "0.
|
|
73
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
74
|
-
"@aztec/protocol-contracts": "0.
|
|
75
|
-
"@aztec/simulator": "0.
|
|
76
|
-
"@aztec/telemetry-client": "0.
|
|
77
|
-
"@aztec/world-state": "0.
|
|
73
|
+
"@aztec/bb-prover": "0.67.0",
|
|
74
|
+
"@aztec/circuit-types": "0.67.0",
|
|
75
|
+
"@aztec/circuits.js": "0.67.0",
|
|
76
|
+
"@aztec/foundation": "0.67.0",
|
|
77
|
+
"@aztec/kv-store": "0.67.0",
|
|
78
|
+
"@aztec/noir-protocol-circuits-types": "0.67.0",
|
|
79
|
+
"@aztec/protocol-contracts": "0.67.0",
|
|
80
|
+
"@aztec/simulator": "0.67.0",
|
|
81
|
+
"@aztec/telemetry-client": "0.67.0",
|
|
82
|
+
"@aztec/world-state": "0.67.0",
|
|
78
83
|
"@noir-lang/types": "portal:../../noir/packages/types",
|
|
79
84
|
"commander": "^12.1.0",
|
|
80
85
|
"lodash.chunk": "^4.2.0",
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type BlockBuilder,
|
|
3
|
+
L2Block,
|
|
4
|
+
MerkleTreeId,
|
|
5
|
+
type MerkleTreeWriteOperations,
|
|
6
|
+
type ProcessedTx,
|
|
7
|
+
makeEmptyProcessedTx,
|
|
8
|
+
} from '@aztec/circuit-types';
|
|
9
|
+
import { Fr, type GlobalVariables, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/circuits.js';
|
|
10
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
11
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
12
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types';
|
|
13
|
+
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
14
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
15
|
+
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
buildBaseRollupHints,
|
|
19
|
+
buildHeaderAndBodyFromTxs,
|
|
20
|
+
getTreeSnapshot,
|
|
21
|
+
} from '../orchestrator/block-building-helpers.js';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
25
|
+
*/
|
|
26
|
+
export class LightweightBlockBuilder implements BlockBuilder {
|
|
27
|
+
private numTxs?: number;
|
|
28
|
+
private globalVariables?: GlobalVariables;
|
|
29
|
+
private l1ToL2Messages?: Fr[];
|
|
30
|
+
|
|
31
|
+
private readonly txs: ProcessedTx[] = [];
|
|
32
|
+
|
|
33
|
+
private readonly logger = createLogger('prover-client:block_builder');
|
|
34
|
+
|
|
35
|
+
constructor(private db: MerkleTreeWriteOperations, private telemetry: TelemetryClient) {}
|
|
36
|
+
|
|
37
|
+
async startNewBlock(numTxs: number, globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void> {
|
|
38
|
+
this.logger.debug('Starting new block', { numTxs, globalVariables: globalVariables.toInspect(), l1ToL2Messages });
|
|
39
|
+
this.numTxs = numTxs;
|
|
40
|
+
this.globalVariables = globalVariables;
|
|
41
|
+
this.l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
42
|
+
|
|
43
|
+
// Update L1 to L2 tree
|
|
44
|
+
await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages!);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async addNewTx(tx: ProcessedTx): Promise<void> {
|
|
48
|
+
this.logger.debug(tx.hash.isZero() ? 'Adding padding tx to block' : 'Adding new tx to block', {
|
|
49
|
+
txHash: tx.hash.toString(),
|
|
50
|
+
});
|
|
51
|
+
this.txs.push(tx);
|
|
52
|
+
await buildBaseRollupHints(tx, this.globalVariables!, this.db);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async setBlockCompleted(): Promise<L2Block> {
|
|
56
|
+
const paddingTxCount = this.numTxs! - this.txs.length;
|
|
57
|
+
for (let i = 0; i < paddingTxCount; i++) {
|
|
58
|
+
await this.addNewTx(
|
|
59
|
+
makeEmptyProcessedTx(
|
|
60
|
+
this.db.getInitialHeader(),
|
|
61
|
+
this.globalVariables!.chainId,
|
|
62
|
+
this.globalVariables!.version,
|
|
63
|
+
getVKTreeRoot(),
|
|
64
|
+
protocolContractTreeRoot,
|
|
65
|
+
),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return this.buildBlock();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private async buildBlock(): Promise<L2Block> {
|
|
73
|
+
const { header, body } = await buildHeaderAndBodyFromTxs(
|
|
74
|
+
this.txs,
|
|
75
|
+
this.globalVariables!,
|
|
76
|
+
this.l1ToL2Messages!,
|
|
77
|
+
this.db,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
await this.db.updateArchive(header);
|
|
81
|
+
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
82
|
+
|
|
83
|
+
const block = new L2Block(newArchive, header, body);
|
|
84
|
+
this.logger.debug(`Built block ${block.number}`, {
|
|
85
|
+
globalVariables: this.globalVariables?.toInspect(),
|
|
86
|
+
archiveRoot: newArchive.root.toString(),
|
|
87
|
+
blockHash: block.hash.toString(),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return block;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class LightweightBlockBuilderFactory {
|
|
95
|
+
constructor(private telemetry?: TelemetryClient) {}
|
|
96
|
+
|
|
97
|
+
create(db: MerkleTreeWriteOperations): BlockBuilder {
|
|
98
|
+
return new LightweightBlockBuilder(db, this.telemetry ?? new NoopTelemetryClient());
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Creates a block builder under the hood with the given txs and messages and creates a block.
|
|
104
|
+
* Automatically adds padding txs to get to a minimum of 2 txs in the block.
|
|
105
|
+
* @param db - A db fork to use for block building.
|
|
106
|
+
*/
|
|
107
|
+
export async function buildBlock(
|
|
108
|
+
txs: ProcessedTx[],
|
|
109
|
+
globalVariables: GlobalVariables,
|
|
110
|
+
l1ToL2Messages: Fr[],
|
|
111
|
+
db: MerkleTreeWriteOperations,
|
|
112
|
+
telemetry: TelemetryClient = new NoopTelemetryClient(),
|
|
113
|
+
) {
|
|
114
|
+
const builder = new LightweightBlockBuilder(db, telemetry);
|
|
115
|
+
await builder.startNewBlock(Math.max(txs.length, 2), globalVariables, l1ToL2Messages);
|
|
116
|
+
for (const tx of txs) {
|
|
117
|
+
await builder.addNewTx(tx);
|
|
118
|
+
}
|
|
119
|
+
return await builder.setBlockCompleted();
|
|
120
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { EpochProverManager } from '@aztec/circuit-types';
|
|
2
2
|
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './prover-client/index.js';
|
|
4
4
|
export * from './config.js';
|
|
5
|
-
export * from './tx-prover/factory.js';
|
|
6
5
|
export * from './proving_broker/prover_cache/memory.js';
|
package/src/mocks/fixtures.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MerkleTreeId,
|
|
3
|
-
type MerkleTreeReadOperations,
|
|
4
|
-
type MerkleTreeWriteOperations,
|
|
5
|
-
type ProcessedTx,
|
|
6
|
-
} from '@aztec/circuit-types';
|
|
7
|
-
import { makeBloatedProcessedTx } from '@aztec/circuit-types/test';
|
|
1
|
+
import { MerkleTreeId, type MerkleTreeWriteOperations, type ProcessedTx } from '@aztec/circuit-types';
|
|
8
2
|
import {
|
|
9
3
|
AztecAddress,
|
|
10
4
|
EthAddress,
|
|
@@ -17,13 +11,11 @@ import {
|
|
|
17
11
|
} from '@aztec/circuits.js';
|
|
18
12
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
19
13
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
20
|
-
import { type
|
|
14
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
21
15
|
import { fileURLToPath } from '@aztec/foundation/url';
|
|
22
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types';
|
|
23
|
-
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
24
16
|
import { NativeACVMSimulator, type SimulationProvider, WASMSimulator } from '@aztec/simulator';
|
|
25
17
|
|
|
26
|
-
import
|
|
18
|
+
import { promises as fs } from 'fs';
|
|
27
19
|
import path from 'path';
|
|
28
20
|
|
|
29
21
|
const {
|
|
@@ -38,7 +30,7 @@ const {
|
|
|
38
30
|
} = process.env;
|
|
39
31
|
|
|
40
32
|
// Determines if we have access to the bb binary and a tmp folder for temp files
|
|
41
|
-
export const getEnvironmentConfig = async (logger:
|
|
33
|
+
export const getEnvironmentConfig = async (logger: Logger) => {
|
|
42
34
|
try {
|
|
43
35
|
const expectedBBPath = BB_BINARY_PATH
|
|
44
36
|
? BB_BINARY_PATH
|
|
@@ -76,7 +68,7 @@ export const getEnvironmentConfig = async (logger: DebugLogger) => {
|
|
|
76
68
|
|
|
77
69
|
export async function getSimulationProvider(
|
|
78
70
|
config: { acvmWorkingDirectory: string | undefined; acvmBinaryPath: string | undefined },
|
|
79
|
-
logger?:
|
|
71
|
+
logger?: Logger,
|
|
80
72
|
): Promise<SimulationProvider> {
|
|
81
73
|
if (config.acvmBinaryPath && config.acvmWorkingDirectory) {
|
|
82
74
|
try {
|
|
@@ -94,9 +86,6 @@ export async function getSimulationProvider(
|
|
|
94
86
|
return new WASMSimulator();
|
|
95
87
|
}
|
|
96
88
|
|
|
97
|
-
export const makeBloatedProcessedTxWithVKRoot = (builderDb: MerkleTreeReadOperations, seed = 0x1) =>
|
|
98
|
-
makeBloatedProcessedTx({ db: builderDb, vkTreeRoot: getVKTreeRoot(), protocolContractTreeRoot, seed });
|
|
99
|
-
|
|
100
89
|
// Updates the expectedDb trees based on the new note hashes, contracts, and nullifiers from these txs
|
|
101
90
|
export const updateExpectedTreesFromTxs = async (db: MerkleTreeWriteOperations, txs: ProcessedTx[]) => {
|
|
102
91
|
await db.appendLeaves(
|
|
@@ -109,10 +98,9 @@ export const updateExpectedTreesFromTxs = async (db: MerkleTreeWriteOperations,
|
|
|
109
98
|
NULLIFIER_TREE_HEIGHT,
|
|
110
99
|
);
|
|
111
100
|
for (const tx of txs) {
|
|
112
|
-
await db.
|
|
101
|
+
await db.sequentialInsert(
|
|
113
102
|
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
114
103
|
tx.txEffect.publicDataWrites.map(write => write.toBuffer()),
|
|
115
|
-
0,
|
|
116
104
|
);
|
|
117
105
|
}
|
|
118
106
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type BBProverConfig } from '@aztec/bb-prover';
|
|
2
2
|
import {
|
|
3
|
-
type
|
|
3
|
+
type L2Block,
|
|
4
4
|
type ProcessedTx,
|
|
5
5
|
type ProcessedTxHandler,
|
|
6
6
|
type PublicExecutionRequest,
|
|
@@ -8,10 +8,13 @@ import {
|
|
|
8
8
|
type Tx,
|
|
9
9
|
type TxValidator,
|
|
10
10
|
} from '@aztec/circuit-types';
|
|
11
|
-
import {
|
|
11
|
+
import { makeBloatedProcessedTx } from '@aztec/circuit-types/test';
|
|
12
|
+
import { type AppendOnlyTreeSnapshot, BlockHeader, type Gas, type GlobalVariables } from '@aztec/circuits.js';
|
|
13
|
+
import { times } from '@aztec/foundation/collection';
|
|
12
14
|
import { Fr } from '@aztec/foundation/fields';
|
|
13
|
-
import { type
|
|
14
|
-
import {
|
|
15
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
16
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types';
|
|
17
|
+
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
15
18
|
import {
|
|
16
19
|
PublicProcessor,
|
|
17
20
|
PublicTxSimulator,
|
|
@@ -20,35 +23,37 @@ import {
|
|
|
20
23
|
type WorldStateDB,
|
|
21
24
|
} from '@aztec/simulator';
|
|
22
25
|
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
|
|
23
|
-
import {
|
|
26
|
+
import { type MerkleTreeAdminDatabase } from '@aztec/world-state';
|
|
24
27
|
import { NativeWorldStateService } from '@aztec/world-state/native';
|
|
25
28
|
|
|
26
29
|
import { jest } from '@jest/globals';
|
|
27
|
-
import
|
|
28
|
-
import {
|
|
30
|
+
import { promises as fs } from 'fs';
|
|
31
|
+
import { mock } from 'jest-mock-extended';
|
|
29
32
|
|
|
30
33
|
import { TestCircuitProver } from '../../../bb-prover/src/test/test_circuit_prover.js';
|
|
31
34
|
import { AvmFinalizedCallResult } from '../../../simulator/src/avm/avm_contract_call_result.js';
|
|
32
35
|
import { type AvmPersistableStateManager } from '../../../simulator/src/avm/journal/journal.js';
|
|
36
|
+
import { buildBlock } from '../block_builder/light.js';
|
|
33
37
|
import { ProvingOrchestrator } from '../orchestrator/index.js';
|
|
34
38
|
import { MemoryProvingQueue } from '../prover-agent/memory-proving-queue.js';
|
|
35
39
|
import { ProverAgent } from '../prover-agent/prover-agent.js';
|
|
36
40
|
import { getEnvironmentConfig, getSimulationProvider, makeGlobals } from './fixtures.js';
|
|
37
41
|
|
|
38
42
|
export class TestContext {
|
|
43
|
+
private headers: Map<number, BlockHeader> = new Map();
|
|
44
|
+
|
|
39
45
|
constructor(
|
|
40
46
|
public publicTxSimulator: PublicTxSimulator,
|
|
41
|
-
public
|
|
47
|
+
public worldState: MerkleTreeAdminDatabase,
|
|
42
48
|
public publicProcessor: PublicProcessor,
|
|
43
49
|
public simulationProvider: SimulationProvider,
|
|
44
50
|
public globalVariables: GlobalVariables,
|
|
45
|
-
public actualDb: MerkleTreeWriteOperations,
|
|
46
51
|
public prover: ServerCircuitProver,
|
|
47
52
|
public proverAgent: ProverAgent,
|
|
48
|
-
public orchestrator:
|
|
53
|
+
public orchestrator: TestProvingOrchestrator,
|
|
49
54
|
public blockNumber: number,
|
|
50
55
|
public directoriesToCleanup: string[],
|
|
51
|
-
public logger:
|
|
56
|
+
public logger: Logger,
|
|
52
57
|
) {}
|
|
53
58
|
|
|
54
59
|
public get epochProver() {
|
|
@@ -56,12 +61,11 @@ export class TestContext {
|
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
static async new(
|
|
59
|
-
logger:
|
|
60
|
-
worldState: 'native' | 'legacy' = 'native',
|
|
64
|
+
logger: Logger,
|
|
61
65
|
proverCount = 4,
|
|
62
66
|
createProver: (bbConfig: BBProverConfig) => Promise<ServerCircuitProver> = _ =>
|
|
63
67
|
Promise.resolve(new TestCircuitProver(new NoopTelemetryClient(), new WASMSimulator())),
|
|
64
|
-
blockNumber =
|
|
68
|
+
blockNumber = 1,
|
|
65
69
|
) {
|
|
66
70
|
const directoriesToCleanup: string[] = [];
|
|
67
71
|
const globalVariables = makeGlobals(blockNumber);
|
|
@@ -70,25 +74,16 @@ export class TestContext {
|
|
|
70
74
|
const telemetry = new NoopTelemetryClient();
|
|
71
75
|
|
|
72
76
|
// Separated dbs for public processor and prover - see public_processor for context
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
const ws = await NativeWorldStateService.tmp();
|
|
78
|
+
const publicDb = await ws.fork();
|
|
75
79
|
|
|
76
|
-
if (worldState === 'native') {
|
|
77
|
-
const ws = await NativeWorldStateService.tmp();
|
|
78
|
-
publicDb = await ws.fork();
|
|
79
|
-
proverDb = await ws.fork();
|
|
80
|
-
} else {
|
|
81
|
-
const ws = await MerkleTrees.new(openTmpStore(), telemetry);
|
|
82
|
-
publicDb = await ws.getLatest();
|
|
83
|
-
proverDb = await ws.getLatest();
|
|
84
|
-
}
|
|
85
80
|
worldStateDB.getMerkleInterface.mockReturnValue(publicDb);
|
|
86
81
|
|
|
87
82
|
const publicTxSimulator = new PublicTxSimulator(publicDb, worldStateDB, telemetry, globalVariables);
|
|
88
83
|
const processor = new PublicProcessor(
|
|
89
84
|
publicDb,
|
|
90
85
|
globalVariables,
|
|
91
|
-
|
|
86
|
+
BlockHeader.empty(),
|
|
92
87
|
worldStateDB,
|
|
93
88
|
publicTxSimulator,
|
|
94
89
|
telemetry,
|
|
@@ -118,7 +113,7 @@ export class TestContext {
|
|
|
118
113
|
}
|
|
119
114
|
|
|
120
115
|
const queue = new MemoryProvingQueue(telemetry);
|
|
121
|
-
const orchestrator = new
|
|
116
|
+
const orchestrator = new TestProvingOrchestrator(ws, queue, telemetry, Fr.ZERO);
|
|
122
117
|
const agent = new ProverAgent(localProver, proverCount);
|
|
123
118
|
|
|
124
119
|
queue.start();
|
|
@@ -126,11 +121,10 @@ export class TestContext {
|
|
|
126
121
|
|
|
127
122
|
return new this(
|
|
128
123
|
publicTxSimulator,
|
|
129
|
-
|
|
124
|
+
ws,
|
|
130
125
|
processor,
|
|
131
126
|
simulationProvider,
|
|
132
127
|
globalVariables,
|
|
133
|
-
proverDb,
|
|
134
128
|
localProver,
|
|
135
129
|
agent,
|
|
136
130
|
orchestrator,
|
|
@@ -140,6 +134,16 @@ export class TestContext {
|
|
|
140
134
|
);
|
|
141
135
|
}
|
|
142
136
|
|
|
137
|
+
public getFork() {
|
|
138
|
+
return this.worldState.fork();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public getBlockHeader(blockNumber: 0): BlockHeader;
|
|
142
|
+
public getBlockHeader(blockNumber: number): BlockHeader | undefined;
|
|
143
|
+
public getBlockHeader(blockNumber = 0) {
|
|
144
|
+
return blockNumber === 0 ? this.worldState.getCommitted().getInitialHeader() : this.headers.get(blockNumber);
|
|
145
|
+
}
|
|
146
|
+
|
|
143
147
|
async cleanup() {
|
|
144
148
|
await this.proverAgent.stop();
|
|
145
149
|
for (const dir of this.directoriesToCleanup.filter(x => x !== '')) {
|
|
@@ -147,6 +151,42 @@ export class TestContext {
|
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
153
|
|
|
154
|
+
public makeProcessedTx(opts?: Parameters<typeof makeBloatedProcessedTx>[0]): ProcessedTx;
|
|
155
|
+
public makeProcessedTx(seed?: number): ProcessedTx;
|
|
156
|
+
public makeProcessedTx(seedOrOpts?: Parameters<typeof makeBloatedProcessedTx>[0] | number): ProcessedTx {
|
|
157
|
+
const opts = typeof seedOrOpts === 'number' ? { seed: seedOrOpts } : seedOrOpts;
|
|
158
|
+
const blockNum = (opts?.globalVariables ?? this.globalVariables).blockNumber.toNumber();
|
|
159
|
+
const header = this.getBlockHeader(blockNum - 1);
|
|
160
|
+
return makeBloatedProcessedTx({
|
|
161
|
+
header,
|
|
162
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
163
|
+
protocolContractTreeRoot,
|
|
164
|
+
globalVariables: this.globalVariables,
|
|
165
|
+
...opts,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Creates a block with the given number of txs and adds it to world-state */
|
|
170
|
+
public async makePendingBlock(
|
|
171
|
+
numTxs: number,
|
|
172
|
+
numMsgs: number = 0,
|
|
173
|
+
blockNumOrGlobals: GlobalVariables | number = this.globalVariables,
|
|
174
|
+
makeProcessedTxOpts: (index: number) => Partial<Parameters<typeof makeBloatedProcessedTx>[0]> = () => ({}),
|
|
175
|
+
) {
|
|
176
|
+
const globalVariables = typeof blockNumOrGlobals === 'number' ? makeGlobals(blockNumOrGlobals) : blockNumOrGlobals;
|
|
177
|
+
const blockNum = globalVariables.blockNumber.toNumber();
|
|
178
|
+
const db = await this.worldState.fork();
|
|
179
|
+
const msgs = times(numMsgs, i => new Fr(blockNum * 100 + i));
|
|
180
|
+
const txs = times(numTxs, i =>
|
|
181
|
+
this.makeProcessedTx({ seed: i + blockNum * 1000, globalVariables, ...makeProcessedTxOpts(i) }),
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
const block = await buildBlock(txs, globalVariables, msgs, db);
|
|
185
|
+
this.headers.set(blockNum, block.header);
|
|
186
|
+
await this.worldState.handleL2BlockAndMessages(block, msgs);
|
|
187
|
+
return { block, txs, msgs };
|
|
188
|
+
}
|
|
189
|
+
|
|
150
190
|
public async processPublicFunctions(
|
|
151
191
|
txs: Tx[],
|
|
152
192
|
maxTransactions: number,
|
|
@@ -217,3 +257,19 @@ export class TestContext {
|
|
|
217
257
|
return await this.publicProcessor.process(txs, maxTransactions, txHandler, txValidator);
|
|
218
258
|
}
|
|
219
259
|
}
|
|
260
|
+
|
|
261
|
+
class TestProvingOrchestrator extends ProvingOrchestrator {
|
|
262
|
+
public isVerifyBuiltBlockAgainstSyncedStateEnabled = false;
|
|
263
|
+
|
|
264
|
+
// Disable this check by default, since it requires seeding world state with the block being built
|
|
265
|
+
// This is only enabled in some tests with multiple blocks that populate the pending chain via makePendingBlock
|
|
266
|
+
protected override verifyBuiltBlockAgainstSyncedState(
|
|
267
|
+
l2Block: L2Block,
|
|
268
|
+
newArchive: AppendOnlyTreeSnapshot,
|
|
269
|
+
): Promise<void> {
|
|
270
|
+
if (this.isVerifyBuiltBlockAgainstSyncedStateEnabled) {
|
|
271
|
+
return super.verifyBuiltBlockAgainstSyncedState(l2Block, newArchive);
|
|
272
|
+
}
|
|
273
|
+
return Promise.resolve();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
ARCHIVE_HEIGHT,
|
|
11
11
|
AppendOnlyTreeSnapshot,
|
|
12
12
|
type BaseOrMergeRollupPublicInputs,
|
|
13
|
+
BlockHeader,
|
|
13
14
|
BlockMergeRollupInputs,
|
|
14
15
|
type BlockRootOrBlockMergePublicInputs,
|
|
15
16
|
ConstantRollupData,
|
|
16
17
|
ContentCommitment,
|
|
17
18
|
Fr,
|
|
18
19
|
type GlobalVariables,
|
|
19
|
-
Header,
|
|
20
20
|
MAX_NOTE_HASHES_PER_TX,
|
|
21
21
|
MAX_NULLIFIERS_PER_TX,
|
|
22
22
|
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
import { makeTuple } from '@aztec/foundation/array';
|
|
53
53
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
54
54
|
import { sha256Trunc } from '@aztec/foundation/crypto';
|
|
55
|
-
import { type
|
|
55
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
56
56
|
import { type Tuple, assertLength, toFriendlyJSON } from '@aztec/foundation/serialize';
|
|
57
57
|
import { computeUnbalancedMerkleRoot } from '@aztec/foundation/trees';
|
|
58
58
|
import { getVKIndex, getVKSiblingPath, getVKTreeRoot } from '@aztec/noir-protocol-circuits-types';
|
|
@@ -95,13 +95,6 @@ export async function buildBaseRollupHints(
|
|
|
95
95
|
i < noteHashSubtreeSiblingPathArray.length ? noteHashSubtreeSiblingPathArray[i] : Fr.ZERO,
|
|
96
96
|
);
|
|
97
97
|
|
|
98
|
-
// Create data hint for reading fee payer initial balance in Fee Juice
|
|
99
|
-
// If no fee payer is set, read hint should be empty
|
|
100
|
-
const leafSlot = computeFeePayerBalanceLeafSlot(tx.data.feePayer);
|
|
101
|
-
const feePayerFeeJuiceBalanceReadHint = tx.data.feePayer.isZero()
|
|
102
|
-
? PublicDataHint.empty()
|
|
103
|
-
: await getPublicDataHint(db, leafSlot.toBigInt());
|
|
104
|
-
|
|
105
98
|
// Update the note hash trees with the new items being inserted to get the new roots
|
|
106
99
|
// that will be used by the next iteration of the base rollup circuit, skipping the empty ones
|
|
107
100
|
const noteHashes = padArrayEnd(tx.txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX);
|
|
@@ -184,7 +177,6 @@ export async function buildBaseRollupHints(
|
|
|
184
177
|
return PublicBaseRollupHints.from({
|
|
185
178
|
start,
|
|
186
179
|
stateDiffHints,
|
|
187
|
-
feePayerFeeJuiceBalanceReadHint: feePayerFeeJuiceBalanceReadHint,
|
|
188
180
|
archiveRootMembershipWitness,
|
|
189
181
|
constants,
|
|
190
182
|
});
|
|
@@ -197,6 +189,13 @@ export async function buildBaseRollupHints(
|
|
|
197
189
|
throw new Error(`More than one public data write in a private only tx`);
|
|
198
190
|
}
|
|
199
191
|
|
|
192
|
+
// Create data hint for reading fee payer initial balance in Fee Juice
|
|
193
|
+
// If no fee payer is set, read hint should be empty
|
|
194
|
+
const leafSlot = computeFeePayerBalanceLeafSlot(tx.data.feePayer);
|
|
195
|
+
const feePayerFeeJuiceBalanceReadHint = tx.data.feePayer.isZero()
|
|
196
|
+
? PublicDataHint.empty()
|
|
197
|
+
: await getPublicDataHint(db, leafSlot.toBigInt());
|
|
198
|
+
|
|
200
199
|
const feeWriteLowLeafPreimage =
|
|
201
200
|
txPublicDataUpdateRequestInfo.lowPublicDataWritesPreimages[0] || PublicDataTreeLeafPreimage.empty();
|
|
202
201
|
const feeWriteLowLeafMembershipWitness =
|
|
@@ -299,7 +298,7 @@ export function buildHeaderFromCircuitOutputs(
|
|
|
299
298
|
parityPublicInputs: ParityPublicInputs,
|
|
300
299
|
rootRollupOutputs: BlockRootOrBlockMergePublicInputs,
|
|
301
300
|
updatedL1ToL2TreeSnapshot: AppendOnlyTreeSnapshot,
|
|
302
|
-
logger?:
|
|
301
|
+
logger?: Logger,
|
|
303
302
|
) {
|
|
304
303
|
const contentCommitment = new ContentCommitment(
|
|
305
304
|
new Fr(previousMergeData[0].numTxs + previousMergeData[1].numTxs),
|
|
@@ -310,7 +309,7 @@ export function buildHeaderFromCircuitOutputs(
|
|
|
310
309
|
sha256Trunc(Buffer.concat([previousMergeData[0].outHash.toBuffer(), previousMergeData[1].outHash.toBuffer()])),
|
|
311
310
|
);
|
|
312
311
|
const state = new StateReference(updatedL1ToL2TreeSnapshot, previousMergeData[1].end);
|
|
313
|
-
const header = new
|
|
312
|
+
const header = new BlockHeader(
|
|
314
313
|
rootRollupOutputs.previousArchive,
|
|
315
314
|
contentCommitment,
|
|
316
315
|
state,
|
|
@@ -371,7 +370,7 @@ export async function buildHeaderAndBodyFromTxs(
|
|
|
371
370
|
const fees = body.txEffects.reduce((acc, tx) => acc.add(tx.transactionFee), Fr.ZERO);
|
|
372
371
|
const manaUsed = txs.reduce((acc, tx) => acc.add(new Fr(tx.gasUsed.totalGas.l2Gas)), Fr.ZERO);
|
|
373
372
|
|
|
374
|
-
const header = new
|
|
373
|
+
const header = new BlockHeader(previousArchive, contentCommitment, stateReference, globalVariables, fees, manaUsed);
|
|
375
374
|
|
|
376
375
|
return { header, body };
|
|
377
376
|
}
|
|
@@ -379,7 +378,7 @@ export async function buildHeaderAndBodyFromTxs(
|
|
|
379
378
|
// Validate that the roots of all local trees match the output of the root circuit simulation
|
|
380
379
|
export async function validateBlockRootOutput(
|
|
381
380
|
blockRootOutput: BlockRootOrBlockMergePublicInputs,
|
|
382
|
-
blockHeader:
|
|
381
|
+
blockHeader: BlockHeader,
|
|
383
382
|
db: MerkleTreeReadOperations,
|
|
384
383
|
) {
|
|
385
384
|
await Promise.all([
|