@aztec/sequencer-client 0.0.1-commit.c80b6263 → 0.0.1-commit.cb6bed7c2
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 +23 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +99 -16
- package/dest/config.d.ts +24 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +40 -28
- package/dest/global_variable_builder/global_builder.d.ts +2 -4
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/publisher/config.d.ts +35 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +106 -42
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +2 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +27 -2
- package/dest/publisher/sequencer-publisher.d.ts +26 -8
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +338 -48
- package/dest/sequencer/checkpoint_proposal_job.d.ts +28 -7
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +164 -89
- package/dest/sequencer/metrics.d.ts +17 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +86 -15
- package/dest/sequencer/sequencer.d.ts +25 -12
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +30 -27
- package/dest/sequencer/timetable.d.ts +4 -6
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +7 -11
- package/dest/sequencer/types.d.ts +5 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/index.d.ts +3 -5
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +10 -10
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +45 -36
- package/dest/test/utils.d.ts +3 -3
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +5 -4
- package/package.json +28 -28
- package/src/client/sequencer-client.ts +135 -18
- package/src/config.ts +54 -38
- package/src/global_variable_builder/global_builder.ts +1 -1
- package/src/publisher/config.ts +121 -43
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-publisher-factory.ts +38 -6
- package/src/publisher/sequencer-publisher.ts +333 -60
- package/src/sequencer/checkpoint_proposal_job.ts +223 -113
- package/src/sequencer/metrics.ts +92 -18
- package/src/sequencer/sequencer.ts +40 -32
- package/src/sequencer/timetable.ts +13 -12
- package/src/sequencer/types.ts +4 -1
- package/src/test/index.ts +2 -4
- package/src/test/mock_checkpoint_builder.ts +62 -50
- package/src/test/utils.ts +5 -2
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
2
|
-
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { BlockNumber, CheckpointNumber, EpochNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { type Logger, type LoggerBindings } from '@aztec/foundation/log';
|
|
5
5
|
import { type DateProvider } from '@aztec/foundation/timer';
|
|
6
6
|
import { type TypedEventEmitter } from '@aztec/foundation/types';
|
|
7
7
|
import type { P2P } from '@aztec/p2p';
|
|
8
8
|
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
9
|
-
import { type L2BlockSink, type L2BlockSource } from '@aztec/stdlib/block';
|
|
10
|
-
import type
|
|
11
|
-
import type
|
|
9
|
+
import { L2Block, type L2BlockSink, type L2BlockSource } from '@aztec/stdlib/block';
|
|
10
|
+
import { type Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
11
|
+
import { type ResolvedSequencerConfig, type WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
12
12
|
import { type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
13
|
+
import { Tx } from '@aztec/stdlib/tx';
|
|
13
14
|
import { type Traceable, type Tracer } from '@aztec/telemetry-client';
|
|
14
|
-
import { type FullNodeCheckpointsBuilder, type ValidatorClient } from '@aztec/validator-client';
|
|
15
|
+
import { CheckpointBuilder, type FullNodeCheckpointsBuilder, type ValidatorClient } from '@aztec/validator-client';
|
|
15
16
|
import type { GlobalVariableBuilder } from '../global_variable_builder/global_builder.js';
|
|
16
17
|
import type { InvalidateCheckpointRequest, SequencerPublisher } from '../publisher/sequencer-publisher.js';
|
|
17
18
|
import type { SequencerEvents } from './events.js';
|
|
@@ -62,7 +63,21 @@ export declare class CheckpointProposalJob implements Traceable {
|
|
|
62
63
|
private proposeCheckpoint;
|
|
63
64
|
private buildBlocksForCheckpoint;
|
|
64
65
|
private waitUntilNextSubslot;
|
|
65
|
-
|
|
66
|
+
/** Builds a single block. Called from the main block building loop. */
|
|
67
|
+
protected buildSingleBlock(checkpointBuilder: CheckpointBuilder, opts: {
|
|
68
|
+
forceCreate?: boolean;
|
|
69
|
+
blockTimestamp: bigint;
|
|
70
|
+
blockNumber: BlockNumber;
|
|
71
|
+
indexWithinCheckpoint: IndexWithinCheckpoint;
|
|
72
|
+
buildDeadline: Date | undefined;
|
|
73
|
+
txHashesAlreadyIncluded: Set<string>;
|
|
74
|
+
}): Promise<{
|
|
75
|
+
block: L2Block;
|
|
76
|
+
usedTxs: Tx[];
|
|
77
|
+
} | {
|
|
78
|
+
error: Error;
|
|
79
|
+
} | undefined>;
|
|
80
|
+
private buildSingleBlockWithCheckpointBuilder;
|
|
66
81
|
private waitForMinTxs;
|
|
67
82
|
private waitForAttestations;
|
|
68
83
|
/** Breaks the attestations before publishing based on attack configs */
|
|
@@ -70,10 +85,16 @@ export declare class CheckpointProposalJob implements Traceable {
|
|
|
70
85
|
private dropFailedTxsFromP2P;
|
|
71
86
|
private syncProposedBlockToArchiver;
|
|
72
87
|
private handleCheckpointEndAsFisherman;
|
|
88
|
+
/**
|
|
89
|
+
* Helper to handle HA double-signing errors. Returns true if the error was handled (caller should yield).
|
|
90
|
+
*/
|
|
91
|
+
private handleHASigningError;
|
|
73
92
|
/** Waits until a specific time within the current slot */
|
|
74
93
|
protected waitUntilTimeInSlot(targetSecondsIntoSlot: number): Promise<void>;
|
|
94
|
+
/** Waits the polling interval for transactions. Extracted for test overriding. */
|
|
95
|
+
protected waitForTxsPollingInterval(): Promise<void>;
|
|
75
96
|
private getSlotStartBuildTimestamp;
|
|
76
97
|
private getSecondsIntoSlot;
|
|
77
98
|
getPublisher(): SequencerPublisher;
|
|
78
99
|
}
|
|
79
|
-
//# sourceMappingURL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+1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoint_proposal_job.d.ts","sourceRoot":"","sources":["../../src/sequencer/checkpoint_proposal_job.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkpoint_proposal_job.d.ts","sourceRoot":"","sources":["../../src/sequencer/checkpoint_proposal_job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,qBAAqB,EACrB,UAAU,EACX,MAAM,iCAAiC,CAAC;AAQzC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAEvF,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,KAAK,iBAAiB,EAA0B,MAAM,yBAAyB,CAAC;AACzF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAGL,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,aAAa,EAEnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,0BAA0B,CAAC;AAG/E,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,mBAAmB,EAAmC,MAAM,yBAAyB,CAAC;AAIpG,OAAO,EAAiB,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAc,KAAK,SAAS,EAAE,KAAK,MAAM,EAAa,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,KAAK,0BAA0B,EAAE,KAAK,eAAe,EAAE,MAAM,yBA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YA2HxB,oBAAoB;IAMlC,uEAAuE;IACvE,UACgB,gBAAgB,CAC9B,iBAAiB,EAAE,iBAAiB,EACpC,IAAI,EAAE;QACJ,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,WAAW,EAAE,WAAW,CAAC;QACzB,qBAAqB,EAAE,qBAAqB,CAAC;QAC7C,aAAa,EAAE,IAAI,GAAG,SAAS,CAAC;QAChC,uBAAuB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;KACtC,GACA,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,EAAE,EAAE,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,GAAG,SAAS,CAAC,CAwG3E;YAGa,qCAAqC;YAsBrC,aAAa;YA2Cb,mBAAmB;IAgFjC,wEAAwE;IACxE,OAAO,CAAC,sBAAsB;YAuEhB,oBAAoB;YAepB,2BAA2B;YAgB3B,8BAA8B;IAwB5C;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAmB5B,0DAA0D;IAC1D,UACgB,mBAAmB,CAAC,qBAAqB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIhF;IAED,kFAAkF;IAClF,UAAgB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEzD;IAED,OAAO,CAAC,0BAA0B;IAIlC,OAAO,CAAC,kBAAkB;IAKnB,YAAY,uBAElB;CACF"}
|
|
@@ -436,21 +436,21 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
436
436
|
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
437
437
|
}
|
|
438
438
|
var _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _initProto;
|
|
439
|
-
import {
|
|
440
|
-
import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB } from '@aztec/constants';
|
|
441
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
439
|
+
import { BlockNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
442
440
|
import { randomInt } from '@aztec/foundation/crypto/random';
|
|
443
|
-
import {
|
|
441
|
+
import { flipSignature, generateRecoverableSignature, generateUnrecoverableSignature } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
444
442
|
import { filter } from '@aztec/foundation/iterator';
|
|
445
443
|
import { createLogger } from '@aztec/foundation/log';
|
|
446
444
|
import { sleep, sleepUntil } from '@aztec/foundation/sleep';
|
|
447
445
|
import { Timer } from '@aztec/foundation/timer';
|
|
448
|
-
import { unfreeze } from '@aztec/foundation/types';
|
|
446
|
+
import { isErrorClass, unfreeze } from '@aztec/foundation/types';
|
|
449
447
|
import { CommitteeAttestationsAndSigners, MaliciousCommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
448
|
+
import { validateCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
450
449
|
import { getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
451
450
|
import { Gas } from '@aztec/stdlib/gas';
|
|
451
|
+
import { NoValidTxsError } from '@aztec/stdlib/interfaces/server';
|
|
452
452
|
import { computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
453
|
-
import { orderAttestations } from '@aztec/stdlib/p2p';
|
|
453
|
+
import { orderAttestations, trimAttestations } from '@aztec/stdlib/p2p';
|
|
454
454
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
455
455
|
import { Attributes, trackSpan } from '@aztec/telemetry-client';
|
|
456
456
|
import { DutyAlreadySignedError, SlashingProtectionError } from '@aztec/validator-ha-signer/errors';
|
|
@@ -589,7 +589,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
589
589
|
// Wait until the voting promises have resolved, so all requests are enqueued (not sent)
|
|
590
590
|
await Promise.all(votesPromises);
|
|
591
591
|
if (checkpoint) {
|
|
592
|
-
this.metrics.
|
|
592
|
+
this.metrics.recordCheckpointProposalSuccess();
|
|
593
593
|
}
|
|
594
594
|
// Do not post anything to L1 if we are fishermen, but do perform L1 fee analysis
|
|
595
595
|
if (this.config.fishermanMode) {
|
|
@@ -639,13 +639,14 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
639
639
|
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(this.checkpointNumber);
|
|
640
640
|
const inHash = computeInHashFromL1ToL2Messages(l1ToL2Messages);
|
|
641
641
|
// Collect the out hashes of all the checkpoints before this one in the same epoch
|
|
642
|
-
const
|
|
643
|
-
|
|
642
|
+
const previousCheckpointOutHashes = (await this.l2BlockSource.getCheckpointsDataForEpoch(this.epoch)).filter((c)=>c.checkpointNumber < this.checkpointNumber).map((c)=>c.checkpointOutHash);
|
|
643
|
+
// Get the fee asset price modifier from the oracle
|
|
644
|
+
const feeAssetPriceModifier = await this.publisher.getFeeAssetPriceModifier();
|
|
644
645
|
const fork = _ts_add_disposable_resource(env, await this.worldState.fork(this.syncedToBlockNumber, {
|
|
645
646
|
closeDelayMs: 12_000
|
|
646
|
-
}),
|
|
647
|
+
}), true);
|
|
647
648
|
// Create checkpoint builder for the entire slot
|
|
648
|
-
const checkpointBuilder = await this.checkpointsBuilder.startCheckpoint(this.checkpointNumber, checkpointGlobalVariables, l1ToL2Messages, previousCheckpointOutHashes, fork, this.log.getBindings());
|
|
649
|
+
const checkpointBuilder = await this.checkpointsBuilder.startCheckpoint(this.checkpointNumber, checkpointGlobalVariables, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, this.log.getBindings());
|
|
649
650
|
// Options for the validator client when creating block and checkpoint proposals
|
|
650
651
|
const blockProposalOptions = {
|
|
651
652
|
publishFullTxs: !!this.config.publishTxsWithProposals,
|
|
@@ -657,6 +658,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
657
658
|
};
|
|
658
659
|
let blocksInCheckpoint = [];
|
|
659
660
|
let blockPendingBroadcast = undefined;
|
|
661
|
+
const checkpointBuildTimer = new Timer();
|
|
660
662
|
try {
|
|
661
663
|
// Main loop: build blocks for the checkpoint
|
|
662
664
|
const result = await this.buildBlocksForCheckpoint(checkpointBuilder, checkpointGlobalVariables.timestamp, inHash, blockProposalOptions);
|
|
@@ -666,19 +668,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
666
668
|
// These errors are expected in HA mode, so we yield and let another HA node handle the slot
|
|
667
669
|
// The only distinction between the 2 errors is SlashingProtectionError throws when the payload is different,
|
|
668
670
|
// which is normal for block building (may have picked different txs)
|
|
669
|
-
if (err
|
|
670
|
-
this.log.info(`Checkpoint proposal for slot ${this.slot} already signed by another HA node, yielding`, {
|
|
671
|
-
slot: this.slot,
|
|
672
|
-
signedByNode: err.signedByNode
|
|
673
|
-
});
|
|
674
|
-
return undefined;
|
|
675
|
-
}
|
|
676
|
-
if (err instanceof SlashingProtectionError) {
|
|
677
|
-
this.log.info(`Checkpoint proposal for slot ${this.slot} blocked by slashing protection, yielding`, {
|
|
678
|
-
slot: this.slot,
|
|
679
|
-
existingMessageHash: err.existingMessageHash,
|
|
680
|
-
attemptedMessageHash: err.attemptedMessageHash
|
|
681
|
-
});
|
|
671
|
+
if (this.handleHASigningError(err, 'Block proposal')) {
|
|
682
672
|
return undefined;
|
|
683
673
|
}
|
|
684
674
|
throw err;
|
|
@@ -692,10 +682,36 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
692
682
|
});
|
|
693
683
|
return undefined;
|
|
694
684
|
}
|
|
685
|
+
const minBlocksForCheckpoint = this.config.minBlocksForCheckpoint;
|
|
686
|
+
if (minBlocksForCheckpoint !== undefined && blocksInCheckpoint.length < minBlocksForCheckpoint) {
|
|
687
|
+
this.log.warn(`Checkpoint has fewer blocks than minimum (${blocksInCheckpoint.length} < ${minBlocksForCheckpoint}), skipping proposal`, {
|
|
688
|
+
slot: this.slot,
|
|
689
|
+
blocksBuilt: blocksInCheckpoint.length,
|
|
690
|
+
minBlocksForCheckpoint
|
|
691
|
+
});
|
|
692
|
+
return undefined;
|
|
693
|
+
}
|
|
695
694
|
// Assemble and broadcast the checkpoint proposal, including the last block that was not
|
|
696
695
|
// broadcasted yet, and wait to collect the committee attestations.
|
|
697
696
|
this.setStateFn(SequencerState.ASSEMBLING_CHECKPOINT, this.slot);
|
|
698
697
|
const checkpoint = await checkpointBuilder.completeCheckpoint();
|
|
698
|
+
// Final validation round for the checkpoint before we propose it, just for safety
|
|
699
|
+
try {
|
|
700
|
+
validateCheckpoint(checkpoint, {
|
|
701
|
+
rollupManaLimit: this.l1Constants.rollupManaLimit,
|
|
702
|
+
maxL2BlockGas: this.config.maxL2BlockGas,
|
|
703
|
+
maxDABlockGas: this.config.maxDABlockGas,
|
|
704
|
+
maxTxsPerBlock: this.config.maxTxsPerBlock,
|
|
705
|
+
maxTxsPerCheckpoint: this.config.maxTxsPerCheckpoint
|
|
706
|
+
});
|
|
707
|
+
} catch (err) {
|
|
708
|
+
this.log.error(`Built an invalid checkpoint at slot ${this.slot} (skipping proposal)`, err, {
|
|
709
|
+
checkpoint: checkpoint.header.toInspect()
|
|
710
|
+
});
|
|
711
|
+
return undefined;
|
|
712
|
+
}
|
|
713
|
+
// Record checkpoint-level build metrics
|
|
714
|
+
this.metrics.recordCheckpointBuild(checkpointBuildTimer.ms(), blocksInCheckpoint.length, checkpoint.getStats().txCount, Number(checkpoint.header.totalManaUsed.toBigInt()));
|
|
699
715
|
// Do not collect attestations nor publish to L1 in fisherman mode
|
|
700
716
|
if (this.config.fishermanMode) {
|
|
701
717
|
this.log.info(`Built checkpoint for slot ${this.slot} with ${blocksInCheckpoint.length} blocks. ` + `Skipping proposal in fisherman mode.`, {
|
|
@@ -713,7 +729,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
713
729
|
txs: blockPendingBroadcast.txs
|
|
714
730
|
};
|
|
715
731
|
// Create the checkpoint proposal and broadcast it
|
|
716
|
-
const proposal = await this.validatorClient.createCheckpointProposal(checkpoint.header, checkpoint.archive.root, lastBlock, this.proposer, checkpointProposalOptions);
|
|
732
|
+
const proposal = await this.validatorClient.createCheckpointProposal(checkpoint.header, checkpoint.archive.root, feeAssetPriceModifier, lastBlock, this.proposer, checkpointProposalOptions);
|
|
717
733
|
const blockProposedAt = this.dateProvider.now();
|
|
718
734
|
await this.p2pClient.broadcastCheckpointProposal(proposal);
|
|
719
735
|
this.setStateFn(SequencerState.COLLECTING_ATTESTATIONS, this.slot);
|
|
@@ -727,20 +743,8 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
727
743
|
attestationsSignature = await this.validatorClient.signAttestationsAndSigners(attestations, signer, this.slot, this.checkpointNumber);
|
|
728
744
|
} catch (err) {
|
|
729
745
|
// We shouldn't really get here since we yield to another HA node
|
|
730
|
-
// as soon as we see these errors when creating block proposals.
|
|
731
|
-
if (err
|
|
732
|
-
this.log.info(`Attestations signature for slot ${this.slot} already signed by another HA node, yielding`, {
|
|
733
|
-
slot: this.slot,
|
|
734
|
-
signedByNode: err.signedByNode
|
|
735
|
-
});
|
|
736
|
-
return undefined;
|
|
737
|
-
}
|
|
738
|
-
if (err instanceof SlashingProtectionError) {
|
|
739
|
-
this.log.info(`Attestations signature for slot ${this.slot} blocked by slashing protection, yielding`, {
|
|
740
|
-
slot: this.slot,
|
|
741
|
-
existingMessageHash: err.existingMessageHash,
|
|
742
|
-
attemptedMessageHash: err.attemptedMessageHash
|
|
743
|
-
});
|
|
746
|
+
// as soon as we see these errors when creating block or checkpoint proposals.
|
|
747
|
+
if (this.handleHASigningError(err, 'Attestations signature')) {
|
|
744
748
|
return undefined;
|
|
745
749
|
}
|
|
746
750
|
throw err;
|
|
@@ -750,6 +754,14 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
750
754
|
const aztecSlotDuration = this.l1Constants.slotDuration;
|
|
751
755
|
const slotStartBuildTimestamp = this.getSlotStartBuildTimestamp();
|
|
752
756
|
const txTimeoutAt = new Date((slotStartBuildTimestamp + aztecSlotDuration) * 1000);
|
|
757
|
+
// If we have been configured to potentially skip publishing checkpoint then roll the dice here
|
|
758
|
+
if (this.config.skipPublishingCheckpointsPercent !== undefined && this.config.skipPublishingCheckpointsPercent > 0) {
|
|
759
|
+
const result = Math.max(0, randomInt(100));
|
|
760
|
+
if (result < this.config.skipPublishingCheckpointsPercent) {
|
|
761
|
+
this.log.warn(`Skipping publishing proposal for checkpoint ${checkpoint.number}. Configured percentage: ${this.config.skipPublishingCheckpointsPercent}, generated value: ${result}`);
|
|
762
|
+
return checkpoint;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
753
765
|
await this.publisher.enqueueProposeCheckpoint(checkpoint, attestations, attestationsSignature, {
|
|
754
766
|
txTimeoutAt,
|
|
755
767
|
forcePendingCheckpointNumber: this.invalidateCheckpoint?.forcePendingCheckpointNumber
|
|
@@ -759,7 +771,8 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
759
771
|
env.error = e;
|
|
760
772
|
env.hasError = true;
|
|
761
773
|
} finally{
|
|
762
|
-
_ts_dispose_resources(env);
|
|
774
|
+
const result = _ts_dispose_resources(env);
|
|
775
|
+
if (result) await result;
|
|
763
776
|
}
|
|
764
777
|
} catch (err) {
|
|
765
778
|
if (err && (err instanceof DutyAlreadySignedError || err instanceof SlashingProtectionError)) {
|
|
@@ -776,13 +789,11 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
776
789
|
const blocksInCheckpoint = [];
|
|
777
790
|
const txHashesAlreadyIncluded = new Set();
|
|
778
791
|
const initialBlockNumber = BlockNumber(this.syncedToBlockNumber + 1);
|
|
779
|
-
// Remaining blob fields available for blocks (checkpoint end marker already subtracted)
|
|
780
|
-
let remainingBlobFields = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB - NUM_CHECKPOINT_END_MARKER_FIELDS;
|
|
781
792
|
// Last block in the checkpoint will usually be flagged as pending broadcast, so we send it along with the checkpoint proposal
|
|
782
793
|
let blockPendingBroadcast = undefined;
|
|
783
794
|
while(true){
|
|
784
795
|
const blocksBuilt = blocksInCheckpoint.length;
|
|
785
|
-
const indexWithinCheckpoint = blocksBuilt;
|
|
796
|
+
const indexWithinCheckpoint = IndexWithinCheckpoint(blocksBuilt);
|
|
786
797
|
const blockNumber = BlockNumber(initialBlockNumber + blocksBuilt);
|
|
787
798
|
const secondsIntoSlot = this.getSecondsIntoSlot();
|
|
788
799
|
const timingInfo = this.timetable.canStartNextBlock(secondsIntoSlot);
|
|
@@ -803,9 +814,9 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
803
814
|
buildDeadline: timingInfo.deadline ? new Date((this.getSlotStartBuildTimestamp() + timingInfo.deadline) * 1000) : undefined,
|
|
804
815
|
blockNumber,
|
|
805
816
|
indexWithinCheckpoint,
|
|
806
|
-
txHashesAlreadyIncluded
|
|
807
|
-
remainingBlobFields
|
|
817
|
+
txHashesAlreadyIncluded
|
|
808
818
|
});
|
|
819
|
+
// TODO(palla/mbps): Review these conditions. We may want to keep trying in some scenarios.
|
|
809
820
|
if (!buildResult && timingInfo.isLastBlock) {
|
|
810
821
|
break;
|
|
811
822
|
} else if (!buildResult && timingInfo.deadline !== undefined) {
|
|
@@ -825,10 +836,8 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
825
836
|
}
|
|
826
837
|
break;
|
|
827
838
|
}
|
|
828
|
-
const { block, usedTxs
|
|
839
|
+
const { block, usedTxs } = buildResult;
|
|
829
840
|
blocksInCheckpoint.push(block);
|
|
830
|
-
// Update remaining blob fields for the next block
|
|
831
|
-
remainingBlobFields = newRemainingBlobFields;
|
|
832
841
|
// Sync the proposed block to the archiver to make it available
|
|
833
842
|
// Note that the checkpoint builder uses its own fork so it should not need to wait for this syncing
|
|
834
843
|
// Eventually we should refactor the checkpoint builder to not need a separate long-lived fork
|
|
@@ -879,7 +888,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
879
888
|
await this.waitUntilTimeInSlot(nextSubslotStart);
|
|
880
889
|
}
|
|
881
890
|
/** Builds a single block. Called from the main block building loop. */ async buildSingleBlock(checkpointBuilder, opts) {
|
|
882
|
-
const { blockTimestamp, forceCreate, blockNumber, indexWithinCheckpoint, buildDeadline, txHashesAlreadyIncluded
|
|
891
|
+
const { blockTimestamp, forceCreate, blockNumber, indexWithinCheckpoint, buildDeadline, txHashesAlreadyIncluded } = opts;
|
|
883
892
|
this.log.verbose(`Preparing block ${blockNumber} index ${indexWithinCheckpoint} at checkpoint ${this.checkpointNumber} for slot ${this.slot}`, {
|
|
884
893
|
...checkpointBuilder.getConstantData(),
|
|
885
894
|
...opts
|
|
@@ -904,58 +913,56 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
904
913
|
}
|
|
905
914
|
// Create iterator to pending txs. We filter out txs already included in previous blocks in the checkpoint
|
|
906
915
|
// just in case p2p failed to sync the provisional block and didn't get to remove those txs from the mempool yet.
|
|
907
|
-
const pendingTxs = filter(this.p2pClient.
|
|
916
|
+
const pendingTxs = filter(this.p2pClient.iterateEligiblePendingTxs(), (tx)=>!txHashesAlreadyIncluded.has(tx.txHash.toString()));
|
|
908
917
|
this.log.debug(`Building block ${blockNumber} at index ${indexWithinCheckpoint} for slot ${this.slot} with ${availableTxs} available txs`, {
|
|
909
918
|
slot: this.slot,
|
|
910
919
|
blockNumber,
|
|
911
920
|
indexWithinCheckpoint
|
|
912
921
|
});
|
|
913
922
|
this.setStateFn(SequencerState.CREATING_BLOCK, this.slot);
|
|
914
|
-
//
|
|
915
|
-
|
|
916
|
-
const maxBlobFieldsForTxs = remainingBlobFields - blockEndOverhead;
|
|
923
|
+
// Per-block limits derived at startup by computeBlockLimits(), further capped
|
|
924
|
+
// by remaining checkpoint-level budgets inside CheckpointBuilder before each block is built.
|
|
917
925
|
const blockBuilderOptions = {
|
|
918
926
|
maxTransactions: this.config.maxTxsPerBlock,
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
deadline: buildDeadline
|
|
927
|
+
maxBlockGas: this.config.maxL2BlockGas !== undefined || this.config.maxDABlockGas !== undefined ? new Gas(this.config.maxDABlockGas ?? Infinity, this.config.maxL2BlockGas ?? Infinity) : undefined,
|
|
928
|
+
deadline: buildDeadline,
|
|
929
|
+
isBuildingProposal: true
|
|
923
930
|
};
|
|
924
931
|
// Actually build the block by executing txs
|
|
925
|
-
const
|
|
926
|
-
const { publicGas, block, publicProcessorDuration, numTxs, blockBuildingTimer, usedTxs, failedTxs, usedTxBlobFields } = await checkpointBuilder.buildBlock(pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
927
|
-
const blockBuildDuration = workTimer.ms();
|
|
932
|
+
const buildResult = await this.buildSingleBlockWithCheckpointBuilder(checkpointBuilder, pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
928
933
|
// If any txs failed during execution, drop them from the mempool so we don't pick them up again
|
|
929
|
-
await this.dropFailedTxsFromP2P(failedTxs);
|
|
934
|
+
await this.dropFailedTxsFromP2P(buildResult.failedTxs);
|
|
930
935
|
// Check if we have created a block with enough txs. If there were invalid txs in the pool, or if execution took
|
|
931
936
|
// too long, then we may not get to minTxsPerBlock after executing public functions.
|
|
932
937
|
const minValidTxs = this.config.minValidTxsPerBlock ?? minTxs;
|
|
933
|
-
|
|
934
|
-
|
|
938
|
+
const numTxs = buildResult.status === 'no-valid-txs' ? 0 : buildResult.numTxs;
|
|
939
|
+
if (buildResult.status === 'no-valid-txs' || !forceCreate && numTxs < minValidTxs) {
|
|
940
|
+
this.log.warn(`Block ${blockNumber} at index ${indexWithinCheckpoint} on slot ${this.slot} has too few valid txs to be proposed`, {
|
|
935
941
|
slot: this.slot,
|
|
936
942
|
blockNumber,
|
|
937
943
|
numTxs,
|
|
938
|
-
indexWithinCheckpoint
|
|
944
|
+
indexWithinCheckpoint,
|
|
945
|
+
minValidTxs,
|
|
946
|
+
buildResult: buildResult.status
|
|
939
947
|
});
|
|
940
|
-
this.eventEmitter.emit('block-
|
|
941
|
-
|
|
942
|
-
availableTxs: numTxs,
|
|
948
|
+
this.eventEmitter.emit('block-build-failed', {
|
|
949
|
+
reason: `Insufficient valid txs`,
|
|
943
950
|
slot: this.slot
|
|
944
951
|
});
|
|
945
952
|
this.metrics.recordBlockProposalFailed('insufficient_valid_txs');
|
|
946
953
|
return undefined;
|
|
947
954
|
}
|
|
948
955
|
// Block creation succeeded, emit stats and metrics
|
|
956
|
+
const { block, publicProcessorDuration, usedTxs, blockBuildDuration } = buildResult;
|
|
949
957
|
const blockStats = {
|
|
950
958
|
eventName: 'l2-block-built',
|
|
951
959
|
duration: blockBuildDuration,
|
|
952
960
|
publicProcessDuration: publicProcessorDuration,
|
|
953
|
-
rollupCircuitsDuration: blockBuildingTimer.ms(),
|
|
954
961
|
...block.getStats()
|
|
955
962
|
};
|
|
956
963
|
const blockHash = await block.hash();
|
|
957
964
|
const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
|
|
958
|
-
const manaPerSec =
|
|
965
|
+
const manaPerSec = block.header.totalManaUsed.toNumberUnsafe() / (blockBuildDuration / 1000);
|
|
959
966
|
this.log.info(`Built block ${block.number} at checkpoint ${this.checkpointNumber} for slot ${this.slot} with ${numTxs} txs`, {
|
|
960
967
|
blockHash,
|
|
961
968
|
txHashes,
|
|
@@ -966,11 +973,10 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
966
973
|
blockNumber: block.number,
|
|
967
974
|
slot: this.slot
|
|
968
975
|
});
|
|
969
|
-
this.metrics.recordBuiltBlock(blockBuildDuration,
|
|
976
|
+
this.metrics.recordBuiltBlock(blockBuildDuration, block.header.totalManaUsed.toNumberUnsafe());
|
|
970
977
|
return {
|
|
971
978
|
block,
|
|
972
|
-
usedTxs
|
|
973
|
-
remainingBlobFields: maxBlobFieldsForTxs - usedTxBlobFields
|
|
979
|
+
usedTxs
|
|
974
980
|
};
|
|
975
981
|
} catch (err) {
|
|
976
982
|
this.eventEmitter.emit('block-build-failed', {
|
|
@@ -988,9 +994,30 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
988
994
|
};
|
|
989
995
|
}
|
|
990
996
|
}
|
|
997
|
+
/** Uses the checkpoint builder to build a block, catching specific txs */ async buildSingleBlockWithCheckpointBuilder(checkpointBuilder, pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions) {
|
|
998
|
+
try {
|
|
999
|
+
const workTimer = new Timer();
|
|
1000
|
+
const result = await checkpointBuilder.buildBlock(pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
1001
|
+
const blockBuildDuration = workTimer.ms();
|
|
1002
|
+
return {
|
|
1003
|
+
...result,
|
|
1004
|
+
blockBuildDuration,
|
|
1005
|
+
status: 'success'
|
|
1006
|
+
};
|
|
1007
|
+
} catch (err) {
|
|
1008
|
+
if (isErrorClass(err, NoValidTxsError)) {
|
|
1009
|
+
return {
|
|
1010
|
+
failedTxs: err.failedTxs,
|
|
1011
|
+
status: 'no-valid-txs'
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
throw err;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
991
1017
|
/** Waits until minTxs are available on the pool for building a block. */ async waitForMinTxs(opts) {
|
|
992
|
-
const minTxs = this.config.minTxsPerBlock;
|
|
993
1018
|
const { indexWithinCheckpoint, blockNumber, buildDeadline, forceCreate } = opts;
|
|
1019
|
+
// We only allow a block with 0 txs in the first block of the checkpoint
|
|
1020
|
+
const minTxs = indexWithinCheckpoint > 0 && this.config.minTxsPerBlock === 0 ? 1 : this.config.minTxsPerBlock;
|
|
994
1021
|
// Deadline is undefined if we are not enforcing the timetable, meaning we'll exit immediately when out of time
|
|
995
1022
|
const startBuildingDeadline = buildDeadline ? new Date(buildDeadline.getTime() - this.timetable.minExecutionTime * 1000) : undefined;
|
|
996
1023
|
let availableTxs = await this.p2pClient.getPendingTxCount();
|
|
@@ -1010,7 +1037,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1010
1037
|
slot: this.slot,
|
|
1011
1038
|
indexWithinCheckpoint
|
|
1012
1039
|
});
|
|
1013
|
-
await
|
|
1040
|
+
await this.waitForTxsPollingInterval();
|
|
1014
1041
|
availableTxs = await this.p2pClient.getPendingTxCount();
|
|
1015
1042
|
}
|
|
1016
1043
|
return {
|
|
@@ -1052,10 +1079,16 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1052
1079
|
try {
|
|
1053
1080
|
const attestations = await this.validatorClient.collectAttestations(proposal, numberOfRequiredAttestations, attestationDeadline);
|
|
1054
1081
|
collectedAttestationsCount = attestations.length;
|
|
1082
|
+
// Trim attestations to minimum required to save L1 calldata gas
|
|
1083
|
+
const localAddresses = this.validatorClient.getValidatorAddresses();
|
|
1084
|
+
const trimmed = trimAttestations(attestations, numberOfRequiredAttestations, this.attestorAddress, localAddresses);
|
|
1085
|
+
if (trimmed.length < attestations.length) {
|
|
1086
|
+
this.log.debug(`Trimmed attestations from ${attestations.length} to ${trimmed.length} for L1 submission`);
|
|
1087
|
+
}
|
|
1055
1088
|
// Rollup contract requires that the signatures are provided in the order of the committee
|
|
1056
|
-
const sorted = orderAttestations(
|
|
1089
|
+
const sorted = orderAttestations(trimmed, committee);
|
|
1057
1090
|
// Manipulate the attestations if we've been configured to do so
|
|
1058
|
-
if (this.config.injectFakeAttestation || this.config.shuffleAttestationOrdering) {
|
|
1091
|
+
if (this.config.injectFakeAttestation || this.config.injectHighSValueAttestation || this.config.injectUnrecoverableSignatureAttestation || this.config.shuffleAttestationOrdering) {
|
|
1059
1092
|
return this.manipulateAttestations(proposal.slotNumber, epoch, seed, committee, sorted);
|
|
1060
1093
|
}
|
|
1061
1094
|
return new CommitteeAttestationsAndSigners(sorted);
|
|
@@ -1072,7 +1105,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1072
1105
|
// Compute the proposer index in the committee, since we dont want to tweak it.
|
|
1073
1106
|
// Otherwise, the L1 rollup contract will reject the block outright.
|
|
1074
1107
|
const proposerIndex = Number(this.epochCache.computeProposerIndex(slotNumber, epoch, seed, BigInt(committee.length)));
|
|
1075
|
-
if (this.config.injectFakeAttestation) {
|
|
1108
|
+
if (this.config.injectFakeAttestation || this.config.injectHighSValueAttestation || this.config.injectUnrecoverableSignatureAttestation) {
|
|
1076
1109
|
// Find non-empty attestations that are not from the proposer
|
|
1077
1110
|
const nonProposerIndices = [];
|
|
1078
1111
|
for(let i = 0; i < attestations.length; i++){
|
|
@@ -1082,8 +1115,16 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1082
1115
|
}
|
|
1083
1116
|
if (nonProposerIndices.length > 0) {
|
|
1084
1117
|
const targetIndex = nonProposerIndices[randomInt(nonProposerIndices.length)];
|
|
1085
|
-
this.
|
|
1086
|
-
|
|
1118
|
+
if (this.config.injectHighSValueAttestation) {
|
|
1119
|
+
this.log.warn(`Injecting high-s value attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`);
|
|
1120
|
+
unfreeze(attestations[targetIndex]).signature = flipSignature(attestations[targetIndex].signature);
|
|
1121
|
+
} else if (this.config.injectUnrecoverableSignatureAttestation) {
|
|
1122
|
+
this.log.warn(`Injecting unrecoverable signature attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`);
|
|
1123
|
+
unfreeze(attestations[targetIndex]).signature = generateUnrecoverableSignature();
|
|
1124
|
+
} else {
|
|
1125
|
+
this.log.warn(`Injecting fake attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`);
|
|
1126
|
+
unfreeze(attestations[targetIndex]).signature = generateRecoverableSignature();
|
|
1127
|
+
}
|
|
1087
1128
|
}
|
|
1088
1129
|
return new CommitteeAttestationsAndSigners(attestations);
|
|
1089
1130
|
}
|
|
@@ -1092,14 +1133,25 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1092
1133
|
const shuffled = [
|
|
1093
1134
|
...attestations
|
|
1094
1135
|
];
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
];
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1136
|
+
// Find two non-proposer positions that both have non-empty signatures to swap.
|
|
1137
|
+
// This ensures the bitmap doesn't change, so the MaliciousCommitteeAttestationsAndSigners
|
|
1138
|
+
// signers array stays correctly aligned with L1's committee reconstruction.
|
|
1139
|
+
const swappable = [];
|
|
1140
|
+
for(let k = 0; k < shuffled.length; k++){
|
|
1141
|
+
if (!shuffled[k].signature.isEmpty() && k !== proposerIndex) {
|
|
1142
|
+
swappable.push(k);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
if (swappable.length >= 2) {
|
|
1146
|
+
const [i, j] = [
|
|
1147
|
+
swappable[0],
|
|
1148
|
+
swappable[1]
|
|
1149
|
+
];
|
|
1150
|
+
[shuffled[i], shuffled[j]] = [
|
|
1151
|
+
shuffled[j],
|
|
1152
|
+
shuffled[i]
|
|
1153
|
+
];
|
|
1154
|
+
}
|
|
1103
1155
|
const signers = new CommitteeAttestationsAndSigners(attestations).getSigners();
|
|
1104
1156
|
return new MaliciousCommitteeAttestationsAndSigners(shuffled, signers);
|
|
1105
1157
|
}
|
|
@@ -1112,7 +1164,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1112
1164
|
const failedTxData = failedTxs.map((fail)=>fail.tx);
|
|
1113
1165
|
const failedTxHashes = failedTxData.map((tx)=>tx.getTxHash());
|
|
1114
1166
|
this.log.verbose(`Dropping failed txs ${failedTxHashes.join(', ')}`);
|
|
1115
|
-
await this.p2pClient.
|
|
1167
|
+
await this.p2pClient.handleFailedExecution(failedTxHashes);
|
|
1116
1168
|
}
|
|
1117
1169
|
/**
|
|
1118
1170
|
* Adds the proposed block to the archiver so it's available via P2P.
|
|
@@ -1147,15 +1199,38 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1147
1199
|
slot: this.slot,
|
|
1148
1200
|
feeAnalysisId: feeAnalysis?.id
|
|
1149
1201
|
});
|
|
1150
|
-
this.metrics.
|
|
1202
|
+
this.metrics.recordCheckpointProposalFailed('block_build_failed');
|
|
1151
1203
|
}
|
|
1152
1204
|
this.publisher.clearPendingRequests();
|
|
1153
1205
|
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Helper to handle HA double-signing errors. Returns true if the error was handled (caller should yield).
|
|
1208
|
+
*/ handleHASigningError(err, errorContext) {
|
|
1209
|
+
if (err instanceof DutyAlreadySignedError) {
|
|
1210
|
+
this.log.info(`${errorContext} for slot ${this.slot} already signed by another HA node, yielding`, {
|
|
1211
|
+
slot: this.slot,
|
|
1212
|
+
signedByNode: err.signedByNode
|
|
1213
|
+
});
|
|
1214
|
+
return true;
|
|
1215
|
+
}
|
|
1216
|
+
if (err instanceof SlashingProtectionError) {
|
|
1217
|
+
this.log.info(`${errorContext} for slot ${this.slot} blocked by slashing protection, yielding`, {
|
|
1218
|
+
slot: this.slot,
|
|
1219
|
+
existingMessageHash: err.existingMessageHash,
|
|
1220
|
+
attemptedMessageHash: err.attemptedMessageHash
|
|
1221
|
+
});
|
|
1222
|
+
return true;
|
|
1223
|
+
}
|
|
1224
|
+
return false;
|
|
1225
|
+
}
|
|
1154
1226
|
/** Waits until a specific time within the current slot */ async waitUntilTimeInSlot(targetSecondsIntoSlot) {
|
|
1155
1227
|
const slotStartTimestamp = this.getSlotStartBuildTimestamp();
|
|
1156
1228
|
const targetTimestamp = slotStartTimestamp + targetSecondsIntoSlot;
|
|
1157
1229
|
await sleepUntil(new Date(targetTimestamp * 1000), this.dateProvider.nowAsDate());
|
|
1158
1230
|
}
|
|
1231
|
+
/** Waits the polling interval for transactions. Extracted for test overriding. */ async waitForTxsPollingInterval() {
|
|
1232
|
+
await sleep(TXS_POLLING_MS);
|
|
1233
|
+
}
|
|
1159
1234
|
getSlotStartBuildTimestamp() {
|
|
1160
1235
|
return getSlotStartBuildTimestamp(this.slot, this.l1Constants);
|
|
1161
1236
|
}
|