@aztec/validator-client 2.1.0-rc.9 → 3.0.0-devnet.2
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/block_proposal_handler.d.ts +23 -18
- package/dest/block_proposal_handler.d.ts.map +1 -1
- package/dest/block_proposal_handler.js +89 -60
- package/dest/duties/validation_service.d.ts +9 -7
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +15 -10
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +3 -1
- package/dest/metrics.d.ts +6 -4
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +23 -13
- package/dest/validator.d.ts +10 -9
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +68 -17
- package/package.json +12 -12
- package/src/block_proposal_handler.ts +116 -87
- package/src/duties/validation_service.ts +21 -15
- package/src/factory.ts +3 -1
- package/src/metrics.ts +32 -14
- package/src/validator.ts +86 -31
|
@@ -3,24 +3,32 @@ import { DateProvider } from '@aztec/foundation/timer';
|
|
|
3
3
|
import type { P2P, PeerId } from '@aztec/p2p';
|
|
4
4
|
import { TxProvider } from '@aztec/p2p';
|
|
5
5
|
import { BlockProposalValidator } from '@aztec/p2p/msg_validators';
|
|
6
|
-
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
6
|
+
import type { L2Block, L2BlockSource } from '@aztec/stdlib/block';
|
|
7
7
|
import type { IFullNodeBlockBuilder, ValidatorClientFullConfig } from '@aztec/stdlib/interfaces/server';
|
|
8
8
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
9
9
|
import { type BlockProposal } from '@aztec/stdlib/p2p';
|
|
10
10
|
import { type FailedTx, type Tx } from '@aztec/stdlib/tx';
|
|
11
11
|
import { type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
|
|
12
12
|
import type { ValidatorMetrics } from './metrics.js';
|
|
13
|
-
export type BlockProposalValidationFailureReason = 'invalid_proposal' | 'parent_block_not_found' | '
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
export type BlockProposalValidationFailureReason = 'invalid_proposal' | 'parent_block_not_found' | 'parent_block_wrong_slot' | 'in_hash_mismatch' | 'block_number_already_exists' | 'txs_not_available' | 'state_mismatch' | 'failed_txs' | 'timeout' | 'unknown_error';
|
|
14
|
+
type ReexecuteTransactionsResult = {
|
|
15
|
+
block: L2Block;
|
|
16
|
+
failedTxs: FailedTx[];
|
|
17
|
+
reexecutionTimeMs: number;
|
|
18
|
+
totalManaUsed: number;
|
|
19
|
+
};
|
|
20
|
+
export type BlockProposalValidationSuccessResult = {
|
|
21
|
+
isValid: true;
|
|
22
|
+
blockNumber: number;
|
|
23
|
+
reexecutionResult?: ReexecuteTransactionsResult;
|
|
24
|
+
};
|
|
25
|
+
export type BlockProposalValidationFailureResult = {
|
|
26
|
+
isValid: false;
|
|
27
|
+
reason: BlockProposalValidationFailureReason;
|
|
28
|
+
blockNumber?: number;
|
|
29
|
+
reexecutionResult?: ReexecuteTransactionsResult;
|
|
30
|
+
};
|
|
31
|
+
export type BlockProposalValidationResult = BlockProposalValidationSuccessResult | BlockProposalValidationFailureResult;
|
|
24
32
|
export declare class BlockProposalHandler {
|
|
25
33
|
private blockBuilder;
|
|
26
34
|
private blockSource;
|
|
@@ -35,13 +43,10 @@ export declare class BlockProposalHandler {
|
|
|
35
43
|
constructor(blockBuilder: IFullNodeBlockBuilder, blockSource: L2BlockSource, l1ToL2MessageSource: L1ToL2MessageSource, txProvider: TxProvider, blockProposalValidator: BlockProposalValidator, config: ValidatorClientFullConfig, metrics?: ValidatorMetrics | undefined, dateProvider?: DateProvider, telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
36
44
|
registerForReexecution(p2pClient: P2P): BlockProposalHandler;
|
|
37
45
|
handleBlockProposal(proposal: BlockProposal, proposalSender: PeerId, shouldReexecute: boolean): Promise<BlockProposalValidationResult>;
|
|
46
|
+
private getParentBlock;
|
|
38
47
|
private getReexecutionDeadline;
|
|
39
48
|
private getReexecuteFailureReason;
|
|
40
|
-
reexecuteTransactions(proposal: BlockProposal, txs: Tx[], l1ToL2Messages: Fr[]): Promise<
|
|
41
|
-
block: any;
|
|
42
|
-
failedTxs: FailedTx[];
|
|
43
|
-
reexecutionTimeMs: number;
|
|
44
|
-
totalManaUsed: number;
|
|
45
|
-
}>;
|
|
49
|
+
reexecuteTransactions(proposal: BlockProposal, blockNumber: number, txs: Tx[], l1ToL2Messages: Fr[]): Promise<ReexecuteTransactionsResult>;
|
|
46
50
|
}
|
|
51
|
+
export {};
|
|
47
52
|
//# sourceMappingURL=block_proposal_handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_proposal_handler.d.ts","sourceRoot":"","sources":["../src/block_proposal_handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"block_proposal_handler.d.ts","sourceRoot":"","sources":["../src/block_proposal_handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EAAE,YAAY,EAAS,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AACxG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,mBAAmB,CA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AC;gBAGrB,YAAY,EAAE,qBAAqB,EACnC,WAAW,EAAE,aAAa,EAC1B,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,UAAU,EACtB,sBAAsB,EAAE,sBAAsB,EAC9C,MAAM,EAAE,yBAAyB,EACjC,OAAO,CAAC,EAAE,gBAAgB,YAAA,EAC1B,YAAY,GAAE,YAAiC,EACvD,SAAS,GAAE,eAAsC,EACzC,GAAG,yCAAmD;IAKhE,sBAAsB,CAAC,SAAS,EAAE,GAAG,GAAG,oBAAoB;IA2BtD,mBAAmB,CACvB,QAAQ,EAAE,aAAa,EACvB,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,OAAO,GACvB,OAAO,CAAC,6BAA6B,CAAC;YA+F3B,cAAc;IAqC5B,OAAO,CAAC,sBAAsB;IAM9B,OAAO,CAAC,yBAAyB;IAY3B,qBAAqB,CACzB,QAAQ,EAAE,aAAa,EACvB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,EAAE,EAAE,EACT,cAAc,EAAE,EAAE,EAAE,GACnB,OAAO,CAAC,2BAA2B,CAAC;CA8ExC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
|
+
import { TimeoutError } from '@aztec/foundation/error';
|
|
2
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
@@ -36,16 +37,16 @@ export class BlockProposalHandler {
|
|
|
36
37
|
const handler = async (proposal, proposalSender)=>{
|
|
37
38
|
try {
|
|
38
39
|
const result = await this.handleBlockProposal(proposal, proposalSender, true);
|
|
39
|
-
if (result.isValid
|
|
40
|
+
if (result.isValid) {
|
|
40
41
|
this.log.info(`Non-validator reexecution completed for slot ${proposal.slotNumber.toBigInt()}`, {
|
|
41
|
-
blockNumber:
|
|
42
|
-
reexecutionTimeMs: result.reexecutionResult
|
|
43
|
-
totalManaUsed: result.reexecutionResult
|
|
44
|
-
numTxs: result.reexecutionResult
|
|
42
|
+
blockNumber: result.blockNumber,
|
|
43
|
+
reexecutionTimeMs: result.reexecutionResult?.reexecutionTimeMs,
|
|
44
|
+
totalManaUsed: result.reexecutionResult?.totalManaUsed,
|
|
45
|
+
numTxs: result.reexecutionResult?.block?.body?.txEffects?.length ?? 0
|
|
45
46
|
});
|
|
46
47
|
} else {
|
|
47
48
|
this.log.warn(`Non-validator reexecution failed for slot ${proposal.slotNumber.toBigInt()}`, {
|
|
48
|
-
blockNumber:
|
|
49
|
+
blockNumber: result.blockNumber,
|
|
49
50
|
reason: result.reason
|
|
50
51
|
});
|
|
51
52
|
}
|
|
@@ -59,8 +60,16 @@ export class BlockProposalHandler {
|
|
|
59
60
|
}
|
|
60
61
|
async handleBlockProposal(proposal, proposalSender, shouldReexecute) {
|
|
61
62
|
const slotNumber = proposal.slotNumber.toBigInt();
|
|
62
|
-
const blockNumber = proposal.blockNumber;
|
|
63
63
|
const proposer = proposal.getSender();
|
|
64
|
+
const config = this.blockBuilder.getConfig();
|
|
65
|
+
// Reject proposals with invalid signatures
|
|
66
|
+
if (!proposer) {
|
|
67
|
+
this.log.warn(`Received proposal with invalid signature for slot ${slotNumber}`);
|
|
68
|
+
return {
|
|
69
|
+
isValid: false,
|
|
70
|
+
reason: 'invalid_proposal'
|
|
71
|
+
};
|
|
72
|
+
}
|
|
64
73
|
const proposalInfo = {
|
|
65
74
|
...proposal.toBlockInfo(),
|
|
66
75
|
proposer: proposer.toString()
|
|
@@ -79,46 +88,45 @@ export class BlockProposalHandler {
|
|
|
79
88
|
reason: 'invalid_proposal'
|
|
80
89
|
};
|
|
81
90
|
}
|
|
91
|
+
// Check that the parent proposal is a block we know, otherwise reexecution would fail
|
|
92
|
+
const parentBlockHeader = await this.getParentBlock(proposal);
|
|
93
|
+
if (parentBlockHeader === undefined) {
|
|
94
|
+
this.log.warn(`Parent block for proposal not found, skipping processing`, proposalInfo);
|
|
95
|
+
return {
|
|
96
|
+
isValid: false,
|
|
97
|
+
reason: 'parent_block_not_found'
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// Check that the parent block's slot is less than the proposal's slot (should not happen, but we check anyway)
|
|
101
|
+
if (parentBlockHeader !== 'genesis' && parentBlockHeader.getSlot() >= slotNumber) {
|
|
102
|
+
this.log.warn(`Parent block slot is greater than or equal to proposal slot, skipping processing`, {
|
|
103
|
+
parentBlockSlot: parentBlockHeader.getSlot().toString(),
|
|
104
|
+
proposalSlot: slotNumber.toString(),
|
|
105
|
+
...proposalInfo
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
isValid: false,
|
|
109
|
+
reason: 'parent_block_wrong_slot'
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
// Compute the block number based on the parent block
|
|
113
|
+
const blockNumber = parentBlockHeader === 'genesis' ? INITIAL_L2_BLOCK_NUM : parentBlockHeader.getBlockNumber() + 1;
|
|
114
|
+
// Check that this block number does not exist already
|
|
115
|
+
const existingBlock = await this.blockSource.getBlockHeader(blockNumber);
|
|
116
|
+
if (existingBlock) {
|
|
117
|
+
this.log.warn(`Block number ${blockNumber} already exists, skipping processing`, proposalInfo);
|
|
118
|
+
return {
|
|
119
|
+
isValid: false,
|
|
120
|
+
blockNumber,
|
|
121
|
+
reason: 'block_number_already_exists'
|
|
122
|
+
};
|
|
123
|
+
}
|
|
82
124
|
// Collect txs from the proposal. We start doing this as early as possible,
|
|
83
|
-
// and we do it even if we don't plan to re-execute the txs, so that we have them
|
|
84
|
-
|
|
85
|
-
const config = this.blockBuilder.getConfig();
|
|
86
|
-
const { txs, missingTxs } = await this.txProvider.getTxsForBlockProposal(proposal, {
|
|
125
|
+
// and we do it even if we don't plan to re-execute the txs, so that we have them if another node needs them.
|
|
126
|
+
const { txs, missingTxs } = await this.txProvider.getTxsForBlockProposal(proposal, blockNumber, {
|
|
87
127
|
pinnedPeer: proposalSender,
|
|
88
|
-
deadline: this.getReexecutionDeadline(
|
|
128
|
+
deadline: this.getReexecutionDeadline(slotNumber, config)
|
|
89
129
|
});
|
|
90
|
-
// Check that the parent proposal is a block we know, otherwise reexecution would fail
|
|
91
|
-
if (blockNumber > INITIAL_L2_BLOCK_NUM) {
|
|
92
|
-
const deadline = this.getReexecutionDeadline(proposal, config);
|
|
93
|
-
const currentTime = this.dateProvider.now();
|
|
94
|
-
const timeoutDurationMs = deadline.getTime() - currentTime;
|
|
95
|
-
const parentBlock = timeoutDurationMs <= 0 ? undefined : await retryUntil(async ()=>{
|
|
96
|
-
const block = await this.blockSource.getBlock(blockNumber - 1);
|
|
97
|
-
if (block) {
|
|
98
|
-
return block;
|
|
99
|
-
}
|
|
100
|
-
await this.blockSource.syncImmediate();
|
|
101
|
-
return await this.blockSource.getBlock(blockNumber - 1);
|
|
102
|
-
}, 'Force Archiver Sync', timeoutDurationMs / 1000, 0.5);
|
|
103
|
-
if (parentBlock === undefined) {
|
|
104
|
-
this.log.warn(`Parent block for ${blockNumber} not found, skipping processing`, proposalInfo);
|
|
105
|
-
return {
|
|
106
|
-
isValid: false,
|
|
107
|
-
reason: 'parent_block_not_found'
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
if (!proposal.payload.header.lastArchiveRoot.equals(parentBlock.archive.root)) {
|
|
111
|
-
this.log.warn(`Parent block archive root for proposal does not match, skipping processing`, {
|
|
112
|
-
proposalLastArchiveRoot: proposal.payload.header.lastArchiveRoot.toString(),
|
|
113
|
-
parentBlockArchiveRoot: parentBlock.archive.root.toString(),
|
|
114
|
-
...proposalInfo
|
|
115
|
-
});
|
|
116
|
-
return {
|
|
117
|
-
isValid: false,
|
|
118
|
-
reason: 'parent_block_does_not_match'
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
130
|
// Check that I have the same set of l1ToL2Messages as the proposal
|
|
123
131
|
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(blockNumber);
|
|
124
132
|
const computedInHash = await computeInHashFromL1ToL2Messages(l1ToL2Messages);
|
|
@@ -131,18 +139,10 @@ export class BlockProposalHandler {
|
|
|
131
139
|
});
|
|
132
140
|
return {
|
|
133
141
|
isValid: false,
|
|
142
|
+
blockNumber,
|
|
134
143
|
reason: 'in_hash_mismatch'
|
|
135
144
|
};
|
|
136
145
|
}
|
|
137
|
-
// Check that this block number does not exist already
|
|
138
|
-
const existingBlock = await this.blockSource.getBlockHeader(blockNumber);
|
|
139
|
-
if (existingBlock) {
|
|
140
|
-
this.log.warn(`Block number ${blockNumber} already exists, skipping processing`, proposalInfo);
|
|
141
|
-
return {
|
|
142
|
-
isValid: false,
|
|
143
|
-
reason: 'block_number_already_exists'
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
146
|
// Check that all of the transactions in the proposal are available
|
|
147
147
|
if (missingTxs.length > 0) {
|
|
148
148
|
this.log.warn(`Missing ${missingTxs.length} txs to process proposal`, {
|
|
@@ -151,6 +151,7 @@ export class BlockProposalHandler {
|
|
|
151
151
|
});
|
|
152
152
|
return {
|
|
153
153
|
isValid: false,
|
|
154
|
+
blockNumber,
|
|
154
155
|
reason: 'txs_not_available'
|
|
155
156
|
};
|
|
156
157
|
}
|
|
@@ -159,12 +160,13 @@ export class BlockProposalHandler {
|
|
|
159
160
|
if (shouldReexecute) {
|
|
160
161
|
try {
|
|
161
162
|
this.log.verbose(`Re-executing transactions in the proposal`, proposalInfo);
|
|
162
|
-
reexecutionResult = await this.reexecuteTransactions(proposal, txs, l1ToL2Messages);
|
|
163
|
+
reexecutionResult = await this.reexecuteTransactions(proposal, blockNumber, txs, l1ToL2Messages);
|
|
163
164
|
} catch (error) {
|
|
164
165
|
this.log.error(`Error reexecuting txs while processing block proposal`, error, proposalInfo);
|
|
165
166
|
const reason = this.getReexecuteFailureReason(error);
|
|
166
167
|
return {
|
|
167
168
|
isValid: false,
|
|
169
|
+
blockNumber,
|
|
168
170
|
reason,
|
|
169
171
|
reexecutionResult
|
|
170
172
|
};
|
|
@@ -173,11 +175,38 @@ export class BlockProposalHandler {
|
|
|
173
175
|
this.log.info(`Successfully processed proposal for slot ${slotNumber}`, proposalInfo);
|
|
174
176
|
return {
|
|
175
177
|
isValid: true,
|
|
178
|
+
blockNumber,
|
|
176
179
|
reexecutionResult
|
|
177
180
|
};
|
|
178
181
|
}
|
|
179
|
-
|
|
180
|
-
const
|
|
182
|
+
async getParentBlock(proposal) {
|
|
183
|
+
const parentArchive = proposal.payload.header.lastArchiveRoot;
|
|
184
|
+
const slot = proposal.slotNumber.toBigInt();
|
|
185
|
+
const config = this.blockBuilder.getConfig();
|
|
186
|
+
const { genesisArchiveRoot } = await this.blockSource.getGenesisValues();
|
|
187
|
+
if (parentArchive.equals(genesisArchiveRoot)) {
|
|
188
|
+
return 'genesis';
|
|
189
|
+
}
|
|
190
|
+
const deadline = this.getReexecutionDeadline(slot, config);
|
|
191
|
+
const currentTime = this.dateProvider.now();
|
|
192
|
+
const timeoutDurationMs = deadline.getTime() - currentTime;
|
|
193
|
+
try {
|
|
194
|
+
return await this.blockSource.getBlockHeaderByArchive(parentArchive) ?? (timeoutDurationMs <= 0 ? undefined : await retryUntil(()=>this.blockSource.syncImmediate().then(()=>this.blockSource.getBlockHeaderByArchive(parentArchive)), 'force archiver sync', timeoutDurationMs / 1000, 0.5));
|
|
195
|
+
} catch (err) {
|
|
196
|
+
if (err instanceof TimeoutError) {
|
|
197
|
+
this.log.debug(`Timed out getting parent block by archive root`, {
|
|
198
|
+
parentArchive
|
|
199
|
+
});
|
|
200
|
+
} else {
|
|
201
|
+
this.log.error('Error getting parent block by archive root', err, {
|
|
202
|
+
parentArchive
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
getReexecutionDeadline(slot, config) {
|
|
209
|
+
const nextSlotTimestampSeconds = Number(getTimestampForSlot(slot + 1n, config));
|
|
181
210
|
const msNeededForPropagationAndPublishing = this.config.validatorReexecuteDeadlineMs;
|
|
182
211
|
return new Date(nextSlotTimestampSeconds * 1000 - msNeededForPropagationAndPublishing);
|
|
183
212
|
}
|
|
@@ -188,11 +217,11 @@ export class BlockProposalHandler {
|
|
|
188
217
|
return 'failed_txs';
|
|
189
218
|
} else if (err instanceof ReExTimeoutError) {
|
|
190
219
|
return 'timeout';
|
|
191
|
-
} else
|
|
220
|
+
} else {
|
|
192
221
|
return 'unknown_error';
|
|
193
222
|
}
|
|
194
223
|
}
|
|
195
|
-
async reexecuteTransactions(proposal, txs, l1ToL2Messages) {
|
|
224
|
+
async reexecuteTransactions(proposal, blockNumber, txs, l1ToL2Messages) {
|
|
196
225
|
const { header } = proposal.payload;
|
|
197
226
|
const { txHashes } = proposal;
|
|
198
227
|
// If we do not have all of the transactions, then we should fail
|
|
@@ -210,13 +239,13 @@ export class BlockProposalHandler {
|
|
|
210
239
|
coinbase: proposal.payload.header.coinbase,
|
|
211
240
|
feeRecipient: proposal.payload.header.feeRecipient,
|
|
212
241
|
gasFees: proposal.payload.header.gasFees,
|
|
213
|
-
blockNumber
|
|
242
|
+
blockNumber,
|
|
214
243
|
timestamp: header.timestamp,
|
|
215
244
|
chainId: new Fr(config.l1ChainId),
|
|
216
245
|
version: new Fr(config.rollupVersion)
|
|
217
246
|
});
|
|
218
247
|
const { block, failedTxs } = await this.blockBuilder.buildBlock(txs, l1ToL2Messages, globalVariables, {
|
|
219
|
-
deadline: this.getReexecutionDeadline(proposal, config)
|
|
248
|
+
deadline: this.getReexecutionDeadline(proposal.payload.header.slotNumber.toBigInt(), config)
|
|
220
249
|
});
|
|
221
250
|
const numFailedTxs = failedTxs.length;
|
|
222
251
|
const slot = proposal.slotNumber.toBigInt();
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import { Signature } from '@aztec/foundation/eth-signature';
|
|
3
|
-
import
|
|
2
|
+
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import type { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
5
5
|
import { BlockAttestation, BlockProposal, type BlockProposalOptions } from '@aztec/stdlib/p2p';
|
|
6
|
-
import type {
|
|
6
|
+
import type { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
7
|
+
import { StateReference, type Tx } from '@aztec/stdlib/tx';
|
|
7
8
|
import type { ValidatorKeyStore } from '../key_store/interface.js';
|
|
8
9
|
export declare class ValidationService {
|
|
9
10
|
private keyStore;
|
|
10
|
-
|
|
11
|
+
private log;
|
|
12
|
+
constructor(keyStore: ValidatorKeyStore, log?: import("@aztec/foundation/log").Logger);
|
|
11
13
|
/**
|
|
12
14
|
* Create a block proposal with the given header, archive, and transactions
|
|
13
15
|
*
|
|
14
|
-
* @param blockNumber - The block number this proposal is for
|
|
15
16
|
* @param header - The block header
|
|
16
17
|
* @param archive - The archive of the current block
|
|
17
18
|
* @param txs - TxHash[] ordered list of transactions
|
|
19
|
+
* @param options - Block proposal options (including broadcastInvalidBlockProposal for testing)
|
|
18
20
|
*
|
|
19
21
|
* @returns A block proposal signing the above information (not the current implementation!!!)
|
|
20
22
|
*/
|
|
21
|
-
createBlockProposal(
|
|
23
|
+
createBlockProposal(header: CheckpointHeader, archive: Fr, stateReference: StateReference, txs: Tx[], proposerAttesterAddress: EthAddress | undefined, options: BlockProposalOptions): Promise<BlockProposal>;
|
|
22
24
|
/**
|
|
23
25
|
* Attest with selection of validators to the given block proposal, constructed by the current sequencer
|
|
24
26
|
*
|
|
@@ -30,6 +32,6 @@ export declare class ValidationService {
|
|
|
30
32
|
* @returns attestations
|
|
31
33
|
*/
|
|
32
34
|
attestToProposal(proposal: BlockProposal, attestors: EthAddress[]): Promise<BlockAttestation[]>;
|
|
33
|
-
signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress
|
|
35
|
+
signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress): Promise<Signature>;
|
|
34
36
|
}
|
|
35
37
|
//# sourceMappingURL=validation_service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation_service.d.ts","sourceRoot":"","sources":["../../src/duties/validation_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"validation_service.d.ts","sourceRoot":"","sources":["../../src/duties/validation_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,KAAK,oBAAoB,EAG1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,GAAG;gBADH,QAAQ,EAAE,iBAAiB,EAC3B,GAAG,yCAA+C;IAG5D;;;;;;;;;OASG;IACG,mBAAmB,CACvB,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,EAAE,EACX,cAAc,EAAE,cAAc,EAC9B,GAAG,EAAE,EAAE,EAAE,EACT,uBAAuB,EAAE,UAAU,GAAG,SAAS,EAC/C,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,aAAa,CAAC;IA0BzB;;;;;;;;;OASG;IACG,gBAAgB,CAAC,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAU/F,0BAA0B,CAC9B,sBAAsB,EAAE,+BAA+B,EACvD,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,SAAS,CAAC;CAMtB"}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
2
|
import { keccak256 } from '@aztec/foundation/crypto';
|
|
3
|
-
import {
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { unfreeze } from '@aztec/foundation/types';
|
|
4
5
|
import { BlockAttestation, BlockProposal, ConsensusPayload, SignatureDomainSeparator } from '@aztec/stdlib/p2p';
|
|
6
|
+
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
5
7
|
export class ValidationService {
|
|
6
8
|
keyStore;
|
|
7
|
-
|
|
9
|
+
log;
|
|
10
|
+
constructor(keyStore, log = createLogger('validator:validation-service')){
|
|
8
11
|
this.keyStore = keyStore;
|
|
12
|
+
this.log = log;
|
|
9
13
|
}
|
|
10
14
|
/**
|
|
11
15
|
* Create a block proposal with the given header, archive, and transactions
|
|
12
16
|
*
|
|
13
|
-
* @param blockNumber - The block number this proposal is for
|
|
14
17
|
* @param header - The block header
|
|
15
18
|
* @param archive - The archive of the current block
|
|
16
19
|
* @param txs - TxHash[] ordered list of transactions
|
|
20
|
+
* @param options - Block proposal options (including broadcastInvalidBlockProposal for testing)
|
|
17
21
|
*
|
|
18
22
|
* @returns A block proposal signing the above information (not the current implementation!!!)
|
|
19
|
-
*/ async createBlockProposal(
|
|
23
|
+
*/ async createBlockProposal(header, archive, stateReference, txs, proposerAttesterAddress, options) {
|
|
20
24
|
let payloadSigner;
|
|
21
25
|
if (proposerAttesterAddress !== undefined) {
|
|
22
26
|
payloadSigner = (payload)=>this.keyStore.signMessageWithAddress(proposerAttesterAddress, payload);
|
|
@@ -27,7 +31,12 @@ export class ValidationService {
|
|
|
27
31
|
}
|
|
28
32
|
// TODO: check if this is calculated earlier / can not be recomputed
|
|
29
33
|
const txHashes = await Promise.all(txs.map((tx)=>tx.getTxHash()));
|
|
30
|
-
|
|
34
|
+
// For testing: corrupt the state reference to trigger state_mismatch validation failure
|
|
35
|
+
if (options.broadcastInvalidBlockProposal) {
|
|
36
|
+
unfreeze(stateReference.partial).noteHashTree = AppendOnlyTreeSnapshot.random();
|
|
37
|
+
this.log.warn(`Creating INVALID block proposal for slot ${header.slotNumber.toBigInt()}`);
|
|
38
|
+
}
|
|
39
|
+
return BlockProposal.createProposalFromSigner(new ConsensusPayload(header, archive, stateReference), txHashes, options.publishFullTxs ? txs : undefined, payloadSigner);
|
|
31
40
|
}
|
|
32
41
|
/**
|
|
33
42
|
* Attest with selection of validators to the given block proposal, constructed by the current sequencer
|
|
@@ -41,13 +50,9 @@ export class ValidationService {
|
|
|
41
50
|
*/ async attestToProposal(proposal, attestors) {
|
|
42
51
|
const buf = Buffer32.fromBuffer(keccak256(proposal.payload.getPayloadToSign(SignatureDomainSeparator.blockAttestation)));
|
|
43
52
|
const signatures = await Promise.all(attestors.map((attestor)=>this.keyStore.signMessageWithAddress(attestor, buf)));
|
|
44
|
-
|
|
45
|
-
return signatures.map((sig)=>new BlockAttestation(proposal.blockNumber, proposal.payload, sig));
|
|
53
|
+
return signatures.map((sig)=>new BlockAttestation(proposal.payload, sig, proposal.signature));
|
|
46
54
|
}
|
|
47
55
|
async signAttestationsAndSigners(attestationsAndSigners, proposer) {
|
|
48
|
-
if (proposer === undefined) {
|
|
49
|
-
return Signature.empty();
|
|
50
|
-
}
|
|
51
56
|
const buf = Buffer32.fromBuffer(keccak256(attestationsAndSigners.getPayloadToSign(SignatureDomainSeparator.attestationsAndSigners)));
|
|
52
57
|
return await this.keyStore.signMessageWithAddress(proposer, buf);
|
|
53
58
|
}
|
package/dest/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AACxG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,yBAAyB,EACjC,IAAI,EAAE;IACJ,YAAY,EAAE,qBAAqB,CAAC;IACpC,WAAW,EAAE,aAAa,CAAC;IAC3B,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,eAAe,CAAC;CAC5B,
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AACxG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,yBAAyB,EACjC,IAAI,EAAE;IACJ,YAAY,EAAE,qBAAqB,CAAC;IACpC,WAAW,EAAE,aAAa,CAAC;IAC3B,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,eAAe,CAAC;CAC5B,wBAiBF;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,yBAAyB,EACjC,IAAI,EAAE;IACJ,YAAY,EAAE,qBAAqB,CAAC;IACpC,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,aAAa,CAAC;IAC3B,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,SAAS,EAAE,eAAe,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,eAAe,GAAG,SAAS,CAAC;CAC9C,+BAmBF"}
|
package/dest/factory.js
CHANGED
|
@@ -4,7 +4,9 @@ import { ValidatorMetrics } from './metrics.js';
|
|
|
4
4
|
import { ValidatorClient } from './validator.js';
|
|
5
5
|
export function createBlockProposalHandler(config, deps) {
|
|
6
6
|
const metrics = new ValidatorMetrics(deps.telemetry);
|
|
7
|
-
const blockProposalValidator = new BlockProposalValidator(deps.epochCache
|
|
7
|
+
const blockProposalValidator = new BlockProposalValidator(deps.epochCache, {
|
|
8
|
+
txsPermitted: !config.disableTransactions
|
|
9
|
+
});
|
|
8
10
|
return new BlockProposalHandler(deps.blockBuilder, deps.blockSource, deps.l1ToL2MessageSource, deps.p2pClient.getTxProvider(), blockProposalValidator, config, metrics, deps.dateProvider, deps.telemetry);
|
|
9
11
|
}
|
|
10
12
|
export function createValidatorClient(config, deps) {
|
package/dest/metrics.d.ts
CHANGED
|
@@ -2,15 +2,17 @@ import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
|
2
2
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
3
3
|
export declare class ValidatorMetrics {
|
|
4
4
|
private failedReexecutionCounter;
|
|
5
|
-
private
|
|
6
|
-
private
|
|
5
|
+
private successfulAttestationsCount;
|
|
6
|
+
private failedAttestationsBadProposalCount;
|
|
7
|
+
private failedAttestationsNodeIssueCount;
|
|
7
8
|
private reexMana;
|
|
8
9
|
private reexTx;
|
|
9
10
|
private reexDuration;
|
|
10
11
|
constructor(telemetryClient: TelemetryClient);
|
|
11
12
|
recordReex(time: number, txs: number, mManaTotal: number): void;
|
|
12
13
|
recordFailedReexecution(proposal: BlockProposal): void;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
incSuccessfulAttestations(num: number): void;
|
|
15
|
+
incFailedAttestationsBadProposal(num: number, reason: string): void;
|
|
16
|
+
incFailedAttestationsNodeIssue(num: number, reason: string): void;
|
|
15
17
|
}
|
|
16
18
|
//# sourceMappingURL=metrics.d.ts.map
|
package/dest/metrics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAIL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,wBAAwB,CAAgB;IAChD,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAIL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,wBAAwB,CAAgB;IAChD,OAAO,CAAC,2BAA2B,CAAgB;IACnD,OAAO,CAAC,kCAAkC,CAAgB;IAC1D,OAAO,CAAC,gCAAgC,CAAgB;IAExD,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,YAAY,CAAY;gBAEpB,eAAe,EAAE,eAAe;IAiDrC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAMxD,uBAAuB,CAAC,QAAQ,EAAE,aAAa;IAQ/C,yBAAyB,CAAC,GAAG,EAAE,MAAM;IAIrC,gCAAgC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAM5D,8BAA8B,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAKlE"}
|
package/dest/metrics.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
|
|
2
2
|
export class ValidatorMetrics {
|
|
3
3
|
failedReexecutionCounter;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
successfulAttestationsCount;
|
|
5
|
+
failedAttestationsBadProposalCount;
|
|
6
|
+
failedAttestationsNodeIssueCount;
|
|
6
7
|
reexMana;
|
|
7
8
|
reexTx;
|
|
8
9
|
reexDuration;
|
|
@@ -13,12 +14,16 @@ export class ValidatorMetrics {
|
|
|
13
14
|
unit: 'count',
|
|
14
15
|
valueType: ValueType.INT
|
|
15
16
|
});
|
|
16
|
-
this.
|
|
17
|
-
description: 'The number of attestations',
|
|
17
|
+
this.successfulAttestationsCount = meter.createUpDownCounter(Metrics.VALIDATOR_ATTESTATION_SUCCESS_COUNT, {
|
|
18
|
+
description: 'The number of successful attestations',
|
|
18
19
|
valueType: ValueType.INT
|
|
19
20
|
});
|
|
20
|
-
this.
|
|
21
|
-
description: 'The number of failed attestations',
|
|
21
|
+
this.failedAttestationsBadProposalCount = meter.createUpDownCounter(Metrics.VALIDATOR_ATTESTATION_FAILED_BAD_PROPOSAL_COUNT, {
|
|
22
|
+
description: 'The number of failed attestations due to invalid block proposals',
|
|
23
|
+
valueType: ValueType.INT
|
|
24
|
+
});
|
|
25
|
+
this.failedAttestationsNodeIssueCount = meter.createUpDownCounter(Metrics.VALIDATOR_ATTESTATION_FAILED_NODE_ISSUE_COUNT, {
|
|
26
|
+
description: 'The number of failed attestations due to node issues (timeout, missing data, etc.)',
|
|
22
27
|
valueType: ValueType.INT
|
|
23
28
|
});
|
|
24
29
|
this.reexMana = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_MANA, {
|
|
@@ -43,18 +48,23 @@ export class ValidatorMetrics {
|
|
|
43
48
|
this.reexMana.record(mManaTotal);
|
|
44
49
|
}
|
|
45
50
|
recordFailedReexecution(proposal) {
|
|
51
|
+
const proposer = proposal.getSender();
|
|
46
52
|
this.failedReexecutionCounter.add(1, {
|
|
47
53
|
[Attributes.STATUS]: 'failed',
|
|
48
|
-
[Attributes.BLOCK_PROPOSER]:
|
|
54
|
+
[Attributes.BLOCK_PROPOSER]: proposer?.toString() ?? 'unknown'
|
|
49
55
|
});
|
|
50
56
|
}
|
|
51
|
-
|
|
52
|
-
this.
|
|
57
|
+
incSuccessfulAttestations(num) {
|
|
58
|
+
this.successfulAttestationsCount.add(num);
|
|
59
|
+
}
|
|
60
|
+
incFailedAttestationsBadProposal(num, reason) {
|
|
61
|
+
this.failedAttestationsBadProposalCount.add(num, {
|
|
62
|
+
[Attributes.ERROR_TYPE]: reason
|
|
63
|
+
});
|
|
53
64
|
}
|
|
54
|
-
|
|
55
|
-
this.
|
|
56
|
-
[Attributes.ERROR_TYPE]: reason
|
|
57
|
-
[Attributes.VALIDATOR_STATUS]: inCommittee ? 'in-committee' : 'none'
|
|
65
|
+
incFailedAttestationsNodeIssue(num, reason) {
|
|
66
|
+
this.failedAttestationsNodeIssueCount.add(num, {
|
|
67
|
+
[Attributes.ERROR_TYPE]: reason
|
|
58
68
|
});
|
|
59
69
|
}
|
|
60
70
|
}
|
package/dest/validator.d.ts
CHANGED
|
@@ -2,20 +2,21 @@ import type { EpochCache } from '@aztec/epoch-cache';
|
|
|
2
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
5
6
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
6
7
|
import type { KeystoreManager } from '@aztec/node-keystore';
|
|
7
8
|
import type { P2P, PeerId, TxProvider } from '@aztec/p2p';
|
|
8
|
-
import { type
|
|
9
|
+
import { type Watcher, type WatcherEmitter } from '@aztec/slasher';
|
|
9
10
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
11
|
import type { CommitteeAttestationsAndSigners, L2BlockSource } from '@aztec/stdlib/block';
|
|
11
12
|
import type { IFullNodeBlockBuilder, Validator, ValidatorClientFullConfig } from '@aztec/stdlib/interfaces/server';
|
|
12
13
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
13
14
|
import type { BlockAttestation, BlockProposal, BlockProposalOptions } from '@aztec/stdlib/p2p';
|
|
14
|
-
import type {
|
|
15
|
+
import type { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
16
|
+
import type { StateReference, Tx } from '@aztec/stdlib/tx';
|
|
15
17
|
import { type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
|
|
16
18
|
import type { TypedDataDefinition } from 'viem';
|
|
17
19
|
import { BlockProposalHandler } from './block_proposal_handler.js';
|
|
18
|
-
import type { ValidatorClientConfig } from './config.js';
|
|
19
20
|
import { NodeKeystoreAdapter } from './key_store/node_keystore_adapter.js';
|
|
20
21
|
declare const ValidatorClient_base: new () => WatcherEmitter;
|
|
21
22
|
/**
|
|
@@ -37,13 +38,13 @@ export declare class ValidatorClient extends ValidatorClient_base implements Val
|
|
|
37
38
|
private lastEpochForCommitteeUpdateLoop;
|
|
38
39
|
private epochCacheUpdateLoop;
|
|
39
40
|
private proposersOfInvalidBlocks;
|
|
40
|
-
protected constructor(keyStore: NodeKeystoreAdapter, epochCache: EpochCache, p2pClient: P2P, blockProposalHandler: BlockProposalHandler, config: ValidatorClientFullConfig, dateProvider?: DateProvider, telemetry?: TelemetryClient, log?:
|
|
41
|
-
static validateKeyStoreConfiguration(keyStoreManager: KeystoreManager): void;
|
|
41
|
+
protected constructor(keyStore: NodeKeystoreAdapter, epochCache: EpochCache, p2pClient: P2P, blockProposalHandler: BlockProposalHandler, config: ValidatorClientFullConfig, dateProvider?: DateProvider, telemetry?: TelemetryClient, log?: Logger);
|
|
42
|
+
static validateKeyStoreConfiguration(keyStoreManager: KeystoreManager, logger?: Logger): void;
|
|
42
43
|
private handleEpochCommitteeUpdate;
|
|
43
|
-
static new(config:
|
|
44
|
+
static new(config: ValidatorClientFullConfig, blockBuilder: IFullNodeBlockBuilder, epochCache: EpochCache, p2pClient: P2P, blockSource: L2BlockSource, l1ToL2MessageSource: L1ToL2MessageSource, txProvider: TxProvider, keyStoreManager: KeystoreManager, dateProvider?: DateProvider, telemetry?: TelemetryClient): ValidatorClient;
|
|
44
45
|
getValidatorAddresses(): EthAddress[];
|
|
45
46
|
getBlockProposalHandler(): BlockProposalHandler;
|
|
46
|
-
reExecuteTransactions(proposal: BlockProposal, txs: any[], l1ToL2Messages: Fr[]): Promise<any>;
|
|
47
|
+
reExecuteTransactions(proposal: BlockProposal, blockNumber: number, txs: any[], l1ToL2Messages: Fr[]): Promise<any>;
|
|
47
48
|
signWithAddress(addr: EthAddress, msg: TypedDataDefinition): Promise<Signature>;
|
|
48
49
|
getCoinbaseForAttestor(attestor: EthAddress): EthAddress;
|
|
49
50
|
getFeeRecipientForAttestor(attestor: EthAddress): AztecAddress;
|
|
@@ -55,9 +56,9 @@ export declare class ValidatorClient extends ValidatorClient_base implements Val
|
|
|
55
56
|
registerHandlers(): Promise<void>;
|
|
56
57
|
attestToProposal(proposal: BlockProposal, proposalSender: PeerId): Promise<BlockAttestation[] | undefined>;
|
|
57
58
|
private slashInvalidBlock;
|
|
58
|
-
createBlockProposal(blockNumber: number, header:
|
|
59
|
+
createBlockProposal(blockNumber: number, header: CheckpointHeader, archive: Fr, stateReference: StateReference, txs: Tx[], proposerAddress: EthAddress | undefined, options: BlockProposalOptions): Promise<BlockProposal | undefined>;
|
|
59
60
|
broadcastBlockProposal(proposal: BlockProposal): Promise<void>;
|
|
60
|
-
signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress
|
|
61
|
+
signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress): Promise<Signature>;
|
|
61
62
|
collectOwnAttestations(proposal: BlockProposal): Promise<BlockAttestation[]>;
|
|
62
63
|
collectAttestations(proposal: BlockProposal, required: number, deadline: Date): Promise<BlockAttestation[]>;
|
|
63
64
|
private createBlockAttestationsFromProposal;
|
package/dest/validator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AA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