@aztec/sequencer-client 2.0.3-rc.2 → 2.0.3-rc.21
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.map +1 -1
- package/dest/client/sequencer-client.js +5 -4
- package/dest/config.d.ts +2 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +2 -0
- package/dest/publisher/config.d.ts +5 -3
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +13 -5
- package/dest/publisher/index.d.ts +1 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/index.js +1 -1
- package/dest/publisher/sequencer-publisher-factory.d.ts +5 -1
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +8 -1
- package/dest/publisher/sequencer-publisher.d.ts +13 -15
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +51 -52
- package/dest/sequencer/metrics.d.ts +5 -17
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +22 -88
- package/dest/sequencer/sequencer.d.ts +4 -3
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +16 -17
- package/package.json +27 -26
- package/src/client/sequencer-client.ts +4 -2
- package/src/config.ts +3 -0
- package/src/publisher/config.ts +23 -5
- package/src/publisher/index.ts +1 -1
- package/src/publisher/sequencer-publisher-factory.ts +12 -2
- package/src/publisher/sequencer-publisher.ts +71 -66
- package/src/sequencer/metrics.ts +24 -100
- package/src/sequencer/sequencer.ts +42 -38
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { L2Block } from '@aztec/aztec.js';
|
|
2
|
-
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
|
+
import { BLOBS_PER_BLOCK, FIELDS_PER_BLOB, INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
3
3
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
4
4
|
import { FormattedViemError, NoCommitteeError, type RollupContract } from '@aztec/ethereum';
|
|
5
5
|
import { omit, pick } from '@aztec/foundation/collection';
|
|
6
6
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
7
8
|
import { Fr } from '@aztec/foundation/fields';
|
|
8
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
9
10
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
@@ -11,7 +12,12 @@ import { type DateProvider, Timer } from '@aztec/foundation/timer';
|
|
|
11
12
|
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
12
13
|
import type { P2P } from '@aztec/p2p';
|
|
13
14
|
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
14
|
-
import
|
|
15
|
+
import {
|
|
16
|
+
type CommitteeAttestation,
|
|
17
|
+
CommitteeAttestationsAndSigners,
|
|
18
|
+
type L2BlockSource,
|
|
19
|
+
type ValidateBlockResult,
|
|
20
|
+
} from '@aztec/stdlib/block';
|
|
15
21
|
import { type L1RollupConstants, getSlotAtTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
16
22
|
import { Gas } from '@aztec/stdlib/gas';
|
|
17
23
|
import {
|
|
@@ -21,19 +27,11 @@ import {
|
|
|
21
27
|
type WorldStateSynchronizer,
|
|
22
28
|
} from '@aztec/stdlib/interfaces/server';
|
|
23
29
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
24
|
-
import type
|
|
25
|
-
import { orderAttestations } from '@aztec/stdlib/p2p';
|
|
30
|
+
import { type BlockProposalOptions, orderAttestations } from '@aztec/stdlib/p2p';
|
|
26
31
|
import { pickFromSchema } from '@aztec/stdlib/schemas';
|
|
27
32
|
import type { L2BlockBuiltStats } from '@aztec/stdlib/stats';
|
|
28
33
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
29
|
-
import {
|
|
30
|
-
ContentCommitment,
|
|
31
|
-
type FailedTx,
|
|
32
|
-
GlobalVariables,
|
|
33
|
-
ProposedBlockHeader,
|
|
34
|
-
Tx,
|
|
35
|
-
type TxHash,
|
|
36
|
-
} from '@aztec/stdlib/tx';
|
|
34
|
+
import { ContentCommitment, type FailedTx, GlobalVariables, ProposedBlockHeader, Tx } from '@aztec/stdlib/tx';
|
|
37
35
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
38
36
|
import { Attributes, type TelemetryClient, type Tracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
39
37
|
import type { ValidatorClient } from '@aztec/validator-client';
|
|
@@ -127,15 +125,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
127
125
|
) {
|
|
128
126
|
super();
|
|
129
127
|
|
|
130
|
-
|
|
131
|
-
const validatorAddresses = this.validatorClient?.getValidatorAddresses() ?? [];
|
|
132
|
-
const coinbase =
|
|
133
|
-
validatorAddresses.length === 0
|
|
134
|
-
? EthAddress.ZERO
|
|
135
|
-
: (this.validatorClient?.getCoinbaseForAttestor(validatorAddresses[0]) ?? EthAddress.ZERO);
|
|
136
|
-
|
|
137
|
-
this.metrics = new SequencerMetrics(telemetry, () => this.state, coinbase, this.rollupContract, 'Sequencer');
|
|
138
|
-
|
|
128
|
+
this.metrics = new SequencerMetrics(telemetry, this.rollupContract, 'Sequencer');
|
|
139
129
|
// Initialize config
|
|
140
130
|
this.updateConfig(this.config);
|
|
141
131
|
}
|
|
@@ -220,7 +210,6 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
220
210
|
* Starts the sequencer and moves to IDLE state.
|
|
221
211
|
*/
|
|
222
212
|
public start() {
|
|
223
|
-
this.metrics.start();
|
|
224
213
|
this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.pollingIntervalMs);
|
|
225
214
|
this.setState(SequencerState.IDLE, undefined, { force: true });
|
|
226
215
|
this.runningPromise.start();
|
|
@@ -232,7 +221,6 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
232
221
|
*/
|
|
233
222
|
public async stop(): Promise<void> {
|
|
234
223
|
this.log.info(`Stopping sequencer`);
|
|
235
|
-
this.metrics.stop();
|
|
236
224
|
this.publisher?.interrupt();
|
|
237
225
|
await this.validatorClient?.stop();
|
|
238
226
|
await this.runningPromise?.stop();
|
|
@@ -361,8 +349,6 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
361
349
|
const coinbase = this.validatorClient!.getCoinbaseForAttestor(attestorAddress);
|
|
362
350
|
const feeRecipient = this.validatorClient!.getFeeRecipientForAttestor(attestorAddress);
|
|
363
351
|
|
|
364
|
-
this.metrics.setCoinbase(coinbase);
|
|
365
|
-
|
|
366
352
|
// Prepare invalidation request if the pending chain is invalid (returns undefined if no need)
|
|
367
353
|
const invalidateBlock = await publisher.simulateInvalidateBlock(syncedTo.pendingChainValidationStatus);
|
|
368
354
|
const canProposeCheck = await publisher.canProposeAtNextEthBlock(
|
|
@@ -435,6 +421,8 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
435
421
|
}
|
|
436
422
|
|
|
437
423
|
this.setState(SequencerState.INITIALIZING_PROPOSAL, slot);
|
|
424
|
+
|
|
425
|
+
this.metrics.incOpenSlot(slot, proposerAddressInNextSlot.toString());
|
|
438
426
|
this.log.verbose(`Preparing proposal for block ${newBlockNumber} at slot ${slot}`, {
|
|
439
427
|
proposer: proposerInNextSlot?.toString(),
|
|
440
428
|
coinbase,
|
|
@@ -494,7 +482,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
494
482
|
if (proposedBlock) {
|
|
495
483
|
this.lastBlockPublished = block;
|
|
496
484
|
this.emit('block-published', { blockNumber: newBlockNumber, slot: Number(slot) });
|
|
497
|
-
this.metrics.incFilledSlot(publisher.getSenderAddress().toString());
|
|
485
|
+
await this.metrics.incFilledSlot(publisher.getSenderAddress().toString(), coinbase);
|
|
498
486
|
} else if (block) {
|
|
499
487
|
this.emit('block-publish-failed', l1Response ?? {});
|
|
500
488
|
}
|
|
@@ -584,6 +572,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
584
572
|
maxTransactions: this.maxTxsPerBlock,
|
|
585
573
|
maxBlockSize: this.maxBlockSizeInBytes,
|
|
586
574
|
maxBlockGas: this.maxBlockGas,
|
|
575
|
+
maxBlobFields: BLOBS_PER_BLOCK * FIELDS_PER_BLOB,
|
|
587
576
|
deadline,
|
|
588
577
|
};
|
|
589
578
|
}
|
|
@@ -616,7 +605,6 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
616
605
|
const slot = proposalHeader.slotNumber.toBigInt();
|
|
617
606
|
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(blockNumber);
|
|
618
607
|
|
|
619
|
-
// this.metrics.recordNewBlock(blockNumber, validTxs.length);
|
|
620
608
|
const workTimer = new Timer();
|
|
621
609
|
this.setState(SequencerState.CREATING_BLOCK, slot);
|
|
622
610
|
|
|
@@ -675,7 +663,18 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
675
663
|
this.log.verbose(`Collected ${attestations.length} attestations`, { blockHash, blockNumber });
|
|
676
664
|
}
|
|
677
665
|
|
|
678
|
-
|
|
666
|
+
const attestationsAndSigners = new CommitteeAttestationsAndSigners(attestations ?? []);
|
|
667
|
+
const attestationsAndSignersSignature = this.validatorClient
|
|
668
|
+
? await this.validatorClient.signAttestationsAndSigners(attestationsAndSigners, proposerAddress)
|
|
669
|
+
: Signature.empty();
|
|
670
|
+
|
|
671
|
+
await this.enqueuePublishL2Block(
|
|
672
|
+
block,
|
|
673
|
+
attestationsAndSigners,
|
|
674
|
+
attestationsAndSignersSignature,
|
|
675
|
+
invalidateBlock,
|
|
676
|
+
publisher,
|
|
677
|
+
);
|
|
679
678
|
this.metrics.recordBuiltBlock(blockBuildDuration, publicGas.l2Gas);
|
|
680
679
|
return block;
|
|
681
680
|
} catch (err) {
|
|
@@ -751,7 +750,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
751
750
|
this.metrics.recordRequiredAttestations(numberOfRequiredAttestations, attestationTimeAllowed);
|
|
752
751
|
|
|
753
752
|
const timer = new Timer();
|
|
754
|
-
let
|
|
753
|
+
let collectedAttestationsCount: number = 0;
|
|
755
754
|
try {
|
|
756
755
|
const attestationDeadline = new Date(this.dateProvider.now() + attestationTimeAllowed * 1000);
|
|
757
756
|
const attestations = await this.validatorClient.collectAttestations(
|
|
@@ -760,17 +759,17 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
760
759
|
attestationDeadline,
|
|
761
760
|
);
|
|
762
761
|
|
|
763
|
-
|
|
762
|
+
collectedAttestationsCount = attestations.length;
|
|
764
763
|
|
|
765
764
|
// note: the smart contract requires that the signatures are provided in the order of the committee
|
|
766
765
|
return orderAttestations(attestations, committee);
|
|
767
766
|
} catch (err) {
|
|
768
767
|
if (err && err instanceof AttestationTimeoutError) {
|
|
769
|
-
|
|
768
|
+
collectedAttestationsCount = err.collectedCount;
|
|
770
769
|
}
|
|
771
770
|
throw err;
|
|
772
771
|
} finally {
|
|
773
|
-
this.metrics.recordCollectedAttestations(
|
|
772
|
+
this.metrics.recordCollectedAttestations(collectedAttestationsCount, timer.ms());
|
|
774
773
|
}
|
|
775
774
|
}
|
|
776
775
|
|
|
@@ -783,8 +782,8 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
783
782
|
}))
|
|
784
783
|
protected async enqueuePublishL2Block(
|
|
785
784
|
block: L2Block,
|
|
786
|
-
|
|
787
|
-
|
|
785
|
+
attestationsAndSigners: CommitteeAttestationsAndSigners,
|
|
786
|
+
attestationsAndSignersSignature: Signature,
|
|
788
787
|
invalidateBlock: InvalidateBlockRequest | undefined,
|
|
789
788
|
publisher: SequencerPublisher,
|
|
790
789
|
): Promise<void> {
|
|
@@ -795,10 +794,15 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
795
794
|
const slot = block.header.globalVariables.slotNumber.toNumber();
|
|
796
795
|
const txTimeoutAt = new Date((this.getSlotStartBuildTimestamp(slot) + this.aztecSlotDuration) * 1000);
|
|
797
796
|
|
|
798
|
-
const enqueued = await publisher.enqueueProposeL2Block(
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
797
|
+
const enqueued = await publisher.enqueueProposeL2Block(
|
|
798
|
+
block,
|
|
799
|
+
attestationsAndSigners,
|
|
800
|
+
attestationsAndSignersSignature,
|
|
801
|
+
{
|
|
802
|
+
txTimeoutAt,
|
|
803
|
+
forcePendingBlockNumber: invalidateBlock?.forcePendingBlockNumber,
|
|
804
|
+
},
|
|
805
|
+
);
|
|
802
806
|
|
|
803
807
|
if (!enqueued) {
|
|
804
808
|
throw new Error(`Failed to enqueue publish of block ${block.number}`);
|