@aztec/validator-client 0.0.1-commit.135b523 → 0.0.1-commit.181e2d196
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 +8 -5
- package/dest/checkpoint_builder.d.ts.map +1 -1
- package/dest/checkpoint_builder.js +28 -18
- 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/factory.d.ts +1 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +2 -1
- 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/metrics.d.ts +9 -1
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +12 -0
- package/dest/validator.d.ts +35 -8
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +179 -29
- package/package.json +19 -19
- package/src/block_proposal_handler.ts +28 -48
- package/src/checkpoint_builder.ts +23 -6
- package/src/config.ts +5 -1
- package/src/duties/validation_service.ts +9 -2
- package/src/factory.ts +1 -0
- package/src/index.ts +0 -1
- package/src/key_store/ha_key_store.ts +2 -2
- package/src/metrics.ts +18 -0
- package/src/validator.ts +234 -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
|
@@ -4,7 +4,7 @@ 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
6
|
import { DateProvider, elapsed } from '@aztec/foundation/timer';
|
|
7
|
-
import { getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
|
|
7
|
+
import { createTxValidatorForBlockBuilding, getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
|
|
8
8
|
import { LightweightCheckpointBuilder } from '@aztec/prover-client/light';
|
|
9
9
|
import {
|
|
10
10
|
GuardedMerkleTreeOperations,
|
|
@@ -28,12 +28,11 @@ import {
|
|
|
28
28
|
type PublicProcessorLimits,
|
|
29
29
|
type WorldStateSynchronizer,
|
|
30
30
|
} from '@aztec/stdlib/interfaces/server';
|
|
31
|
+
import { type DebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
31
32
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
32
33
|
import { type CheckpointGlobalVariables, GlobalVariables, StateReference, Tx } from '@aztec/stdlib/tx';
|
|
33
34
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
34
35
|
|
|
35
|
-
import { createValidatorForBlockBuilding } from './tx_validator/tx_validator_factory.js';
|
|
36
|
-
|
|
37
36
|
// Re-export for backward compatibility
|
|
38
37
|
export type { BuildBlockInCheckpointResult } from '@aztec/stdlib/interfaces/server';
|
|
39
38
|
|
|
@@ -52,6 +51,7 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
52
51
|
private dateProvider: DateProvider,
|
|
53
52
|
private telemetryClient: TelemetryClient,
|
|
54
53
|
bindings?: LoggerBindings,
|
|
54
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
55
55
|
) {
|
|
56
56
|
this.log = createLogger('checkpoint-builder', {
|
|
57
57
|
...bindings,
|
|
@@ -105,7 +105,7 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
// Add block to checkpoint
|
|
108
|
-
const block = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
|
|
108
|
+
const { block } = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
|
|
109
109
|
expectedEndState: opts.expectedEndState,
|
|
110
110
|
});
|
|
111
111
|
|
|
@@ -148,10 +148,15 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
protected async makeBlockBuilderDeps(globalVariables: GlobalVariables, fork: MerkleTreeWriteOperations) {
|
|
151
|
-
const txPublicSetupAllowList =
|
|
151
|
+
const txPublicSetupAllowList = [
|
|
152
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
153
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
154
|
+
];
|
|
152
155
|
const contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
|
|
153
156
|
const guardedFork = new GuardedMerkleTreeOperations(fork);
|
|
154
157
|
|
|
158
|
+
const collectDebugLogs = this.debugLogStore.isEnabled;
|
|
159
|
+
|
|
155
160
|
const bindings = this.log.getBindings();
|
|
156
161
|
const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(
|
|
157
162
|
guardedFork,
|
|
@@ -159,6 +164,7 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
159
164
|
globalVariables,
|
|
160
165
|
this.telemetryClient,
|
|
161
166
|
bindings,
|
|
167
|
+
collectDebugLogs,
|
|
162
168
|
);
|
|
163
169
|
|
|
164
170
|
const processor = new PublicProcessor(
|
|
@@ -170,9 +176,10 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
170
176
|
this.telemetryClient,
|
|
171
177
|
createLogger('simulator:public-processor', bindings),
|
|
172
178
|
this.config,
|
|
179
|
+
this.debugLogStore,
|
|
173
180
|
);
|
|
174
181
|
|
|
175
|
-
const validator =
|
|
182
|
+
const validator = createTxValidatorForBlockBuilding(
|
|
176
183
|
fork,
|
|
177
184
|
this.contractDataSource,
|
|
178
185
|
globalVariables,
|
|
@@ -197,6 +204,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
197
204
|
private contractDataSource: ContractDataSource,
|
|
198
205
|
private dateProvider: DateProvider,
|
|
199
206
|
private telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
207
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
200
208
|
) {
|
|
201
209
|
this.log = createLogger('checkpoint-builder');
|
|
202
210
|
}
|
|
@@ -215,6 +223,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
215
223
|
async startCheckpoint(
|
|
216
224
|
checkpointNumber: CheckpointNumber,
|
|
217
225
|
constants: CheckpointGlobalVariables,
|
|
226
|
+
feeAssetPriceModifier: bigint,
|
|
218
227
|
l1ToL2Messages: Fr[],
|
|
219
228
|
previousCheckpointOutHashes: Fr[],
|
|
220
229
|
fork: MerkleTreeWriteOperations,
|
|
@@ -229,6 +238,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
229
238
|
initialStateReference: stateReference.toInspect(),
|
|
230
239
|
initialArchiveRoot: bufferToHex(archiveTree.root),
|
|
231
240
|
constants,
|
|
241
|
+
feeAssetPriceModifier,
|
|
232
242
|
});
|
|
233
243
|
|
|
234
244
|
const lightweightBuilder = await LightweightCheckpointBuilder.startNewCheckpoint(
|
|
@@ -238,6 +248,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
238
248
|
previousCheckpointOutHashes,
|
|
239
249
|
fork,
|
|
240
250
|
bindings,
|
|
251
|
+
feeAssetPriceModifier,
|
|
241
252
|
);
|
|
242
253
|
|
|
243
254
|
return new CheckpointBuilder(
|
|
@@ -248,6 +259,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
248
259
|
this.dateProvider,
|
|
249
260
|
this.telemetryClient,
|
|
250
261
|
bindings,
|
|
262
|
+
this.debugLogStore,
|
|
251
263
|
);
|
|
252
264
|
}
|
|
253
265
|
|
|
@@ -257,6 +269,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
257
269
|
async openCheckpoint(
|
|
258
270
|
checkpointNumber: CheckpointNumber,
|
|
259
271
|
constants: CheckpointGlobalVariables,
|
|
272
|
+
feeAssetPriceModifier: bigint,
|
|
260
273
|
l1ToL2Messages: Fr[],
|
|
261
274
|
previousCheckpointOutHashes: Fr[],
|
|
262
275
|
fork: MerkleTreeWriteOperations,
|
|
@@ -270,6 +283,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
270
283
|
return this.startCheckpoint(
|
|
271
284
|
checkpointNumber,
|
|
272
285
|
constants,
|
|
286
|
+
feeAssetPriceModifier,
|
|
273
287
|
l1ToL2Messages,
|
|
274
288
|
previousCheckpointOutHashes,
|
|
275
289
|
fork,
|
|
@@ -284,11 +298,13 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
284
298
|
initialStateReference: stateReference.toInspect(),
|
|
285
299
|
initialArchiveRoot: bufferToHex(archiveTree.root),
|
|
286
300
|
constants,
|
|
301
|
+
feeAssetPriceModifier,
|
|
287
302
|
});
|
|
288
303
|
|
|
289
304
|
const lightweightBuilder = await LightweightCheckpointBuilder.resumeCheckpoint(
|
|
290
305
|
checkpointNumber,
|
|
291
306
|
constants,
|
|
307
|
+
feeAssetPriceModifier,
|
|
292
308
|
l1ToL2Messages,
|
|
293
309
|
previousCheckpointOutHashes,
|
|
294
310
|
fork,
|
|
@@ -304,6 +320,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
304
320
|
this.dateProvider,
|
|
305
321
|
this.telemetryClient,
|
|
306
322
|
bindings,
|
|
323
|
+
this.debugLogStore,
|
|
307
324
|
);
|
|
308
325
|
}
|
|
309
326
|
|
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/factory.ts
CHANGED
|
@@ -29,6 +29,7 @@ export function createBlockProposalHandler(
|
|
|
29
29
|
const metrics = new ValidatorMetrics(deps.telemetry);
|
|
30
30
|
const blockProposalValidator = new BlockProposalValidator(deps.epochCache, {
|
|
31
31
|
txsPermitted: !config.disableTransactions,
|
|
32
|
+
maxTxsPerBlock: config.maxTxsPerBlock,
|
|
32
33
|
});
|
|
33
34
|
return new BlockProposalHandler(
|
|
34
35
|
deps.checkpointsBuilder,
|
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
|
/**
|
package/src/metrics.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
1
3
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
2
4
|
import {
|
|
3
5
|
Attributes,
|
|
@@ -16,6 +18,8 @@ export class ValidatorMetrics {
|
|
|
16
18
|
private successfulAttestationsCount: UpDownCounter;
|
|
17
19
|
private failedAttestationsBadProposalCount: UpDownCounter;
|
|
18
20
|
private failedAttestationsNodeIssueCount: UpDownCounter;
|
|
21
|
+
private currentEpoch: Gauge;
|
|
22
|
+
private attestedEpochCount: UpDownCounter;
|
|
19
23
|
|
|
20
24
|
private reexMana: Histogram;
|
|
21
25
|
private reexTx: Histogram;
|
|
@@ -64,6 +68,10 @@ export class ValidatorMetrics {
|
|
|
64
68
|
},
|
|
65
69
|
);
|
|
66
70
|
|
|
71
|
+
this.currentEpoch = meter.createGauge(Metrics.VALIDATOR_CURRENT_EPOCH);
|
|
72
|
+
|
|
73
|
+
this.attestedEpochCount = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_ATTESTED_EPOCH_COUNT);
|
|
74
|
+
|
|
67
75
|
this.reexMana = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_MANA);
|
|
68
76
|
|
|
69
77
|
this.reexTx = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_TX_COUNT);
|
|
@@ -110,4 +118,14 @@ export class ValidatorMetrics {
|
|
|
110
118
|
[Attributes.IS_COMMITTEE_MEMBER]: inCommittee,
|
|
111
119
|
});
|
|
112
120
|
}
|
|
121
|
+
|
|
122
|
+
/** Update the gauge tracking the current epoch number (proxy for total epochs elapsed). */
|
|
123
|
+
public setCurrentEpoch(epoch: EpochNumber) {
|
|
124
|
+
this.currentEpoch.record(Number(epoch));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Increment the count of epochs in which the given attester submitted at least one attestation. */
|
|
128
|
+
public incAttestedEpochCount(attester: EthAddress) {
|
|
129
|
+
this.attestedEpochCount.add(1, { [Attributes.ATTESTER_ADDRESS]: attester.toString() });
|
|
130
|
+
}
|
|
113
131
|
}
|