@aztec/epoch-cache 0.0.1-commit.ee80a48 → 0.0.1-commit.f103f88

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.
@@ -1,11 +1,14 @@
1
1
  import { createEthereumChain } from '@aztec/ethereum/chain';
2
+ import { makeL1HttpTransport } from '@aztec/ethereum/client';
2
3
  import { NoCommitteeError, RollupContract } from '@aztec/ethereum/contracts';
4
+ import { SlotNumber } from '@aztec/foundation/branded-types';
3
5
  import { EthAddress } from '@aztec/foundation/eth-address';
4
6
  import { createLogger } from '@aztec/foundation/log';
5
7
  import { DateProvider } from '@aztec/foundation/timer';
6
- import { getEpochAtSlot, getEpochNumberAtTimestamp, getSlotAtTimestamp, getSlotRangeForEpoch, getTimestampForSlot, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
7
- import { createPublicClient, encodeAbiParameters, fallback, http, keccak256 } from 'viem';
8
+ import { getEpochAtSlot, getEpochNumberAtTimestamp, getNextL1SlotTimestamp, getSlotAtNextL1Block, getSlotAtTimestamp, getSlotRangeForEpoch, getStartTimestampForEpoch, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
9
+ import { createPublicClient, encodeAbiParameters, keccak256 } from 'viem';
8
10
  import { getEpochCacheConfigEnvVars } from './config.js';
11
+ /** When proposer pipelining is enabled, the proposer builds one slot ahead. */ export const PROPOSER_PIPELINING_SLOT_OFFSET = 1;
9
12
  /**
10
13
  * Epoch cache
11
14
  *
@@ -19,14 +22,19 @@ import { getEpochCacheConfigEnvVars } from './config.js';
19
22
  l1constants;
20
23
  dateProvider;
21
24
  config;
22
- // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
25
+ /**
26
+ * Single map holding both resolved entries and in-flight promises.
27
+ * A `Promise` value means a fetch is in progress; concurrent callers await it.
28
+ */ // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
23
29
  cache;
24
30
  allValidators;
25
31
  lastValidatorRefresh;
26
32
  log;
33
+ enableProposerPipelining;
27
34
  constructor(rollup, l1constants, dateProvider = new DateProvider(), config = {
28
35
  cacheSize: 12,
29
- validatorRefreshIntervalSeconds: 60
36
+ validatorRefreshIntervalSeconds: 60,
37
+ enableProposerPipelining: false
30
38
  }){
31
39
  this.rollup = rollup;
32
40
  this.l1constants = l1constants;
@@ -36,8 +44,10 @@ import { getEpochCacheConfigEnvVars } from './config.js';
36
44
  this.allValidators = new Set();
37
45
  this.lastValidatorRefresh = 0;
38
46
  this.log = createLogger('epoch-cache');
47
+ this.enableProposerPipelining = this.config.enableProposerPipelining;
39
48
  this.log.debug(`Initialized EpochCache`, {
40
- l1constants
49
+ l1constants,
50
+ enableProposerPipelining: this.enableProposerPipelining
41
51
  });
42
52
  }
43
53
  static async create(rollupOrAddress, config, deps = {}) {
@@ -50,21 +60,23 @@ import { getEpochCacheConfigEnvVars } from './config.js';
50
60
  const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
51
61
  const publicClient = createPublicClient({
52
62
  chain: chain.chainInfo,
53
- transport: fallback(config.l1RpcUrls.map((url)=>http(url, {
54
- batch: false
55
- }))),
63
+ transport: makeL1HttpTransport(config.l1RpcUrls, {
64
+ timeout: config.l1HttpTimeoutMS
65
+ }),
56
66
  pollingInterval: config.viemPollingIntervalMS
57
67
  });
58
68
  rollup = new RollupContract(publicClient, rollupOrAddress.toString());
59
69
  }
60
- const [l1StartBlock, l1GenesisTime, proofSubmissionEpochs, slotDuration, epochDuration, lagInEpochsForValidatorSet, lagInEpochsForRandao] = await Promise.all([
70
+ const [l1StartBlock, l1GenesisTime, proofSubmissionEpochs, slotDuration, epochDuration, lagInEpochsForValidatorSet, lagInEpochsForRandao, targetCommitteeSize, rollupManaLimit] = await Promise.all([
61
71
  rollup.getL1StartBlock(),
62
72
  rollup.getL1GenesisTime(),
63
73
  rollup.getProofSubmissionEpochs(),
64
74
  rollup.getSlotDuration(),
65
75
  rollup.getEpochDuration(),
66
76
  rollup.getLagInEpochsForValidatorSet(),
67
- rollup.getLagInEpochsForRandao()
77
+ rollup.getLagInEpochsForRandao(),
78
+ rollup.getTargetCommitteeSize(),
79
+ rollup.getManaLimit()
68
80
  ]);
69
81
  const l1RollupConstants = {
70
82
  l1StartBlock,
@@ -74,13 +86,39 @@ import { getEpochCacheConfigEnvVars } from './config.js';
74
86
  epochDuration: Number(epochDuration),
75
87
  ethereumSlotDuration: config.ethereumSlotDuration,
76
88
  lagInEpochsForValidatorSet: Number(lagInEpochsForValidatorSet),
77
- lagInEpochsForRandao: Number(lagInEpochsForRandao)
89
+ lagInEpochsForRandao: Number(lagInEpochsForRandao),
90
+ targetCommitteeSize: Number(targetCommitteeSize),
91
+ rollupManaLimit: Number(rollupManaLimit)
78
92
  };
79
- return new EpochCache(rollup, l1RollupConstants, deps.dateProvider);
93
+ return new EpochCache(rollup, l1RollupConstants, deps.dateProvider, {
94
+ cacheSize: 12,
95
+ validatorRefreshIntervalSeconds: 60,
96
+ enableProposerPipelining: config.enableProposerPipelining
97
+ });
80
98
  }
81
99
  getL1Constants() {
82
100
  return this.l1constants;
83
101
  }
102
+ isProposerPipeliningEnabled() {
103
+ return this.enableProposerPipelining;
104
+ }
105
+ pipeliningOffset() {
106
+ return this.enableProposerPipelining ? PROPOSER_PIPELINING_SLOT_OFFSET : 0;
107
+ }
108
+ getSlotNow() {
109
+ return this.getEpochAndSlotNow().slot;
110
+ }
111
+ getTargetSlot() {
112
+ const slotNow = this.getSlotNow();
113
+ const offset = this.isProposerPipeliningEnabled() ? PROPOSER_PIPELINING_SLOT_OFFSET : 0;
114
+ return SlotNumber(slotNow + offset);
115
+ }
116
+ getEpochNow() {
117
+ return this.getEpochAndSlotNow().epoch;
118
+ }
119
+ getTargetEpoch() {
120
+ return getEpochAtSlot(this.getTargetSlot(), this.l1constants);
121
+ }
84
122
  getEpochAndSlotNow() {
85
123
  const nowMs = BigInt(this.dateProvider.now());
86
124
  const nowSeconds = nowMs / 1000n;
@@ -89,48 +127,44 @@ import { getEpochCacheConfigEnvVars } from './config.js';
89
127
  nowMs
90
128
  };
91
129
  }
92
- nowInSeconds() {
93
- return BigInt(Math.floor(this.dateProvider.now() / 1000));
94
- }
95
130
  getEpochAndSlotAtSlot(slot) {
96
- const epoch = getEpochAtSlot(slot, this.l1constants);
97
- const ts = getTimestampRangeForEpoch(epoch, this.l1constants)[0];
98
- return {
99
- epoch,
100
- ts,
101
- slot
102
- };
131
+ return this.getEpochAndSlotAtTimestamp(getTimestampForSlot(slot, this.l1constants));
103
132
  }
104
133
  getEpochAndSlotInNextL1Slot() {
105
- const now = this.nowInSeconds();
106
- const nextSlotTs = now + BigInt(this.l1constants.ethereumSlotDuration);
134
+ const nowSeconds = this.dateProvider.nowInSeconds();
135
+ const nextSlotTs = getNextL1SlotTimestamp(nowSeconds, this.l1constants);
107
136
  return {
108
137
  ...this.getEpochAndSlotAtTimestamp(nextSlotTs),
109
- now
138
+ nowSeconds: BigInt(nowSeconds)
139
+ };
140
+ }
141
+ getTargetEpochAndSlotInNextL1Slot() {
142
+ if (!this.isProposerPipeliningEnabled()) {
143
+ return this.getEpochAndSlotInNextL1Slot();
144
+ }
145
+ const result = this.getEpochAndSlotInNextL1Slot();
146
+ const offset = PROPOSER_PIPELINING_SLOT_OFFSET;
147
+ const targetSlot = SlotNumber(result.slot + offset);
148
+ return {
149
+ ...result,
150
+ slot: targetSlot,
151
+ epoch: getEpochAtSlot(targetSlot, this.l1constants)
110
152
  };
111
153
  }
112
154
  getEpochAndSlotAtTimestamp(ts) {
113
155
  const slot = getSlotAtTimestamp(ts, this.l1constants);
156
+ const epoch = getEpochNumberAtTimestamp(ts, this.l1constants);
114
157
  return {
115
- epoch: getEpochNumberAtTimestamp(ts, this.l1constants),
116
- ts: getTimestampForSlot(slot, this.l1constants),
117
- slot
158
+ slot,
159
+ epoch,
160
+ ts: getTimestampForSlot(slot, this.l1constants)
118
161
  };
119
162
  }
120
163
  getCommitteeForEpoch(epoch) {
121
164
  const [startSlot] = getSlotRangeForEpoch(epoch, this.l1constants);
122
165
  return this.getCommittee(startSlot);
123
166
  }
124
- /**
125
- * Returns whether the escape hatch is open for the given epoch.
126
- *
127
- * Uses the already-cached EpochCommitteeInfo when available. If not cached, it will fetch
128
- * the epoch committee info (which includes the escape hatch flag) and return it.
129
- */ async isEscapeHatchOpen(epoch) {
130
- const cached = this.cache.get(epoch);
131
- if (cached) {
132
- return cached.isEscapeHatchOpen;
133
- }
167
+ /** Returns whether the escape hatch is open for the given epoch. */ async isEscapeHatchOpen(epoch) {
134
168
  const info = await this.getCommitteeForEpoch(epoch);
135
169
  return info.isEscapeHatchOpen;
136
170
  }
@@ -140,30 +174,47 @@ import { getEpochCacheConfigEnvVars } from './config.js';
140
174
  * This is a lightweight helper intended for callers that already have a slot number and only
141
175
  * need the escape hatch flag (without pulling full committee info).
142
176
  */ async isEscapeHatchOpenAtSlot(slot = 'now') {
143
- const epoch = slot === 'now' ? this.getEpochAndSlotNow().epoch : slot === 'next' ? this.getEpochAndSlotInNextL1Slot().epoch : getEpochAtSlot(slot, this.l1constants);
177
+ const epoch = slot === 'now' ? this.getEpochNow() : slot === 'next' ? this.getEpochAndSlotInNextL1Slot().epoch : getEpochAtSlot(slot, this.l1constants);
144
178
  return await this.isEscapeHatchOpen(epoch);
145
179
  }
146
180
  /**
147
- * Get the current validator set
148
- * @param nextSlot - If true, get the validator set for the next slot.
149
- * @returns The current validator set.
181
+ * Get the current validator set.
182
+ *
183
+ * Returns cached data if the entry is finalized or still fresh (queried less than one
184
+ * Ethereum slot ago). Stale non-finalized entries are re-queried, and concurrent callers
185
+ * coalesce on the same in-flight promise so the L1 query happens only once.
150
186
  */ async getCommittee(slot = 'now') {
151
187
  const { epoch, ts } = this.getEpochAndTimestamp(slot);
152
- if (this.cache.has(epoch)) {
153
- return this.cache.get(epoch);
188
+ const cached = this.cache.get(epoch);
189
+ // In-flight promise: another caller is already fetching this epoch — just await it.
190
+ if (cached instanceof Promise) {
191
+ return (await cached).data;
154
192
  }
155
- const epochData = await this.computeCommittee({
156
- epoch,
157
- ts
158
- });
159
- // If the committee size is 0 or undefined, then do not cache
160
- if (!epochData.committee || epochData.committee.length === 0) {
161
- return epochData;
193
+ // Resolved entry: return it if finalized or still fresh.
194
+ if (cached && (cached.finalized || !this.isStale(cached))) {
195
+ return cached.data;
196
+ }
197
+ // Stale non-finalized entry: do a lightweight refresh first (check block hash + finalized ts).
198
+ // Only fall back to a full re-fetch if the L1 block was reorged.
199
+ if (cached) {
200
+ const promise = this.refreshStaleEntry(cached, epoch, ts);
201
+ this.cache.set(epoch, promise);
202
+ try {
203
+ return (await promise).data;
204
+ } catch (err) {
205
+ this.cache.set(epoch, cached);
206
+ throw err;
207
+ }
208
+ }
209
+ // No entry at all: full fetch.
210
+ const promise = this.fetchAndCache(epoch, ts);
211
+ this.cache.set(epoch, promise);
212
+ try {
213
+ return (await promise).data;
214
+ } catch (err) {
215
+ this.cache.delete(epoch);
216
+ throw err;
162
217
  }
163
- this.cache.set(epoch, epochData);
164
- const toPurge = Array.from(this.cache.keys()).sort((a, b)=>Number(b - a)).slice(this.config.cacheSize);
165
- toPurge.forEach((key)=>this.cache.delete(key));
166
- return epochData;
167
218
  }
168
219
  getEpochAndTimestamp(slot = 'now') {
169
220
  if (slot === 'now') {
@@ -174,27 +225,126 @@ import { getEpochCacheConfigEnvVars } from './config.js';
174
225
  return this.getEpochAndSlotAtSlot(slot);
175
226
  }
176
227
  }
177
- async computeCommittee(when) {
178
- const { ts, epoch } = when;
179
- const [committee, seedBuffer, l1Timestamp, isEscapeHatchOpen] = await Promise.all([
228
+ /** Evicts oldest cache entries (resolved or in-flight) beyond cacheSize. */ purgeCache() {
229
+ if (this.cache.size <= this.config.cacheSize) {
230
+ return;
231
+ }
232
+ const toPurge = Array.from(this.cache.keys()).sort((a, b)=>Number(b - a)).slice(this.config.cacheSize);
233
+ toPurge.forEach((key)=>this.cache.delete(key));
234
+ }
235
+ /** Returns true if a non-finalized cache entry is older than one Ethereum slot. */ isStale(entry) {
236
+ const nowSeconds = BigInt(this.dateProvider.nowInSeconds());
237
+ return nowSeconds - entry.lastRefreshL1Timestamp >= BigInt(this.l1constants.ethereumSlotDuration);
238
+ }
239
+ /** Whether a cached epoch entry has been marked as finalized. Returns undefined if not cached or still in-flight. */ isFinalized(epoch) {
240
+ const entry = this.cache.get(epoch);
241
+ if (!entry || entry instanceof Promise) {
242
+ return undefined;
243
+ }
244
+ return entry.finalized;
245
+ }
246
+ /** Returns the latest L1 timestamp stored in the cached entry. Undefined if not cached or in-flight. */ getCachedLastRefreshL1Timestamp(epoch) {
247
+ const entry = this.cache.get(epoch);
248
+ if (!entry || entry instanceof Promise) {
249
+ return undefined;
250
+ }
251
+ return entry.lastRefreshL1Timestamp;
252
+ }
253
+ /** Computes the sampling timestamp for an epoch's committee data. */ getSamplingTimestamp(epoch) {
254
+ const { lagInEpochsForRandao, epochDuration, slotDuration } = this.l1constants;
255
+ const epochStartTs = getStartTimestampForEpoch(epoch, this.l1constants);
256
+ return epochStartTs - BigInt(lagInEpochsForRandao) * BigInt(epochDuration) * BigInt(slotDuration);
257
+ }
258
+ /**
259
+ * Lightweight refresh for a stale non-finalized entry. Queries only the block hash at
260
+ * the original block number and the finalized block timestamp — avoids the expensive
261
+ * getCommitteeAt and getSampleSeedAt calls on the rollup contract.
262
+ *
263
+ * If the block hash still matches (no L1 reorg), we keep the existing data and just
264
+ * update the provenance timestamp. If the finalized block has caught up, we promote the
265
+ * entry to finalized. If there was a reorg (hash mismatch), we fall back to a full fetch.
266
+ */ async refreshStaleEntry(stale, epoch, ts) {
267
+ const [blockAtOriginal, l1FinalizedBlock, latestBlock] = await Promise.all([
268
+ this.rollup.client.getBlock({
269
+ blockNumber: stale.lastQueryL1BlockNumber,
270
+ includeTransactions: false
271
+ }),
272
+ this.rollup.client.getBlock({
273
+ blockTag: 'finalized',
274
+ includeTransactions: false
275
+ }),
276
+ this.rollup.client.getBlock({
277
+ includeTransactions: false
278
+ })
279
+ ]);
280
+ if (blockAtOriginal.hash === stale.lastQueryL1BlockHash) {
281
+ // No reorg: the data is still valid. Check if we can now mark it as finalized.
282
+ const samplingTs = this.getSamplingTimestamp(epoch);
283
+ const finalized = !!(stale.data.committee && stale.data.committee.length > 0) && samplingTs <= l1FinalizedBlock.timestamp;
284
+ const refreshed = {
285
+ ...stale,
286
+ lastRefreshL1Timestamp: latestBlock.timestamp,
287
+ finalized
288
+ };
289
+ this.cache.set(epoch, refreshed);
290
+ return refreshed;
291
+ }
292
+ // Reorg detected: block hash mismatch. Do a full re-fetch.
293
+ // Pass the already-fetched block timestamps to avoid redundant queries.
294
+ this.log.warn(`L1 reorg detected for epoch ${epoch}: block ${stale.lastQueryL1BlockNumber} hash changed`, {
295
+ epoch,
296
+ expectedHash: stale.lastQueryL1BlockHash,
297
+ actualHash: blockAtOriginal.hash
298
+ });
299
+ return this.fetchAndCache(epoch, ts, {
300
+ latestBlock,
301
+ finalizedBlock: l1FinalizedBlock
302
+ });
303
+ }
304
+ /**
305
+ * Fetches committee data from L1, determines finalization status, and stores in the cache.
306
+ *
307
+ * Uses `lagInEpochsForRandao` (the binding constraint, always <= lagInEpochsForValidatorSet)
308
+ * and computes the sampling timestamp from the epoch start to match the L1 contract's logic.
309
+ *
310
+ * When called from refreshStaleEntry after a reorg, the latest and finalized blocks are
311
+ * passed in to avoid redundant L1 queries.
312
+ */ async fetchAndCache(epoch, ts, prefetched) {
313
+ const [committee, seedBuffer, latestBlock, finalizedBlock, isEscapeHatchOpen] = await Promise.all([
180
314
  this.rollup.getCommitteeAt(ts),
181
315
  this.rollup.getSampleSeedAt(ts),
182
- this.rollup.client.getBlock({
316
+ prefetched?.latestBlock ?? this.rollup.client.getBlock({
183
317
  includeTransactions: false
184
- }).then((b)=>b.timestamp),
318
+ }),
319
+ prefetched?.finalizedBlock ?? this.rollup.client.getBlock({
320
+ blockTag: 'finalized',
321
+ includeTransactions: false
322
+ }),
185
323
  this.rollup.isEscapeHatchOpen(epoch)
186
324
  ]);
187
- const { lagInEpochsForValidatorSet, epochDuration, slotDuration } = this.l1constants;
188
- const sub = BigInt(lagInEpochsForValidatorSet) * BigInt(epochDuration) * BigInt(slotDuration);
189
- if (ts - sub > l1Timestamp) {
190
- throw new Error(`Cannot query committee for future epoch ${epoch} with timestamp ${ts} (current L1 time is ${l1Timestamp}). Check your Ethereum node is synced.`);
325
+ const samplingTs = this.getSamplingTimestamp(epoch);
326
+ if (samplingTs > latestBlock.timestamp) {
327
+ throw new Error(`Cannot query committee for future epoch ${epoch}: ` + `sampling timestamp ${samplingTs} is beyond latest L1 block at ${latestBlock.timestamp}. ` + `Check your Ethereum node is synced.`);
191
328
  }
192
- return {
329
+ // Empty committees are never marked finalized so they always get re-queried after TTL.
330
+ const hasCommittee = !!(committee && committee.length > 0);
331
+ const finalized = hasCommittee && samplingTs <= finalizedBlock.timestamp;
332
+ const data = {
193
333
  committee,
194
334
  seed: seedBuffer.toBigInt(),
195
335
  epoch,
196
336
  isEscapeHatchOpen
197
337
  };
338
+ const entry = {
339
+ data,
340
+ lastQueryL1BlockNumber: latestBlock.number,
341
+ lastQueryL1BlockHash: latestBlock.hash,
342
+ lastRefreshL1Timestamp: latestBlock.timestamp,
343
+ finalized
344
+ };
345
+ this.cache.set(epoch, entry);
346
+ this.purgeCache();
347
+ return entry;
198
348
  }
199
349
  /**
200
350
  * Get the ABI encoding of the proposer index - see ValidatorSelectionLib.sol computeProposerIndex
@@ -225,14 +375,26 @@ import { getEpochCacheConfigEnvVars } from './config.js';
225
375
  }
226
376
  return BigInt(keccak256(this.getProposerIndexEncoding(epoch, slot, seed))) % size;
227
377
  }
228
- /** Returns the current and next L2 slot numbers. */ getCurrentAndNextSlot() {
229
- const current = this.getEpochAndSlotNow();
378
+ /** Returns the current and next L2 slot in next eth L1 Slot. */ getCurrentAndNextSlot() {
379
+ const currentSlot = this.getSlotNow();
230
380
  const next = this.getEpochAndSlotInNextL1Slot();
231
381
  return {
232
- currentSlot: current.slot,
382
+ currentSlot,
233
383
  nextSlot: next.slot
234
384
  };
235
385
  }
386
+ /** Returns the target and next L2 slot in the next L1 slot. */ getTargetAndNextSlot() {
387
+ const nowSeconds = BigInt(this.dateProvider.nowInSeconds());
388
+ const offset = this.isProposerPipeliningEnabled() ? PROPOSER_PIPELINING_SLOT_OFFSET : 0;
389
+ const currentSlot = getSlotAtTimestamp(nowSeconds, this.l1constants);
390
+ const targetSlot = SlotNumber(currentSlot + offset);
391
+ const nextL2SlotOnL1 = getSlotAtNextL1Block(nowSeconds, this.l1constants);
392
+ const nextSlot = SlotNumber(nextL2SlotOnL1 + offset);
393
+ return {
394
+ targetSlot,
395
+ nextSlot
396
+ };
397
+ }
236
398
  /**
237
399
  * Get the proposer attester address in the given L2 slot
238
400
  * @returns The proposer attester address. If the committee does not exist, we throw a NoCommitteeError.
@@ -290,10 +452,11 @@ import { getEpochCacheConfigEnvVars } from './config.js';
290
452
  async getRegisteredValidators() {
291
453
  const validatorRefreshIntervalMs = this.config.validatorRefreshIntervalSeconds * 1000;
292
454
  const validatorRefreshTime = this.lastValidatorRefresh + validatorRefreshIntervalMs;
293
- if (validatorRefreshTime < this.dateProvider.now()) {
294
- const currentSet = await this.rollup.getAttesters();
455
+ const now = this.dateProvider.now();
456
+ if (validatorRefreshTime < now) {
457
+ const currentSet = await this.rollup.getAttesters(BigInt(Math.floor(now / 1000)));
295
458
  this.allValidators = new Set(currentSet.map((v)=>v.toString()));
296
- this.lastValidatorRefresh = this.dateProvider.now();
459
+ this.lastValidatorRefresh = now;
297
460
  }
298
461
  return Array.from(this.allValidators.keys()).map((v)=>EthAddress.fromString(v));
299
462
  }
@@ -1,7 +1,7 @@
1
1
  import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
2
2
  import { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
4
- import type { EpochAndSlot, EpochCacheInterface, EpochCommitteeInfo, SlotTag } from '../epoch_cache.js';
4
+ import { type EpochAndSlot, type EpochCacheInterface, type EpochCommitteeInfo, type SlotTag } from '../epoch_cache.js';
5
5
  /**
6
6
  * A test implementation of EpochCacheInterface that allows manual configuration
7
7
  * of committee, proposer, slot, and escape hatch state for use in tests.
@@ -17,6 +17,7 @@ export declare class TestEpochCache implements EpochCacheInterface {
17
17
  private seed;
18
18
  private registeredValidators;
19
19
  private l1Constants;
20
+ private proposerPipeliningEnabled;
20
21
  constructor(l1Constants?: Partial<L1RollupConstants>);
21
22
  /**
22
23
  * Sets the committee members. Used in validation and attestation flows.
@@ -54,12 +55,22 @@ export declare class TestEpochCache implements EpochCacheInterface {
54
55
  */
55
56
  setL1Constants(constants: Partial<L1RollupConstants>): this;
56
57
  getL1Constants(): L1RollupConstants;
58
+ setProposerPipeliningEnabled(enabled: boolean): void;
57
59
  getCommittee(_slot?: SlotTag): Promise<EpochCommitteeInfo>;
60
+ getSlotNow(): SlotNumber;
61
+ getTargetSlot(): SlotNumber;
62
+ getEpochNow(): EpochNumber;
63
+ getTargetEpoch(): EpochNumber;
64
+ isProposerPipeliningEnabled(): boolean;
65
+ pipeliningOffset(): number;
58
66
  getEpochAndSlotNow(): EpochAndSlot & {
59
67
  nowMs: bigint;
60
68
  };
61
69
  getEpochAndSlotInNextL1Slot(): EpochAndSlot & {
62
- now: bigint;
70
+ nowSeconds: bigint;
71
+ };
72
+ getTargetEpochAndSlotInNextL1Slot(): EpochAndSlot & {
73
+ nowSeconds: bigint;
63
74
  };
64
75
  getProposerIndexEncoding(epoch: EpochNumber, slot: SlotNumber, seed: bigint): `0x${string}`;
65
76
  computeProposerIndex(slot: SlotNumber, _epoch: EpochNumber, _seed: bigint, size: bigint): bigint;
@@ -67,10 +78,15 @@ export declare class TestEpochCache implements EpochCacheInterface {
67
78
  currentSlot: SlotNumber;
68
79
  nextSlot: SlotNumber;
69
80
  };
81
+ getTargetAndNextSlot(): {
82
+ targetSlot: SlotNumber;
83
+ nextSlot: SlotNumber;
84
+ };
70
85
  getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined>;
71
86
  getRegisteredValidators(): Promise<EthAddress[]>;
72
87
  isInCommittee(_slot: SlotTag, validator: EthAddress): Promise<boolean>;
73
88
  filterInCommittee(_slot: SlotTag, validators: EthAddress[]): Promise<EthAddress[]>;
89
+ isEscapeHatchOpen(_epoch: EpochNumber): Promise<boolean>;
74
90
  isEscapeHatchOpenAtSlot(_slot?: SlotTag): Promise<boolean>;
75
91
  }
76
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdF9lcG9jaF9jYWNoZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3QvdGVzdF9lcG9jaF9jYWNoZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLFVBQVUsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQzFFLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUMzRCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBR3JFLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxtQkFBbUIsRUFBRSxrQkFBa0IsRUFBRSxPQUFPLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQVl4Rzs7Ozs7O0dBTUc7QUFDSCxxQkFBYSxjQUFlLFlBQVcsbUJBQW1CO0lBQ3hELE9BQU8sQ0FBQyxTQUFTLENBQW9CO0lBQ3JDLE9BQU8sQ0FBQyxlQUFlLENBQXlCO0lBQ2hELE9BQU8sQ0FBQyxXQUFXLENBQTZCO0lBQ2hELE9BQU8sQ0FBQyxlQUFlLENBQWtCO0lBQ3pDLE9BQU8sQ0FBQyxJQUFJLENBQWM7SUFDMUIsT0FBTyxDQUFDLG9CQUFvQixDQUFvQjtJQUNoRCxPQUFPLENBQU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@
1
1
  import { SlotNumber } from '@aztec/foundation/branded-types';
2
2
  import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
3
+ import { PROPOSER_PIPELINING_SLOT_OFFSET } from '../epoch_cache.js';
3
4
  /** Default L1 constants for testing. */ const DEFAULT_L1_CONSTANTS = {
4
5
  l1StartBlock: 0n,
5
6
  l1GenesisTime: 0n,
6
7
  slotDuration: 24,
7
8
  epochDuration: 16,
8
9
  ethereumSlotDuration: 12,
9
- proofSubmissionEpochs: 2
10
+ proofSubmissionEpochs: 2,
11
+ targetCommitteeSize: 48,
12
+ rollupManaLimit: Number.MAX_SAFE_INTEGER
10
13
  };
11
14
  /**
12
15
  * A test implementation of EpochCacheInterface that allows manual configuration
@@ -22,6 +25,7 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
22
25
  seed = 0n;
23
26
  registeredValidators = [];
24
27
  l1Constants;
28
+ proposerPipeliningEnabled = false;
25
29
  constructor(l1Constants = {}){
26
30
  this.l1Constants = {
27
31
  ...DEFAULT_L1_CONSTANTS,
@@ -83,6 +87,9 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
83
87
  getL1Constants() {
84
88
  return this.l1Constants;
85
89
  }
90
+ setProposerPipeliningEnabled(enabled) {
91
+ this.proposerPipeliningEnabled = enabled;
92
+ }
86
93
  getCommittee(_slot) {
87
94
  const epoch = getEpochAtSlot(this.currentSlot, this.l1Constants);
88
95
  return Promise.resolve({
@@ -92,27 +99,55 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
92
99
  isEscapeHatchOpen: this.escapeHatchOpen
93
100
  });
94
101
  }
102
+ getSlotNow() {
103
+ return this.currentSlot;
104
+ }
105
+ getTargetSlot() {
106
+ return this.proposerPipeliningEnabled ? SlotNumber(this.currentSlot + PROPOSER_PIPELINING_SLOT_OFFSET) : this.currentSlot;
107
+ }
108
+ getEpochNow() {
109
+ return getEpochAtSlot(this.currentSlot, this.l1Constants);
110
+ }
111
+ getTargetEpoch() {
112
+ return getEpochAtSlot(this.getTargetSlot(), this.l1Constants);
113
+ }
114
+ isProposerPipeliningEnabled() {
115
+ return this.proposerPipeliningEnabled;
116
+ }
117
+ pipeliningOffset() {
118
+ return this.proposerPipeliningEnabled ? PROPOSER_PIPELINING_SLOT_OFFSET : 0;
119
+ }
95
120
  getEpochAndSlotNow() {
96
- const epoch = getEpochAtSlot(this.currentSlot, this.l1Constants);
97
- const ts = getTimestampRangeForEpoch(epoch, this.l1Constants)[0];
121
+ const epochNow = getEpochAtSlot(this.currentSlot, this.l1Constants);
122
+ const ts = getTimestampRangeForEpoch(epochNow, this.l1Constants)[0];
98
123
  return {
99
- epoch,
124
+ epoch: epochNow,
100
125
  slot: this.currentSlot,
101
126
  ts,
102
127
  nowMs: ts * 1000n
103
128
  };
104
129
  }
105
130
  getEpochAndSlotInNextL1Slot() {
106
- const now = getTimestampRangeForEpoch(getEpochAtSlot(this.currentSlot, this.l1Constants), this.l1Constants)[0];
107
- const nextSlotTs = now + BigInt(this.l1Constants.ethereumSlotDuration);
131
+ const nowTs = getTimestampRangeForEpoch(getEpochAtSlot(this.currentSlot, this.l1Constants), this.l1Constants)[0];
132
+ const nextSlotTs = nowTs + BigInt(this.l1Constants.ethereumSlotDuration);
108
133
  const nextSlot = getSlotAtTimestamp(nextSlotTs, this.l1Constants);
109
- const epoch = getEpochAtSlot(nextSlot, this.l1Constants);
110
- const ts = getTimestampRangeForEpoch(epoch, this.l1Constants)[0];
134
+ const epochNow = getEpochAtSlot(nextSlot, this.l1Constants);
135
+ const ts = getTimestampRangeForEpoch(epochNow, this.l1Constants)[0];
111
136
  return {
112
- epoch,
137
+ epoch: epochNow,
113
138
  slot: nextSlot,
114
139
  ts,
115
- now
140
+ nowSeconds: nowTs
141
+ };
142
+ }
143
+ getTargetEpochAndSlotInNextL1Slot() {
144
+ const result = this.getEpochAndSlotInNextL1Slot();
145
+ const offset = this.isProposerPipeliningEnabled() ? PROPOSER_PIPELINING_SLOT_OFFSET : 0;
146
+ const targetSlot = SlotNumber(result.slot + offset);
147
+ return {
148
+ ...result,
149
+ slot: targetSlot,
150
+ epoch: getEpochAtSlot(targetSlot, this.l1Constants)
116
151
  };
117
152
  }
118
153
  getProposerIndexEncoding(epoch, slot, seed) {
@@ -126,9 +161,19 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
126
161
  return BigInt(slot) % size;
127
162
  }
128
163
  getCurrentAndNextSlot() {
164
+ const currentSlot = this.getSlotNow();
165
+ const next = this.getEpochAndSlotInNextL1Slot();
129
166
  return {
130
- currentSlot: this.currentSlot,
131
- nextSlot: SlotNumber(this.currentSlot + 1)
167
+ currentSlot,
168
+ nextSlot: next.slot
169
+ };
170
+ }
171
+ getTargetAndNextSlot() {
172
+ const targetSlot = this.getTargetSlot();
173
+ const next = this.getTargetEpochAndSlotInNextL1Slot();
174
+ return {
175
+ targetSlot,
176
+ nextSlot: next.slot
132
177
  };
133
178
  }
134
179
  getProposerAttesterAddressInSlot(_slot) {
@@ -144,6 +189,9 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
144
189
  const committeeSet = new Set(this.committee.map((v)=>v.toString()));
145
190
  return Promise.resolve(validators.filter((v)=>committeeSet.has(v.toString())));
146
191
  }
192
+ isEscapeHatchOpen(_epoch) {
193
+ return Promise.resolve(this.escapeHatchOpen);
194
+ }
147
195
  isEscapeHatchOpenAtSlot(_slot) {
148
196
  return Promise.resolve(this.escapeHatchOpen);
149
197
  }