@aztec/sequencer-client 0.0.1-commit.88e6f9396 → 0.0.1-commit.8c0b8ff
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 +5 -1
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +6 -12
- package/dest/config.d.ts +3 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +1 -2
- package/dest/global_variable_builder/global_builder.d.ts +13 -7
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +22 -22
- package/dest/global_variable_builder/index.d.ts +2 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/publisher/config.d.ts +1 -5
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +1 -6
- package/dest/publisher/index.d.ts +1 -2
- package/dest/publisher/index.d.ts.map +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-factory.js +0 -14
- package/dest/publisher/sequencer-publisher.d.ts +11 -16
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +53 -289
- package/dest/sequencer/checkpoint_proposal_job.d.ts +4 -10
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +75 -117
- package/dest/sequencer/checkpoint_voter.d.ts +1 -2
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +2 -5
- package/dest/sequencer/events.d.ts +1 -2
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts +1 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +0 -11
- package/dest/sequencer/sequencer.d.ts +5 -4
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +50 -59
- package/dest/test/mock_checkpoint_builder.d.ts +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +2 -0
- package/package.json +28 -27
- package/src/client/sequencer-client.ts +9 -11
- package/src/config.ts +0 -4
- package/src/global_variable_builder/global_builder.ts +22 -24
- package/src/global_variable_builder/index.ts +1 -1
- package/src/publisher/config.ts +0 -9
- package/src/publisher/index.ts +0 -3
- package/src/publisher/sequencer-publisher-factory.ts +0 -15
- package/src/publisher/sequencer-publisher.ts +51 -274
- package/src/sequencer/checkpoint_proposal_job.ts +66 -139
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/events.ts +1 -1
- package/src/sequencer/metrics.ts +0 -14
- package/src/sequencer/sequencer.ts +58 -84
- package/src/test/mock_checkpoint_builder.ts +2 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +0 -11
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +0 -1
- package/dest/publisher/l1_tx_failed_store/factory.js +0 -22
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +0 -59
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +0 -1
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +0 -1
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +0 -15
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +0 -1
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +0 -34
- package/dest/publisher/l1_tx_failed_store/index.d.ts +0 -4
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +0 -1
- package/dest/publisher/l1_tx_failed_store/index.js +0 -2
- package/src/publisher/l1_tx_failed_store/factory.ts +0 -32
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +0 -55
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +0 -46
- package/src/publisher/l1_tx_failed_store/index.ts +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequencer-publisher.d.ts","sourceRoot":"","sources":["../../src/publisher/sequencer-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EACL,KAAK,8BAA8B,EAEnC,KAAK,0BAA0B,EAI/B,cAAc,EACd,KAAK,6BAA6B,EAGnC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,mBAAmB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAC1F,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,EAEd,KAAK,gBAAgB,EAEtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAA+C,MAAM,uBAAuB,CAAC;AAGxG,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG/E,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"sequencer-publisher.d.ts","sourceRoot":"","sources":["../../src/publisher/sequencer-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EACL,KAAK,8BAA8B,EAEnC,KAAK,0BAA0B,EAI/B,cAAc,EACd,KAAK,6BAA6B,EAGnC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,mBAAmB,EAAE,a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
381
381
|
import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
382
382
|
import { trimmedBytesLength } from '@aztec/foundation/buffer';
|
|
383
383
|
import { pick } from '@aztec/foundation/collection';
|
|
384
|
-
import { TimeoutError } from '@aztec/foundation/error';
|
|
385
384
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
386
385
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
387
386
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -391,9 +390,9 @@ import { Timer } from '@aztec/foundation/timer';
|
|
|
391
390
|
import { EmpireBaseAbi, ErrorsAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
392
391
|
import { encodeSlashConsensusVotes } from '@aztec/slasher';
|
|
393
392
|
import { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
393
|
+
import { getLastL1SlotTimestampForL2Slot, getNextL1SlotTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
394
394
|
import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
395
|
-
import { encodeFunctionData,
|
|
396
|
-
import { createL1TxFailedStore } from './l1_tx_failed_store/index.js';
|
|
395
|
+
import { encodeFunctionData, toHex } from 'viem';
|
|
397
396
|
import { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
|
|
398
397
|
export const Actions = [
|
|
399
398
|
'invalidate-by-invalid-attestation',
|
|
@@ -433,7 +432,6 @@ export class SequencerPublisher {
|
|
|
433
432
|
interrupted;
|
|
434
433
|
metrics;
|
|
435
434
|
epochCache;
|
|
436
|
-
failedTxStore;
|
|
437
435
|
governanceLog;
|
|
438
436
|
slashingLog;
|
|
439
437
|
lastActions;
|
|
@@ -442,9 +440,9 @@ export class SequencerPublisher {
|
|
|
442
440
|
log;
|
|
443
441
|
ethereumSlotDuration;
|
|
444
442
|
aztecSlotDuration;
|
|
443
|
+
dateProvider;
|
|
445
444
|
blobClient;
|
|
446
445
|
/** Address to use for simulations in fisherman mode (actual proposer's address) */ proposerAddressForSimulation;
|
|
447
|
-
/** Optional callback to obtain a replacement publisher when the current one fails to send. */ getNextPublisher;
|
|
448
446
|
/** L1 fee analyzer for fisherman mode */ l1FeeAnalyzer;
|
|
449
447
|
/** Fee asset price oracle for computing price modifiers from Uniswap V4 */ feeAssetPriceOracle;
|
|
450
448
|
// A CALL to a cold address is 2700 gas
|
|
@@ -470,6 +468,7 @@ export class SequencerPublisher {
|
|
|
470
468
|
this.log = deps.log ?? createLogger('sequencer:publisher');
|
|
471
469
|
this.ethereumSlotDuration = BigInt(config.ethereumSlotDuration);
|
|
472
470
|
this.aztecSlotDuration = BigInt(config.aztecSlotDuration);
|
|
471
|
+
this.dateProvider = deps.dateProvider;
|
|
473
472
|
this.epochCache = deps.epochCache;
|
|
474
473
|
this.lastActions = deps.lastActions;
|
|
475
474
|
this.blobClient = deps.blobClient;
|
|
@@ -477,7 +476,6 @@ export class SequencerPublisher {
|
|
|
477
476
|
this.metrics = deps.metrics ?? new SequencerPublisherMetrics(telemetry, 'SequencerPublisher');
|
|
478
477
|
this.tracer = telemetry.getTracer('SequencerPublisher');
|
|
479
478
|
this.l1TxUtils = deps.l1TxUtils;
|
|
480
|
-
this.getNextPublisher = deps.getNextPublisher;
|
|
481
479
|
this.rollupContract = deps.rollupContract;
|
|
482
480
|
this.govProposerContract = deps.governanceProposerContract;
|
|
483
481
|
this.slashingProposerContract = deps.slashingProposerContract;
|
|
@@ -493,24 +491,6 @@ export class SequencerPublisher {
|
|
|
493
491
|
}
|
|
494
492
|
// Initialize fee asset price oracle
|
|
495
493
|
this.feeAssetPriceOracle = new FeeAssetPriceOracle(this.l1TxUtils.client, this.rollupContract, createLogger('sequencer:publisher:price-oracle'));
|
|
496
|
-
// Initialize failed L1 tx store (optional, for test networks)
|
|
497
|
-
this.failedTxStore = createL1TxFailedStore(config.l1TxFailedStore, this.log);
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* Backs up a failed L1 transaction to the configured store for debugging.
|
|
501
|
-
* Does nothing if no store is configured.
|
|
502
|
-
*/ backupFailedTx(failedTx) {
|
|
503
|
-
if (!this.failedTxStore) {
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
|
-
const tx = {
|
|
507
|
-
...failedTx,
|
|
508
|
-
timestamp: Date.now()
|
|
509
|
-
};
|
|
510
|
-
// Fire and forget - don't block on backup
|
|
511
|
-
void this.failedTxStore.then((store)=>store?.saveFailedTx(tx)).catch((err)=>{
|
|
512
|
-
this.log.warn(`Failed to backup failed L1 tx to store`, err);
|
|
513
|
-
});
|
|
514
494
|
}
|
|
515
495
|
getRollupContract() {
|
|
516
496
|
return this.rollupContract;
|
|
@@ -539,7 +519,7 @@ export class SequencerPublisher {
|
|
|
539
519
|
this.requests.push(request);
|
|
540
520
|
}
|
|
541
521
|
getCurrentL2Slot() {
|
|
542
|
-
return this.epochCache.
|
|
522
|
+
return this.epochCache.getEpochAndSlotNow().slot;
|
|
543
523
|
}
|
|
544
524
|
/**
|
|
545
525
|
* Clears all pending requests without sending them.
|
|
@@ -656,34 +636,12 @@ export class SequencerPublisher {
|
|
|
656
636
|
// This ensures the committee gets precomputed correctly
|
|
657
637
|
validRequests.sort((a, b)=>compareActions(a.action, b.action));
|
|
658
638
|
try {
|
|
659
|
-
// Capture context for failed tx backup before sending
|
|
660
|
-
const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
|
|
661
|
-
const multicallData = encodeFunctionData({
|
|
662
|
-
abi: multicall3Abi,
|
|
663
|
-
functionName: 'aggregate3',
|
|
664
|
-
args: [
|
|
665
|
-
validRequests.map((r)=>({
|
|
666
|
-
target: r.request.to,
|
|
667
|
-
callData: r.request.data,
|
|
668
|
-
allowFailure: true
|
|
669
|
-
}))
|
|
670
|
-
]
|
|
671
|
-
});
|
|
672
|
-
const blobDataHex = blobConfig?.blobs?.map((b)=>toHex(b));
|
|
673
|
-
const txContext = {
|
|
674
|
-
multicallData,
|
|
675
|
-
blobData: blobDataHex,
|
|
676
|
-
l1BlockNumber
|
|
677
|
-
};
|
|
678
639
|
this.log.debug('Forwarding transactions', {
|
|
679
640
|
validRequests: validRequests.map((request)=>request.action),
|
|
680
641
|
txConfig
|
|
681
642
|
});
|
|
682
|
-
const result = await
|
|
683
|
-
|
|
684
|
-
return undefined;
|
|
685
|
-
}
|
|
686
|
-
const { successfulActions = [], failedActions = [] } = this.callbackBundledTransactions(validRequests, result, txContext);
|
|
643
|
+
const result = await Multicall3.forward(validRequests.map((request)=>request.request), this.l1TxUtils, txConfig, blobConfig, this.rollupContract.address, this.log);
|
|
644
|
+
const { successfulActions = [], failedActions = [] } = this.callbackBundledTransactions(validRequests, result);
|
|
687
645
|
return {
|
|
688
646
|
result,
|
|
689
647
|
expiredActions,
|
|
@@ -703,67 +661,10 @@ export class SequencerPublisher {
|
|
|
703
661
|
}
|
|
704
662
|
}
|
|
705
663
|
}
|
|
706
|
-
|
|
707
|
-
* Forwards transactions via Multicall3, rotating to the next available publisher if a send
|
|
708
|
-
* failure occurs (i.e. the tx never reached the chain).
|
|
709
|
-
* On-chain reverts and simulation errors are returned as-is without rotation.
|
|
710
|
-
*/ async forwardWithPublisherRotation(validRequests, txConfig, blobConfig) {
|
|
711
|
-
const triedAddresses = [];
|
|
712
|
-
let currentPublisher = this.l1TxUtils;
|
|
713
|
-
while(true){
|
|
714
|
-
triedAddresses.push(currentPublisher.getSenderAddress());
|
|
715
|
-
try {
|
|
716
|
-
const result = await Multicall3.forward(validRequests.map((r)=>r.request), currentPublisher, txConfig, blobConfig, this.rollupContract.address, this.log);
|
|
717
|
-
this.l1TxUtils = currentPublisher;
|
|
718
|
-
return result;
|
|
719
|
-
} catch (err) {
|
|
720
|
-
if (err instanceof TimeoutError) {
|
|
721
|
-
throw err;
|
|
722
|
-
}
|
|
723
|
-
const viemError = formatViemError(err);
|
|
724
|
-
if (!this.getNextPublisher) {
|
|
725
|
-
this.log.error('Failed to publish bundled transactions', viemError);
|
|
726
|
-
return undefined;
|
|
727
|
-
}
|
|
728
|
-
this.log.warn(`Publisher ${currentPublisher.getSenderAddress()} failed to send, rotating to next publisher`, viemError);
|
|
729
|
-
const nextPublisher = await this.getNextPublisher([
|
|
730
|
-
...triedAddresses
|
|
731
|
-
]);
|
|
732
|
-
if (!nextPublisher) {
|
|
733
|
-
this.log.error('All available publishers exhausted, failed to publish bundled transactions');
|
|
734
|
-
return undefined;
|
|
735
|
-
}
|
|
736
|
-
currentPublisher = nextPublisher;
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
callbackBundledTransactions(requests, result, txContext) {
|
|
664
|
+
callbackBundledTransactions(requests, result) {
|
|
741
665
|
const actionsListStr = requests.map((r)=>r.action).join(', ');
|
|
742
666
|
if (result instanceof FormattedViemError) {
|
|
743
667
|
this.log.error(`Failed to publish bundled transactions (${actionsListStr})`, result);
|
|
744
|
-
this.backupFailedTx({
|
|
745
|
-
id: keccak256(txContext.multicallData),
|
|
746
|
-
failureType: 'send-error',
|
|
747
|
-
request: {
|
|
748
|
-
to: MULTI_CALL_3_ADDRESS,
|
|
749
|
-
data: txContext.multicallData
|
|
750
|
-
},
|
|
751
|
-
blobData: txContext.blobData,
|
|
752
|
-
l1BlockNumber: txContext.l1BlockNumber.toString(),
|
|
753
|
-
error: {
|
|
754
|
-
message: result.message,
|
|
755
|
-
name: result.name
|
|
756
|
-
},
|
|
757
|
-
context: {
|
|
758
|
-
actions: requests.map((r)=>r.action),
|
|
759
|
-
requests: requests.map((r)=>({
|
|
760
|
-
action: r.action,
|
|
761
|
-
to: r.request.to,
|
|
762
|
-
data: r.request.data
|
|
763
|
-
})),
|
|
764
|
-
sender: this.getSenderAddress().toString()
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
668
|
return {
|
|
768
669
|
failedActions: requests.map((r)=>r.action)
|
|
769
670
|
};
|
|
@@ -790,37 +691,6 @@ export class SequencerPublisher {
|
|
|
790
691
|
failedActions.push(request.action);
|
|
791
692
|
}
|
|
792
693
|
}
|
|
793
|
-
// Single backup for the whole reverted tx
|
|
794
|
-
if (failedActions.length > 0 && result?.receipt?.status === 'reverted') {
|
|
795
|
-
this.backupFailedTx({
|
|
796
|
-
id: result.receipt.transactionHash,
|
|
797
|
-
failureType: 'revert',
|
|
798
|
-
request: {
|
|
799
|
-
to: MULTI_CALL_3_ADDRESS,
|
|
800
|
-
data: txContext.multicallData
|
|
801
|
-
},
|
|
802
|
-
blobData: txContext.blobData,
|
|
803
|
-
l1BlockNumber: result.receipt.blockNumber.toString(),
|
|
804
|
-
receipt: {
|
|
805
|
-
transactionHash: result.receipt.transactionHash,
|
|
806
|
-
blockNumber: result.receipt.blockNumber.toString(),
|
|
807
|
-
gasUsed: (result.receipt.gasUsed ?? 0n).toString(),
|
|
808
|
-
status: 'reverted'
|
|
809
|
-
},
|
|
810
|
-
error: {
|
|
811
|
-
message: result.errorMsg ?? 'Transaction reverted'
|
|
812
|
-
},
|
|
813
|
-
context: {
|
|
814
|
-
actions: failedActions,
|
|
815
|
-
requests: requests.filter((r)=>failedActions.includes(r.action)).map((r)=>({
|
|
816
|
-
action: r.action,
|
|
817
|
-
to: r.request.to,
|
|
818
|
-
data: r.request.data
|
|
819
|
-
})),
|
|
820
|
-
sender: this.getSenderAddress().toString()
|
|
821
|
-
}
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
694
|
return {
|
|
825
695
|
successfulActions,
|
|
826
696
|
failedActions
|
|
@@ -838,9 +708,10 @@ export class SequencerPublisher {
|
|
|
838
708
|
'InvalidProposer',
|
|
839
709
|
'InvalidArchive'
|
|
840
710
|
];
|
|
841
|
-
const pipelined = opts.pipelined ??
|
|
711
|
+
const pipelined = opts.pipelined ?? false;
|
|
842
712
|
const slotOffset = pipelined ? this.aztecSlotDuration : 0n;
|
|
843
|
-
|
|
713
|
+
const nextL1SlotTs = this.getNextL1SlotTimestamp() + slotOffset;
|
|
714
|
+
return this.rollupContract.canProposeAt(tipArchive.toBuffer(), msgSender.toString(), nextL1SlotTs, {
|
|
844
715
|
forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
|
|
845
716
|
}).catch((err)=>{
|
|
846
717
|
if (err instanceof FormattedViemError && ignoredErrors.find((e)=>err.message.includes(e))) {
|
|
@@ -872,7 +743,7 @@ export class SequencerPublisher {
|
|
|
872
743
|
header.blobsHash.toString(),
|
|
873
744
|
flags
|
|
874
745
|
];
|
|
875
|
-
const ts =
|
|
746
|
+
const ts = this.getSimulationTimestamp(header.slotNumber);
|
|
876
747
|
const stateOverrides = await this.rollupContract.makePendingCheckpointNumberOverride(opts?.forcePendingCheckpointNumber);
|
|
877
748
|
let balance = 0n;
|
|
878
749
|
if (this.config.fishermanMode) {
|
|
@@ -895,7 +766,7 @@ export class SequencerPublisher {
|
|
|
895
766
|
}),
|
|
896
767
|
from: MULTI_CALL_3_ADDRESS
|
|
897
768
|
}, {
|
|
898
|
-
time: ts
|
|
769
|
+
time: ts
|
|
899
770
|
}, stateOverrides);
|
|
900
771
|
this.log.debug(`Simulated validateHeader`);
|
|
901
772
|
}
|
|
@@ -925,7 +796,6 @@ export class SequencerPublisher {
|
|
|
925
796
|
...logData,
|
|
926
797
|
request
|
|
927
798
|
});
|
|
928
|
-
const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
|
|
929
799
|
try {
|
|
930
800
|
const { gasUsed } = await this.l1TxUtils.simulate(request, undefined, undefined, mergeAbis([
|
|
931
801
|
request.abi ?? [],
|
|
@@ -968,27 +838,6 @@ export class SequencerPublisher {
|
|
|
968
838
|
}
|
|
969
839
|
// Otherwise, throw. We cannot build the next checkpoint if we cannot invalidate the previous one.
|
|
970
840
|
this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed`, viemError, logData);
|
|
971
|
-
this.backupFailedTx({
|
|
972
|
-
id: keccak256(request.data),
|
|
973
|
-
failureType: 'simulation',
|
|
974
|
-
request: {
|
|
975
|
-
to: request.to,
|
|
976
|
-
data: request.data,
|
|
977
|
-
value: request.value?.toString()
|
|
978
|
-
},
|
|
979
|
-
l1BlockNumber: l1BlockNumber.toString(),
|
|
980
|
-
error: {
|
|
981
|
-
message: viemError.message,
|
|
982
|
-
name: viemError.name
|
|
983
|
-
},
|
|
984
|
-
context: {
|
|
985
|
-
actions: [
|
|
986
|
-
`invalidate-${reason}`
|
|
987
|
-
],
|
|
988
|
-
checkpointNumber,
|
|
989
|
-
sender: this.getSenderAddress().toString()
|
|
990
|
-
}
|
|
991
|
-
});
|
|
992
841
|
throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber}`, {
|
|
993
842
|
cause: viemError
|
|
994
843
|
});
|
|
@@ -1015,9 +864,6 @@ export class SequencerPublisher {
|
|
|
1015
864
|
}
|
|
1016
865
|
}
|
|
1017
866
|
/** Simulates `propose` to make sure that the checkpoint is valid for submission */ async validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, options) {
|
|
1018
|
-
// Anchor the simulation timestamp to the checkpoint's own slot start time
|
|
1019
|
-
// rather than the current L1 block timestamp, which may overshoot into the next slot if the build ran late.
|
|
1020
|
-
const ts = checkpoint.header.timestamp;
|
|
1021
867
|
const blobFields = checkpoint.toBlobFields();
|
|
1022
868
|
const blobs = await getBlobsPerL1Block(blobFields);
|
|
1023
869
|
const blobInput = getPrefixedEthBlobCommitments(blobs);
|
|
@@ -1034,10 +880,9 @@ export class SequencerPublisher {
|
|
|
1034
880
|
attestationsAndSignersSignature.toViemSignature(),
|
|
1035
881
|
blobInput
|
|
1036
882
|
];
|
|
1037
|
-
await this.simulateProposeTx(args,
|
|
1038
|
-
return ts;
|
|
883
|
+
await this.simulateProposeTx(args, options);
|
|
1039
884
|
}
|
|
1040
|
-
async enqueueCastSignalHelper(slotNumber,
|
|
885
|
+
async enqueueCastSignalHelper(slotNumber, signalType, payload, base, signerAddress, signer) {
|
|
1041
886
|
if (this.lastActions[signalType] && this.lastActions[signalType] === slotNumber) {
|
|
1042
887
|
this.log.debug(`Skipping duplicate vote cast signal ${signalType} for slot ${slotNumber}`);
|
|
1043
888
|
return false;
|
|
@@ -1093,7 +938,7 @@ export class SequencerPublisher {
|
|
|
1093
938
|
signer: this.l1TxUtils.client.account?.address,
|
|
1094
939
|
lastValidL2Slot: slotNumber
|
|
1095
940
|
});
|
|
1096
|
-
const
|
|
941
|
+
const timestamp = this.getSimulationTimestamp(slotNumber);
|
|
1097
942
|
try {
|
|
1098
943
|
await this.l1TxUtils.simulate(request, {
|
|
1099
944
|
time: timestamp
|
|
@@ -1106,27 +951,8 @@ export class SequencerPublisher {
|
|
|
1106
951
|
});
|
|
1107
952
|
} catch (err) {
|
|
1108
953
|
const viemError = formatViemError(err);
|
|
1109
|
-
this.log.error(`Failed simulation for ${action} at slot ${slotNumber} (enqueuing the action anyway)`, viemError
|
|
1110
|
-
|
|
1111
|
-
id: keccak256(request.data),
|
|
1112
|
-
failureType: 'simulation',
|
|
1113
|
-
request: {
|
|
1114
|
-
to: request.to,
|
|
1115
|
-
data: request.data,
|
|
1116
|
-
value: request.value?.toString()
|
|
1117
|
-
},
|
|
1118
|
-
l1BlockNumber: l1BlockNumber.toString(),
|
|
1119
|
-
error: {
|
|
1120
|
-
message: viemError.message,
|
|
1121
|
-
name: viemError.name
|
|
1122
|
-
},
|
|
1123
|
-
context: {
|
|
1124
|
-
actions: [
|
|
1125
|
-
action
|
|
1126
|
-
],
|
|
1127
|
-
slot: slotNumber,
|
|
1128
|
-
sender: this.getSenderAddress().toString()
|
|
1129
|
-
}
|
|
954
|
+
this.log.error(`Failed simulation for ${action} at slot ${slotNumber} (enqueuing the action anyway)`, viemError, {
|
|
955
|
+
simulationTimestamp: timestamp
|
|
1130
956
|
});
|
|
1131
957
|
// Yes, we enqueue the request anyway, in case there was a bug with the simulation itself
|
|
1132
958
|
}
|
|
@@ -1171,12 +997,11 @@ export class SequencerPublisher {
|
|
|
1171
997
|
/**
|
|
1172
998
|
* Enqueues a governance castSignal transaction to cast a signal for a given slot number.
|
|
1173
999
|
* @param slotNumber - The slot number to cast a signal for.
|
|
1174
|
-
* @param timestamp - The timestamp of the slot to cast a signal for.
|
|
1175
1000
|
* @returns True if the signal was successfully enqueued, false otherwise.
|
|
1176
|
-
*/ enqueueGovernanceCastSignal(governancePayload, slotNumber,
|
|
1177
|
-
return this.enqueueCastSignalHelper(slotNumber,
|
|
1001
|
+
*/ enqueueGovernanceCastSignal(governancePayload, slotNumber, signerAddress, signer) {
|
|
1002
|
+
return this.enqueueCastSignalHelper(slotNumber, 'governance-signal', governancePayload, this.govProposerContract, signerAddress, signer);
|
|
1178
1003
|
}
|
|
1179
|
-
/** Enqueues all slashing actions as returned by the slasher client. */ async enqueueSlashingActions(actions, slotNumber,
|
|
1004
|
+
/** Enqueues all slashing actions as returned by the slasher client. */ async enqueueSlashingActions(actions, slotNumber, signerAddress, signer) {
|
|
1180
1005
|
if (actions.length === 0) {
|
|
1181
1006
|
this.log.debug(`No slashing actions to enqueue for slot ${slotNumber}`);
|
|
1182
1007
|
return false;
|
|
@@ -1192,7 +1017,7 @@ export class SequencerPublisher {
|
|
|
1192
1017
|
this.log.debug(`Enqueuing slashing vote for payload ${action.payload} at slot ${slotNumber}`, {
|
|
1193
1018
|
signerAddress
|
|
1194
1019
|
});
|
|
1195
|
-
await this.enqueueCastSignalHelper(slotNumber,
|
|
1020
|
+
await this.enqueueCastSignalHelper(slotNumber, 'empire-slashing-signal', action.payload, this.slashingProposerContract, signerAddress, signer);
|
|
1196
1021
|
break;
|
|
1197
1022
|
}
|
|
1198
1023
|
case 'create-empire-payload':
|
|
@@ -1202,7 +1027,7 @@ export class SequencerPublisher {
|
|
|
1202
1027
|
signerAddress
|
|
1203
1028
|
});
|
|
1204
1029
|
const request = this.slashFactoryContract.buildCreatePayloadRequest(action.data);
|
|
1205
|
-
await this.simulateAndEnqueueRequest('create-empire-payload', request, (receipt)=>!!this.slashFactoryContract.tryExtractSlashPayloadCreatedEvent(receipt.logs), slotNumber
|
|
1030
|
+
await this.simulateAndEnqueueRequest('create-empire-payload', request, (receipt)=>!!this.slashFactoryContract.tryExtractSlashPayloadCreatedEvent(receipt.logs), slotNumber);
|
|
1206
1031
|
break;
|
|
1207
1032
|
}
|
|
1208
1033
|
case 'execute-empire-payload':
|
|
@@ -1217,7 +1042,7 @@ export class SequencerPublisher {
|
|
|
1217
1042
|
}
|
|
1218
1043
|
const empireSlashingProposer = this.slashingProposerContract;
|
|
1219
1044
|
const request = empireSlashingProposer.buildExecuteRoundRequest(action.round);
|
|
1220
|
-
await this.simulateAndEnqueueRequest('execute-empire-payload', request, (receipt)=>!!empireSlashingProposer.tryExtractPayloadSubmittedEvent(receipt.logs), slotNumber
|
|
1045
|
+
await this.simulateAndEnqueueRequest('execute-empire-payload', request, (receipt)=>!!empireSlashingProposer.tryExtractPayloadSubmittedEvent(receipt.logs), slotNumber);
|
|
1221
1046
|
break;
|
|
1222
1047
|
}
|
|
1223
1048
|
case 'vote-offenses':
|
|
@@ -1235,7 +1060,7 @@ export class SequencerPublisher {
|
|
|
1235
1060
|
const tallySlashingProposer = this.slashingProposerContract;
|
|
1236
1061
|
const votes = bufferToHex(encodeSlashConsensusVotes(action.votes));
|
|
1237
1062
|
const request = await tallySlashingProposer.buildVoteRequestFromSigner(votes, slotNumber, signer);
|
|
1238
|
-
await this.simulateAndEnqueueRequest('vote-offenses', request, (receipt)=>!!tallySlashingProposer.tryExtractVoteCastEvent(receipt.logs), slotNumber
|
|
1063
|
+
await this.simulateAndEnqueueRequest('vote-offenses', request, (receipt)=>!!tallySlashingProposer.tryExtractVoteCastEvent(receipt.logs), slotNumber);
|
|
1239
1064
|
break;
|
|
1240
1065
|
}
|
|
1241
1066
|
case 'execute-slash':
|
|
@@ -1251,7 +1076,7 @@ export class SequencerPublisher {
|
|
|
1251
1076
|
}
|
|
1252
1077
|
const tallySlashingProposer = this.slashingProposerContract;
|
|
1253
1078
|
const request = tallySlashingProposer.buildExecuteRoundRequest(action.round, action.committees);
|
|
1254
|
-
await this.simulateAndEnqueueRequest('execute-slash', request, (receipt)=>!!tallySlashingProposer.tryExtractRoundExecutedEvent(receipt.logs), slotNumber
|
|
1079
|
+
await this.simulateAndEnqueueRequest('execute-slash', request, (receipt)=>!!tallySlashingProposer.tryExtractRoundExecutedEvent(receipt.logs), slotNumber);
|
|
1255
1080
|
break;
|
|
1256
1081
|
}
|
|
1257
1082
|
default:
|
|
@@ -1275,14 +1100,13 @@ export class SequencerPublisher {
|
|
|
1275
1100
|
attestationsAndSignersSignature,
|
|
1276
1101
|
feeAssetPriceModifier: checkpoint.feeAssetPriceModifier
|
|
1277
1102
|
};
|
|
1278
|
-
let ts;
|
|
1279
1103
|
try {
|
|
1280
1104
|
// @note This will make sure that we are passing the checks for our header ASSUMING that the data is also made available
|
|
1281
1105
|
// This means that we can avoid the simulation issues in later checks.
|
|
1282
1106
|
// By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which
|
|
1283
1107
|
// make time consistency checks break.
|
|
1284
1108
|
// TODO(palla): Check whether we're validating twice, once here and once within addProposeTx, since we call simulateProposeTx in both places.
|
|
1285
|
-
|
|
1109
|
+
await this.validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts);
|
|
1286
1110
|
} catch (err) {
|
|
1287
1111
|
this.log.error(`Checkpoint validation failed. ${err instanceof Error ? err.message : 'No error message'}`, err, {
|
|
1288
1112
|
...checkpoint.getStats(),
|
|
@@ -1295,7 +1119,7 @@ export class SequencerPublisher {
|
|
|
1295
1119
|
...checkpoint.toCheckpointInfo(),
|
|
1296
1120
|
...opts
|
|
1297
1121
|
});
|
|
1298
|
-
await this.addProposeTx(checkpoint, proposeTxArgs, opts
|
|
1122
|
+
await this.addProposeTx(checkpoint, proposeTxArgs, opts);
|
|
1299
1123
|
}
|
|
1300
1124
|
enqueueInvalidateCheckpoint(request, opts = {}) {
|
|
1301
1125
|
if (!request) {
|
|
@@ -1336,7 +1160,8 @@ export class SequencerPublisher {
|
|
|
1336
1160
|
}
|
|
1337
1161
|
});
|
|
1338
1162
|
}
|
|
1339
|
-
async simulateAndEnqueueRequest(action, request, checkSuccess, slotNumber
|
|
1163
|
+
async simulateAndEnqueueRequest(action, request, checkSuccess, slotNumber) {
|
|
1164
|
+
const timestamp = this.getSimulationTimestamp(slotNumber);
|
|
1340
1165
|
const logData = {
|
|
1341
1166
|
slotNumber,
|
|
1342
1167
|
timestamp,
|
|
@@ -1349,7 +1174,6 @@ export class SequencerPublisher {
|
|
|
1349
1174
|
const cachedLastActionSlot = this.lastActions[action];
|
|
1350
1175
|
this.lastActions[action] = slotNumber;
|
|
1351
1176
|
this.log.debug(`Simulating ${action} for slot ${slotNumber}`, logData);
|
|
1352
|
-
const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
|
|
1353
1177
|
let gasUsed;
|
|
1354
1178
|
const simulateAbi = mergeAbis([
|
|
1355
1179
|
request.abi ?? [],
|
|
@@ -1358,7 +1182,7 @@ export class SequencerPublisher {
|
|
|
1358
1182
|
try {
|
|
1359
1183
|
({ gasUsed } = await this.l1TxUtils.simulate(request, {
|
|
1360
1184
|
time: timestamp
|
|
1361
|
-
}, [], simulateAbi));
|
|
1185
|
+
}, [], simulateAbi));
|
|
1362
1186
|
this.log.verbose(`Simulation for ${action} succeeded`, {
|
|
1363
1187
|
...logData,
|
|
1364
1188
|
request,
|
|
@@ -1367,27 +1191,6 @@ export class SequencerPublisher {
|
|
|
1367
1191
|
} catch (err) {
|
|
1368
1192
|
const viemError = formatViemError(err, simulateAbi);
|
|
1369
1193
|
this.log.error(`Simulation for ${action} at ${slotNumber} failed`, viemError, logData);
|
|
1370
|
-
this.backupFailedTx({
|
|
1371
|
-
id: keccak256(request.data),
|
|
1372
|
-
failureType: 'simulation',
|
|
1373
|
-
request: {
|
|
1374
|
-
to: request.to,
|
|
1375
|
-
data: request.data,
|
|
1376
|
-
value: request.value?.toString()
|
|
1377
|
-
},
|
|
1378
|
-
l1BlockNumber: l1BlockNumber.toString(),
|
|
1379
|
-
error: {
|
|
1380
|
-
message: viemError.message,
|
|
1381
|
-
name: viemError.name
|
|
1382
|
-
},
|
|
1383
|
-
context: {
|
|
1384
|
-
actions: [
|
|
1385
|
-
action
|
|
1386
|
-
],
|
|
1387
|
-
slot: slotNumber,
|
|
1388
|
-
sender: this.getSenderAddress().toString()
|
|
1389
|
-
}
|
|
1390
|
-
});
|
|
1391
1194
|
return false;
|
|
1392
1195
|
}
|
|
1393
1196
|
// We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
|
|
@@ -1439,7 +1242,7 @@ export class SequencerPublisher {
|
|
|
1439
1242
|
this.interrupted = false;
|
|
1440
1243
|
this.l1TxUtils.restart();
|
|
1441
1244
|
}
|
|
1442
|
-
async prepareProposeTx(encodedData,
|
|
1245
|
+
async prepareProposeTx(encodedData, options) {
|
|
1443
1246
|
const kzg = Blob.getViemKzgInstance();
|
|
1444
1247
|
const blobInput = getPrefixedEthBlobCommitments(encodedData.blobs);
|
|
1445
1248
|
this.log.debug('Validating blob input', {
|
|
@@ -1466,38 +1269,10 @@ export class SequencerPublisher {
|
|
|
1466
1269
|
}, {}, {
|
|
1467
1270
|
blobs: encodedData.blobs.map((b)=>b.data),
|
|
1468
1271
|
kzg
|
|
1469
|
-
}).catch(
|
|
1470
|
-
const
|
|
1471
|
-
this.log.error(`Failed to validate blobs`,
|
|
1472
|
-
metaMessages
|
|
1473
|
-
});
|
|
1474
|
-
const validateBlobsData = encodeFunctionData({
|
|
1475
|
-
abi: RollupAbi,
|
|
1476
|
-
functionName: 'validateBlobs',
|
|
1477
|
-
args: [
|
|
1478
|
-
blobInput
|
|
1479
|
-
]
|
|
1480
|
-
});
|
|
1481
|
-
const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
|
|
1482
|
-
this.backupFailedTx({
|
|
1483
|
-
id: keccak256(validateBlobsData),
|
|
1484
|
-
failureType: 'simulation',
|
|
1485
|
-
request: {
|
|
1486
|
-
to: this.rollupContract.address,
|
|
1487
|
-
data: validateBlobsData
|
|
1488
|
-
},
|
|
1489
|
-
blobData: encodedData.blobs.map((b)=>toHex(b.data)),
|
|
1490
|
-
l1BlockNumber: l1BlockNumber.toString(),
|
|
1491
|
-
error: {
|
|
1492
|
-
message: viemError.message,
|
|
1493
|
-
name: viemError.name
|
|
1494
|
-
},
|
|
1495
|
-
context: {
|
|
1496
|
-
actions: [
|
|
1497
|
-
'validate-blobs'
|
|
1498
|
-
],
|
|
1499
|
-
sender: this.getSenderAddress().toString()
|
|
1500
|
-
}
|
|
1272
|
+
}).catch((err)=>{
|
|
1273
|
+
const { message, metaMessages } = formatViemError(err);
|
|
1274
|
+
this.log.error(`Failed to validate blobs`, message, {
|
|
1275
|
+
metaMessages
|
|
1501
1276
|
});
|
|
1502
1277
|
throw new Error('Failed to validate blobs');
|
|
1503
1278
|
});
|
|
@@ -1516,7 +1291,7 @@ export class SequencerPublisher {
|
|
|
1516
1291
|
encodedData.attestationsAndSignersSignature.toViemSignature(),
|
|
1517
1292
|
blobInput
|
|
1518
1293
|
];
|
|
1519
|
-
const { rollupData, simulationResult } = await this.simulateProposeTx(args,
|
|
1294
|
+
const { rollupData, simulationResult } = await this.simulateProposeTx(args, options);
|
|
1520
1295
|
return {
|
|
1521
1296
|
args,
|
|
1522
1297
|
blobEvaluationGas,
|
|
@@ -1527,9 +1302,8 @@ export class SequencerPublisher {
|
|
|
1527
1302
|
/**
|
|
1528
1303
|
* Simulates the propose tx with eth_simulateV1
|
|
1529
1304
|
* @param args - The propose tx args
|
|
1530
|
-
* @param timestamp - The timestamp to simulate proposal at
|
|
1531
1305
|
* @returns The simulation result
|
|
1532
|
-
*/ async simulateProposeTx(args,
|
|
1306
|
+
*/ async simulateProposeTx(args, options) {
|
|
1533
1307
|
const rollupData = encodeFunctionData({
|
|
1534
1308
|
abi: RollupAbi,
|
|
1535
1309
|
functionName: 'propose',
|
|
@@ -1557,7 +1331,7 @@ export class SequencerPublisher {
|
|
|
1557
1331
|
balance: 10n * WEI_CONST * WEI_CONST
|
|
1558
1332
|
});
|
|
1559
1333
|
}
|
|
1560
|
-
const
|
|
1334
|
+
const simTs = this.getSimulationTimestamp(SlotNumber.fromBigInt(args[0].header.slotNumber));
|
|
1561
1335
|
const simulationResult = await this.l1TxUtils.simulate({
|
|
1562
1336
|
to: this.rollupContract.address,
|
|
1563
1337
|
data: rollupData,
|
|
@@ -1566,8 +1340,7 @@ export class SequencerPublisher {
|
|
|
1566
1340
|
from: this.proposerAddressForSimulation.toString()
|
|
1567
1341
|
}
|
|
1568
1342
|
}, {
|
|
1569
|
-
|
|
1570
|
-
time: timestamp + 1n,
|
|
1343
|
+
time: simTs,
|
|
1571
1344
|
// @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit so we increase here
|
|
1572
1345
|
gasLimit: MAX_L1_TX_LIMIT * 2n
|
|
1573
1346
|
}, stateOverrides, RollupAbi, {
|
|
@@ -1584,26 +1357,8 @@ export class SequencerPublisher {
|
|
|
1584
1357
|
logs: []
|
|
1585
1358
|
};
|
|
1586
1359
|
}
|
|
1587
|
-
this.log.error(`Failed to simulate propose tx`, viemError
|
|
1588
|
-
|
|
1589
|
-
id: keccak256(rollupData),
|
|
1590
|
-
failureType: 'simulation',
|
|
1591
|
-
request: {
|
|
1592
|
-
to: this.rollupContract.address,
|
|
1593
|
-
data: rollupData
|
|
1594
|
-
},
|
|
1595
|
-
l1BlockNumber: l1BlockNumber.toString(),
|
|
1596
|
-
error: {
|
|
1597
|
-
message: viemError.message,
|
|
1598
|
-
name: viemError.name
|
|
1599
|
-
},
|
|
1600
|
-
context: {
|
|
1601
|
-
actions: [
|
|
1602
|
-
'propose'
|
|
1603
|
-
],
|
|
1604
|
-
slot: Number(args[0].header.slotNumber),
|
|
1605
|
-
sender: this.getSenderAddress().toString()
|
|
1606
|
-
}
|
|
1360
|
+
this.log.error(`Failed to simulate propose tx`, viemError, {
|
|
1361
|
+
simulationTimestamp: simTs
|
|
1607
1362
|
});
|
|
1608
1363
|
throw err;
|
|
1609
1364
|
});
|
|
@@ -1612,11 +1367,11 @@ export class SequencerPublisher {
|
|
|
1612
1367
|
simulationResult
|
|
1613
1368
|
};
|
|
1614
1369
|
}
|
|
1615
|
-
async addProposeTx(checkpoint, encodedData, opts = {}
|
|
1370
|
+
async addProposeTx(checkpoint, encodedData, opts = {}) {
|
|
1616
1371
|
const slot = checkpoint.header.slotNumber;
|
|
1617
1372
|
const timer = new Timer();
|
|
1618
1373
|
const kzg = Blob.getViemKzgInstance();
|
|
1619
|
-
const { rollupData, simulationResult, blobEvaluationGas } = await this.prepareProposeTx(encodedData,
|
|
1374
|
+
const { rollupData, simulationResult, blobEvaluationGas } = await this.prepareProposeTx(encodedData, opts);
|
|
1620
1375
|
const startBlock = await this.l1TxUtils.getBlockNumber();
|
|
1621
1376
|
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(simulationResult.gasUsed) * 64 / 63)) + blobEvaluationGas + SequencerPublisher.MULTICALL_OVERHEAD_GAS_GUESS);
|
|
1622
1377
|
// Send the blobs to the blob client preemptively. This helps in tests where the sequencer mistakingly thinks that the propose
|
|
@@ -1681,4 +1436,13 @@ export class SequencerPublisher {
|
|
|
1681
1436
|
}
|
|
1682
1437
|
});
|
|
1683
1438
|
}
|
|
1439
|
+
/** Returns the timestamp of the last L1 slot within a given L2 slot. Used as the simulation timestamp
|
|
1440
|
+
* for eth_simulateV1 calls, since it's guaranteed to be greater than any L1 block produced during the slot. */ getSimulationTimestamp(slot) {
|
|
1441
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
1442
|
+
return getLastL1SlotTimestampForL2Slot(slot, l1Constants);
|
|
1443
|
+
}
|
|
1444
|
+
/** Returns the timestamp of the next L1 slot boundary after now. */ getNextL1SlotTimestamp() {
|
|
1445
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
1446
|
+
return getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), l1Constants);
|
|
1447
|
+
}
|
|
1684
1448
|
}
|