@aztec/sequencer-client 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c
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 +21 -16
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +45 -27
- package/dest/config.d.ts +14 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +83 -35
- package/dest/global_variable_builder/global_builder.d.ts +20 -13
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +51 -41
- 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 +37 -20
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +104 -39
- package/dest/publisher/sequencer-publisher-factory.d.ts +15 -6
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +14 -3
- 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 +63 -47
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +630 -137
- package/dest/sequencer/checkpoint_proposal_job.d.ts +102 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +1213 -0
- package/dest/sequencer/checkpoint_voter.d.ts +35 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +109 -0
- package/dest/sequencer/config.d.ts +3 -2
- package/dest/sequencer/config.d.ts.map +1 -1
- 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 +4 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +3 -1
- package/dest/sequencer/metrics.d.ts +38 -6
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +216 -72
- package/dest/sequencer/sequencer.d.ts +119 -133
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +717 -625
- package/dest/sequencer/timetable.d.ts +51 -14
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +145 -59
- 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 +6 -7
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +97 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +222 -0
- package/dest/test/utils.d.ts +53 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +104 -0
- package/package.json +32 -30
- package/src/client/sequencer-client.ts +54 -47
- package/src/config.ts +95 -44
- package/src/global_variable_builder/global_builder.ts +65 -61
- package/src/index.ts +1 -7
- package/src/publisher/config.ts +122 -50
- package/src/publisher/sequencer-publisher-factory.ts +28 -10
- package/src/publisher/sequencer-publisher-metrics.ts +19 -71
- package/src/publisher/sequencer-publisher.ts +350 -176
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/checkpoint_proposal_job.ts +914 -0
- package/src/sequencer/checkpoint_voter.ts +130 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +3 -1
- package/src/sequencer/metrics.ts +268 -82
- package/src/sequencer/sequencer.ts +464 -831
- package/src/sequencer/timetable.ts +175 -80
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +18 -9
- package/src/test/index.ts +5 -6
- package/src/test/mock_checkpoint_builder.ts +320 -0
- package/src/test/utils.ts +167 -0
- package/dest/sequencer/block_builder.d.ts +0 -27
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -134
- 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 -17
- 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/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -132
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
import { DutyAlreadySignedError } from '@aztec/validator-ha-signer/errors';
|
|
9
|
+
import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
|
|
10
|
+
|
|
11
|
+
import type { TypedDataDefinition } from 'viem';
|
|
12
|
+
|
|
13
|
+
import type { SequencerPublisher } from '../publisher/sequencer-publisher.js';
|
|
14
|
+
import type { SequencerMetrics } from './metrics.js';
|
|
15
|
+
import type { SequencerRollupConstants } from './types.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Handles governance and slashing voting for a given slot.
|
|
19
|
+
*/
|
|
20
|
+
export class CheckpointVoter {
|
|
21
|
+
private slotTimestamp: bigint;
|
|
22
|
+
private governanceSigner: (msg: TypedDataDefinition) => Promise<`0x${string}`>;
|
|
23
|
+
private slashingSigner: (msg: TypedDataDefinition) => Promise<`0x${string}`>;
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
private readonly slot: SlotNumber,
|
|
27
|
+
private readonly publisher: SequencerPublisher,
|
|
28
|
+
private readonly attestorAddress: EthAddress,
|
|
29
|
+
private readonly validatorClient: ValidatorClient,
|
|
30
|
+
private readonly slasherClient: SlasherClientInterface | undefined,
|
|
31
|
+
private readonly l1Constants: SequencerRollupConstants,
|
|
32
|
+
private readonly config: ResolvedSequencerConfig,
|
|
33
|
+
private readonly metrics: SequencerMetrics,
|
|
34
|
+
private readonly log: Logger,
|
|
35
|
+
) {
|
|
36
|
+
this.slotTimestamp = getTimestampForSlot(this.slot, this.l1Constants);
|
|
37
|
+
|
|
38
|
+
// Create separate signers with appropriate duty contexts for governance and slashing votes
|
|
39
|
+
// These use HA protection to ensure only one node signs per slot/duty
|
|
40
|
+
const governanceContext: SigningContext = { slot: this.slot, dutyType: DutyType.GOVERNANCE_VOTE };
|
|
41
|
+
this.governanceSigner = (msg: TypedDataDefinition) =>
|
|
42
|
+
this.validatorClient.signWithAddress(this.attestorAddress, msg, governanceContext).then(s => s.toString());
|
|
43
|
+
|
|
44
|
+
const slashingContext: SigningContext = { slot: this.slot, dutyType: DutyType.SLASHING_VOTE };
|
|
45
|
+
this.slashingSigner = (msg: TypedDataDefinition) =>
|
|
46
|
+
this.validatorClient.signWithAddress(this.attestorAddress, msg, slashingContext).then(s => s.toString());
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Enqueues governance and slashing votes with the publisher.
|
|
51
|
+
* Returns a tuple of promises that resolve to whether each vote was successfully enqueued.
|
|
52
|
+
*/
|
|
53
|
+
enqueueVotes(): [Promise<boolean | undefined>, Promise<boolean | undefined>] {
|
|
54
|
+
try {
|
|
55
|
+
const enqueueGovernancePromise = this.enqueueGovernanceVote();
|
|
56
|
+
const enqueueSlashingPromise = this.enqueueSlashingVote();
|
|
57
|
+
|
|
58
|
+
return [enqueueGovernancePromise, enqueueSlashingPromise];
|
|
59
|
+
} catch (err) {
|
|
60
|
+
this.log.error(`Error enqueueing governance and slashing votes`, err);
|
|
61
|
+
return [Promise.resolve(false), Promise.resolve(false)];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private async enqueueGovernanceVote(): Promise<boolean | undefined> {
|
|
66
|
+
const governanceProposerPayload = this.config.governanceProposerPayload;
|
|
67
|
+
if (!governanceProposerPayload || governanceProposerPayload.isZero()) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.log.info(`Enqueuing vote for ${governanceProposerPayload} governance for slot ${this.slot}`, {
|
|
72
|
+
slot: this.slot,
|
|
73
|
+
governanceProposerPayload: governanceProposerPayload.toString(),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
return await this.publisher.enqueueGovernanceCastSignal(
|
|
78
|
+
governanceProposerPayload,
|
|
79
|
+
this.slot,
|
|
80
|
+
this.slotTimestamp,
|
|
81
|
+
this.attestorAddress,
|
|
82
|
+
this.governanceSigner,
|
|
83
|
+
);
|
|
84
|
+
} catch (err) {
|
|
85
|
+
if (err instanceof DutyAlreadySignedError) {
|
|
86
|
+
this.log.info(`Governance vote already signed by another node`, {
|
|
87
|
+
slot: this.slot,
|
|
88
|
+
signedByNode: err.signedByNode,
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
this.log.error(`Error enqueueing governance vote`, err);
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private async enqueueSlashingVote(): Promise<boolean | undefined> {
|
|
98
|
+
try {
|
|
99
|
+
const actions = await this.slasherClient?.getProposerActions(this.slot);
|
|
100
|
+
if (!actions || actions.length === 0) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this.log.info(`Enqueuing vote for ${actions.length} slashing actions for slot ${this.slot}`, {
|
|
105
|
+
slot: this.slot,
|
|
106
|
+
actionCount: actions.length,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
this.metrics.recordSlashingAttempt(actions.length);
|
|
110
|
+
|
|
111
|
+
return await this.publisher.enqueueSlashingActions(
|
|
112
|
+
actions,
|
|
113
|
+
this.slot,
|
|
114
|
+
this.slotTimestamp,
|
|
115
|
+
this.attestorAddress,
|
|
116
|
+
this.slashingSigner,
|
|
117
|
+
);
|
|
118
|
+
} catch (err) {
|
|
119
|
+
if (err instanceof DutyAlreadySignedError) {
|
|
120
|
+
this.log.info(`Slashing vote already signed by another node`, {
|
|
121
|
+
slot: this.slot,
|
|
122
|
+
signedByNode: err.signedByNode,
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
this.log.error(`Error enqueueing slashing vote`, err);
|
|
126
|
+
}
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
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,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,5 +1,6 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import type { RollupContract } from '@aztec/ethereum';
|
|
2
|
+
import type { RollupContract } from '@aztec/ethereum/contracts';
|
|
3
|
+
import type { L1FeeAnalysisResult } from '@aztec/ethereum/l1-fee-analysis';
|
|
3
4
|
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
5
|
import {
|
|
5
6
|
Attributes,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
type TelemetryClient,
|
|
11
12
|
type Tracer,
|
|
12
13
|
type UpDownCounter,
|
|
13
|
-
|
|
14
|
+
createUpDownCounterWithDefault,
|
|
14
15
|
} from '@aztec/telemetry-client';
|
|
15
16
|
|
|
16
17
|
import { type Hex, formatUnits } from 'viem';
|
|
@@ -38,9 +39,32 @@ export class SequencerMetrics {
|
|
|
38
39
|
private filledSlots: UpDownCounter;
|
|
39
40
|
|
|
40
41
|
private blockProposalFailed: UpDownCounter;
|
|
41
|
-
private
|
|
42
|
-
private
|
|
42
|
+
private checkpointProposalSuccess: UpDownCounter;
|
|
43
|
+
private checkpointPrecheckFailed: UpDownCounter;
|
|
44
|
+
private checkpointProposalFailed: UpDownCounter;
|
|
45
|
+
private checkpointSuccess: UpDownCounter;
|
|
43
46
|
private slashingAttempts: UpDownCounter;
|
|
47
|
+
private checkpointAttestationDelay: Histogram;
|
|
48
|
+
private checkpointBuildDuration: Histogram;
|
|
49
|
+
private checkpointBlockCount: Gauge;
|
|
50
|
+
private checkpointTxCount: Gauge;
|
|
51
|
+
private checkpointTotalMana: Gauge;
|
|
52
|
+
|
|
53
|
+
// Fisherman fee analysis metrics
|
|
54
|
+
private fishermanWouldBeIncluded: UpDownCounter;
|
|
55
|
+
private fishermanTimeBeforeBlock: Histogram;
|
|
56
|
+
private fishermanPendingBlobTxCount: Histogram;
|
|
57
|
+
private fishermanIncludedBlobTxCount: Histogram;
|
|
58
|
+
private fishermanPendingBlobCount: Histogram;
|
|
59
|
+
private fishermanIncludedBlobCount: Histogram;
|
|
60
|
+
private fishermanBlockBlobsFull: UpDownCounter;
|
|
61
|
+
private fishermanMaxBlobCapacity: Histogram;
|
|
62
|
+
private fishermanCalculatedPriorityFee: Histogram;
|
|
63
|
+
private fishermanPriorityFeeDelta: Histogram;
|
|
64
|
+
private fishermanEstimatedCost: Histogram;
|
|
65
|
+
private fishermanEstimatedOverpayment: Histogram;
|
|
66
|
+
private fishermanMinedBlobTxPriorityFee: Histogram;
|
|
67
|
+
private fishermanMinedBlobTxTotalCost: Histogram;
|
|
44
68
|
|
|
45
69
|
private lastSeenSlot?: SlotNumber;
|
|
46
70
|
|
|
@@ -52,104 +76,124 @@ export class SequencerMetrics {
|
|
|
52
76
|
this.meter = client.getMeter(name);
|
|
53
77
|
this.tracer = client.getTracer(name);
|
|
54
78
|
|
|
55
|
-
this.blockCounter = this.meter
|
|
56
|
-
|
|
57
|
-
this.blockBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION, {
|
|
58
|
-
unit: 'ms',
|
|
59
|
-
description: 'Duration to build a block',
|
|
60
|
-
valueType: ValueType.INT,
|
|
79
|
+
this.blockCounter = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_COUNT, {
|
|
80
|
+
[Attributes.STATUS]: ['failed', 'built'],
|
|
61
81
|
});
|
|
62
82
|
|
|
63
|
-
this.
|
|
64
|
-
unit: 'mana/s',
|
|
65
|
-
description: 'Mana per second when building a block',
|
|
66
|
-
valueType: ValueType.INT,
|
|
67
|
-
});
|
|
83
|
+
this.blockBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION);
|
|
68
84
|
|
|
69
|
-
this.
|
|
70
|
-
Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION,
|
|
71
|
-
{
|
|
72
|
-
unit: 'ms',
|
|
73
|
-
description:
|
|
74
|
-
'The time difference between when the sequencer needed to transition to a new state and when it actually did.',
|
|
75
|
-
valueType: ValueType.INT,
|
|
76
|
-
},
|
|
77
|
-
);
|
|
85
|
+
this.blockBuildManaPerSecond = this.meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND);
|
|
78
86
|
|
|
79
|
-
|
|
80
|
-
this.blockCounter.add(0, {
|
|
81
|
-
[Attributes.STATUS]: 'failed',
|
|
82
|
-
});
|
|
83
|
-
this.blockCounter.add(0, {
|
|
84
|
-
[Attributes.STATUS]: 'built',
|
|
85
|
-
});
|
|
87
|
+
this.stateTransitionBufferDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION);
|
|
86
88
|
|
|
87
|
-
this.
|
|
88
|
-
valueType: ValueType.DOUBLE,
|
|
89
|
-
description: 'The rewards earned',
|
|
90
|
-
});
|
|
89
|
+
this.checkpointAttestationDelay = this.meter.createHistogram(Metrics.SEQUENCER_CHECKPOINT_ATTESTATION_DELAY);
|
|
91
90
|
|
|
92
|
-
this.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
});
|
|
91
|
+
this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_SLOT_REWARDS);
|
|
92
|
+
|
|
93
|
+
this.slots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLOT_COUNT);
|
|
96
94
|
|
|
97
95
|
/**
|
|
98
96
|
* NOTE: we do not track missed slots as a separate metric. That would be difficult to determine
|
|
99
97
|
* Instead, use a computed metric, `slots - filledSlots` to get the number of slots a sequencer has missed.
|
|
100
98
|
*/
|
|
101
|
-
this.filledSlots = this.meter
|
|
102
|
-
valueType: ValueType.INT,
|
|
103
|
-
description: 'The number of slots this sequencer has filled',
|
|
104
|
-
});
|
|
99
|
+
this.filledSlots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_FILLED_SLOT_COUNT);
|
|
105
100
|
|
|
106
|
-
this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_DURATION
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
101
|
+
this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_DURATION);
|
|
102
|
+
|
|
103
|
+
this.allowanceToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_TIME_ALLOWANCE);
|
|
104
|
+
|
|
105
|
+
this.requiredAttestions = this.meter.createGauge(Metrics.SEQUENCER_REQUIRED_ATTESTATIONS_COUNT);
|
|
106
|
+
|
|
107
|
+
this.collectedAttestions = this.meter.createGauge(Metrics.SEQUENCER_COLLECTED_ATTESTATIONS_COUNT);
|
|
108
|
+
|
|
109
|
+
this.blockProposalFailed = createUpDownCounterWithDefault(
|
|
110
|
+
this.meter,
|
|
111
|
+
Metrics.SEQUENCER_BLOCK_PROPOSAL_FAILED_COUNT,
|
|
112
|
+
);
|
|
111
113
|
|
|
112
|
-
this.
|
|
113
|
-
|
|
114
|
+
this.checkpointProposalSuccess = createUpDownCounterWithDefault(
|
|
115
|
+
this.meter,
|
|
116
|
+
Metrics.SEQUENCER_CHECKPOINT_PROPOSAL_SUCCESS_COUNT,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
this.checkpointSuccess = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_SUCCESS_COUNT);
|
|
120
|
+
|
|
121
|
+
this.checkpointPrecheckFailed = createUpDownCounterWithDefault(
|
|
122
|
+
this.meter,
|
|
123
|
+
Metrics.SEQUENCER_CHECKPOINT_PRECHECK_FAILED_COUNT,
|
|
114
124
|
{
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
125
|
+
[Attributes.ERROR_TYPE]: [
|
|
126
|
+
'slot_already_taken',
|
|
127
|
+
'rollup_contract_check_failed',
|
|
128
|
+
'slot_mismatch',
|
|
129
|
+
'block_number_mismatch',
|
|
130
|
+
],
|
|
118
131
|
},
|
|
119
132
|
);
|
|
120
133
|
|
|
121
|
-
this.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
134
|
+
this.checkpointProposalFailed = createUpDownCounterWithDefault(
|
|
135
|
+
this.meter,
|
|
136
|
+
Metrics.SEQUENCER_CHECKPOINT_PROPOSAL_FAILED_COUNT,
|
|
137
|
+
);
|
|
125
138
|
|
|
126
|
-
this.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
139
|
+
this.checkpointBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_CHECKPOINT_BUILD_DURATION);
|
|
140
|
+
this.checkpointBlockCount = this.meter.createGauge(Metrics.SEQUENCER_CHECKPOINT_BLOCK_COUNT);
|
|
141
|
+
this.checkpointTxCount = this.meter.createGauge(Metrics.SEQUENCER_CHECKPOINT_TX_COUNT);
|
|
142
|
+
this.checkpointTotalMana = this.meter.createGauge(Metrics.SEQUENCER_CHECKPOINT_TOTAL_MANA);
|
|
130
143
|
|
|
131
|
-
this.
|
|
132
|
-
valueType: ValueType.INT,
|
|
133
|
-
description: 'The number of times block proposal failed (including validation builds)',
|
|
134
|
-
});
|
|
144
|
+
this.slashingAttempts = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT);
|
|
135
145
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
146
|
+
// Fisherman fee analysis metrics
|
|
147
|
+
this.fishermanWouldBeIncluded = createUpDownCounterWithDefault(
|
|
148
|
+
this.meter,
|
|
149
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_WOULD_BE_INCLUDED,
|
|
150
|
+
{
|
|
151
|
+
[Attributes.OK]: [true, false],
|
|
152
|
+
[Attributes.BLOCK_FULL]: ['true', 'false'],
|
|
153
|
+
},
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
this.fishermanTimeBeforeBlock = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_TIME_BEFORE_BLOCK);
|
|
157
|
+
|
|
158
|
+
this.fishermanPendingBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_TX_COUNT);
|
|
159
|
+
|
|
160
|
+
this.fishermanIncludedBlobTxCount = this.meter.createHistogram(
|
|
161
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_TX_COUNT,
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
this.fishermanCalculatedPriorityFee = this.meter.createHistogram(
|
|
165
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_CALCULATED_PRIORITY_FEE,
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
this.fishermanPriorityFeeDelta = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PRIORITY_FEE_DELTA);
|
|
140
169
|
|
|
141
|
-
this.
|
|
142
|
-
|
|
170
|
+
this.fishermanEstimatedCost = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_COST);
|
|
171
|
+
|
|
172
|
+
this.fishermanEstimatedOverpayment = this.meter.createHistogram(
|
|
173
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_OVERPAYMENT,
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
this.fishermanMinedBlobTxPriorityFee = this.meter.createHistogram(
|
|
177
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_PRIORITY_FEE,
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
this.fishermanMinedBlobTxTotalCost = this.meter.createHistogram(
|
|
181
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_TOTAL_COST,
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
this.fishermanPendingBlobCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_COUNT);
|
|
185
|
+
|
|
186
|
+
this.fishermanIncludedBlobCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_COUNT);
|
|
187
|
+
|
|
188
|
+
this.fishermanBlockBlobsFull = createUpDownCounterWithDefault(
|
|
189
|
+
this.meter,
|
|
190
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_BLOCK_BLOBS_FULL,
|
|
143
191
|
{
|
|
144
|
-
|
|
145
|
-
description: 'The number of times block proposal pre-build checks failed',
|
|
192
|
+
[Attributes.OK]: [true, false],
|
|
146
193
|
},
|
|
147
194
|
);
|
|
148
195
|
|
|
149
|
-
this.
|
|
150
|
-
valueType: ValueType.INT,
|
|
151
|
-
description: 'The number of slashing action attempts',
|
|
152
|
-
});
|
|
196
|
+
this.fishermanMaxBlobCapacity = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MAX_BLOB_CAPACITY);
|
|
153
197
|
}
|
|
154
198
|
|
|
155
199
|
public recordRequiredAttestations(requiredAttestationsCount: number, allowanceMs: number) {
|
|
@@ -161,6 +205,10 @@ export class SequencerMetrics {
|
|
|
161
205
|
this.timeToCollectAttestations.record(0);
|
|
162
206
|
}
|
|
163
207
|
|
|
208
|
+
public recordCheckpointAttestationDelay(duration: number) {
|
|
209
|
+
this.checkpointAttestationDelay.record(duration);
|
|
210
|
+
}
|
|
211
|
+
|
|
164
212
|
public recordCollectedAttestations(count: number, durationMs: number) {
|
|
165
213
|
this.collectedAttestions.record(count);
|
|
166
214
|
this.timeToCollectAttestations.record(Math.ceil(durationMs));
|
|
@@ -218,23 +266,161 @@ export class SequencerMetrics {
|
|
|
218
266
|
}
|
|
219
267
|
}
|
|
220
268
|
|
|
269
|
+
recordCheckpointSuccess() {
|
|
270
|
+
this.checkpointSuccess.add(1);
|
|
271
|
+
}
|
|
272
|
+
|
|
221
273
|
recordBlockProposalFailed(reason?: string) {
|
|
222
274
|
this.blockProposalFailed.add(1, {
|
|
223
275
|
...(reason && { [Attributes.ERROR_TYPE]: reason }),
|
|
224
276
|
});
|
|
225
277
|
}
|
|
226
278
|
|
|
227
|
-
|
|
228
|
-
this.
|
|
279
|
+
recordCheckpointProposalSuccess() {
|
|
280
|
+
this.checkpointProposalSuccess.add(1);
|
|
229
281
|
}
|
|
230
282
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
283
|
+
recordCheckpointPrecheckFailed(
|
|
284
|
+
checkType: 'slot_already_taken' | 'rollup_contract_check_failed' | 'slot_mismatch' | 'block_number_mismatch',
|
|
285
|
+
) {
|
|
286
|
+
this.checkpointPrecheckFailed.add(1, { [Attributes.ERROR_TYPE]: checkType });
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
recordCheckpointProposalFailed(reason?: string) {
|
|
290
|
+
this.checkpointProposalFailed.add(1, {
|
|
291
|
+
...(reason && { [Attributes.ERROR_TYPE]: reason }),
|
|
234
292
|
});
|
|
235
293
|
}
|
|
236
294
|
|
|
295
|
+
/** Records aggregate metrics for a completed checkpoint build. */
|
|
296
|
+
recordCheckpointBuild(durationMs: number, blockCount: number, txCount: number, totalMana: number) {
|
|
297
|
+
this.checkpointBuildDuration.record(Math.ceil(durationMs));
|
|
298
|
+
this.checkpointBlockCount.record(blockCount);
|
|
299
|
+
this.checkpointTxCount.record(txCount);
|
|
300
|
+
this.checkpointTotalMana.record(totalMana);
|
|
301
|
+
}
|
|
302
|
+
|
|
237
303
|
recordSlashingAttempt(actionCount: number) {
|
|
238
304
|
this.slashingAttempts.add(actionCount);
|
|
239
305
|
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Records metrics for a completed fisherman fee analysis
|
|
309
|
+
* @param analysis - The completed fee analysis result
|
|
310
|
+
*/
|
|
311
|
+
recordFishermanFeeAnalysis(analysis: L1FeeAnalysisResult) {
|
|
312
|
+
// In fisherman mode, we should always have strategy results
|
|
313
|
+
if (!analysis.computedPrices.strategyResults || analysis.computedPrices.strategyResults.length === 0) {
|
|
314
|
+
// This should never happen in fisherman mode - log an error
|
|
315
|
+
// We don't record metrics without strategy IDs as that defeats the purpose
|
|
316
|
+
throw new Error(
|
|
317
|
+
`No strategy results found in fisherman fee analysis ${analysis.id}. This indicates a bug in the fee analysis.`,
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Record metrics for each strategy separately
|
|
322
|
+
for (const strategyResult of analysis.computedPrices.strategyResults) {
|
|
323
|
+
const strategyAttributes = {
|
|
324
|
+
[Attributes.FISHERMAN_FEE_STRATEGY_ID]: strategyResult.strategyId,
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
// Record pending block snapshot data (once per strategy for comparison)
|
|
328
|
+
this.fishermanPendingBlobTxCount.record(analysis.pendingSnapshot.pendingBlobTxCount, strategyAttributes);
|
|
329
|
+
this.fishermanPendingBlobCount.record(analysis.pendingSnapshot.pendingBlobCount, strategyAttributes);
|
|
330
|
+
|
|
331
|
+
// Record mined block data if available
|
|
332
|
+
if (analysis.minedBlock) {
|
|
333
|
+
this.fishermanIncludedBlobTxCount.record(analysis.minedBlock.includedBlobTxCount, strategyAttributes);
|
|
334
|
+
this.fishermanIncludedBlobCount.record(analysis.minedBlock.includedBlobCount, strategyAttributes);
|
|
335
|
+
|
|
336
|
+
// Record actual fees from blob transactions in the mined block
|
|
337
|
+
for (const blobTx of analysis.minedBlock.includedBlobTxs) {
|
|
338
|
+
// Record priority fee per gas in Gwei
|
|
339
|
+
const priorityFeeGwei = Number(blobTx.maxPriorityFeePerGas) / 1e9;
|
|
340
|
+
this.fishermanMinedBlobTxPriorityFee.record(priorityFeeGwei, strategyAttributes);
|
|
341
|
+
|
|
342
|
+
// Calculate total cost in ETH
|
|
343
|
+
// Cost = (gas * (baseFee + priorityFee)) + (blobCount * blobGasPerBlob * blobBaseFee)
|
|
344
|
+
const baseFee = analysis.minedBlock.baseFeePerGas;
|
|
345
|
+
const effectiveGasPrice = baseFee + blobTx.maxPriorityFeePerGas;
|
|
346
|
+
|
|
347
|
+
// Calculate execution cost using actual gas limit from the transaction
|
|
348
|
+
const executionCost = blobTx.gas * effectiveGasPrice;
|
|
349
|
+
|
|
350
|
+
// Calculate blob cost using maxFeePerBlobGas * blobCount * GAS_PER_BLOB
|
|
351
|
+
const blobCost = blobTx.maxFeePerBlobGas * BigInt(blobTx.blobCount) * 131072n; // 128KB per blob
|
|
352
|
+
|
|
353
|
+
const totalCostWei = executionCost + blobCost;
|
|
354
|
+
const totalCostEth = Number(totalCostWei) / 1e18;
|
|
355
|
+
|
|
356
|
+
this.fishermanMinedBlobTxTotalCost.record(totalCostEth, strategyAttributes);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Record the calculated priority fee for this strategy
|
|
361
|
+
const calculatedPriorityFeeGwei = Number(strategyResult.calculatedPriorityFee) / 1e9;
|
|
362
|
+
this.fishermanCalculatedPriorityFee.record(calculatedPriorityFeeGwei, strategyAttributes);
|
|
363
|
+
|
|
364
|
+
// Record analysis results if available
|
|
365
|
+
if (analysis.analysis) {
|
|
366
|
+
this.fishermanTimeBeforeBlock.record(Math.ceil(analysis.analysis.timeBeforeBlockMs), strategyAttributes);
|
|
367
|
+
|
|
368
|
+
// Record whether the block reached 100% blob capacity
|
|
369
|
+
if (analysis.analysis.blockBlobsFull) {
|
|
370
|
+
this.fishermanBlockBlobsFull.add(1, { ...strategyAttributes, [Attributes.OK]: true });
|
|
371
|
+
} else {
|
|
372
|
+
this.fishermanBlockBlobsFull.add(1, { ...strategyAttributes, [Attributes.OK]: false });
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// Record the max blob capacity for this block
|
|
376
|
+
this.fishermanMaxBlobCapacity.record(analysis.analysis.maxBlobCapacity, strategyAttributes);
|
|
377
|
+
|
|
378
|
+
// Record strategy-specific inclusion result
|
|
379
|
+
if (strategyResult.wouldBeIncluded !== undefined) {
|
|
380
|
+
const inclusionAttributes = {
|
|
381
|
+
...strategyAttributes,
|
|
382
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false',
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
if (strategyResult.wouldBeIncluded) {
|
|
386
|
+
this.fishermanWouldBeIncluded.add(1, { ...inclusionAttributes, [Attributes.OK]: true });
|
|
387
|
+
} else {
|
|
388
|
+
this.fishermanWouldBeIncluded.add(1, {
|
|
389
|
+
...inclusionAttributes,
|
|
390
|
+
[Attributes.OK]: false,
|
|
391
|
+
...(strategyResult.exclusionReason && { [Attributes.ERROR_TYPE]: strategyResult.exclusionReason }),
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// Record strategy-specific priority fee delta
|
|
397
|
+
if (strategyResult.priorityFeeDelta !== undefined) {
|
|
398
|
+
const priorityFeeDeltaGwei = Number(strategyResult.priorityFeeDelta) / 1e9;
|
|
399
|
+
const deltaAttributes = {
|
|
400
|
+
...strategyAttributes,
|
|
401
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false',
|
|
402
|
+
};
|
|
403
|
+
this.fishermanPriorityFeeDelta.record(priorityFeeDeltaGwei, deltaAttributes);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Record estimated cost if available
|
|
407
|
+
if (strategyResult.estimatedCostEth !== undefined) {
|
|
408
|
+
const costAttributes = {
|
|
409
|
+
...strategyAttributes,
|
|
410
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false',
|
|
411
|
+
};
|
|
412
|
+
this.fishermanEstimatedCost.record(strategyResult.estimatedCostEth, costAttributes);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// Record estimated overpayment if available
|
|
416
|
+
if (strategyResult.estimatedOverpaymentEth !== undefined) {
|
|
417
|
+
const overpaymentAttributes = {
|
|
418
|
+
...strategyAttributes,
|
|
419
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false',
|
|
420
|
+
};
|
|
421
|
+
this.fishermanEstimatedOverpayment.record(strategyResult.estimatedOverpaymentEth, overpaymentAttributes);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
240
426
|
}
|