@aztec/sequencer-client 0.85.0-alpha-testnet.2 → 0.85.0-alpha-testnet.4
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/publisher/sequencer-publisher.d.ts +14 -9
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +10 -1
- package/dest/sequencer/metrics.d.ts +16 -1
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +80 -11
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +11 -2
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +16 -3
- package/package.json +25 -25
- package/src/publisher/sequencer-publisher.ts +9 -1
- package/src/sequencer/metrics.ts +107 -16
- package/src/sequencer/sequencer.ts +17 -2
- package/src/tx_validator/tx_validator_factory.ts +16 -3
|
@@ -62,6 +62,7 @@ export declare class SequencerPublisher {
|
|
|
62
62
|
governanceProposerContract: GovernanceProposerContract;
|
|
63
63
|
epochCache: EpochCache;
|
|
64
64
|
});
|
|
65
|
+
getRollupContract(): RollupContract;
|
|
65
66
|
registerSlashPayloadGetter(callback: GetSlashPayloadCallBack): void;
|
|
66
67
|
getForwarderAddress(): EthAddress;
|
|
67
68
|
getSenderAddress(): EthAddress;
|
|
@@ -77,15 +78,19 @@ export declare class SequencerPublisher {
|
|
|
77
78
|
* - undefined if no valid requests are found OR the tx failed to send.
|
|
78
79
|
*/
|
|
79
80
|
sendRequests(): Promise<{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
result: {
|
|
82
|
+
receipt: TransactionReceipt<bigint, number, "success" | "reverted", import("viem").TransactionType>;
|
|
83
|
+
gasPrice: GasPrice;
|
|
84
|
+
stats: TransactionStats | undefined;
|
|
85
|
+
errorMsg?: undefined;
|
|
86
|
+
} | {
|
|
87
|
+
receipt: TransactionReceipt<bigint, number, "success" | "reverted", import("viem").TransactionType>;
|
|
88
|
+
gasPrice: GasPrice;
|
|
89
|
+
errorMsg: string | undefined;
|
|
90
|
+
stats?: undefined;
|
|
91
|
+
};
|
|
92
|
+
expiredActions: Action[];
|
|
93
|
+
validActions: Action[];
|
|
89
94
|
} | undefined>;
|
|
90
95
|
private callbackBundledTransactions;
|
|
91
96
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequencer-publisher.d.ts","sourceRoot":"","sources":["../../src/publisher/sequencer-publisher.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,KAAK,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AAC7F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACb,KAAK,0BAA0B,EAE/B,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,cAAc,EACd,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAMjE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAGnF,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,MA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ashingProposerContract = deps.slashingProposerContract;
|
|
57
57
|
}
|
|
58
|
+
getRollupContract() {
|
|
59
|
+
return this.rollupContract;
|
|
60
|
+
}
|
|
58
61
|
registerSlashPayloadGetter(callback) {
|
|
59
62
|
this.getSlashPayload = callback;
|
|
60
63
|
}
|
|
@@ -93,6 +96,8 @@ export class SequencerPublisher {
|
|
|
93
96
|
const currentL2Slot = this.getCurrentL2Slot();
|
|
94
97
|
this.log.debug(`Current L2 slot: ${currentL2Slot}`);
|
|
95
98
|
const validRequests = requestsToProcess.filter((request)=>request.lastValidL2Slot >= currentL2Slot);
|
|
99
|
+
const validActions = validRequests.map((x)=>x.action);
|
|
100
|
+
const expiredActions = requestsToProcess.filter((request)=>request.lastValidL2Slot < currentL2Slot).map((x)=>x.action);
|
|
96
101
|
if (validRequests.length !== requestsToProcess.length) {
|
|
97
102
|
this.log.warn(`Some requests were expired for slot ${currentL2Slot}`, {
|
|
98
103
|
validRequests: validRequests.map((request)=>({
|
|
@@ -125,7 +130,11 @@ export class SequencerPublisher {
|
|
|
125
130
|
});
|
|
126
131
|
const result = await this.forwarderContract.forward(validRequests.map((request)=>request.request), this.l1TxUtils, gasConfig, blobConfig, this.log);
|
|
127
132
|
this.callbackBundledTransactions(validRequests, result);
|
|
128
|
-
return
|
|
133
|
+
return {
|
|
134
|
+
result,
|
|
135
|
+
expiredActions,
|
|
136
|
+
validActions
|
|
137
|
+
};
|
|
129
138
|
} catch (err) {
|
|
130
139
|
const viemError = formatViemError(err);
|
|
131
140
|
this.log.error(`Failed to publish bundled transactions`, viemError);
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/aztec.js';
|
|
2
|
+
import type { RollupContract } from '@aztec/ethereum';
|
|
1
3
|
import { type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
|
|
2
4
|
import { type SequencerState, type SequencerStateCallback } from './utils.js';
|
|
3
5
|
export declare class SequencerMetrics {
|
|
6
|
+
private coinbase;
|
|
7
|
+
private rollup;
|
|
4
8
|
readonly tracer: Tracer;
|
|
9
|
+
private meter;
|
|
5
10
|
private blockCounter;
|
|
6
11
|
private blockBuildDuration;
|
|
7
12
|
private blockBuildManaPerSecond;
|
|
@@ -10,7 +15,15 @@ export declare class SequencerMetrics {
|
|
|
10
15
|
private currentBlockSize;
|
|
11
16
|
private blockBuilderInsertions;
|
|
12
17
|
private timeToCollectAttestations;
|
|
13
|
-
|
|
18
|
+
private rewards;
|
|
19
|
+
private slots;
|
|
20
|
+
private filledSlots;
|
|
21
|
+
private missedSlots;
|
|
22
|
+
private lastSeenSlot?;
|
|
23
|
+
constructor(client: TelemetryClient, getState: SequencerStateCallback, coinbase: EthAddress, rollup: RollupContract, name?: string);
|
|
24
|
+
start(): void;
|
|
25
|
+
stop(): void;
|
|
26
|
+
private observe;
|
|
14
27
|
startCollectingAttestationsTimer(): () => void;
|
|
15
28
|
recordTimeToCollectAttestations(time: number): void;
|
|
16
29
|
recordBlockBuilderTreeInsertions(timeUs: number): void;
|
|
@@ -19,6 +32,8 @@ export declare class SequencerMetrics {
|
|
|
19
32
|
recordFailedBlock(): void;
|
|
20
33
|
recordNewBlock(blockNumber: number, txCount: number): void;
|
|
21
34
|
recordStateTransitionBufferMs(durationMs: number, state: SequencerState): void;
|
|
35
|
+
observeSlotChange(slot: bigint | undefined, proposer: string): void;
|
|
36
|
+
incFilledSlot(proposer: string): void;
|
|
22
37
|
private setCurrentBlock;
|
|
23
38
|
}
|
|
24
39
|
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/sequencer/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/sequencer/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,cA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AU,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc;IAMvE,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM;IAqB5D,aAAa,CAAC,QAAQ,EAAE,MAAM;IAO9B,OAAO,CAAC,eAAe;CAIxB"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
|
|
2
|
+
import { formatUnits } from 'viem';
|
|
2
3
|
import { sequencerStateToNumber } from './utils.js';
|
|
3
4
|
export class SequencerMetrics {
|
|
5
|
+
coinbase;
|
|
6
|
+
rollup;
|
|
4
7
|
tracer;
|
|
8
|
+
meter;
|
|
5
9
|
blockCounter;
|
|
6
10
|
blockBuildDuration;
|
|
7
11
|
blockBuildManaPerSecond;
|
|
@@ -10,44 +14,59 @@ export class SequencerMetrics {
|
|
|
10
14
|
currentBlockSize;
|
|
11
15
|
blockBuilderInsertions;
|
|
12
16
|
timeToCollectAttestations;
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
rewards;
|
|
18
|
+
slots;
|
|
19
|
+
filledSlots;
|
|
20
|
+
missedSlots;
|
|
21
|
+
lastSeenSlot;
|
|
22
|
+
constructor(client, getState, coinbase, rollup, name = 'Sequencer'){
|
|
23
|
+
this.coinbase = coinbase;
|
|
24
|
+
this.rollup = rollup;
|
|
25
|
+
this.observe = async (observer)=>{
|
|
26
|
+
let rewards = 0n;
|
|
27
|
+
rewards = await this.rollup.getSequencerRewards(this.coinbase);
|
|
28
|
+
const fmt = parseFloat(formatUnits(rewards, 18));
|
|
29
|
+
observer.observe(this.rewards, fmt, {
|
|
30
|
+
[Attributes.COINBASE]: this.coinbase.toString()
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
this.meter = client.getMeter(name);
|
|
15
34
|
this.tracer = client.getTracer(name);
|
|
16
|
-
this.blockCounter = meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_COUNT);
|
|
17
|
-
this.blockBuildDuration = meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION, {
|
|
35
|
+
this.blockCounter = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_COUNT);
|
|
36
|
+
this.blockBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION, {
|
|
18
37
|
unit: 'ms',
|
|
19
38
|
description: 'Duration to build a block',
|
|
20
39
|
valueType: ValueType.INT
|
|
21
40
|
});
|
|
22
|
-
this.blockBuildManaPerSecond = meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND, {
|
|
41
|
+
this.blockBuildManaPerSecond = this.meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND, {
|
|
23
42
|
unit: 'mana/s',
|
|
24
43
|
description: 'Mana per second when building a block',
|
|
25
44
|
valueType: ValueType.INT
|
|
26
45
|
});
|
|
27
|
-
this.stateTransitionBufferDuration = meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION, {
|
|
46
|
+
this.stateTransitionBufferDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION, {
|
|
28
47
|
unit: 'ms',
|
|
29
48
|
description: 'The time difference between when the sequencer needed to transition to a new state and when it actually did.',
|
|
30
49
|
valueType: ValueType.INT
|
|
31
50
|
});
|
|
32
|
-
const currentState = meter.createObservableGauge(Metrics.SEQUENCER_CURRENT_STATE, {
|
|
51
|
+
const currentState = this.meter.createObservableGauge(Metrics.SEQUENCER_CURRENT_STATE, {
|
|
33
52
|
description: 'Current state of the sequencer'
|
|
34
53
|
});
|
|
35
54
|
currentState.addCallback((observer)=>{
|
|
36
55
|
observer.observe(sequencerStateToNumber(getState()));
|
|
37
56
|
});
|
|
38
|
-
this.currentBlockNumber = meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_NUMBER, {
|
|
57
|
+
this.currentBlockNumber = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_NUMBER, {
|
|
39
58
|
description: 'Current block number',
|
|
40
59
|
valueType: ValueType.INT
|
|
41
60
|
});
|
|
42
|
-
this.currentBlockSize = meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_SIZE, {
|
|
61
|
+
this.currentBlockSize = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_SIZE, {
|
|
43
62
|
description: 'Current block size',
|
|
44
63
|
valueType: ValueType.INT
|
|
45
64
|
});
|
|
46
|
-
this.timeToCollectAttestations = meter.createGauge(Metrics.SEQUENCER_TIME_TO_COLLECT_ATTESTATIONS, {
|
|
65
|
+
this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_TIME_TO_COLLECT_ATTESTATIONS, {
|
|
47
66
|
description: 'The time spent collecting attestations from committee members',
|
|
48
67
|
valueType: ValueType.INT
|
|
49
68
|
});
|
|
50
|
-
this.blockBuilderInsertions = meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_INSERTION_TIME, {
|
|
69
|
+
this.blockBuilderInsertions = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_INSERTION_TIME, {
|
|
51
70
|
description: 'Timer for tree insertions performed by the block builder',
|
|
52
71
|
unit: 'us',
|
|
53
72
|
valueType: ValueType.INT
|
|
@@ -63,7 +82,34 @@ export class SequencerMetrics {
|
|
|
63
82
|
this.blockCounter.add(0, {
|
|
64
83
|
[Attributes.STATUS]: 'built'
|
|
65
84
|
});
|
|
85
|
+
this.rewards = this.meter.createObservableGauge(Metrics.SEQUENCER_CURRENT_BLOCK_REWARDS, {
|
|
86
|
+
valueType: ValueType.DOUBLE,
|
|
87
|
+
description: 'The rewards earned'
|
|
88
|
+
});
|
|
89
|
+
this.slots = this.meter.createUpDownCounter(Metrics.SEQUENCER_SLOT_COUNT, {
|
|
90
|
+
valueType: ValueType.INT,
|
|
91
|
+
description: 'The number of slots this sequencer was selected for'
|
|
92
|
+
});
|
|
93
|
+
this.filledSlots = this.meter.createUpDownCounter(Metrics.SEQUENCER_FILLED_SLOT_COUNT, {
|
|
94
|
+
valueType: ValueType.INT,
|
|
95
|
+
description: 'The number of slots this sequencer has filled'
|
|
96
|
+
});
|
|
97
|
+
this.missedSlots = this.meter.createUpDownCounter(Metrics.SEQUENCER_MISSED_SLOT_COUNT, {
|
|
98
|
+
valueType: ValueType.INT,
|
|
99
|
+
description: 'The number of slots this sequencer has missed to fill'
|
|
100
|
+
});
|
|
66
101
|
}
|
|
102
|
+
start() {
|
|
103
|
+
this.meter.addBatchObservableCallback(this.observe, [
|
|
104
|
+
this.rewards
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
107
|
+
stop() {
|
|
108
|
+
this.meter.removeBatchObservableCallback(this.observe, [
|
|
109
|
+
this.rewards
|
|
110
|
+
]);
|
|
111
|
+
}
|
|
112
|
+
observe;
|
|
67
113
|
startCollectingAttestationsTimer() {
|
|
68
114
|
const startTime = Date.now();
|
|
69
115
|
const stop = ()=>{
|
|
@@ -105,6 +151,29 @@ export class SequencerMetrics {
|
|
|
105
151
|
[Attributes.SEQUENCER_STATE]: state
|
|
106
152
|
});
|
|
107
153
|
}
|
|
154
|
+
observeSlotChange(slot, proposer) {
|
|
155
|
+
// sequencer went through the loop a second time. Noop
|
|
156
|
+
if (slot === this.lastSeenSlot) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (typeof this.lastSeenSlot === 'bigint') {
|
|
160
|
+
this.missedSlots.add(1, {
|
|
161
|
+
[Attributes.BLOCK_PROPOSER]: proposer
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (typeof slot === 'bigint') {
|
|
165
|
+
this.slots.add(1, {
|
|
166
|
+
[Attributes.BLOCK_PROPOSER]: proposer
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
this.lastSeenSlot = slot;
|
|
170
|
+
}
|
|
171
|
+
incFilledSlot(proposer) {
|
|
172
|
+
this.filledSlots.add(1, {
|
|
173
|
+
[Attributes.BLOCK_PROPOSER]: proposer
|
|
174
|
+
});
|
|
175
|
+
this.lastSeenSlot = undefined;
|
|
176
|
+
}
|
|
108
177
|
setCurrentBlock(blockNumber, txCount) {
|
|
109
178
|
this.currentBlockNumber.record(blockNumber);
|
|
110
179
|
this.currentBlockSize.record(txCount);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequencer.d.ts","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,iBAAiB,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,EAAW,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAGL,KAAK,eAAe,EAEpB,EAAE,EACF,KAAK,MAAM,EACZ,MAAM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AE,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC,EAC5C,kBAAkB,EAAE,eAAe,EACnC,IAAI,GAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAO;;;;;;;;;IAuIvC;;;;;;;;OAQG;YAIW,2BAA2B;cAkEzB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,SAAS,CAAC;IA6CzG;;;OAGG;cAIa,qBAAqB,CACnC,KAAK,EAAE,OAAO,EACd,YAAY,CAAC,EAAE,SAAS,EAAE,EAC1B,QAAQ,CAAC,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,IAAI,CAAC;IAiBhB;;;;OAIG;cACa,WAAW,IAAI,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,EAAE,CAAA;KAAE,GAAG,SAAS,CAAC;IA+CxF,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,kBAAkB;IAK1B,IAAI,iBAAiB,WAEpB;IAED,IAAI,QAAQ,IAAI,UAAU,CAEzB;IAED,IAAI,YAAY,IAAI,YAAY,CAE/B;IAED,IAAI,aAAa,IAAI,MAAM,GAAG,SAAS,CAEtC;CACF"}
|
|
@@ -95,7 +95,7 @@ export { SequencerState };
|
|
|
95
95
|
this.maxBlockGas = new Gas(100e9, 100e9);
|
|
96
96
|
this.isFlushing = false;
|
|
97
97
|
this.enforceTimeTable = false;
|
|
98
|
-
this.metrics = new SequencerMetrics(telemetry, ()=>this.state, 'Sequencer');
|
|
98
|
+
this.metrics = new SequencerMetrics(telemetry, ()=>this.state, this._coinbase, this.publisher.getRollupContract(), 'Sequencer');
|
|
99
99
|
this.l1Metrics = new L1Metrics(telemetry.getMeter('SequencerL1Metrics'), publisher.l1TxUtils.publicClient, [
|
|
100
100
|
publisher.getSenderAddress()
|
|
101
101
|
]);
|
|
@@ -167,6 +167,7 @@ export { SequencerState };
|
|
|
167
167
|
* Starts the sequencer and moves to IDLE state.
|
|
168
168
|
*/ async start() {
|
|
169
169
|
await this.updateConfig(this.config);
|
|
170
|
+
this.metrics.start();
|
|
170
171
|
this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.pollingIntervalMs);
|
|
171
172
|
this.setState(SequencerState.IDLE, 0n, true);
|
|
172
173
|
this.runningPromise.start();
|
|
@@ -177,6 +178,7 @@ export { SequencerState };
|
|
|
177
178
|
* Stops the sequencer from processing txs and moves to STOPPED state.
|
|
178
179
|
*/ async stop() {
|
|
179
180
|
this.log.debug(`Stopping sequencer`);
|
|
181
|
+
this.metrics.stop();
|
|
180
182
|
await this.validatorClient?.stop();
|
|
181
183
|
await this.runningPromise?.stop();
|
|
182
184
|
this.slasherClient.stop();
|
|
@@ -224,6 +226,7 @@ export { SequencerState };
|
|
|
224
226
|
// If we cannot find a tip archive, assume genesis.
|
|
225
227
|
const chainTipArchive = chainTip.archive;
|
|
226
228
|
const slot = await this.slotForProposal(chainTipArchive.toBuffer(), BigInt(newBlockNumber));
|
|
229
|
+
this.metrics.observeSlotChange(slot, this.publisher.getSenderAddress().toString());
|
|
227
230
|
if (!slot) {
|
|
228
231
|
this.log.debug(`Cannot propose block ${newBlockNumber}`);
|
|
229
232
|
return;
|
|
@@ -272,7 +275,13 @@ export { SequencerState };
|
|
|
272
275
|
slot
|
|
273
276
|
});
|
|
274
277
|
});
|
|
275
|
-
await this.publisher.sendRequests();
|
|
278
|
+
const resp = await this.publisher.sendRequests();
|
|
279
|
+
if (resp) {
|
|
280
|
+
const proposedBlock = resp.validActions.find((a)=>a === 'propose');
|
|
281
|
+
if (proposedBlock) {
|
|
282
|
+
this.metrics.incFilledSlot(this.publisher.getSenderAddress().toString());
|
|
283
|
+
}
|
|
284
|
+
}
|
|
276
285
|
if (finishedFlushing) {
|
|
277
286
|
this.isFlushing = false;
|
|
278
287
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_validator_factory.d.ts","sourceRoot":"","sources":["../../src/tx_validator/tx_validator_factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tx_validator_factory.d.ts","sourceRoot":"","sources":["../../src/tx_validator/tx_validator_factory.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,wBAAgB,8BAA8B,CAC5C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,6BAA6B,GAAG,SAAS,EACnD,EACE,WAAW,EACX,SAAS,EACT,aAAa,EACb,cAAc,EACd,OAAO,EACP,kBAAkB,GACnB,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,GACA,WAAW,CAAC,EAAE,CAAC,CAwBjB;AAED,wBAAgB,+BAA+B,CAC7C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAAE,GAC/B;IACD,mBAAmB,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;IACrC,cAAc,EAAE,cAAc,CAAC;CAChC,CAgBA"}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
2
3
|
import { AggregateTxValidator, ArchiveCache, BlockHeaderTxValidator, DataTxValidator, DoubleSpendTxValidator, GasTxValidator, MetadataTxValidator, PhasesTxValidator, TxProofValidator } from '@aztec/p2p';
|
|
3
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
4
|
+
import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
4
5
|
import { DatabasePublicStateSource } from '@aztec/stdlib/trees';
|
|
5
6
|
import { NullifierCache } from './nullifier_cache.js';
|
|
6
7
|
export function createValidatorForAcceptingTxs(db, contractDataSource, verifier, { blockNumber, l1ChainId, rollupVersion, setupAllowList, gasFees, skipFeeEnforcement }) {
|
|
7
8
|
const validators = [
|
|
8
9
|
new DataTxValidator(),
|
|
9
|
-
new MetadataTxValidator(
|
|
10
|
+
new MetadataTxValidator({
|
|
11
|
+
l1ChainId: new Fr(l1ChainId),
|
|
12
|
+
rollupVersion: new Fr(rollupVersion),
|
|
13
|
+
blockNumber: new Fr(blockNumber),
|
|
14
|
+
protocolContractTreeRoot,
|
|
15
|
+
vkTreeRoot: getVKTreeRoot()
|
|
16
|
+
}),
|
|
10
17
|
new DoubleSpendTxValidator(new NullifierCache(db)),
|
|
11
18
|
new PhasesTxValidator(contractDataSource, setupAllowList, blockNumber),
|
|
12
19
|
new BlockHeaderTxValidator(new ArchiveCache(db))
|
|
@@ -30,5 +37,11 @@ export function createValidatorForBlockBuilding(db, contractDataSource, globalVa
|
|
|
30
37
|
}
|
|
31
38
|
function preprocessValidator(nullifierCache, archiveCache, publicStateSource, contractDataSource, globalVariables, setupAllowList) {
|
|
32
39
|
// We don't include the TxProofValidator nor the DataTxValidator here because they are already checked by the time we get to block building.
|
|
33
|
-
return new AggregateTxValidator(new MetadataTxValidator(
|
|
40
|
+
return new AggregateTxValidator(new MetadataTxValidator({
|
|
41
|
+
l1ChainId: globalVariables.chainId,
|
|
42
|
+
rollupVersion: globalVariables.version,
|
|
43
|
+
blockNumber: globalVariables.blockNumber,
|
|
44
|
+
protocolContractTreeRoot,
|
|
45
|
+
vkTreeRoot: getVKTreeRoot()
|
|
46
|
+
}), new DoubleSpendTxValidator(nullifierCache), new PhasesTxValidator(contractDataSource, setupAllowList, globalVariables.blockNumber.toNumber()), new GasTxValidator(publicStateSource, ProtocolContractAddress.FeeJuice, globalVariables.gasFees), new BlockHeaderTxValidator(archiveCache));
|
|
34
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/sequencer-client",
|
|
3
|
-
"version": "0.85.0-alpha-testnet.
|
|
3
|
+
"version": "0.85.0-alpha-testnet.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -28,36 +28,36 @@
|
|
|
28
28
|
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@aztec/aztec.js": "0.85.0-alpha-testnet.
|
|
32
|
-
"@aztec/bb-prover": "0.85.0-alpha-testnet.
|
|
33
|
-
"@aztec/blob-lib": "0.85.0-alpha-testnet.
|
|
34
|
-
"@aztec/blob-sink": "0.85.0-alpha-testnet.
|
|
35
|
-
"@aztec/constants": "0.85.0-alpha-testnet.
|
|
36
|
-
"@aztec/epoch-cache": "0.85.0-alpha-testnet.
|
|
37
|
-
"@aztec/ethereum": "0.85.0-alpha-testnet.
|
|
38
|
-
"@aztec/foundation": "0.85.0-alpha-testnet.
|
|
39
|
-
"@aztec/l1-artifacts": "0.85.0-alpha-testnet.
|
|
40
|
-
"@aztec/merkle-tree": "0.85.0-alpha-testnet.
|
|
41
|
-
"@aztec/noir-acvm_js": "0.85.0-alpha-testnet.
|
|
42
|
-
"@aztec/noir-contracts.js": "0.85.0-alpha-testnet.
|
|
43
|
-
"@aztec/noir-protocol-circuits-types": "0.85.0-alpha-testnet.
|
|
44
|
-
"@aztec/noir-types": "0.85.0-alpha-testnet.
|
|
45
|
-
"@aztec/p2p": "0.85.0-alpha-testnet.
|
|
46
|
-
"@aztec/protocol-contracts": "0.85.0-alpha-testnet.
|
|
47
|
-
"@aztec/prover-client": "0.85.0-alpha-testnet.
|
|
48
|
-
"@aztec/simulator": "0.85.0-alpha-testnet.
|
|
49
|
-
"@aztec/stdlib": "0.85.0-alpha-testnet.
|
|
50
|
-
"@aztec/telemetry-client": "0.85.0-alpha-testnet.
|
|
51
|
-
"@aztec/validator-client": "0.85.0-alpha-testnet.
|
|
52
|
-
"@aztec/world-state": "0.85.0-alpha-testnet.
|
|
31
|
+
"@aztec/aztec.js": "0.85.0-alpha-testnet.4",
|
|
32
|
+
"@aztec/bb-prover": "0.85.0-alpha-testnet.4",
|
|
33
|
+
"@aztec/blob-lib": "0.85.0-alpha-testnet.4",
|
|
34
|
+
"@aztec/blob-sink": "0.85.0-alpha-testnet.4",
|
|
35
|
+
"@aztec/constants": "0.85.0-alpha-testnet.4",
|
|
36
|
+
"@aztec/epoch-cache": "0.85.0-alpha-testnet.4",
|
|
37
|
+
"@aztec/ethereum": "0.85.0-alpha-testnet.4",
|
|
38
|
+
"@aztec/foundation": "0.85.0-alpha-testnet.4",
|
|
39
|
+
"@aztec/l1-artifacts": "0.85.0-alpha-testnet.4",
|
|
40
|
+
"@aztec/merkle-tree": "0.85.0-alpha-testnet.4",
|
|
41
|
+
"@aztec/noir-acvm_js": "0.85.0-alpha-testnet.4",
|
|
42
|
+
"@aztec/noir-contracts.js": "0.85.0-alpha-testnet.4",
|
|
43
|
+
"@aztec/noir-protocol-circuits-types": "0.85.0-alpha-testnet.4",
|
|
44
|
+
"@aztec/noir-types": "0.85.0-alpha-testnet.4",
|
|
45
|
+
"@aztec/p2p": "0.85.0-alpha-testnet.4",
|
|
46
|
+
"@aztec/protocol-contracts": "0.85.0-alpha-testnet.4",
|
|
47
|
+
"@aztec/prover-client": "0.85.0-alpha-testnet.4",
|
|
48
|
+
"@aztec/simulator": "0.85.0-alpha-testnet.4",
|
|
49
|
+
"@aztec/stdlib": "0.85.0-alpha-testnet.4",
|
|
50
|
+
"@aztec/telemetry-client": "0.85.0-alpha-testnet.4",
|
|
51
|
+
"@aztec/validator-client": "0.85.0-alpha-testnet.4",
|
|
52
|
+
"@aztec/world-state": "0.85.0-alpha-testnet.4",
|
|
53
53
|
"lodash.chunk": "^4.2.0",
|
|
54
54
|
"lodash.pick": "^4.4.0",
|
|
55
55
|
"tslib": "^2.4.0",
|
|
56
56
|
"viem": "2.23.7"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@aztec/archiver": "0.85.0-alpha-testnet.
|
|
60
|
-
"@aztec/kv-store": "0.85.0-alpha-testnet.
|
|
59
|
+
"@aztec/archiver": "0.85.0-alpha-testnet.4",
|
|
60
|
+
"@aztec/kv-store": "0.85.0-alpha-testnet.4",
|
|
61
61
|
"@jest/globals": "^29.5.0",
|
|
62
62
|
"@types/jest": "^29.5.0",
|
|
63
63
|
"@types/lodash.chunk": "^4.2.7",
|
|
@@ -135,6 +135,10 @@ export class SequencerPublisher {
|
|
|
135
135
|
this.slashingProposerContract = deps.slashingProposerContract;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
public getRollupContract(): RollupContract {
|
|
139
|
+
return this.rollupContract;
|
|
140
|
+
}
|
|
141
|
+
|
|
138
142
|
public registerSlashPayloadGetter(callback: GetSlashPayloadCallBack) {
|
|
139
143
|
this.getSlashPayload = callback;
|
|
140
144
|
}
|
|
@@ -179,6 +183,10 @@ export class SequencerPublisher {
|
|
|
179
183
|
const currentL2Slot = this.getCurrentL2Slot();
|
|
180
184
|
this.log.debug(`Current L2 slot: ${currentL2Slot}`);
|
|
181
185
|
const validRequests = requestsToProcess.filter(request => request.lastValidL2Slot >= currentL2Slot);
|
|
186
|
+
const validActions = validRequests.map(x => x.action);
|
|
187
|
+
const expiredActions = requestsToProcess
|
|
188
|
+
.filter(request => request.lastValidL2Slot < currentL2Slot)
|
|
189
|
+
.map(x => x.action);
|
|
182
190
|
|
|
183
191
|
if (validRequests.length !== requestsToProcess.length) {
|
|
184
192
|
this.log.warn(`Some requests were expired for slot ${currentL2Slot}`, {
|
|
@@ -223,7 +231,7 @@ export class SequencerPublisher {
|
|
|
223
231
|
this.log,
|
|
224
232
|
);
|
|
225
233
|
this.callbackBundledTransactions(validRequests, result);
|
|
226
|
-
return result;
|
|
234
|
+
return { result, expiredActions, validActions };
|
|
227
235
|
} catch (err) {
|
|
228
236
|
const viemError = formatViemError(err);
|
|
229
237
|
this.log.error(`Failed to publish bundled transactions`, viemError);
|
package/src/sequencer/metrics.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/aztec.js';
|
|
2
|
+
import type { RollupContract } from '@aztec/ethereum';
|
|
1
3
|
import {
|
|
2
4
|
Attributes,
|
|
5
|
+
type BatchObservableResult,
|
|
3
6
|
type Gauge,
|
|
4
7
|
type Histogram,
|
|
8
|
+
type Meter,
|
|
5
9
|
Metrics,
|
|
10
|
+
type ObservableGauge,
|
|
6
11
|
type TelemetryClient,
|
|
7
12
|
type Tracer,
|
|
8
13
|
type UpDownCounter,
|
|
9
14
|
ValueType,
|
|
10
15
|
} from '@aztec/telemetry-client';
|
|
11
16
|
|
|
17
|
+
import { formatUnits } from 'viem';
|
|
18
|
+
|
|
12
19
|
import { type SequencerState, type SequencerStateCallback, sequencerStateToNumber } from './utils.js';
|
|
13
20
|
|
|
14
21
|
export class SequencerMetrics {
|
|
15
22
|
public readonly tracer: Tracer;
|
|
23
|
+
private meter: Meter;
|
|
16
24
|
|
|
17
25
|
private blockCounter: UpDownCounter;
|
|
18
26
|
private blockBuildDuration: Histogram;
|
|
@@ -24,32 +32,49 @@ export class SequencerMetrics {
|
|
|
24
32
|
|
|
25
33
|
private timeToCollectAttestations: Gauge;
|
|
26
34
|
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
private rewards: ObservableGauge;
|
|
36
|
+
|
|
37
|
+
private slots: UpDownCounter;
|
|
38
|
+
private filledSlots: UpDownCounter;
|
|
39
|
+
private missedSlots: UpDownCounter;
|
|
40
|
+
|
|
41
|
+
private lastSeenSlot?: bigint;
|
|
42
|
+
|
|
43
|
+
constructor(
|
|
44
|
+
client: TelemetryClient,
|
|
45
|
+
getState: SequencerStateCallback,
|
|
46
|
+
private coinbase: EthAddress,
|
|
47
|
+
private rollup: RollupContract,
|
|
48
|
+
name = 'Sequencer',
|
|
49
|
+
) {
|
|
50
|
+
this.meter = client.getMeter(name);
|
|
29
51
|
this.tracer = client.getTracer(name);
|
|
30
52
|
|
|
31
|
-
this.blockCounter = meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_COUNT);
|
|
53
|
+
this.blockCounter = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_COUNT);
|
|
32
54
|
|
|
33
|
-
this.blockBuildDuration = meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION, {
|
|
55
|
+
this.blockBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION, {
|
|
34
56
|
unit: 'ms',
|
|
35
57
|
description: 'Duration to build a block',
|
|
36
58
|
valueType: ValueType.INT,
|
|
37
59
|
});
|
|
38
60
|
|
|
39
|
-
this.blockBuildManaPerSecond = meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND, {
|
|
61
|
+
this.blockBuildManaPerSecond = this.meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND, {
|
|
40
62
|
unit: 'mana/s',
|
|
41
63
|
description: 'Mana per second when building a block',
|
|
42
64
|
valueType: ValueType.INT,
|
|
43
65
|
});
|
|
44
66
|
|
|
45
|
-
this.stateTransitionBufferDuration = meter.createHistogram(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
67
|
+
this.stateTransitionBufferDuration = this.meter.createHistogram(
|
|
68
|
+
Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION,
|
|
69
|
+
{
|
|
70
|
+
unit: 'ms',
|
|
71
|
+
description:
|
|
72
|
+
'The time difference between when the sequencer needed to transition to a new state and when it actually did.',
|
|
73
|
+
valueType: ValueType.INT,
|
|
74
|
+
},
|
|
75
|
+
);
|
|
51
76
|
|
|
52
|
-
const currentState = meter.createObservableGauge(Metrics.SEQUENCER_CURRENT_STATE, {
|
|
77
|
+
const currentState = this.meter.createObservableGauge(Metrics.SEQUENCER_CURRENT_STATE, {
|
|
53
78
|
description: 'Current state of the sequencer',
|
|
54
79
|
});
|
|
55
80
|
|
|
@@ -57,22 +82,22 @@ export class SequencerMetrics {
|
|
|
57
82
|
observer.observe(sequencerStateToNumber(getState()));
|
|
58
83
|
});
|
|
59
84
|
|
|
60
|
-
this.currentBlockNumber = meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_NUMBER, {
|
|
85
|
+
this.currentBlockNumber = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_NUMBER, {
|
|
61
86
|
description: 'Current block number',
|
|
62
87
|
valueType: ValueType.INT,
|
|
63
88
|
});
|
|
64
89
|
|
|
65
|
-
this.currentBlockSize = meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_SIZE, {
|
|
90
|
+
this.currentBlockSize = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_SIZE, {
|
|
66
91
|
description: 'Current block size',
|
|
67
92
|
valueType: ValueType.INT,
|
|
68
93
|
});
|
|
69
94
|
|
|
70
|
-
this.timeToCollectAttestations = meter.createGauge(Metrics.SEQUENCER_TIME_TO_COLLECT_ATTESTATIONS, {
|
|
95
|
+
this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_TIME_TO_COLLECT_ATTESTATIONS, {
|
|
71
96
|
description: 'The time spent collecting attestations from committee members',
|
|
72
97
|
valueType: ValueType.INT,
|
|
73
98
|
});
|
|
74
99
|
|
|
75
|
-
this.blockBuilderInsertions = meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_INSERTION_TIME, {
|
|
100
|
+
this.blockBuilderInsertions = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_INSERTION_TIME, {
|
|
76
101
|
description: 'Timer for tree insertions performed by the block builder',
|
|
77
102
|
unit: 'us',
|
|
78
103
|
valueType: ValueType.INT,
|
|
@@ -89,8 +114,46 @@ export class SequencerMetrics {
|
|
|
89
114
|
this.blockCounter.add(0, {
|
|
90
115
|
[Attributes.STATUS]: 'built',
|
|
91
116
|
});
|
|
117
|
+
|
|
118
|
+
this.rewards = this.meter.createObservableGauge(Metrics.SEQUENCER_CURRENT_BLOCK_REWARDS, {
|
|
119
|
+
valueType: ValueType.DOUBLE,
|
|
120
|
+
description: 'The rewards earned',
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
this.slots = this.meter.createUpDownCounter(Metrics.SEQUENCER_SLOT_COUNT, {
|
|
124
|
+
valueType: ValueType.INT,
|
|
125
|
+
description: 'The number of slots this sequencer was selected for',
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
this.filledSlots = this.meter.createUpDownCounter(Metrics.SEQUENCER_FILLED_SLOT_COUNT, {
|
|
129
|
+
valueType: ValueType.INT,
|
|
130
|
+
description: 'The number of slots this sequencer has filled',
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
this.missedSlots = this.meter.createUpDownCounter(Metrics.SEQUENCER_MISSED_SLOT_COUNT, {
|
|
134
|
+
valueType: ValueType.INT,
|
|
135
|
+
description: 'The number of slots this sequencer has missed to fill',
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public start() {
|
|
140
|
+
this.meter.addBatchObservableCallback(this.observe, [this.rewards]);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public stop() {
|
|
144
|
+
this.meter.removeBatchObservableCallback(this.observe, [this.rewards]);
|
|
92
145
|
}
|
|
93
146
|
|
|
147
|
+
private observe = async (observer: BatchObservableResult): Promise<void> => {
|
|
148
|
+
let rewards = 0n;
|
|
149
|
+
rewards = await this.rollup.getSequencerRewards(this.coinbase);
|
|
150
|
+
|
|
151
|
+
const fmt = parseFloat(formatUnits(rewards, 18));
|
|
152
|
+
observer.observe(this.rewards, fmt, {
|
|
153
|
+
[Attributes.COINBASE]: this.coinbase.toString(),
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
|
|
94
157
|
startCollectingAttestationsTimer(): () => void {
|
|
95
158
|
const startTime = Date.now();
|
|
96
159
|
const stop = () => {
|
|
@@ -140,6 +203,34 @@ export class SequencerMetrics {
|
|
|
140
203
|
});
|
|
141
204
|
}
|
|
142
205
|
|
|
206
|
+
observeSlotChange(slot: bigint | undefined, proposer: string) {
|
|
207
|
+
// sequencer went through the loop a second time. Noop
|
|
208
|
+
if (slot === this.lastSeenSlot) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (typeof this.lastSeenSlot === 'bigint') {
|
|
213
|
+
this.missedSlots.add(1, {
|
|
214
|
+
[Attributes.BLOCK_PROPOSER]: proposer,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (typeof slot === 'bigint') {
|
|
219
|
+
this.slots.add(1, {
|
|
220
|
+
[Attributes.BLOCK_PROPOSER]: proposer,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
this.lastSeenSlot = slot;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
incFilledSlot(proposer: string) {
|
|
228
|
+
this.filledSlots.add(1, {
|
|
229
|
+
[Attributes.BLOCK_PROPOSER]: proposer,
|
|
230
|
+
});
|
|
231
|
+
this.lastSeenSlot = undefined;
|
|
232
|
+
}
|
|
233
|
+
|
|
143
234
|
private setCurrentBlock(blockNumber: number, txCount: number) {
|
|
144
235
|
this.currentBlockNumber.record(blockNumber);
|
|
145
236
|
this.currentBlockSize.record(txCount);
|
|
@@ -105,7 +105,13 @@ export class Sequencer {
|
|
|
105
105
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
106
106
|
protected log = createLogger('sequencer'),
|
|
107
107
|
) {
|
|
108
|
-
this.metrics = new SequencerMetrics(
|
|
108
|
+
this.metrics = new SequencerMetrics(
|
|
109
|
+
telemetry,
|
|
110
|
+
() => this.state,
|
|
111
|
+
this._coinbase,
|
|
112
|
+
this.publisher.getRollupContract(),
|
|
113
|
+
'Sequencer',
|
|
114
|
+
);
|
|
109
115
|
this.l1Metrics = new L1Metrics(telemetry.getMeter('SequencerL1Metrics'), publisher.l1TxUtils.publicClient, [
|
|
110
116
|
publisher.getSenderAddress(),
|
|
111
117
|
]);
|
|
@@ -197,6 +203,7 @@ export class Sequencer {
|
|
|
197
203
|
*/
|
|
198
204
|
public async start() {
|
|
199
205
|
await this.updateConfig(this.config);
|
|
206
|
+
this.metrics.start();
|
|
200
207
|
this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.pollingIntervalMs);
|
|
201
208
|
this.setState(SequencerState.IDLE, 0n, true /** force */);
|
|
202
209
|
this.runningPromise.start();
|
|
@@ -209,6 +216,7 @@ export class Sequencer {
|
|
|
209
216
|
*/
|
|
210
217
|
public async stop(): Promise<void> {
|
|
211
218
|
this.log.debug(`Stopping sequencer`);
|
|
219
|
+
this.metrics.stop();
|
|
212
220
|
await this.validatorClient?.stop();
|
|
213
221
|
await this.runningPromise?.stop();
|
|
214
222
|
this.slasherClient.stop();
|
|
@@ -266,6 +274,7 @@ export class Sequencer {
|
|
|
266
274
|
const chainTipArchive = chainTip.archive;
|
|
267
275
|
|
|
268
276
|
const slot = await this.slotForProposal(chainTipArchive.toBuffer(), BigInt(newBlockNumber));
|
|
277
|
+
this.metrics.observeSlotChange(slot, this.publisher.getSenderAddress().toString());
|
|
269
278
|
if (!slot) {
|
|
270
279
|
this.log.debug(`Cannot propose block ${newBlockNumber}`);
|
|
271
280
|
return;
|
|
@@ -333,7 +342,13 @@ export class Sequencer {
|
|
|
333
342
|
this.log.error(`Error enqueuing slashing vote`, err, { blockNumber: newBlockNumber, slot });
|
|
334
343
|
});
|
|
335
344
|
|
|
336
|
-
await this.publisher.sendRequests();
|
|
345
|
+
const resp = await this.publisher.sendRequests();
|
|
346
|
+
if (resp) {
|
|
347
|
+
const proposedBlock = resp.validActions.find(a => a === 'propose');
|
|
348
|
+
if (proposedBlock) {
|
|
349
|
+
this.metrics.incFilledSlot(this.publisher.getSenderAddress().toString());
|
|
350
|
+
}
|
|
351
|
+
}
|
|
337
352
|
|
|
338
353
|
if (finishedFlushing) {
|
|
339
354
|
this.isFlushing = false;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
2
3
|
import {
|
|
3
4
|
AggregateTxValidator,
|
|
4
5
|
ArchiveCache,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
PhasesTxValidator,
|
|
11
12
|
TxProofValidator,
|
|
12
13
|
} from '@aztec/p2p';
|
|
13
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
14
|
+
import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
14
15
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
15
16
|
import type { GasFees } from '@aztec/stdlib/gas';
|
|
16
17
|
import type {
|
|
@@ -45,7 +46,13 @@ export function createValidatorForAcceptingTxs(
|
|
|
45
46
|
): TxValidator<Tx> {
|
|
46
47
|
const validators: TxValidator<Tx>[] = [
|
|
47
48
|
new DataTxValidator(),
|
|
48
|
-
new MetadataTxValidator(
|
|
49
|
+
new MetadataTxValidator({
|
|
50
|
+
l1ChainId: new Fr(l1ChainId),
|
|
51
|
+
rollupVersion: new Fr(rollupVersion),
|
|
52
|
+
blockNumber: new Fr(blockNumber),
|
|
53
|
+
protocolContractTreeRoot,
|
|
54
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
55
|
+
}),
|
|
49
56
|
new DoubleSpendTxValidator(new NullifierCache(db)),
|
|
50
57
|
new PhasesTxValidator(contractDataSource, setupAllowList, blockNumber),
|
|
51
58
|
new BlockHeaderTxValidator(new ArchiveCache(db)),
|
|
@@ -98,7 +105,13 @@ function preprocessValidator(
|
|
|
98
105
|
): TxValidator<Tx> {
|
|
99
106
|
// We don't include the TxProofValidator nor the DataTxValidator here because they are already checked by the time we get to block building.
|
|
100
107
|
return new AggregateTxValidator(
|
|
101
|
-
new MetadataTxValidator(
|
|
108
|
+
new MetadataTxValidator({
|
|
109
|
+
l1ChainId: globalVariables.chainId,
|
|
110
|
+
rollupVersion: globalVariables.version,
|
|
111
|
+
blockNumber: globalVariables.blockNumber,
|
|
112
|
+
protocolContractTreeRoot,
|
|
113
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
114
|
+
}),
|
|
102
115
|
new DoubleSpendTxValidator(nullifierCache),
|
|
103
116
|
new PhasesTxValidator(contractDataSource, setupAllowList, globalVariables.blockNumber.toNumber()),
|
|
104
117
|
new GasTxValidator(publicStateSource, ProtocolContractAddress.FeeJuice, globalVariables.gasFees),
|