@aztec/sequencer-client 0.0.1-commit.2ed92850 → 0.0.1-commit.2f68f620
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/README.md +281 -21
- package/dest/client/sequencer-client.d.ts +19 -9
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +65 -32
- package/dest/config.d.ts +28 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +76 -37
- package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
- package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_predictor.js +128 -0
- package/dest/global_variable_builder/fee_provider.d.ts +21 -0
- package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_provider.js +58 -0
- package/dest/global_variable_builder/global_builder.d.ts +14 -16
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +16 -50
- package/dest/global_variable_builder/index.d.ts +4 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/global_variable_builder/index.js +2 -0
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/publisher/config.d.ts +47 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +121 -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 +58 -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-bundle-simulator.d.ts +96 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
- package/dest/publisher/sequencer-bundle-simulator.js +198 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -5
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +27 -3
- 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-metrics.js +12 -4
- package/dest/publisher/sequencer-publisher.d.ts +94 -68
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +448 -363
- package/dest/sequencer/automine/automine_factory.d.ts +54 -0
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_factory.js +84 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts +151 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_sequencer.js +509 -0
- package/dest/sequencer/chain_state_overrides.d.ts +61 -0
- package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
- package/dest/sequencer/chain_state_overrides.js +98 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +85 -14
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +882 -254
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
- 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 +48 -2
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/index.d.ts +3 -1
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +2 -0
- package/dest/sequencer/metrics.d.ts +23 -8
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +142 -36
- package/dest/sequencer/sequencer.d.ts +85 -22
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +380 -137
- package/dest/sequencer/timetable.d.ts +14 -6
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +47 -46
- package/dest/sequencer/types.d.ts +2 -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 +12 -12
- 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 +10 -8
- package/package.json +27 -28
- package/src/client/sequencer-client.ts +91 -35
- package/src/config.ts +98 -46
- package/src/global_variable_builder/README.md +44 -0
- package/src/global_variable_builder/fee_predictor.ts +172 -0
- package/src/global_variable_builder/fee_provider.ts +75 -0
- package/src/global_variable_builder/global_builder.ts +26 -63
- package/src/global_variable_builder/index.ts +3 -1
- package/src/index.ts +10 -1
- package/src/publisher/config.ts +157 -45
- 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 +57 -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-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher-factory.ts +38 -9
- package/src/publisher/sequencer-publisher-metrics.ts +7 -3
- package/src/publisher/sequencer-publisher.ts +542 -460
- package/src/sequencer/README.md +162 -450
- package/src/sequencer/automine/README.md +46 -0
- package/src/sequencer/automine/automine_factory.ts +145 -0
- package/src/sequencer/automine/automine_sequencer.ts +595 -0
- package/src/sequencer/chain_state_overrides.ts +162 -0
- package/src/sequencer/checkpoint_proposal_job.ts +1078 -290
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/events.ts +51 -2
- package/src/sequencer/index.ts +2 -0
- package/src/sequencer/metrics.ts +164 -39
- package/src/sequencer/sequencer.ts +471 -157
- package/src/sequencer/timetable.ts +62 -56
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +2 -4
- package/src/test/mock_checkpoint_builder.ts +65 -53
- package/src/test/utils.ts +31 -10
|
@@ -3,50 +3,101 @@ import { Blob, getBlobsPerL1Block, getPrefixedEthBlobCommitments } from '@aztec/
|
|
|
3
3
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
4
4
|
import type { L1ContractsConfig } from '@aztec/ethereum/config';
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
FeeAssetPriceOracle,
|
|
7
7
|
type GovernanceProposerContract,
|
|
8
|
-
type IEmpireBase,
|
|
9
8
|
MULTI_CALL_3_ADDRESS,
|
|
10
9
|
Multicall3,
|
|
11
|
-
|
|
12
|
-
type
|
|
13
|
-
type
|
|
14
|
-
type
|
|
10
|
+
MulticallForwarderRevertedError,
|
|
11
|
+
type RollupContract,
|
|
12
|
+
type SimulationOverridesPlan,
|
|
13
|
+
type SlashingProposerContract,
|
|
14
|
+
buildSimulationOverridesStateOverride,
|
|
15
15
|
} from '@aztec/ethereum/contracts';
|
|
16
16
|
import { type L1FeeAnalysisResult, L1FeeAnalyzer } from '@aztec/ethereum/l1-fee-analysis';
|
|
17
17
|
import {
|
|
18
18
|
type L1BlobInputs,
|
|
19
19
|
type L1TxConfig,
|
|
20
20
|
type L1TxRequest,
|
|
21
|
+
type L1TxUtils,
|
|
22
|
+
MAX_L1_TX_LIMIT,
|
|
21
23
|
type TransactionStats,
|
|
22
24
|
WEI_CONST,
|
|
23
25
|
} from '@aztec/ethereum/l1-tx-utils';
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
import {
|
|
27
|
+
FormattedViemError,
|
|
28
|
+
formatViemError,
|
|
29
|
+
mergeAbis,
|
|
30
|
+
tryDecodeRevertReason,
|
|
31
|
+
tryExtractEvent,
|
|
32
|
+
} from '@aztec/ethereum/utils';
|
|
28
33
|
import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
34
|
+
import { trimmedBytesLength } from '@aztec/foundation/buffer';
|
|
29
35
|
import { pick } from '@aztec/foundation/collection';
|
|
30
36
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
37
|
+
import { TimeoutError } from '@aztec/foundation/error';
|
|
31
38
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
32
|
-
import { Signature
|
|
39
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
33
40
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
41
|
+
import { InterruptibleSleep } from '@aztec/foundation/sleep';
|
|
34
42
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
35
|
-
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
36
|
-
import { EmpireBaseAbi, ErrorsAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
43
|
+
import { type DateProvider, Timer } from '@aztec/foundation/timer';
|
|
44
|
+
import { EmpireBaseAbi, ErrorsAbi, RollupAbi, SlashingProposerAbi } from '@aztec/l1-artifacts';
|
|
37
45
|
import { type ProposerSlashAction, encodeSlashConsensusVotes } from '@aztec/slasher';
|
|
38
46
|
import { CommitteeAttestationsAndSigners, type ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
39
47
|
import type { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
40
|
-
import {
|
|
48
|
+
import {
|
|
49
|
+
getLastL1SlotTimestampForL2Slot,
|
|
50
|
+
getNextL1SlotTimestamp,
|
|
51
|
+
getTimestampForSlot,
|
|
52
|
+
} from '@aztec/stdlib/epoch-helpers';
|
|
41
53
|
import type { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
42
54
|
import type { L1PublishCheckpointStats } from '@aztec/stdlib/stats';
|
|
43
55
|
import { type TelemetryClient, type Tracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
44
56
|
|
|
45
|
-
import {
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
import {
|
|
58
|
+
type Abi,
|
|
59
|
+
type Hex,
|
|
60
|
+
type TransactionReceipt,
|
|
61
|
+
type TypedDataDefinition,
|
|
62
|
+
encodeFunctionData,
|
|
63
|
+
keccak256,
|
|
64
|
+
toHex,
|
|
65
|
+
} from 'viem';
|
|
66
|
+
|
|
67
|
+
import type { SequencerPublisherConfig } from './config.js';
|
|
68
|
+
import { type FailedL1Tx, type L1TxFailedStore, createL1TxFailedStore } from './l1_tx_failed_store/index.js';
|
|
69
|
+
import { type DroppedRequest, SequencerBundleSimulator } from './sequencer-bundle-simulator.js';
|
|
48
70
|
import { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
|
|
49
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Returns true if the receipt indicates a successful send AND the expected event was emitted
|
|
74
|
+
* by the target contract. Both pieces are required: an aggregate3 entry that reverted will
|
|
75
|
+
* have receipt.status === 'success' but no event log.
|
|
76
|
+
*/
|
|
77
|
+
function extractEventSuccess(
|
|
78
|
+
receipt: TransactionReceipt | undefined,
|
|
79
|
+
opts: { address: string; abi: Abi; eventName: string },
|
|
80
|
+
): boolean {
|
|
81
|
+
if (!receipt || receipt.status !== 'success') {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return !!tryExtractEvent(receipt.logs, opts.address.toString() as Hex, opts.abi, opts.eventName);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Result of a sendRequests call, returned by both sendRequests() and sendRequestsAt(). */
|
|
88
|
+
export type SendRequestsResult = {
|
|
89
|
+
/** The L1 transaction receipt from the bundled multicall. */
|
|
90
|
+
result: { receipt: TransactionReceipt };
|
|
91
|
+
/** Actions that expired (past their deadline) before the request was sent. */
|
|
92
|
+
expiredActions: Action[];
|
|
93
|
+
/** Actions that were included in the sent L1 transaction. */
|
|
94
|
+
sentActions: Action[];
|
|
95
|
+
/** Actions whose L1 simulation succeeded (subset of sentActions). */
|
|
96
|
+
successfulActions: Action[];
|
|
97
|
+
/** Actions whose L1 simulation failed (subset of sentActions). */
|
|
98
|
+
failedActions: Action[];
|
|
99
|
+
};
|
|
100
|
+
|
|
50
101
|
/** Arguments to the process method of the rollup contract */
|
|
51
102
|
type L1ProcessArgs = {
|
|
52
103
|
/** The L2 block header. */
|
|
@@ -59,6 +110,8 @@ type L1ProcessArgs = {
|
|
|
59
110
|
attestationsAndSigners: CommitteeAttestationsAndSigners;
|
|
60
111
|
/** Attestations and signers signature */
|
|
61
112
|
attestationsAndSignersSignature: Signature;
|
|
113
|
+
/** The fee asset price modifier in basis points (from oracle) */
|
|
114
|
+
feeAssetPriceModifier: bigint;
|
|
62
115
|
};
|
|
63
116
|
|
|
64
117
|
export const Actions = [
|
|
@@ -66,16 +119,13 @@ export const Actions = [
|
|
|
66
119
|
'invalidate-by-insufficient-attestations',
|
|
67
120
|
'propose',
|
|
68
121
|
'governance-signal',
|
|
69
|
-
'empire-slashing-signal',
|
|
70
|
-
'create-empire-payload',
|
|
71
|
-
'execute-empire-payload',
|
|
72
122
|
'vote-offenses',
|
|
73
123
|
'execute-slash',
|
|
74
124
|
] as const;
|
|
75
125
|
|
|
76
126
|
export type Action = (typeof Actions)[number];
|
|
77
127
|
|
|
78
|
-
type GovernanceSignalAction = Extract<Action, 'governance-signal'
|
|
128
|
+
type GovernanceSignalAction = Extract<Action, 'governance-signal'>;
|
|
79
129
|
|
|
80
130
|
// Sorting for actions such that invalidations go before proposals, and proposals go before votes
|
|
81
131
|
export const compareActions = (a: Action, b: Action) => Actions.indexOf(a) - Actions.indexOf(b);
|
|
@@ -86,14 +136,22 @@ export type InvalidateCheckpointRequest = {
|
|
|
86
136
|
gasUsed: bigint;
|
|
87
137
|
checkpointNumber: CheckpointNumber;
|
|
88
138
|
forcePendingCheckpointNumber: CheckpointNumber;
|
|
139
|
+
/** Archive at the rollback target checkpoint (checkpoint N-1). */
|
|
140
|
+
lastArchive: Fr;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
type EnqueueProposeCheckpointOpts = {
|
|
144
|
+
txTimeoutAt?: Date;
|
|
89
145
|
};
|
|
90
146
|
|
|
91
|
-
interface RequestWithExpiry {
|
|
147
|
+
export interface RequestWithExpiry {
|
|
92
148
|
action: Action;
|
|
93
149
|
request: L1TxRequest;
|
|
94
150
|
lastValidL2Slot: SlotNumber;
|
|
95
151
|
gasConfig?: Pick<L1TxConfig, 'txTimeoutAt' | 'gasLimit'>;
|
|
96
152
|
blobConfig?: L1BlobInputs;
|
|
153
|
+
/** Gas consumed by validateBlobs; stashed for the bundle simulate at send time. */
|
|
154
|
+
blobEvaluationGas?: bigint;
|
|
97
155
|
checkSuccess: (
|
|
98
156
|
request: L1TxRequest,
|
|
99
157
|
result?: { receipt: TransactionReceipt; stats?: TransactionStats; errorMsg?: string },
|
|
@@ -103,74 +161,82 @@ interface RequestWithExpiry {
|
|
|
103
161
|
export class SequencerPublisher {
|
|
104
162
|
private interrupted = false;
|
|
105
163
|
private metrics: SequencerPublisherMetrics;
|
|
164
|
+
private bundleSimulator: SequencerBundleSimulator;
|
|
106
165
|
public epochCache: EpochCache;
|
|
166
|
+
private failedTxStore?: Promise<L1TxFailedStore | undefined>;
|
|
107
167
|
|
|
108
|
-
|
|
109
|
-
|
|
168
|
+
/**
|
|
169
|
+
* ABI used to decode raw revert payloads from dropped bundle entries when the original
|
|
170
|
+
* request did not carry an abi (e.g. the propose request). Merges every contract the
|
|
171
|
+
* publisher can route to so any of their custom errors decode against it.
|
|
172
|
+
*/
|
|
173
|
+
private readonly revertDecoderAbi: Abi = mergeAbis([RollupAbi, SlashingProposerAbi, EmpireBaseAbi, ErrorsAbi]);
|
|
110
174
|
|
|
111
175
|
protected lastActions: Partial<Record<Action, SlotNumber>> = {};
|
|
112
176
|
|
|
113
|
-
private isPayloadEmptyCache: Map<string, boolean> = new Map<string, boolean>();
|
|
114
|
-
|
|
115
177
|
protected log: Logger;
|
|
116
178
|
protected ethereumSlotDuration: bigint;
|
|
179
|
+
protected aztecSlotDuration: bigint;
|
|
180
|
+
|
|
181
|
+
/** Date provider for wall-clock time. */
|
|
182
|
+
private readonly dateProvider: DateProvider;
|
|
117
183
|
|
|
118
184
|
private blobClient: BlobClientInterface;
|
|
119
185
|
|
|
120
|
-
/**
|
|
121
|
-
private
|
|
186
|
+
/** Optional callback to obtain a replacement publisher when the current one fails to send. */
|
|
187
|
+
private getNextPublisher?: (excludeAddresses: EthAddress[]) => Promise<L1TxUtils | undefined>;
|
|
122
188
|
|
|
123
189
|
/** L1 fee analyzer for fisherman mode */
|
|
124
190
|
private l1FeeAnalyzer?: L1FeeAnalyzer;
|
|
125
|
-
// @note - with blobs, the below estimate seems too large.
|
|
126
|
-
// Total used for full block from int_l1_pub e2e test: 1m (of which 86k is 1x blob)
|
|
127
|
-
// Total used for emptier block from above test: 429k (of which 84k is 1x blob)
|
|
128
|
-
public static PROPOSE_GAS_GUESS: bigint = 12_000_000n;
|
|
129
191
|
|
|
130
|
-
|
|
131
|
-
|
|
192
|
+
/** Fee asset price oracle for computing price modifiers from Uniswap V4 */
|
|
193
|
+
private feeAssetPriceOracle: FeeAssetPriceOracle;
|
|
132
194
|
|
|
133
|
-
|
|
134
|
-
|
|
195
|
+
/** Interruptible sleep used by sendRequestsAt to wait until a target timestamp. */
|
|
196
|
+
private readonly interruptibleSleep = new InterruptibleSleep();
|
|
135
197
|
|
|
136
|
-
public l1TxUtils:
|
|
198
|
+
public l1TxUtils: L1TxUtils;
|
|
137
199
|
public rollupContract: RollupContract;
|
|
138
200
|
public govProposerContract: GovernanceProposerContract;
|
|
139
|
-
public slashingProposerContract:
|
|
140
|
-
public slashFactoryContract: SlashFactoryContract;
|
|
201
|
+
public slashingProposerContract: SlashingProposerContract | undefined;
|
|
141
202
|
|
|
142
203
|
public readonly tracer: Tracer;
|
|
143
204
|
|
|
144
205
|
protected requests: RequestWithExpiry[] = [];
|
|
145
206
|
|
|
146
207
|
constructor(
|
|
147
|
-
private config:
|
|
208
|
+
private config: Pick<SequencerPublisherConfig, 'fishermanMode' | 'l1TxFailedStore'> &
|
|
209
|
+
Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration'> & { l1ChainId: number },
|
|
148
210
|
deps: {
|
|
149
211
|
telemetry?: TelemetryClient;
|
|
150
212
|
blobClient: BlobClientInterface;
|
|
151
|
-
l1TxUtils:
|
|
213
|
+
l1TxUtils: L1TxUtils;
|
|
152
214
|
rollupContract: RollupContract;
|
|
153
|
-
slashingProposerContract:
|
|
215
|
+
slashingProposerContract: SlashingProposerContract | undefined;
|
|
154
216
|
governanceProposerContract: GovernanceProposerContract;
|
|
155
|
-
slashFactoryContract: SlashFactoryContract;
|
|
156
217
|
epochCache: EpochCache;
|
|
157
218
|
dateProvider: DateProvider;
|
|
158
219
|
metrics: SequencerPublisherMetrics;
|
|
159
220
|
lastActions: Partial<Record<Action, SlotNumber>>;
|
|
160
221
|
log?: Logger;
|
|
222
|
+
getNextPublisher?: (excludeAddresses: EthAddress[]) => Promise<L1TxUtils | undefined>;
|
|
161
223
|
},
|
|
162
224
|
) {
|
|
163
225
|
this.log = deps.log ?? createLogger('sequencer:publisher');
|
|
164
226
|
this.ethereumSlotDuration = BigInt(config.ethereumSlotDuration);
|
|
227
|
+
this.aztecSlotDuration = BigInt(config.aztecSlotDuration);
|
|
228
|
+
this.dateProvider = deps.dateProvider;
|
|
165
229
|
this.epochCache = deps.epochCache;
|
|
166
230
|
this.lastActions = deps.lastActions;
|
|
167
231
|
|
|
168
232
|
this.blobClient = deps.blobClient;
|
|
233
|
+
this.dateProvider = deps.dateProvider;
|
|
169
234
|
|
|
170
235
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
171
236
|
this.metrics = deps.metrics ?? new SequencerPublisherMetrics(telemetry, 'SequencerPublisher');
|
|
172
237
|
this.tracer = telemetry.getTracer('SequencerPublisher');
|
|
173
238
|
this.l1TxUtils = deps.l1TxUtils;
|
|
239
|
+
this.getNextPublisher = deps.getNextPublisher;
|
|
174
240
|
|
|
175
241
|
this.rollupContract = deps.rollupContract;
|
|
176
242
|
|
|
@@ -182,22 +248,71 @@ export class SequencerPublisher {
|
|
|
182
248
|
const newSlashingProposer = await this.rollupContract.getSlashingProposer();
|
|
183
249
|
this.slashingProposerContract = newSlashingProposer;
|
|
184
250
|
});
|
|
185
|
-
this.slashFactoryContract = deps.slashFactoryContract;
|
|
186
|
-
|
|
187
251
|
// Initialize L1 fee analyzer for fisherman mode
|
|
188
252
|
if (config.fishermanMode) {
|
|
189
253
|
this.l1FeeAnalyzer = new L1FeeAnalyzer(
|
|
190
254
|
this.l1TxUtils.client,
|
|
191
255
|
deps.dateProvider,
|
|
192
|
-
|
|
256
|
+
this.log.createChild('fee-analyzer'),
|
|
193
257
|
);
|
|
194
258
|
}
|
|
259
|
+
|
|
260
|
+
// Initialize fee asset price oracle
|
|
261
|
+
this.feeAssetPriceOracle = new FeeAssetPriceOracle(
|
|
262
|
+
this.l1TxUtils.client,
|
|
263
|
+
this.rollupContract,
|
|
264
|
+
this.log.createChild('price-oracle'),
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
// Initialize failed L1 tx store (optional, for test networks)
|
|
268
|
+
this.failedTxStore = createL1TxFailedStore(config.l1TxFailedStore, this.log);
|
|
269
|
+
|
|
270
|
+
this.bundleSimulator = new SequencerBundleSimulator({
|
|
271
|
+
getL1TxUtils: () => this.l1TxUtils,
|
|
272
|
+
rollupContract: this.rollupContract,
|
|
273
|
+
epochCache: this.epochCache,
|
|
274
|
+
log: this.log.createChild('bundle-simulator'),
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Backs up a failed L1 transaction to the configured store for debugging.
|
|
280
|
+
* Does nothing if no store is configured.
|
|
281
|
+
*/
|
|
282
|
+
private backupFailedTx(failedTx: Omit<FailedL1Tx, 'timestamp'>): void {
|
|
283
|
+
if (!this.failedTxStore) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const tx: FailedL1Tx = {
|
|
288
|
+
...failedTx,
|
|
289
|
+
timestamp: Date.now(),
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// Fire and forget - don't block on backup
|
|
293
|
+
void this.failedTxStore
|
|
294
|
+
.then(store => store?.saveFailedTx(tx))
|
|
295
|
+
.catch(err => {
|
|
296
|
+
this.log.warn(`Failed to backup failed L1 tx to store`, err);
|
|
297
|
+
});
|
|
195
298
|
}
|
|
196
299
|
|
|
197
300
|
public getRollupContract(): RollupContract {
|
|
198
301
|
return this.rollupContract;
|
|
199
302
|
}
|
|
200
303
|
|
|
304
|
+
/**
|
|
305
|
+
* Gets the fee asset price modifier from the oracle.
|
|
306
|
+
*
|
|
307
|
+
* @param predictedParentEthPerFeeAssetE12 - Optional predicted parent eth-per-fee-asset (E12).
|
|
308
|
+
* Pipelined proposers should pass the value from the predicted parent fee header so the
|
|
309
|
+
* modifier matches the parent L1 will use when applying it.
|
|
310
|
+
* @returns The fee asset price modifier in basis points, or 0n if the oracle query fails.
|
|
311
|
+
*/
|
|
312
|
+
public getFeeAssetPriceModifier(predictedParentEthPerFeeAssetE12?: bigint): Promise<bigint> {
|
|
313
|
+
return this.feeAssetPriceOracle.computePriceModifier(predictedParentEthPerFeeAssetE12);
|
|
314
|
+
}
|
|
315
|
+
|
|
201
316
|
public getSenderAddress() {
|
|
202
317
|
return this.l1TxUtils.getSenderAddress();
|
|
203
318
|
}
|
|
@@ -209,20 +324,12 @@ export class SequencerPublisher {
|
|
|
209
324
|
return this.l1FeeAnalyzer;
|
|
210
325
|
}
|
|
211
326
|
|
|
212
|
-
/**
|
|
213
|
-
* Sets the proposer address to use for simulations in fisherman mode.
|
|
214
|
-
* @param proposerAddress - The actual proposer's address to use for balance lookups in simulations
|
|
215
|
-
*/
|
|
216
|
-
public setProposerAddressForSimulation(proposerAddress: EthAddress | undefined) {
|
|
217
|
-
this.proposerAddressForSimulation = proposerAddress;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
327
|
public addRequest(request: RequestWithExpiry) {
|
|
221
328
|
this.requests.push(request);
|
|
222
329
|
}
|
|
223
330
|
|
|
224
331
|
public getCurrentL2Slot(): SlotNumber {
|
|
225
|
-
return this.epochCache.
|
|
332
|
+
return this.epochCache.getSlotNow();
|
|
226
333
|
}
|
|
227
334
|
|
|
228
335
|
/**
|
|
@@ -273,7 +380,7 @@ export class SequencerPublisher {
|
|
|
273
380
|
// Start the analysis
|
|
274
381
|
const analysisId = await this.l1FeeAnalyzer.startAnalysis(
|
|
275
382
|
l2SlotNumber,
|
|
276
|
-
gasLimit > 0n ? gasLimit :
|
|
383
|
+
gasLimit > 0n ? gasLimit : MAX_L1_TX_LIMIT,
|
|
277
384
|
l1Requests,
|
|
278
385
|
blobConfig,
|
|
279
386
|
onComplete,
|
|
@@ -294,22 +401,26 @@ export class SequencerPublisher {
|
|
|
294
401
|
|
|
295
402
|
/**
|
|
296
403
|
* Sends all requests that are still valid.
|
|
404
|
+
* @param targetSlot - The target L2 slot for this send. When provided (the production path, via
|
|
405
|
+
* sendRequestsAt), it is threaded into bundleSimulate so the block.timestamp override matches
|
|
406
|
+
* the slot the propose is built for. When omitted, falls back to getCurrentL2Slot() for the
|
|
407
|
+
* AutomineSequencer, which publishes synchronously within the current slot.
|
|
297
408
|
* @returns one of:
|
|
298
409
|
* - A receipt and stats if the tx succeeded
|
|
299
410
|
* - a receipt and errorMsg if it failed on L1
|
|
300
411
|
* - undefined if no valid requests are found OR the tx failed to send.
|
|
301
412
|
*/
|
|
302
413
|
@trackSpan('SequencerPublisher.sendRequests')
|
|
303
|
-
public async sendRequests() {
|
|
414
|
+
public async sendRequests(targetSlot?: SlotNumber): Promise<SendRequestsResult | undefined> {
|
|
304
415
|
const requestsToProcess = [...this.requests];
|
|
305
416
|
this.requests = [];
|
|
417
|
+
|
|
306
418
|
if (this.interrupted || requestsToProcess.length === 0) {
|
|
307
419
|
return undefined;
|
|
308
420
|
}
|
|
309
|
-
const currentL2Slot = this.getCurrentL2Slot();
|
|
421
|
+
const currentL2Slot = targetSlot ?? this.getCurrentL2Slot();
|
|
310
422
|
this.log.debug(`Sending requests on L2 slot ${currentL2Slot}`);
|
|
311
423
|
const validRequests = requestsToProcess.filter(request => request.lastValidL2Slot >= currentL2Slot);
|
|
312
|
-
const validActions = validRequests.map(x => x.action);
|
|
313
424
|
const expiredActions = requestsToProcess
|
|
314
425
|
.filter(request => request.lastValidL2Slot < currentL2Slot)
|
|
315
426
|
.map(x => x.action);
|
|
@@ -332,44 +443,58 @@ export class SequencerPublisher {
|
|
|
332
443
|
return undefined;
|
|
333
444
|
}
|
|
334
445
|
|
|
335
|
-
//
|
|
336
|
-
|
|
337
|
-
// See https://github.com/AztecProtocol/aztec-packages/issues/11513
|
|
338
|
-
const gasConfigs = requestsToProcess.filter(request => request.gasConfig).map(request => request.gasConfig);
|
|
339
|
-
const blobConfigs = requestsToProcess.filter(request => request.blobConfig).map(request => request.blobConfig);
|
|
340
|
-
|
|
341
|
-
if (blobConfigs.length > 1) {
|
|
342
|
-
throw new Error('Multiple blob configs found');
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const blobConfig = blobConfigs[0];
|
|
346
|
-
|
|
347
|
-
// Merge gasConfigs. Yields the sum of gasLimits, and the earliest txTimeoutAt, or undefined if no gasConfig sets them.
|
|
348
|
-
const gasLimits = gasConfigs.map(g => g?.gasLimit).filter((g): g is bigint => g !== undefined);
|
|
349
|
-
const gasLimit = gasLimits.length > 0 ? sumBigint(gasLimits) : undefined; // sum
|
|
446
|
+
// Collect earliest txTimeoutAt across all requests.
|
|
447
|
+
const gasConfigs = validRequests.filter(request => request.gasConfig).map(request => request.gasConfig);
|
|
350
448
|
const txTimeoutAts = gasConfigs.map(g => g?.txTimeoutAt).filter((g): g is Date => g !== undefined);
|
|
351
|
-
const txTimeoutAt = txTimeoutAts.length > 0 ? new Date(Math.min(...txTimeoutAts.map(g => g.getTime()))) : undefined;
|
|
352
|
-
const txConfig: RequestWithExpiry['gasConfig'] = { gasLimit, txTimeoutAt };
|
|
449
|
+
const txTimeoutAt = txTimeoutAts.length > 0 ? new Date(Math.min(...txTimeoutAts.map(g => g.getTime()))) : undefined;
|
|
353
450
|
|
|
354
451
|
// Sort the requests so that proposals always go first
|
|
355
452
|
// This ensures the committee gets precomputed correctly
|
|
356
453
|
validRequests.sort((a, b) => compareActions(a.action, b.action));
|
|
357
454
|
|
|
358
455
|
try {
|
|
456
|
+
// Bundle-level eth_simulateV1: filters out entries that revert and derives the gasLimit.
|
|
457
|
+
const bundleResult = await this.bundleSimulator.simulate(validRequests, currentL2Slot);
|
|
458
|
+
|
|
459
|
+
if (bundleResult.kind === 'aborted') {
|
|
460
|
+
this.logDroppedInSim(bundleResult.droppedRequests);
|
|
461
|
+
void this.backupDroppedInSim(bundleResult.droppedRequests);
|
|
462
|
+
return undefined;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const { requests, droppedRequests, gasLimit } =
|
|
466
|
+
bundleResult.kind === 'fallback'
|
|
467
|
+
? {
|
|
468
|
+
requests: bundleResult.requests,
|
|
469
|
+
droppedRequests: bundleResult.droppedRequests,
|
|
470
|
+
gasLimit: MAX_L1_TX_LIMIT,
|
|
471
|
+
}
|
|
472
|
+
: bundleResult;
|
|
473
|
+
|
|
474
|
+
this.logDroppedInSim(droppedRequests);
|
|
475
|
+
|
|
476
|
+
// Compute blobConfig from survivors (not original validRequests) so that if the propose
|
|
477
|
+
// entry was dropped by bundleSimulate we don't attach a blob-typed config to a non-blob tx.
|
|
478
|
+
const [blobConfig] = requests.filter(r => r.blobConfig).map(r => r.blobConfig);
|
|
479
|
+
const txConfig: RequestWithExpiry['gasConfig'] = { gasLimit, txTimeoutAt };
|
|
480
|
+
|
|
359
481
|
this.log.debug('Forwarding transactions', {
|
|
360
|
-
|
|
482
|
+
requests: requests.map(request => request.action),
|
|
361
483
|
txConfig,
|
|
362
484
|
});
|
|
363
|
-
const result = await
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
485
|
+
const result = await this.forwardWithPublisherRotation(requests, txConfig, blobConfig);
|
|
486
|
+
if (result === undefined) {
|
|
487
|
+
return undefined;
|
|
488
|
+
}
|
|
489
|
+
const { successfulActions = [], failedActions = [] } = this.callbackBundledTransactions(requests, result);
|
|
490
|
+
const allFailedActions = [...failedActions, ...droppedRequests.map(d => d.request.action)];
|
|
491
|
+
return {
|
|
492
|
+
result,
|
|
493
|
+
expiredActions,
|
|
494
|
+
sentActions: requests.map(x => x.action),
|
|
495
|
+
successfulActions,
|
|
496
|
+
failedActions: allFailedActions,
|
|
497
|
+
};
|
|
373
498
|
} catch (err) {
|
|
374
499
|
const viemError = formatViemError(err);
|
|
375
500
|
this.log.error(`Failed to publish bundled transactions`, viemError);
|
|
@@ -386,49 +511,195 @@ export class SequencerPublisher {
|
|
|
386
511
|
}
|
|
387
512
|
}
|
|
388
513
|
|
|
514
|
+
/** Logs entries dropped by bundle simulation as warnings on the publisher's logger. */
|
|
515
|
+
private logDroppedInSim(dropped: DroppedRequest[]): void {
|
|
516
|
+
for (const drop of dropped) {
|
|
517
|
+
const revertReasonDecoded = drop.revertReason ?? tryDecodeRevertReason(drop.returnData, this.revertDecoderAbi);
|
|
518
|
+
this.log.warn('Bundle entry dropped: action reverted in sim', {
|
|
519
|
+
action: drop.request.action,
|
|
520
|
+
revertReason: revertReasonDecoded ?? drop.returnData,
|
|
521
|
+
revertReasonDecoded,
|
|
522
|
+
returnData: drop.returnData,
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/** Backs up entries dropped by bundle simulation, one record per dropped action. */
|
|
528
|
+
private async backupDroppedInSim(dropped: DroppedRequest[]): Promise<void> {
|
|
529
|
+
if (dropped.length === 0) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
|
|
533
|
+
for (const { request: req } of dropped) {
|
|
534
|
+
this.backupFailedTx({
|
|
535
|
+
id: keccak256(req.request.data!),
|
|
536
|
+
failureType: 'simulation',
|
|
537
|
+
request: { to: req.request.to! as Hex, data: req.request.data! },
|
|
538
|
+
l1BlockNumber: l1BlockNumber.toString(),
|
|
539
|
+
error: { message: 'Bundle entry dropped: action reverted in sim' },
|
|
540
|
+
context: {
|
|
541
|
+
actions: [req.action],
|
|
542
|
+
sender: this.getSenderAddress().toString(),
|
|
543
|
+
},
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Forwards transactions via Multicall3, rotating to the next available publisher if a send
|
|
550
|
+
* failure occurs (i.e. the tx never reached the chain).
|
|
551
|
+
* On-chain reverts and simulation errors are returned as-is without rotation.
|
|
552
|
+
*/
|
|
553
|
+
private async forwardWithPublisherRotation(
|
|
554
|
+
validRequests: RequestWithExpiry[],
|
|
555
|
+
txConfig: RequestWithExpiry['gasConfig'],
|
|
556
|
+
blobConfig: L1BlobInputs | undefined,
|
|
557
|
+
) {
|
|
558
|
+
if (!txConfig?.gasLimit) {
|
|
559
|
+
throw new Error('gasLimit is required for bundled transactions');
|
|
560
|
+
}
|
|
561
|
+
const txConfigWithGasLimit = txConfig as L1TxConfig & { gasLimit: bigint };
|
|
562
|
+
|
|
563
|
+
const triedAddresses: EthAddress[] = [];
|
|
564
|
+
let currentPublisher = this.l1TxUtils;
|
|
565
|
+
|
|
566
|
+
while (true) {
|
|
567
|
+
if (txConfig.txTimeoutAt && new Date() > txConfig.txTimeoutAt) {
|
|
568
|
+
this.log.warn(`Tx timeout (${txConfig.txTimeoutAt.toISOString()}) elapsed; stopping publisher rotation`, {
|
|
569
|
+
triedAddresses: triedAddresses.map(a => a.toString()),
|
|
570
|
+
});
|
|
571
|
+
return undefined;
|
|
572
|
+
}
|
|
573
|
+
triedAddresses.push(currentPublisher.getSenderAddress());
|
|
574
|
+
|
|
575
|
+
try {
|
|
576
|
+
const result = await Multicall3.forward(
|
|
577
|
+
validRequests.map(r => r.request),
|
|
578
|
+
currentPublisher,
|
|
579
|
+
txConfigWithGasLimit,
|
|
580
|
+
blobConfig,
|
|
581
|
+
{ gasLimitRequired: true },
|
|
582
|
+
);
|
|
583
|
+
this.l1TxUtils = currentPublisher;
|
|
584
|
+
return result;
|
|
585
|
+
} catch (err) {
|
|
586
|
+
if (err instanceof TimeoutError) {
|
|
587
|
+
throw err;
|
|
588
|
+
}
|
|
589
|
+
if (err instanceof MulticallForwarderRevertedError) {
|
|
590
|
+
this.log.error('Forwarder transaction reverted on-chain; not rotating publisher', err, {
|
|
591
|
+
transactionHash: err.receipt.transactionHash,
|
|
592
|
+
});
|
|
593
|
+
return undefined;
|
|
594
|
+
}
|
|
595
|
+
const viemError = formatViemError(err);
|
|
596
|
+
if (!this.getNextPublisher) {
|
|
597
|
+
this.log.error('Failed to publish bundled transactions', viemError);
|
|
598
|
+
return undefined;
|
|
599
|
+
}
|
|
600
|
+
this.log.warn(
|
|
601
|
+
`Publisher ${currentPublisher.getSenderAddress()} failed to send, rotating to next publisher`,
|
|
602
|
+
viemError,
|
|
603
|
+
);
|
|
604
|
+
const nextPublisher = await this.getNextPublisher([...triedAddresses]);
|
|
605
|
+
if (!nextPublisher) {
|
|
606
|
+
this.log.error(
|
|
607
|
+
`All available publishers exhausted (tried ${triedAddresses.length}), failed to publish bundled transactions`,
|
|
608
|
+
viemError,
|
|
609
|
+
{ triedAddresses: triedAddresses.map(a => a.toString()) },
|
|
610
|
+
);
|
|
611
|
+
return undefined;
|
|
612
|
+
}
|
|
613
|
+
currentPublisher = nextPublisher;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/*
|
|
619
|
+
* Schedules sending all enqueued requests at (or after) the start of the given L2 slot.
|
|
620
|
+
* Sleeps until one L1 slot before the L2 slot boundary so the tx has a chance of being
|
|
621
|
+
* picked up by the first L1 block of the L2 slot.
|
|
622
|
+
* NB: there is a known correctness risk — being included in the L1 block right before the
|
|
623
|
+
* L2 slot starts would revert propose with HeaderLib__InvalidSlotNumber.
|
|
624
|
+
* Uses InterruptibleSleep so it can be cancelled via interrupt().
|
|
625
|
+
*/
|
|
626
|
+
public async sendRequestsAt(targetSlot: SlotNumber): Promise<SendRequestsResult | undefined> {
|
|
627
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
628
|
+
// Start of the target L2 slot, in ms (getTimestampForSlot returns seconds).
|
|
629
|
+
const startOfTargetSlotMs = Number(getTimestampForSlot(targetSlot, l1Constants)) * 1000;
|
|
630
|
+
// Aim to be in the mempool one L1 slot before the L2 slot starts, so we have a chance of
|
|
631
|
+
// being picked up by the first L1 block of the L2 slot.
|
|
632
|
+
const submitAfterMs = startOfTargetSlotMs - Number(this.ethereumSlotDuration) * 1000;
|
|
633
|
+
if (this.interrupted) {
|
|
634
|
+
return undefined;
|
|
635
|
+
}
|
|
636
|
+
const sleepMs = submitAfterMs - this.dateProvider.now();
|
|
637
|
+
if (sleepMs > 0) {
|
|
638
|
+
this.log.debug(`Sleeping ${sleepMs}ms before sending requests`, {
|
|
639
|
+
targetSlot,
|
|
640
|
+
submitAfterMs,
|
|
641
|
+
});
|
|
642
|
+
await this.interruptibleSleep.sleep(sleepMs);
|
|
643
|
+
}
|
|
644
|
+
if (this.interrupted) {
|
|
645
|
+
return undefined;
|
|
646
|
+
}
|
|
647
|
+
return this.sendRequests(targetSlot);
|
|
648
|
+
}
|
|
649
|
+
|
|
389
650
|
private callbackBundledTransactions(
|
|
390
651
|
requests: RequestWithExpiry[],
|
|
391
|
-
result
|
|
652
|
+
result: { receipt: TransactionReceipt; multicallData: Hex },
|
|
392
653
|
) {
|
|
393
654
|
const actionsListStr = requests.map(r => r.action).join(', ');
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
655
|
+
this.log.verbose(`Published bundled transactions (${actionsListStr})`, {
|
|
656
|
+
result,
|
|
657
|
+
requests: requests.map(r => ({
|
|
658
|
+
...r,
|
|
659
|
+
// Avoid logging large blob data
|
|
660
|
+
blobConfig: r.blobConfig
|
|
661
|
+
? { ...r.blobConfig, blobs: r.blobConfig.blobs.map(b => ({ size: trimmedBytesLength(b) })) }
|
|
662
|
+
: undefined,
|
|
663
|
+
})),
|
|
664
|
+
});
|
|
665
|
+
const successfulActions: Action[] = [];
|
|
666
|
+
const failedActions: Action[] = [];
|
|
667
|
+
for (const request of requests) {
|
|
668
|
+
if (request.checkSuccess(request.request, result)) {
|
|
669
|
+
successfulActions.push(request.action);
|
|
670
|
+
} else {
|
|
671
|
+
failedActions.push(request.action);
|
|
407
672
|
}
|
|
408
|
-
return { successfulActions, failedActions };
|
|
409
673
|
}
|
|
674
|
+
return { successfulActions, failedActions };
|
|
410
675
|
}
|
|
411
676
|
|
|
412
677
|
/**
|
|
413
|
-
* @notice Will call `
|
|
678
|
+
* @notice Will call `canProposeAt` to make sure that it is possible to propose
|
|
414
679
|
* @param tipArchive - The archive to check
|
|
415
680
|
* @returns The slot and block number if it is possible to propose, undefined otherwise
|
|
416
681
|
*/
|
|
417
|
-
public
|
|
418
|
-
tipArchive: Fr,
|
|
419
|
-
msgSender: EthAddress,
|
|
420
|
-
opts: { forcePendingCheckpointNumber?: CheckpointNumber } = {},
|
|
421
|
-
) {
|
|
682
|
+
public async canProposeAt(tipArchive: Fr, msgSender: EthAddress, simulationOverridesPlan?: SimulationOverridesPlan) {
|
|
422
683
|
// TODO: #14291 - should loop through multiple keys to check if any of them can propose
|
|
423
|
-
|
|
684
|
+
// These errors are expected when we cannot actually propose right now — usually because our
|
|
685
|
+
// local view of the chain is ahead of L1 (proposed parent hasn't landed yet, or someone
|
|
686
|
+
// else has just landed the slot, or the archive override doesn't match). We log a warn and
|
|
687
|
+
// skip the proposal; we do NOT treat these as bugs.
|
|
688
|
+
const expectedErrors = ['SlotAlreadyInChain', 'InvalidProposer', 'InvalidArchive'];
|
|
689
|
+
|
|
690
|
+
const slotOffset = this.aztecSlotDuration;
|
|
691
|
+
const nextL1SlotTs = this.getNextL1SlotTimestamp() + slotOffset;
|
|
424
692
|
|
|
425
693
|
return this.rollupContract
|
|
426
|
-
.
|
|
427
|
-
|
|
428
|
-
|
|
694
|
+
.canProposeAt(
|
|
695
|
+
tipArchive.toBuffer(),
|
|
696
|
+
msgSender.toString(),
|
|
697
|
+
nextL1SlotTs,
|
|
698
|
+
await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan),
|
|
699
|
+
)
|
|
429
700
|
.catch(err => {
|
|
430
|
-
if (err instanceof FormattedViemError &&
|
|
431
|
-
this.log.warn(`Failed canProposeAtTime check with ${
|
|
701
|
+
if (err instanceof FormattedViemError && expectedErrors.find(e => err.message.includes(e))) {
|
|
702
|
+
this.log.warn(`Failed canProposeAtTime check with ${expectedErrors.find(e => err.message.includes(e))}`, {
|
|
432
703
|
error: err.message,
|
|
433
704
|
});
|
|
434
705
|
} else {
|
|
@@ -437,6 +708,7 @@ export class SequencerPublisher {
|
|
|
437
708
|
return undefined;
|
|
438
709
|
});
|
|
439
710
|
}
|
|
711
|
+
|
|
440
712
|
/**
|
|
441
713
|
* @notice Will simulate `validateHeader` to make sure that the block header is valid
|
|
442
714
|
* @dev This is a convenience function that can be used by the sequencer to validate a "partial" header.
|
|
@@ -446,13 +718,13 @@ export class SequencerPublisher {
|
|
|
446
718
|
@trackSpan('SequencerPublisher.validateBlockHeader')
|
|
447
719
|
public async validateBlockHeader(
|
|
448
720
|
header: CheckpointHeader,
|
|
449
|
-
|
|
721
|
+
simulationOverridesPlan?: SimulationOverridesPlan,
|
|
450
722
|
): Promise<void> {
|
|
451
723
|
const flags = { ignoreDA: true, ignoreSignatures: true };
|
|
452
724
|
|
|
453
725
|
const args = [
|
|
454
726
|
header.toViem(),
|
|
455
|
-
CommitteeAttestationsAndSigners.
|
|
727
|
+
CommitteeAttestationsAndSigners.packAttestations([]),
|
|
456
728
|
[], // no signers
|
|
457
729
|
Signature.empty().toViemSignature(),
|
|
458
730
|
`0x${'0'.repeat(64)}`, // 32 empty bytes
|
|
@@ -460,10 +732,9 @@ export class SequencerPublisher {
|
|
|
460
732
|
flags,
|
|
461
733
|
] as const;
|
|
462
734
|
|
|
463
|
-
const
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
);
|
|
735
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
736
|
+
const ts = getLastL1SlotTimestampForL2Slot(header.slotNumber, l1Constants);
|
|
737
|
+
const stateOverrides = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
|
|
467
738
|
let balance = 0n;
|
|
468
739
|
if (this.config.fishermanMode) {
|
|
469
740
|
// In fisherman mode, we can't know where the proposer is publishing from
|
|
@@ -483,7 +754,7 @@ export class SequencerPublisher {
|
|
|
483
754
|
data: encodeFunctionData({ abi: RollupAbi, functionName: 'validateHeaderWithAttestations', args }),
|
|
484
755
|
from: MULTI_CALL_3_ADDRESS,
|
|
485
756
|
},
|
|
486
|
-
{ time: ts
|
|
757
|
+
{ time: ts },
|
|
487
758
|
stateOverrides,
|
|
488
759
|
);
|
|
489
760
|
this.log.debug(`Simulated validateHeader`);
|
|
@@ -516,8 +787,15 @@ export class SequencerPublisher {
|
|
|
516
787
|
const request = this.buildInvalidateCheckpointRequest(validationResult);
|
|
517
788
|
this.log.debug(`Simulating invalidate checkpoint ${checkpointNumber}`, { ...logData, request });
|
|
518
789
|
|
|
790
|
+
const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
|
|
791
|
+
|
|
519
792
|
try {
|
|
520
|
-
const { gasUsed } = await this.l1TxUtils.simulate(
|
|
793
|
+
const { gasUsed } = await this.l1TxUtils.simulate(
|
|
794
|
+
request,
|
|
795
|
+
undefined,
|
|
796
|
+
undefined,
|
|
797
|
+
mergeAbis([request.abi ?? [], ErrorsAbi]),
|
|
798
|
+
);
|
|
521
799
|
this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} succeeded`, {
|
|
522
800
|
...logData,
|
|
523
801
|
request,
|
|
@@ -529,6 +807,7 @@ export class SequencerPublisher {
|
|
|
529
807
|
gasUsed,
|
|
530
808
|
checkpointNumber,
|
|
531
809
|
forcePendingCheckpointNumber: CheckpointNumber(checkpointNumber - 1),
|
|
810
|
+
lastArchive: validationResult.checkpoint.lastArchive,
|
|
532
811
|
reason,
|
|
533
812
|
};
|
|
534
813
|
} catch (err) {
|
|
@@ -536,13 +815,13 @@ export class SequencerPublisher {
|
|
|
536
815
|
|
|
537
816
|
// If the error is due to the checkpoint not being in the pending chain, and it was indeed removed by someone else,
|
|
538
817
|
// we can safely ignore it and return undefined so we go ahead with checkpoint building.
|
|
539
|
-
if (viemError.message?.includes('
|
|
818
|
+
if (viemError.message?.includes('Rollup__CheckpointNotInPendingChain')) {
|
|
540
819
|
this.log.verbose(
|
|
541
820
|
`Simulation for invalidate checkpoint ${checkpointNumber} failed due to checkpoint not being in pending chain`,
|
|
542
821
|
{ ...logData, request, error: viemError.message },
|
|
543
822
|
);
|
|
544
|
-
const
|
|
545
|
-
if (
|
|
823
|
+
const latestProposedCheckpointNumber = await this.rollupContract.getCheckpointNumber();
|
|
824
|
+
if (latestProposedCheckpointNumber < checkpointNumber) {
|
|
546
825
|
this.log.verbose(`Checkpoint ${checkpointNumber} has already been invalidated`, { ...logData });
|
|
547
826
|
return undefined;
|
|
548
827
|
} else {
|
|
@@ -562,6 +841,18 @@ export class SequencerPublisher {
|
|
|
562
841
|
|
|
563
842
|
// Otherwise, throw. We cannot build the next checkpoint if we cannot invalidate the previous one.
|
|
564
843
|
this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed`, viemError, logData);
|
|
844
|
+
this.backupFailedTx({
|
|
845
|
+
id: keccak256(request.data!),
|
|
846
|
+
failureType: 'simulation',
|
|
847
|
+
request: { to: request.to!, data: request.data!, value: request.value?.toString() },
|
|
848
|
+
l1BlockNumber: l1BlockNumber.toString(),
|
|
849
|
+
error: { message: viemError.message, name: viemError.name },
|
|
850
|
+
context: {
|
|
851
|
+
actions: [`invalidate-${reason}`],
|
|
852
|
+
checkpointNumber,
|
|
853
|
+
sender: this.getSenderAddress().toString(),
|
|
854
|
+
},
|
|
855
|
+
});
|
|
565
856
|
throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber}`, { cause: viemError });
|
|
566
857
|
}
|
|
567
858
|
}
|
|
@@ -575,9 +866,7 @@ export class SequencerPublisher {
|
|
|
575
866
|
const logData = { ...checkpoint, reason };
|
|
576
867
|
this.log.debug(`Building invalidate checkpoint ${checkpoint.checkpointNumber} request`, logData);
|
|
577
868
|
|
|
578
|
-
const attestationsAndSigners =
|
|
579
|
-
validationResult.attestations,
|
|
580
|
-
).getPackedAttestations();
|
|
869
|
+
const attestationsAndSigners = CommitteeAttestationsAndSigners.packAttestations(validationResult.attestations);
|
|
581
870
|
|
|
582
871
|
if (reason === 'invalid-attestation') {
|
|
583
872
|
return this.rollupContract.buildInvalidateBadAttestationRequest(
|
|
@@ -598,59 +887,11 @@ export class SequencerPublisher {
|
|
|
598
887
|
}
|
|
599
888
|
}
|
|
600
889
|
|
|
601
|
-
/** Simulates `propose` to make sure that the checkpoint is valid for submission */
|
|
602
|
-
@trackSpan('SequencerPublisher.validateCheckpointForSubmission')
|
|
603
|
-
public async validateCheckpointForSubmission(
|
|
604
|
-
checkpoint: Checkpoint,
|
|
605
|
-
attestationsAndSigners: CommitteeAttestationsAndSigners,
|
|
606
|
-
attestationsAndSignersSignature: Signature,
|
|
607
|
-
options: { forcePendingCheckpointNumber?: CheckpointNumber },
|
|
608
|
-
): Promise<bigint> {
|
|
609
|
-
const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
|
|
610
|
-
|
|
611
|
-
// TODO(palla/mbps): This should not be needed, there's no flow where we propose with zero attestations. Or is there?
|
|
612
|
-
// If we have no attestations, we still need to provide the empty attestations
|
|
613
|
-
// so that the committee is recalculated correctly
|
|
614
|
-
// const ignoreSignatures = attestationsAndSigners.attestations.length === 0;
|
|
615
|
-
// if (ignoreSignatures) {
|
|
616
|
-
// const { committee } = await this.epochCache.getCommittee(block.header.globalVariables.slotNumber);
|
|
617
|
-
// if (!committee) {
|
|
618
|
-
// this.log.warn(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
|
|
619
|
-
// throw new Error(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
|
|
620
|
-
// }
|
|
621
|
-
// attestationsAndSigners.attestations = committee.map(committeeMember =>
|
|
622
|
-
// CommitteeAttestation.fromAddress(committeeMember),
|
|
623
|
-
// );
|
|
624
|
-
// }
|
|
625
|
-
|
|
626
|
-
const blobFields = checkpoint.toBlobFields();
|
|
627
|
-
const blobs = getBlobsPerL1Block(blobFields);
|
|
628
|
-
const blobInput = getPrefixedEthBlobCommitments(blobs);
|
|
629
|
-
|
|
630
|
-
const args = [
|
|
631
|
-
{
|
|
632
|
-
header: checkpoint.header.toViem(),
|
|
633
|
-
archive: toHex(checkpoint.archive.root.toBuffer()),
|
|
634
|
-
oracleInput: {
|
|
635
|
-
feeAssetPriceModifier: 0n,
|
|
636
|
-
},
|
|
637
|
-
},
|
|
638
|
-
attestationsAndSigners.getPackedAttestations(),
|
|
639
|
-
attestationsAndSigners.getSigners().map(signer => signer.toString()),
|
|
640
|
-
attestationsAndSignersSignature.toViemSignature(),
|
|
641
|
-
blobInput,
|
|
642
|
-
] as const;
|
|
643
|
-
|
|
644
|
-
await this.simulateProposeTx(args, ts, options);
|
|
645
|
-
return ts;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
890
|
private async enqueueCastSignalHelper(
|
|
649
891
|
slotNumber: SlotNumber,
|
|
650
|
-
timestamp: bigint,
|
|
651
892
|
signalType: GovernanceSignalAction,
|
|
652
893
|
payload: EthAddress,
|
|
653
|
-
base:
|
|
894
|
+
base: GovernanceProposerContract,
|
|
654
895
|
signerAddress: EthAddress,
|
|
655
896
|
signer: (msg: TypedDataDefinition) => Promise<`0x${string}`>,
|
|
656
897
|
): Promise<boolean> {
|
|
@@ -676,11 +917,31 @@ export class SequencerPublisher {
|
|
|
676
917
|
return false;
|
|
677
918
|
}
|
|
678
919
|
|
|
679
|
-
if (await
|
|
920
|
+
if (await base.isPayloadEmpty(payload)) {
|
|
680
921
|
this.log.warn(`Skipping vote cast for payload with empty code`);
|
|
681
922
|
return false;
|
|
682
923
|
}
|
|
683
924
|
|
|
925
|
+
// Skip signaling if there is already a live (non-terminal) Governance proposal for this
|
|
926
|
+
// payload. This is intentionally not cached: a previously-live proposal may transition to
|
|
927
|
+
// a terminal state (Dropped/Rejected/Expired/Executed), at which point we may want to re-signal
|
|
928
|
+
// the same payload in a future round.
|
|
929
|
+
let proposed = false;
|
|
930
|
+
try {
|
|
931
|
+
proposed = await base.hasActiveProposalWithPayload(payload.toString());
|
|
932
|
+
} catch (err) {
|
|
933
|
+
// We deliberately swallow the error and proceed to signal. Failing closed (skipping the
|
|
934
|
+
// signal) on transient RPC errors would let a flaky L1 endpoint silence governance
|
|
935
|
+
// participation entirely; failing open at worst produces a duplicate signal that the
|
|
936
|
+
// contract will simply count alongside others in the round.
|
|
937
|
+
this.log.error(`Failed to check if payload ${payload} was already proposed (signalling anyway)`, err);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
if (proposed) {
|
|
941
|
+
this.log.info(`Payload ${payload} has a live governance proposal, stopping signals`);
|
|
942
|
+
return false;
|
|
943
|
+
}
|
|
944
|
+
|
|
684
945
|
const cachedLastVote = this.lastActions[signalType];
|
|
685
946
|
this.lastActions[signalType] = slotNumber;
|
|
686
947
|
const action = signalType;
|
|
@@ -699,26 +960,19 @@ export class SequencerPublisher {
|
|
|
699
960
|
lastValidL2Slot: slotNumber,
|
|
700
961
|
});
|
|
701
962
|
|
|
702
|
-
try {
|
|
703
|
-
await this.l1TxUtils.simulate(request, { time: timestamp }, [], ErrorsAbi);
|
|
704
|
-
this.log.debug(`Simulation for ${action} at slot ${slotNumber} succeeded`, { request });
|
|
705
|
-
} catch (err) {
|
|
706
|
-
this.log.error(`Failed simulation for ${action} at slot ${slotNumber} (enqueuing the action anyway)`, err);
|
|
707
|
-
// Yes, we enqueue the request anyway, in case there was a bug with the simulation itself
|
|
708
|
-
}
|
|
709
|
-
|
|
710
963
|
// TODO(palla/slash): All votes (governance and slashing) should txTimeoutAt at the end of the slot.
|
|
711
964
|
this.addRequest({
|
|
712
|
-
gasConfig: { gasLimit: SequencerPublisher.VOTE_GAS_GUESS },
|
|
713
965
|
action,
|
|
714
966
|
request,
|
|
715
967
|
lastValidL2Slot: slotNumber,
|
|
716
968
|
checkSuccess: (_request, result) => {
|
|
717
969
|
const success =
|
|
718
970
|
result &&
|
|
719
|
-
result.receipt
|
|
720
|
-
|
|
721
|
-
|
|
971
|
+
extractEventSuccess(result.receipt, {
|
|
972
|
+
address: base.address.toString(),
|
|
973
|
+
abi: EmpireBaseAbi,
|
|
974
|
+
eventName: 'SignalCast',
|
|
975
|
+
});
|
|
722
976
|
|
|
723
977
|
const logData = { ...result, slotNumber, round, payload: payload.toString() };
|
|
724
978
|
if (!success) {
|
|
@@ -740,33 +994,19 @@ export class SequencerPublisher {
|
|
|
740
994
|
return true;
|
|
741
995
|
}
|
|
742
996
|
|
|
743
|
-
private async isPayloadEmpty(payload: EthAddress): Promise<boolean> {
|
|
744
|
-
const key = payload.toString();
|
|
745
|
-
const cached = this.isPayloadEmptyCache.get(key);
|
|
746
|
-
if (cached) {
|
|
747
|
-
return cached;
|
|
748
|
-
}
|
|
749
|
-
const isEmpty = !(await this.l1TxUtils.getCode(payload));
|
|
750
|
-
this.isPayloadEmptyCache.set(key, isEmpty);
|
|
751
|
-
return isEmpty;
|
|
752
|
-
}
|
|
753
|
-
|
|
754
997
|
/**
|
|
755
998
|
* Enqueues a governance castSignal transaction to cast a signal for a given slot number.
|
|
756
999
|
* @param slotNumber - The slot number to cast a signal for.
|
|
757
|
-
* @param timestamp - The timestamp of the slot to cast a signal for.
|
|
758
1000
|
* @returns True if the signal was successfully enqueued, false otherwise.
|
|
759
1001
|
*/
|
|
760
1002
|
public enqueueGovernanceCastSignal(
|
|
761
1003
|
governancePayload: EthAddress,
|
|
762
1004
|
slotNumber: SlotNumber,
|
|
763
|
-
timestamp: bigint,
|
|
764
1005
|
signerAddress: EthAddress,
|
|
765
1006
|
signer: (msg: TypedDataDefinition) => Promise<`0x${string}`>,
|
|
766
1007
|
): Promise<boolean> {
|
|
767
1008
|
return this.enqueueCastSignalHelper(
|
|
768
1009
|
slotNumber,
|
|
769
|
-
timestamp,
|
|
770
1010
|
'governance-signal',
|
|
771
1011
|
governancePayload,
|
|
772
1012
|
this.govProposerContract,
|
|
@@ -779,7 +1019,6 @@ export class SequencerPublisher {
|
|
|
779
1019
|
public async enqueueSlashingActions(
|
|
780
1020
|
actions: ProposerSlashAction[],
|
|
781
1021
|
slotNumber: SlotNumber,
|
|
782
|
-
timestamp: bigint,
|
|
783
1022
|
signerAddress: EthAddress,
|
|
784
1023
|
signer: (msg: TypedDataDefinition) => Promise<`0x${string}`>,
|
|
785
1024
|
): Promise<boolean> {
|
|
@@ -790,58 +1029,6 @@ export class SequencerPublisher {
|
|
|
790
1029
|
|
|
791
1030
|
for (const action of actions) {
|
|
792
1031
|
switch (action.type) {
|
|
793
|
-
case 'vote-empire-payload': {
|
|
794
|
-
if (this.slashingProposerContract?.type !== 'empire') {
|
|
795
|
-
this.log.error('Cannot vote for empire payload on non-empire slashing contract');
|
|
796
|
-
break;
|
|
797
|
-
}
|
|
798
|
-
this.log.debug(`Enqueuing slashing vote for payload ${action.payload} at slot ${slotNumber}`, {
|
|
799
|
-
signerAddress,
|
|
800
|
-
});
|
|
801
|
-
await this.enqueueCastSignalHelper(
|
|
802
|
-
slotNumber,
|
|
803
|
-
timestamp,
|
|
804
|
-
'empire-slashing-signal',
|
|
805
|
-
action.payload,
|
|
806
|
-
this.slashingProposerContract,
|
|
807
|
-
signerAddress,
|
|
808
|
-
signer,
|
|
809
|
-
);
|
|
810
|
-
break;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
case 'create-empire-payload': {
|
|
814
|
-
this.log.debug(`Enqueuing slashing create payload at slot ${slotNumber}`, { slotNumber, signerAddress });
|
|
815
|
-
const request = this.slashFactoryContract.buildCreatePayloadRequest(action.data);
|
|
816
|
-
await this.simulateAndEnqueueRequest(
|
|
817
|
-
'create-empire-payload',
|
|
818
|
-
request,
|
|
819
|
-
(receipt: TransactionReceipt) =>
|
|
820
|
-
!!this.slashFactoryContract.tryExtractSlashPayloadCreatedEvent(receipt.logs),
|
|
821
|
-
slotNumber,
|
|
822
|
-
timestamp,
|
|
823
|
-
);
|
|
824
|
-
break;
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
case 'execute-empire-payload': {
|
|
828
|
-
this.log.debug(`Enqueuing slashing execute payload at slot ${slotNumber}`, { slotNumber, signerAddress });
|
|
829
|
-
if (this.slashingProposerContract?.type !== 'empire') {
|
|
830
|
-
this.log.error('Cannot execute slashing payload on non-empire slashing contract');
|
|
831
|
-
return false;
|
|
832
|
-
}
|
|
833
|
-
const empireSlashingProposer = this.slashingProposerContract as EmpireSlashingProposerContract;
|
|
834
|
-
const request = empireSlashingProposer.buildExecuteRoundRequest(action.round);
|
|
835
|
-
await this.simulateAndEnqueueRequest(
|
|
836
|
-
'execute-empire-payload',
|
|
837
|
-
request,
|
|
838
|
-
(receipt: TransactionReceipt) => !!empireSlashingProposer.tryExtractPayloadSubmittedEvent(receipt.logs),
|
|
839
|
-
slotNumber,
|
|
840
|
-
timestamp,
|
|
841
|
-
);
|
|
842
|
-
break;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
1032
|
case 'vote-offenses': {
|
|
846
1033
|
this.log.debug(`Enqueuing slashing vote for ${action.votes.length} votes at slot ${slotNumber}`, {
|
|
847
1034
|
slotNumber,
|
|
@@ -849,19 +1036,21 @@ export class SequencerPublisher {
|
|
|
849
1036
|
votesCount: action.votes.length,
|
|
850
1037
|
signerAddress,
|
|
851
1038
|
});
|
|
852
|
-
if (this.slashingProposerContract
|
|
853
|
-
this.log.error('
|
|
1039
|
+
if (!this.slashingProposerContract) {
|
|
1040
|
+
this.log.error('No slashing proposer contract available');
|
|
854
1041
|
return false;
|
|
855
1042
|
}
|
|
856
|
-
const tallySlashingProposer = this.slashingProposerContract as TallySlashingProposerContract;
|
|
857
1043
|
const votes = bufferToHex(encodeSlashConsensusVotes(action.votes));
|
|
858
|
-
const request = await
|
|
859
|
-
|
|
1044
|
+
const request = await this.slashingProposerContract.buildVoteRequestFromSigner(votes, slotNumber, signer);
|
|
1045
|
+
this.enqueueRequest(
|
|
860
1046
|
'vote-offenses',
|
|
861
1047
|
request,
|
|
862
|
-
|
|
1048
|
+
{
|
|
1049
|
+
address: this.slashingProposerContract.address.toString(),
|
|
1050
|
+
abi: SlashingProposerAbi,
|
|
1051
|
+
eventName: 'VoteCast',
|
|
1052
|
+
},
|
|
863
1053
|
slotNumber,
|
|
864
|
-
timestamp,
|
|
865
1054
|
);
|
|
866
1055
|
break;
|
|
867
1056
|
}
|
|
@@ -872,18 +1061,23 @@ export class SequencerPublisher {
|
|
|
872
1061
|
round: action.round,
|
|
873
1062
|
signerAddress,
|
|
874
1063
|
});
|
|
875
|
-
if (this.slashingProposerContract
|
|
876
|
-
this.log.error('
|
|
1064
|
+
if (!this.slashingProposerContract) {
|
|
1065
|
+
this.log.error('No slashing proposer contract available');
|
|
877
1066
|
return false;
|
|
878
1067
|
}
|
|
879
|
-
const
|
|
880
|
-
|
|
881
|
-
|
|
1068
|
+
const executeRequest = this.slashingProposerContract.buildExecuteRoundRequest(
|
|
1069
|
+
action.round,
|
|
1070
|
+
action.committees,
|
|
1071
|
+
);
|
|
1072
|
+
this.enqueueRequest(
|
|
882
1073
|
'execute-slash',
|
|
883
|
-
|
|
884
|
-
|
|
1074
|
+
executeRequest,
|
|
1075
|
+
{
|
|
1076
|
+
address: this.slashingProposerContract.address.toString(),
|
|
1077
|
+
abi: SlashingProposerAbi,
|
|
1078
|
+
eventName: 'RoundExecuted',
|
|
1079
|
+
},
|
|
885
1080
|
slotNumber,
|
|
886
|
-
timestamp,
|
|
887
1081
|
);
|
|
888
1082
|
break;
|
|
889
1083
|
}
|
|
@@ -898,51 +1092,32 @@ export class SequencerPublisher {
|
|
|
898
1092
|
return true;
|
|
899
1093
|
}
|
|
900
1094
|
|
|
901
|
-
/**
|
|
1095
|
+
/** Enqueues a proposal for a checkpoint on L1 */
|
|
902
1096
|
public async enqueueProposeCheckpoint(
|
|
903
1097
|
checkpoint: Checkpoint,
|
|
904
1098
|
attestationsAndSigners: CommitteeAttestationsAndSigners,
|
|
905
1099
|
attestationsAndSignersSignature: Signature,
|
|
906
|
-
opts:
|
|
1100
|
+
opts: EnqueueProposeCheckpointOpts = {},
|
|
907
1101
|
): Promise<void> {
|
|
908
1102
|
const checkpointHeader = checkpoint.header;
|
|
909
1103
|
|
|
910
1104
|
const blobFields = checkpoint.toBlobFields();
|
|
911
|
-
const blobs = getBlobsPerL1Block(blobFields);
|
|
1105
|
+
const blobs = await getBlobsPerL1Block(blobFields);
|
|
912
1106
|
|
|
913
|
-
const proposeTxArgs = {
|
|
1107
|
+
const proposeTxArgs: L1ProcessArgs = {
|
|
914
1108
|
header: checkpointHeader,
|
|
915
1109
|
archive: checkpoint.archive.root.toBuffer(),
|
|
916
1110
|
blobs,
|
|
917
1111
|
attestationsAndSigners,
|
|
918
1112
|
attestationsAndSignersSignature,
|
|
1113
|
+
feeAssetPriceModifier: checkpoint.feeAssetPriceModifier,
|
|
919
1114
|
};
|
|
920
1115
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
// By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which
|
|
927
|
-
// make time consistency checks break.
|
|
928
|
-
// TODO(palla): Check whether we're validating twice, once here and once within addProposeTx, since we call simulateProposeTx in both places.
|
|
929
|
-
ts = await this.validateCheckpointForSubmission(
|
|
930
|
-
checkpoint,
|
|
931
|
-
attestationsAndSigners,
|
|
932
|
-
attestationsAndSignersSignature,
|
|
933
|
-
opts,
|
|
934
|
-
);
|
|
935
|
-
} catch (err: any) {
|
|
936
|
-
this.log.error(`Checkpoint validation failed. ${err instanceof Error ? err.message : 'No error message'}`, err, {
|
|
937
|
-
...checkpoint.getStats(),
|
|
938
|
-
slotNumber: checkpoint.header.slotNumber,
|
|
939
|
-
forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber,
|
|
940
|
-
});
|
|
941
|
-
throw err;
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
this.log.verbose(`Enqueuing checkpoint propose transaction`, { ...checkpoint.toCheckpointInfo(), ...opts });
|
|
945
|
-
await this.addProposeTx(checkpoint, proposeTxArgs, opts, ts);
|
|
1116
|
+
this.log.verbose(`Enqueuing checkpoint propose transaction`, {
|
|
1117
|
+
...checkpoint.toCheckpointInfo(),
|
|
1118
|
+
txTimeoutAt: opts.txTimeoutAt,
|
|
1119
|
+
});
|
|
1120
|
+
await this.addProposeTx(checkpoint, proposeTxArgs, { txTimeoutAt: opts.txTimeoutAt });
|
|
946
1121
|
}
|
|
947
1122
|
|
|
948
1123
|
public enqueueInvalidateCheckpoint(
|
|
@@ -953,23 +1128,22 @@ export class SequencerPublisher {
|
|
|
953
1128
|
return;
|
|
954
1129
|
}
|
|
955
1130
|
|
|
956
|
-
// We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
|
|
957
|
-
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil((Number(request.gasUsed) * 64) / 63)));
|
|
958
|
-
|
|
959
1131
|
const { gasUsed, checkpointNumber } = request;
|
|
960
|
-
const logData = { gasUsed, checkpointNumber,
|
|
1132
|
+
const logData = { gasUsed, checkpointNumber, opts };
|
|
961
1133
|
this.log.verbose(`Enqueuing invalidate checkpoint request`, logData);
|
|
962
1134
|
this.addRequest({
|
|
963
1135
|
action: `invalidate-by-${request.reason}`,
|
|
964
1136
|
request: request.request,
|
|
965
|
-
gasConfig: {
|
|
1137
|
+
gasConfig: opts.txTimeoutAt ? { txTimeoutAt: opts.txTimeoutAt } : undefined,
|
|
966
1138
|
lastValidL2Slot: SlotNumber(this.getCurrentL2Slot() + 2),
|
|
967
1139
|
checkSuccess: (_req, result) => {
|
|
968
1140
|
const success =
|
|
969
1141
|
result &&
|
|
970
|
-
result.receipt
|
|
971
|
-
|
|
972
|
-
|
|
1142
|
+
extractEventSuccess(result.receipt, {
|
|
1143
|
+
address: this.rollupContract.address,
|
|
1144
|
+
abi: RollupAbi,
|
|
1145
|
+
eventName: 'CheckpointInvalidated',
|
|
1146
|
+
});
|
|
973
1147
|
if (!success) {
|
|
974
1148
|
this.log.warn(`Invalidate checkpoint ${request.checkpointNumber} failed`, { ...result, ...logData });
|
|
975
1149
|
} else {
|
|
@@ -980,51 +1154,36 @@ export class SequencerPublisher {
|
|
|
980
1154
|
});
|
|
981
1155
|
}
|
|
982
1156
|
|
|
983
|
-
|
|
1157
|
+
/**
|
|
1158
|
+
* Dedup-checked enqueue helper for actions that are simulated at bundle-send time rather
|
|
1159
|
+
* than at enqueue time. Validates the (action, slot) dedup key, sets `lastActions`, and
|
|
1160
|
+
* enqueues without a gasLimit so the bundle simulate sets the only gasLimit that matters.
|
|
1161
|
+
*/
|
|
1162
|
+
private enqueueRequest(
|
|
984
1163
|
action: Action,
|
|
985
1164
|
request: L1TxRequest,
|
|
986
|
-
|
|
1165
|
+
eventOpts: { address: string; abi: Abi; eventName: string },
|
|
987
1166
|
slotNumber: SlotNumber,
|
|
988
|
-
|
|
989
|
-
) {
|
|
990
|
-
const logData = { slotNumber, timestamp, gasLimit: undefined as bigint | undefined };
|
|
1167
|
+
): boolean {
|
|
991
1168
|
if (this.lastActions[action] && this.lastActions[action] === slotNumber) {
|
|
992
1169
|
this.log.debug(`Skipping duplicate action ${action} for slot ${slotNumber}`);
|
|
993
1170
|
return false;
|
|
994
1171
|
}
|
|
995
|
-
|
|
996
1172
|
const cachedLastActionSlot = this.lastActions[action];
|
|
997
1173
|
this.lastActions[action] = slotNumber;
|
|
998
1174
|
|
|
999
|
-
this.log.debug(`
|
|
1000
|
-
|
|
1001
|
-
let gasUsed: bigint;
|
|
1002
|
-
try {
|
|
1003
|
-
({ gasUsed } = await this.l1TxUtils.simulate(request, { time: timestamp }, [], ErrorsAbi)); // TODO(palla/slash): Check the timestamp logic
|
|
1004
|
-
this.log.verbose(`Simulation for ${action} succeeded`, { ...logData, request, gasUsed });
|
|
1005
|
-
} catch (err) {
|
|
1006
|
-
const viemError = formatViemError(err);
|
|
1007
|
-
this.log.error(`Simulation for ${action} at ${slotNumber} failed`, viemError, logData);
|
|
1008
|
-
return false;
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
// We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
|
|
1012
|
-
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil((Number(gasUsed) * 64) / 63)));
|
|
1013
|
-
logData.gasLimit = gasLimit;
|
|
1014
|
-
|
|
1015
|
-
this.log.debug(`Enqueuing ${action}`, logData);
|
|
1175
|
+
this.log.debug(`Enqueuing ${action}`, { slotNumber });
|
|
1016
1176
|
this.addRequest({
|
|
1017
1177
|
action,
|
|
1018
1178
|
request,
|
|
1019
|
-
gasConfig: { gasLimit },
|
|
1020
1179
|
lastValidL2Slot: slotNumber,
|
|
1021
|
-
checkSuccess: (
|
|
1022
|
-
const success = result && result.receipt
|
|
1180
|
+
checkSuccess: (_request, result) => {
|
|
1181
|
+
const success = result && extractEventSuccess(result.receipt, eventOpts);
|
|
1023
1182
|
if (!success) {
|
|
1024
|
-
this.log.warn(`Action ${action} at ${slotNumber} failed`, { ...result,
|
|
1183
|
+
this.log.warn(`Action ${action} at ${slotNumber} failed`, { ...result, slotNumber });
|
|
1025
1184
|
this.lastActions[action] = cachedLastActionSlot;
|
|
1026
1185
|
} else {
|
|
1027
|
-
this.log.info(`Action ${action} at ${slotNumber} succeeded`, { ...result,
|
|
1186
|
+
this.log.info(`Action ${action} at ${slotNumber} succeeded`, { ...result, slotNumber });
|
|
1028
1187
|
}
|
|
1029
1188
|
return !!success;
|
|
1030
1189
|
},
|
|
@@ -1040,6 +1199,7 @@ export class SequencerPublisher {
|
|
|
1040
1199
|
*/
|
|
1041
1200
|
public interrupt() {
|
|
1042
1201
|
this.interrupted = true;
|
|
1202
|
+
this.interruptibleSleep.interrupt();
|
|
1043
1203
|
this.l1TxUtils.interrupt();
|
|
1044
1204
|
}
|
|
1045
1205
|
|
|
@@ -1049,11 +1209,7 @@ export class SequencerPublisher {
|
|
|
1049
1209
|
this.l1TxUtils.restart();
|
|
1050
1210
|
}
|
|
1051
1211
|
|
|
1052
|
-
private async prepareProposeTx(
|
|
1053
|
-
encodedData: L1ProcessArgs,
|
|
1054
|
-
timestamp: bigint,
|
|
1055
|
-
options: { forcePendingCheckpointNumber?: CheckpointNumber },
|
|
1056
|
-
) {
|
|
1212
|
+
private async prepareProposeTx(encodedData: L1ProcessArgs) {
|
|
1057
1213
|
const kzg = Blob.getViemKzgInstance();
|
|
1058
1214
|
const blobInput = getPrefixedEthBlobCommitments(encodedData.blobs);
|
|
1059
1215
|
this.log.debug('Validating blob input', { blobInput });
|
|
@@ -1066,7 +1222,11 @@ export class SequencerPublisher {
|
|
|
1066
1222
|
blobEvaluationGas = BigInt(encodedData.blobs.length) * 21_000n;
|
|
1067
1223
|
this.log.debug(`Using fixed blob evaluation gas estimate in fisherman mode: ${blobEvaluationGas}`);
|
|
1068
1224
|
} else {
|
|
1069
|
-
//
|
|
1225
|
+
// We call validateBlobs via estimateGas with real blob+kzg sidecars as a consistency check
|
|
1226
|
+
// that our locally-built blob commitments match the blob data. The bundle simulate at send
|
|
1227
|
+
// time uses eth_simulateV1, which cannot carry blob inputs, so the rollup's on-chain blob
|
|
1228
|
+
// check is forced off there — making this the only pre-flight detector of a commitment/data
|
|
1229
|
+
// mismatch. The returned gas estimate is stashed on the request for the bundle path to read.
|
|
1070
1230
|
blobEvaluationGas = await this.l1TxUtils
|
|
1071
1231
|
.estimateGas(
|
|
1072
1232
|
this.getSenderAddress().toString(),
|
|
@@ -1084,9 +1244,27 @@ export class SequencerPublisher {
|
|
|
1084
1244
|
kzg,
|
|
1085
1245
|
},
|
|
1086
1246
|
)
|
|
1087
|
-
.catch(err => {
|
|
1088
|
-
const
|
|
1089
|
-
this.log.error(`Failed to validate blobs`, message, { metaMessages });
|
|
1247
|
+
.catch(async err => {
|
|
1248
|
+
const viemError = formatViemError(err);
|
|
1249
|
+
this.log.error(`Failed to validate blobs`, viemError.message, { metaMessages: viemError.metaMessages });
|
|
1250
|
+
const validateBlobsData = encodeFunctionData({
|
|
1251
|
+
abi: RollupAbi,
|
|
1252
|
+
functionName: 'validateBlobs',
|
|
1253
|
+
args: [blobInput],
|
|
1254
|
+
});
|
|
1255
|
+
const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
|
|
1256
|
+
this.backupFailedTx({
|
|
1257
|
+
id: keccak256(validateBlobsData),
|
|
1258
|
+
failureType: 'simulation',
|
|
1259
|
+
request: { to: this.rollupContract.address as Hex, data: validateBlobsData },
|
|
1260
|
+
blobData: encodedData.blobs.map(b => toHex(b.data)) as Hex[],
|
|
1261
|
+
l1BlockNumber: l1BlockNumber.toString(),
|
|
1262
|
+
error: { message: viemError.message, name: viemError.name },
|
|
1263
|
+
context: {
|
|
1264
|
+
actions: ['validate-blobs'],
|
|
1265
|
+
sender: this.getSenderAddress().toString(),
|
|
1266
|
+
},
|
|
1267
|
+
});
|
|
1090
1268
|
throw new Error('Failed to validate blobs');
|
|
1091
1269
|
});
|
|
1092
1270
|
}
|
|
@@ -1097,8 +1275,7 @@ export class SequencerPublisher {
|
|
|
1097
1275
|
header: encodedData.header.toViem(),
|
|
1098
1276
|
archive: toHex(encodedData.archive),
|
|
1099
1277
|
oracleInput: {
|
|
1100
|
-
|
|
1101
|
-
feeAssetPriceModifier: 0n,
|
|
1278
|
+
feeAssetPriceModifier: encodedData.feeAssetPriceModifier,
|
|
1102
1279
|
},
|
|
1103
1280
|
},
|
|
1104
1281
|
encodedData.attestationsAndSigners.getPackedAttestations(),
|
|
@@ -1107,124 +1284,21 @@ export class SequencerPublisher {
|
|
|
1107
1284
|
blobInput,
|
|
1108
1285
|
] as const;
|
|
1109
1286
|
|
|
1110
|
-
const
|
|
1287
|
+
const rollupData = encodeFunctionData({ abi: RollupAbi, functionName: 'propose', args });
|
|
1111
1288
|
|
|
1112
|
-
return { args, blobEvaluationGas, rollupData
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
/**
|
|
1116
|
-
* Simulates the propose tx with eth_simulateV1
|
|
1117
|
-
* @param args - The propose tx args
|
|
1118
|
-
* @param timestamp - The timestamp to simulate proposal at
|
|
1119
|
-
* @returns The simulation result
|
|
1120
|
-
*/
|
|
1121
|
-
private async simulateProposeTx(
|
|
1122
|
-
args: readonly [
|
|
1123
|
-
{
|
|
1124
|
-
readonly header: ViemHeader;
|
|
1125
|
-
readonly archive: `0x${string}`;
|
|
1126
|
-
readonly oracleInput: {
|
|
1127
|
-
readonly feeAssetPriceModifier: 0n;
|
|
1128
|
-
};
|
|
1129
|
-
},
|
|
1130
|
-
ViemCommitteeAttestations,
|
|
1131
|
-
`0x${string}`[], // Signers
|
|
1132
|
-
ViemSignature,
|
|
1133
|
-
`0x${string}`,
|
|
1134
|
-
],
|
|
1135
|
-
timestamp: bigint,
|
|
1136
|
-
options: { forcePendingCheckpointNumber?: CheckpointNumber },
|
|
1137
|
-
) {
|
|
1138
|
-
const rollupData = encodeFunctionData({
|
|
1139
|
-
abi: RollupAbi,
|
|
1140
|
-
functionName: 'propose',
|
|
1141
|
-
args,
|
|
1142
|
-
});
|
|
1143
|
-
|
|
1144
|
-
// override the pending checkpoint number if requested
|
|
1145
|
-
const forcePendingCheckpointNumberStateDiff = (
|
|
1146
|
-
options.forcePendingCheckpointNumber !== undefined
|
|
1147
|
-
? await this.rollupContract.makePendingCheckpointNumberOverride(options.forcePendingCheckpointNumber)
|
|
1148
|
-
: []
|
|
1149
|
-
).flatMap(override => override.stateDiff ?? []);
|
|
1150
|
-
|
|
1151
|
-
const stateOverrides: StateOverride = [
|
|
1152
|
-
{
|
|
1153
|
-
address: this.rollupContract.address,
|
|
1154
|
-
// @note we override checkBlob to false since blobs are not part simulate()
|
|
1155
|
-
stateDiff: [
|
|
1156
|
-
{ slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true), value: toPaddedHex(0n, true) },
|
|
1157
|
-
...forcePendingCheckpointNumberStateDiff,
|
|
1158
|
-
],
|
|
1159
|
-
},
|
|
1160
|
-
];
|
|
1161
|
-
// In fisherman mode, simulate as the proposer but with sufficient balance
|
|
1162
|
-
if (this.proposerAddressForSimulation) {
|
|
1163
|
-
stateOverrides.push({
|
|
1164
|
-
address: this.proposerAddressForSimulation.toString(),
|
|
1165
|
-
balance: 10n * WEI_CONST * WEI_CONST, // 10 ETH
|
|
1166
|
-
});
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
const simulationResult = await this.l1TxUtils
|
|
1170
|
-
.simulate(
|
|
1171
|
-
{
|
|
1172
|
-
to: this.rollupContract.address,
|
|
1173
|
-
data: rollupData,
|
|
1174
|
-
gas: SequencerPublisher.PROPOSE_GAS_GUESS,
|
|
1175
|
-
...(this.proposerAddressForSimulation && { from: this.proposerAddressForSimulation.toString() }),
|
|
1176
|
-
},
|
|
1177
|
-
{
|
|
1178
|
-
// @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp
|
|
1179
|
-
time: timestamp + 1n,
|
|
1180
|
-
// @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit so we increase here
|
|
1181
|
-
gasLimit: SequencerPublisher.PROPOSE_GAS_GUESS * 2n,
|
|
1182
|
-
},
|
|
1183
|
-
stateOverrides,
|
|
1184
|
-
RollupAbi,
|
|
1185
|
-
{
|
|
1186
|
-
// @note fallback gas estimate to use if the node doesn't support simulation API
|
|
1187
|
-
fallbackGasEstimate: SequencerPublisher.PROPOSE_GAS_GUESS,
|
|
1188
|
-
},
|
|
1189
|
-
)
|
|
1190
|
-
.catch(err => {
|
|
1191
|
-
// In fisherman mode, we expect ValidatorSelection__MissingProposerSignature since fisherman doesn't have proposer signature
|
|
1192
|
-
const viemError = formatViemError(err);
|
|
1193
|
-
if (this.config.fishermanMode && viemError.message?.includes('ValidatorSelection__MissingProposerSignature')) {
|
|
1194
|
-
this.log.debug(`Ignoring expected ValidatorSelection__MissingProposerSignature error in fisherman mode`);
|
|
1195
|
-
// Return a minimal simulation result with the fallback gas estimate
|
|
1196
|
-
return {
|
|
1197
|
-
gasUsed: SequencerPublisher.PROPOSE_GAS_GUESS,
|
|
1198
|
-
logs: [],
|
|
1199
|
-
};
|
|
1200
|
-
}
|
|
1201
|
-
this.log.error(`Failed to simulate propose tx`, viemError);
|
|
1202
|
-
throw err;
|
|
1203
|
-
});
|
|
1204
|
-
|
|
1205
|
-
return { rollupData, simulationResult };
|
|
1289
|
+
return { args, blobEvaluationGas, rollupData };
|
|
1206
1290
|
}
|
|
1207
1291
|
|
|
1208
1292
|
private async addProposeTx(
|
|
1209
1293
|
checkpoint: Checkpoint,
|
|
1210
1294
|
encodedData: L1ProcessArgs,
|
|
1211
|
-
opts:
|
|
1212
|
-
timestamp: bigint,
|
|
1295
|
+
opts: EnqueueProposeCheckpointOpts = {},
|
|
1213
1296
|
): Promise<void> {
|
|
1214
1297
|
const slot = checkpoint.header.slotNumber;
|
|
1215
1298
|
const timer = new Timer();
|
|
1216
1299
|
const kzg = Blob.getViemKzgInstance();
|
|
1217
|
-
const { rollupData,
|
|
1218
|
-
encodedData,
|
|
1219
|
-
timestamp,
|
|
1220
|
-
opts,
|
|
1221
|
-
);
|
|
1300
|
+
const { rollupData, blobEvaluationGas } = await this.prepareProposeTx(encodedData);
|
|
1222
1301
|
const startBlock = await this.l1TxUtils.getBlockNumber();
|
|
1223
|
-
const gasLimit = this.l1TxUtils.bumpGasLimit(
|
|
1224
|
-
BigInt(Math.ceil((Number(simulationResult.gasUsed) * 64) / 63)) +
|
|
1225
|
-
blobEvaluationGas +
|
|
1226
|
-
SequencerPublisher.MULTICALL_OVERHEAD_GAS_GUESS, // We issue the simulation against the rollup contract, so we need to account for the overhead of the multicall3
|
|
1227
|
-
);
|
|
1228
1302
|
|
|
1229
1303
|
// Send the blobs to the blob client preemptively. This helps in tests where the sequencer mistakingly thinks that the propose
|
|
1230
1304
|
// tx fails but it does get mined. We make sure that the blobs are sent to the blob client regardless of the tx outcome.
|
|
@@ -1241,7 +1315,8 @@ export class SequencerPublisher {
|
|
|
1241
1315
|
data: rollupData,
|
|
1242
1316
|
},
|
|
1243
1317
|
lastValidL2Slot: checkpoint.header.slotNumber,
|
|
1244
|
-
gasConfig: {
|
|
1318
|
+
gasConfig: { txTimeoutAt: opts.txTimeoutAt, gasLimit: undefined },
|
|
1319
|
+
blobEvaluationGas,
|
|
1245
1320
|
blobConfig: {
|
|
1246
1321
|
blobs: encodedData.blobs.map(b => b.data),
|
|
1247
1322
|
kzg,
|
|
@@ -1251,10 +1326,11 @@ export class SequencerPublisher {
|
|
|
1251
1326
|
return false;
|
|
1252
1327
|
}
|
|
1253
1328
|
const { receipt, stats, errorMsg } = result;
|
|
1254
|
-
const success =
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1329
|
+
const success = extractEventSuccess(receipt, {
|
|
1330
|
+
address: this.rollupContract.address,
|
|
1331
|
+
abi: RollupAbi,
|
|
1332
|
+
eventName: 'CheckpointProposed',
|
|
1333
|
+
});
|
|
1258
1334
|
|
|
1259
1335
|
if (success) {
|
|
1260
1336
|
const endBlock = receipt.blockNumber;
|
|
@@ -1294,4 +1370,10 @@ export class SequencerPublisher {
|
|
|
1294
1370
|
},
|
|
1295
1371
|
});
|
|
1296
1372
|
}
|
|
1373
|
+
|
|
1374
|
+
/** Returns the timestamp of the next L1 slot boundary after now. */
|
|
1375
|
+
private getNextL1SlotTimestamp(): bigint {
|
|
1376
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
1377
|
+
return getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), l1Constants);
|
|
1378
|
+
}
|
|
1297
1379
|
}
|