@aztec/sequencer-client 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0
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 +281 -21
- package/dest/client/sequencer-client.d.ts +41 -18
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +88 -43
- package/dest/config.d.ts +41 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +146 -55
- package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
- package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_predictor.js +138 -0
- package/dest/global_variable_builder/fee_provider.d.ts +21 -0
- package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_provider.js +80 -0
- package/dest/global_variable_builder/global_builder.d.ts +20 -26
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +28 -75
- package/dest/global_variable_builder/index.d.ts +4 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/global_variable_builder/index.js +2 -0
- package/dest/index.d.ts +2 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/publisher/config.d.ts +57 -20
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +134 -39
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/l1_to_l2_messaging.d.ts +21 -0
- package/dest/publisher/l1_to_l2_messaging.d.ts.map +1 -0
- package/dest/publisher/l1_to_l2_messaging.js +70 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +98 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +68 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +36 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +3 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
- package/dest/publisher/sequencer-bundle-simulator.js +198 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +15 -8
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +28 -4
- 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-metrics.js +23 -86
- package/dest/publisher/sequencer-publisher.d.ts +152 -90
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +1257 -421
- package/dest/publisher/write_json.d.ts +11 -0
- package/dest/publisher/write_json.d.ts.map +1 -0
- package/dest/publisher/write_json.js +57 -0
- package/dest/sequencer/automine/automine_factory.d.ts +56 -0
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_factory.js +85 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts +189 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_sequencer.js +690 -0
- package/dest/sequencer/automine/index.d.ts +3 -0
- package/dest/sequencer/automine/index.d.ts.map +1 -0
- package/dest/sequencer/automine/index.js +2 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +158 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +1801 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -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 +106 -0
- package/dest/sequencer/config.d.ts +3 -2
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/events.d.ts +103 -0
- package/dest/sequencer/events.d.ts.map +1 -0
- package/dest/sequencer/events.js +1 -0
- package/dest/sequencer/index.d.ts +4 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +3 -1
- package/dest/sequencer/metrics.d.ts +42 -7
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +241 -72
- package/dest/sequencer/requests_tracker.d.ts +22 -0
- package/dest/sequencer/requests_tracker.d.ts.map +1 -0
- package/dest/sequencer/requests_tracker.js +33 -0
- package/dest/sequencer/sequencer.d.ts +251 -138
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +1190 -704
- 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 +8 -9
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +95 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +231 -0
- package/dest/test/utils.d.ts +67 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +122 -0
- package/package.json +32 -29
- package/src/client/sequencer-client.ts +118 -66
- package/src/config.ts +173 -64
- package/src/global_variable_builder/README.md +44 -0
- package/src/global_variable_builder/fee_predictor.ts +182 -0
- package/src/global_variable_builder/fee_provider.ts +97 -0
- package/src/global_variable_builder/global_builder.ts +45 -110
- package/src/global_variable_builder/index.ts +3 -1
- package/src/index.ts +1 -7
- package/src/publisher/config.ts +182 -46
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_to_l2_messaging.ts +85 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +164 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +47 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher-factory.ts +43 -13
- package/src/publisher/sequencer-publisher-metrics.ts +19 -71
- package/src/publisher/sequencer-publisher.ts +1042 -542
- package/src/publisher/write_json.ts +78 -0
- package/src/sequencer/README.md +243 -0
- package/src/sequencer/automine/README.md +60 -0
- package/src/sequencer/automine/automine_factory.ts +152 -0
- package/src/sequencer/automine/automine_sequencer.ts +796 -0
- package/src/sequencer/automine/index.ts +6 -0
- package/src/sequencer/checkpoint_proposal_job.ts +1652 -0
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/checkpoint_voter.ts +119 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/events.ts +88 -0
- package/src/sequencer/index.ts +3 -1
- package/src/sequencer/metrics.ts +302 -83
- package/src/sequencer/requests_tracker.ts +43 -0
- package/src/sequencer/sequencer.ts +1011 -898
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +18 -9
- package/src/test/index.ts +7 -8
- package/src/test/mock_checkpoint_builder.ts +323 -0
- package/src/test/utils.ts +218 -0
- package/dest/sequencer/block_builder.d.ts +0 -28
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -134
- package/dest/sequencer/timetable.d.ts +0 -50
- package/dest/sequencer/timetable.d.ts.map +0 -1
- package/dest/sequencer/timetable.js +0 -137
- 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 -18
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -53
- package/src/sequencer/block_builder.ts +0 -222
- package/src/sequencer/timetable.ts +0 -188
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -133
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Attributes,
|
|
3
|
+
type Gauge,
|
|
4
|
+
type Histogram,
|
|
5
|
+
type Meter,
|
|
6
|
+
Metrics,
|
|
7
|
+
type TelemetryClient,
|
|
8
|
+
} from '@aztec/telemetry-client';
|
|
9
|
+
|
|
10
|
+
type CheckpointProposalJobInstruments = {
|
|
11
|
+
checkpointAttestationDelay: Histogram;
|
|
12
|
+
checkpointBuildDuration: Histogram;
|
|
13
|
+
checkpointStartToFirstBlockDuration: Histogram;
|
|
14
|
+
checkpointLastBlockToBroadcastDuration: Histogram;
|
|
15
|
+
pipelinedCheckpointBuildStartOffsetFromSlotBoundary: Histogram;
|
|
16
|
+
checkpointBlockCount: Gauge;
|
|
17
|
+
checkpointTxCount: Gauge;
|
|
18
|
+
checkpointTotalMana: Gauge;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Per-job recording surface used by {@link CheckpointProposalJob}.
|
|
23
|
+
*
|
|
24
|
+
* Ownership split:
|
|
25
|
+
* - {@link CheckpointProposalJobMetrics} owns the OpenTelemetry meter and instruments and should live for the
|
|
26
|
+
* lifetime of the sequencer process.
|
|
27
|
+
* - A recorder owns only mutable timing state for one checkpoint proposal job so overlapping jobs cannot
|
|
28
|
+
* overwrite each other's timing markers.
|
|
29
|
+
*/
|
|
30
|
+
export interface CheckpointProposalJobMetricsRecorder {
|
|
31
|
+
recordCheckpointAttestationDelay(durationMs: number): void;
|
|
32
|
+
recordCheckpointBuild(durationMs: number, blockCount: number, txCount: number, totalMana: number): void;
|
|
33
|
+
recordPipelinedCheckpointBuildStartOffsetFromSlotBoundary(offsetMs: number): void;
|
|
34
|
+
startCheckpointTiming(nowMs: number): void;
|
|
35
|
+
noteCheckpointBlockBuilt(nowMs: number, opts: { isFirstBlock: boolean; isLastBlock: boolean }): void;
|
|
36
|
+
noteCheckpointBroadcast(nowMs: number): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Concrete per-job recorder.
|
|
41
|
+
*
|
|
42
|
+
* This class should be short-lived: create one recorder per checkpoint proposal job and discard it when the job
|
|
43
|
+
* completes. It intentionally does not create instruments; it only holds the job-local timestamps needed to derive
|
|
44
|
+
* timing metrics safely.
|
|
45
|
+
*/
|
|
46
|
+
class CheckpointProposalJobMetricsRecorderImpl implements CheckpointProposalJobMetricsRecorder {
|
|
47
|
+
private checkpointStartedAt?: number;
|
|
48
|
+
private checkpointLastBlockBuiltAt?: number;
|
|
49
|
+
|
|
50
|
+
constructor(private readonly instruments: CheckpointProposalJobInstruments) {}
|
|
51
|
+
|
|
52
|
+
public recordCheckpointAttestationDelay(durationMs: number) {
|
|
53
|
+
this.instruments.checkpointAttestationDelay.record(Math.ceil(durationMs));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public recordCheckpointBuild(durationMs: number, blockCount: number, txCount: number, totalMana: number) {
|
|
57
|
+
this.instruments.checkpointBuildDuration.record(Math.ceil(durationMs));
|
|
58
|
+
this.instruments.checkpointBlockCount.record(blockCount);
|
|
59
|
+
this.instruments.checkpointTxCount.record(txCount);
|
|
60
|
+
this.instruments.checkpointTotalMana.record(totalMana);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public recordPipelinedCheckpointBuildStartOffsetFromSlotBoundary(offsetMs: number) {
|
|
64
|
+
this.instruments.pipelinedCheckpointBuildStartOffsetFromSlotBoundary.record(Math.ceil(Math.abs(offsetMs)), {
|
|
65
|
+
[Attributes.SLOT_BOUNDARY_SIDE]: offsetMs < 0 ? 'before' : 'after',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public startCheckpointTiming(nowMs: number) {
|
|
70
|
+
this.checkpointStartedAt = nowMs;
|
|
71
|
+
this.checkpointLastBlockBuiltAt = undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public noteCheckpointBlockBuilt(nowMs: number, opts: { isFirstBlock: boolean; isLastBlock: boolean }) {
|
|
75
|
+
if (opts.isFirstBlock && this.checkpointStartedAt !== undefined) {
|
|
76
|
+
this.instruments.checkpointStartToFirstBlockDuration.record(Math.ceil(nowMs - this.checkpointStartedAt));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (opts.isLastBlock) {
|
|
80
|
+
this.checkpointLastBlockBuiltAt = nowMs;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public noteCheckpointBroadcast(nowMs: number) {
|
|
85
|
+
if (this.checkpointLastBlockBuiltAt !== undefined) {
|
|
86
|
+
this.instruments.checkpointLastBlockToBroadcastDuration.record(
|
|
87
|
+
Math.ceil(nowMs - this.checkpointLastBlockBuiltAt),
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.checkpointLastBlockBuiltAt = undefined;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Long-lived owner of checkpoint proposal job telemetry instruments.
|
|
97
|
+
*
|
|
98
|
+
* The sequencer should construct this once and reuse it across jobs. Each call to {@link createRecorder} returns a
|
|
99
|
+
* lightweight recorder with isolated mutable state for a single checkpoint proposal job.
|
|
100
|
+
*/
|
|
101
|
+
export class CheckpointProposalJobMetrics {
|
|
102
|
+
private readonly meter: Meter;
|
|
103
|
+
private readonly instruments: CheckpointProposalJobInstruments;
|
|
104
|
+
|
|
105
|
+
constructor(client: TelemetryClient, name = 'CheckpointProposalJob') {
|
|
106
|
+
this.meter = client.getMeter(name);
|
|
107
|
+
this.instruments = {
|
|
108
|
+
checkpointAttestationDelay: this.meter.createHistogram(Metrics.SEQUENCER_CHECKPOINT_ATTESTATION_DELAY),
|
|
109
|
+
checkpointBuildDuration: this.meter.createHistogram(Metrics.SEQUENCER_CHECKPOINT_BUILD_DURATION),
|
|
110
|
+
checkpointStartToFirstBlockDuration: this.meter.createHistogram(
|
|
111
|
+
Metrics.SEQUENCER_CHECKPOINT_START_TO_FIRST_BLOCK_DURATION,
|
|
112
|
+
),
|
|
113
|
+
checkpointLastBlockToBroadcastDuration: this.meter.createHistogram(
|
|
114
|
+
Metrics.SEQUENCER_CHECKPOINT_LAST_BLOCK_TO_BROADCAST_DURATION,
|
|
115
|
+
),
|
|
116
|
+
pipelinedCheckpointBuildStartOffsetFromSlotBoundary: this.meter.createHistogram(
|
|
117
|
+
Metrics.SEQUENCER_PIPELINED_CHECKPOINT_BUILD_START_OFFSET_FROM_SLOT_BOUNDARY,
|
|
118
|
+
),
|
|
119
|
+
checkpointBlockCount: this.meter.createGauge(Metrics.SEQUENCER_CHECKPOINT_BLOCK_COUNT),
|
|
120
|
+
checkpointTxCount: this.meter.createGauge(Metrics.SEQUENCER_CHECKPOINT_TX_COUNT),
|
|
121
|
+
checkpointTotalMana: this.meter.createGauge(Metrics.SEQUENCER_CHECKPOINT_TOTAL_MANA),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public createRecorder(): CheckpointProposalJobMetricsRecorder {
|
|
126
|
+
return new CheckpointProposalJobMetricsRecorderImpl(this.instruments);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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 type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import type { ValidatorClient } from '@aztec/validator-client';
|
|
7
|
+
import { DutyAlreadySignedError } from '@aztec/validator-ha-signer/errors';
|
|
8
|
+
import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
|
|
9
|
+
|
|
10
|
+
import type { TypedDataDefinition } from 'viem';
|
|
11
|
+
|
|
12
|
+
import type { SequencerPublisher } from '../publisher/sequencer-publisher.js';
|
|
13
|
+
import type { SequencerMetrics } from './metrics.js';
|
|
14
|
+
import type { SequencerRollupConstants } from './types.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Handles governance and slashing voting for a given slot.
|
|
18
|
+
*/
|
|
19
|
+
export class CheckpointVoter {
|
|
20
|
+
private governanceSigner: (msg: TypedDataDefinition) => Promise<`0x${string}`>;
|
|
21
|
+
private slashingSigner: (msg: TypedDataDefinition) => Promise<`0x${string}`>;
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
private readonly slot: SlotNumber,
|
|
25
|
+
private readonly publisher: SequencerPublisher,
|
|
26
|
+
private readonly attestorAddress: EthAddress,
|
|
27
|
+
private readonly validatorClient: ValidatorClient,
|
|
28
|
+
private readonly slasherClient: SlasherClientInterface | undefined,
|
|
29
|
+
private readonly l1Constants: SequencerRollupConstants,
|
|
30
|
+
private readonly config: ResolvedSequencerConfig,
|
|
31
|
+
private readonly metrics: SequencerMetrics,
|
|
32
|
+
private readonly log: Logger,
|
|
33
|
+
) {
|
|
34
|
+
// Create separate signers with appropriate duty contexts for governance and slashing votes
|
|
35
|
+
// These use HA protection to ensure only one node signs per slot/duty
|
|
36
|
+
const governanceContext: SigningContext = { slot: this.slot, dutyType: DutyType.GOVERNANCE_VOTE };
|
|
37
|
+
this.governanceSigner = (msg: TypedDataDefinition) =>
|
|
38
|
+
this.validatorClient.signWithAddress(this.attestorAddress, msg, governanceContext).then(s => s.toString());
|
|
39
|
+
|
|
40
|
+
const slashingContext: SigningContext = { slot: this.slot, dutyType: DutyType.SLASHING_VOTE };
|
|
41
|
+
this.slashingSigner = (msg: TypedDataDefinition) =>
|
|
42
|
+
this.validatorClient.signWithAddress(this.attestorAddress, msg, slashingContext).then(s => s.toString());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Enqueues governance and slashing votes with the publisher.
|
|
47
|
+
* Returns a tuple of promises that resolve to whether each vote was successfully enqueued.
|
|
48
|
+
*/
|
|
49
|
+
enqueueVotes(): [Promise<boolean | undefined>, Promise<boolean | undefined>] {
|
|
50
|
+
try {
|
|
51
|
+
const enqueueGovernancePromise = this.enqueueGovernanceVote();
|
|
52
|
+
const enqueueSlashingPromise = this.enqueueSlashingVote();
|
|
53
|
+
|
|
54
|
+
return [enqueueGovernancePromise, enqueueSlashingPromise];
|
|
55
|
+
} catch (err) {
|
|
56
|
+
this.log.error(`Error enqueueing governance and slashing votes`, err);
|
|
57
|
+
return [Promise.resolve(false), Promise.resolve(false)];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private async enqueueGovernanceVote(): Promise<boolean | undefined> {
|
|
62
|
+
const governanceProposerPayload = this.config.governanceProposerPayload;
|
|
63
|
+
if (!governanceProposerPayload || governanceProposerPayload.isZero()) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
this.log.info(`Enqueuing vote for ${governanceProposerPayload} governance for slot ${this.slot}`, {
|
|
68
|
+
slot: this.slot,
|
|
69
|
+
governanceProposerPayload: governanceProposerPayload.toString(),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
return await this.publisher.enqueueGovernanceCastSignal(
|
|
74
|
+
governanceProposerPayload,
|
|
75
|
+
this.slot,
|
|
76
|
+
this.attestorAddress,
|
|
77
|
+
this.governanceSigner,
|
|
78
|
+
);
|
|
79
|
+
} catch (err) {
|
|
80
|
+
if (err instanceof DutyAlreadySignedError) {
|
|
81
|
+
this.log.info(`Governance vote already signed by another node`, {
|
|
82
|
+
slot: this.slot,
|
|
83
|
+
signedByNode: err.signedByNode,
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
86
|
+
this.log.error(`Error enqueueing governance vote`, err);
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private async enqueueSlashingVote(): Promise<boolean | undefined> {
|
|
93
|
+
try {
|
|
94
|
+
const actions = await this.slasherClient?.getProposerActions(this.slot);
|
|
95
|
+
if (!actions || actions.length === 0) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
this.log.info(`Enqueuing vote for ${actions.length} slashing actions for slot ${this.slot}`, {
|
|
100
|
+
slot: this.slot,
|
|
101
|
+
actionCount: actions.length,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
this.metrics.recordSlashingAttempt(actions.length);
|
|
105
|
+
|
|
106
|
+
return await this.publisher.enqueueSlashingActions(actions, this.slot, this.attestorAddress, this.slashingSigner);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
if (err instanceof DutyAlreadySignedError) {
|
|
109
|
+
this.log.info(`Slashing vote already signed by another node`, {
|
|
110
|
+
slot: this.slot,
|
|
111
|
+
signedByNode: err.signedByNode,
|
|
112
|
+
});
|
|
113
|
+
} else {
|
|
114
|
+
this.log.error(`Error enqueueing slashing vote`, err);
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
package/src/sequencer/config.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { GovernanceProposerContract
|
|
1
|
+
import type { GovernanceProposerContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import type { RollupContract } from '@aztec/ethereum/contracts/rollup';
|
|
2
3
|
|
|
3
4
|
export { type SequencerConfig } from '@aztec/stdlib/config';
|
|
4
5
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { BlockHash } from '@aztec/stdlib/block';
|
|
3
|
+
|
|
4
|
+
import type { Action } from '../publisher/sequencer-publisher.js';
|
|
5
|
+
import type { SequencerState } from './utils.js';
|
|
6
|
+
|
|
7
|
+
export type SequencerEvents = {
|
|
8
|
+
/**
|
|
9
|
+
* Emitted on every sequencer state transition (including no-op transitions to the same state). The
|
|
10
|
+
* timing fields are anchored to the build frame of the slot being proposed for, not to wall-clock
|
|
11
|
+
* slot boundaries, because the proposer builds for `targetSlot` during the previous (build) slot.
|
|
12
|
+
*
|
|
13
|
+
* - `oldState` / `newState` are the previous and new {@link SequencerState}.
|
|
14
|
+
* - `secondsIntoBuildFrame` is the wall-clock seconds elapsed since the build-frame start of
|
|
15
|
+
* `targetSlot` (`now − getBuildFrameStart(targetSlot)`). Undefined for lifecycle states with no
|
|
16
|
+
* associated slot (e.g. IDLE/STOPPING). It can be negative if the transition happens before the
|
|
17
|
+
* build frame opens.
|
|
18
|
+
* - `targetSlot` is the slot the checkpoint is being proposed for (the submission slot, one ahead of
|
|
19
|
+
* the wall-clock build slot under pipelining). Undefined for lifecycle states with no slot.
|
|
20
|
+
*/
|
|
21
|
+
['state-changed']: (args: {
|
|
22
|
+
oldState: SequencerState;
|
|
23
|
+
newState: SequencerState;
|
|
24
|
+
secondsIntoBuildFrame?: number;
|
|
25
|
+
targetSlot?: SlotNumber;
|
|
26
|
+
}) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Emitted by the sequencer once it has decided it is going to attempt to build a
|
|
29
|
+
* checkpoint for `targetSlot`, after computing the L1 simulation overrides used by
|
|
30
|
+
* `canProposeAt`. Fired BEFORE the L1 simulation is run, so consumers can observe the
|
|
31
|
+
* decision regardless of whether the propose ultimately lands.
|
|
32
|
+
*
|
|
33
|
+
* - `hadProposedParent` indicates whether the build saw a proposed (pipelined) parent
|
|
34
|
+
* checkpoint that hasn't landed on L1 yet.
|
|
35
|
+
* - `provenOverride` is the assumed proven checkpoint number pinned for the L1
|
|
36
|
+
* simulation. The plan always pins both chain tips to short-circuit `canPruneAtTime`,
|
|
37
|
+
* so this is populated whenever a simulation plan was built — the value either
|
|
38
|
+
* matches the on-chain proven snapshot (defensive pin) or the assumed-proven
|
|
39
|
+
* checkpoint when building optimistically across a pruning boundary.
|
|
40
|
+
* - `simulatedPending` is the pending checkpoint passed to L1 simulation. The plan
|
|
41
|
+
* always pins both chain tips to short-circuit `canPruneAtTime`, so this reflects
|
|
42
|
+
* either the pipelined/invalidated tip or the on-chain pending snapshot.
|
|
43
|
+
*/
|
|
44
|
+
['preparing-checkpoint']: (args: {
|
|
45
|
+
targetSlot: SlotNumber;
|
|
46
|
+
checkpointNumber: CheckpointNumber;
|
|
47
|
+
hadProposedParent: boolean;
|
|
48
|
+
provenOverride: CheckpointNumber | undefined;
|
|
49
|
+
simulatedPending: CheckpointNumber | undefined;
|
|
50
|
+
}) => void;
|
|
51
|
+
['proposer-rollup-check-failed']: (args: { reason: string; slot: SlotNumber }) => void;
|
|
52
|
+
['block-tx-count-check-failed']: (args: { minTxs: number; slot: SlotNumber }) => void;
|
|
53
|
+
['block-build-failed']: (args: { reason: string; slot: SlotNumber }) => void;
|
|
54
|
+
['block-proposed']: (args: {
|
|
55
|
+
blockNumber: BlockNumber;
|
|
56
|
+
blockHash: BlockHash;
|
|
57
|
+
checkpointNumber: CheckpointNumber;
|
|
58
|
+
indexWithinCheckpoint: IndexWithinCheckpoint;
|
|
59
|
+
slot: SlotNumber;
|
|
60
|
+
buildSlot: SlotNumber;
|
|
61
|
+
}) => void;
|
|
62
|
+
['checkpoint-empty']: (args: { slot: SlotNumber }) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Emitted when the proposer's pre-broadcast `validateBlockHeader` simulation fails. This is a
|
|
65
|
+
* last-chance check before we gossip a checkpoint proposal: a failure here means the header
|
|
66
|
+
* would not be accepted by L1 (e.g. archive mismatch, stale chain tip, or some other state
|
|
67
|
+
* drift between when we built the checkpoint and when we are about to broadcast it).
|
|
68
|
+
*/
|
|
69
|
+
['header-validation-failed']: (args: {
|
|
70
|
+
slot: SlotNumber;
|
|
71
|
+
checkpointNumber: CheckpointNumber;
|
|
72
|
+
reason: string;
|
|
73
|
+
}) => void;
|
|
74
|
+
['checkpoint-publish-failed']: (args: {
|
|
75
|
+
slot: SlotNumber;
|
|
76
|
+
successfulActions?: Action[];
|
|
77
|
+
failedActions?: Action[];
|
|
78
|
+
sentActions?: Action[];
|
|
79
|
+
expiredActions?: Action[];
|
|
80
|
+
}) => void;
|
|
81
|
+
['checkpoint-published']: (args: { checkpoint: CheckpointNumber; slot: SlotNumber }) => void;
|
|
82
|
+
['checkpoint-error']: (args: { error: Error }) => void;
|
|
83
|
+
['pipelined-checkpoint-discarded']: (args: {
|
|
84
|
+
slot: SlotNumber;
|
|
85
|
+
checkpointNumber: CheckpointNumber;
|
|
86
|
+
reason: string;
|
|
87
|
+
}) => void;
|
|
88
|
+
};
|
package/src/sequencer/index.ts
CHANGED