@aztec/validator-client 0.0.1-commit.10bd49492 → 0.0.1-commit.11bf3dd6e
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 +9 -12
- package/dest/checkpoint_builder.d.ts +10 -7
- package/dest/checkpoint_builder.d.ts.map +1 -1
- package/dest/checkpoint_builder.js +64 -41
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +4 -9
- package/dest/duties/validation_service.d.ts +7 -9
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +14 -26
- package/dest/factory.d.ts +7 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +5 -5
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/metrics.d.ts +6 -2
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +12 -0
- package/dest/proposal_handler.d.ts +108 -0
- package/dest/proposal_handler.d.ts.map +1 -0
- package/dest/{block_proposal_handler.js → proposal_handler.js} +393 -25
- package/dest/validator.d.ts +15 -20
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +59 -227
- package/package.json +19 -19
- package/src/checkpoint_builder.ts +79 -52
- package/src/config.ts +4 -9
- package/src/duties/validation_service.ts +17 -30
- package/src/factory.ts +10 -4
- package/src/index.ts +1 -1
- package/src/metrics.ts +19 -1
- package/src/{block_proposal_handler.ts → proposal_handler.ts} +441 -23
- package/src/validator.ts +85 -249
- package/dest/block_proposal_handler.d.ts +0 -64
- package/dest/block_proposal_handler.d.ts.map +0 -1
|
@@ -20,13 +20,14 @@ import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
|
20
20
|
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
21
21
|
import { Gas } from '@aztec/stdlib/gas';
|
|
22
22
|
import {
|
|
23
|
+
type BlockBuilderOptions,
|
|
23
24
|
type BuildBlockInCheckpointResult,
|
|
24
25
|
type FullNodeBlockBuilderConfig,
|
|
25
26
|
FullNodeBlockBuilderConfigKeys,
|
|
26
27
|
type ICheckpointBlockBuilder,
|
|
27
28
|
type ICheckpointsBuilder,
|
|
29
|
+
InsufficientValidTxsError,
|
|
28
30
|
type MerkleTreeWriteOperations,
|
|
29
|
-
NoValidTxsError,
|
|
30
31
|
type PublicProcessorLimits,
|
|
31
32
|
type WorldStateSynchronizer,
|
|
32
33
|
} from '@aztec/stdlib/interfaces/server';
|
|
@@ -34,6 +35,7 @@ import { type DebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
|
34
35
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
35
36
|
import { type CheckpointGlobalVariables, GlobalVariables, StateReference, Tx } from '@aztec/stdlib/tx';
|
|
36
37
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
38
|
+
import { ForkCheckpoint } from '@aztec/world-state';
|
|
37
39
|
|
|
38
40
|
// Re-export for backward compatibility
|
|
39
41
|
export type { BuildBlockInCheckpointResult } from '@aztec/stdlib/interfaces/server';
|
|
@@ -45,6 +47,9 @@ export type { BuildBlockInCheckpointResult } from '@aztec/stdlib/interfaces/serv
|
|
|
45
47
|
export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
46
48
|
private log: Logger;
|
|
47
49
|
|
|
50
|
+
/** Persistent contracts DB shared across all blocks in this checkpoint. */
|
|
51
|
+
protected contractsDB: PublicContractsDB;
|
|
52
|
+
|
|
48
53
|
constructor(
|
|
49
54
|
private checkpointBuilder: LightweightCheckpointBuilder,
|
|
50
55
|
private fork: MerkleTreeWriteOperations,
|
|
@@ -59,6 +64,7 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
59
64
|
...bindings,
|
|
60
65
|
instanceId: `checkpoint-${checkpointBuilder.checkpointNumber}`,
|
|
61
66
|
});
|
|
67
|
+
this.contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
getConstantData(): CheckpointGlobalVariables {
|
|
@@ -73,7 +79,7 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
73
79
|
pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
|
|
74
80
|
blockNumber: BlockNumber,
|
|
75
81
|
timestamp: bigint,
|
|
76
|
-
opts:
|
|
82
|
+
opts: BlockBuilderOptions & { expectedEndState?: StateReference },
|
|
77
83
|
): Promise<BuildBlockInCheckpointResult> {
|
|
78
84
|
const slot = this.checkpointBuilder.constants.slotNumber;
|
|
79
85
|
|
|
@@ -103,34 +109,54 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
103
109
|
...this.capLimitsByCheckpointBudgets(opts),
|
|
104
110
|
};
|
|
105
111
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// (only the first block in a checkpoint can be empty)
|
|
112
|
-
if (processedTxs.length === 0 && this.checkpointBuilder.getBlockCount() > 0) {
|
|
113
|
-
throw new NoValidTxsError(failedTxs);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Add block to checkpoint
|
|
117
|
-
const { block } = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
|
|
118
|
-
expectedEndState: opts.expectedEndState,
|
|
119
|
-
});
|
|
112
|
+
// Create a block-level checkpoint on the contracts DB so we can roll back on failure
|
|
113
|
+
this.contractsDB.createCheckpoint();
|
|
114
|
+
// We execute all merkle tree operations on a world state fork checkpoint
|
|
115
|
+
// This enables us to discard all modifications in the event that we fail to successfully process sufficient transactions
|
|
116
|
+
const forkCheckpoint = await ForkCheckpoint.new(this.fork);
|
|
120
117
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
118
|
+
try {
|
|
119
|
+
const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs]] = await elapsed(() =>
|
|
120
|
+
processor.process(pendingTxs, cappedOpts, validator),
|
|
121
|
+
);
|
|
126
122
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
123
|
+
// Throw before updating state if we don't have enough valid txs
|
|
124
|
+
const minValidTxs = opts.minValidTxs ?? 0;
|
|
125
|
+
if (processedTxs.length < minValidTxs) {
|
|
126
|
+
throw new InsufficientValidTxsError(processedTxs.length, minValidTxs, failedTxs);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Commit the fork checkpoint
|
|
130
|
+
await forkCheckpoint.commit();
|
|
131
|
+
|
|
132
|
+
// Add block to checkpoint
|
|
133
|
+
const { block } = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
|
|
134
|
+
expectedEndState: opts.expectedEndState,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
this.contractsDB.commitCheckpoint();
|
|
138
|
+
|
|
139
|
+
this.log.debug('Built block within checkpoint', {
|
|
140
|
+
header: block.header.toInspect(),
|
|
141
|
+
processedTxs: processedTxs.map(tx => tx.hash.toString()),
|
|
142
|
+
failedTxs: failedTxs.map(tx => tx.tx.txHash.toString()),
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
block,
|
|
147
|
+
publicProcessorDuration,
|
|
148
|
+
numTxs: processedTxs.length,
|
|
149
|
+
failedTxs,
|
|
150
|
+
usedTxs,
|
|
151
|
+
};
|
|
152
|
+
} catch (err) {
|
|
153
|
+
// Revert all changes to contracts db
|
|
154
|
+
this.contractsDB.revertCheckpoint();
|
|
155
|
+
// If we reached the point of committing the checkpoint, this does nothing
|
|
156
|
+
// Otherwise it reverts any changes made to the fork for this failed block
|
|
157
|
+
await forkCheckpoint.revert();
|
|
158
|
+
throw err;
|
|
159
|
+
}
|
|
134
160
|
}
|
|
135
161
|
|
|
136
162
|
/** Completes the checkpoint and returns it. */
|
|
@@ -153,11 +179,12 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
153
179
|
|
|
154
180
|
/**
|
|
155
181
|
* Caps per-block gas and blob field limits by remaining checkpoint-level budgets.
|
|
156
|
-
*
|
|
157
|
-
*
|
|
182
|
+
* When building a proposal (isBuildingProposal=true), computes a fair share of remaining budget
|
|
183
|
+
* across remaining blocks scaled by the multiplier. When validating, only caps by per-block limit
|
|
184
|
+
* and remaining checkpoint budget (no redistribution or multiplier).
|
|
158
185
|
*/
|
|
159
186
|
protected capLimitsByCheckpointBudgets(
|
|
160
|
-
opts:
|
|
187
|
+
opts: BlockBuilderOptions,
|
|
161
188
|
): Pick<PublicProcessorLimits, 'maxBlockGas' | 'maxBlobFields' | 'maxTransactions'> {
|
|
162
189
|
const existingBlocks = this.checkpointBuilder.getBlocks();
|
|
163
190
|
|
|
@@ -178,31 +205,31 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
178
205
|
const blockEndOverhead = getNumBlockEndBlobFields(isFirstBlock);
|
|
179
206
|
const maxBlobFieldsForTxs = totalBlobCapacity - usedBlobFields - blockEndOverhead;
|
|
180
207
|
|
|
181
|
-
//
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
//
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
cappedMaxTransactions =
|
|
208
|
+
// Remaining txs
|
|
209
|
+
const usedTxs = sum(existingBlocks.map(b => b.body.txEffects.length));
|
|
210
|
+
const remainingTxs = Math.max(0, (this.config.maxTxsPerCheckpoint ?? Infinity) - usedTxs);
|
|
211
|
+
|
|
212
|
+
// Cap by per-block limit + remaining checkpoint budget
|
|
213
|
+
let cappedL2Gas = Math.min(opts.maxBlockGas?.l2Gas ?? Infinity, remainingMana);
|
|
214
|
+
let cappedDAGas = Math.min(opts.maxBlockGas?.daGas ?? Infinity, remainingDAGas);
|
|
215
|
+
let cappedBlobFields = Math.min(opts.maxBlobFields ?? Infinity, maxBlobFieldsForTxs);
|
|
216
|
+
let cappedMaxTransactions = Math.min(opts.maxTransactions ?? Infinity, remainingTxs);
|
|
217
|
+
|
|
218
|
+
// Proposer mode: further cap by fair share of remaining budget across remaining blocks
|
|
219
|
+
if (opts.isBuildingProposal) {
|
|
220
|
+
const remainingBlocks = Math.max(1, opts.maxBlocksPerCheckpoint - existingBlocks.length);
|
|
221
|
+
const multiplier = opts.perBlockAllocationMultiplier;
|
|
222
|
+
|
|
223
|
+
cappedL2Gas = Math.min(cappedL2Gas, Math.ceil((remainingMana / remainingBlocks) * multiplier));
|
|
224
|
+
cappedDAGas = Math.min(cappedDAGas, Math.ceil((remainingDAGas / remainingBlocks) * multiplier));
|
|
225
|
+
cappedBlobFields = Math.min(cappedBlobFields, Math.ceil((maxBlobFieldsForTxs / remainingBlocks) * multiplier));
|
|
226
|
+
cappedMaxTransactions = Math.min(cappedMaxTransactions, Math.ceil((remainingTxs / remainingBlocks) * multiplier));
|
|
200
227
|
}
|
|
201
228
|
|
|
202
229
|
return {
|
|
203
230
|
maxBlockGas: new Gas(cappedDAGas, cappedL2Gas),
|
|
204
231
|
maxBlobFields: cappedBlobFields,
|
|
205
|
-
maxTransactions: cappedMaxTransactions,
|
|
232
|
+
maxTransactions: Number.isFinite(cappedMaxTransactions) ? cappedMaxTransactions : undefined,
|
|
206
233
|
};
|
|
207
234
|
}
|
|
208
235
|
|
|
@@ -211,7 +238,7 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
211
238
|
...(await getDefaultAllowedSetupFunctions()),
|
|
212
239
|
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
213
240
|
];
|
|
214
|
-
const contractsDB =
|
|
241
|
+
const contractsDB = this.contractsDB;
|
|
215
242
|
const guardedFork = new GuardedMerkleTreeOperations(fork);
|
|
216
243
|
|
|
217
244
|
const collectDebugLogs = this.debugLogStore.isEnabled;
|
package/src/config.ts
CHANGED
|
@@ -49,11 +49,6 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
|
|
|
49
49
|
description: 'Interval between polling for new attestations',
|
|
50
50
|
...numberConfigHelper(200),
|
|
51
51
|
},
|
|
52
|
-
validatorReexecute: {
|
|
53
|
-
env: 'VALIDATOR_REEXECUTE',
|
|
54
|
-
description: 'Re-execute transactions before attesting',
|
|
55
|
-
...booleanConfigHelper(true),
|
|
56
|
-
},
|
|
57
52
|
alwaysReexecuteBlockProposals: {
|
|
58
53
|
description:
|
|
59
54
|
'Whether to always reexecute block proposals, even for non-validator nodes (useful for monitoring network status).',
|
|
@@ -80,22 +75,22 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
|
|
|
80
75
|
validateMaxL2BlockGas: {
|
|
81
76
|
env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
|
|
82
77
|
description: 'Maximum L2 block gas for validation. Proposals exceeding this limit are rejected.',
|
|
83
|
-
parseEnv: (val: string) =>
|
|
78
|
+
parseEnv: (val: string) => parseInt(val, 10),
|
|
84
79
|
},
|
|
85
80
|
validateMaxDABlockGas: {
|
|
86
81
|
env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
|
|
87
82
|
description: 'Maximum DA block gas for validation. Proposals exceeding this limit are rejected.',
|
|
88
|
-
parseEnv: (val: string) =>
|
|
83
|
+
parseEnv: (val: string) => parseInt(val, 10),
|
|
89
84
|
},
|
|
90
85
|
validateMaxTxsPerBlock: {
|
|
91
86
|
env: 'VALIDATOR_MAX_TX_PER_BLOCK',
|
|
92
87
|
description: 'Maximum transactions per block for validation. Proposals exceeding this limit are rejected.',
|
|
93
|
-
parseEnv: (val: string) =>
|
|
88
|
+
parseEnv: (val: string) => parseInt(val, 10),
|
|
94
89
|
},
|
|
95
90
|
validateMaxTxsPerCheckpoint: {
|
|
96
91
|
env: 'VALIDATOR_MAX_TX_PER_CHECKPOINT',
|
|
97
92
|
description: 'Maximum transactions per checkpoint for validation. Proposals exceeding this limit are rejected.',
|
|
98
|
-
parseEnv: (val: string) =>
|
|
93
|
+
parseEnv: (val: string) => parseInt(val, 10),
|
|
99
94
|
},
|
|
100
95
|
...localSignerConfigMappings,
|
|
101
96
|
...validatorHASignerConfigMappings,
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BlockNumber,
|
|
3
|
-
type CheckpointNumber,
|
|
4
|
-
IndexWithinCheckpoint,
|
|
5
|
-
type SlotNumber,
|
|
6
|
-
} from '@aztec/foundation/branded-types';
|
|
1
|
+
import { type CheckpointNumber, IndexWithinCheckpoint, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
7
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
8
3
|
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
9
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -11,7 +6,6 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
11
6
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
12
7
|
import { createLogger } from '@aztec/foundation/log';
|
|
13
8
|
import type { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
14
|
-
import type { CreateCheckpointProposalLastBlockData } from '@aztec/stdlib/interfaces/server';
|
|
15
9
|
import {
|
|
16
10
|
BlockProposal,
|
|
17
11
|
type BlockProposalOptions,
|
|
@@ -52,6 +46,7 @@ export class ValidationService {
|
|
|
52
46
|
*/
|
|
53
47
|
public createBlockProposal(
|
|
54
48
|
blockHeader: BlockHeader,
|
|
49
|
+
checkpointNumber: CheckpointNumber,
|
|
55
50
|
blockIndexWithinCheckpoint: IndexWithinCheckpoint,
|
|
56
51
|
inHash: Fr,
|
|
57
52
|
archive: Fr,
|
|
@@ -72,6 +67,7 @@ export class ValidationService {
|
|
|
72
67
|
|
|
73
68
|
return BlockProposal.createProposalFromSigner(
|
|
74
69
|
blockHeader,
|
|
70
|
+
checkpointNumber,
|
|
75
71
|
blockIndexWithinCheckpoint,
|
|
76
72
|
inHash,
|
|
77
73
|
archive,
|
|
@@ -86,7 +82,7 @@ export class ValidationService {
|
|
|
86
82
|
*
|
|
87
83
|
* @param checkpointHeader - The checkpoint header containing aggregated data
|
|
88
84
|
* @param archive - The archive of the checkpoint
|
|
89
|
-
* @param
|
|
85
|
+
* @param lastBlockProposal - Signed block proposal for the last block in the checkpoint, or undefined
|
|
90
86
|
* @param proposerAttesterAddress - The address of the proposer
|
|
91
87
|
* @param options - Checkpoint proposal options
|
|
92
88
|
*
|
|
@@ -95,14 +91,17 @@ export class ValidationService {
|
|
|
95
91
|
public createCheckpointProposal(
|
|
96
92
|
checkpointHeader: CheckpointHeader,
|
|
97
93
|
archive: Fr,
|
|
94
|
+
checkpointNumber: CheckpointNumber,
|
|
98
95
|
feeAssetPriceModifier: bigint,
|
|
99
|
-
|
|
96
|
+
lastBlockProposal: BlockProposal | undefined,
|
|
100
97
|
proposerAttesterAddress: EthAddress | undefined,
|
|
101
98
|
options: CheckpointProposalOptions,
|
|
102
99
|
): Promise<CheckpointProposal> {
|
|
103
|
-
// For testing: change the archive to trigger state_mismatch validation failure
|
|
100
|
+
// For testing: change the archive to trigger state_mismatch validation failure.
|
|
101
|
+
// If there's a last block proposal, use its (already invalid) archive to keep signatures consistent
|
|
102
|
+
// so P2P validation passes and the slasher can detect the offense.
|
|
104
103
|
if (options.broadcastInvalidCheckpointProposal) {
|
|
105
|
-
archive = Fr.random();
|
|
104
|
+
archive = lastBlockProposal?.archiveRoot ?? Fr.random();
|
|
106
105
|
this.log.warn(`Creating INVALID checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
|
|
107
106
|
}
|
|
108
107
|
|
|
@@ -112,19 +111,12 @@ export class ValidationService {
|
|
|
112
111
|
return this.keyStore.signMessageWithAddress(address, payload, context);
|
|
113
112
|
};
|
|
114
113
|
|
|
115
|
-
// Last block to include in the proposal
|
|
116
|
-
const lastBlock = lastBlockInfo && {
|
|
117
|
-
blockHeader: lastBlockInfo.blockHeader,
|
|
118
|
-
indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
|
|
119
|
-
txHashes: lastBlockInfo.txs.map(tx => tx.getTxHash()),
|
|
120
|
-
txs: options.publishFullTxs ? lastBlockInfo.txs : undefined,
|
|
121
|
-
};
|
|
122
|
-
|
|
123
114
|
return CheckpointProposal.createProposalFromSigner(
|
|
124
115
|
checkpointHeader,
|
|
125
116
|
archive,
|
|
117
|
+
checkpointNumber,
|
|
126
118
|
feeAssetPriceModifier,
|
|
127
|
-
|
|
119
|
+
lastBlockProposal,
|
|
128
120
|
payloadSigner,
|
|
129
121
|
);
|
|
130
122
|
}
|
|
@@ -142,6 +134,7 @@ export class ValidationService {
|
|
|
142
134
|
async attestToCheckpointProposal(
|
|
143
135
|
proposal: CheckpointProposalCore,
|
|
144
136
|
attestors: EthAddress[],
|
|
137
|
+
checkpointNumber: CheckpointNumber,
|
|
145
138
|
): Promise<CheckpointAttestation[]> {
|
|
146
139
|
// Create the attestation payload from the checkpoint proposal
|
|
147
140
|
const payload = new ConsensusPayload(proposal.checkpointHeader, proposal.archive, proposal.feeAssetPriceModifier);
|
|
@@ -149,14 +142,9 @@ export class ValidationService {
|
|
|
149
142
|
keccak256(payload.getPayloadToSign(SignatureDomainSeparator.checkpointAttestation)),
|
|
150
143
|
);
|
|
151
144
|
|
|
152
|
-
// TODO(spy/ha): Use checkpointNumber instead of blockNumber once CheckpointHeader includes it.
|
|
153
|
-
// CheckpointProposalCore doesn't have lastBlock info, so use 0 as a proxy.
|
|
154
|
-
// blockNumber is NOT used for the primary key so it's safe to use here.
|
|
155
|
-
// See CheckpointHeader TODO and SigningContext types documentation.
|
|
156
|
-
const blockNumber = BlockNumber(0);
|
|
157
145
|
const context: SigningContext = {
|
|
158
146
|
slot: proposal.slotNumber,
|
|
159
|
-
|
|
147
|
+
checkpointNumber,
|
|
160
148
|
dutyType: DutyType.ATTESTATION,
|
|
161
149
|
};
|
|
162
150
|
|
|
@@ -177,7 +165,7 @@ export class ValidationService {
|
|
|
177
165
|
} else {
|
|
178
166
|
const error = result.reason;
|
|
179
167
|
if (error instanceof DutyAlreadySignedError || error instanceof SlashingProtectionError) {
|
|
180
|
-
this.log.
|
|
168
|
+
this.log.verbose(
|
|
181
169
|
`Attestation for slot ${proposal.slotNumber} by ${attestors[i]} already signed by another High-Availability node`,
|
|
182
170
|
);
|
|
183
171
|
// Continue with remaining attestors
|
|
@@ -195,7 +183,6 @@ export class ValidationService {
|
|
|
195
183
|
* @param attestationsAndSigners - The attestations and signers to sign
|
|
196
184
|
* @param proposer - The proposer address to sign with
|
|
197
185
|
* @param slot - The slot number for HA signing context
|
|
198
|
-
* @param blockNumber - The block or checkpoint number for HA signing context
|
|
199
186
|
* @returns signature
|
|
200
187
|
* @throws DutyAlreadySignedError if already signed by another HA node
|
|
201
188
|
* @throws SlashingProtectionError if attempting to sign different data for same slot
|
|
@@ -204,11 +191,11 @@ export class ValidationService {
|
|
|
204
191
|
attestationsAndSigners: CommitteeAttestationsAndSigners,
|
|
205
192
|
proposer: EthAddress,
|
|
206
193
|
slot: SlotNumber,
|
|
207
|
-
|
|
194
|
+
checkpointNumber: CheckpointNumber,
|
|
208
195
|
): Promise<Signature> {
|
|
209
196
|
const context: SigningContext = {
|
|
210
197
|
slot,
|
|
211
|
-
|
|
198
|
+
checkpointNumber,
|
|
212
199
|
dutyType: DutyType.ATTESTATIONS_AND_SIGNERS,
|
|
213
200
|
};
|
|
214
201
|
|
package/src/factory.ts
CHANGED
|
@@ -7,13 +7,14 @@ import type { L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
|
7
7
|
import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
8
8
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
9
9
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
10
|
+
import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
10
11
|
|
|
11
|
-
import { BlockProposalHandler } from './block_proposal_handler.js';
|
|
12
12
|
import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
|
|
13
13
|
import { ValidatorMetrics } from './metrics.js';
|
|
14
|
+
import { ProposalHandler } from './proposal_handler.js';
|
|
14
15
|
import { ValidatorClient } from './validator.js';
|
|
15
16
|
|
|
16
|
-
export function
|
|
17
|
+
export function createProposalHandler(
|
|
17
18
|
config: ValidatorClientFullConfig,
|
|
18
19
|
deps: {
|
|
19
20
|
checkpointsBuilder: FullNodeCheckpointsBuilder;
|
|
@@ -22,6 +23,7 @@ export function createBlockProposalHandler(
|
|
|
22
23
|
l1ToL2MessageSource: L1ToL2MessageSource;
|
|
23
24
|
p2pClient: P2PClient;
|
|
24
25
|
epochCache: EpochCache;
|
|
26
|
+
blobClient: BlobClientInterface;
|
|
25
27
|
dateProvider: DateProvider;
|
|
26
28
|
telemetry: TelemetryClient;
|
|
27
29
|
},
|
|
@@ -29,9 +31,9 @@ export function createBlockProposalHandler(
|
|
|
29
31
|
const metrics = new ValidatorMetrics(deps.telemetry);
|
|
30
32
|
const blockProposalValidator = new BlockProposalValidator(deps.epochCache, {
|
|
31
33
|
txsPermitted: !config.disableTransactions,
|
|
32
|
-
maxTxsPerBlock: config.validateMaxTxsPerBlock,
|
|
34
|
+
maxTxsPerBlock: config.validateMaxTxsPerBlock ?? config.validateMaxTxsPerCheckpoint,
|
|
33
35
|
});
|
|
34
|
-
return new
|
|
36
|
+
return new ProposalHandler(
|
|
35
37
|
deps.checkpointsBuilder,
|
|
36
38
|
deps.worldState,
|
|
37
39
|
deps.blockSource,
|
|
@@ -40,9 +42,11 @@ export function createBlockProposalHandler(
|
|
|
40
42
|
blockProposalValidator,
|
|
41
43
|
deps.epochCache,
|
|
42
44
|
config,
|
|
45
|
+
deps.blobClient,
|
|
43
46
|
metrics,
|
|
44
47
|
deps.dateProvider,
|
|
45
48
|
deps.telemetry,
|
|
49
|
+
undefined,
|
|
46
50
|
);
|
|
47
51
|
}
|
|
48
52
|
|
|
@@ -59,6 +63,7 @@ export function createValidatorClient(
|
|
|
59
63
|
epochCache: EpochCache;
|
|
60
64
|
keyStoreManager: KeystoreManager | undefined;
|
|
61
65
|
blobClient: BlobClientInterface;
|
|
66
|
+
slashingProtectionDb?: SlashingProtectionDatabase;
|
|
62
67
|
},
|
|
63
68
|
) {
|
|
64
69
|
if (config.disableValidator || !deps.keyStoreManager) {
|
|
@@ -79,5 +84,6 @@ export function createValidatorClient(
|
|
|
79
84
|
deps.blobClient,
|
|
80
85
|
deps.dateProvider,
|
|
81
86
|
deps.telemetry,
|
|
87
|
+
deps.slashingProtectionDb,
|
|
82
88
|
);
|
|
83
89
|
}
|
package/src/index.ts
CHANGED
package/src/metrics.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
createUpDownCounterWithDefault,
|
|
12
12
|
} from '@aztec/telemetry-client';
|
|
13
13
|
|
|
14
|
-
import type { BlockProposalValidationFailureReason } from './
|
|
14
|
+
import type { BlockProposalValidationFailureReason } from './proposal_handler.js';
|
|
15
15
|
|
|
16
16
|
export class ValidatorMetrics {
|
|
17
17
|
private failedReexecutionCounter: UpDownCounter;
|
|
@@ -24,6 +24,8 @@ export class ValidatorMetrics {
|
|
|
24
24
|
private reexMana: Histogram;
|
|
25
25
|
private reexTx: Histogram;
|
|
26
26
|
private reexDuration: Gauge;
|
|
27
|
+
private checkpointProposalToPipelinedStateDuration: Histogram;
|
|
28
|
+
private checkpointProposalReceiveOffsetFromNextSlotBoundary: Histogram;
|
|
27
29
|
|
|
28
30
|
constructor(telemetryClient: TelemetryClient) {
|
|
29
31
|
const meter = telemetryClient.getMeter('Validator');
|
|
@@ -77,6 +79,12 @@ export class ValidatorMetrics {
|
|
|
77
79
|
this.reexTx = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_TX_COUNT);
|
|
78
80
|
|
|
79
81
|
this.reexDuration = meter.createGauge(Metrics.VALIDATOR_RE_EXECUTION_TIME);
|
|
82
|
+
this.checkpointProposalToPipelinedStateDuration = meter.createHistogram(
|
|
83
|
+
Metrics.VALIDATOR_CHECKPOINT_PROPOSAL_TO_PIPELINED_STATE_DURATION,
|
|
84
|
+
);
|
|
85
|
+
this.checkpointProposalReceiveOffsetFromNextSlotBoundary = meter.createHistogram(
|
|
86
|
+
Metrics.VALIDATOR_CHECKPOINT_PROPOSAL_RECEIVE_OFFSET_FROM_NEXT_SLOT_BOUNDARY,
|
|
87
|
+
);
|
|
80
88
|
}
|
|
81
89
|
|
|
82
90
|
public recordReex(time: number, txs: number, mManaTotal: number) {
|
|
@@ -85,6 +93,16 @@ export class ValidatorMetrics {
|
|
|
85
93
|
this.reexMana.record(mManaTotal);
|
|
86
94
|
}
|
|
87
95
|
|
|
96
|
+
public recordCheckpointProposalToPipelinedStateDuration(durationMs: number) {
|
|
97
|
+
this.checkpointProposalToPipelinedStateDuration.record(Math.ceil(durationMs));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public recordCheckpointProposalReceiveOffsetFromNextSlotBoundary(offsetMs: number) {
|
|
101
|
+
this.checkpointProposalReceiveOffsetFromNextSlotBoundary.record(Math.ceil(Math.abs(offsetMs)), {
|
|
102
|
+
[Attributes.SLOT_BOUNDARY_SIDE]: offsetMs < 0 ? 'before' : 'after',
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
88
106
|
public recordFailedReexecution(proposal: BlockProposal) {
|
|
89
107
|
const proposer = proposal.getSender();
|
|
90
108
|
this.failedReexecutionCounter.add(1, {
|