@aztec/prover-node 0.0.1-fake-c83136db25 → 0.0.1-private.d0bedffd
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 +4 -4
- package/dest/actions/index.d.ts +1 -1
- package/dest/actions/rerun-epoch-proving-job.d.ts +4 -3
- package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -1
- package/dest/actions/rerun-epoch-proving-job.js +5 -3
- package/dest/actions/upload-epoch-proof-failure.d.ts +2 -2
- package/dest/actions/upload-epoch-proof-failure.d.ts.map +1 -1
- package/dest/bin/run-failed-epoch.d.ts +1 -1
- package/dest/bin/run-failed-epoch.js +5 -2
- package/dest/config.d.ts +8 -10
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +18 -20
- package/dest/factory.d.ts +20 -16
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +27 -62
- 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 +8 -6
- package/dest/job/epoch-proving-job-data.d.ts.map +1 -1
- package/dest/job/epoch-proving-job-data.js +25 -18
- package/dest/job/epoch-proving-job.d.ts +7 -13
- package/dest/job/epoch-proving-job.d.ts.map +1 -1
- package/dest/job/epoch-proving-job.js +503 -105
- package/dest/metrics.d.ts +4 -3
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +30 -98
- package/dest/monitors/epoch-monitor.d.ts +3 -2
- package/dest/monitors/epoch-monitor.d.ts.map +1 -1
- package/dest/monitors/epoch-monitor.js +3 -11
- package/dest/monitors/index.d.ts +1 -1
- package/dest/prover-node-publisher.d.ts +14 -11
- package/dest/prover-node-publisher.d.ts.map +1 -1
- package/dest/prover-node-publisher.js +49 -42
- package/dest/prover-node.d.ts +27 -16
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +441 -57
- package/dest/prover-publisher-factory.d.ts +9 -5
- package/dest/prover-publisher-factory.d.ts.map +1 -1
- package/dest/prover-publisher-factory.js +4 -2
- package/dest/test/index.d.ts +1 -1
- package/dest/test/index.d.ts.map +1 -1
- package/package.json +26 -25
- package/src/actions/rerun-epoch-proving-job.ts +6 -4
- package/src/actions/upload-epoch-proof-failure.ts +1 -1
- package/src/bin/run-failed-epoch.ts +5 -2
- package/src/config.ts +26 -32
- package/src/factory.ts +63 -101
- package/src/index.ts +1 -0
- package/src/job/epoch-proving-job-data.ts +31 -25
- package/src/job/epoch-proving-job.ts +139 -110
- package/src/metrics.ts +31 -82
- package/src/monitors/epoch-monitor.ts +5 -11
- package/src/prover-node-publisher.ts +71 -58
- package/src/prover-node.ts +61 -51
- package/src/prover-publisher-factory.ts +16 -8
package/src/metrics.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RollupContract } from '@aztec/ethereum';
|
|
1
|
+
import type { RollupContract } from '@aztec/ethereum/contracts';
|
|
2
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import type { L1PublishProofStats, L1PublishStats } from '@aztec/stdlib/stats';
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
type TelemetryClient,
|
|
14
14
|
type Tracer,
|
|
15
15
|
type UpDownCounter,
|
|
16
|
-
|
|
16
|
+
createUpDownCounterWithDefault,
|
|
17
17
|
} from '@aztec/telemetry-client';
|
|
18
18
|
|
|
19
19
|
import { formatEther, formatUnits } from 'viem';
|
|
@@ -21,6 +21,7 @@ import { formatEther, formatUnits } from 'viem';
|
|
|
21
21
|
export class ProverNodeJobMetrics {
|
|
22
22
|
proverEpochExecutionDuration: Histogram;
|
|
23
23
|
provingJobDuration: Histogram;
|
|
24
|
+
provingJobCheckpoints: Gauge;
|
|
24
25
|
provingJobBlocks: Gauge;
|
|
25
26
|
provingJobTransactions: Gauge;
|
|
26
27
|
|
|
@@ -29,29 +30,23 @@ export class ProverNodeJobMetrics {
|
|
|
29
30
|
public readonly tracer: Tracer,
|
|
30
31
|
private logger = createLogger('prover-node:publisher:metrics'),
|
|
31
32
|
) {
|
|
32
|
-
this.proverEpochExecutionDuration = this.meter.createHistogram(Metrics.PROVER_NODE_EXECUTION_DURATION
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.provingJobDuration = this.meter.createHistogram(Metrics.PROVER_NODE_JOB_DURATION, {
|
|
38
|
-
description: 'Duration of proving job',
|
|
39
|
-
unit: 's',
|
|
40
|
-
valueType: ValueType.DOUBLE,
|
|
41
|
-
});
|
|
42
|
-
this.provingJobBlocks = this.meter.createGauge(Metrics.PROVER_NODE_JOB_BLOCKS, {
|
|
43
|
-
description: 'Number of blocks in a proven epoch',
|
|
44
|
-
valueType: ValueType.INT,
|
|
45
|
-
});
|
|
46
|
-
this.provingJobTransactions = this.meter.createGauge(Metrics.PROVER_NODE_JOB_TRANSACTIONS, {
|
|
47
|
-
description: 'Number of transactions in a proven epoch',
|
|
48
|
-
valueType: ValueType.INT,
|
|
49
|
-
});
|
|
33
|
+
this.proverEpochExecutionDuration = this.meter.createHistogram(Metrics.PROVER_NODE_EXECUTION_DURATION);
|
|
34
|
+
this.provingJobDuration = this.meter.createHistogram(Metrics.PROVER_NODE_JOB_DURATION);
|
|
35
|
+
this.provingJobCheckpoints = this.meter.createGauge(Metrics.PROVER_NODE_JOB_CHECKPOINTS);
|
|
36
|
+
this.provingJobBlocks = this.meter.createGauge(Metrics.PROVER_NODE_JOB_BLOCKS);
|
|
37
|
+
this.provingJobTransactions = this.meter.createGauge(Metrics.PROVER_NODE_JOB_TRANSACTIONS);
|
|
50
38
|
}
|
|
51
39
|
|
|
52
|
-
public recordProvingJob(
|
|
40
|
+
public recordProvingJob(
|
|
41
|
+
executionTimeMs: number,
|
|
42
|
+
totalTimeMs: number,
|
|
43
|
+
numCheckpoints: number,
|
|
44
|
+
numBlocks: number,
|
|
45
|
+
numTxs: number,
|
|
46
|
+
) {
|
|
53
47
|
this.proverEpochExecutionDuration.record(Math.ceil(executionTimeMs));
|
|
54
48
|
this.provingJobDuration.record(totalTimeMs / 1000);
|
|
49
|
+
this.provingJobCheckpoints.record(Math.floor(numCheckpoints));
|
|
55
50
|
this.provingJobBlocks.record(Math.floor(numBlocks));
|
|
56
51
|
this.provingJobTransactions.record(Math.floor(numTxs));
|
|
57
52
|
}
|
|
@@ -69,15 +64,9 @@ export class ProverNodeRewardsMetrics {
|
|
|
69
64
|
private rollup: RollupContract,
|
|
70
65
|
private logger = createLogger('prover-node:publisher:metrics'),
|
|
71
66
|
) {
|
|
72
|
-
this.rewards = this.meter.createObservableGauge(Metrics.PROVER_NODE_REWARDS_PER_EPOCH
|
|
73
|
-
valueType: ValueType.DOUBLE,
|
|
74
|
-
description: 'The rewards earned',
|
|
75
|
-
});
|
|
67
|
+
this.rewards = this.meter.createObservableGauge(Metrics.PROVER_NODE_REWARDS_PER_EPOCH);
|
|
76
68
|
|
|
77
|
-
this.accumulatedRewards = this.meter
|
|
78
|
-
valueType: ValueType.DOUBLE,
|
|
79
|
-
description: 'The rewards earned (total)',
|
|
80
|
-
});
|
|
69
|
+
this.accumulatedRewards = createUpDownCounterWithDefault(this.meter, Metrics.PROVER_NODE_REWARDS_TOTAL);
|
|
81
70
|
}
|
|
82
71
|
|
|
83
72
|
public async start() {
|
|
@@ -97,7 +86,7 @@ export class ProverNodeRewardsMetrics {
|
|
|
97
86
|
// look at the prev epoch so that we get an accurate value, after proof submission window has closed
|
|
98
87
|
// For example, if proof submission window is 1 epoch, and we are in epoch 2, we should be looking at epoch 0.
|
|
99
88
|
// Similarly, if the proof submission window is 0, and we are in epoch 1, we should be looking at epoch 0.
|
|
100
|
-
const closedEpoch = epoch - BigInt(this.proofSubmissionEpochs) - 1n;
|
|
89
|
+
const closedEpoch = BigInt(epoch) - BigInt(this.proofSubmissionEpochs) - 1n;
|
|
101
90
|
const rewards = await this.rollup.getSpecificProverRewardsForEpoch(closedEpoch, this.coinbase);
|
|
102
91
|
|
|
103
92
|
const fmt = parseFloat(formatUnits(rewards, 18));
|
|
@@ -138,68 +127,28 @@ export class ProverNodePublisherMetrics {
|
|
|
138
127
|
) {
|
|
139
128
|
this.meter = client.getMeter(name);
|
|
140
129
|
|
|
141
|
-
this.gasPrice = this.meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE
|
|
142
|
-
description: 'The gas price used for transactions',
|
|
143
|
-
unit: 'gwei',
|
|
144
|
-
valueType: ValueType.DOUBLE,
|
|
145
|
-
});
|
|
130
|
+
this.gasPrice = this.meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE);
|
|
146
131
|
|
|
147
|
-
this.txCount = this.meter
|
|
148
|
-
|
|
132
|
+
this.txCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_PUBLISHER_TX_COUNT, {
|
|
133
|
+
[Attributes.L1_TX_TYPE]: ['submitProof'],
|
|
134
|
+
[Attributes.OK]: [true, false],
|
|
149
135
|
});
|
|
150
136
|
|
|
151
|
-
this.txDuration = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION
|
|
152
|
-
description: 'The duration of transaction processing',
|
|
153
|
-
unit: 'ms',
|
|
154
|
-
valueType: ValueType.INT,
|
|
155
|
-
});
|
|
137
|
+
this.txDuration = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION);
|
|
156
138
|
|
|
157
|
-
this.txGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS
|
|
158
|
-
description: 'The gas consumed by transactions',
|
|
159
|
-
unit: 'gas',
|
|
160
|
-
valueType: ValueType.INT,
|
|
161
|
-
});
|
|
139
|
+
this.txGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS);
|
|
162
140
|
|
|
163
|
-
this.txCalldataSize = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE
|
|
164
|
-
description: 'The size of the calldata in transactions',
|
|
165
|
-
unit: 'By',
|
|
166
|
-
valueType: ValueType.INT,
|
|
167
|
-
});
|
|
141
|
+
this.txCalldataSize = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE);
|
|
168
142
|
|
|
169
|
-
this.txCalldataGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS
|
|
170
|
-
description: 'The gas consumed by the calldata in transactions',
|
|
171
|
-
unit: 'gas',
|
|
172
|
-
valueType: ValueType.INT,
|
|
173
|
-
});
|
|
143
|
+
this.txCalldataGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS);
|
|
174
144
|
|
|
175
|
-
this.txBlobDataGasUsed = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED
|
|
176
|
-
description: 'The amount of blob gas used in transactions',
|
|
177
|
-
unit: 'gas',
|
|
178
|
-
valueType: ValueType.INT,
|
|
179
|
-
});
|
|
145
|
+
this.txBlobDataGasUsed = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED);
|
|
180
146
|
|
|
181
|
-
this.txBlobDataGasCost = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST
|
|
182
|
-
description: 'The gas cost of blobs in transactions',
|
|
183
|
-
unit: 'gwei',
|
|
184
|
-
valueType: ValueType.INT,
|
|
185
|
-
});
|
|
147
|
+
this.txBlobDataGasCost = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST);
|
|
186
148
|
|
|
187
|
-
this.txTotalFee = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE
|
|
188
|
-
description: 'How much L1 tx costs',
|
|
189
|
-
unit: 'gwei',
|
|
190
|
-
valueType: ValueType.DOUBLE,
|
|
191
|
-
advice: {
|
|
192
|
-
explicitBucketBoundaries: [
|
|
193
|
-
0.001, 0.002, 0.004, 0.008, 0.01, 0.02, 0.04, 0.08, 0.1, 0.2, 0.4, 0.8, 1, 1.2, 1.4, 1.8, 2,
|
|
194
|
-
],
|
|
195
|
-
},
|
|
196
|
-
});
|
|
149
|
+
this.txTotalFee = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE);
|
|
197
150
|
|
|
198
|
-
this.senderBalance = this.meter.createGauge(Metrics.L1_PUBLISHER_BALANCE
|
|
199
|
-
unit: 'eth',
|
|
200
|
-
description: 'The balance of the sender address',
|
|
201
|
-
valueType: ValueType.DOUBLE,
|
|
202
|
-
});
|
|
151
|
+
this.senderBalance = this.meter.createGauge(Metrics.L1_PUBLISHER_BALANCE);
|
|
203
152
|
}
|
|
204
153
|
|
|
205
154
|
recordFailedTx() {
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
+
import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
3
4
|
import { sleep } from '@aztec/foundation/sleep';
|
|
4
5
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
5
6
|
import { type L1RollupConstants, getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
6
|
-
import {
|
|
7
|
-
type TelemetryClient,
|
|
8
|
-
type Traceable,
|
|
9
|
-
type Tracer,
|
|
10
|
-
getTelemetryClient,
|
|
11
|
-
trackSpan,
|
|
12
|
-
} from '@aztec/telemetry-client';
|
|
7
|
+
import { type TelemetryClient, type Traceable, type Tracer, getTelemetryClient } from '@aztec/telemetry-client';
|
|
13
8
|
|
|
14
9
|
export interface EpochMonitorHandler {
|
|
15
|
-
handleEpochReadyToProve(epochNumber:
|
|
10
|
+
handleEpochReadyToProve(epochNumber: EpochNumber): Promise<boolean>;
|
|
16
11
|
}
|
|
17
12
|
|
|
18
13
|
/**
|
|
@@ -32,7 +27,7 @@ export class EpochMonitor implements Traceable {
|
|
|
32
27
|
public readonly tracer: Tracer;
|
|
33
28
|
|
|
34
29
|
private handler: EpochMonitorHandler | undefined;
|
|
35
|
-
private latestEpochNumber:
|
|
30
|
+
private latestEpochNumber: EpochNumber | undefined;
|
|
36
31
|
|
|
37
32
|
constructor(
|
|
38
33
|
private readonly l2BlockSource: L2BlockSource,
|
|
@@ -72,7 +67,6 @@ export class EpochMonitor implements Traceable {
|
|
|
72
67
|
this.log.info('Stopped EpochMonitor');
|
|
73
68
|
}
|
|
74
69
|
|
|
75
|
-
@trackSpan('EpochMonitor.work')
|
|
76
70
|
public async work() {
|
|
77
71
|
const { epochToProve, blockNumber, slotNumber } = await this.getEpochNumberToProve();
|
|
78
72
|
this.log.debug(`Epoch to prove: ${epochToProve}`, { blockNumber, slotNumber });
|
|
@@ -104,7 +98,7 @@ export class EpochMonitor implements Traceable {
|
|
|
104
98
|
|
|
105
99
|
private async getEpochNumberToProve() {
|
|
106
100
|
const lastBlockProven = await this.l2BlockSource.getProvenBlockNumber();
|
|
107
|
-
const firstBlockToProve = lastBlockProven + 1;
|
|
101
|
+
const firstBlockToProve = BlockNumber(lastBlockProven + 1);
|
|
108
102
|
const firstBlockHeaderToProve = await this.l2BlockSource.getBlockHeader(firstBlockToProve);
|
|
109
103
|
if (!firstBlockHeaderToProve) {
|
|
110
104
|
return { epochToProve: undefined, blockNumber: firstBlockToProve };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
1
|
+
import { BatchedBlob, getEthBlobEvaluationInputs } from '@aztec/blob-lib';
|
|
2
|
+
import { MAX_CHECKPOINTS_PER_EPOCH } from '@aztec/constants';
|
|
3
|
+
import type { RollupContract, ViemCommitteeAttestation } from '@aztec/ethereum/contracts';
|
|
4
|
+
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
4
5
|
import { makeTuple } from '@aztec/foundation/array';
|
|
6
|
+
import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
5
7
|
import { areArraysEqual } from '@aztec/foundation/collection';
|
|
8
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
9
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
|
-
import {
|
|
8
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
10
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
9
11
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
10
12
|
import { Timer } from '@aztec/foundation/timer';
|
|
11
13
|
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
@@ -29,7 +31,7 @@ export type L1SubmitEpochProofArgs = {
|
|
|
29
31
|
endTimestamp: Fr;
|
|
30
32
|
outHash: Fr;
|
|
31
33
|
proverId: Fr;
|
|
32
|
-
fees: Tuple<FeeRecipient, typeof
|
|
34
|
+
fees: Tuple<FeeRecipient, typeof MAX_CHECKPOINTS_PER_EPOCH>;
|
|
33
35
|
proof: Proof;
|
|
34
36
|
};
|
|
35
37
|
|
|
@@ -37,7 +39,7 @@ export class ProverNodePublisher {
|
|
|
37
39
|
private interrupted = false;
|
|
38
40
|
private metrics: ProverNodePublisherMetrics;
|
|
39
41
|
|
|
40
|
-
protected log
|
|
42
|
+
protected log: Logger;
|
|
41
43
|
|
|
42
44
|
protected rollupContract: RollupContract;
|
|
43
45
|
|
|
@@ -50,10 +52,12 @@ export class ProverNodePublisher {
|
|
|
50
52
|
l1TxUtils: L1TxUtils;
|
|
51
53
|
telemetry?: TelemetryClient;
|
|
52
54
|
},
|
|
55
|
+
bindings?: LoggerBindings,
|
|
53
56
|
) {
|
|
54
57
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
55
58
|
|
|
56
59
|
this.metrics = new ProverNodePublisherMetrics(telemetry, 'ProverNode');
|
|
60
|
+
this.log = createLogger('prover-node:l1-tx-publisher', bindings);
|
|
57
61
|
|
|
58
62
|
this.rollupContract = deps.rollupContract;
|
|
59
63
|
this.l1TxUtils = deps.l1TxUtils;
|
|
@@ -85,16 +89,16 @@ export class ProverNodePublisher {
|
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
public async submitEpochProof(args: {
|
|
88
|
-
epochNumber:
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
epochNumber: EpochNumber;
|
|
93
|
+
fromCheckpoint: CheckpointNumber;
|
|
94
|
+
toCheckpoint: CheckpointNumber;
|
|
91
95
|
publicInputs: RootRollupPublicInputs;
|
|
92
96
|
proof: Proof;
|
|
93
97
|
batchedBlobInputs: BatchedBlob;
|
|
94
98
|
attestations: ViemCommitteeAttestation[];
|
|
95
99
|
}): Promise<boolean> {
|
|
96
|
-
const { epochNumber,
|
|
97
|
-
const ctx = { epochNumber,
|
|
100
|
+
const { epochNumber, fromCheckpoint, toCheckpoint } = args;
|
|
101
|
+
const ctx = { epochNumber, fromCheckpoint, toCheckpoint };
|
|
98
102
|
|
|
99
103
|
if (!this.interrupted) {
|
|
100
104
|
const timer = new Timer();
|
|
@@ -103,6 +107,7 @@ export class ProverNodePublisher {
|
|
|
103
107
|
|
|
104
108
|
const txReceipt = await this.sendSubmitEpochProofTx(args);
|
|
105
109
|
if (!txReceipt) {
|
|
110
|
+
this.log.error(`Failed to mine submitEpochProof tx`, undefined, ctx);
|
|
106
111
|
return false;
|
|
107
112
|
}
|
|
108
113
|
|
|
@@ -135,47 +140,51 @@ export class ProverNodePublisher {
|
|
|
135
140
|
}
|
|
136
141
|
|
|
137
142
|
this.metrics.recordFailedTx();
|
|
138
|
-
this.log.error(`Rollup
|
|
143
|
+
this.log.error(`Rollup submitEpochProof tx reverted ${txReceipt.transactionHash}`, undefined, ctx);
|
|
139
144
|
}
|
|
140
145
|
|
|
141
|
-
this.log.verbose('
|
|
146
|
+
this.log.verbose('Checkpoint data syncing interrupted', ctx);
|
|
142
147
|
return false;
|
|
143
148
|
}
|
|
144
149
|
|
|
145
150
|
private async validateEpochProofSubmission(args: {
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
fromCheckpoint: CheckpointNumber;
|
|
152
|
+
toCheckpoint: CheckpointNumber;
|
|
148
153
|
publicInputs: RootRollupPublicInputs;
|
|
149
154
|
proof: Proof;
|
|
150
155
|
batchedBlobInputs: BatchedBlob;
|
|
151
156
|
attestations: ViemCommitteeAttestation[];
|
|
152
157
|
}) {
|
|
153
|
-
const {
|
|
158
|
+
const { fromCheckpoint, toCheckpoint, publicInputs, batchedBlobInputs } = args;
|
|
154
159
|
|
|
155
|
-
// Check that the
|
|
156
|
-
const {
|
|
157
|
-
// Don't publish if proven is beyond our
|
|
158
|
-
if (proven >
|
|
159
|
-
throw new Error(
|
|
160
|
+
// Check that the checkpoint numbers match the expected epoch to be proven
|
|
161
|
+
const { pending, proven } = await this.rollupContract.getTips();
|
|
162
|
+
// Don't publish if proven is beyond our toCheckpoint, pointless to do so
|
|
163
|
+
if (proven > toCheckpoint) {
|
|
164
|
+
throw new Error(
|
|
165
|
+
`Cannot submit epoch proof for ${fromCheckpoint}-${toCheckpoint} as proven checkpoint is ${proven}`,
|
|
166
|
+
);
|
|
160
167
|
}
|
|
161
|
-
//
|
|
162
|
-
if (
|
|
163
|
-
throw new Error(
|
|
168
|
+
// toCheckpoint can't be greater than pending
|
|
169
|
+
if (toCheckpoint > pending) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
`Cannot submit epoch proof for ${fromCheckpoint}-${toCheckpoint} as pending checkpoint is ${pending}`,
|
|
172
|
+
);
|
|
164
173
|
}
|
|
165
174
|
|
|
166
|
-
// Check the archive for the immediate
|
|
167
|
-
const
|
|
168
|
-
if (publicInputs.previousArchiveRoot.
|
|
175
|
+
// Check the archive for the immediate checkpoint before the epoch
|
|
176
|
+
const checkpointLog = await this.rollupContract.getCheckpoint(CheckpointNumber(fromCheckpoint - 1));
|
|
177
|
+
if (!publicInputs.previousArchiveRoot.equals(checkpointLog.archive)) {
|
|
169
178
|
throw new Error(
|
|
170
|
-
`Previous archive root mismatch: ${publicInputs.previousArchiveRoot.toString()} !== ${
|
|
179
|
+
`Previous archive root mismatch: ${publicInputs.previousArchiveRoot.toString()} !== ${checkpointLog.archive.toString()}`,
|
|
171
180
|
);
|
|
172
181
|
}
|
|
173
182
|
|
|
174
|
-
// Check the archive for the last
|
|
175
|
-
const
|
|
176
|
-
if (publicInputs.endArchiveRoot.
|
|
183
|
+
// Check the archive for the last checkpoint in the epoch
|
|
184
|
+
const endCheckpointLog = await this.rollupContract.getCheckpoint(toCheckpoint);
|
|
185
|
+
if (!publicInputs.endArchiveRoot.equals(endCheckpointLog.archive)) {
|
|
177
186
|
throw new Error(
|
|
178
|
-
`End archive root mismatch: ${publicInputs.endArchiveRoot.toString()} !== ${
|
|
187
|
+
`End archive root mismatch: ${publicInputs.endArchiveRoot.toString()} !== ${endCheckpointLog.archive.toString()}`,
|
|
179
188
|
);
|
|
180
189
|
}
|
|
181
190
|
|
|
@@ -193,7 +202,7 @@ export class ProverNodePublisher {
|
|
|
193
202
|
);
|
|
194
203
|
const argsPublicInputs = [...publicInputs.toFields()];
|
|
195
204
|
|
|
196
|
-
if (!areArraysEqual(rollupPublicInputs
|
|
205
|
+
if (!areArraysEqual(rollupPublicInputs, argsPublicInputs, (a, b) => a.equals(b))) {
|
|
197
206
|
const fmt = (inputs: Fr[] | readonly string[]) => inputs.map(x => x.toString()).join(', ');
|
|
198
207
|
throw new Error(
|
|
199
208
|
`Root rollup public inputs mismatch:\nRollup: ${fmt(rollupPublicInputs)}\nComputed:${fmt(argsPublicInputs)}`,
|
|
@@ -202,8 +211,8 @@ export class ProverNodePublisher {
|
|
|
202
211
|
}
|
|
203
212
|
|
|
204
213
|
private async sendSubmitEpochProofTx(args: {
|
|
205
|
-
|
|
206
|
-
|
|
214
|
+
fromCheckpoint: CheckpointNumber;
|
|
215
|
+
toCheckpoint: CheckpointNumber;
|
|
207
216
|
publicInputs: RootRollupPublicInputs;
|
|
208
217
|
proof: Proof;
|
|
209
218
|
batchedBlobInputs: BatchedBlob;
|
|
@@ -213,8 +222,8 @@ export class ProverNodePublisher {
|
|
|
213
222
|
|
|
214
223
|
this.log.info(`Submitting epoch proof to L1 rollup contract`, {
|
|
215
224
|
proofSize: args.proof.withoutPublicInputs().length,
|
|
216
|
-
|
|
217
|
-
|
|
225
|
+
fromCheckpoint: args.fromCheckpoint,
|
|
226
|
+
toCheckpoint: args.toCheckpoint,
|
|
218
227
|
});
|
|
219
228
|
const data = encodeFunctionData({
|
|
220
229
|
abi: RollupAbi,
|
|
@@ -223,53 +232,57 @@ export class ProverNodePublisher {
|
|
|
223
232
|
});
|
|
224
233
|
try {
|
|
225
234
|
const { receipt } = await this.l1TxUtils.sendAndMonitorTransaction({ to: this.rollupContract.address, data });
|
|
235
|
+
if (receipt.status !== 'success') {
|
|
236
|
+
const errorMsg = await this.l1TxUtils.tryGetErrorFromRevertedTx(
|
|
237
|
+
data,
|
|
238
|
+
{
|
|
239
|
+
args: [...txArgs],
|
|
240
|
+
functionName: 'submitEpochRootProof',
|
|
241
|
+
abi: RollupAbi,
|
|
242
|
+
address: this.rollupContract.address,
|
|
243
|
+
},
|
|
244
|
+
/*blobInputs*/ undefined,
|
|
245
|
+
/*stateOverride*/ [],
|
|
246
|
+
);
|
|
247
|
+
this.log.error(`Rollup submit epoch proof tx reverted with ${errorMsg ?? 'unknown error'}`);
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
226
250
|
return receipt;
|
|
227
251
|
} catch (err) {
|
|
228
252
|
this.log.error(`Rollup submit epoch proof failed`, err);
|
|
229
|
-
const errorMsg = await this.l1TxUtils.tryGetErrorFromRevertedTx(
|
|
230
|
-
data,
|
|
231
|
-
{
|
|
232
|
-
args: [...txArgs],
|
|
233
|
-
functionName: 'submitEpochRootProof',
|
|
234
|
-
abi: RollupAbi,
|
|
235
|
-
address: this.rollupContract.address,
|
|
236
|
-
},
|
|
237
|
-
/*blobInputs*/ undefined,
|
|
238
|
-
/*stateOverride*/ [],
|
|
239
|
-
);
|
|
240
|
-
this.log.error(`Rollup submit epoch proof tx reverted. ${errorMsg}`);
|
|
241
253
|
return undefined;
|
|
242
254
|
}
|
|
243
255
|
}
|
|
244
256
|
|
|
245
257
|
private getEpochProofPublicInputsArgs(args: {
|
|
246
|
-
|
|
247
|
-
|
|
258
|
+
fromCheckpoint: CheckpointNumber;
|
|
259
|
+
toCheckpoint: CheckpointNumber;
|
|
248
260
|
publicInputs: RootRollupPublicInputs;
|
|
249
261
|
batchedBlobInputs: BatchedBlob;
|
|
250
262
|
attestations: ViemCommitteeAttestation[];
|
|
251
263
|
}) {
|
|
252
264
|
// Returns arguments for EpochProofLib.sol -> getEpochProofPublicInputs()
|
|
253
265
|
return [
|
|
254
|
-
BigInt(args.
|
|
255
|
-
BigInt(args.
|
|
266
|
+
BigInt(args.fromCheckpoint) /*_start*/,
|
|
267
|
+
BigInt(args.toCheckpoint) /*_end*/,
|
|
256
268
|
{
|
|
257
269
|
previousArchive: args.publicInputs.previousArchiveRoot.toString(),
|
|
258
270
|
endArchive: args.publicInputs.endArchiveRoot.toString(),
|
|
271
|
+
outHash: args.publicInputs.outHash.toString(),
|
|
259
272
|
proverId: EthAddress.fromField(args.publicInputs.constants.proverId).toString(),
|
|
260
273
|
} /*_args*/,
|
|
261
|
-
makeTuple(
|
|
274
|
+
makeTuple(MAX_CHECKPOINTS_PER_EPOCH * 2, i =>
|
|
262
275
|
i % 2 === 0
|
|
263
276
|
? args.publicInputs.fees[i / 2].recipient.toField().toString()
|
|
264
277
|
: args.publicInputs.fees[(i - 1) / 2].value.toString(),
|
|
265
278
|
) /*_fees*/,
|
|
266
|
-
args.batchedBlobInputs
|
|
279
|
+
getEthBlobEvaluationInputs(args.batchedBlobInputs) /*_blobPublicInputs*/,
|
|
267
280
|
] as const;
|
|
268
281
|
}
|
|
269
282
|
|
|
270
283
|
private getSubmitEpochProofArgs(args: {
|
|
271
|
-
|
|
272
|
-
|
|
284
|
+
fromCheckpoint: CheckpointNumber;
|
|
285
|
+
toCheckpoint: CheckpointNumber;
|
|
273
286
|
publicInputs: RootRollupPublicInputs;
|
|
274
287
|
proof: Proof;
|
|
275
288
|
batchedBlobInputs: BatchedBlob;
|