@aztec/sequencer-client 3.0.0-nightly.20251127 → 3.0.0-nightly.20251201.2
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 +1 -1
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/config.d.ts +1 -1
- package/dest/global_variable_builder/global_builder.d.ts +3 -6
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +8 -5
- package/dest/global_variable_builder/index.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/publisher/config.d.ts +1 -1
- package/dest/publisher/index.d.ts +1 -1
- package/dest/publisher/sequencer-publisher-factory.d.ts +1 -1
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.d.ts +17 -22
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +9 -11
- package/dest/sequencer/block_builder.d.ts +1 -1
- package/dest/sequencer/block_builder.d.ts.map +1 -1
- package/dest/sequencer/block_builder.js +1 -1
- package/dest/sequencer/config.d.ts +1 -1
- package/dest/sequencer/errors.d.ts +1 -1
- package/dest/sequencer/errors.d.ts.map +1 -1
- package/dest/sequencer/index.d.ts +1 -1
- package/dest/sequencer/metrics.d.ts +3 -2
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/sequencer.d.ts +11 -23
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +6 -6
- package/dest/sequencer/timetable.d.ts +1 -1
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/utils.d.ts +1 -1
- package/dest/test/index.d.ts +1 -1
- 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 +2 -2
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/package.json +30 -29
- package/src/global_variable_builder/global_builder.ts +11 -7
- package/src/publisher/sequencer-publisher-factory.ts +2 -1
- package/src/publisher/sequencer-publisher.ts +17 -24
- package/src/sequencer/block_builder.ts +1 -1
- package/src/sequencer/metrics.ts +3 -2
- package/src/sequencer/sequencer.ts +21 -21
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
type TransactionStats,
|
|
19
19
|
type ViemCommitteeAttestations,
|
|
20
20
|
type ViemHeader,
|
|
21
|
-
type ViemStateReference,
|
|
22
21
|
WEI_CONST,
|
|
23
22
|
formatViemError,
|
|
24
23
|
tryExtractEvent,
|
|
@@ -26,6 +25,7 @@ import {
|
|
|
26
25
|
import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
27
26
|
import { sumBigint } from '@aztec/foundation/bigint';
|
|
28
27
|
import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
|
|
28
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
29
29
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
30
30
|
import { Signature, type ViemSignature } from '@aztec/foundation/eth-signature';
|
|
31
31
|
import type { Fr } from '@aztec/foundation/fields';
|
|
@@ -38,7 +38,6 @@ import { CommitteeAttestation, CommitteeAttestationsAndSigners, type ValidateBlo
|
|
|
38
38
|
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
39
39
|
import type { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
40
40
|
import type { L1PublishBlockStats } from '@aztec/stdlib/stats';
|
|
41
|
-
import { StateReference } from '@aztec/stdlib/tx';
|
|
42
41
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
43
42
|
|
|
44
43
|
import { type StateOverride, type TransactionReceipt, type TypedDataDefinition, encodeFunctionData, toHex } from 'viem';
|
|
@@ -52,8 +51,6 @@ type L1ProcessArgs = {
|
|
|
52
51
|
header: CheckpointHeader;
|
|
53
52
|
/** A root of the archive tree after the L2 block is applied. */
|
|
54
53
|
archive: Buffer;
|
|
55
|
-
/** State reference after the L2 block is applied. */
|
|
56
|
-
stateReference: StateReference;
|
|
57
54
|
/** L2 block blobs containing all tx effects. */
|
|
58
55
|
blobs: Blob[];
|
|
59
56
|
/** Attestations */
|
|
@@ -92,7 +89,7 @@ export type InvalidateBlockRequest = {
|
|
|
92
89
|
interface RequestWithExpiry {
|
|
93
90
|
action: Action;
|
|
94
91
|
request: L1TxRequest;
|
|
95
|
-
lastValidL2Slot:
|
|
92
|
+
lastValidL2Slot: SlotNumber;
|
|
96
93
|
gasConfig?: Pick<L1TxConfig, 'txTimeoutAt' | 'gasLimit'>;
|
|
97
94
|
blobConfig?: L1BlobInputs;
|
|
98
95
|
checkSuccess: (
|
|
@@ -109,7 +106,7 @@ export class SequencerPublisher {
|
|
|
109
106
|
protected governanceLog = createLogger('sequencer:publisher:governance');
|
|
110
107
|
protected slashingLog = createLogger('sequencer:publisher:slashing');
|
|
111
108
|
|
|
112
|
-
protected lastActions: Partial<Record<Action,
|
|
109
|
+
protected lastActions: Partial<Record<Action, SlotNumber>> = {};
|
|
113
110
|
|
|
114
111
|
protected log: Logger;
|
|
115
112
|
protected ethereumSlotDuration: bigint;
|
|
@@ -150,7 +147,7 @@ export class SequencerPublisher {
|
|
|
150
147
|
epochCache: EpochCache;
|
|
151
148
|
dateProvider: DateProvider;
|
|
152
149
|
metrics: SequencerPublisherMetrics;
|
|
153
|
-
lastActions: Partial<Record<Action,
|
|
150
|
+
lastActions: Partial<Record<Action, SlotNumber>>;
|
|
154
151
|
log?: Logger;
|
|
155
152
|
},
|
|
156
153
|
) {
|
|
@@ -199,7 +196,7 @@ export class SequencerPublisher {
|
|
|
199
196
|
this.requests.push(request);
|
|
200
197
|
}
|
|
201
198
|
|
|
202
|
-
public getCurrentL2Slot():
|
|
199
|
+
public getCurrentL2Slot(): SlotNumber {
|
|
203
200
|
return this.epochCache.getEpochAndSlotNow().slot;
|
|
204
201
|
}
|
|
205
202
|
|
|
@@ -344,7 +341,7 @@ export class SequencerPublisher {
|
|
|
344
341
|
const ignoredErrors = ['SlotAlreadyInChain', 'InvalidProposer', 'InvalidArchive'];
|
|
345
342
|
|
|
346
343
|
return this.rollupContract
|
|
347
|
-
.canProposeAtNextEthBlock(tipArchive.toBuffer(), msgSender.toString(), this.ethereumSlotDuration, {
|
|
344
|
+
.canProposeAtNextEthBlock(tipArchive.toBuffer(), msgSender.toString(), Number(this.ethereumSlotDuration), {
|
|
348
345
|
forcePendingCheckpointNumber: opts.forcePendingBlockNumber,
|
|
349
346
|
})
|
|
350
347
|
.catch(err => {
|
|
@@ -521,10 +518,10 @@ export class SequencerPublisher {
|
|
|
521
518
|
// so that the committee is recalculated correctly
|
|
522
519
|
const ignoreSignatures = attestationsAndSigners.attestations.length === 0;
|
|
523
520
|
if (ignoreSignatures) {
|
|
524
|
-
const { committee } = await this.epochCache.getCommittee(block.header.globalVariables.slotNumber
|
|
521
|
+
const { committee } = await this.epochCache.getCommittee(block.header.globalVariables.slotNumber);
|
|
525
522
|
if (!committee) {
|
|
526
|
-
this.log.warn(`No committee found for slot ${block.header.globalVariables.slotNumber
|
|
527
|
-
throw new Error(`No committee found for slot ${block.header.globalVariables.slotNumber
|
|
523
|
+
this.log.warn(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
|
|
524
|
+
throw new Error(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
|
|
528
525
|
}
|
|
529
526
|
attestationsAndSigners.attestations = committee.map(committeeMember =>
|
|
530
527
|
CommitteeAttestation.fromAddress(committeeMember),
|
|
@@ -539,7 +536,6 @@ export class SequencerPublisher {
|
|
|
539
536
|
{
|
|
540
537
|
header: block.getCheckpointHeader().toViem(),
|
|
541
538
|
archive: toHex(block.archive.root.toBuffer()),
|
|
542
|
-
stateReference: block.header.state.toViem(),
|
|
543
539
|
oracleInput: {
|
|
544
540
|
feeAssetPriceModifier: 0n,
|
|
545
541
|
},
|
|
@@ -555,7 +551,7 @@ export class SequencerPublisher {
|
|
|
555
551
|
}
|
|
556
552
|
|
|
557
553
|
private async enqueueCastSignalHelper(
|
|
558
|
-
slotNumber:
|
|
554
|
+
slotNumber: SlotNumber,
|
|
559
555
|
timestamp: bigint,
|
|
560
556
|
signalType: GovernanceSignalAction,
|
|
561
557
|
payload: EthAddress,
|
|
@@ -648,7 +644,7 @@ export class SequencerPublisher {
|
|
|
648
644
|
*/
|
|
649
645
|
public enqueueGovernanceCastSignal(
|
|
650
646
|
governancePayload: EthAddress,
|
|
651
|
-
slotNumber:
|
|
647
|
+
slotNumber: SlotNumber,
|
|
652
648
|
timestamp: bigint,
|
|
653
649
|
signerAddress: EthAddress,
|
|
654
650
|
signer: (msg: TypedDataDefinition) => Promise<`0x${string}`>,
|
|
@@ -667,7 +663,7 @@ export class SequencerPublisher {
|
|
|
667
663
|
/** Enqueues all slashing actions as returned by the slasher client. */
|
|
668
664
|
public async enqueueSlashingActions(
|
|
669
665
|
actions: ProposerSlashAction[],
|
|
670
|
-
slotNumber:
|
|
666
|
+
slotNumber: SlotNumber,
|
|
671
667
|
timestamp: bigint,
|
|
672
668
|
signerAddress: EthAddress,
|
|
673
669
|
signer: (msg: TypedDataDefinition) => Promise<`0x${string}`>,
|
|
@@ -807,7 +803,6 @@ export class SequencerPublisher {
|
|
|
807
803
|
const proposeTxArgs = {
|
|
808
804
|
header: checkpointHeader,
|
|
809
805
|
archive: block.archive.root.toBuffer(),
|
|
810
|
-
stateReference: block.header.state,
|
|
811
806
|
body: block.body.toBuffer(),
|
|
812
807
|
blobs,
|
|
813
808
|
attestationsAndSigners,
|
|
@@ -826,7 +821,7 @@ export class SequencerPublisher {
|
|
|
826
821
|
} catch (err: any) {
|
|
827
822
|
this.log.error(`Block validation failed. ${err instanceof Error ? err.message : 'No error message'}`, err, {
|
|
828
823
|
...block.getStats(),
|
|
829
|
-
slotNumber: block.header.globalVariables.slotNumber
|
|
824
|
+
slotNumber: block.header.globalVariables.slotNumber,
|
|
830
825
|
forcePendingBlockNumber: opts.forcePendingBlockNumber,
|
|
831
826
|
});
|
|
832
827
|
throw err;
|
|
@@ -852,7 +847,7 @@ export class SequencerPublisher {
|
|
|
852
847
|
action: `invalidate-by-${request.reason}`,
|
|
853
848
|
request: request.request,
|
|
854
849
|
gasConfig: { gasLimit, txTimeoutAt: opts.txTimeoutAt },
|
|
855
|
-
lastValidL2Slot: this.getCurrentL2Slot() +
|
|
850
|
+
lastValidL2Slot: SlotNumber(this.getCurrentL2Slot() + 2),
|
|
856
851
|
checkSuccess: (_req, result) => {
|
|
857
852
|
const success =
|
|
858
853
|
result &&
|
|
@@ -873,7 +868,7 @@ export class SequencerPublisher {
|
|
|
873
868
|
action: Action,
|
|
874
869
|
request: L1TxRequest,
|
|
875
870
|
checkSuccess: (receipt: TransactionReceipt) => boolean | undefined,
|
|
876
|
-
slotNumber:
|
|
871
|
+
slotNumber: SlotNumber,
|
|
877
872
|
timestamp: bigint,
|
|
878
873
|
) {
|
|
879
874
|
const logData = { slotNumber, timestamp, gasLimit: undefined as bigint | undefined };
|
|
@@ -985,7 +980,6 @@ export class SequencerPublisher {
|
|
|
985
980
|
{
|
|
986
981
|
header: encodedData.header.toViem(),
|
|
987
982
|
archive: toHex(encodedData.archive),
|
|
988
|
-
stateReference: encodedData.stateReference.toViem(),
|
|
989
983
|
oracleInput: {
|
|
990
984
|
// We are currently not modifying these. See #9963
|
|
991
985
|
feeAssetPriceModifier: 0n,
|
|
@@ -1013,7 +1007,6 @@ export class SequencerPublisher {
|
|
|
1013
1007
|
{
|
|
1014
1008
|
readonly header: ViemHeader;
|
|
1015
1009
|
readonly archive: `0x${string}`;
|
|
1016
|
-
readonly stateReference: ViemStateReference;
|
|
1017
1010
|
readonly oracleInput: {
|
|
1018
1011
|
readonly feeAssetPriceModifier: 0n;
|
|
1019
1012
|
};
|
|
@@ -1128,7 +1121,7 @@ export class SequencerPublisher {
|
|
|
1128
1121
|
to: this.rollupContract.address,
|
|
1129
1122
|
data: rollupData,
|
|
1130
1123
|
},
|
|
1131
|
-
lastValidL2Slot: block.header.globalVariables.slotNumber
|
|
1124
|
+
lastValidL2Slot: block.header.globalVariables.slotNumber,
|
|
1132
1125
|
gasConfig: { ...opts, gasLimit },
|
|
1133
1126
|
blobConfig: {
|
|
1134
1127
|
blobs: encodedData.blobs.map(b => b.data),
|
|
@@ -1171,7 +1164,7 @@ export class SequencerPublisher {
|
|
|
1171
1164
|
...block.getStats(),
|
|
1172
1165
|
receipt,
|
|
1173
1166
|
txHash: receipt.transactionHash,
|
|
1174
|
-
slotNumber: block.header.globalVariables.slotNumber
|
|
1167
|
+
slotNumber: block.header.globalVariables.slotNumber,
|
|
1175
1168
|
});
|
|
1176
1169
|
return false;
|
|
1177
1170
|
}
|
|
@@ -47,7 +47,7 @@ export async function buildBlock(
|
|
|
47
47
|
): Promise<BuildBlockResult> {
|
|
48
48
|
const blockBuildingTimer = new Timer();
|
|
49
49
|
const blockNumber = newGlobalVariables.blockNumber;
|
|
50
|
-
const slot = newGlobalVariables.slotNumber
|
|
50
|
+
const slot = newGlobalVariables.slotNumber;
|
|
51
51
|
const msgCount = l1ToL2Messages.length;
|
|
52
52
|
const stateReference = await worldStateFork.getStateReference();
|
|
53
53
|
const archiveTree = await worldStateFork.getTreeInfo(MerkleTreeId.ARCHIVE);
|
package/src/sequencer/metrics.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import type { RollupContract } from '@aztec/ethereum';
|
|
3
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
4
|
import {
|
|
4
5
|
Attributes,
|
|
5
6
|
type Gauge,
|
|
@@ -41,7 +42,7 @@ export class SequencerMetrics {
|
|
|
41
42
|
private blockProposalPrecheckFailed: UpDownCounter;
|
|
42
43
|
private slashingAttempts: UpDownCounter;
|
|
43
44
|
|
|
44
|
-
private lastSeenSlot?:
|
|
45
|
+
private lastSeenSlot?: SlotNumber;
|
|
45
46
|
|
|
46
47
|
constructor(
|
|
47
48
|
client: TelemetryClient,
|
|
@@ -185,7 +186,7 @@ export class SequencerMetrics {
|
|
|
185
186
|
});
|
|
186
187
|
}
|
|
187
188
|
|
|
188
|
-
incOpenSlot(slot:
|
|
189
|
+
incOpenSlot(slot: SlotNumber, proposer: string) {
|
|
189
190
|
// sequencer went through the loop a second time. Noop
|
|
190
191
|
if (slot === this.lastSeenSlot) {
|
|
191
192
|
return;
|
|
@@ -2,6 +2,7 @@ import { L2Block } from '@aztec/aztec.js/block';
|
|
|
2
2
|
import { BLOBS_PER_CHECKPOINT, 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
|
+
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
5
6
|
import { omit, pick } from '@aztec/foundation/collection';
|
|
6
7
|
import { randomInt } from '@aztec/foundation/crypto';
|
|
7
8
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -61,7 +62,7 @@ export type SequencerEvents = {
|
|
|
61
62
|
oldState: SequencerState;
|
|
62
63
|
newState: SequencerState;
|
|
63
64
|
secondsIntoSlot?: number;
|
|
64
|
-
slotNumber?:
|
|
65
|
+
slotNumber?: SlotNumber;
|
|
65
66
|
}) => void;
|
|
66
67
|
['proposer-rollup-check-failed']: (args: { reason: string }) => void;
|
|
67
68
|
['tx-count-check-failed']: (args: { minTxs: number; availableTxs: number }) => void;
|
|
@@ -100,10 +101,10 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
100
101
|
private governanceProposerPayload: EthAddress | undefined;
|
|
101
102
|
|
|
102
103
|
/** The last slot for which we attempted to vote when sync failed, to prevent duplicate attempts. */
|
|
103
|
-
private lastSlotForVoteWhenSyncFailed:
|
|
104
|
+
private lastSlotForVoteWhenSyncFailed: SlotNumber | undefined;
|
|
104
105
|
|
|
105
106
|
/** The last slot for which we built a validation block in fisherman mode, to prevent duplicate attempts. */
|
|
106
|
-
private lastSlotForValidationBlock:
|
|
107
|
+
private lastSlotForValidationBlock: SlotNumber | undefined;
|
|
107
108
|
|
|
108
109
|
/** The maximum number of seconds that the sequencer can be into a slot to transition to a particular state. */
|
|
109
110
|
protected timetable!: SequencerTimetable;
|
|
@@ -465,7 +466,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
465
466
|
|
|
466
467
|
/** Tries building a block proposal, and if successful, enqueues it for publishing. */
|
|
467
468
|
private async tryBuildBlockAndEnqueuePublish(
|
|
468
|
-
slot:
|
|
469
|
+
slot: SlotNumber,
|
|
469
470
|
proposer: EthAddress | undefined,
|
|
470
471
|
newBlockNumber: number,
|
|
471
472
|
publisher: SequencerPublisher,
|
|
@@ -553,13 +554,13 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
553
554
|
* @param slotNumber - The current slot number.
|
|
554
555
|
* @param force - Whether to force the transition even if the sequencer is stopped.
|
|
555
556
|
*/
|
|
556
|
-
setState(proposedState: SequencerStateWithSlot, slotNumber:
|
|
557
|
+
setState(proposedState: SequencerStateWithSlot, slotNumber: SlotNumber, opts?: { force?: boolean }): void;
|
|
557
558
|
setState(
|
|
558
559
|
proposedState: Exclude<SequencerState, SequencerStateWithSlot>,
|
|
559
560
|
slotNumber?: undefined,
|
|
560
561
|
opts?: { force?: boolean },
|
|
561
562
|
): void;
|
|
562
|
-
setState(proposedState: SequencerState, slotNumber:
|
|
563
|
+
setState(proposedState: SequencerState, slotNumber: SlotNumber | undefined, opts: { force?: boolean } = {}): void {
|
|
563
564
|
if (this.state === SequencerState.STOPPING && proposedState !== SequencerState.STOPPED && !opts.force) {
|
|
564
565
|
this.log.warn(`Cannot set sequencer to ${proposedState} as it is stopping.`);
|
|
565
566
|
throw new SequencerInterruptedError();
|
|
@@ -600,7 +601,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
600
601
|
await this.p2pClient.deleteTxs(failedTxHashes);
|
|
601
602
|
}
|
|
602
603
|
|
|
603
|
-
protected getBlockBuilderOptions(slot:
|
|
604
|
+
protected getBlockBuilderOptions(slot: SlotNumber): PublicProcessorLimits {
|
|
604
605
|
// Deadline for processing depends on whether we're proposing a block
|
|
605
606
|
const secondsIntoSlot = this.getSecondsIntoSlot(slot);
|
|
606
607
|
const processingEndTimeWithinSlot = this.timetable.getBlockProposalExecTimeEnd(secondsIntoSlot);
|
|
@@ -643,14 +644,14 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
643
644
|
await publisher.validateBlockHeader(proposalHeader, invalidateBlock);
|
|
644
645
|
|
|
645
646
|
const blockNumber = newGlobalVariables.blockNumber;
|
|
646
|
-
const slot = proposalHeader.slotNumber
|
|
647
|
+
const slot = proposalHeader.slotNumber;
|
|
647
648
|
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(blockNumber);
|
|
648
649
|
|
|
649
650
|
const workTimer = new Timer();
|
|
650
651
|
this.setState(SequencerState.CREATING_BLOCK, slot);
|
|
651
652
|
|
|
652
653
|
try {
|
|
653
|
-
const blockBuilderOptions = this.getBlockBuilderOptions(
|
|
654
|
+
const blockBuilderOptions = this.getBlockBuilderOptions(slot);
|
|
654
655
|
const buildBlockRes = await this.blockBuilder.buildBlock(
|
|
655
656
|
pendingTxs,
|
|
656
657
|
l1ToL2Messages,
|
|
@@ -766,7 +767,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
766
767
|
|
|
767
768
|
const numberOfRequiredAttestations = Math.floor((committee.length * 2) / 3) + 1;
|
|
768
769
|
|
|
769
|
-
const slotNumber = block.header.globalVariables.slotNumber
|
|
770
|
+
const slotNumber = block.header.globalVariables.slotNumber;
|
|
770
771
|
this.setState(SequencerState.COLLECTING_ATTESTATIONS, slotNumber);
|
|
771
772
|
|
|
772
773
|
this.log.debug('Creating block proposal for validators');
|
|
@@ -778,7 +779,6 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
778
779
|
block.header.globalVariables.blockNumber,
|
|
779
780
|
block.getCheckpointHeader(),
|
|
780
781
|
block.archive.root,
|
|
781
|
-
block.header.state,
|
|
782
782
|
txs,
|
|
783
783
|
proposerAddress,
|
|
784
784
|
blockProposalOptions,
|
|
@@ -837,7 +837,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
837
837
|
/** Breaks the attestations before publishing based on attack configs */
|
|
838
838
|
private manipulateAttestations(
|
|
839
839
|
block: L2Block,
|
|
840
|
-
epoch:
|
|
840
|
+
epoch: EpochNumber,
|
|
841
841
|
seed: bigint,
|
|
842
842
|
committee: EthAddress[],
|
|
843
843
|
attestations: CommitteeAttestation[],
|
|
@@ -896,10 +896,10 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
896
896
|
publisher: SequencerPublisher,
|
|
897
897
|
): Promise<void> {
|
|
898
898
|
// Publishes new block to the network and awaits the tx to be mined
|
|
899
|
-
this.setState(SequencerState.PUBLISHING_BLOCK, block.header.globalVariables.slotNumber
|
|
899
|
+
this.setState(SequencerState.PUBLISHING_BLOCK, block.header.globalVariables.slotNumber);
|
|
900
900
|
|
|
901
901
|
// Time out tx at the end of the slot
|
|
902
|
-
const slot = block.header.globalVariables.slotNumber
|
|
902
|
+
const slot = block.header.globalVariables.slotNumber;
|
|
903
903
|
const txTimeoutAt = new Date((this.getSlotStartBuildTimestamp(slot) + this.aztecSlotDuration) * 1000);
|
|
904
904
|
|
|
905
905
|
const enqueued = await publisher.enqueueProposeL2Block(
|
|
@@ -921,7 +921,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
921
921
|
* Returns whether all dependencies have caught up.
|
|
922
922
|
* We don't check against the previous block submitted since it may have been reorg'd out.
|
|
923
923
|
*/
|
|
924
|
-
protected async checkSync(args: { ts: bigint; slot:
|
|
924
|
+
protected async checkSync(args: { ts: bigint; slot: SlotNumber }): Promise<
|
|
925
925
|
| {
|
|
926
926
|
block?: L2Block;
|
|
927
927
|
blockNumber: number;
|
|
@@ -1007,7 +1007,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
1007
1007
|
protected enqueueGovernanceAndSlashingVotes(
|
|
1008
1008
|
publisher: SequencerPublisher,
|
|
1009
1009
|
attestorAddress: EthAddress,
|
|
1010
|
-
slot:
|
|
1010
|
+
slot: SlotNumber,
|
|
1011
1011
|
timestamp: bigint,
|
|
1012
1012
|
): [Promise<boolean> | undefined, Promise<boolean> | undefined] {
|
|
1013
1013
|
try {
|
|
@@ -1056,7 +1056,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
1056
1056
|
* Checks if we are the proposer for the next slot.
|
|
1057
1057
|
* @returns True if we can propose, and the proposer address (undefined if anyone can propose)
|
|
1058
1058
|
*/
|
|
1059
|
-
protected async checkCanPropose(slot:
|
|
1059
|
+
protected async checkCanPropose(slot: SlotNumber): Promise<[boolean, EthAddress | undefined]> {
|
|
1060
1060
|
let proposer: EthAddress | undefined;
|
|
1061
1061
|
|
|
1062
1062
|
try {
|
|
@@ -1094,7 +1094,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
1094
1094
|
* Tries to vote on slashing actions and governance when the sync check fails but we're past the max time for initializing a proposal.
|
|
1095
1095
|
* This allows the sequencer to participate in governance/slashing votes even when it cannot build blocks.
|
|
1096
1096
|
*/
|
|
1097
|
-
protected async tryVoteWhenSyncFails(args: { slot:
|
|
1097
|
+
protected async tryVoteWhenSyncFails(args: { slot: SlotNumber; ts: bigint }): Promise<void> {
|
|
1098
1098
|
const { slot, ts } = args;
|
|
1099
1099
|
|
|
1100
1100
|
// Prevent duplicate attempts in the same slot
|
|
@@ -1161,7 +1161,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
1161
1161
|
*/
|
|
1162
1162
|
protected async considerInvalidatingBlock(
|
|
1163
1163
|
syncedTo: NonNullable<Awaited<ReturnType<Sequencer['checkSync']>>>,
|
|
1164
|
-
currentSlot:
|
|
1164
|
+
currentSlot: SlotNumber,
|
|
1165
1165
|
): Promise<void> {
|
|
1166
1166
|
const { pendingChainValidationStatus, l1Timestamp } = syncedTo;
|
|
1167
1167
|
if (pendingChainValidationStatus.valid) {
|
|
@@ -1231,11 +1231,11 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
1231
1231
|
}
|
|
1232
1232
|
}
|
|
1233
1233
|
|
|
1234
|
-
private getSlotStartBuildTimestamp(slotNumber:
|
|
1234
|
+
private getSlotStartBuildTimestamp(slotNumber: SlotNumber): number {
|
|
1235
1235
|
return getSlotStartBuildTimestamp(slotNumber, this.l1Constants);
|
|
1236
1236
|
}
|
|
1237
1237
|
|
|
1238
|
-
private getSecondsIntoSlot(slotNumber:
|
|
1238
|
+
private getSecondsIntoSlot(slotNumber: SlotNumber): number {
|
|
1239
1239
|
const slotStartTimestamp = this.getSlotStartBuildTimestamp(slotNumber);
|
|
1240
1240
|
return Number((this.dateProvider.now() / 1000 - slotStartTimestamp).toFixed(3));
|
|
1241
1241
|
}
|