@aztec/prover-node 0.0.1-commit.21caa21 → 0.0.1-commit.21ecf947b
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/actions/download-epoch-proving-job.d.ts +1 -1
- package/dest/actions/rerun-epoch-proving-job.d.ts +3 -2
- package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -1
- package/dest/actions/rerun-epoch-proving-job.js +5 -3
- package/dest/config.d.ts +5 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +4 -3
- package/dest/factory.d.ts +5 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +28 -19
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/job/epoch-proving-job-data.d.ts +7 -6
- package/dest/job/epoch-proving-job-data.d.ts.map +1 -1
- package/dest/job/epoch-proving-job-data.js +24 -18
- package/dest/job/epoch-proving-job.d.ts +5 -4
- package/dest/job/epoch-proving-job.d.ts.map +1 -1
- package/dest/job/epoch-proving-job.js +499 -108
- package/dest/metrics.d.ts +4 -3
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +29 -97
- package/dest/monitors/epoch-monitor.d.ts +1 -1
- package/dest/monitors/epoch-monitor.d.ts.map +1 -1
- package/dest/monitors/epoch-monitor.js +3 -11
- package/dest/prover-node-publisher.d.ts +12 -10
- package/dest/prover-node-publisher.d.ts.map +1 -1
- package/dest/prover-node-publisher.js +46 -40
- package/dest/prover-node.d.ts +4 -4
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +429 -47
- package/dest/prover-publisher-factory.d.ts +7 -3
- package/dest/prover-publisher-factory.d.ts.map +1 -1
- package/dest/prover-publisher-factory.js +4 -2
- package/package.json +25 -25
- package/src/actions/rerun-epoch-proving-job.ts +5 -3
- package/src/bin/run-failed-epoch.ts +1 -1
- package/src/config.ts +6 -4
- package/src/factory.ts +36 -22
- package/src/index.ts +1 -0
- package/src/job/epoch-proving-job-data.ts +28 -23
- package/src/job/epoch-proving-job.ts +133 -111
- package/src/metrics.ts +30 -81
- package/src/monitors/epoch-monitor.ts +3 -10
- package/src/prover-node-publisher.ts +67 -55
- package/src/prover-node.ts +38 -32
- package/src/prover-publisher-factory.ts +14 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/prover-node",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.21ecf947b",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"../package.common.json"
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
|
-
"build": "yarn clean &&
|
|
15
|
-
"build:dev": "
|
|
14
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
15
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
16
16
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
17
17
|
"bb": "node --no-warnings ./dest/bb/index.js",
|
|
18
18
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
|
|
@@ -56,27 +56,27 @@
|
|
|
56
56
|
]
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
60
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
61
|
-
"@aztec/blob-
|
|
62
|
-
"@aztec/blob-
|
|
63
|
-
"@aztec/constants": "0.0.1-commit.
|
|
64
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
65
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
66
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
67
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
68
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
69
|
-
"@aztec/node-keystore": "0.0.1-commit.
|
|
70
|
-
"@aztec/node-lib": "0.0.1-commit.
|
|
71
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
72
|
-
"@aztec/p2p": "0.0.1-commit.
|
|
73
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
74
|
-
"@aztec/prover-client": "0.0.1-commit.
|
|
75
|
-
"@aztec/sequencer-client": "0.0.1-commit.
|
|
76
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
77
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
78
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
79
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
59
|
+
"@aztec/archiver": "0.0.1-commit.21ecf947b",
|
|
60
|
+
"@aztec/bb-prover": "0.0.1-commit.21ecf947b",
|
|
61
|
+
"@aztec/blob-client": "0.0.1-commit.21ecf947b",
|
|
62
|
+
"@aztec/blob-lib": "0.0.1-commit.21ecf947b",
|
|
63
|
+
"@aztec/constants": "0.0.1-commit.21ecf947b",
|
|
64
|
+
"@aztec/epoch-cache": "0.0.1-commit.21ecf947b",
|
|
65
|
+
"@aztec/ethereum": "0.0.1-commit.21ecf947b",
|
|
66
|
+
"@aztec/foundation": "0.0.1-commit.21ecf947b",
|
|
67
|
+
"@aztec/kv-store": "0.0.1-commit.21ecf947b",
|
|
68
|
+
"@aztec/l1-artifacts": "0.0.1-commit.21ecf947b",
|
|
69
|
+
"@aztec/node-keystore": "0.0.1-commit.21ecf947b",
|
|
70
|
+
"@aztec/node-lib": "0.0.1-commit.21ecf947b",
|
|
71
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.21ecf947b",
|
|
72
|
+
"@aztec/p2p": "0.0.1-commit.21ecf947b",
|
|
73
|
+
"@aztec/protocol-contracts": "0.0.1-commit.21ecf947b",
|
|
74
|
+
"@aztec/prover-client": "0.0.1-commit.21ecf947b",
|
|
75
|
+
"@aztec/sequencer-client": "0.0.1-commit.21ecf947b",
|
|
76
|
+
"@aztec/simulator": "0.0.1-commit.21ecf947b",
|
|
77
|
+
"@aztec/stdlib": "0.0.1-commit.21ecf947b",
|
|
78
|
+
"@aztec/telemetry-client": "0.0.1-commit.21ecf947b",
|
|
79
|
+
"@aztec/world-state": "0.0.1-commit.21ecf947b",
|
|
80
80
|
"source-map-support": "^0.5.21",
|
|
81
81
|
"tslib": "^2.4.0",
|
|
82
82
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@types/jest": "^30.0.0",
|
|
87
87
|
"@types/node": "^22.15.17",
|
|
88
88
|
"@types/source-map-support": "^0.5.10",
|
|
89
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
89
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
90
90
|
"jest": "^30.0.0",
|
|
91
91
|
"jest-mock-extended": "^4.0.0",
|
|
92
92
|
"ts-node": "^10.9.1",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createArchiverStore } from '@aztec/archiver';
|
|
2
|
+
import type { L1ContractsConfig } from '@aztec/ethereum/config';
|
|
2
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
4
|
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
4
5
|
import { type ProverClientConfig, createProverClient } from '@aztec/prover-client';
|
|
@@ -21,7 +22,7 @@ import { ProverNodeJobMetrics } from '../metrics.js';
|
|
|
21
22
|
export async function rerunEpochProvingJob(
|
|
22
23
|
localPath: string,
|
|
23
24
|
log: Logger,
|
|
24
|
-
config: DataStoreConfig & ProverBrokerConfig & ProverClientConfig,
|
|
25
|
+
config: DataStoreConfig & ProverBrokerConfig & ProverClientConfig & Pick<L1ContractsConfig, 'aztecEpochDuration'>,
|
|
25
26
|
) {
|
|
26
27
|
const jobData = deserializeEpochProvingJobData(readFileSync(localPath));
|
|
27
28
|
log.info(`Loaded proving job data for epoch ${jobData.epochNumber}`);
|
|
@@ -29,8 +30,8 @@ export async function rerunEpochProvingJob(
|
|
|
29
30
|
const telemetry = getTelemetryClient();
|
|
30
31
|
const metrics = new ProverNodeJobMetrics(telemetry.getMeter('prover-job'), telemetry.getTracer('prover-job'));
|
|
31
32
|
const worldState = await createWorldState(config);
|
|
32
|
-
const archiver = await createArchiverStore(config);
|
|
33
|
-
const publicProcessorFactory = new PublicProcessorFactory(archiver);
|
|
33
|
+
const archiver = await createArchiverStore(config, { epochDuration: config.aztecEpochDuration });
|
|
34
|
+
const publicProcessorFactory = new PublicProcessorFactory(archiver, undefined, undefined, log.getBindings());
|
|
34
35
|
|
|
35
36
|
const publisher = { submitEpochProof: () => Promise.resolve(true) };
|
|
36
37
|
const l2BlockSourceForReorgDetection = undefined;
|
|
@@ -52,6 +53,7 @@ export async function rerunEpochProvingJob(
|
|
|
52
53
|
metrics,
|
|
53
54
|
deadline,
|
|
54
55
|
{ skipEpochCheck: true },
|
|
56
|
+
log.getBindings(),
|
|
55
57
|
);
|
|
56
58
|
|
|
57
59
|
log.info(`Rerunning epoch proving job for epoch ${jobData.epochNumber}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import type { L1ContractAddresses } from '@aztec/ethereum';
|
|
2
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
package/src/config.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver/config';
|
|
2
2
|
import type { ACVMConfig, BBConfig } from '@aztec/bb-prover/config';
|
|
3
|
-
import { type GenesisStateConfig, genesisStateConfigMappings } from '@aztec/ethereum';
|
|
3
|
+
import { type GenesisStateConfig, genesisStateConfigMappings } from '@aztec/ethereum/config';
|
|
4
4
|
import {
|
|
5
5
|
type ConfigMappingsType,
|
|
6
6
|
booleanConfigHelper,
|
|
@@ -8,7 +8,9 @@ import {
|
|
|
8
8
|
numberConfigHelper,
|
|
9
9
|
} from '@aztec/foundation/config';
|
|
10
10
|
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
11
|
-
import { type
|
|
11
|
+
import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore/config';
|
|
12
|
+
import { ethPrivateKeySchema } from '@aztec/node-keystore/schemas';
|
|
13
|
+
import type { KeyStore } from '@aztec/node-keystore/types';
|
|
12
14
|
import { type SharedNodeConfig, sharedNodeConfigMappings } from '@aztec/node-lib/config';
|
|
13
15
|
import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
|
|
14
16
|
import {
|
|
@@ -16,7 +18,7 @@ import {
|
|
|
16
18
|
type ProverBrokerConfig,
|
|
17
19
|
proverAgentConfigMappings,
|
|
18
20
|
proverBrokerConfigMappings,
|
|
19
|
-
} from '@aztec/prover-client/broker';
|
|
21
|
+
} from '@aztec/prover-client/broker/config';
|
|
20
22
|
import { type ProverClientUserConfig, bbConfigMappings, proverClientConfigMappings } from '@aztec/prover-client/config';
|
|
21
23
|
import {
|
|
22
24
|
type PublisherConfig,
|
|
@@ -163,7 +165,7 @@ function createKeyStoreFromWeb3Signer(config: ProverNodeConfig): KeyStore | unde
|
|
|
163
165
|
function createKeyStoreFromPublisherKeys(config: ProverNodeConfig): KeyStore | undefined {
|
|
164
166
|
// Extract the publisher keys from the provided config.
|
|
165
167
|
const publisherKeys = config.publisherPrivateKeys
|
|
166
|
-
? config.publisherPrivateKeys.map(k => ethPrivateKeySchema.parse(k.getValue()))
|
|
168
|
+
? config.publisherPrivateKeys.map((k: { getValue: () => string }) => ethPrivateKeySchema.parse(k.getValue()))
|
|
167
169
|
: [];
|
|
168
170
|
|
|
169
171
|
// There must be at least 1.
|
package/src/factory.ts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { type Archiver, createArchiver } from '@aztec/archiver';
|
|
2
2
|
import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
3
|
-
import {
|
|
3
|
+
import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
4
4
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
5
|
-
import {
|
|
5
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
6
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
7
|
+
import { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
8
|
+
import { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
6
9
|
import { pick } from '@aztec/foundation/collection';
|
|
7
10
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
8
11
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
9
12
|
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
10
13
|
import { type KeyStoreConfig, KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
11
14
|
import { trySnapshotSync } from '@aztec/node-lib/actions';
|
|
12
|
-
import {
|
|
13
|
-
|
|
15
|
+
import {
|
|
16
|
+
createForwarderL1TxUtilsFromEthSigner,
|
|
17
|
+
createL1TxUtilsFromEthSignerWithStore,
|
|
18
|
+
} from '@aztec/node-lib/factories';
|
|
19
|
+
import { NodeRpcTxSource, type P2PClientDeps, createP2PClient } from '@aztec/p2p';
|
|
14
20
|
import { type ProverClientConfig, createProverClient } from '@aztec/prover-client';
|
|
15
21
|
import { createAndStartProvingBroker } from '@aztec/prover-client/broker';
|
|
16
22
|
import type { AztecNode, ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
@@ -33,10 +39,10 @@ export type ProverNodeDeps = {
|
|
|
33
39
|
aztecNodeTxProvider?: Pick<AztecNode, 'getTxsByHash'>;
|
|
34
40
|
archiver?: Archiver;
|
|
35
41
|
publisherFactory?: ProverPublisherFactory;
|
|
36
|
-
blobSinkClient?: BlobSinkClientInterface;
|
|
37
42
|
broker?: ProvingJobBroker;
|
|
38
43
|
l1TxUtils?: L1TxUtils;
|
|
39
44
|
dateProvider?: DateProvider;
|
|
45
|
+
p2pClientDeps?: P2PClientDeps<P2PClientType.Prover>;
|
|
40
46
|
};
|
|
41
47
|
|
|
42
48
|
/** Creates a new prover node given a config. */
|
|
@@ -50,8 +56,7 @@ export async function createProverNode(
|
|
|
50
56
|
const config = { ...userConfig };
|
|
51
57
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
52
58
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
53
|
-
const
|
|
54
|
-
deps.blobSinkClient ?? createBlobSinkClient(config, { logger: createLogger('prover-node:blob-sink:client') });
|
|
59
|
+
const blobClient = await createBlobClientWithFileStores(config, createLogger('prover-node:blob-client:client'));
|
|
55
60
|
const log = deps.log ?? createLogger('prover-node');
|
|
56
61
|
|
|
57
62
|
// Build a key store from file if given or from environment otherwise
|
|
@@ -102,12 +107,11 @@ export async function createProverNode(
|
|
|
102
107
|
|
|
103
108
|
const archiver =
|
|
104
109
|
deps.archiver ??
|
|
105
|
-
(await createArchiver(config, {
|
|
110
|
+
(await createArchiver(config, { blobClient, epochCache, telemetry, dateProvider }, { blockUntilSync: true }));
|
|
106
111
|
log.verbose(`Created archiver and synced to block ${await archiver.getBlockNumber()}`);
|
|
107
112
|
|
|
108
|
-
const worldStateConfig = { ...config, worldStateProvenBlocksOnly: false };
|
|
109
113
|
const worldStateSynchronizer = await createWorldStateSynchronizer(
|
|
110
|
-
|
|
114
|
+
config,
|
|
111
115
|
archiver,
|
|
112
116
|
options.prefilledPublicData,
|
|
113
117
|
telemetry,
|
|
@@ -123,7 +127,7 @@ export async function createProverNode(
|
|
|
123
127
|
|
|
124
128
|
const publicClient = createPublicClient({
|
|
125
129
|
chain: chain.chainInfo,
|
|
126
|
-
transport: fallback(config.l1RpcUrls.map((url: string) => http(url))),
|
|
130
|
+
transport: fallback(config.l1RpcUrls.map((url: string) => http(url, { batch: false }))),
|
|
127
131
|
pollingInterval: config.viemPollingIntervalMS,
|
|
128
132
|
});
|
|
129
133
|
|
|
@@ -131,24 +135,32 @@ export async function createProverNode(
|
|
|
131
135
|
|
|
132
136
|
const l1TxUtils = deps.l1TxUtils
|
|
133
137
|
? [deps.l1TxUtils]
|
|
134
|
-
:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
: config.publisherForwarderAddress
|
|
139
|
+
? await createForwarderL1TxUtilsFromEthSigner(
|
|
140
|
+
publicClient,
|
|
141
|
+
proverSigners.signers,
|
|
142
|
+
config.publisherForwarderAddress,
|
|
143
|
+
{ ...config, scope: 'prover' },
|
|
144
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
145
|
+
)
|
|
146
|
+
: await createL1TxUtilsFromEthSignerWithStore(
|
|
147
|
+
publicClient,
|
|
148
|
+
proverSigners.signers,
|
|
149
|
+
{ ...config, scope: 'prover' },
|
|
150
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
151
|
+
);
|
|
140
152
|
|
|
141
153
|
const publisherFactory =
|
|
142
154
|
deps.publisherFactory ??
|
|
143
155
|
new ProverPublisherFactory(config, {
|
|
144
156
|
rollupContract,
|
|
145
|
-
publisherManager: new PublisherManager(l1TxUtils, config),
|
|
157
|
+
publisherManager: new PublisherManager(l1TxUtils, config, log.getBindings()),
|
|
146
158
|
telemetry,
|
|
147
159
|
});
|
|
148
160
|
|
|
149
161
|
const proofVerifier = new QueuedIVCVerifier(
|
|
150
162
|
config,
|
|
151
|
-
config.realProofs
|
|
163
|
+
config.realProofs || config.debugForceTxProofVerification
|
|
152
164
|
? await BBCircuitVerifier.new(config)
|
|
153
165
|
: new TestCircuitVerifier(config.proverTestVerificationDelayMs),
|
|
154
166
|
);
|
|
@@ -164,9 +176,11 @@ export async function createProverNode(
|
|
|
164
176
|
dateProvider,
|
|
165
177
|
telemetry,
|
|
166
178
|
{
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
179
|
+
...deps.p2pClientDeps,
|
|
180
|
+
txCollectionNodeSources: [
|
|
181
|
+
...(deps.p2pClientDeps?.txCollectionNodeSources ?? []),
|
|
182
|
+
...(deps.aztecNodeTxProvider ? [new NodeRpcTxSource(deps.aztecNodeTxProvider, 'TestNode')] : []),
|
|
183
|
+
],
|
|
170
184
|
},
|
|
171
185
|
);
|
|
172
186
|
|
package/src/index.ts
CHANGED
|
@@ -1,40 +1,45 @@
|
|
|
1
|
-
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
-
import { CommitteeAttestation
|
|
4
|
+
import { CommitteeAttestation } from '@aztec/stdlib/block';
|
|
5
|
+
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
5
6
|
import { BlockHeader, Tx } from '@aztec/stdlib/tx';
|
|
6
7
|
|
|
7
8
|
/** All data from an epoch used in proving. */
|
|
8
9
|
export type EpochProvingJobData = {
|
|
9
10
|
epochNumber: EpochNumber;
|
|
10
|
-
|
|
11
|
+
checkpoints: Checkpoint[];
|
|
11
12
|
txs: Map<string, Tx>;
|
|
12
|
-
l1ToL2Messages: Record<
|
|
13
|
+
l1ToL2Messages: Record<CheckpointNumber, Fr[]>;
|
|
13
14
|
previousBlockHeader: BlockHeader;
|
|
14
15
|
attestations: CommitteeAttestation[];
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
export function validateEpochProvingJobData(data: EpochProvingJobData) {
|
|
18
|
-
if (data.
|
|
19
|
+
if (data.checkpoints.length === 0) {
|
|
20
|
+
throw new Error('No checkpoints to prove');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const firstBlockNumber = data.checkpoints[0].blocks[0].number;
|
|
24
|
+
const previousBlockNumber = data.previousBlockHeader.getBlockNumber();
|
|
25
|
+
if (previousBlockNumber + 1 !== firstBlockNumber) {
|
|
19
26
|
throw new Error(
|
|
20
|
-
`Initial block number ${
|
|
21
|
-
data.blocks[0].number
|
|
22
|
-
} does not match previous block header ${data.previousBlockHeader.getBlockNumber()}`,
|
|
27
|
+
`Initial block number ${firstBlockNumber} does not match previous block header ${previousBlockNumber}`,
|
|
23
28
|
);
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
for (const
|
|
27
|
-
if (!(
|
|
28
|
-
throw new Error(`Missing L1 to L2 messages for
|
|
31
|
+
for (const checkpoint of data.checkpoints) {
|
|
32
|
+
if (!(checkpoint.number in data.l1ToL2Messages)) {
|
|
33
|
+
throw new Error(`Missing L1 to L2 messages for checkpoint number ${checkpoint.number}`);
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
export function serializeEpochProvingJobData(data: EpochProvingJobData): Buffer {
|
|
34
|
-
const
|
|
39
|
+
const checkpoints = data.checkpoints.map(checkpoint => checkpoint.toBuffer());
|
|
35
40
|
const txs = Array.from(data.txs.values()).map(tx => tx.toBuffer());
|
|
36
|
-
const l1ToL2Messages = Object.entries(data.l1ToL2Messages).map(([
|
|
37
|
-
Number(
|
|
41
|
+
const l1ToL2Messages = Object.entries(data.l1ToL2Messages).map(([checkpointNumber, messages]) => [
|
|
42
|
+
Number(checkpointNumber),
|
|
38
43
|
messages.length,
|
|
39
44
|
...messages,
|
|
40
45
|
]);
|
|
@@ -43,8 +48,8 @@ export function serializeEpochProvingJobData(data: EpochProvingJobData): Buffer
|
|
|
43
48
|
return serializeToBuffer(
|
|
44
49
|
data.epochNumber,
|
|
45
50
|
data.previousBlockHeader,
|
|
46
|
-
|
|
47
|
-
...
|
|
51
|
+
checkpoints.length,
|
|
52
|
+
...checkpoints,
|
|
48
53
|
txs.length,
|
|
49
54
|
...txs,
|
|
50
55
|
l1ToL2Messages.length,
|
|
@@ -58,20 +63,20 @@ export function deserializeEpochProvingJobData(buf: Buffer): EpochProvingJobData
|
|
|
58
63
|
const reader = BufferReader.asReader(buf);
|
|
59
64
|
const epochNumber = EpochNumber(reader.readNumber());
|
|
60
65
|
const previousBlockHeader = reader.readObject(BlockHeader);
|
|
61
|
-
const
|
|
66
|
+
const checkpoints = reader.readVector(Checkpoint);
|
|
62
67
|
const txArray = reader.readVector(Tx);
|
|
63
68
|
|
|
64
|
-
const
|
|
69
|
+
const l1ToL2MessageCheckpointCount = reader.readNumber();
|
|
65
70
|
const l1ToL2Messages: Record<number, Fr[]> = {};
|
|
66
|
-
for (let i = 0; i <
|
|
67
|
-
const
|
|
71
|
+
for (let i = 0; i < l1ToL2MessageCheckpointCount; i++) {
|
|
72
|
+
const checkpointNumber = CheckpointNumber(reader.readNumber());
|
|
68
73
|
const messages = reader.readVector(Fr);
|
|
69
|
-
l1ToL2Messages[
|
|
74
|
+
l1ToL2Messages[checkpointNumber] = messages;
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
const attestations = reader.readVector(CommitteeAttestation);
|
|
73
78
|
|
|
74
79
|
const txs = new Map<string, Tx>(txArray.map(tx => [tx.getTxHash().toString(), tx]));
|
|
75
80
|
|
|
76
|
-
return { epochNumber, previousBlockHeader,
|
|
81
|
+
return { epochNumber, previousBlockHeader, checkpoints, txs, l1ToL2Messages, attestations };
|
|
77
82
|
}
|