@aztec/prover-client 0.65.1 → 0.66.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 +71 -0
- package/dest/config.d.ts +4 -10
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +8 -7
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -3
- package/dest/mocks/fixtures.d.ts +1 -2
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +3 -7
- package/dest/mocks/test_context.d.ts +28 -10
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +59 -21
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +10 -18
- package/dest/orchestrator/block-proving-state.js +2 -2
- 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 +83 -72
- 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 +10 -8
- package/dest/prover-agent/memory-proving-queue.d.ts.map +1 -1
- package/dest/prover-agent/memory-proving-queue.js +35 -35
- package/dest/prover-agent/prover-agent.d.ts +1 -0
- package/dest/prover-agent/prover-agent.d.ts.map +1 -1
- package/dest/prover-agent/prover-agent.js +12 -9
- 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/prover-client/prover-client.d.ts +41 -0
- 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 +30 -0
- package/dest/proving_broker/caching_broker_facade.d.ts.map +1 -0
- package/dest/proving_broker/caching_broker_facade.js +150 -0
- package/dest/proving_broker/factory.d.ts +5 -0
- package/dest/proving_broker/factory.d.ts.map +1 -0
- package/dest/proving_broker/factory.js +17 -0
- package/dest/proving_broker/index.d.ts +9 -0
- package/dest/proving_broker/index.d.ts.map +1 -0
- package/dest/proving_broker/index.js +9 -0
- package/dest/proving_broker/proof_store.d.ts +46 -0
- package/dest/proving_broker/proof_store.d.ts.map +1 -0
- package/dest/proving_broker/proof_store.js +37 -0
- package/dest/proving_broker/prover_cache/memory.d.ts +9 -0
- package/dest/proving_broker/prover_cache/memory.d.ts.map +1 -0
- package/dest/proving_broker/prover_cache/memory.js +16 -0
- package/dest/proving_broker/proving_agent.d.ts +16 -6
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +59 -20
- 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 +22 -16
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +79 -25
- package/dest/proving_broker/proving_broker_database/memory.d.ts +14 -0
- package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -0
- package/dest/proving_broker/proving_broker_database/memory.js +35 -0
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +17 -0
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -0
- package/dest/proving_broker/proving_broker_database/persisted.js +43 -0
- package/dest/proving_broker/{proving_job_database.d.ts → proving_broker_database.d.ts} +8 -8
- package/dest/proving_broker/proving_broker_database.d.ts.map +1 -0
- package/dest/proving_broker/proving_broker_database.js +2 -0
- 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 +91 -0
- package/dest/proving_broker/proving_job_controller.d.ts +13 -8
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +43 -43
- package/dest/proving_broker/rpc.d.ts +11 -0
- package/dest/proving_broker/rpc.d.ts.map +1 -0
- package/dest/proving_broker/rpc.js +44 -0
- package/dest/test/mock_prover.d.ts +16 -2
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +37 -1
- package/package.json +17 -14
- package/src/block_builder/index.ts +6 -0
- package/src/block_builder/light.ts +117 -0
- package/src/config.ts +17 -16
- package/src/index.ts +2 -2
- package/src/mocks/fixtures.ts +2 -14
- package/src/mocks/test_context.ts +81 -25
- package/src/orchestrator/block-building-helpers.ts +22 -33
- package/src/orchestrator/block-proving-state.ts +1 -1
- package/src/orchestrator/epoch-proving-state.ts +10 -13
- package/src/orchestrator/orchestrator.ts +97 -77
- package/src/orchestrator/tx-proving-state.ts +1 -56
- package/src/prover-agent/memory-proving-queue.ts +43 -44
- package/src/prover-agent/prover-agent.ts +16 -20
- package/src/prover-client/factory.ts +15 -0
- package/src/prover-client/index.ts +2 -0
- package/src/prover-client/prover-client.ts +172 -0
- package/src/proving_broker/caching_broker_facade.ts +312 -0
- package/src/proving_broker/factory.ts +25 -0
- package/src/proving_broker/index.ts +8 -0
- package/src/proving_broker/proof_store.ts +106 -0
- package/src/proving_broker/prover_cache/memory.ts +20 -0
- package/src/proving_broker/proving_agent.ts +90 -20
- package/src/proving_broker/proving_agent_instrumentation.ts +21 -0
- package/src/proving_broker/proving_broker.ts +143 -67
- package/src/proving_broker/proving_broker_database/memory.ts +43 -0
- package/src/proving_broker/proving_broker_database/persisted.ts +60 -0
- package/src/proving_broker/{proving_job_database.ts → proving_broker_database.ts} +7 -12
- package/src/proving_broker/proving_broker_instrumentation.ts +130 -0
- package/src/proving_broker/proving_job_controller.ts +54 -46
- package/src/proving_broker/rpc.ts +64 -0
- package/src/test/mock_prover.ts +52 -0
- package/dest/proving_broker/proving_broker_interface.d.ts +0 -61
- package/dest/proving_broker/proving_broker_interface.d.ts.map +0 -1
- package/dest/proving_broker/proving_broker_interface.js +0 -2
- package/dest/proving_broker/proving_job_database/memory.d.ts +0 -14
- package/dest/proving_broker/proving_job_database/memory.d.ts.map +0 -1
- package/dest/proving_broker/proving_job_database/memory.js +0 -35
- package/dest/proving_broker/proving_job_database/persisted.d.ts +0 -15
- package/dest/proving_broker/proving_job_database/persisted.d.ts.map +0 -1
- package/dest/proving_broker/proving_job_database/persisted.js +0 -35
- package/dest/proving_broker/proving_job_database.d.ts.map +0 -1
- package/dest/proving_broker/proving_job_database.js +0 -2
- package/dest/tx-prover/factory.d.ts +0 -5
- 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 +0 -38
- package/dest/tx-prover/tx-prover.d.ts.map +0 -1
- package/dest/tx-prover/tx-prover.js +0 -93
- package/src/proving_broker/proving_broker_interface.ts +0 -74
- package/src/proving_broker/proving_job_database/memory.ts +0 -43
- package/src/proving_broker/proving_job_database/persisted.ts +0 -45
- package/src/tx-prover/factory.ts +0 -9
- package/src/tx-prover/tx-prover.ts +0 -130
package/dest/test/mock_prover.js
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
import { makeProofAndVerificationKey, makePublicInputsAndRecursiveProof, } from '@aztec/circuit-types';
|
|
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
|
+
import { times } from '@aztec/foundation/collection';
|
|
5
|
+
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
|
|
6
|
+
import { InlineProofStore } from '../proving_broker/proof_store.js';
|
|
7
|
+
import { ProvingAgent } from '../proving_broker/proving_agent.js';
|
|
8
|
+
import { ProvingBroker } from '../proving_broker/proving_broker.js';
|
|
9
|
+
import { InMemoryBrokerDatabase } from '../proving_broker/proving_broker_database/memory.js';
|
|
10
|
+
export class TestBroker {
|
|
11
|
+
constructor(agentCount, prover, proofStore = new InlineProofStore()) {
|
|
12
|
+
this.proofStore = proofStore;
|
|
13
|
+
this.broker = new ProvingBroker(new InMemoryBrokerDatabase(), new NoopTelemetryClient());
|
|
14
|
+
this.agents = times(agentCount, () => new ProvingAgent(this.broker, proofStore, prover, new NoopTelemetryClient()));
|
|
15
|
+
}
|
|
16
|
+
async start() {
|
|
17
|
+
await this.broker.start();
|
|
18
|
+
this.agents.forEach(agent => agent.start());
|
|
19
|
+
}
|
|
20
|
+
async stop() {
|
|
21
|
+
await Promise.all(this.agents.map(agent => agent.stop()));
|
|
22
|
+
await this.broker.stop();
|
|
23
|
+
}
|
|
24
|
+
getProofStore() {
|
|
25
|
+
return this.proofStore;
|
|
26
|
+
}
|
|
27
|
+
enqueueProvingJob(job) {
|
|
28
|
+
return this.broker.enqueueProvingJob(job);
|
|
29
|
+
}
|
|
30
|
+
getProvingJobStatus(id) {
|
|
31
|
+
return this.broker.getProvingJobStatus(id);
|
|
32
|
+
}
|
|
33
|
+
removeAndCancelProvingJob(id) {
|
|
34
|
+
return this.broker.removeAndCancelProvingJob(id);
|
|
35
|
+
}
|
|
36
|
+
waitForJobToSettle(id) {
|
|
37
|
+
return this.broker.waitForJobToSettle(id);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
4
40
|
export class MockProver {
|
|
5
41
|
constructor() { }
|
|
6
42
|
getAvmProof(_inputs, _signal, _epochNumber) {
|
|
@@ -40,4 +76,4 @@ export class MockProver {
|
|
|
40
76
|
return Promise.resolve(makeProofAndVerificationKey(makeRecursiveProof(TUBE_PROOF_LENGTH), VerificationKeyData.makeFake()));
|
|
41
77
|
}
|
|
42
78
|
}
|
|
43
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
79
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9ja19wcm92ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdC9tb2NrX3Byb3Zlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBU0wsMkJBQTJCLEVBQzNCLGlDQUFpQyxHQUNsQyxNQUFNLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8sRUFDTCwwQkFBMEIsRUFDMUIscUNBQXFDLEVBVXJDLDZCQUE2QixFQUk3QixzQkFBc0IsRUFJdEIsaUJBQWlCLEVBQ2pCLG1CQUFtQixFQUNuQix1QkFBdUIsRUFDdkIsa0JBQWtCLEdBQ25CLE1BQU0sb0JBQW9CLENBQUM7QUFDNUIsT0FBTyxFQUNMLGlDQUFpQyxFQUNqQywyQ0FBMkMsRUFDM0MsNkJBQTZCLEVBQzdCLHNCQUFzQixFQUN0QiwwQkFBMEIsR0FDM0IsTUFBTSw0QkFBNEIsQ0FBQztBQUNwQyxPQUFPLEVBQUUsS0FBSyxFQUFFLE1BQU0sOEJBQThCLENBQUM7QUFDckQsT0FBTyxFQUFFLG1CQUFtQixFQUFFL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UsRUFDL0Isa0JBQWtCLENBQUMsc0JBQXNCLENBQUMsRUFDMUMsbUJBQW1CLENBQUMsWUFBWSxFQUFFLENBQ25DLENBQ0YsQ0FBQztJQUNKLENBQUM7SUFFRCxrQkFBa0IsQ0FDaEIsTUFBd0IsRUFDeEIsT0FBcUIsRUFDckIsWUFBcUI7UUFFckIsT0FBTyxPQUFPLENBQUMsT0FBTyxDQUNwQixpQ0FBaUMsQ0FDL0IsMEJBQTBCLEVBQUUsRUFDNUIsa0JBQWtCLENBQUMsc0JBQXNCLENBQUMsRUFDMUMsbUJBQW1CLENBQUMsWUFBWSxFQUFFLENBQ25DLENBQ0YsQ0FBQztJQUNKLENBQUM7SUFFRCxZQUFZO1FBQ1YsT0FBTyxPQUFPLENBQUMsT0FBTyxDQUNwQiwyQkFBMkIsQ0FBQyxrQkFBa0IsQ0FBQyxpQkFBaUIsQ0FBQyxFQUFFLG1CQUFtQixDQUFDLFFBQVEsRUFBRSxDQUFDLENBQ25HLENBQUM7SUFDSixDQUFDO0NBQ0YifQ==
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/prover-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.66.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
7
|
+
"./block-builder": "./dest/block_builder/index.js",
|
|
8
|
+
"./broker": "./dest/proving_broker/index.js",
|
|
7
9
|
"./prover-agent": "./dest/prover-agent/index.js",
|
|
8
10
|
"./orchestrator": "./dest/orchestrator/index.js",
|
|
9
11
|
"./helpers": "./dest/orchestrator/block-building-helpers.js"
|
|
@@ -26,8 +28,8 @@
|
|
|
26
28
|
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
27
29
|
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
28
30
|
"bb": "node --no-warnings ./dest/bb/index.js",
|
|
29
|
-
"test": "
|
|
30
|
-
"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"
|
|
31
33
|
},
|
|
32
34
|
"jest": {
|
|
33
35
|
"moduleNameMapper": {
|
|
@@ -64,21 +66,22 @@
|
|
|
64
66
|
]
|
|
65
67
|
},
|
|
66
68
|
"dependencies": {
|
|
67
|
-
"@aztec/bb-prover": "0.
|
|
68
|
-
"@aztec/circuit-types": "0.
|
|
69
|
-
"@aztec/circuits.js": "0.
|
|
70
|
-
"@aztec/foundation": "0.
|
|
71
|
-
"@aztec/kv-store": "0.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
73
|
-
"@aztec/protocol-contracts": "0.
|
|
74
|
-
"@aztec/simulator": "0.
|
|
75
|
-
"@aztec/telemetry-client": "0.
|
|
76
|
-
"@aztec/world-state": "0.
|
|
69
|
+
"@aztec/bb-prover": "0.66.0",
|
|
70
|
+
"@aztec/circuit-types": "0.66.0",
|
|
71
|
+
"@aztec/circuits.js": "0.66.0",
|
|
72
|
+
"@aztec/foundation": "0.66.0",
|
|
73
|
+
"@aztec/kv-store": "0.66.0",
|
|
74
|
+
"@aztec/noir-protocol-circuits-types": "0.66.0",
|
|
75
|
+
"@aztec/protocol-contracts": "0.66.0",
|
|
76
|
+
"@aztec/simulator": "0.66.0",
|
|
77
|
+
"@aztec/telemetry-client": "0.66.0",
|
|
78
|
+
"@aztec/world-state": "0.66.0",
|
|
77
79
|
"@noir-lang/types": "portal:../../noir/packages/types",
|
|
78
80
|
"commander": "^12.1.0",
|
|
79
81
|
"lodash.chunk": "^4.2.0",
|
|
80
82
|
"source-map-support": "^0.5.21",
|
|
81
|
-
"tslib": "^2.4.0"
|
|
83
|
+
"tslib": "^2.4.0",
|
|
84
|
+
"zod": "^3.23.8"
|
|
82
85
|
},
|
|
83
86
|
"devDependencies": {
|
|
84
87
|
"@jest/globals": "^29.5.0",
|
|
@@ -0,0 +1,117 @@
|
|
|
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 { createDebugLogger } 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 { inspect } from 'util';
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
buildBaseRollupHints,
|
|
21
|
+
buildHeaderAndBodyFromTxs,
|
|
22
|
+
getTreeSnapshot,
|
|
23
|
+
} from '../orchestrator/block-building-helpers.js';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
27
|
+
*/
|
|
28
|
+
export class LightweightBlockBuilder implements BlockBuilder {
|
|
29
|
+
private numTxs?: number;
|
|
30
|
+
private globalVariables?: GlobalVariables;
|
|
31
|
+
private l1ToL2Messages?: Fr[];
|
|
32
|
+
|
|
33
|
+
private readonly txs: ProcessedTx[] = [];
|
|
34
|
+
|
|
35
|
+
private readonly logger = createDebugLogger('aztec:sequencer-client:block_builder_light');
|
|
36
|
+
|
|
37
|
+
constructor(private db: MerkleTreeWriteOperations, private telemetry: TelemetryClient) {}
|
|
38
|
+
|
|
39
|
+
async startNewBlock(numTxs: number, globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void> {
|
|
40
|
+
this.logger.verbose('Starting new block', { numTxs, globalVariables: inspect(globalVariables), l1ToL2Messages });
|
|
41
|
+
this.numTxs = numTxs;
|
|
42
|
+
this.globalVariables = globalVariables;
|
|
43
|
+
this.l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
44
|
+
|
|
45
|
+
// Update L1 to L2 tree
|
|
46
|
+
await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages!);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async addNewTx(tx: ProcessedTx): Promise<void> {
|
|
50
|
+
this.logger.verbose('Adding new tx to block', { txHash: tx.hash.toString() });
|
|
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
|
+
this.logger.verbose(`Setting block as completed and adding ${paddingTxCount} padding txs`);
|
|
58
|
+
for (let i = 0; i < paddingTxCount; i++) {
|
|
59
|
+
await this.addNewTx(
|
|
60
|
+
makeEmptyProcessedTx(
|
|
61
|
+
this.db.getInitialHeader(),
|
|
62
|
+
this.globalVariables!.chainId,
|
|
63
|
+
this.globalVariables!.version,
|
|
64
|
+
getVKTreeRoot(),
|
|
65
|
+
protocolContractTreeRoot,
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return this.buildBlock();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private async buildBlock(): Promise<L2Block> {
|
|
74
|
+
this.logger.verbose(`Finalising block`);
|
|
75
|
+
|
|
76
|
+
const { header, body } = await buildHeaderAndBodyFromTxs(
|
|
77
|
+
this.txs,
|
|
78
|
+
this.globalVariables!,
|
|
79
|
+
this.l1ToL2Messages!,
|
|
80
|
+
this.db,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
await this.db.updateArchive(header);
|
|
84
|
+
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
85
|
+
|
|
86
|
+
const block = new L2Block(newArchive, header, body);
|
|
87
|
+
return block;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class LightweightBlockBuilderFactory {
|
|
92
|
+
constructor(private telemetry?: TelemetryClient) {}
|
|
93
|
+
|
|
94
|
+
create(db: MerkleTreeWriteOperations): BlockBuilder {
|
|
95
|
+
return new LightweightBlockBuilder(db, this.telemetry ?? new NoopTelemetryClient());
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Creates a block builder under the hood with the given txs and messages and creates a block.
|
|
101
|
+
* Automatically adds padding txs to get to a minimum of 2 txs in the block.
|
|
102
|
+
* @param db - A db fork to use for block building.
|
|
103
|
+
*/
|
|
104
|
+
export async function buildBlock(
|
|
105
|
+
txs: ProcessedTx[],
|
|
106
|
+
globalVariables: GlobalVariables,
|
|
107
|
+
l1ToL2Messages: Fr[],
|
|
108
|
+
db: MerkleTreeWriteOperations,
|
|
109
|
+
telemetry: TelemetryClient = new NoopTelemetryClient(),
|
|
110
|
+
) {
|
|
111
|
+
const builder = new LightweightBlockBuilder(db, telemetry);
|
|
112
|
+
await builder.startNewBlock(Math.max(txs.length, 2), globalVariables, l1ToL2Messages);
|
|
113
|
+
for (const tx of txs) {
|
|
114
|
+
await builder.addNewTx(tx);
|
|
115
|
+
}
|
|
116
|
+
return await builder.setBlockCompleted();
|
|
117
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import { type BBConfig } from '@aztec/bb-prover';
|
|
2
|
-
import {
|
|
1
|
+
import { type ACVMConfig, type BBConfig } from '@aztec/bb-prover';
|
|
2
|
+
import {
|
|
3
|
+
type ProverAgentConfig,
|
|
4
|
+
type ProverBrokerConfig,
|
|
5
|
+
type ProverConfig,
|
|
6
|
+
proverAgentConfigMappings,
|
|
7
|
+
proverBrokerConfigMappings,
|
|
8
|
+
proverConfigMappings,
|
|
9
|
+
} from '@aztec/circuit-types';
|
|
3
10
|
import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
|
|
4
11
|
|
|
5
12
|
/**
|
|
6
13
|
* The prover configuration.
|
|
7
14
|
*/
|
|
8
|
-
export type ProverClientConfig = ProverConfig &
|
|
9
|
-
BBConfig & {
|
|
10
|
-
/** The URL to the Aztec prover node to take proving jobs from */
|
|
11
|
-
proverJobSourceUrl?: string;
|
|
12
|
-
/** The working directory to use for simulation/proving */
|
|
13
|
-
acvmWorkingDirectory: string;
|
|
14
|
-
/** The path to the ACVM binary */
|
|
15
|
-
acvmBinaryPath: string;
|
|
16
|
-
};
|
|
15
|
+
export type ProverClientConfig = ProverConfig & ProverAgentConfig & ProverBrokerConfig & BBConfig & ACVMConfig;
|
|
17
16
|
|
|
18
|
-
export const
|
|
19
|
-
proverJobSourceUrl: {
|
|
20
|
-
env: 'PROVER_JOB_SOURCE_URL',
|
|
21
|
-
description: 'The URL to the Aztec prover node to take proving jobs from',
|
|
22
|
-
},
|
|
17
|
+
export const bbConfigMappings: ConfigMappingsType<BBConfig & ACVMConfig> = {
|
|
23
18
|
acvmWorkingDirectory: {
|
|
24
19
|
env: 'ACVM_WORKING_DIRECTORY',
|
|
25
20
|
description: 'The working directory to use for simulation/proving',
|
|
@@ -41,7 +36,13 @@ export const proverClientConfigMappings: ConfigMappingsType<ProverClientConfig>
|
|
|
41
36
|
description: 'Whether to skip cleanup of bb temporary files',
|
|
42
37
|
...booleanConfigHelper(false),
|
|
43
38
|
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const proverClientConfigMappings: ConfigMappingsType<ProverClientConfig> = {
|
|
42
|
+
...bbConfigMappings,
|
|
44
43
|
...proverConfigMappings,
|
|
44
|
+
...proverAgentConfigMappings,
|
|
45
|
+
...proverBrokerConfigMappings,
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
/**
|
package/src/index.ts
CHANGED
|
@@ -1,5 +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 './
|
|
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,
|
|
@@ -19,8 +13,6 @@ import { padArrayEnd } from '@aztec/foundation/collection';
|
|
|
19
13
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
20
14
|
import { type DebugLogger } 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
18
|
import * as fs from 'fs/promises';
|
|
@@ -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 {
|
|
12
|
-
import { type
|
|
11
|
+
import { makeBloatedProcessedTx } from '@aztec/circuit-types/test';
|
|
12
|
+
import { type AppendOnlyTreeSnapshot, type Gas, type GlobalVariables, Header } from '@aztec/circuits.js';
|
|
13
|
+
import { times } from '@aztec/foundation/collection';
|
|
14
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
13
15
|
import { type DebugLogger } from '@aztec/foundation/log';
|
|
14
|
-
import {
|
|
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,32 +23,34 @@ 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
30
|
import * as fs from 'fs/promises';
|
|
28
|
-
import {
|
|
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, Header> = 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
56
|
public logger: DebugLogger,
|
|
@@ -57,11 +62,10 @@ export class TestContext {
|
|
|
57
62
|
|
|
58
63
|
static async new(
|
|
59
64
|
logger: DebugLogger,
|
|
60
|
-
worldState: 'native' | 'legacy' = 'native',
|
|
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,18 +74,9 @@ 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);
|
|
@@ -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 getHeader(blockNumber: 0): Header;
|
|
142
|
+
public getHeader(blockNumber: number): Header | undefined;
|
|
143
|
+
public getHeader(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.getHeader(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
|
+
}
|
|
@@ -492,41 +492,30 @@ async function processPublicDataUpdateRequests(tx: ProcessedTx, db: MerkleTreeWr
|
|
|
492
492
|
({ leafSlot, value }) => new PublicDataTreeLeaf(leafSlot, value),
|
|
493
493
|
);
|
|
494
494
|
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
// TODO(Alvaro) write a specialized function for this? Internally add_or_update_value uses batch insertion anyway
|
|
505
|
-
const { lowLeavesWitnessData, newSubtreeSiblingPath } = await db.batchInsert(
|
|
506
|
-
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
507
|
-
[write.toBuffer()],
|
|
508
|
-
// TODO(#3675) remove oldValue from update requests
|
|
509
|
-
0,
|
|
510
|
-
);
|
|
511
|
-
|
|
512
|
-
if (lowLeavesWitnessData === undefined) {
|
|
513
|
-
throw new Error(`Could not craft public data batch insertion proofs`);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
const [lowLeafWitness] = lowLeavesWitnessData;
|
|
517
|
-
lowPublicDataWritesPreimages.push(lowLeafWitness.leafPreimage as PublicDataTreeLeafPreimage);
|
|
518
|
-
lowPublicDataWritesMembershipWitnesses.push(
|
|
519
|
-
MembershipWitness.fromBufferArray<typeof PUBLIC_DATA_TREE_HEIGHT>(
|
|
520
|
-
lowLeafWitness.index,
|
|
521
|
-
assertLength(lowLeafWitness.siblingPath.toBufferArray(), PUBLIC_DATA_TREE_HEIGHT),
|
|
522
|
-
),
|
|
523
|
-
);
|
|
495
|
+
const { lowLeavesWitnessData, insertionWitnessData } = await db.sequentialInsert(
|
|
496
|
+
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
497
|
+
allPublicDataWrites.map(write => {
|
|
498
|
+
if (write.isEmpty()) {
|
|
499
|
+
throw new Error(`Empty public data write in tx: ${toFriendlyJSON(tx)}`);
|
|
500
|
+
}
|
|
501
|
+
return write.toBuffer();
|
|
502
|
+
}),
|
|
503
|
+
);
|
|
524
504
|
|
|
525
|
-
|
|
505
|
+
const lowPublicDataWritesPreimages = lowLeavesWitnessData.map(
|
|
506
|
+
lowLeafWitness => lowLeafWitness.leafPreimage as PublicDataTreeLeafPreimage,
|
|
507
|
+
);
|
|
508
|
+
const lowPublicDataWritesMembershipWitnesses = lowLeavesWitnessData.map(lowLeafWitness =>
|
|
509
|
+
MembershipWitness.fromBufferArray<typeof PUBLIC_DATA_TREE_HEIGHT>(
|
|
510
|
+
lowLeafWitness.index,
|
|
511
|
+
assertLength(lowLeafWitness.siblingPath.toBufferArray(), PUBLIC_DATA_TREE_HEIGHT),
|
|
512
|
+
),
|
|
513
|
+
);
|
|
514
|
+
const publicDataWritesSiblingPaths = insertionWitnessData.map(w => {
|
|
515
|
+
const insertionSiblingPath = w.siblingPath.toFields();
|
|
526
516
|
assertLength(insertionSiblingPath, PUBLIC_DATA_TREE_HEIGHT);
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}
|
|
517
|
+
return insertionSiblingPath as Tuple<Fr, typeof PUBLIC_DATA_TREE_HEIGHT>;
|
|
518
|
+
});
|
|
530
519
|
|
|
531
520
|
return {
|
|
532
521
|
lowPublicDataWritesPreimages,
|
|
@@ -131,7 +131,7 @@ export class BlockProvingState {
|
|
|
131
131
|
|
|
132
132
|
/** Returns the block number as an epoch number. Used for prioritizing proof requests. */
|
|
133
133
|
public get epochNumber(): number {
|
|
134
|
-
return this.
|
|
134
|
+
return this.parentEpoch.epochNumber;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/**
|