@aztec/sequencer-client 0.0.1-commit.6d3c34e → 0.0.1-commit.7035c9bd6
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 +12 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +56 -17
- package/dest/config.d.ts +26 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +47 -30
- package/dest/global_variable_builder/global_builder.d.ts +2 -4
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +7 -6
- 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 +35 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +106 -42
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +2 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +27 -2
- package/dest/publisher/sequencer-publisher-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 +30 -10
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +362 -56
- package/dest/sequencer/checkpoint_proposal_job.d.ts +42 -11
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +322 -122
- package/dest/sequencer/checkpoint_voter.d.ts +3 -2
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +34 -10
- package/dest/sequencer/events.d.ts +2 -1
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/index.d.ts +1 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +0 -1
- package/dest/sequencer/metrics.d.ts +21 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +122 -30
- package/dest/sequencer/sequencer.d.ts +43 -20
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +151 -82
- 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 +23 -19
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +67 -38
- package/dest/test/utils.d.ts +8 -8
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +12 -11
- package/package.json +29 -28
- package/src/client/sequencer-client.ts +77 -18
- package/src/config.ts +66 -41
- package/src/global_variable_builder/global_builder.ts +6 -5
- package/src/index.ts +1 -6
- package/src/publisher/config.ts +121 -43
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-publisher-factory.ts +38 -6
- package/src/publisher/sequencer-publisher-metrics.ts +7 -3
- package/src/publisher/sequencer-publisher.ts +360 -69
- package/src/sequencer/checkpoint_proposal_job.ts +449 -142
- package/src/sequencer/checkpoint_voter.ts +32 -7
- package/src/sequencer/events.ts +1 -1
- package/src/sequencer/index.ts +0 -1
- package/src/sequencer/metrics.ts +138 -32
- package/src/sequencer/sequencer.ts +200 -91
- 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 +122 -78
- package/src/test/utils.ts +24 -14
- package/dest/sequencer/block_builder.d.ts +0 -26
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -129
- package/src/sequencer/block_builder.ts +0 -216
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,39 +1,41 @@
|
|
|
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 {
|
|
4
|
-
import
|
|
5
|
-
import { L2BlockNew } from '@aztec/stdlib/block';
|
|
3
|
+
import { unfreeze } from '@aztec/foundation/types';
|
|
4
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
6
5
|
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
7
|
-
import {
|
|
8
|
-
|
|
6
|
+
import type {
|
|
7
|
+
BlockBuilderOptions,
|
|
8
|
+
FullNodeBlockBuilderConfig,
|
|
9
|
+
ICheckpointBlockBuilder,
|
|
10
|
+
ICheckpointsBuilder,
|
|
11
|
+
MerkleTreeWriteOperations,
|
|
12
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
9
13
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
10
14
|
import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
|
|
11
15
|
import type { CheckpointGlobalVariables, Tx } from '@aztec/stdlib/tx';
|
|
12
|
-
import type {
|
|
13
|
-
BuildBlockInCheckpointResult,
|
|
14
|
-
CheckpointBuilder,
|
|
15
|
-
FullNodeCheckpointsBuilder,
|
|
16
|
-
} from '@aztec/validator-client';
|
|
16
|
+
import type { BuildBlockInCheckpointResult } from '@aztec/validator-client';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* A fake CheckpointBuilder for testing that implements the same interface as the real one.
|
|
20
20
|
* Can be seeded with blocks to return sequentially on each `buildBlock` call.
|
|
21
21
|
*/
|
|
22
|
-
export class MockCheckpointBuilder implements
|
|
23
|
-
private blocks:
|
|
24
|
-
private builtBlocks:
|
|
22
|
+
export class MockCheckpointBuilder implements ICheckpointBlockBuilder {
|
|
23
|
+
private blocks: L2Block[] = [];
|
|
24
|
+
private builtBlocks: L2Block[] = [];
|
|
25
25
|
private usedTxsPerBlock: Tx[][] = [];
|
|
26
26
|
private blockIndex = 0;
|
|
27
27
|
|
|
28
28
|
/** Optional function to dynamically provide the block (alternative to seedBlocks) */
|
|
29
|
-
private blockProvider: (() =>
|
|
29
|
+
private blockProvider: (() => L2Block) | undefined = undefined;
|
|
30
30
|
|
|
31
31
|
/** Track calls for assertions */
|
|
32
32
|
public buildBlockCalls: Array<{
|
|
33
33
|
blockNumber: BlockNumber;
|
|
34
34
|
timestamp: bigint;
|
|
35
|
-
opts:
|
|
35
|
+
opts: BlockBuilderOptions;
|
|
36
36
|
}> = [];
|
|
37
|
+
/** Track all consumed transaction hashes across buildBlock calls */
|
|
38
|
+
public consumedTxHashes: Set<string> = new Set();
|
|
37
39
|
public completeCheckpointCalled = false;
|
|
38
40
|
public getCheckpointCalled = false;
|
|
39
41
|
|
|
@@ -46,7 +48,7 @@ export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
|
|
|
46
48
|
) {}
|
|
47
49
|
|
|
48
50
|
/** Seed the builder with blocks to return on successive buildBlock calls */
|
|
49
|
-
seedBlocks(blocks:
|
|
51
|
+
seedBlocks(blocks: L2Block[], usedTxsPerBlock?: Tx[][]): this {
|
|
50
52
|
this.blocks = blocks;
|
|
51
53
|
this.usedTxsPerBlock = usedTxsPerBlock ?? blocks.map(() => []);
|
|
52
54
|
this.blockIndex = 0;
|
|
@@ -58,7 +60,7 @@ export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
|
|
|
58
60
|
* Set a function that provides blocks dynamically.
|
|
59
61
|
* Useful for tests where the block is determined at call time (e.g., sequencer tests).
|
|
60
62
|
*/
|
|
61
|
-
setBlockProvider(provider: () =>
|
|
63
|
+
setBlockProvider(provider: () => L2Block): this {
|
|
62
64
|
this.blockProvider = provider;
|
|
63
65
|
this.blocks = [];
|
|
64
66
|
return this;
|
|
@@ -68,24 +70,26 @@ export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
|
|
|
68
70
|
return this.constants;
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
buildBlock(
|
|
72
|
-
|
|
73
|
+
async buildBlock(
|
|
74
|
+
pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
|
|
73
75
|
blockNumber: BlockNumber,
|
|
74
76
|
timestamp: bigint,
|
|
75
|
-
opts:
|
|
77
|
+
opts: BlockBuilderOptions,
|
|
76
78
|
): Promise<BuildBlockInCheckpointResult> {
|
|
77
79
|
this.buildBlockCalls.push({ blockNumber, timestamp, opts });
|
|
78
80
|
|
|
79
81
|
if (this.errorOnBuild) {
|
|
80
|
-
|
|
82
|
+
throw this.errorOnBuild;
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
let block:
|
|
85
|
+
let block: L2Block;
|
|
84
86
|
let usedTxs: Tx[];
|
|
85
87
|
|
|
86
88
|
if (this.blockProvider) {
|
|
87
|
-
// Dynamic mode: get block from provider
|
|
88
|
-
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();
|
|
89
93
|
usedTxs = [];
|
|
90
94
|
this.builtBlocks.push(block);
|
|
91
95
|
} else {
|
|
@@ -96,82 +100,94 @@ export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
|
|
|
96
100
|
this.builtBlocks.push(block);
|
|
97
101
|
}
|
|
98
102
|
|
|
99
|
-
|
|
103
|
+
// Check that no pending tx has already been consumed
|
|
104
|
+
for await (const tx of pendingTxs) {
|
|
105
|
+
const hash = tx.getTxHash().toString();
|
|
106
|
+
if (this.consumedTxHashes.has(hash)) {
|
|
107
|
+
throw new Error(`Transaction ${hash} was already consumed in a previous block`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Add used txs to consumed set
|
|
112
|
+
for (const tx of usedTxs) {
|
|
113
|
+
this.consumedTxHashes.add(tx.getTxHash().toString());
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return {
|
|
100
117
|
block,
|
|
101
|
-
publicGas: Gas.empty(),
|
|
102
118
|
publicProcessorDuration: 0,
|
|
103
119
|
numTxs: block?.body?.txEffects?.length ?? usedTxs.length,
|
|
104
|
-
blockBuildingTimer: new Timer(),
|
|
105
120
|
usedTxs,
|
|
106
121
|
failedTxs: [],
|
|
107
|
-
}
|
|
122
|
+
};
|
|
108
123
|
}
|
|
109
124
|
|
|
110
125
|
completeCheckpoint(): Promise<Checkpoint> {
|
|
111
126
|
this.completeCheckpointCalled = true;
|
|
112
127
|
const allBlocks = this.blockProvider ? this.builtBlocks : this.blocks;
|
|
113
|
-
|
|
114
|
-
// Create a CheckpointHeader from the last block's header for testing
|
|
115
|
-
const checkpointHeader = this.createCheckpointHeader(lastBlock);
|
|
116
|
-
return Promise.resolve(
|
|
117
|
-
new Checkpoint(
|
|
118
|
-
makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
|
|
119
|
-
checkpointHeader,
|
|
120
|
-
allBlocks,
|
|
121
|
-
this.checkpointNumber,
|
|
122
|
-
),
|
|
123
|
-
);
|
|
128
|
+
return this.buildCheckpoint(allBlocks);
|
|
124
129
|
}
|
|
125
130
|
|
|
126
131
|
getCheckpoint(): Promise<Checkpoint> {
|
|
127
132
|
this.getCheckpointCalled = true;
|
|
128
133
|
const builtBlocks = this.blockProvider ? this.builtBlocks : this.blocks.slice(0, this.blockIndex);
|
|
129
|
-
|
|
130
|
-
if (!lastBlock) {
|
|
134
|
+
if (builtBlocks.length === 0) {
|
|
131
135
|
throw new Error('No blocks built yet');
|
|
132
136
|
}
|
|
133
|
-
|
|
134
|
-
const checkpointHeader = this.createCheckpointHeader(lastBlock);
|
|
135
|
-
return Promise.resolve(
|
|
136
|
-
new Checkpoint(
|
|
137
|
-
makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
|
|
138
|
-
checkpointHeader,
|
|
139
|
-
builtBlocks,
|
|
140
|
-
this.checkpointNumber,
|
|
141
|
-
),
|
|
142
|
-
);
|
|
137
|
+
return this.buildCheckpoint(builtBlocks);
|
|
143
138
|
}
|
|
144
139
|
|
|
145
|
-
/**
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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(),
|
|
155
158
|
slotNumber: gv.slotNumber,
|
|
156
159
|
timestamp: gv.timestamp,
|
|
157
160
|
coinbase: gv.coinbase,
|
|
158
161
|
feeRecipient: gv.feeRecipient,
|
|
159
162
|
gasFees: gv.gasFees,
|
|
160
|
-
totalManaUsed: header.totalManaUsed,
|
|
163
|
+
totalManaUsed: lastBlock.header.totalManaUsed,
|
|
161
164
|
});
|
|
165
|
+
|
|
166
|
+
return new Checkpoint(
|
|
167
|
+
makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
|
|
168
|
+
checkpointHeader,
|
|
169
|
+
blocks,
|
|
170
|
+
this.checkpointNumber,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Resets per-checkpoint state (built blocks, consumed txs) while preserving config (blockProvider, seeded blocks). */
|
|
175
|
+
resetCheckpointState(): void {
|
|
176
|
+
this.builtBlocks = [];
|
|
177
|
+
this.blockIndex = 0;
|
|
178
|
+
this.consumedTxHashes.clear();
|
|
179
|
+
this.completeCheckpointCalled = false;
|
|
180
|
+
this.getCheckpointCalled = false;
|
|
162
181
|
}
|
|
163
182
|
|
|
164
183
|
/** Reset for reuse in another test */
|
|
165
184
|
reset(): void {
|
|
166
185
|
this.blocks = [];
|
|
167
|
-
this.builtBlocks = [];
|
|
168
186
|
this.usedTxsPerBlock = [];
|
|
169
|
-
this.blockIndex = 0;
|
|
170
187
|
this.buildBlockCalls = [];
|
|
171
|
-
this.completeCheckpointCalled = false;
|
|
172
|
-
this.getCheckpointCalled = false;
|
|
173
188
|
this.errorOnBuild = undefined;
|
|
174
189
|
this.blockProvider = undefined;
|
|
190
|
+
this.resetCheckpointState();
|
|
175
191
|
}
|
|
176
192
|
}
|
|
177
193
|
|
|
@@ -180,7 +196,7 @@ export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
|
|
|
180
196
|
* as FullNodeCheckpointsBuilder. Returns MockCheckpointBuilder instances.
|
|
181
197
|
* Does NOT use jest mocks - this is a proper test double.
|
|
182
198
|
*/
|
|
183
|
-
export class MockCheckpointsBuilder implements
|
|
199
|
+
export class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
184
200
|
private checkpointBuilder: MockCheckpointBuilder | undefined;
|
|
185
201
|
|
|
186
202
|
/** Track calls for assertions */
|
|
@@ -188,12 +204,16 @@ export class MockCheckpointsBuilder implements FunctionsOf<FullNodeCheckpointsBu
|
|
|
188
204
|
checkpointNumber: CheckpointNumber;
|
|
189
205
|
constants: CheckpointGlobalVariables;
|
|
190
206
|
l1ToL2Messages: Fr[];
|
|
207
|
+
previousCheckpointOutHashes: Fr[];
|
|
208
|
+
feeAssetPriceModifier: bigint;
|
|
191
209
|
}> = [];
|
|
192
210
|
public openCheckpointCalls: Array<{
|
|
193
211
|
checkpointNumber: CheckpointNumber;
|
|
194
212
|
constants: CheckpointGlobalVariables;
|
|
195
213
|
l1ToL2Messages: Fr[];
|
|
196
|
-
|
|
214
|
+
previousCheckpointOutHashes: Fr[];
|
|
215
|
+
existingBlocks: L2Block[];
|
|
216
|
+
feeAssetPriceModifier: bigint;
|
|
197
217
|
}> = [];
|
|
198
218
|
public updateConfigCalls: Array<Partial<FullNodeBlockBuilderConfig>> = [];
|
|
199
219
|
|
|
@@ -229,6 +249,7 @@ export class MockCheckpointsBuilder implements FunctionsOf<FullNodeCheckpointsBu
|
|
|
229
249
|
slotDuration: 24,
|
|
230
250
|
l1ChainId: 1,
|
|
231
251
|
rollupVersion: 1,
|
|
252
|
+
rollupManaLimit: 200_000_000,
|
|
232
253
|
};
|
|
233
254
|
}
|
|
234
255
|
|
|
@@ -239,34 +260,57 @@ export class MockCheckpointsBuilder implements FunctionsOf<FullNodeCheckpointsBu
|
|
|
239
260
|
startCheckpoint(
|
|
240
261
|
checkpointNumber: CheckpointNumber,
|
|
241
262
|
constants: CheckpointGlobalVariables,
|
|
263
|
+
feeAssetPriceModifier: bigint,
|
|
242
264
|
l1ToL2Messages: Fr[],
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
265
|
+
previousCheckpointOutHashes: Fr[],
|
|
266
|
+
_fork: MerkleTreeWriteOperations,
|
|
267
|
+
): Promise<ICheckpointBlockBuilder> {
|
|
268
|
+
this.startCheckpointCalls.push({
|
|
269
|
+
checkpointNumber,
|
|
270
|
+
constants,
|
|
271
|
+
l1ToL2Messages,
|
|
272
|
+
previousCheckpointOutHashes,
|
|
273
|
+
feeAssetPriceModifier,
|
|
274
|
+
});
|
|
246
275
|
|
|
247
276
|
if (!this.checkpointBuilder) {
|
|
248
277
|
// Auto-create a builder if none was set
|
|
249
278
|
this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
|
|
279
|
+
} else {
|
|
280
|
+
this.checkpointBuilder.resetCheckpointState();
|
|
250
281
|
}
|
|
251
282
|
|
|
252
|
-
return Promise.resolve(this.checkpointBuilder
|
|
283
|
+
return Promise.resolve(this.checkpointBuilder);
|
|
253
284
|
}
|
|
254
285
|
|
|
255
286
|
openCheckpoint(
|
|
256
287
|
checkpointNumber: CheckpointNumber,
|
|
257
288
|
constants: CheckpointGlobalVariables,
|
|
289
|
+
feeAssetPriceModifier: bigint,
|
|
258
290
|
l1ToL2Messages: Fr[],
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
291
|
+
previousCheckpointOutHashes: Fr[],
|
|
292
|
+
_fork: MerkleTreeWriteOperations,
|
|
293
|
+
existingBlocks: L2Block[] = [],
|
|
294
|
+
): Promise<ICheckpointBlockBuilder> {
|
|
295
|
+
this.openCheckpointCalls.push({
|
|
296
|
+
checkpointNumber,
|
|
297
|
+
constants,
|
|
298
|
+
l1ToL2Messages,
|
|
299
|
+
previousCheckpointOutHashes,
|
|
300
|
+
existingBlocks,
|
|
301
|
+
feeAssetPriceModifier,
|
|
302
|
+
});
|
|
263
303
|
|
|
264
304
|
if (!this.checkpointBuilder) {
|
|
265
305
|
// Auto-create a builder if none was set
|
|
266
306
|
this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
|
|
267
307
|
}
|
|
268
308
|
|
|
269
|
-
return Promise.resolve(this.checkpointBuilder
|
|
309
|
+
return Promise.resolve(this.checkpointBuilder);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
getFork(_blockNumber: BlockNumber): Promise<MerkleTreeWriteOperations> {
|
|
313
|
+
throw new Error('MockCheckpointsBuilder.getFork not implemented');
|
|
270
314
|
}
|
|
271
315
|
|
|
272
316
|
/** Reset for reuse in another test */
|
package/src/test/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Body } from '@aztec/aztec.js/block';
|
|
2
|
-
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { times } from '@aztec/foundation/collection';
|
|
4
4
|
import { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
5
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -7,7 +7,7 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
7
7
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
8
8
|
import type { P2P } from '@aztec/p2p';
|
|
9
9
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
10
|
-
import { CommitteeAttestation,
|
|
10
|
+
import { CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
|
|
11
11
|
import { BlockProposal, CheckpointAttestation, CheckpointProposal, ConsensusPayload } from '@aztec/stdlib/p2p';
|
|
12
12
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
13
13
|
import { makeAppendOnlyTreeSnapshot, mockTxForRollup } from '@aztec/stdlib/testing';
|
|
@@ -30,9 +30,9 @@ export async function makeTx(seed?: number, chainId?: Fr): Promise<Tx> {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* Creates an
|
|
33
|
+
* Creates an L2Block from transactions and global variables
|
|
34
34
|
*/
|
|
35
|
-
export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Promise<
|
|
35
|
+
export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Promise<L2Block> {
|
|
36
36
|
const processedTxs = await Promise.all(
|
|
37
37
|
txs.map(tx =>
|
|
38
38
|
makeProcessedTxFromPrivateOnlyTx(tx, Fr.ZERO, new PublicDataWrite(Fr.random(), Fr.random()), globalVariables),
|
|
@@ -41,7 +41,13 @@ export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Pr
|
|
|
41
41
|
const body = new Body(processedTxs.map(tx => tx.txEffect));
|
|
42
42
|
const header = BlockHeader.empty({ globalVariables });
|
|
43
43
|
const archive = makeAppendOnlyTreeSnapshot(globalVariables.blockNumber + 1);
|
|
44
|
-
return new
|
|
44
|
+
return new L2Block(
|
|
45
|
+
archive,
|
|
46
|
+
header,
|
|
47
|
+
body,
|
|
48
|
+
CheckpointNumber.fromBlockNumber(globalVariables.blockNumber),
|
|
49
|
+
IndexWithinCheckpoint(0),
|
|
50
|
+
);
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
/**
|
|
@@ -50,6 +56,7 @@ export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Pr
|
|
|
50
56
|
export function mockPendingTxs(p2p: MockProxy<P2P>, txs: Tx[]): void {
|
|
51
57
|
p2p.getPendingTxCount.mockResolvedValue(txs.length);
|
|
52
58
|
p2p.iteratePendingTxs.mockImplementation(() => mockTxIterator(Promise.resolve(txs)));
|
|
59
|
+
p2p.iterateEligiblePendingTxs.mockImplementation(() => mockTxIterator(Promise.resolve(txs)));
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
/**
|
|
@@ -70,16 +77,17 @@ export function createMockSignatures(signer: Secp256k1Signer): CommitteeAttestat
|
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
/**
|
|
73
|
-
* Creates a CheckpointHeader from an
|
|
74
|
-
* Uses mock values for blockHeadersHash, blobsHash and inHash since
|
|
80
|
+
* Creates a CheckpointHeader from an L2Block for testing purposes.
|
|
81
|
+
* Uses mock values for blockHeadersHash, blobsHash and inHash since L2Block doesn't have these fields.
|
|
75
82
|
*/
|
|
76
|
-
function createCheckpointHeaderFromBlock(block:
|
|
83
|
+
function createCheckpointHeaderFromBlock(block: L2Block): CheckpointHeader {
|
|
77
84
|
const gv = block.header.globalVariables;
|
|
78
85
|
return new CheckpointHeader(
|
|
79
86
|
block.header.lastArchive.root,
|
|
80
87
|
Fr.random(), // blockHeadersHash - mock value for testing
|
|
81
88
|
Fr.random(), // blobsHash - mock value for testing
|
|
82
89
|
Fr.random(), // inHash - mock value for testing
|
|
90
|
+
Fr.random(), // outHash - mock value for testing
|
|
83
91
|
gv.slotNumber,
|
|
84
92
|
gv.timestamp,
|
|
85
93
|
gv.coinbase,
|
|
@@ -92,7 +100,7 @@ function createCheckpointHeaderFromBlock(block: L2BlockNew): CheckpointHeader {
|
|
|
92
100
|
/**
|
|
93
101
|
* Creates a block proposal from a block and signature
|
|
94
102
|
*/
|
|
95
|
-
export function createBlockProposal(block:
|
|
103
|
+
export function createBlockProposal(block: L2Block, signature: Signature): BlockProposal {
|
|
96
104
|
const txHashes = block.body.txEffects.map(tx => tx.txHash);
|
|
97
105
|
return new BlockProposal(
|
|
98
106
|
block.header,
|
|
@@ -108,13 +116,14 @@ export function createBlockProposal(block: L2BlockNew, signature: Signature): Bl
|
|
|
108
116
|
* Creates a checkpoint proposal from a block and signature
|
|
109
117
|
*/
|
|
110
118
|
export function createCheckpointProposal(
|
|
111
|
-
block:
|
|
119
|
+
block: L2Block,
|
|
112
120
|
checkpointSignature: Signature,
|
|
113
121
|
blockSignature?: Signature,
|
|
122
|
+
feeAssetPriceModifier: bigint = 0n,
|
|
114
123
|
): CheckpointProposal {
|
|
115
124
|
const txHashes = block.body.txEffects.map(tx => tx.txHash);
|
|
116
125
|
const checkpointHeader = createCheckpointHeaderFromBlock(block);
|
|
117
|
-
return new CheckpointProposal(checkpointHeader, block.archive.root, checkpointSignature, {
|
|
126
|
+
return new CheckpointProposal(checkpointHeader, block.archive.root, feeAssetPriceModifier, checkpointSignature, {
|
|
118
127
|
blockHeader: block.header,
|
|
119
128
|
indexWithinCheckpoint: block.indexWithinCheckpoint,
|
|
120
129
|
txHashes,
|
|
@@ -128,12 +137,13 @@ export function createCheckpointProposal(
|
|
|
128
137
|
* In production, the sender is recovered from the signature.
|
|
129
138
|
*/
|
|
130
139
|
export function createCheckpointAttestation(
|
|
131
|
-
block:
|
|
140
|
+
block: L2Block,
|
|
132
141
|
signature: Signature,
|
|
133
142
|
sender: EthAddress,
|
|
143
|
+
feeAssetPriceModifier: bigint = 0n,
|
|
134
144
|
): CheckpointAttestation {
|
|
135
145
|
const checkpointHeader = createCheckpointHeaderFromBlock(block);
|
|
136
|
-
const payload = new ConsensusPayload(checkpointHeader, block.archive.root);
|
|
146
|
+
const payload = new ConsensusPayload(checkpointHeader, block.archive.root, feeAssetPriceModifier);
|
|
137
147
|
const attestation = new CheckpointAttestation(payload, signature, signature);
|
|
138
148
|
// Set sender directly for testing (bypasses signature recovery)
|
|
139
149
|
(attestation as any).sender = sender;
|
|
@@ -149,7 +159,7 @@ export async function setupTxsAndBlock(
|
|
|
149
159
|
globalVariables: GlobalVariables,
|
|
150
160
|
txCount: number,
|
|
151
161
|
chainId: Fr,
|
|
152
|
-
): Promise<{ txs: Tx[]; block:
|
|
162
|
+
): Promise<{ txs: Tx[]; block: L2Block }> {
|
|
153
163
|
const txs = await Promise.all(times(txCount, i => makeTx(i + 1, chainId)));
|
|
154
164
|
const block = await makeBlock(txs, globalVariables);
|
|
155
165
|
mockPendingTxs(p2p, txs);
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
|
-
import { PublicProcessor } from '@aztec/simulator/server';
|
|
5
|
-
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
6
|
-
import type { BuildBlockResult, FullNodeBlockBuilderConfig, IFullNodeBlockBuilder, MerkleTreeWriteOperations, PublicProcessorLimits, PublicProcessorValidator, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
7
|
-
import { GlobalVariables, Tx } from '@aztec/stdlib/tx';
|
|
8
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
9
|
-
export declare class FullNodeBlockBuilder implements IFullNodeBlockBuilder {
|
|
10
|
-
private config;
|
|
11
|
-
private worldState;
|
|
12
|
-
private contractDataSource;
|
|
13
|
-
private dateProvider;
|
|
14
|
-
private telemetryClient;
|
|
15
|
-
constructor(config: FullNodeBlockBuilderConfig, worldState: WorldStateSynchronizer, contractDataSource: ContractDataSource, dateProvider: DateProvider, telemetryClient?: TelemetryClient);
|
|
16
|
-
getConfig(): FullNodeBlockBuilderConfig;
|
|
17
|
-
updateConfig(config: Partial<FullNodeBlockBuilderConfig>): void;
|
|
18
|
-
makeBlockBuilderDeps(globalVariables: GlobalVariables, fork: MerkleTreeWriteOperations): Promise<{
|
|
19
|
-
processor: PublicProcessor;
|
|
20
|
-
validator: PublicProcessorValidator;
|
|
21
|
-
}>;
|
|
22
|
-
private syncToPreviousBlock;
|
|
23
|
-
buildBlock(pendingTxs: Iterable<Tx> | AsyncIterable<Tx>, l1ToL2Messages: Fr[], globalVariables: GlobalVariables, opts: PublicProcessorLimits, suppliedFork?: MerkleTreeWriteOperations): Promise<BuildBlockResult>;
|
|
24
|
-
getFork(blockNumber: BlockNumber): Promise<MerkleTreeWriteOperations>;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfYnVpbGRlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlcXVlbmNlci9ibG9ja19idWlsZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU5RCxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUl6RCxPQUFPLEVBQUUsWUFBWSxFQUFrQixNQUFNLHlCQUF5QixDQUFDO0FBR3ZFLE9BQU8sRUFHTCxlQUFlLEVBRWhCLE1BQU0seUJBQXlCLENBQUM7QUFDakMsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUdqRSxPQUFPLEtBQUssRUFDVixnQkFBZ0IsRUFDaEIsMEJBQTBCLEVBQzFCLHFCQUFxQixFQUNyQix5QkFBeUIsRUFDekIscUJBQXFCLEVBQ3JCLHdCQUF3QixFQUN4QixzQkFBc0I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