@aztec/sequencer-client 3.0.0-nightly.20251221 → 3.0.0-nightly.20251223
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/client/sequencer-client.d.ts +9 -8
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +28 -24
- package/dest/config.d.ts +7 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +63 -26
- package/dest/global_variable_builder/global_builder.d.ts +16 -8
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +35 -26
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/publisher/config.d.ts +3 -3
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +2 -2
- package/dest/publisher/sequencer-publisher-factory.d.ts +3 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.d.ts +11 -24
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +50 -62
- package/dest/sequencer/block_builder.d.ts +1 -3
- package/dest/sequencer/block_builder.d.ts.map +1 -1
- package/dest/sequencer/block_builder.js +4 -2
- package/dest/sequencer/checkpoint_builder.d.ts +63 -0
- package/dest/sequencer/checkpoint_builder.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_builder.js +131 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +73 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +638 -0
- package/dest/sequencer/checkpoint_voter.d.ts +34 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +85 -0
- package/dest/sequencer/events.d.ts +46 -0
- package/dest/sequencer/events.d.ts.map +1 -0
- package/dest/sequencer/events.js +1 -0
- package/dest/sequencer/index.d.ts +5 -1
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +4 -0
- package/dest/sequencer/metrics.d.ts +3 -1
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +9 -0
- package/dest/sequencer/sequencer.d.ts +87 -127
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +179 -596
- package/dest/sequencer/timetable.d.ts +33 -13
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +73 -39
- package/dest/sequencer/types.d.ts +3 -0
- package/dest/sequencer/types.d.ts.map +1 -0
- package/dest/sequencer/types.js +1 -0
- package/dest/sequencer/utils.d.ts +14 -8
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +7 -4
- package/dest/test/index.d.ts +3 -1
- package/dest/test/index.d.ts.map +1 -1
- package/package.json +27 -27
- package/src/client/sequencer-client.ts +24 -31
- package/src/config.ts +68 -25
- package/src/global_variable_builder/global_builder.ts +45 -39
- package/src/index.ts +2 -0
- package/src/publisher/config.ts +3 -3
- package/src/publisher/sequencer-publisher-factory.ts +3 -3
- package/src/publisher/sequencer-publisher-metrics.ts +2 -2
- package/src/publisher/sequencer-publisher.ts +71 -74
- package/src/sequencer/block_builder.ts +4 -1
- package/src/sequencer/checkpoint_builder.ts +217 -0
- package/src/sequencer/checkpoint_proposal_job.ts +701 -0
- package/src/sequencer/checkpoint_voter.ts +105 -0
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +4 -0
- package/src/sequencer/metrics.ts +11 -0
- package/src/sequencer/sequencer.ts +275 -804
- package/src/sequencer/timetable.ts +84 -49
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +18 -9
- package/src/test/index.ts +2 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
4
|
+
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
5
|
+
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
6
|
+
import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
|
|
7
|
+
import type { ValidatorClient } from '@aztec/validator-client';
|
|
8
|
+
|
|
9
|
+
import type { TypedDataDefinition } from 'viem';
|
|
10
|
+
|
|
11
|
+
import type { SequencerPublisher } from '../publisher/sequencer-publisher.js';
|
|
12
|
+
import type { SequencerMetrics } from './metrics.js';
|
|
13
|
+
import type { SequencerRollupConstants } from './types.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Handles governance and slashing voting for a given slot.
|
|
17
|
+
*/
|
|
18
|
+
export class CheckpointVoter {
|
|
19
|
+
private slotTimestamp: bigint;
|
|
20
|
+
private signer: (msg: TypedDataDefinition) => Promise<`0x${string}`>;
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
private readonly slot: SlotNumber,
|
|
24
|
+
private readonly publisher: SequencerPublisher,
|
|
25
|
+
private readonly attestorAddress: EthAddress,
|
|
26
|
+
private readonly validatorClient: ValidatorClient,
|
|
27
|
+
private readonly slasherClient: SlasherClientInterface | undefined,
|
|
28
|
+
private readonly l1Constants: SequencerRollupConstants,
|
|
29
|
+
private readonly config: ResolvedSequencerConfig,
|
|
30
|
+
private readonly metrics: SequencerMetrics,
|
|
31
|
+
private readonly log: Logger,
|
|
32
|
+
) {
|
|
33
|
+
this.slotTimestamp = getTimestampForSlot(this.slot, this.l1Constants);
|
|
34
|
+
this.signer = (msg: TypedDataDefinition) =>
|
|
35
|
+
this.validatorClient.signWithAddress(this.attestorAddress, msg).then(s => s.toString());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Enqueues governance and slashing votes with the publisher.
|
|
40
|
+
* Returns a tuple of promises that resolve to whether each vote was successfully enqueued.
|
|
41
|
+
*/
|
|
42
|
+
enqueueVotes(): [Promise<boolean | undefined>, Promise<boolean | undefined>] {
|
|
43
|
+
try {
|
|
44
|
+
const enqueueGovernancePromise = this.enqueueGovernanceVote();
|
|
45
|
+
const enqueueSlashingPromise = this.enqueueSlashingVote();
|
|
46
|
+
|
|
47
|
+
return [enqueueGovernancePromise, enqueueSlashingPromise];
|
|
48
|
+
} catch (err) {
|
|
49
|
+
this.log.error(`Error enqueueing governance and slashing votes`, err);
|
|
50
|
+
return [Promise.resolve(false), Promise.resolve(false)];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private async enqueueGovernanceVote(): Promise<boolean | undefined> {
|
|
55
|
+
const governanceProposerPayload = this.config.governanceProposerPayload;
|
|
56
|
+
if (!governanceProposerPayload || governanceProposerPayload.isZero()) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.log.info(`Enqueuing vote for ${governanceProposerPayload} governance for slot ${this.slot}`, {
|
|
61
|
+
slot: this.slot,
|
|
62
|
+
governanceProposerPayload: governanceProposerPayload.toString(),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
return await this.publisher.enqueueGovernanceCastSignal(
|
|
67
|
+
governanceProposerPayload,
|
|
68
|
+
this.slot,
|
|
69
|
+
this.slotTimestamp,
|
|
70
|
+
this.attestorAddress,
|
|
71
|
+
this.signer,
|
|
72
|
+
);
|
|
73
|
+
} catch (err) {
|
|
74
|
+
this.log.error(`Error enqueuing governance vote`, err, { slot: this.slot });
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private async enqueueSlashingVote(): Promise<boolean | undefined> {
|
|
80
|
+
try {
|
|
81
|
+
const actions = await this.slasherClient?.getProposerActions(this.slot);
|
|
82
|
+
if (!actions || actions.length === 0) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.log.info(`Enqueuing vote for ${actions.length} slashing actions for slot ${this.slot}`, {
|
|
87
|
+
slot: this.slot,
|
|
88
|
+
actionCount: actions.length,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
this.metrics.recordSlashingAttempt(actions.length);
|
|
92
|
+
|
|
93
|
+
return await this.publisher.enqueueSlashingActions(
|
|
94
|
+
actions,
|
|
95
|
+
this.slot,
|
|
96
|
+
this.slotTimestamp,
|
|
97
|
+
this.attestorAddress,
|
|
98
|
+
this.signer,
|
|
99
|
+
);
|
|
100
|
+
} catch (err) {
|
|
101
|
+
this.log.error(`Error enqueuing slashing vote`, err, { slot: this.slot });
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
|
|
3
|
+
import type { Action } from '../publisher/sequencer-publisher.js';
|
|
4
|
+
import type { SequencerState } from './utils.js';
|
|
5
|
+
|
|
6
|
+
export type SequencerEvents = {
|
|
7
|
+
['state-changed']: (args: {
|
|
8
|
+
oldState: SequencerState;
|
|
9
|
+
newState: SequencerState;
|
|
10
|
+
secondsIntoSlot?: number;
|
|
11
|
+
slot?: SlotNumber;
|
|
12
|
+
}) => void;
|
|
13
|
+
['proposer-rollup-check-failed']: (args: { reason: string; slot: SlotNumber }) => void;
|
|
14
|
+
['block-tx-count-check-failed']: (args: { minTxs: number; availableTxs: number; slot: SlotNumber }) => void;
|
|
15
|
+
['block-build-failed']: (args: { reason: string; slot: SlotNumber }) => void;
|
|
16
|
+
['block-proposed']: (args: { blockNumber: BlockNumber; slot: SlotNumber }) => void;
|
|
17
|
+
['checkpoint-empty']: (args: { slot: SlotNumber }) => void;
|
|
18
|
+
['checkpoint-publish-failed']: (args: {
|
|
19
|
+
slot: SlotNumber;
|
|
20
|
+
successfulActions?: Action[];
|
|
21
|
+
failedActions?: Action[];
|
|
22
|
+
sentActions?: Action[];
|
|
23
|
+
expiredActions?: Action[];
|
|
24
|
+
}) => void;
|
|
25
|
+
['checkpoint-published']: (args: { checkpoint: CheckpointNumber; slot: SlotNumber }) => void;
|
|
26
|
+
['checkpoint-error']: (args: { error: Error }) => void;
|
|
27
|
+
};
|
package/src/sequencer/index.ts
CHANGED
package/src/sequencer/metrics.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { type Hex, formatUnits } from 'viem';
|
|
|
18
18
|
|
|
19
19
|
import type { SequencerState } from './utils.js';
|
|
20
20
|
|
|
21
|
+
// TODO(palla/mbps): Review all metrics and add any missing ones per checkpoint
|
|
21
22
|
export class SequencerMetrics {
|
|
22
23
|
public readonly tracer: Tracer;
|
|
23
24
|
private meter: Meter;
|
|
@@ -41,6 +42,7 @@ export class SequencerMetrics {
|
|
|
41
42
|
private blockProposalFailed: UpDownCounter;
|
|
42
43
|
private blockProposalSuccess: UpDownCounter;
|
|
43
44
|
private blockProposalPrecheckFailed: UpDownCounter;
|
|
45
|
+
private checkpointSuccess: UpDownCounter;
|
|
44
46
|
private slashingAttempts: UpDownCounter;
|
|
45
47
|
|
|
46
48
|
// Fisherman fee analysis metrics
|
|
@@ -151,6 +153,11 @@ export class SequencerMetrics {
|
|
|
151
153
|
description: 'The number of times block proposal succeeded (including validation builds)',
|
|
152
154
|
});
|
|
153
155
|
|
|
156
|
+
this.checkpointSuccess = this.meter.createUpDownCounter(Metrics.SEQUENCER_CHECKPOINT_SUCCESS_COUNT, {
|
|
157
|
+
valueType: ValueType.INT,
|
|
158
|
+
description: 'The number of times checkpoint publishing succeeded',
|
|
159
|
+
});
|
|
160
|
+
|
|
154
161
|
this.blockProposalPrecheckFailed = this.meter.createUpDownCounter(
|
|
155
162
|
Metrics.SEQUENCER_BLOCK_PROPOSAL_PRECHECK_FAILED_COUNT,
|
|
156
163
|
{
|
|
@@ -307,6 +314,10 @@ export class SequencerMetrics {
|
|
|
307
314
|
}
|
|
308
315
|
}
|
|
309
316
|
|
|
317
|
+
recordCheckpointSuccess() {
|
|
318
|
+
this.checkpointSuccess.add(1);
|
|
319
|
+
}
|
|
320
|
+
|
|
310
321
|
recordBlockProposalFailed(reason?: string) {
|
|
311
322
|
this.blockProposalFailed.add(1, {
|
|
312
323
|
...(reason && { [Attributes.ERROR_TYPE]: reason }),
|