@aztec/sequencer-client 0.0.1-commit.fffb133c → 0.0.1-dev
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 +16 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +56 -23
- package/dest/config.d.ts +25 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +46 -28
- package/dest/global_variable_builder/global_builder.d.ts +14 -10
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +22 -21
- 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 +31 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +101 -42
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +13 -2
- 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 +28 -14
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +137 -74
- package/dest/sequencer/checkpoint_proposal_job.d.ts +35 -10
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +212 -137
- 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/metrics.d.ts +17 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +111 -30
- package/dest/sequencer/sequencer.d.ts +29 -13
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +48 -44
- package/dest/sequencer/timetable.d.ts +4 -6
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +7 -11
- package/dest/sequencer/types.d.ts +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 +47 -36
- package/dest/test/utils.d.ts +3 -3
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +5 -4
- package/package.json +28 -28
- package/src/client/sequencer-client.ts +78 -21
- package/src/config.ts +61 -38
- package/src/global_variable_builder/global_builder.ts +23 -24
- package/src/global_variable_builder/index.ts +1 -1
- package/src/publisher/config.ts +112 -43
- package/src/publisher/sequencer-publisher-factory.ts +23 -6
- package/src/publisher/sequencer-publisher-metrics.ts +7 -3
- package/src/publisher/sequencer-publisher.ts +149 -90
- package/src/sequencer/checkpoint_proposal_job.ts +309 -186
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/metrics.ts +124 -32
- package/src/sequencer/sequencer.ts +61 -50
- package/src/sequencer/timetable.ts +13 -12
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +2 -4
- package/src/test/mock_checkpoint_builder.ts +67 -53
- package/src/test/utils.ts +5 -2
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
import {
|
|
3
|
+
CHECKPOINT_ASSEMBLE_TIME,
|
|
4
|
+
CHECKPOINT_INITIALIZATION_TIME,
|
|
5
|
+
DEFAULT_P2P_PROPAGATION_TIME,
|
|
6
|
+
MIN_EXECUTION_TIME,
|
|
7
|
+
} from '@aztec/stdlib/timetable';
|
|
2
8
|
|
|
3
|
-
import { DEFAULT_ATTESTATION_PROPAGATION_TIME as DEFAULT_P2P_PROPAGATION_TIME } from '../config.js';
|
|
4
9
|
import { SequencerTooSlowError } from './errors.js';
|
|
5
10
|
import type { SequencerMetrics } from './metrics.js';
|
|
6
11
|
import { SequencerState } from './utils.js';
|
|
7
12
|
|
|
8
|
-
export const MIN_EXECUTION_TIME = 2;
|
|
9
|
-
export const CHECKPOINT_INITIALIZATION_TIME = 1;
|
|
10
|
-
export const CHECKPOINT_ASSEMBLE_TIME = 1;
|
|
11
|
-
|
|
12
13
|
export class SequencerTimetable {
|
|
13
14
|
/**
|
|
14
15
|
* How late into the slot can we be to start working. Computed as the total time needed for assembling and publishing a block,
|
|
@@ -79,7 +80,7 @@ export class SequencerTimetable {
|
|
|
79
80
|
enforce: boolean;
|
|
80
81
|
},
|
|
81
82
|
private readonly metrics?: SequencerMetrics,
|
|
82
|
-
private readonly log
|
|
83
|
+
private readonly log?: Logger,
|
|
83
84
|
) {
|
|
84
85
|
this.ethereumSlotDuration = opts.ethereumSlotDuration;
|
|
85
86
|
this.aztecSlotDuration = opts.aztecSlotDuration;
|
|
@@ -131,7 +132,7 @@ export class SequencerTimetable {
|
|
|
131
132
|
const initializeDeadline = this.aztecSlotDuration - minWorkToDo;
|
|
132
133
|
this.initializeDeadline = initializeDeadline;
|
|
133
134
|
|
|
134
|
-
this.log
|
|
135
|
+
this.log?.info(
|
|
135
136
|
`Sequencer timetable initialized with ${this.maxNumberOfBlocks} blocks per slot (${this.enforce ? 'enforced' : 'not enforced'})`,
|
|
136
137
|
{
|
|
137
138
|
ethereumSlotDuration: this.ethereumSlotDuration,
|
|
@@ -205,7 +206,7 @@ export class SequencerTimetable {
|
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
this.metrics?.recordStateTransitionBufferMs(Math.floor(bufferSeconds * 1000), newState);
|
|
208
|
-
this.log
|
|
209
|
+
this.log?.trace(`Enough time to transition to ${newState}`, { maxAllowedTime, secondsIntoSlot });
|
|
209
210
|
}
|
|
210
211
|
|
|
211
212
|
/**
|
|
@@ -241,7 +242,7 @@ export class SequencerTimetable {
|
|
|
241
242
|
const canStart = available >= this.minExecutionTime;
|
|
242
243
|
const deadline = secondsIntoSlot + available;
|
|
243
244
|
|
|
244
|
-
this.log
|
|
245
|
+
this.log?.verbose(
|
|
245
246
|
`${canStart ? 'Can' : 'Cannot'} start single-block checkpoint at ${secondsIntoSlot}s into slot`,
|
|
246
247
|
{ secondsIntoSlot, maxAllowed, available, deadline },
|
|
247
248
|
);
|
|
@@ -261,7 +262,7 @@ export class SequencerTimetable {
|
|
|
261
262
|
// Found an available sub-slot! Is this the last one?
|
|
262
263
|
const isLastBlock = subSlot === this.maxNumberOfBlocks;
|
|
263
264
|
|
|
264
|
-
this.log
|
|
265
|
+
this.log?.verbose(
|
|
265
266
|
`Can start ${isLastBlock ? 'last block' : 'block'} in sub-slot ${subSlot} with deadline ${deadline}s`,
|
|
266
267
|
{ secondsIntoSlot, deadline, timeUntilDeadline, subSlot, maxBlocks: this.maxNumberOfBlocks },
|
|
267
268
|
);
|
|
@@ -271,7 +272,7 @@ export class SequencerTimetable {
|
|
|
271
272
|
}
|
|
272
273
|
|
|
273
274
|
// No sub-slots available with enough time
|
|
274
|
-
this.log
|
|
275
|
+
this.log?.verbose(`No time left to start any more blocks`, {
|
|
275
276
|
secondsIntoSlot,
|
|
276
277
|
maxBlocks: this.maxNumberOfBlocks,
|
|
277
278
|
initializationOffset: this.initializationOffset,
|
package/src/sequencer/types.ts
CHANGED
|
@@ -2,5 +2,5 @@ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
|
2
2
|
|
|
3
3
|
export type SequencerRollupConstants = Pick<
|
|
4
4
|
L1RollupConstants,
|
|
5
|
-
'ethereumSlotDuration' | 'l1GenesisTime' | 'slotDuration'
|
|
5
|
+
'ethereumSlotDuration' | 'l1GenesisTime' | 'slotDuration' | 'rollupManaLimit'
|
|
6
6
|
>;
|
package/src/test/index.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
2
2
|
import type { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
3
3
|
import type { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
4
4
|
import type { FullNodeCheckpointsBuilder, ValidatorClient } from '@aztec/validator-client';
|
|
5
5
|
|
|
6
6
|
import { SequencerClient } from '../client/sequencer-client.js';
|
|
7
7
|
import type { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
8
|
-
import type { SequencerPublisher } from '../publisher/sequencer-publisher.js';
|
|
9
8
|
import { Sequencer } from '../sequencer/sequencer.js';
|
|
10
9
|
import type { SequencerTimetable } from '../sequencer/timetable.js';
|
|
11
10
|
|
|
12
11
|
class TestSequencer_ extends Sequencer {
|
|
13
12
|
declare public publicProcessorFactory: PublicProcessorFactory;
|
|
14
13
|
declare public timetable: SequencerTimetable;
|
|
15
|
-
declare public publisher: SequencerPublisher;
|
|
16
14
|
declare public publisherFactory: SequencerPublisherFactory;
|
|
17
15
|
declare public validatorClient: ValidatorClient;
|
|
18
16
|
declare public checkpointsBuilder: FullNodeCheckpointsBuilder;
|
|
@@ -22,7 +20,7 @@ export type TestSequencer = TestSequencer_;
|
|
|
22
20
|
|
|
23
21
|
class TestSequencerClient_ extends SequencerClient {
|
|
24
22
|
declare public sequencer: TestSequencer;
|
|
25
|
-
declare public publisherManager: PublisherManager<
|
|
23
|
+
declare public publisherManager: PublisherManager<L1TxUtils>;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
export type TestSequencerClient = TestSequencerClient_;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { type BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { type BlockNumber, CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import {
|
|
3
|
+
import { unfreeze } from '@aztec/foundation/types';
|
|
4
4
|
import { L2Block } from '@aztec/stdlib/block';
|
|
5
5
|
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
6
|
-
import { Gas } from '@aztec/stdlib/gas';
|
|
7
6
|
import type {
|
|
7
|
+
BlockBuilderOptions,
|
|
8
8
|
FullNodeBlockBuilderConfig,
|
|
9
9
|
ICheckpointBlockBuilder,
|
|
10
10
|
ICheckpointsBuilder,
|
|
11
11
|
MerkleTreeWriteOperations,
|
|
12
|
-
PublicProcessorLimits,
|
|
13
12
|
} from '@aztec/stdlib/interfaces/server';
|
|
14
13
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
15
14
|
import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
|
|
16
15
|
import type { CheckpointGlobalVariables, Tx } from '@aztec/stdlib/tx';
|
|
17
|
-
import type {
|
|
16
|
+
import type { BuildBlockInCheckpointResult } from '@aztec/validator-client';
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* A fake CheckpointBuilder for testing that implements the same interface as the real one.
|
|
@@ -33,7 +32,7 @@ export class MockCheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
33
32
|
public buildBlockCalls: Array<{
|
|
34
33
|
blockNumber: BlockNumber;
|
|
35
34
|
timestamp: bigint;
|
|
36
|
-
opts:
|
|
35
|
+
opts: BlockBuilderOptions;
|
|
37
36
|
}> = [];
|
|
38
37
|
/** Track all consumed transaction hashes across buildBlock calls */
|
|
39
38
|
public consumedTxHashes: Set<string> = new Set();
|
|
@@ -75,8 +74,8 @@ export class MockCheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
75
74
|
pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
|
|
76
75
|
blockNumber: BlockNumber,
|
|
77
76
|
timestamp: bigint,
|
|
78
|
-
opts:
|
|
79
|
-
): Promise<
|
|
77
|
+
opts: BlockBuilderOptions,
|
|
78
|
+
): Promise<BuildBlockInCheckpointResult> {
|
|
80
79
|
this.buildBlockCalls.push({ blockNumber, timestamp, opts });
|
|
81
80
|
|
|
82
81
|
if (this.errorOnBuild) {
|
|
@@ -87,8 +86,10 @@ export class MockCheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
87
86
|
let usedTxs: Tx[];
|
|
88
87
|
|
|
89
88
|
if (this.blockProvider) {
|
|
90
|
-
// Dynamic mode: get block from provider
|
|
91
|
-
block = this.blockProvider();
|
|
89
|
+
// Dynamic mode: get block from provider, cloning to avoid shared references across multiple buildBlock calls
|
|
90
|
+
block = L2Block.fromBuffer(this.blockProvider().toBuffer());
|
|
91
|
+
block.header.globalVariables.blockNumber = blockNumber;
|
|
92
|
+
await block.header.recomputeHash();
|
|
92
93
|
usedTxs = [];
|
|
93
94
|
this.builtBlocks.push(block);
|
|
94
95
|
} else {
|
|
@@ -114,82 +115,79 @@ export class MockCheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
114
115
|
|
|
115
116
|
return {
|
|
116
117
|
block,
|
|
117
|
-
publicGas: Gas.empty(),
|
|
118
118
|
publicProcessorDuration: 0,
|
|
119
119
|
numTxs: block?.body?.txEffects?.length ?? usedTxs.length,
|
|
120
|
-
blockBuildingTimer: new Timer(),
|
|
121
120
|
usedTxs,
|
|
122
121
|
failedTxs: [],
|
|
123
|
-
usedTxBlobFields: block?.body?.txEffects?.reduce((sum, tx) => sum + tx.getNumBlobFields(), 0) ?? 0,
|
|
124
122
|
};
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
completeCheckpoint(): Promise<Checkpoint> {
|
|
128
126
|
this.completeCheckpointCalled = true;
|
|
129
127
|
const allBlocks = this.blockProvider ? this.builtBlocks : this.blocks;
|
|
130
|
-
|
|
131
|
-
// Create a CheckpointHeader from the last block's header for testing
|
|
132
|
-
const checkpointHeader = this.createCheckpointHeader(lastBlock);
|
|
133
|
-
return Promise.resolve(
|
|
134
|
-
new Checkpoint(
|
|
135
|
-
makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
|
|
136
|
-
checkpointHeader,
|
|
137
|
-
allBlocks,
|
|
138
|
-
this.checkpointNumber,
|
|
139
|
-
),
|
|
140
|
-
);
|
|
128
|
+
return this.buildCheckpoint(allBlocks);
|
|
141
129
|
}
|
|
142
130
|
|
|
143
131
|
getCheckpoint(): Promise<Checkpoint> {
|
|
144
132
|
this.getCheckpointCalled = true;
|
|
145
133
|
const builtBlocks = this.blockProvider ? this.builtBlocks : this.blocks.slice(0, this.blockIndex);
|
|
146
|
-
|
|
147
|
-
if (!lastBlock) {
|
|
134
|
+
if (builtBlocks.length === 0) {
|
|
148
135
|
throw new Error('No blocks built yet');
|
|
149
136
|
}
|
|
150
|
-
|
|
151
|
-
const checkpointHeader = this.createCheckpointHeader(lastBlock);
|
|
152
|
-
return Promise.resolve(
|
|
153
|
-
new Checkpoint(
|
|
154
|
-
makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
|
|
155
|
-
checkpointHeader,
|
|
156
|
-
builtBlocks,
|
|
157
|
-
this.checkpointNumber,
|
|
158
|
-
),
|
|
159
|
-
);
|
|
137
|
+
return this.buildCheckpoint(builtBlocks);
|
|
160
138
|
}
|
|
161
139
|
|
|
162
|
-
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
140
|
+
/** Builds a structurally valid Checkpoint from a list of blocks, fixing up indexes and archive chaining. */
|
|
141
|
+
private async buildCheckpoint(blocks: L2Block[]): Promise<Checkpoint> {
|
|
142
|
+
// Fix up indexWithinCheckpoint and archive chaining so the checkpoint passes structural validation.
|
|
143
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
144
|
+
blocks[i].indexWithinCheckpoint = IndexWithinCheckpoint(i);
|
|
145
|
+
if (i > 0) {
|
|
146
|
+
unfreeze(blocks[i].header).lastArchive = blocks[i - 1].archive;
|
|
147
|
+
await blocks[i].header.recomputeHash();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const firstBlock = blocks[0];
|
|
152
|
+
const lastBlock = blocks[blocks.length - 1];
|
|
153
|
+
const gv = firstBlock.header.globalVariables;
|
|
154
|
+
|
|
155
|
+
const checkpointHeader = CheckpointHeader.empty({
|
|
156
|
+
lastArchiveRoot: firstBlock.header.lastArchive.root,
|
|
157
|
+
blockHeadersHash: Fr.random(),
|
|
172
158
|
slotNumber: gv.slotNumber,
|
|
173
159
|
timestamp: gv.timestamp,
|
|
174
160
|
coinbase: gv.coinbase,
|
|
175
161
|
feeRecipient: gv.feeRecipient,
|
|
176
162
|
gasFees: gv.gasFees,
|
|
177
|
-
totalManaUsed: header.totalManaUsed,
|
|
163
|
+
totalManaUsed: lastBlock.header.totalManaUsed,
|
|
178
164
|
});
|
|
165
|
+
|
|
166
|
+
return new Checkpoint(
|
|
167
|
+
makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
|
|
168
|
+
checkpointHeader,
|
|
169
|
+
blocks,
|
|
170
|
+
this.checkpointNumber,
|
|
171
|
+
);
|
|
179
172
|
}
|
|
180
173
|
|
|
181
|
-
/**
|
|
182
|
-
|
|
183
|
-
this.blocks = [];
|
|
174
|
+
/** Resets per-checkpoint state (built blocks, consumed txs) while preserving config (blockProvider, seeded blocks). */
|
|
175
|
+
resetCheckpointState(): void {
|
|
184
176
|
this.builtBlocks = [];
|
|
185
|
-
this.usedTxsPerBlock = [];
|
|
186
177
|
this.blockIndex = 0;
|
|
187
|
-
this.buildBlockCalls = [];
|
|
188
178
|
this.consumedTxHashes.clear();
|
|
189
179
|
this.completeCheckpointCalled = false;
|
|
190
180
|
this.getCheckpointCalled = false;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Reset for reuse in another test */
|
|
184
|
+
reset(): void {
|
|
185
|
+
this.blocks = [];
|
|
186
|
+
this.usedTxsPerBlock = [];
|
|
187
|
+
this.buildBlockCalls = [];
|
|
191
188
|
this.errorOnBuild = undefined;
|
|
192
189
|
this.blockProvider = undefined;
|
|
190
|
+
this.resetCheckpointState();
|
|
193
191
|
}
|
|
194
192
|
}
|
|
195
193
|
|
|
@@ -207,6 +205,7 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
207
205
|
constants: CheckpointGlobalVariables;
|
|
208
206
|
l1ToL2Messages: Fr[];
|
|
209
207
|
previousCheckpointOutHashes: Fr[];
|
|
208
|
+
feeAssetPriceModifier: bigint;
|
|
210
209
|
}> = [];
|
|
211
210
|
public openCheckpointCalls: Array<{
|
|
212
211
|
checkpointNumber: CheckpointNumber;
|
|
@@ -214,6 +213,7 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
214
213
|
l1ToL2Messages: Fr[];
|
|
215
214
|
previousCheckpointOutHashes: Fr[];
|
|
216
215
|
existingBlocks: L2Block[];
|
|
216
|
+
feeAssetPriceModifier: bigint;
|
|
217
217
|
}> = [];
|
|
218
218
|
public updateConfigCalls: Array<Partial<FullNodeBlockBuilderConfig>> = [];
|
|
219
219
|
|
|
@@ -249,6 +249,7 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
249
249
|
slotDuration: 24,
|
|
250
250
|
l1ChainId: 1,
|
|
251
251
|
rollupVersion: 1,
|
|
252
|
+
rollupManaLimit: 200_000_000,
|
|
252
253
|
};
|
|
253
254
|
}
|
|
254
255
|
|
|
@@ -259,15 +260,24 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
259
260
|
startCheckpoint(
|
|
260
261
|
checkpointNumber: CheckpointNumber,
|
|
261
262
|
constants: CheckpointGlobalVariables,
|
|
263
|
+
feeAssetPriceModifier: bigint,
|
|
262
264
|
l1ToL2Messages: Fr[],
|
|
263
265
|
previousCheckpointOutHashes: Fr[],
|
|
264
266
|
_fork: MerkleTreeWriteOperations,
|
|
265
267
|
): Promise<ICheckpointBlockBuilder> {
|
|
266
|
-
this.startCheckpointCalls.push({
|
|
268
|
+
this.startCheckpointCalls.push({
|
|
269
|
+
checkpointNumber,
|
|
270
|
+
constants,
|
|
271
|
+
l1ToL2Messages,
|
|
272
|
+
previousCheckpointOutHashes,
|
|
273
|
+
feeAssetPriceModifier,
|
|
274
|
+
});
|
|
267
275
|
|
|
268
276
|
if (!this.checkpointBuilder) {
|
|
269
277
|
// Auto-create a builder if none was set
|
|
270
278
|
this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
|
|
279
|
+
} else {
|
|
280
|
+
this.checkpointBuilder.resetCheckpointState();
|
|
271
281
|
}
|
|
272
282
|
|
|
273
283
|
return Promise.resolve(this.checkpointBuilder);
|
|
@@ -276,6 +286,7 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
276
286
|
openCheckpoint(
|
|
277
287
|
checkpointNumber: CheckpointNumber,
|
|
278
288
|
constants: CheckpointGlobalVariables,
|
|
289
|
+
feeAssetPriceModifier: bigint,
|
|
279
290
|
l1ToL2Messages: Fr[],
|
|
280
291
|
previousCheckpointOutHashes: Fr[],
|
|
281
292
|
_fork: MerkleTreeWriteOperations,
|
|
@@ -287,11 +298,14 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
287
298
|
l1ToL2Messages,
|
|
288
299
|
previousCheckpointOutHashes,
|
|
289
300
|
existingBlocks,
|
|
301
|
+
feeAssetPriceModifier,
|
|
290
302
|
});
|
|
291
303
|
|
|
292
304
|
if (!this.checkpointBuilder) {
|
|
293
305
|
// Auto-create a builder if none was set
|
|
294
306
|
this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
|
|
307
|
+
} else {
|
|
308
|
+
this.checkpointBuilder.resetCheckpointState();
|
|
295
309
|
}
|
|
296
310
|
|
|
297
311
|
return Promise.resolve(this.checkpointBuilder);
|
package/src/test/utils.ts
CHANGED
|
@@ -56,6 +56,7 @@ export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Pr
|
|
|
56
56
|
export function mockPendingTxs(p2p: MockProxy<P2P>, txs: Tx[]): void {
|
|
57
57
|
p2p.getPendingTxCount.mockResolvedValue(txs.length);
|
|
58
58
|
p2p.iteratePendingTxs.mockImplementation(() => mockTxIterator(Promise.resolve(txs)));
|
|
59
|
+
p2p.iterateEligiblePendingTxs.mockImplementation(() => mockTxIterator(Promise.resolve(txs)));
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
/**
|
|
@@ -118,10 +119,11 @@ export function createCheckpointProposal(
|
|
|
118
119
|
block: L2Block,
|
|
119
120
|
checkpointSignature: Signature,
|
|
120
121
|
blockSignature?: Signature,
|
|
122
|
+
feeAssetPriceModifier: bigint = 0n,
|
|
121
123
|
): CheckpointProposal {
|
|
122
124
|
const txHashes = block.body.txEffects.map(tx => tx.txHash);
|
|
123
125
|
const checkpointHeader = createCheckpointHeaderFromBlock(block);
|
|
124
|
-
return new CheckpointProposal(checkpointHeader, block.archive.root, checkpointSignature, {
|
|
126
|
+
return new CheckpointProposal(checkpointHeader, block.archive.root, feeAssetPriceModifier, checkpointSignature, {
|
|
125
127
|
blockHeader: block.header,
|
|
126
128
|
indexWithinCheckpoint: block.indexWithinCheckpoint,
|
|
127
129
|
txHashes,
|
|
@@ -138,9 +140,10 @@ export function createCheckpointAttestation(
|
|
|
138
140
|
block: L2Block,
|
|
139
141
|
signature: Signature,
|
|
140
142
|
sender: EthAddress,
|
|
143
|
+
feeAssetPriceModifier: bigint = 0n,
|
|
141
144
|
): CheckpointAttestation {
|
|
142
145
|
const checkpointHeader = createCheckpointHeaderFromBlock(block);
|
|
143
|
-
const payload = new ConsensusPayload(checkpointHeader, block.archive.root);
|
|
146
|
+
const payload = new ConsensusPayload(checkpointHeader, block.archive.root, feeAssetPriceModifier);
|
|
144
147
|
const attestation = new CheckpointAttestation(payload, signature, signature);
|
|
145
148
|
// Set sender directly for testing (bypasses signature recovery)
|
|
146
149
|
(attestation as any).sender = sender;
|