@aztec/sequencer-client 0.0.1-commit.b655e406 → 0.0.1-commit.d1f2d6c
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/index.d.ts +1 -1
- package/dest/client/sequencer-client.d.ts +12 -12
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +32 -24
- package/dest/config.d.ts +12 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +80 -28
- package/dest/global_variable_builder/global_builder.d.ts +22 -16
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +52 -39
- package/dest/global_variable_builder/index.d.ts +1 -1
- package/dest/index.d.ts +2 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/publisher/config.d.ts +9 -4
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +14 -3
- package/dest/publisher/index.d.ts +1 -1
- package/dest/publisher/sequencer-publisher-factory.d.ts +5 -4
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +15 -86
- package/dest/publisher/sequencer-publisher.d.ts +75 -61
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +661 -158
- package/dest/sequencer/checkpoint_proposal_job.d.ts +79 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +1164 -0
- package/dest/sequencer/checkpoint_voter.d.ts +35 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +109 -0
- package/dest/sequencer/config.d.ts +3 -2
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/errors.d.ts +1 -1
- package/dest/sequencer/errors.d.ts.map +1 -1
- package/dest/sequencer/events.d.ts +46 -0
- package/dest/sequencer/events.d.ts.map +1 -0
- package/dest/sequencer/events.js +1 -0
- package/dest/sequencer/index.d.ts +4 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +3 -1
- package/dest/sequencer/metrics.d.ts +32 -3
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +147 -46
- package/dest/sequencer/sequencer.d.ts +110 -142
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +716 -504
- package/dest/sequencer/timetable.d.ts +54 -14
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +148 -59
- package/dest/sequencer/types.d.ts +3 -0
- package/dest/sequencer/types.d.ts.map +1 -0
- package/dest/sequencer/types.js +1 -0
- package/dest/sequencer/utils.d.ts +14 -8
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +7 -4
- package/dest/test/index.d.ts +4 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +92 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +208 -0
- package/dest/test/utils.d.ts +53 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +103 -0
- package/package.json +33 -30
- package/src/client/sequencer-client.ts +30 -41
- package/src/config.ts +86 -32
- package/src/global_variable_builder/global_builder.ts +67 -59
- package/src/index.ts +1 -7
- package/src/publisher/config.ts +20 -9
- package/src/publisher/sequencer-publisher-factory.ts +7 -5
- package/src/publisher/sequencer-publisher-metrics.ts +16 -72
- package/src/publisher/sequencer-publisher.ts +381 -203
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/checkpoint_proposal_job.ts +843 -0
- package/src/sequencer/checkpoint_voter.ts +130 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +3 -1
- package/src/sequencer/metrics.ts +198 -55
- package/src/sequencer/sequencer.ts +465 -696
- package/src/sequencer/timetable.ts +173 -79
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +18 -9
- package/src/test/index.ts +3 -2
- package/src/test/mock_checkpoint_builder.ts +295 -0
- package/src/test/utils.ts +164 -0
- package/dest/sequencer/block_builder.d.ts +0 -27
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -130
- package/dest/tx_validator/nullifier_cache.d.ts +0 -14
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -17
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -53
- package/src/sequencer/block_builder.ts +0 -218
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -132
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
3
|
+
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
4
|
+
import { Gas } from '@aztec/stdlib/gas';
|
|
5
|
+
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
6
|
+
import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
|
|
7
|
+
/**
|
|
8
|
+
* A fake CheckpointBuilder for testing that implements the same interface as the real one.
|
|
9
|
+
* Can be seeded with blocks to return sequentially on each `buildBlock` call.
|
|
10
|
+
*/ export class MockCheckpointBuilder {
|
|
11
|
+
constants;
|
|
12
|
+
checkpointNumber;
|
|
13
|
+
blocks;
|
|
14
|
+
builtBlocks;
|
|
15
|
+
usedTxsPerBlock;
|
|
16
|
+
blockIndex;
|
|
17
|
+
/** Optional function to dynamically provide the block (alternative to seedBlocks) */ blockProvider;
|
|
18
|
+
/** Track calls for assertions */ buildBlockCalls;
|
|
19
|
+
completeCheckpointCalled;
|
|
20
|
+
getCheckpointCalled;
|
|
21
|
+
/** Set to an error to make buildBlock throw on next call */ errorOnBuild;
|
|
22
|
+
constructor(constants, checkpointNumber){
|
|
23
|
+
this.constants = constants;
|
|
24
|
+
this.checkpointNumber = checkpointNumber;
|
|
25
|
+
this.blocks = [];
|
|
26
|
+
this.builtBlocks = [];
|
|
27
|
+
this.usedTxsPerBlock = [];
|
|
28
|
+
this.blockIndex = 0;
|
|
29
|
+
this.blockProvider = undefined;
|
|
30
|
+
this.buildBlockCalls = [];
|
|
31
|
+
this.completeCheckpointCalled = false;
|
|
32
|
+
this.getCheckpointCalled = false;
|
|
33
|
+
this.errorOnBuild = undefined;
|
|
34
|
+
}
|
|
35
|
+
/** Seed the builder with blocks to return on successive buildBlock calls */ seedBlocks(blocks, usedTxsPerBlock) {
|
|
36
|
+
this.blocks = blocks;
|
|
37
|
+
this.usedTxsPerBlock = usedTxsPerBlock ?? blocks.map(()=>[]);
|
|
38
|
+
this.blockIndex = 0;
|
|
39
|
+
this.blockProvider = undefined;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Set a function that provides blocks dynamically.
|
|
44
|
+
* Useful for tests where the block is determined at call time (e.g., sequencer tests).
|
|
45
|
+
*/ setBlockProvider(provider) {
|
|
46
|
+
this.blockProvider = provider;
|
|
47
|
+
this.blocks = [];
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
getConstantData() {
|
|
51
|
+
return this.constants;
|
|
52
|
+
}
|
|
53
|
+
buildBlock(_pendingTxs, blockNumber, timestamp, opts) {
|
|
54
|
+
this.buildBlockCalls.push({
|
|
55
|
+
blockNumber,
|
|
56
|
+
timestamp,
|
|
57
|
+
opts
|
|
58
|
+
});
|
|
59
|
+
if (this.errorOnBuild) {
|
|
60
|
+
return Promise.reject(this.errorOnBuild);
|
|
61
|
+
}
|
|
62
|
+
let block;
|
|
63
|
+
let usedTxs;
|
|
64
|
+
if (this.blockProvider) {
|
|
65
|
+
// Dynamic mode: get block from provider
|
|
66
|
+
block = this.blockProvider();
|
|
67
|
+
usedTxs = [];
|
|
68
|
+
this.builtBlocks.push(block);
|
|
69
|
+
} else {
|
|
70
|
+
// Seeded mode: get block from pre-seeded list
|
|
71
|
+
block = this.blocks[this.blockIndex];
|
|
72
|
+
usedTxs = this.usedTxsPerBlock[this.blockIndex] ?? [];
|
|
73
|
+
this.blockIndex++;
|
|
74
|
+
this.builtBlocks.push(block);
|
|
75
|
+
}
|
|
76
|
+
return Promise.resolve({
|
|
77
|
+
block,
|
|
78
|
+
publicGas: Gas.empty(),
|
|
79
|
+
publicProcessorDuration: 0,
|
|
80
|
+
numTxs: block?.body?.txEffects?.length ?? usedTxs.length,
|
|
81
|
+
blockBuildingTimer: new Timer(),
|
|
82
|
+
usedTxs,
|
|
83
|
+
failedTxs: [],
|
|
84
|
+
usedTxBlobFields: block?.body?.txEffects?.reduce((sum, tx)=>sum + tx.getNumBlobFields(), 0) ?? 0
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
completeCheckpoint() {
|
|
88
|
+
this.completeCheckpointCalled = true;
|
|
89
|
+
const allBlocks = this.blockProvider ? this.builtBlocks : this.blocks;
|
|
90
|
+
const lastBlock = allBlocks[allBlocks.length - 1];
|
|
91
|
+
// Create a CheckpointHeader from the last block's header for testing
|
|
92
|
+
const checkpointHeader = this.createCheckpointHeader(lastBlock);
|
|
93
|
+
return Promise.resolve(new Checkpoint(makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1), checkpointHeader, allBlocks, this.checkpointNumber));
|
|
94
|
+
}
|
|
95
|
+
getCheckpoint() {
|
|
96
|
+
this.getCheckpointCalled = true;
|
|
97
|
+
const builtBlocks = this.blockProvider ? this.builtBlocks : this.blocks.slice(0, this.blockIndex);
|
|
98
|
+
const lastBlock = builtBlocks[builtBlocks.length - 1];
|
|
99
|
+
if (!lastBlock) {
|
|
100
|
+
throw new Error('No blocks built yet');
|
|
101
|
+
}
|
|
102
|
+
// Create a CheckpointHeader from the last block's header for testing
|
|
103
|
+
const checkpointHeader = this.createCheckpointHeader(lastBlock);
|
|
104
|
+
return Promise.resolve(new Checkpoint(makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1), checkpointHeader, builtBlocks, this.checkpointNumber));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Creates a CheckpointHeader from a block's header for testing.
|
|
108
|
+
* This is a simplified version that creates a minimal CheckpointHeader.
|
|
109
|
+
*/ createCheckpointHeader(block) {
|
|
110
|
+
const header = block.header;
|
|
111
|
+
const gv = header.globalVariables;
|
|
112
|
+
return CheckpointHeader.empty({
|
|
113
|
+
lastArchiveRoot: header.lastArchive.root,
|
|
114
|
+
blockHeadersHash: Fr.random(),
|
|
115
|
+
slotNumber: gv.slotNumber,
|
|
116
|
+
timestamp: gv.timestamp,
|
|
117
|
+
coinbase: gv.coinbase,
|
|
118
|
+
feeRecipient: gv.feeRecipient,
|
|
119
|
+
gasFees: gv.gasFees,
|
|
120
|
+
totalManaUsed: header.totalManaUsed
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/** Reset for reuse in another test */ reset() {
|
|
124
|
+
this.blocks = [];
|
|
125
|
+
this.builtBlocks = [];
|
|
126
|
+
this.usedTxsPerBlock = [];
|
|
127
|
+
this.blockIndex = 0;
|
|
128
|
+
this.buildBlockCalls = [];
|
|
129
|
+
this.completeCheckpointCalled = false;
|
|
130
|
+
this.getCheckpointCalled = false;
|
|
131
|
+
this.errorOnBuild = undefined;
|
|
132
|
+
this.blockProvider = undefined;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A fake CheckpointsBuilder (factory) for testing that implements the same interface
|
|
137
|
+
* as FullNodeCheckpointsBuilder. Returns MockCheckpointBuilder instances.
|
|
138
|
+
* Does NOT use jest mocks - this is a proper test double.
|
|
139
|
+
*/ export class MockCheckpointsBuilder {
|
|
140
|
+
checkpointBuilder;
|
|
141
|
+
/** Track calls for assertions */ startCheckpointCalls = [];
|
|
142
|
+
openCheckpointCalls = [];
|
|
143
|
+
updateConfigCalls = [];
|
|
144
|
+
/**
|
|
145
|
+
* Set the MockCheckpointBuilder to return from startCheckpoint.
|
|
146
|
+
* Must be called before startCheckpoint is invoked.
|
|
147
|
+
*/ setCheckpointBuilder(builder) {
|
|
148
|
+
this.checkpointBuilder = builder;
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Creates a new MockCheckpointBuilder with the given constants.
|
|
153
|
+
* Convenience method that creates and sets the builder in one call.
|
|
154
|
+
*/ createCheckpointBuilder(constants, checkpointNumber) {
|
|
155
|
+
this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
|
|
156
|
+
return this.checkpointBuilder;
|
|
157
|
+
}
|
|
158
|
+
/** Get the current checkpoint builder (for assertions) */ getCheckpointBuilder() {
|
|
159
|
+
return this.checkpointBuilder;
|
|
160
|
+
}
|
|
161
|
+
getConfig() {
|
|
162
|
+
return {
|
|
163
|
+
l1GenesisTime: 0n,
|
|
164
|
+
slotDuration: 24,
|
|
165
|
+
l1ChainId: 1,
|
|
166
|
+
rollupVersion: 1
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
updateConfig(config) {
|
|
170
|
+
this.updateConfigCalls.push(config);
|
|
171
|
+
}
|
|
172
|
+
startCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, _fork) {
|
|
173
|
+
this.startCheckpointCalls.push({
|
|
174
|
+
checkpointNumber,
|
|
175
|
+
constants,
|
|
176
|
+
l1ToL2Messages,
|
|
177
|
+
previousCheckpointOutHashes
|
|
178
|
+
});
|
|
179
|
+
if (!this.checkpointBuilder) {
|
|
180
|
+
// Auto-create a builder if none was set
|
|
181
|
+
this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
|
|
182
|
+
}
|
|
183
|
+
return Promise.resolve(this.checkpointBuilder);
|
|
184
|
+
}
|
|
185
|
+
openCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, _fork, existingBlocks = []) {
|
|
186
|
+
this.openCheckpointCalls.push({
|
|
187
|
+
checkpointNumber,
|
|
188
|
+
constants,
|
|
189
|
+
l1ToL2Messages,
|
|
190
|
+
previousCheckpointOutHashes,
|
|
191
|
+
existingBlocks
|
|
192
|
+
});
|
|
193
|
+
if (!this.checkpointBuilder) {
|
|
194
|
+
// Auto-create a builder if none was set
|
|
195
|
+
this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
|
|
196
|
+
}
|
|
197
|
+
return Promise.resolve(this.checkpointBuilder);
|
|
198
|
+
}
|
|
199
|
+
getFork(_blockNumber) {
|
|
200
|
+
throw new Error('MockCheckpointsBuilder.getFork not implemented');
|
|
201
|
+
}
|
|
202
|
+
/** Reset for reuse in another test */ reset() {
|
|
203
|
+
this.checkpointBuilder = undefined;
|
|
204
|
+
this.startCheckpointCalls = [];
|
|
205
|
+
this.openCheckpointCalls = [];
|
|
206
|
+
this.updateConfigCalls = [];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
|
+
import type { P2P } from '@aztec/p2p';
|
|
6
|
+
import { CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
|
|
7
|
+
import { BlockProposal, CheckpointAttestation, CheckpointProposal } from '@aztec/stdlib/p2p';
|
|
8
|
+
import { GlobalVariables, type Tx } from '@aztec/stdlib/tx';
|
|
9
|
+
import type { MockProxy } from 'jest-mock-extended';
|
|
10
|
+
export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint_builder.js';
|
|
11
|
+
/**
|
|
12
|
+
* Creates a mock transaction with a specific seed for deterministic testing
|
|
13
|
+
*/
|
|
14
|
+
export declare function makeTx(seed?: number, chainId?: Fr): Promise<Tx>;
|
|
15
|
+
/**
|
|
16
|
+
* Creates an L2Block from transactions and global variables
|
|
17
|
+
*/
|
|
18
|
+
export declare function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Promise<L2Block>;
|
|
19
|
+
/**
|
|
20
|
+
* Mocks the P2P client to return specific pending transactions
|
|
21
|
+
*/
|
|
22
|
+
export declare function mockPendingTxs(p2p: MockProxy<P2P>, txs: Tx[]): void;
|
|
23
|
+
/**
|
|
24
|
+
* Creates an async iterator for transactions
|
|
25
|
+
*/
|
|
26
|
+
export declare function mockTxIterator(txs: Promise<Tx[]>): AsyncIterableIterator<Tx>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates mock committee attestations from a signer
|
|
29
|
+
*/
|
|
30
|
+
export declare function createMockSignatures(signer: Secp256k1Signer): CommitteeAttestation[];
|
|
31
|
+
/**
|
|
32
|
+
* Creates a block proposal from a block and signature
|
|
33
|
+
*/
|
|
34
|
+
export declare function createBlockProposal(block: L2Block, signature: Signature): BlockProposal;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a checkpoint proposal from a block and signature
|
|
37
|
+
*/
|
|
38
|
+
export declare function createCheckpointProposal(block: L2Block, checkpointSignature: Signature, blockSignature?: Signature): CheckpointProposal;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a checkpoint attestation from a block and signature.
|
|
41
|
+
* Note: We manually set the sender since we use random signatures in tests.
|
|
42
|
+
* In production, the sender is recovered from the signature.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createCheckpointAttestation(block: L2Block, signature: Signature, sender: EthAddress): CheckpointAttestation;
|
|
45
|
+
/**
|
|
46
|
+
* Creates transactions and a block, and mocks P2P to return them.
|
|
47
|
+
* Helper for tests that need to set up a block with transactions.
|
|
48
|
+
*/
|
|
49
|
+
export declare function setupTxsAndBlock(p2p: MockProxy<P2P>, globalVariables: GlobalVariables, txCount: number, chainId: Fr): Promise<{
|
|
50
|
+
txs: Tx[];
|
|
51
|
+
block: L2Block;
|
|
52
|
+
}>;
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0L3V0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSwyQ0FBMkMsQ0FBQztBQUM1RSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDaEUsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQzVELE9BQU8sS0FBSyxFQUFFLEdBQUcsRUFBRSxNQUFNLFlBQVksQ0FBQztBQUV0QyxPQUFPLEVBQUUsb0JBQW9CLEVBQUUsT0FBTyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDcEUsT0FBTyxFQUFFLGFBQWEsRUFBRSxxQkFBcUIsRUFBRSxrQkFBa0IsRUFBb0IsTUFBTSxtQkFBbUIsQ0FBQztBQUcvRyxPQUFPLEVBQWUsZUFBZSxFQUFFLEtBQUssRUFBRSxFQUFvQyxNQUFNLGtCQUFrQixDQUFDO0FBRTNHLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBR3BELE9BQU8sRUFBRSxxQkFBcUIsRUFBRSxzQkFBc0IsRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBRTdGOztHQUVHO0FBQ0gsd0JBQXNCLE1BQU0sQ0FBQyxJQUFJLENBQUMsRUFBRSxNQUFNLEVBQUUsT0FBTyxDQUFDLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxFQUFFLENBQUMsQ0FNckU7QUFFRDs7R0FFRztBQUNILHdCQUFzQixTQUFTLENBQUMsR0FBRyxFQUFFLEVBQUUsRUFBRSxFQUFFLGVBQWUsRUFBRSxlQUFlLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQWdCN0Y7QUFFRDs7R0FFRztBQUNILHdCQUFnQixjQUFjLENBQUMsR0FBRyxFQUFFLFNBQVMsQ0FBQyxHQUFHLENBQUMsRUFBRSxHQUFHLEVBQUUsRUFBRSxFQUFFLEdBQUcsSUFBSSxDQUduRTtBQUVEOztHQUVHO0FBQ0gsd0JBQXVCLGNBQWMsQ0FBQyxHQUFHLEVBQUUsT0FBTyxDQUFDLEVBQUUsRUFBRSxDQUFDLEdBQUcscUJBQXFCLENBQUMsRUFBRSxDQUFDLENBSW5GO0FBRUQ7O0dBRUc7QUFDSCx3QkFBZ0Isb0JBQW9CLENBQUMsTUFBTSxFQUFFLGVBQWUsR0FBRyxvQkFBb0IsRUFBRSxDQUdwRjtBQXVCRDs7R0FFRztBQUNILHdCQUFnQixtQkFBbUIsQ0FBQyxLQUFLLEVBQUUsT0FBTyxFQUFFLFNBQVMsRUFBRSxTQUFTLEdBQUcsYUFBYSxDQVV2RjtBQUVEOztHQUVHO0FBQ0gsd0JBQWdCLHdCQUF3QixDQUN0QyxLQUFLLEVBQUUsT0FBTyxFQUNkLG1CQUFtQixFQUFFLFNBQVMsRUFDOUIsY0FBYyxDQUFDLEVBQUUsU0FBUyxHQUN6QixrQkFBa0IsQ0FTcEI7QUFFRDs7OztHQUlHO0FBQ0gsd0JBQWdCLDJCQUEyQixDQUN6QyxLQUFLLEVBQUUsT0FBTyxFQUNkLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLE1BQU0sRUFBRSxVQUFVLEdBQ2pCLHFCQUFxQixDQU92QjtBQUVEOzs7R0FHRztBQUNILHdCQUFzQixnQkFBZ0IsQ0FDcEMsR0FBRyxFQUFFLFNBQVMsQ0FBQyxHQUFHLENBQUMsRUFDbkIsZUFBZSxFQUFFLGVBQWUsRUFDaEMsT0FBTyxFQUFFLE1BQU0sRUFDZixPQUFPLEVBQUUsRUFBRSxHQUNWLE9BQU8sQ0FBQztJQUFFLEdBQUcsRUFBRSxFQUFFLEVBQUUsQ0FBQztJQUFDLEtBQUssRUFBRSxPQUFPLENBQUE7Q0FBRSxDQUFDLENBS3hDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/test/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,kBAAkB,EAAoB,MAAM,mBAAmB,CAAC;AAG/G,OAAO,EAAe,eAAe,EAAE,KAAK,EAAE,EAAoC,MAAM,kBAAkB,CAAC;AAE3G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE7F;;GAEG;AACH,wBAAsB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,CAMrE;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAgB7F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,IAAI,CAGnE;AAED;;GAEG;AACH,wBAAuB,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,GAAG,qBAAqB,CAAC,EAAE,CAAC,CAInF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,oBAAoB,EAAE,CAGpF;AAuBD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,aAAa,CAUvF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,EACd,mBAAmB,EAAE,SAAS,EAC9B,cAAc,CAAC,EAAE,SAAS,GACzB,kBAAkB,CASpB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,UAAU,GACjB,qBAAqB,CAOvB;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,EACnB,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,EAAE,GACV,OAAO,CAAC;IAAE,GAAG,EAAE,EAAE,EAAE,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAKxC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Body } from '@aztec/aztec.js/block';
|
|
2
|
+
import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { times } from '@aztec/foundation/collection';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
6
|
+
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
7
|
+
import { CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
|
|
8
|
+
import { BlockProposal, CheckpointAttestation, CheckpointProposal, ConsensusPayload } from '@aztec/stdlib/p2p';
|
|
9
|
+
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
10
|
+
import { makeAppendOnlyTreeSnapshot, mockTxForRollup } from '@aztec/stdlib/testing';
|
|
11
|
+
import { BlockHeader, makeProcessedTxFromPrivateOnlyTx } from '@aztec/stdlib/tx';
|
|
12
|
+
// Re-export mock classes from their dedicated file
|
|
13
|
+
export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint_builder.js';
|
|
14
|
+
/**
|
|
15
|
+
* Creates a mock transaction with a specific seed for deterministic testing
|
|
16
|
+
*/ export async function makeTx(seed, chainId) {
|
|
17
|
+
const tx = await mockTxForRollup(seed);
|
|
18
|
+
if (chainId) {
|
|
19
|
+
tx.data.constants.txContext.chainId = chainId;
|
|
20
|
+
}
|
|
21
|
+
return tx;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates an L2Block from transactions and global variables
|
|
25
|
+
*/ export async function makeBlock(txs, globalVariables) {
|
|
26
|
+
const processedTxs = await Promise.all(txs.map((tx)=>makeProcessedTxFromPrivateOnlyTx(tx, Fr.ZERO, new PublicDataWrite(Fr.random(), Fr.random()), globalVariables)));
|
|
27
|
+
const body = new Body(processedTxs.map((tx)=>tx.txEffect));
|
|
28
|
+
const header = BlockHeader.empty({
|
|
29
|
+
globalVariables
|
|
30
|
+
});
|
|
31
|
+
const archive = makeAppendOnlyTreeSnapshot(globalVariables.blockNumber + 1);
|
|
32
|
+
return new L2Block(archive, header, body, CheckpointNumber.fromBlockNumber(globalVariables.blockNumber), IndexWithinCheckpoint(0));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Mocks the P2P client to return specific pending transactions
|
|
36
|
+
*/ export function mockPendingTxs(p2p, txs) {
|
|
37
|
+
p2p.getPendingTxCount.mockResolvedValue(txs.length);
|
|
38
|
+
p2p.iteratePendingTxs.mockImplementation(()=>mockTxIterator(Promise.resolve(txs)));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates an async iterator for transactions
|
|
42
|
+
*/ export async function* mockTxIterator(txs) {
|
|
43
|
+
for (const tx of (await txs)){
|
|
44
|
+
yield tx;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates mock committee attestations from a signer
|
|
49
|
+
*/ export function createMockSignatures(signer) {
|
|
50
|
+
const mockedSig = Signature.random();
|
|
51
|
+
return [
|
|
52
|
+
new CommitteeAttestation(signer.address, mockedSig)
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Creates a CheckpointHeader from an L2Block for testing purposes.
|
|
57
|
+
* Uses mock values for blockHeadersHash, blobsHash and inHash since L2Block doesn't have these fields.
|
|
58
|
+
*/ function createCheckpointHeaderFromBlock(block) {
|
|
59
|
+
const gv = block.header.globalVariables;
|
|
60
|
+
return new CheckpointHeader(block.header.lastArchive.root, Fr.random(), Fr.random(), Fr.random(), Fr.random(), gv.slotNumber, gv.timestamp, gv.coinbase, gv.feeRecipient, gv.gasFees, block.header.totalManaUsed);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates a block proposal from a block and signature
|
|
64
|
+
*/ export function createBlockProposal(block, signature) {
|
|
65
|
+
const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
|
|
66
|
+
return new BlockProposal(block.header, block.indexWithinCheckpoint, Fr.ZERO, block.archive.root, txHashes, signature);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Creates a checkpoint proposal from a block and signature
|
|
70
|
+
*/ export function createCheckpointProposal(block, checkpointSignature, blockSignature) {
|
|
71
|
+
const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
|
|
72
|
+
const checkpointHeader = createCheckpointHeaderFromBlock(block);
|
|
73
|
+
return new CheckpointProposal(checkpointHeader, block.archive.root, checkpointSignature, {
|
|
74
|
+
blockHeader: block.header,
|
|
75
|
+
indexWithinCheckpoint: block.indexWithinCheckpoint,
|
|
76
|
+
txHashes,
|
|
77
|
+
signature: blockSignature ?? checkpointSignature
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates a checkpoint attestation from a block and signature.
|
|
82
|
+
* Note: We manually set the sender since we use random signatures in tests.
|
|
83
|
+
* In production, the sender is recovered from the signature.
|
|
84
|
+
*/ export function createCheckpointAttestation(block, signature, sender) {
|
|
85
|
+
const checkpointHeader = createCheckpointHeaderFromBlock(block);
|
|
86
|
+
const payload = new ConsensusPayload(checkpointHeader, block.archive.root);
|
|
87
|
+
const attestation = new CheckpointAttestation(payload, signature, signature);
|
|
88
|
+
// Set sender directly for testing (bypasses signature recovery)
|
|
89
|
+
attestation.sender = sender;
|
|
90
|
+
return attestation;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Creates transactions and a block, and mocks P2P to return them.
|
|
94
|
+
* Helper for tests that need to set up a block with transactions.
|
|
95
|
+
*/ export async function setupTxsAndBlock(p2p, globalVariables, txCount, chainId) {
|
|
96
|
+
const txs = await Promise.all(times(txCount, (i)=>makeTx(i + 1, chainId)));
|
|
97
|
+
const block = await makeBlock(txs, globalVariables);
|
|
98
|
+
mockPendingTxs(p2p, txs);
|
|
99
|
+
return {
|
|
100
|
+
txs,
|
|
101
|
+
block
|
|
102
|
+
};
|
|
103
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/sequencer-client",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.d1f2d6c",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -18,50 +18,53 @@
|
|
|
18
18
|
"../package.common.json"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "yarn clean && tsc
|
|
22
|
-
"build:dev": "tsc
|
|
21
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
22
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
23
23
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
24
24
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
|
|
25
25
|
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
|
|
26
26
|
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
30
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
31
|
-
"@aztec/blob-
|
|
32
|
-
"@aztec/blob-
|
|
33
|
-
"@aztec/constants": "0.0.1-commit.
|
|
34
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
35
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
36
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
37
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
38
|
-
"@aztec/merkle-tree": "0.0.1-commit.
|
|
39
|
-
"@aztec/node-keystore": "0.0.1-commit.
|
|
40
|
-
"@aztec/noir-acvm_js": "0.0.1-commit.
|
|
41
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
42
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
43
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
44
|
-
"@aztec/p2p": "0.0.1-commit.
|
|
45
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
46
|
-
"@aztec/prover-client": "0.0.1-commit.
|
|
47
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
48
|
-
"@aztec/slasher": "0.0.1-commit.
|
|
49
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
50
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
51
|
-
"@aztec/validator-client": "0.0.1-commit.
|
|
52
|
-
"@aztec/
|
|
29
|
+
"@aztec/aztec.js": "0.0.1-commit.d1f2d6c",
|
|
30
|
+
"@aztec/bb-prover": "0.0.1-commit.d1f2d6c",
|
|
31
|
+
"@aztec/blob-client": "0.0.1-commit.d1f2d6c",
|
|
32
|
+
"@aztec/blob-lib": "0.0.1-commit.d1f2d6c",
|
|
33
|
+
"@aztec/constants": "0.0.1-commit.d1f2d6c",
|
|
34
|
+
"@aztec/epoch-cache": "0.0.1-commit.d1f2d6c",
|
|
35
|
+
"@aztec/ethereum": "0.0.1-commit.d1f2d6c",
|
|
36
|
+
"@aztec/foundation": "0.0.1-commit.d1f2d6c",
|
|
37
|
+
"@aztec/l1-artifacts": "0.0.1-commit.d1f2d6c",
|
|
38
|
+
"@aztec/merkle-tree": "0.0.1-commit.d1f2d6c",
|
|
39
|
+
"@aztec/node-keystore": "0.0.1-commit.d1f2d6c",
|
|
40
|
+
"@aztec/noir-acvm_js": "0.0.1-commit.d1f2d6c",
|
|
41
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.d1f2d6c",
|
|
42
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.d1f2d6c",
|
|
43
|
+
"@aztec/noir-types": "0.0.1-commit.d1f2d6c",
|
|
44
|
+
"@aztec/p2p": "0.0.1-commit.d1f2d6c",
|
|
45
|
+
"@aztec/protocol-contracts": "0.0.1-commit.d1f2d6c",
|
|
46
|
+
"@aztec/prover-client": "0.0.1-commit.d1f2d6c",
|
|
47
|
+
"@aztec/simulator": "0.0.1-commit.d1f2d6c",
|
|
48
|
+
"@aztec/slasher": "0.0.1-commit.d1f2d6c",
|
|
49
|
+
"@aztec/stdlib": "0.0.1-commit.d1f2d6c",
|
|
50
|
+
"@aztec/telemetry-client": "0.0.1-commit.d1f2d6c",
|
|
51
|
+
"@aztec/validator-client": "0.0.1-commit.d1f2d6c",
|
|
52
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.d1f2d6c",
|
|
53
|
+
"@aztec/world-state": "0.0.1-commit.d1f2d6c",
|
|
53
54
|
"lodash.chunk": "^4.2.0",
|
|
54
55
|
"tslib": "^2.4.0",
|
|
55
|
-
"viem": "npm:@
|
|
56
|
+
"viem": "npm:@aztec/viem@2.38.2"
|
|
56
57
|
},
|
|
57
58
|
"devDependencies": {
|
|
58
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
59
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
59
|
+
"@aztec/archiver": "0.0.1-commit.d1f2d6c",
|
|
60
|
+
"@aztec/kv-store": "0.0.1-commit.d1f2d6c",
|
|
61
|
+
"@electric-sql/pglite": "^0.3.14",
|
|
60
62
|
"@jest/globals": "^30.0.0",
|
|
61
63
|
"@types/jest": "^30.0.0",
|
|
62
64
|
"@types/lodash.chunk": "^4.2.7",
|
|
63
65
|
"@types/lodash.pick": "^4.4.7",
|
|
64
66
|
"@types/node": "^22.15.17",
|
|
67
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
65
68
|
"concurrently": "^7.6.0",
|
|
66
69
|
"eslint": "^9.26.0",
|
|
67
70
|
"express": "^4.21.2",
|
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
2
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
RollupContract,
|
|
7
|
-
getPublicClient,
|
|
8
|
-
isAnvilTestChain,
|
|
9
|
-
} from '@aztec/ethereum';
|
|
3
|
+
import { isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
4
|
+
import { getPublicClient } from '@aztec/ethereum/client';
|
|
5
|
+
import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
10
6
|
import { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
7
|
+
import { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
11
8
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
13
10
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
14
11
|
import type { KeystoreManager } from '@aztec/node-keystore';
|
|
15
12
|
import type { P2P } from '@aztec/p2p';
|
|
16
13
|
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
17
|
-
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
18
|
-
import type {
|
|
19
|
-
IFullNodeBlockBuilder,
|
|
20
|
-
ValidatorClientFullConfig,
|
|
21
|
-
WorldStateSynchronizer,
|
|
22
|
-
} from '@aztec/stdlib/interfaces/server';
|
|
14
|
+
import type { L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
15
|
+
import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
23
16
|
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
24
17
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
25
18
|
import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
|
|
26
|
-
import { NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
|
|
19
|
+
import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
|
|
27
20
|
|
|
28
21
|
import type { SequencerClientConfig } from '../config.js';
|
|
29
22
|
import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
@@ -37,7 +30,7 @@ export class SequencerClient {
|
|
|
37
30
|
constructor(
|
|
38
31
|
protected publisherManager: PublisherManager<L1TxUtilsWithBlobs>,
|
|
39
32
|
protected sequencer: Sequencer,
|
|
40
|
-
protected
|
|
33
|
+
protected checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
41
34
|
protected validatorClient?: ValidatorClient,
|
|
42
35
|
private l1Metrics?: L1Metrics,
|
|
43
36
|
) {}
|
|
@@ -57,16 +50,16 @@ export class SequencerClient {
|
|
|
57
50
|
public static async new(
|
|
58
51
|
config: SequencerClientConfig,
|
|
59
52
|
deps: {
|
|
60
|
-
validatorClient: ValidatorClient
|
|
53
|
+
validatorClient: ValidatorClient;
|
|
61
54
|
p2pClient: P2P;
|
|
62
55
|
worldStateSynchronizer: WorldStateSynchronizer;
|
|
63
56
|
slasherClient: SlasherClientInterface | undefined;
|
|
64
|
-
|
|
65
|
-
l2BlockSource: L2BlockSource;
|
|
57
|
+
checkpointsBuilder: FullNodeCheckpointsBuilder;
|
|
58
|
+
l2BlockSource: L2BlockSource & L2BlockSink;
|
|
66
59
|
l1ToL2MessageSource: L1ToL2MessageSource;
|
|
67
60
|
telemetry: TelemetryClient;
|
|
68
61
|
publisherFactory?: SequencerPublisherFactory;
|
|
69
|
-
|
|
62
|
+
blobClient: BlobClientInterface;
|
|
70
63
|
dateProvider: DateProvider;
|
|
71
64
|
epochCache?: EpochCache;
|
|
72
65
|
l1TxUtils: L1TxUtilsWithBlobs[];
|
|
@@ -78,7 +71,7 @@ export class SequencerClient {
|
|
|
78
71
|
p2pClient,
|
|
79
72
|
worldStateSynchronizer,
|
|
80
73
|
slasherClient,
|
|
81
|
-
|
|
74
|
+
checkpointsBuilder,
|
|
82
75
|
l2BlockSource,
|
|
83
76
|
l1ToL2MessageSource,
|
|
84
77
|
telemetry: telemetryClient,
|
|
@@ -94,9 +87,11 @@ export class SequencerClient {
|
|
|
94
87
|
);
|
|
95
88
|
const publisherManager = new PublisherManager(l1TxUtils, config);
|
|
96
89
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
97
|
-
const [l1GenesisTime, slotDuration] = await Promise.all([
|
|
90
|
+
const [l1GenesisTime, slotDuration, rollupVersion, rollupManaLimit] = await Promise.all([
|
|
98
91
|
rollupContract.getL1GenesisTime(),
|
|
99
92
|
rollupContract.getSlotDuration(),
|
|
93
|
+
rollupContract.getVersion(),
|
|
94
|
+
rollupContract.getManaLimit().then(Number),
|
|
100
95
|
] as const);
|
|
101
96
|
|
|
102
97
|
const governanceProposerContract = new GovernanceProposerContract(
|
|
@@ -125,7 +120,7 @@ export class SequencerClient {
|
|
|
125
120
|
deps.publisherFactory ??
|
|
126
121
|
new SequencerPublisherFactory(config, {
|
|
127
122
|
telemetry: telemetryClient,
|
|
128
|
-
|
|
123
|
+
blobClient: deps.blobClient,
|
|
129
124
|
epochCache,
|
|
130
125
|
governanceProposerContract,
|
|
131
126
|
slashFactoryContract,
|
|
@@ -135,33 +130,27 @@ export class SequencerClient {
|
|
|
135
130
|
nodeKeyStore: NodeKeystoreAdapter.fromKeyStoreManager(deps.nodeKeyStore),
|
|
136
131
|
logger: log,
|
|
137
132
|
});
|
|
138
|
-
const globalsBuilder = new GlobalVariableBuilder(config);
|
|
139
133
|
|
|
140
134
|
const ethereumSlotDuration = config.ethereumSlotDuration;
|
|
135
|
+
const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration };
|
|
136
|
+
|
|
137
|
+
const globalsBuilder = new GlobalVariableBuilder({ ...config, ...l1Constants, rollupVersion });
|
|
141
138
|
|
|
142
|
-
const rollupManaLimit = Number(await rollupContract.getManaLimit());
|
|
143
139
|
let sequencerManaLimit = config.maxL2BlockGas ?? rollupManaLimit;
|
|
144
140
|
if (sequencerManaLimit > rollupManaLimit) {
|
|
145
141
|
log.warn(
|
|
146
|
-
`Provided maxL2BlockGas
|
|
142
|
+
`Provided maxL2BlockGas ${sequencerManaLimit} is greater than the max allowed by L1. Setting limit to ${rollupManaLimit}.`,
|
|
147
143
|
);
|
|
148
144
|
sequencerManaLimit = rollupManaLimit;
|
|
149
145
|
}
|
|
150
146
|
|
|
151
147
|
// When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
|
|
152
|
-
// Otherwise,
|
|
153
|
-
// maxL1TxInclusionTimeIntoSlot of zero) to get the tx into that L1 slot.
|
|
148
|
+
// Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
|
|
154
149
|
// In theory, the L1 slot has an initial 4s phase where the block is propagated, so we could
|
|
155
|
-
//
|
|
150
|
+
// reduce the publishing time allowance. However, we prefer being conservative.
|
|
156
151
|
// See https://www.blocknative.com/blog/anatomy-of-a-slot#7 for more info.
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const l1Constants = {
|
|
161
|
-
l1GenesisTime,
|
|
162
|
-
slotDuration: Number(slotDuration),
|
|
163
|
-
ethereumSlotDuration,
|
|
164
|
-
};
|
|
152
|
+
const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
|
|
153
|
+
const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
|
|
165
154
|
|
|
166
155
|
const sequencer = new Sequencer(
|
|
167
156
|
publisherFactory,
|
|
@@ -172,19 +161,19 @@ export class SequencerClient {
|
|
|
172
161
|
slasherClient,
|
|
173
162
|
l2BlockSource,
|
|
174
163
|
l1ToL2MessageSource,
|
|
175
|
-
|
|
164
|
+
checkpointsBuilder,
|
|
176
165
|
l1Constants,
|
|
177
166
|
deps.dateProvider,
|
|
178
167
|
epochCache,
|
|
179
168
|
rollupContract,
|
|
180
|
-
{ ...config,
|
|
169
|
+
{ ...config, l1PublishingTime, maxL2BlockGas: sequencerManaLimit },
|
|
181
170
|
telemetryClient,
|
|
182
171
|
log,
|
|
183
172
|
);
|
|
184
173
|
|
|
185
174
|
await sequencer.init();
|
|
186
175
|
|
|
187
|
-
return new SequencerClient(publisherManager, sequencer,
|
|
176
|
+
return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics);
|
|
188
177
|
}
|
|
189
178
|
|
|
190
179
|
/**
|
|
@@ -193,7 +182,7 @@ export class SequencerClient {
|
|
|
193
182
|
*/
|
|
194
183
|
public updateConfig(config: SequencerConfig & Partial<ValidatorClientFullConfig>) {
|
|
195
184
|
this.sequencer.updateConfig(config);
|
|
196
|
-
this.
|
|
185
|
+
this.checkpointsBuilder.updateConfig(config);
|
|
197
186
|
this.validatorClient?.updateConfig(config);
|
|
198
187
|
}
|
|
199
188
|
|