@aztec/sequencer-client 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107
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/index.d.ts +1 -1
- package/dest/client/sequencer-client.d.ts +10 -8
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +40 -28
- package/dest/config.d.ts +13 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +82 -25
- package/dest/global_variable_builder/global_builder.d.ts +19 -13
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +41 -28
- package/dest/global_variable_builder/index.d.ts +1 -1
- 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 +11 -8
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +21 -13
- package/dest/publisher/index.d.ts +2 -2
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/index.js +1 -1
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -5
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +9 -2
- package/dest/publisher/sequencer-publisher-metrics.d.ts +4 -4
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +1 -1
- package/dest/publisher/sequencer-publisher.d.ts +76 -69
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +290 -180
- package/dest/sequencer/block_builder.d.ts +6 -10
- package/dest/sequencer/block_builder.d.ts.map +1 -1
- package/dest/sequencer/block_builder.js +21 -10
- 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 +74 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +642 -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/config.d.ts +3 -2
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/errors.d.ts +11 -0
- package/dest/sequencer/errors.d.ts.map +1 -0
- package/dest/sequencer/errors.js +15 -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 +37 -20
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +211 -85
- package/dest/sequencer/sequencer.d.ts +109 -121
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +798 -525
- package/dest/sequencer/timetable.d.ts +57 -21
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +150 -68
- 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 +20 -28
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +12 -24
- package/dest/test/index.d.ts +4 -2
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +83 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +179 -0
- package/dest/test/utils.d.ts +49 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +94 -0
- package/dest/tx_validator/nullifier_cache.d.ts +1 -1
- package/dest/tx_validator/nullifier_cache.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.d.ts +4 -3
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +12 -9
- package/package.json +32 -31
- package/src/client/sequencer-client.ts +34 -40
- package/src/config.ts +89 -29
- package/src/global_variable_builder/global_builder.ts +56 -48
- package/src/index.ts +2 -0
- package/src/publisher/config.ts +32 -19
- package/src/publisher/index.ts +1 -1
- package/src/publisher/sequencer-publisher-factory.ts +19 -6
- package/src/publisher/sequencer-publisher-metrics.ts +3 -3
- package/src/publisher/sequencer-publisher.ts +410 -240
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/block_builder.ts +28 -30
- package/src/sequencer/checkpoint_builder.ts +217 -0
- package/src/sequencer/checkpoint_proposal_job.ts +706 -0
- package/src/sequencer/checkpoint_voter.ts +105 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/errors.ts +21 -0
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +4 -0
- package/src/sequencer/metrics.ts +269 -94
- package/src/sequencer/sequencer.ts +506 -676
- package/src/sequencer/timetable.ts +181 -91
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +24 -29
- package/src/test/index.ts +3 -1
- package/src/test/mock_checkpoint_builder.ts +247 -0
- package/src/test/utils.ts +137 -0
- package/src/tx_validator/tx_validator_factory.ts +13 -7
|
@@ -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
|
+
}
|
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,21 @@
|
|
|
1
|
+
import type { SequencerState } from './utils.js';
|
|
2
|
+
|
|
3
|
+
export class SequencerTooSlowError extends Error {
|
|
4
|
+
constructor(
|
|
5
|
+
public readonly proposedState: SequencerState,
|
|
6
|
+
public readonly maxAllowedTime: number,
|
|
7
|
+
public readonly currentTime: number,
|
|
8
|
+
) {
|
|
9
|
+
super(
|
|
10
|
+
`Too far into slot for ${proposedState} (time into slot ${currentTime}s greater than ${maxAllowedTime}s allowance)`,
|
|
11
|
+
);
|
|
12
|
+
this.name = 'SequencerTooSlowError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class SequencerInterruptedError extends Error {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(`Sequencer was interrupted`);
|
|
19
|
+
this.name = 'SequencerInterruptedError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -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
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { RollupContract } from '@aztec/ethereum';
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { RollupContract } from '@aztec/ethereum/contracts';
|
|
3
|
+
import type { L1FeeAnalysisResult } from '@aztec/ethereum/l1-fee-analysis';
|
|
4
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
5
|
import {
|
|
4
6
|
Attributes,
|
|
5
|
-
type BatchObservableResult,
|
|
6
7
|
type Gauge,
|
|
7
8
|
type Histogram,
|
|
8
9
|
type Meter,
|
|
9
10
|
Metrics,
|
|
10
|
-
type ObservableGauge,
|
|
11
11
|
type TelemetryClient,
|
|
12
12
|
type Tracer,
|
|
13
13
|
type UpDownCounter,
|
|
14
14
|
ValueType,
|
|
15
15
|
} from '@aztec/telemetry-client';
|
|
16
16
|
|
|
17
|
-
import { formatUnits } from 'viem';
|
|
17
|
+
import { type Hex, formatUnits } from 'viem';
|
|
18
18
|
|
|
19
|
-
import {
|
|
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;
|
|
@@ -26,9 +27,6 @@ export class SequencerMetrics {
|
|
|
26
27
|
private blockBuildDuration: Histogram;
|
|
27
28
|
private blockBuildManaPerSecond: Gauge;
|
|
28
29
|
private stateTransitionBufferDuration: Histogram;
|
|
29
|
-
private currentBlockNumber: Gauge;
|
|
30
|
-
private currentBlockSize: Gauge;
|
|
31
|
-
private blockBuilderInsertions: Histogram;
|
|
32
30
|
|
|
33
31
|
// these are gauges because for individual sequencers building a block is not something that happens often enough to warrant a histogram
|
|
34
32
|
private timeToCollectAttestations: Gauge;
|
|
@@ -36,18 +34,34 @@ export class SequencerMetrics {
|
|
|
36
34
|
private requiredAttestions: Gauge;
|
|
37
35
|
private collectedAttestions: Gauge;
|
|
38
36
|
|
|
39
|
-
private rewards:
|
|
37
|
+
private rewards: Gauge;
|
|
40
38
|
|
|
41
39
|
private slots: UpDownCounter;
|
|
42
40
|
private filledSlots: UpDownCounter;
|
|
43
|
-
private missedSlots: UpDownCounter;
|
|
44
41
|
|
|
45
|
-
private
|
|
42
|
+
private blockProposalFailed: UpDownCounter;
|
|
43
|
+
private blockProposalSuccess: UpDownCounter;
|
|
44
|
+
private blockProposalPrecheckFailed: UpDownCounter;
|
|
45
|
+
private checkpointSuccess: UpDownCounter;
|
|
46
|
+
private slashingAttempts: UpDownCounter;
|
|
47
|
+
private blockAttestationDelay: Histogram;
|
|
48
|
+
|
|
49
|
+
// Fisherman fee analysis metrics
|
|
50
|
+
private fishermanWouldBeIncluded: UpDownCounter;
|
|
51
|
+
private fishermanTimeBeforeBlock: Histogram;
|
|
52
|
+
private fishermanPendingBlobTxCount: Histogram;
|
|
53
|
+
private fishermanIncludedBlobTxCount: Histogram;
|
|
54
|
+
private fishermanCalculatedPriorityFee: Histogram;
|
|
55
|
+
private fishermanPriorityFeeDelta: Histogram;
|
|
56
|
+
private fishermanEstimatedCost: Histogram;
|
|
57
|
+
private fishermanEstimatedOverpayment: Histogram;
|
|
58
|
+
private fishermanMinedBlobTxPriorityFee: Histogram;
|
|
59
|
+
private fishermanMinedBlobTxTotalCost: Histogram;
|
|
60
|
+
|
|
61
|
+
private lastSeenSlot?: SlotNumber;
|
|
46
62
|
|
|
47
63
|
constructor(
|
|
48
64
|
client: TelemetryClient,
|
|
49
|
-
getState: SequencerStateCallback,
|
|
50
|
-
private coinbase: EthAddress,
|
|
51
65
|
private rollup: RollupContract,
|
|
52
66
|
name = 'Sequencer',
|
|
53
67
|
) {
|
|
@@ -78,35 +92,13 @@ export class SequencerMetrics {
|
|
|
78
92
|
},
|
|
79
93
|
);
|
|
80
94
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
currentState.addCallback(observer => {
|
|
86
|
-
observer.observe(sequencerStateToNumber(getState()));
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
this.currentBlockNumber = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_NUMBER, {
|
|
90
|
-
description: 'Current block number',
|
|
91
|
-
valueType: ValueType.INT,
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
this.currentBlockSize = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_SIZE, {
|
|
95
|
-
description: 'Current block size',
|
|
96
|
-
valueType: ValueType.INT,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
this.blockBuilderInsertions = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_INSERTION_TIME, {
|
|
100
|
-
description: 'Timer for tree insertions performed by the block builder',
|
|
101
|
-
unit: 'us',
|
|
95
|
+
this.blockAttestationDelay = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_ATTESTATION_DELAY, {
|
|
96
|
+
unit: 'ms',
|
|
97
|
+
description: 'The time difference between block proposal and minimal attestation count reached,',
|
|
102
98
|
valueType: ValueType.INT,
|
|
103
99
|
});
|
|
104
100
|
|
|
105
101
|
// Init gauges and counters
|
|
106
|
-
this.setCurrentBlock(0, 0);
|
|
107
|
-
this.blockCounter.add(0, {
|
|
108
|
-
[Attributes.STATUS]: 'cancelled',
|
|
109
|
-
});
|
|
110
102
|
this.blockCounter.add(0, {
|
|
111
103
|
[Attributes.STATUS]: 'failed',
|
|
112
104
|
});
|
|
@@ -114,7 +106,7 @@ export class SequencerMetrics {
|
|
|
114
106
|
[Attributes.STATUS]: 'built',
|
|
115
107
|
});
|
|
116
108
|
|
|
117
|
-
this.rewards = this.meter.
|
|
109
|
+
this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_REWARDS, {
|
|
118
110
|
valueType: ValueType.DOUBLE,
|
|
119
111
|
description: 'The rewards earned',
|
|
120
112
|
});
|
|
@@ -124,16 +116,15 @@ export class SequencerMetrics {
|
|
|
124
116
|
description: 'The number of slots this sequencer was selected for',
|
|
125
117
|
});
|
|
126
118
|
|
|
119
|
+
/**
|
|
120
|
+
* NOTE: we do not track missed slots as a separate metric. That would be difficult to determine
|
|
121
|
+
* Instead, use a computed metric, `slots - filledSlots` to get the number of slots a sequencer has missed.
|
|
122
|
+
*/
|
|
127
123
|
this.filledSlots = this.meter.createUpDownCounter(Metrics.SEQUENCER_FILLED_SLOT_COUNT, {
|
|
128
124
|
valueType: ValueType.INT,
|
|
129
125
|
description: 'The number of slots this sequencer has filled',
|
|
130
126
|
});
|
|
131
127
|
|
|
132
|
-
this.missedSlots = this.meter.createUpDownCounter(Metrics.SEQUENCER_MISSED_SLOT_COUNT, {
|
|
133
|
-
valueType: ValueType.INT,
|
|
134
|
-
description: 'The number of slots this sequencer has missed to fill',
|
|
135
|
-
});
|
|
136
|
-
|
|
137
128
|
this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_DURATION, {
|
|
138
129
|
description: 'The time spent collecting attestations from committee members',
|
|
139
130
|
unit: 'ms',
|
|
@@ -158,29 +149,111 @@ export class SequencerMetrics {
|
|
|
158
149
|
valueType: ValueType.INT,
|
|
159
150
|
description: 'The minimum number of attestations required to publish a block',
|
|
160
151
|
});
|
|
161
|
-
}
|
|
162
152
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
153
|
+
this.blockProposalFailed = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_PROPOSAL_FAILED_COUNT, {
|
|
154
|
+
valueType: ValueType.INT,
|
|
155
|
+
description: 'The number of times block proposal failed (including validation builds)',
|
|
156
|
+
});
|
|
166
157
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
158
|
+
this.blockProposalSuccess = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_PROPOSAL_SUCCESS_COUNT, {
|
|
159
|
+
valueType: ValueType.INT,
|
|
160
|
+
description: 'The number of times block proposal succeeded (including validation builds)',
|
|
161
|
+
});
|
|
170
162
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
163
|
+
this.checkpointSuccess = this.meter.createUpDownCounter(Metrics.SEQUENCER_CHECKPOINT_SUCCESS_COUNT, {
|
|
164
|
+
valueType: ValueType.INT,
|
|
165
|
+
description: 'The number of times checkpoint publishing succeeded',
|
|
166
|
+
});
|
|
174
167
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
168
|
+
this.blockProposalPrecheckFailed = this.meter.createUpDownCounter(
|
|
169
|
+
Metrics.SEQUENCER_BLOCK_PROPOSAL_PRECHECK_FAILED_COUNT,
|
|
170
|
+
{
|
|
171
|
+
valueType: ValueType.INT,
|
|
172
|
+
description: 'The number of times block proposal pre-build checks failed',
|
|
173
|
+
},
|
|
174
|
+
);
|
|
178
175
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
176
|
+
this.slashingAttempts = this.meter.createUpDownCounter(Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT, {
|
|
177
|
+
valueType: ValueType.INT,
|
|
178
|
+
description: 'The number of slashing action attempts',
|
|
182
179
|
});
|
|
183
|
-
|
|
180
|
+
|
|
181
|
+
// Fisherman fee analysis metrics
|
|
182
|
+
this.fishermanWouldBeIncluded = this.meter.createUpDownCounter(Metrics.FISHERMAN_FEE_ANALYSIS_WOULD_BE_INCLUDED, {
|
|
183
|
+
valueType: ValueType.INT,
|
|
184
|
+
description: 'Whether the transaction would have been included in the block',
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
this.fishermanTimeBeforeBlock = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_TIME_BEFORE_BLOCK, {
|
|
188
|
+
unit: 'ms',
|
|
189
|
+
description: 'Time in ms between fee analysis and block being mined',
|
|
190
|
+
valueType: ValueType.INT,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
this.fishermanPendingBlobTxCount = this.meter.createHistogram(
|
|
194
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_TX_COUNT,
|
|
195
|
+
{
|
|
196
|
+
description: 'Number of blob transactions seen in the pending block',
|
|
197
|
+
valueType: ValueType.INT,
|
|
198
|
+
},
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
this.fishermanIncludedBlobTxCount = this.meter.createHistogram(
|
|
202
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_TX_COUNT,
|
|
203
|
+
{
|
|
204
|
+
description: 'Number of blob transactions that got included in the mined block',
|
|
205
|
+
valueType: ValueType.INT,
|
|
206
|
+
},
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
this.fishermanCalculatedPriorityFee = this.meter.createHistogram(
|
|
210
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_CALCULATED_PRIORITY_FEE,
|
|
211
|
+
{
|
|
212
|
+
unit: 'gwei',
|
|
213
|
+
description: 'Priority fee calculated by each strategy',
|
|
214
|
+
valueType: ValueType.DOUBLE,
|
|
215
|
+
},
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
this.fishermanPriorityFeeDelta = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PRIORITY_FEE_DELTA, {
|
|
219
|
+
unit: 'gwei',
|
|
220
|
+
description: 'Difference between our priority fee and minimum included priority fee',
|
|
221
|
+
valueType: ValueType.DOUBLE,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
this.fishermanEstimatedCost = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_COST, {
|
|
225
|
+
unit: 'eth',
|
|
226
|
+
description: 'Estimated total cost in ETH for the transaction with this strategy',
|
|
227
|
+
valueType: ValueType.DOUBLE,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
this.fishermanEstimatedOverpayment = this.meter.createHistogram(
|
|
231
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_OVERPAYMENT,
|
|
232
|
+
{
|
|
233
|
+
unit: 'eth',
|
|
234
|
+
description: 'Estimated overpayment in ETH vs minimum required for inclusion',
|
|
235
|
+
valueType: ValueType.DOUBLE,
|
|
236
|
+
},
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
this.fishermanMinedBlobTxPriorityFee = this.meter.createHistogram(
|
|
240
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_PRIORITY_FEE,
|
|
241
|
+
{
|
|
242
|
+
unit: 'gwei',
|
|
243
|
+
description: 'Priority fee per gas for blob transactions in mined blocks',
|
|
244
|
+
valueType: ValueType.DOUBLE,
|
|
245
|
+
},
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
this.fishermanMinedBlobTxTotalCost = this.meter.createHistogram(
|
|
249
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_TOTAL_COST,
|
|
250
|
+
{
|
|
251
|
+
unit: 'eth',
|
|
252
|
+
description: 'Total cost in ETH for blob transactions in mined blocks',
|
|
253
|
+
valueType: ValueType.DOUBLE,
|
|
254
|
+
},
|
|
255
|
+
);
|
|
256
|
+
}
|
|
184
257
|
|
|
185
258
|
public recordRequiredAttestations(requiredAttestationsCount: number, allowanceMs: number) {
|
|
186
259
|
this.requiredAttestions.record(requiredAttestationsCount);
|
|
@@ -191,22 +264,15 @@ export class SequencerMetrics {
|
|
|
191
264
|
this.timeToCollectAttestations.record(0);
|
|
192
265
|
}
|
|
193
266
|
|
|
267
|
+
public recordBlockAttestationDelay(duration: number) {
|
|
268
|
+
this.blockAttestationDelay.record(duration);
|
|
269
|
+
}
|
|
270
|
+
|
|
194
271
|
public recordCollectedAttestations(count: number, durationMs: number) {
|
|
195
272
|
this.collectedAttestions.record(count);
|
|
196
273
|
this.timeToCollectAttestations.record(Math.ceil(durationMs));
|
|
197
274
|
}
|
|
198
275
|
|
|
199
|
-
recordBlockBuilderTreeInsertions(timeUs: number) {
|
|
200
|
-
this.blockBuilderInsertions.record(Math.ceil(timeUs));
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
recordCancelledBlock() {
|
|
204
|
-
this.blockCounter.add(1, {
|
|
205
|
-
[Attributes.STATUS]: 'cancelled',
|
|
206
|
-
});
|
|
207
|
-
this.setCurrentBlock(0, 0);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
276
|
recordBuiltBlock(buildDurationMs: number, totalMana: number) {
|
|
211
277
|
this.blockCounter.add(1, {
|
|
212
278
|
[Attributes.STATUS]: 'built',
|
|
@@ -219,11 +285,6 @@ export class SequencerMetrics {
|
|
|
219
285
|
this.blockCounter.add(1, {
|
|
220
286
|
[Attributes.STATUS]: 'failed',
|
|
221
287
|
});
|
|
222
|
-
this.setCurrentBlock(0, 0);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
recordNewBlock(blockNumber: number, txCount: number) {
|
|
226
|
-
this.setCurrentBlock(blockNumber, txCount);
|
|
227
288
|
}
|
|
228
289
|
|
|
229
290
|
recordStateTransitionBufferMs(durationMs: number, state: SequencerState) {
|
|
@@ -232,36 +293,150 @@ export class SequencerMetrics {
|
|
|
232
293
|
});
|
|
233
294
|
}
|
|
234
295
|
|
|
235
|
-
|
|
296
|
+
incOpenSlot(slot: SlotNumber, proposer: string) {
|
|
236
297
|
// sequencer went through the loop a second time. Noop
|
|
237
298
|
if (slot === this.lastSeenSlot) {
|
|
238
299
|
return;
|
|
239
300
|
}
|
|
240
301
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (typeof slot === 'bigint') {
|
|
248
|
-
this.slots.add(1, {
|
|
249
|
-
[Attributes.BLOCK_PROPOSER]: proposer,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
302
|
+
this.slots.add(1, {
|
|
303
|
+
[Attributes.BLOCK_PROPOSER]: proposer,
|
|
304
|
+
});
|
|
252
305
|
|
|
253
306
|
this.lastSeenSlot = slot;
|
|
254
307
|
}
|
|
255
308
|
|
|
256
|
-
incFilledSlot(proposer: string) {
|
|
309
|
+
async incFilledSlot(proposer: string, coinbase: Hex | EthAddress | undefined): Promise<void> {
|
|
257
310
|
this.filledSlots.add(1, {
|
|
258
311
|
[Attributes.BLOCK_PROPOSER]: proposer,
|
|
259
312
|
});
|
|
260
313
|
this.lastSeenSlot = undefined;
|
|
314
|
+
|
|
315
|
+
if (coinbase) {
|
|
316
|
+
try {
|
|
317
|
+
const rewards = await this.rollup.getSequencerRewards(coinbase);
|
|
318
|
+
const fmt = parseFloat(formatUnits(rewards, 18));
|
|
319
|
+
this.rewards.record(fmt, {
|
|
320
|
+
[Attributes.COINBASE]: coinbase.toString(),
|
|
321
|
+
});
|
|
322
|
+
} catch {
|
|
323
|
+
// no-op
|
|
324
|
+
}
|
|
325
|
+
}
|
|
261
326
|
}
|
|
262
327
|
|
|
263
|
-
|
|
264
|
-
this.
|
|
265
|
-
|
|
328
|
+
recordCheckpointSuccess() {
|
|
329
|
+
this.checkpointSuccess.add(1);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
recordBlockProposalFailed(reason?: string) {
|
|
333
|
+
this.blockProposalFailed.add(1, {
|
|
334
|
+
...(reason && { [Attributes.ERROR_TYPE]: reason }),
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
recordBlockProposalSuccess() {
|
|
339
|
+
this.blockProposalSuccess.add(1);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
recordBlockProposalPrecheckFailed(checkType: string) {
|
|
343
|
+
this.blockProposalPrecheckFailed.add(1, {
|
|
344
|
+
[Attributes.ERROR_TYPE]: checkType,
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
recordSlashingAttempt(actionCount: number) {
|
|
349
|
+
this.slashingAttempts.add(actionCount);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Records metrics for a completed fisherman fee analysis
|
|
354
|
+
* @param analysis - The completed fee analysis result
|
|
355
|
+
*/
|
|
356
|
+
recordFishermanFeeAnalysis(analysis: L1FeeAnalysisResult) {
|
|
357
|
+
// In fisherman mode, we should always have strategy results
|
|
358
|
+
if (!analysis.computedPrices.strategyResults || analysis.computedPrices.strategyResults.length === 0) {
|
|
359
|
+
// This should never happen in fisherman mode - log an error
|
|
360
|
+
// We don't record metrics without strategy IDs as that defeats the purpose
|
|
361
|
+
throw new Error(
|
|
362
|
+
`No strategy results found in fisherman fee analysis ${analysis.id}. This indicates a bug in the fee analysis.`,
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Record metrics for each strategy separately
|
|
367
|
+
for (const strategyResult of analysis.computedPrices.strategyResults) {
|
|
368
|
+
const strategyAttributes = {
|
|
369
|
+
[Attributes.FISHERMAN_FEE_STRATEGY_ID]: strategyResult.strategyId,
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
// Record pending block snapshot data (once per strategy for comparison)
|
|
373
|
+
this.fishermanPendingBlobTxCount.record(analysis.pendingSnapshot.pendingBlobTxCount, strategyAttributes);
|
|
374
|
+
|
|
375
|
+
// Record mined block data if available
|
|
376
|
+
if (analysis.minedBlock) {
|
|
377
|
+
this.fishermanIncludedBlobTxCount.record(analysis.minedBlock.includedBlobTxCount, strategyAttributes);
|
|
378
|
+
|
|
379
|
+
// Record actual fees from blob transactions in the mined block
|
|
380
|
+
for (const blobTx of analysis.minedBlock.includedBlobTxs) {
|
|
381
|
+
// Record priority fee per gas in Gwei
|
|
382
|
+
const priorityFeeGwei = Number(blobTx.maxPriorityFeePerGas) / 1e9;
|
|
383
|
+
this.fishermanMinedBlobTxPriorityFee.record(priorityFeeGwei, strategyAttributes);
|
|
384
|
+
|
|
385
|
+
// Calculate total cost in ETH
|
|
386
|
+
// Cost = (gas * (baseFee + priorityFee)) + (blobCount * blobGasPerBlob * blobBaseFee)
|
|
387
|
+
const baseFee = analysis.minedBlock.baseFeePerGas;
|
|
388
|
+
const effectiveGasPrice = baseFee + blobTx.maxPriorityFeePerGas;
|
|
389
|
+
|
|
390
|
+
// Calculate execution cost using actual gas limit from the transaction
|
|
391
|
+
const executionCost = blobTx.gas * effectiveGasPrice;
|
|
392
|
+
|
|
393
|
+
// Calculate blob cost using maxFeePerBlobGas * blobCount * GAS_PER_BLOB
|
|
394
|
+
const blobCost = blobTx.maxFeePerBlobGas * BigInt(blobTx.blobCount) * 131072n; // 128KB per blob
|
|
395
|
+
|
|
396
|
+
const totalCostWei = executionCost + blobCost;
|
|
397
|
+
const totalCostEth = Number(totalCostWei) / 1e18;
|
|
398
|
+
|
|
399
|
+
this.fishermanMinedBlobTxTotalCost.record(totalCostEth, strategyAttributes);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// Record the calculated priority fee for this strategy
|
|
404
|
+
const calculatedPriorityFeeGwei = Number(strategyResult.calculatedPriorityFee) / 1e9;
|
|
405
|
+
this.fishermanCalculatedPriorityFee.record(calculatedPriorityFeeGwei, strategyAttributes);
|
|
406
|
+
|
|
407
|
+
// Record analysis results if available
|
|
408
|
+
if (analysis.analysis) {
|
|
409
|
+
this.fishermanTimeBeforeBlock.record(Math.ceil(analysis.analysis.timeBeforeBlockMs), strategyAttributes);
|
|
410
|
+
|
|
411
|
+
// Record strategy-specific inclusion result
|
|
412
|
+
if (strategyResult.wouldBeIncluded !== undefined) {
|
|
413
|
+
if (strategyResult.wouldBeIncluded) {
|
|
414
|
+
this.fishermanWouldBeIncluded.add(1, { ...strategyAttributes, [Attributes.OK]: true });
|
|
415
|
+
} else {
|
|
416
|
+
this.fishermanWouldBeIncluded.add(1, {
|
|
417
|
+
...strategyAttributes,
|
|
418
|
+
[Attributes.OK]: false,
|
|
419
|
+
...(strategyResult.exclusionReason && { [Attributes.ERROR_TYPE]: strategyResult.exclusionReason }),
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// Record strategy-specific priority fee delta
|
|
425
|
+
if (strategyResult.priorityFeeDelta !== undefined) {
|
|
426
|
+
const priorityFeeDeltaGwei = Number(strategyResult.priorityFeeDelta) / 1e9;
|
|
427
|
+
this.fishermanPriorityFeeDelta.record(priorityFeeDeltaGwei, strategyAttributes);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// Record estimated cost if available
|
|
431
|
+
if (strategyResult.estimatedCostEth !== undefined) {
|
|
432
|
+
this.fishermanEstimatedCost.record(strategyResult.estimatedCostEth, strategyAttributes);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// Record estimated overpayment if available
|
|
436
|
+
if (strategyResult.estimatedOverpaymentEth !== undefined) {
|
|
437
|
+
this.fishermanEstimatedOverpayment.record(strategyResult.estimatedOverpaymentEth, strategyAttributes);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
266
441
|
}
|
|
267
442
|
}
|