@aztec/validator-client 0.0.1-commit.c80b6263 → 0.0.1-commit.c949de6bc
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/README.md +21 -18
- package/dest/block_proposal_handler.d.ts +2 -2
- package/dest/block_proposal_handler.d.ts.map +1 -1
- package/dest/block_proposal_handler.js +20 -34
- package/dest/checkpoint_builder.d.ts +10 -11
- package/dest/checkpoint_builder.d.ts.map +1 -1
- package/dest/checkpoint_builder.js +37 -24
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +5 -1
- package/dest/duties/validation_service.d.ts +2 -2
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +3 -3
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/key_store/ha_key_store.d.ts +1 -1
- package/dest/key_store/ha_key_store.d.ts.map +1 -1
- package/dest/key_store/ha_key_store.js +2 -2
- package/dest/validator.d.ts +33 -8
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +165 -28
- package/package.json +19 -19
- package/src/block_proposal_handler.ts +28 -48
- package/src/checkpoint_builder.ts +35 -17
- package/src/config.ts +5 -1
- package/src/duties/validation_service.ts +9 -2
- package/src/index.ts +0 -1
- package/src/key_store/ha_key_store.ts +2 -2
- package/src/validator.ts +219 -35
- package/dest/tx_validator/index.d.ts +0 -3
- package/dest/tx_validator/index.d.ts.map +0 -1
- package/dest/tx_validator/index.js +0 -2
- package/dest/tx_validator/nullifier_cache.d.ts +0 -14
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -19
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -54
- package/src/tx_validator/index.ts +0 -2
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -154
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/validator-client",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.c949de6bc",
|
|
4
4
|
"main": "dest/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -64,30 +64,30 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/blob-client": "0.0.1-commit.
|
|
68
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
69
|
-
"@aztec/constants": "0.0.1-commit.
|
|
70
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
71
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
72
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
73
|
-
"@aztec/node-keystore": "0.0.1-commit.
|
|
74
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
75
|
-
"@aztec/p2p": "0.0.1-commit.
|
|
76
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
77
|
-
"@aztec/prover-client": "0.0.1-commit.
|
|
78
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
79
|
-
"@aztec/slasher": "0.0.1-commit.
|
|
80
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
81
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
82
|
-
"@aztec/validator-ha-signer": "0.0.1-commit.
|
|
67
|
+
"@aztec/blob-client": "0.0.1-commit.c949de6bc",
|
|
68
|
+
"@aztec/blob-lib": "0.0.1-commit.c949de6bc",
|
|
69
|
+
"@aztec/constants": "0.0.1-commit.c949de6bc",
|
|
70
|
+
"@aztec/epoch-cache": "0.0.1-commit.c949de6bc",
|
|
71
|
+
"@aztec/ethereum": "0.0.1-commit.c949de6bc",
|
|
72
|
+
"@aztec/foundation": "0.0.1-commit.c949de6bc",
|
|
73
|
+
"@aztec/node-keystore": "0.0.1-commit.c949de6bc",
|
|
74
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.c949de6bc",
|
|
75
|
+
"@aztec/p2p": "0.0.1-commit.c949de6bc",
|
|
76
|
+
"@aztec/protocol-contracts": "0.0.1-commit.c949de6bc",
|
|
77
|
+
"@aztec/prover-client": "0.0.1-commit.c949de6bc",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.c949de6bc",
|
|
79
|
+
"@aztec/slasher": "0.0.1-commit.c949de6bc",
|
|
80
|
+
"@aztec/stdlib": "0.0.1-commit.c949de6bc",
|
|
81
|
+
"@aztec/telemetry-client": "0.0.1-commit.c949de6bc",
|
|
82
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.c949de6bc",
|
|
83
83
|
"koa": "^2.16.1",
|
|
84
84
|
"koa-router": "^13.1.1",
|
|
85
85
|
"tslib": "^2.4.0",
|
|
86
86
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
90
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
89
|
+
"@aztec/archiver": "0.0.1-commit.c949de6bc",
|
|
90
|
+
"@aztec/world-state": "0.0.1-commit.c949de6bc",
|
|
91
91
|
"@electric-sql/pglite": "^0.3.14",
|
|
92
92
|
"@jest/globals": "^30.0.0",
|
|
93
93
|
"@types/jest": "^30.0.0",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
2
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
3
3
|
import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
|
-
import { chunkBy } from '@aztec/foundation/collection';
|
|
5
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
5
|
import { TimeoutError } from '@aztec/foundation/error';
|
|
7
6
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -9,16 +8,12 @@ import { retryUntil } from '@aztec/foundation/retry';
|
|
|
9
8
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
10
9
|
import type { P2P, PeerId } from '@aztec/p2p';
|
|
11
10
|
import { BlockProposalValidator } from '@aztec/p2p/msg_validators';
|
|
12
|
-
import type { L2Block, L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
11
|
+
import type { BlockData, L2Block, L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
13
12
|
import { getEpochAtSlot, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
14
13
|
import type { ITxProvider, ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
15
|
-
import {
|
|
16
|
-
type L1ToL2MessageSource,
|
|
17
|
-
computeCheckpointOutHash,
|
|
18
|
-
computeInHashFromL1ToL2Messages,
|
|
19
|
-
} from '@aztec/stdlib/messaging';
|
|
14
|
+
import { type L1ToL2MessageSource, computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
20
15
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
21
|
-
import {
|
|
16
|
+
import type { CheckpointGlobalVariables, FailedTx, Tx } from '@aztec/stdlib/tx';
|
|
22
17
|
import {
|
|
23
18
|
ReExFailedTxsError,
|
|
24
19
|
ReExStateMismatchError,
|
|
@@ -153,16 +148,16 @@ export class BlockProposalHandler {
|
|
|
153
148
|
}
|
|
154
149
|
|
|
155
150
|
// Check that the parent proposal is a block we know, otherwise reexecution would fail
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
151
|
+
const parentBlock = await this.getParentBlock(proposal);
|
|
152
|
+
if (parentBlock === undefined) {
|
|
158
153
|
this.log.warn(`Parent block for proposal not found, skipping processing`, proposalInfo);
|
|
159
154
|
return { isValid: false, reason: 'parent_block_not_found' };
|
|
160
155
|
}
|
|
161
156
|
|
|
162
157
|
// Check that the parent block's slot is not greater than the proposal's slot.
|
|
163
|
-
if (
|
|
158
|
+
if (parentBlock !== 'genesis' && parentBlock.header.getSlot() > slotNumber) {
|
|
164
159
|
this.log.warn(`Parent block slot is greater than proposal slot, skipping processing`, {
|
|
165
|
-
parentBlockSlot:
|
|
160
|
+
parentBlockSlot: parentBlock.header.getSlot().toString(),
|
|
166
161
|
proposalSlot: slotNumber.toString(),
|
|
167
162
|
...proposalInfo,
|
|
168
163
|
});
|
|
@@ -171,9 +166,9 @@ export class BlockProposalHandler {
|
|
|
171
166
|
|
|
172
167
|
// Compute the block number based on the parent block
|
|
173
168
|
const blockNumber =
|
|
174
|
-
|
|
169
|
+
parentBlock === 'genesis'
|
|
175
170
|
? BlockNumber(INITIAL_L2_BLOCK_NUM)
|
|
176
|
-
: BlockNumber(
|
|
171
|
+
: BlockNumber(parentBlock.header.getBlockNumber() + 1);
|
|
177
172
|
|
|
178
173
|
// Check that this block number does not exist already
|
|
179
174
|
const existingBlock = await this.blockSource.getBlockHeader(blockNumber);
|
|
@@ -190,7 +185,7 @@ export class BlockProposalHandler {
|
|
|
190
185
|
});
|
|
191
186
|
|
|
192
187
|
// Compute the checkpoint number for this block and validate checkpoint consistency
|
|
193
|
-
const checkpointResult =
|
|
188
|
+
const checkpointResult = this.computeCheckpointNumber(proposal, parentBlock, proposalInfo);
|
|
194
189
|
if (checkpointResult.reason) {
|
|
195
190
|
return { isValid: false, blockNumber, reason: checkpointResult.reason };
|
|
196
191
|
}
|
|
@@ -218,17 +213,11 @@ export class BlockProposalHandler {
|
|
|
218
213
|
// Try re-executing the transactions in the proposal if needed
|
|
219
214
|
let reexecutionResult;
|
|
220
215
|
if (shouldReexecute) {
|
|
221
|
-
//
|
|
222
|
-
// TODO(leila/mbps): There can be a more efficient way to get the previous checkpoint out
|
|
223
|
-
// hashes without having to fetch all the blocks.
|
|
216
|
+
// Collect the out hashes of all the checkpoints before this one in the same epoch
|
|
224
217
|
const epoch = getEpochAtSlot(slotNumber, this.epochCache.getL1Constants());
|
|
225
|
-
const
|
|
226
|
-
.filter(
|
|
227
|
-
.
|
|
228
|
-
const blocksByCheckpoint = chunkBy(checkpointedBlocks, b => b.checkpointNumber);
|
|
229
|
-
const previousCheckpointOutHashes = blocksByCheckpoint.map(checkpointBlocks =>
|
|
230
|
-
computeCheckpointOutHash(checkpointBlocks.map(b => b.block.body.txEffects.map(tx => tx.l2ToL1Msgs))),
|
|
231
|
-
);
|
|
218
|
+
const previousCheckpointOutHashes = (await this.blockSource.getCheckpointsDataForEpoch(epoch))
|
|
219
|
+
.filter(c => c.checkpointNumber < checkpointNumber)
|
|
220
|
+
.map(c => c.checkpointOutHash);
|
|
232
221
|
|
|
233
222
|
try {
|
|
234
223
|
this.log.verbose(`Re-executing transactions in the proposal`, proposalInfo);
|
|
@@ -260,7 +249,7 @@ export class BlockProposalHandler {
|
|
|
260
249
|
return { isValid: true, blockNumber, reexecutionResult };
|
|
261
250
|
}
|
|
262
251
|
|
|
263
|
-
private async getParentBlock(proposal: BlockProposal): Promise<'genesis' |
|
|
252
|
+
private async getParentBlock(proposal: BlockProposal): Promise<'genesis' | BlockData | undefined> {
|
|
264
253
|
const parentArchive = proposal.blockHeader.lastArchive.root;
|
|
265
254
|
const slot = proposal.slotNumber;
|
|
266
255
|
const config = this.checkpointsBuilder.getConfig();
|
|
@@ -276,12 +265,11 @@ export class BlockProposalHandler {
|
|
|
276
265
|
|
|
277
266
|
try {
|
|
278
267
|
return (
|
|
279
|
-
(await this.blockSource.
|
|
268
|
+
(await this.blockSource.getBlockDataByArchive(parentArchive)) ??
|
|
280
269
|
(timeoutDurationMs <= 0
|
|
281
270
|
? undefined
|
|
282
271
|
: await retryUntil(
|
|
283
|
-
() =>
|
|
284
|
-
this.blockSource.syncImmediate().then(() => this.blockSource.getBlockHeaderByArchive(parentArchive)),
|
|
272
|
+
() => this.blockSource.syncImmediate().then(() => this.blockSource.getBlockDataByArchive(parentArchive)),
|
|
285
273
|
'force archiver sync',
|
|
286
274
|
timeoutDurationMs / 1000,
|
|
287
275
|
0.5,
|
|
@@ -297,12 +285,12 @@ export class BlockProposalHandler {
|
|
|
297
285
|
}
|
|
298
286
|
}
|
|
299
287
|
|
|
300
|
-
private
|
|
288
|
+
private computeCheckpointNumber(
|
|
301
289
|
proposal: BlockProposal,
|
|
302
|
-
|
|
290
|
+
parentBlock: 'genesis' | BlockData,
|
|
303
291
|
proposalInfo: object,
|
|
304
|
-
):
|
|
305
|
-
if (
|
|
292
|
+
): CheckpointComputationResult {
|
|
293
|
+
if (parentBlock === 'genesis') {
|
|
306
294
|
// First block is in checkpoint 1
|
|
307
295
|
if (proposal.indexWithinCheckpoint !== 0) {
|
|
308
296
|
this.log.warn(`First block proposal has non-zero indexWithinCheckpoint`, proposalInfo);
|
|
@@ -311,19 +299,9 @@ export class BlockProposalHandler {
|
|
|
311
299
|
return { checkpointNumber: CheckpointNumber.INITIAL };
|
|
312
300
|
}
|
|
313
301
|
|
|
314
|
-
// Get the parent block to find its checkpoint number
|
|
315
|
-
// TODO(palla/mbps): The block header should include the checkpoint number to avoid this lookup,
|
|
316
|
-
// or at least the L2BlockSource should return a different struct that includes it.
|
|
317
|
-
const parentBlockNumber = parentBlockHeader.getBlockNumber();
|
|
318
|
-
const parentBlock = await this.blockSource.getL2Block(parentBlockNumber);
|
|
319
|
-
if (!parentBlock) {
|
|
320
|
-
this.log.warn(`Parent block ${parentBlockNumber} not found in archiver`, proposalInfo);
|
|
321
|
-
return { reason: 'invalid_proposal' };
|
|
322
|
-
}
|
|
323
|
-
|
|
324
302
|
if (proposal.indexWithinCheckpoint === 0) {
|
|
325
303
|
// If this is the first block in a new checkpoint, increment the checkpoint number
|
|
326
|
-
if (!(proposal.blockHeader.getSlot() >
|
|
304
|
+
if (!(proposal.blockHeader.getSlot() > parentBlock.header.getSlot())) {
|
|
327
305
|
this.log.warn(`Slot should be greater than parent block slot for first block in checkpoint`, proposalInfo);
|
|
328
306
|
return { reason: 'invalid_proposal' };
|
|
329
307
|
}
|
|
@@ -335,7 +313,7 @@ export class BlockProposalHandler {
|
|
|
335
313
|
this.log.warn(`Non-sequential indexWithinCheckpoint`, proposalInfo);
|
|
336
314
|
return { reason: 'invalid_proposal' };
|
|
337
315
|
}
|
|
338
|
-
if (proposal.blockHeader.getSlot() !==
|
|
316
|
+
if (proposal.blockHeader.getSlot() !== parentBlock.header.getSlot()) {
|
|
339
317
|
this.log.warn(`Slot should be equal to parent block slot for non-first block in checkpoint`, proposalInfo);
|
|
340
318
|
return { reason: 'invalid_proposal' };
|
|
341
319
|
}
|
|
@@ -356,7 +334,7 @@ export class BlockProposalHandler {
|
|
|
356
334
|
*/
|
|
357
335
|
private validateNonFirstBlockInCheckpoint(
|
|
358
336
|
proposal: BlockProposal,
|
|
359
|
-
parentBlock:
|
|
337
|
+
parentBlock: BlockData,
|
|
360
338
|
proposalInfo: object,
|
|
361
339
|
): CheckpointComputationResult | undefined {
|
|
362
340
|
const proposalGlobals = proposal.blockHeader.globalVariables;
|
|
@@ -475,13 +453,14 @@ export class BlockProposalHandler {
|
|
|
475
453
|
// Fork before the block to be built
|
|
476
454
|
const parentBlockNumber = BlockNumber(blockNumber - 1);
|
|
477
455
|
await this.worldState.syncImmediate(parentBlockNumber);
|
|
478
|
-
using fork = await this.worldState.fork(parentBlockNumber);
|
|
456
|
+
await using fork = await this.worldState.fork(parentBlockNumber);
|
|
479
457
|
|
|
480
|
-
// Build checkpoint constants from proposal (excludes blockNumber
|
|
458
|
+
// Build checkpoint constants from proposal (excludes blockNumber which is per-block)
|
|
481
459
|
const constants: CheckpointGlobalVariables = {
|
|
482
460
|
chainId: new Fr(config.l1ChainId),
|
|
483
461
|
version: new Fr(config.rollupVersion),
|
|
484
462
|
slotNumber: slot,
|
|
463
|
+
timestamp: blockHeader.globalVariables.timestamp,
|
|
485
464
|
coinbase: blockHeader.globalVariables.coinbase,
|
|
486
465
|
feeRecipient: blockHeader.globalVariables.feeRecipient,
|
|
487
466
|
gasFees: blockHeader.globalVariables.gasFees,
|
|
@@ -491,6 +470,7 @@ export class BlockProposalHandler {
|
|
|
491
470
|
const checkpointBuilder = await this.checkpointsBuilder.openCheckpoint(
|
|
492
471
|
checkpointNumber,
|
|
493
472
|
constants,
|
|
473
|
+
0n, // only takes effect in the following checkpoint.
|
|
494
474
|
l1ToL2Messages,
|
|
495
475
|
previousCheckpointOutHashes,
|
|
496
476
|
fork,
|
|
@@ -3,8 +3,8 @@ import { merge, pick } from '@aztec/foundation/collection';
|
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
6
|
-
import { DateProvider,
|
|
7
|
-
import { getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
|
|
6
|
+
import { DateProvider, elapsed } from '@aztec/foundation/timer';
|
|
7
|
+
import { createTxValidatorForBlockBuilding, getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
|
|
8
8
|
import { LightweightCheckpointBuilder } from '@aztec/prover-client/light';
|
|
9
9
|
import {
|
|
10
10
|
GuardedMerkleTreeOperations,
|
|
@@ -24,23 +24,18 @@ import {
|
|
|
24
24
|
type ICheckpointBlockBuilder,
|
|
25
25
|
type ICheckpointsBuilder,
|
|
26
26
|
type MerkleTreeWriteOperations,
|
|
27
|
+
NoValidTxsError,
|
|
27
28
|
type PublicProcessorLimits,
|
|
28
29
|
type WorldStateSynchronizer,
|
|
29
30
|
} from '@aztec/stdlib/interfaces/server';
|
|
31
|
+
import { type DebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
30
32
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
31
33
|
import { type CheckpointGlobalVariables, GlobalVariables, StateReference, Tx } from '@aztec/stdlib/tx';
|
|
32
34
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
33
35
|
|
|
34
|
-
import { createValidatorForBlockBuilding } from './tx_validator/tx_validator_factory.js';
|
|
35
|
-
|
|
36
36
|
// Re-export for backward compatibility
|
|
37
37
|
export type { BuildBlockInCheckpointResult } from '@aztec/stdlib/interfaces/server';
|
|
38
38
|
|
|
39
|
-
/** Result of building a block within a checkpoint. Extends the base interface with timer. */
|
|
40
|
-
export interface BuildBlockInCheckpointResultWithTimer extends BuildBlockInCheckpointResult {
|
|
41
|
-
blockBuildingTimer: Timer;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
39
|
/**
|
|
45
40
|
* Builder for a single checkpoint. Handles building blocks within the checkpoint
|
|
46
41
|
* and completing it.
|
|
@@ -56,6 +51,7 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
56
51
|
private dateProvider: DateProvider,
|
|
57
52
|
private telemetryClient: TelemetryClient,
|
|
58
53
|
bindings?: LoggerBindings,
|
|
54
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
59
55
|
) {
|
|
60
56
|
this.log = createLogger('checkpoint-builder', {
|
|
61
57
|
...bindings,
|
|
@@ -75,8 +71,7 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
75
71
|
blockNumber: BlockNumber,
|
|
76
72
|
timestamp: bigint,
|
|
77
73
|
opts: PublicProcessorLimits & { expectedEndState?: StateReference } = {},
|
|
78
|
-
): Promise<
|
|
79
|
-
const blockBuildingTimer = new Timer();
|
|
74
|
+
): Promise<BuildBlockInCheckpointResult> {
|
|
80
75
|
const slot = this.checkpointBuilder.constants.slotNumber;
|
|
81
76
|
|
|
82
77
|
this.log.verbose(`Building block ${blockNumber} for slot ${slot} within checkpoint`, {
|
|
@@ -103,26 +98,35 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
103
98
|
processor.process(pendingTxs, opts, validator),
|
|
104
99
|
);
|
|
105
100
|
|
|
101
|
+
// Throw if we didn't collect a single valid tx and we're not allowed to build empty blocks
|
|
102
|
+
// (only the first block in a checkpoint can be empty)
|
|
103
|
+
if (processedTxs.length === 0 && this.checkpointBuilder.getBlockCount() > 0) {
|
|
104
|
+
throw new NoValidTxsError(failedTxs);
|
|
105
|
+
}
|
|
106
|
+
|
|
106
107
|
// Add block to checkpoint
|
|
107
|
-
const block = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
|
|
108
|
+
const { block } = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
|
|
108
109
|
expectedEndState: opts.expectedEndState,
|
|
109
110
|
});
|
|
110
111
|
|
|
111
112
|
// How much public gas was processed
|
|
112
113
|
const publicGas = processedTxs.reduce((acc, tx) => acc.add(tx.gasUsed.publicGas), Gas.empty());
|
|
113
114
|
|
|
114
|
-
|
|
115
|
+
this.log.debug('Built block within checkpoint', {
|
|
116
|
+
header: block.header.toInspect(),
|
|
117
|
+
processedTxs: processedTxs.map(tx => tx.hash.toString()),
|
|
118
|
+
failedTxs: failedTxs.map(tx => tx.tx.txHash.toString()),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
return {
|
|
115
122
|
block,
|
|
116
123
|
publicGas,
|
|
117
124
|
publicProcessorDuration,
|
|
118
125
|
numTxs: processedTxs.length,
|
|
119
126
|
failedTxs,
|
|
120
|
-
blockBuildingTimer,
|
|
121
127
|
usedTxs,
|
|
122
128
|
usedTxBlobFields,
|
|
123
129
|
};
|
|
124
|
-
this.log.debug('Built block within checkpoint', res.block.header);
|
|
125
|
-
return res;
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
/** Completes the checkpoint and returns it. */
|
|
@@ -148,6 +152,8 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
148
152
|
const contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
|
|
149
153
|
const guardedFork = new GuardedMerkleTreeOperations(fork);
|
|
150
154
|
|
|
155
|
+
const collectDebugLogs = this.debugLogStore.isEnabled;
|
|
156
|
+
|
|
151
157
|
const bindings = this.log.getBindings();
|
|
152
158
|
const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(
|
|
153
159
|
guardedFork,
|
|
@@ -155,6 +161,7 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
155
161
|
globalVariables,
|
|
156
162
|
this.telemetryClient,
|
|
157
163
|
bindings,
|
|
164
|
+
collectDebugLogs,
|
|
158
165
|
);
|
|
159
166
|
|
|
160
167
|
const processor = new PublicProcessor(
|
|
@@ -166,9 +173,10 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
166
173
|
this.telemetryClient,
|
|
167
174
|
createLogger('simulator:public-processor', bindings),
|
|
168
175
|
this.config,
|
|
176
|
+
this.debugLogStore,
|
|
169
177
|
);
|
|
170
178
|
|
|
171
|
-
const validator =
|
|
179
|
+
const validator = createTxValidatorForBlockBuilding(
|
|
172
180
|
fork,
|
|
173
181
|
this.contractDataSource,
|
|
174
182
|
globalVariables,
|
|
@@ -193,6 +201,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
193
201
|
private contractDataSource: ContractDataSource,
|
|
194
202
|
private dateProvider: DateProvider,
|
|
195
203
|
private telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
204
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
196
205
|
) {
|
|
197
206
|
this.log = createLogger('checkpoint-builder');
|
|
198
207
|
}
|
|
@@ -211,6 +220,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
211
220
|
async startCheckpoint(
|
|
212
221
|
checkpointNumber: CheckpointNumber,
|
|
213
222
|
constants: CheckpointGlobalVariables,
|
|
223
|
+
feeAssetPriceModifier: bigint,
|
|
214
224
|
l1ToL2Messages: Fr[],
|
|
215
225
|
previousCheckpointOutHashes: Fr[],
|
|
216
226
|
fork: MerkleTreeWriteOperations,
|
|
@@ -225,6 +235,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
225
235
|
initialStateReference: stateReference.toInspect(),
|
|
226
236
|
initialArchiveRoot: bufferToHex(archiveTree.root),
|
|
227
237
|
constants,
|
|
238
|
+
feeAssetPriceModifier,
|
|
228
239
|
});
|
|
229
240
|
|
|
230
241
|
const lightweightBuilder = await LightweightCheckpointBuilder.startNewCheckpoint(
|
|
@@ -234,6 +245,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
234
245
|
previousCheckpointOutHashes,
|
|
235
246
|
fork,
|
|
236
247
|
bindings,
|
|
248
|
+
feeAssetPriceModifier,
|
|
237
249
|
);
|
|
238
250
|
|
|
239
251
|
return new CheckpointBuilder(
|
|
@@ -244,6 +256,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
244
256
|
this.dateProvider,
|
|
245
257
|
this.telemetryClient,
|
|
246
258
|
bindings,
|
|
259
|
+
this.debugLogStore,
|
|
247
260
|
);
|
|
248
261
|
}
|
|
249
262
|
|
|
@@ -253,6 +266,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
253
266
|
async openCheckpoint(
|
|
254
267
|
checkpointNumber: CheckpointNumber,
|
|
255
268
|
constants: CheckpointGlobalVariables,
|
|
269
|
+
feeAssetPriceModifier: bigint,
|
|
256
270
|
l1ToL2Messages: Fr[],
|
|
257
271
|
previousCheckpointOutHashes: Fr[],
|
|
258
272
|
fork: MerkleTreeWriteOperations,
|
|
@@ -266,6 +280,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
266
280
|
return this.startCheckpoint(
|
|
267
281
|
checkpointNumber,
|
|
268
282
|
constants,
|
|
283
|
+
feeAssetPriceModifier,
|
|
269
284
|
l1ToL2Messages,
|
|
270
285
|
previousCheckpointOutHashes,
|
|
271
286
|
fork,
|
|
@@ -280,11 +295,13 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
280
295
|
initialStateReference: stateReference.toInspect(),
|
|
281
296
|
initialArchiveRoot: bufferToHex(archiveTree.root),
|
|
282
297
|
constants,
|
|
298
|
+
feeAssetPriceModifier,
|
|
283
299
|
});
|
|
284
300
|
|
|
285
301
|
const lightweightBuilder = await LightweightCheckpointBuilder.resumeCheckpoint(
|
|
286
302
|
checkpointNumber,
|
|
287
303
|
constants,
|
|
304
|
+
feeAssetPriceModifier,
|
|
288
305
|
l1ToL2Messages,
|
|
289
306
|
previousCheckpointOutHashes,
|
|
290
307
|
fork,
|
|
@@ -300,6 +317,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
300
317
|
this.dateProvider,
|
|
301
318
|
this.telemetryClient,
|
|
302
319
|
bindings,
|
|
320
|
+
this.debugLogStore,
|
|
303
321
|
);
|
|
304
322
|
}
|
|
305
323
|
|
package/src/config.ts
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
secretValueConfigHelper,
|
|
7
7
|
} from '@aztec/foundation/config';
|
|
8
8
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
|
+
import { validatorHASignerConfigMappings } from '@aztec/stdlib/ha-signing';
|
|
9
10
|
import type { ValidatorClientConfig } from '@aztec/stdlib/interfaces/server';
|
|
10
|
-
import { validatorHASignerConfigMappings } from '@aztec/validator-ha-signer/config';
|
|
11
11
|
|
|
12
12
|
export type { ValidatorClientConfig };
|
|
13
13
|
|
|
@@ -73,6 +73,10 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
|
|
|
73
73
|
description: 'Skip pushing re-executed blocks to archiver (default: false)',
|
|
74
74
|
defaultValue: false,
|
|
75
75
|
},
|
|
76
|
+
attestToEquivocatedProposals: {
|
|
77
|
+
description: 'Agree to attest to equivocated checkpoint proposals (for testing purposes only)',
|
|
78
|
+
...booleanConfigHelper(false),
|
|
79
|
+
},
|
|
76
80
|
...validatorHASignerConfigMappings,
|
|
77
81
|
};
|
|
78
82
|
|
|
@@ -95,6 +95,7 @@ export class ValidationService {
|
|
|
95
95
|
public createCheckpointProposal(
|
|
96
96
|
checkpointHeader: CheckpointHeader,
|
|
97
97
|
archive: Fr,
|
|
98
|
+
feeAssetPriceModifier: bigint,
|
|
98
99
|
lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined,
|
|
99
100
|
proposerAttesterAddress: EthAddress | undefined,
|
|
100
101
|
options: CheckpointProposalOptions,
|
|
@@ -119,7 +120,13 @@ export class ValidationService {
|
|
|
119
120
|
txs: options.publishFullTxs ? lastBlockInfo.txs : undefined,
|
|
120
121
|
};
|
|
121
122
|
|
|
122
|
-
return CheckpointProposal.createProposalFromSigner(
|
|
123
|
+
return CheckpointProposal.createProposalFromSigner(
|
|
124
|
+
checkpointHeader,
|
|
125
|
+
archive,
|
|
126
|
+
feeAssetPriceModifier,
|
|
127
|
+
lastBlock,
|
|
128
|
+
payloadSigner,
|
|
129
|
+
);
|
|
123
130
|
}
|
|
124
131
|
|
|
125
132
|
/**
|
|
@@ -137,7 +144,7 @@ export class ValidationService {
|
|
|
137
144
|
attestors: EthAddress[],
|
|
138
145
|
): Promise<CheckpointAttestation[]> {
|
|
139
146
|
// Create the attestation payload from the checkpoint proposal
|
|
140
|
-
const payload = new ConsensusPayload(proposal.checkpointHeader, proposal.archive);
|
|
147
|
+
const payload = new ConsensusPayload(proposal.checkpointHeader, proposal.archive, proposal.feeAssetPriceModifier);
|
|
141
148
|
const buf = Buffer32.fromBuffer(
|
|
142
149
|
keccak256(payload.getPayloadToSign(SignatureDomainSeparator.checkpointAttestation)),
|
|
143
150
|
);
|
package/src/index.ts
CHANGED
|
@@ -256,8 +256,8 @@ export class HAKeyStore implements ExtendedValidatorKeyStore {
|
|
|
256
256
|
/**
|
|
257
257
|
* Start the high-availability key store
|
|
258
258
|
*/
|
|
259
|
-
public start()
|
|
260
|
-
|
|
259
|
+
public async start() {
|
|
260
|
+
await this.haSigner.start();
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
/**
|