@aztec/epoch-cache 0.0.1-commit.c31f2472 → 0.0.1-commit.c52d6e7

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,15 @@
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 { getFinalizedL1Block } from '@aztec/ethereum/queries';
5
+ import { SlotNumber } from '@aztec/foundation/branded-types';
3
6
  import { EthAddress } from '@aztec/foundation/eth-address';
4
7
  import { createLogger } from '@aztec/foundation/log';
5
8
  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';
9
+ import { getEpochAtSlot, getEpochNumberAtTimestamp, getNextL1SlotTimestamp, getSlotAtNextL1Block, getSlotAtTimestamp, getSlotRangeForEpoch, getStartTimestampForEpoch, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
10
+ import { createPublicClient, encodeAbiParameters, keccak256 } from 'viem';
8
11
  import { getEpochCacheConfigEnvVars } from './config.js';
12
+ /** The proposer pipelines by building one slot ahead. */ export const PROPOSER_PIPELINING_SLOT_OFFSET = 1;
9
13
  /**
10
14
  * Epoch cache
11
15
  *
@@ -19,8 +23,10 @@ import { getEpochCacheConfigEnvVars } from './config.js';
19
23
  l1constants;
20
24
  dateProvider;
21
25
  config;
22
- // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
23
- cache;
26
+ /**
27
+ * Single map holding both resolved entries and in-flight promises.
28
+ * A `Promise` value means a fetch is in progress; concurrent callers await it.
29
+ */ cache;
24
30
  allValidators;
25
31
  lastValidatorRefresh;
26
32
  log;
@@ -50,21 +56,23 @@ import { getEpochCacheConfigEnvVars } from './config.js';
50
56
  const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
51
57
  const publicClient = createPublicClient({
52
58
  chain: chain.chainInfo,
53
- transport: fallback(config.l1RpcUrls.map((url)=>http(url, {
54
- batch: false
55
- }))),
59
+ transport: makeL1HttpTransport(config.l1RpcUrls, {
60
+ timeout: config.l1HttpTimeoutMS
61
+ }),
56
62
  pollingInterval: config.viemPollingIntervalMS
57
63
  });
58
64
  rollup = new RollupContract(publicClient, rollupOrAddress.toString());
59
65
  }
60
- const [l1StartBlock, l1GenesisTime, proofSubmissionEpochs, slotDuration, epochDuration, lagInEpochsForValidatorSet, lagInEpochsForRandao] = await Promise.all([
66
+ const [l1StartBlock, l1GenesisTime, proofSubmissionEpochs, slotDuration, epochDuration, lagInEpochsForValidatorSet, lagInEpochsForRandao, targetCommitteeSize, rollupManaLimit] = await Promise.all([
61
67
  rollup.getL1StartBlock(),
62
68
  rollup.getL1GenesisTime(),
63
69
  rollup.getProofSubmissionEpochs(),
64
70
  rollup.getSlotDuration(),
65
71
  rollup.getEpochDuration(),
66
72
  rollup.getLagInEpochsForValidatorSet(),
67
- rollup.getLagInEpochsForRandao()
73
+ rollup.getLagInEpochsForRandao(),
74
+ rollup.getTargetCommitteeSize(),
75
+ rollup.getManaLimit()
68
76
  ]);
69
77
  const l1RollupConstants = {
70
78
  l1StartBlock,
@@ -74,13 +82,40 @@ import { getEpochCacheConfigEnvVars } from './config.js';
74
82
  epochDuration: Number(epochDuration),
75
83
  ethereumSlotDuration: config.ethereumSlotDuration,
76
84
  lagInEpochsForValidatorSet: Number(lagInEpochsForValidatorSet),
77
- lagInEpochsForRandao: Number(lagInEpochsForRandao)
85
+ lagInEpochsForRandao: Number(lagInEpochsForRandao),
86
+ targetCommitteeSize: Number(targetCommitteeSize),
87
+ rollupManaLimit: Number(rollupManaLimit)
78
88
  };
79
- return new EpochCache(rollup, l1RollupConstants, deps.dateProvider);
89
+ return new EpochCache(rollup, l1RollupConstants, deps.dateProvider, {
90
+ cacheSize: 12,
91
+ validatorRefreshIntervalSeconds: 60
92
+ });
80
93
  }
81
94
  getL1Constants() {
82
95
  return this.l1constants;
83
96
  }
97
+ /**
98
+ * The number of epochs by which validator-set sampling lags. The committee for epoch `E` samples the
99
+ * validator set as of `lagInEpochsForValidatorSet` epochs before `E` (see
100
+ * `ValidatorSelectionLib.stableEpochToValidatorSetSampleTime` on L1), so a newly staked validator only
101
+ * becomes eligible for a committee this many epochs after staking.
102
+ */ getLagInEpochsForValidatorSet() {
103
+ return this.l1constants.lagInEpochsForValidatorSet;
104
+ }
105
+ getSlotNow() {
106
+ return this.getEpochAndSlotNow().slot;
107
+ }
108
+ getTargetSlot() {
109
+ const slotNow = this.getSlotNow();
110
+ const offset = PROPOSER_PIPELINING_SLOT_OFFSET;
111
+ return SlotNumber(slotNow + offset);
112
+ }
113
+ getEpochNow() {
114
+ return this.getEpochAndSlotNow().epoch;
115
+ }
116
+ getTargetEpoch() {
117
+ return getEpochAtSlot(this.getTargetSlot(), this.l1constants);
118
+ }
84
119
  getEpochAndSlotNow() {
85
120
  const nowMs = BigInt(this.dateProvider.now());
86
121
  const nowSeconds = nowMs / 1000n;
@@ -89,48 +124,41 @@ import { getEpochCacheConfigEnvVars } from './config.js';
89
124
  nowMs
90
125
  };
91
126
  }
92
- nowInSeconds() {
93
- return BigInt(Math.floor(this.dateProvider.now() / 1000));
94
- }
95
127
  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
- };
128
+ return this.getEpochAndSlotAtTimestamp(getTimestampForSlot(slot, this.l1constants));
103
129
  }
104
130
  getEpochAndSlotInNextL1Slot() {
105
- const now = this.nowInSeconds();
106
- const nextSlotTs = now + BigInt(this.l1constants.ethereumSlotDuration);
131
+ const nowSeconds = this.dateProvider.nowInSeconds();
132
+ const nextSlotTs = getNextL1SlotTimestamp(nowSeconds, this.l1constants);
107
133
  return {
108
134
  ...this.getEpochAndSlotAtTimestamp(nextSlotTs),
109
- now
135
+ nowSeconds: BigInt(nowSeconds)
136
+ };
137
+ }
138
+ getTargetEpochAndSlotInNextL1Slot() {
139
+ const result = this.getEpochAndSlotInNextL1Slot();
140
+ const offset = PROPOSER_PIPELINING_SLOT_OFFSET;
141
+ const targetSlot = SlotNumber(result.slot + offset);
142
+ return {
143
+ ...result,
144
+ slot: targetSlot,
145
+ epoch: getEpochAtSlot(targetSlot, this.l1constants)
110
146
  };
111
147
  }
112
148
  getEpochAndSlotAtTimestamp(ts) {
113
149
  const slot = getSlotAtTimestamp(ts, this.l1constants);
150
+ const epoch = getEpochNumberAtTimestamp(ts, this.l1constants);
114
151
  return {
115
- epoch: getEpochNumberAtTimestamp(ts, this.l1constants),
116
- ts: getTimestampForSlot(slot, this.l1constants),
117
- slot
152
+ slot,
153
+ epoch,
154
+ ts: getTimestampForSlot(slot, this.l1constants)
118
155
  };
119
156
  }
120
157
  getCommitteeForEpoch(epoch) {
121
158
  const [startSlot] = getSlotRangeForEpoch(epoch, this.l1constants);
122
159
  return this.getCommittee(startSlot);
123
160
  }
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
- }
161
+ /** Returns whether the escape hatch is open for the given epoch. */ async isEscapeHatchOpen(epoch) {
134
162
  const info = await this.getCommitteeForEpoch(epoch);
135
163
  return info.isEscapeHatchOpen;
136
164
  }
@@ -140,30 +168,47 @@ import { getEpochCacheConfigEnvVars } from './config.js';
140
168
  * This is a lightweight helper intended for callers that already have a slot number and only
141
169
  * need the escape hatch flag (without pulling full committee info).
142
170
  */ async isEscapeHatchOpenAtSlot(slot = 'now') {
143
- const epoch = slot === 'now' ? this.getEpochAndSlotNow().epoch : slot === 'next' ? this.getEpochAndSlotInNextL1Slot().epoch : getEpochAtSlot(slot, this.l1constants);
171
+ const epoch = slot === 'now' ? this.getEpochNow() : slot === 'next' ? this.getEpochAndSlotInNextL1Slot().epoch : getEpochAtSlot(slot, this.l1constants);
144
172
  return await this.isEscapeHatchOpen(epoch);
145
173
  }
146
174
  /**
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.
175
+ * Get the current validator set.
176
+ *
177
+ * Returns cached data if the entry is finalized or still fresh (queried less than one
178
+ * Ethereum slot ago). Stale non-finalized entries are re-queried, and concurrent callers
179
+ * coalesce on the same in-flight promise so the L1 query happens only once.
150
180
  */ async getCommittee(slot = 'now') {
151
181
  const { epoch, ts } = this.getEpochAndTimestamp(slot);
152
- if (this.cache.has(epoch)) {
153
- return this.cache.get(epoch);
182
+ const cached = this.cache.get(epoch);
183
+ // In-flight promise: another caller is already fetching this epoch — just await it.
184
+ if (cached instanceof Promise) {
185
+ return (await cached).data;
154
186
  }
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;
187
+ // Resolved entry: return it if finalized or still fresh.
188
+ if (cached && (cached.finalized || !this.isStale(cached))) {
189
+ return cached.data;
190
+ }
191
+ // Stale non-finalized entry: do a lightweight refresh first (check block hash + finalized ts).
192
+ // Only fall back to a full re-fetch if the L1 block was reorged.
193
+ if (cached) {
194
+ const promise = this.refreshStaleEntry(cached, epoch, ts);
195
+ this.cache.set(epoch, promise);
196
+ try {
197
+ return (await promise).data;
198
+ } catch (err) {
199
+ this.cache.set(epoch, cached);
200
+ throw err;
201
+ }
202
+ }
203
+ // No entry at all: full fetch.
204
+ const promise = this.fetchAndCache(epoch, ts);
205
+ this.cache.set(epoch, promise);
206
+ try {
207
+ return (await promise).data;
208
+ } catch (err) {
209
+ this.cache.delete(epoch);
210
+ throw err;
162
211
  }
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
212
  }
168
213
  getEpochAndTimestamp(slot = 'now') {
169
214
  if (slot === 'now') {
@@ -174,27 +219,121 @@ import { getEpochCacheConfigEnvVars } from './config.js';
174
219
  return this.getEpochAndSlotAtSlot(slot);
175
220
  }
176
221
  }
177
- async computeCommittee(when) {
178
- const { ts, epoch } = when;
179
- const [committee, seedBuffer, l1Timestamp, isEscapeHatchOpen] = await Promise.all([
222
+ /** Evicts oldest cache entries (resolved or in-flight) beyond cacheSize. */ purgeCache() {
223
+ if (this.cache.size <= this.config.cacheSize) {
224
+ return;
225
+ }
226
+ const toPurge = Array.from(this.cache.keys()).sort((a, b)=>Number(b - a)).slice(this.config.cacheSize);
227
+ toPurge.forEach((key)=>this.cache.delete(key));
228
+ }
229
+ /** Returns true if a non-finalized cache entry is older than one Ethereum slot. */ isStale(entry) {
230
+ const nowSeconds = BigInt(this.dateProvider.nowInSeconds());
231
+ return nowSeconds - entry.lastRefreshL1Timestamp >= BigInt(this.l1constants.ethereumSlotDuration);
232
+ }
233
+ /** Whether a cached epoch entry has been marked as finalized. Returns undefined if not cached or still in-flight. */ isFinalized(epoch) {
234
+ const entry = this.cache.get(epoch);
235
+ if (!entry || entry instanceof Promise) {
236
+ return undefined;
237
+ }
238
+ return entry.finalized;
239
+ }
240
+ /** Returns the latest L1 timestamp stored in the cached entry. Undefined if not cached or in-flight. */ getCachedLastRefreshL1Timestamp(epoch) {
241
+ const entry = this.cache.get(epoch);
242
+ if (!entry || entry instanceof Promise) {
243
+ return undefined;
244
+ }
245
+ return entry.lastRefreshL1Timestamp;
246
+ }
247
+ /** Computes the sampling timestamp for an epoch's committee data. */ getSamplingTimestamp(epoch) {
248
+ const { lagInEpochsForRandao, epochDuration, slotDuration } = this.l1constants;
249
+ const epochStartTs = getStartTimestampForEpoch(epoch, this.l1constants);
250
+ return epochStartTs - BigInt(lagInEpochsForRandao) * BigInt(epochDuration) * BigInt(slotDuration);
251
+ }
252
+ /**
253
+ * Lightweight refresh for a stale non-finalized entry. Queries only the block hash at
254
+ * the original block number and the finalized block timestamp — avoids the expensive
255
+ * getCommitteeAt and getSampleSeedAt calls on the rollup contract.
256
+ *
257
+ * If the block hash still matches (no L1 reorg), we keep the existing data and just
258
+ * update the provenance timestamp. If the finalized block has caught up, we promote the
259
+ * entry to finalized. If there was a reorg (hash mismatch), we fall back to a full fetch.
260
+ */ async refreshStaleEntry(stale, epoch, ts) {
261
+ const [blockAtOriginal, l1FinalizedBlock, latestBlock] = await Promise.all([
262
+ this.rollup.client.getBlock({
263
+ blockNumber: stale.lastQueryL1BlockNumber,
264
+ includeTransactions: false
265
+ }),
266
+ getFinalizedL1Block(this.rollup.client),
267
+ this.rollup.client.getBlock({
268
+ includeTransactions: false
269
+ })
270
+ ]);
271
+ if (blockAtOriginal.hash === stale.lastQueryL1BlockHash) {
272
+ // No reorg: the data is still valid. Check if we can now mark it as finalized.
273
+ const samplingTs = this.getSamplingTimestamp(epoch);
274
+ const finalized = !!(stale.data.committee && stale.data.committee.length > 0) && l1FinalizedBlock !== undefined && samplingTs <= l1FinalizedBlock.timestamp;
275
+ const refreshed = {
276
+ ...stale,
277
+ lastRefreshL1Timestamp: latestBlock.timestamp,
278
+ finalized
279
+ };
280
+ this.cache.set(epoch, refreshed);
281
+ return refreshed;
282
+ }
283
+ // Reorg detected: block hash mismatch. Do a full re-fetch.
284
+ // Pass the already-fetched block timestamps to avoid redundant queries.
285
+ this.log.warn(`L1 reorg detected for epoch ${epoch}: block ${stale.lastQueryL1BlockNumber} hash changed`, {
286
+ epoch,
287
+ expectedHash: stale.lastQueryL1BlockHash,
288
+ actualHash: blockAtOriginal.hash
289
+ });
290
+ return this.fetchAndCache(epoch, ts, {
291
+ latestBlock,
292
+ finalizedBlock: l1FinalizedBlock
293
+ });
294
+ }
295
+ /**
296
+ * Fetches committee data from L1, determines finalization status, and stores in the cache.
297
+ *
298
+ * Uses `lagInEpochsForRandao` (the binding constraint, always <= lagInEpochsForValidatorSet)
299
+ * and computes the sampling timestamp from the epoch start to match the L1 contract's logic.
300
+ *
301
+ * When called from refreshStaleEntry after a reorg, the latest and finalized blocks are
302
+ * passed in to avoid redundant L1 queries.
303
+ */ async fetchAndCache(epoch, ts, prefetched) {
304
+ const [committee, seedBuffer, latestBlock, finalizedBlock, isEscapeHatchOpen] = await Promise.all([
180
305
  this.rollup.getCommitteeAt(ts),
181
306
  this.rollup.getSampleSeedAt(ts),
182
- this.rollup.client.getBlock({
307
+ prefetched?.latestBlock ?? this.rollup.client.getBlock({
183
308
  includeTransactions: false
184
- }).then((b)=>b.timestamp),
309
+ }),
310
+ prefetched !== undefined ? prefetched.finalizedBlock : getFinalizedL1Block(this.rollup.client),
185
311
  this.rollup.isEscapeHatchOpen(epoch)
186
312
  ]);
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.`);
313
+ const samplingTs = this.getSamplingTimestamp(epoch);
314
+ if (samplingTs > latestBlock.timestamp) {
315
+ 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
316
  }
192
- return {
317
+ // Empty committees are never marked finalized so they always get re-queried after TTL.
318
+ // If L1 has no finalized block yet (devnet startup), entries stay unfinalized.
319
+ const hasCommittee = !!(committee && committee.length > 0);
320
+ const finalized = hasCommittee && finalizedBlock !== undefined && samplingTs <= finalizedBlock.timestamp;
321
+ const data = {
193
322
  committee,
194
323
  seed: seedBuffer.toBigInt(),
195
324
  epoch,
196
325
  isEscapeHatchOpen
197
326
  };
327
+ const entry = {
328
+ data,
329
+ lastQueryL1BlockNumber: latestBlock.number,
330
+ lastQueryL1BlockHash: latestBlock.hash,
331
+ lastRefreshL1Timestamp: latestBlock.timestamp,
332
+ finalized
333
+ };
334
+ this.cache.set(epoch, entry);
335
+ this.purgeCache();
336
+ return entry;
198
337
  }
199
338
  /**
200
339
  * Get the ABI encoding of the proposer index - see ValidatorSelectionLib.sol computeProposerIndex
@@ -225,14 +364,26 @@ import { getEpochCacheConfigEnvVars } from './config.js';
225
364
  }
226
365
  return BigInt(keccak256(this.getProposerIndexEncoding(epoch, slot, seed))) % size;
227
366
  }
228
- /** Returns the current and next L2 slot numbers. */ getCurrentAndNextSlot() {
229
- const current = this.getEpochAndSlotNow();
367
+ /** Returns the current and next L2 slot in next eth L1 Slot. */ getCurrentAndNextSlot() {
368
+ const currentSlot = this.getSlotNow();
230
369
  const next = this.getEpochAndSlotInNextL1Slot();
231
370
  return {
232
- currentSlot: current.slot,
371
+ currentSlot,
233
372
  nextSlot: next.slot
234
373
  };
235
374
  }
375
+ /** Returns the target and next L2 slot in the next L1 slot. */ getTargetAndNextSlot() {
376
+ const nowSeconds = BigInt(this.dateProvider.nowInSeconds());
377
+ const offset = PROPOSER_PIPELINING_SLOT_OFFSET;
378
+ const currentSlot = getSlotAtTimestamp(nowSeconds, this.l1constants);
379
+ const targetSlot = SlotNumber(currentSlot + offset);
380
+ const nextL2SlotOnL1 = getSlotAtNextL1Block(nowSeconds, this.l1constants);
381
+ const nextSlot = SlotNumber(nextL2SlotOnL1 + offset);
382
+ return {
383
+ targetSlot,
384
+ nextSlot
385
+ };
386
+ }
236
387
  /**
237
388
  * Get the proposer attester address in the given L2 slot
238
389
  * @returns The proposer attester address. If the committee does not exist, we throw a NoCommitteeError.
@@ -290,10 +441,11 @@ import { getEpochCacheConfigEnvVars } from './config.js';
290
441
  async getRegisteredValidators() {
291
442
  const validatorRefreshIntervalMs = this.config.validatorRefreshIntervalSeconds * 1000;
292
443
  const validatorRefreshTime = this.lastValidatorRefresh + validatorRefreshIntervalMs;
293
- if (validatorRefreshTime < this.dateProvider.now()) {
294
- const currentSet = await this.rollup.getAttesters();
444
+ const now = this.dateProvider.now();
445
+ if (validatorRefreshTime < now) {
446
+ const currentSet = await this.rollup.getAttesters(BigInt(Math.floor(now / 1000)));
295
447
  this.allValidators = new Set(currentSet.map((v)=>v.toString()));
296
- this.lastValidatorRefresh = this.dateProvider.now();
448
+ this.lastValidatorRefresh = now;
297
449
  }
298
450
  return Array.from(this.allValidators.keys()).map((v)=>EthAddress.fromString(v));
299
451
  }
@@ -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,7 +17,9 @@ export declare class TestEpochCache implements EpochCacheInterface {
17
17
  private seed;
18
18
  private registeredValidators;
19
19
  private l1Constants;
20
+ private lagInEpochsForValidatorSet;
20
21
  constructor(l1Constants?: Partial<L1RollupConstants>);
22
+ setLagInEpochsForValidatorSet(lag: number): this;
21
23
  /**
22
24
  * Sets the committee members. Used in validation and attestation flows.
23
25
  * @param committee - Array of committee member addresses.
@@ -54,12 +56,20 @@ export declare class TestEpochCache implements EpochCacheInterface {
54
56
  */
55
57
  setL1Constants(constants: Partial<L1RollupConstants>): this;
56
58
  getL1Constants(): L1RollupConstants;
59
+ getLagInEpochsForValidatorSet(): number;
57
60
  getCommittee(_slot?: SlotTag): Promise<EpochCommitteeInfo>;
61
+ getSlotNow(): SlotNumber;
62
+ getTargetSlot(): SlotNumber;
63
+ getEpochNow(): EpochNumber;
64
+ getTargetEpoch(): EpochNumber;
58
65
  getEpochAndSlotNow(): EpochAndSlot & {
59
66
  nowMs: bigint;
60
67
  };
61
68
  getEpochAndSlotInNextL1Slot(): EpochAndSlot & {
62
- now: bigint;
69
+ nowSeconds: bigint;
70
+ };
71
+ getTargetEpochAndSlotInNextL1Slot(): EpochAndSlot & {
72
+ nowSeconds: bigint;
63
73
  };
64
74
  getProposerIndexEncoding(epoch: EpochNumber, slot: SlotNumber, seed: bigint): `0x${string}`;
65
75
  computeProposerIndex(slot: SlotNumber, _epoch: EpochNumber, _seed: bigint, size: bigint): bigint;
@@ -67,10 +77,15 @@ export declare class TestEpochCache implements EpochCacheInterface {
67
77
  currentSlot: SlotNumber;
68
78
  nextSlot: SlotNumber;
69
79
  };
80
+ getTargetAndNextSlot(): {
81
+ targetSlot: SlotNumber;
82
+ nextSlot: SlotNumber;
83
+ };
70
84
  getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined>;
71
85
  getRegisteredValidators(): Promise<EthAddress[]>;
72
86
  isInCommittee(_slot: SlotTag, validator: EthAddress): Promise<boolean>;
73
87
  filterInCommittee(_slot: SlotTag, validators: EthAddress[]): Promise<EthAddress[]>;
88
+ isEscapeHatchOpen(_epoch: EpochNumber): Promise<boolean>;
74
89
  isEscapeHatchOpenAtSlot(_slot?: SlotTag): Promise<boolean>;
75
90
  }
76
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdF9lcG9jaF9jYWNoZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3QvdGVzdF9lcG9jaF9jYWNoZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjo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AAC;QAAC,QAAQ,EAAE,UAAU,CAAA;KAAE,CAQzE;IAED,oBAAoB,IAAI;QAAE,UAAU,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE,UAAU,CAAA;KAAE,CAQvE;IAED,gCAAgC,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAEnF;IAED,uBAAuB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAE/C;IAED,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAErE;IAED,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAGjF;IAED,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAEvD;IAED,uBAAuB,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAEzD;CACF"}
@@ -1,12 +1,15 @@
1
1
  import { SlotNumber } from '@aztec/foundation/branded-types';
2
- import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
2
+ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampForSlot, 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,12 +25,17 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
22
25
  seed = 0n;
23
26
  registeredValidators = [];
24
27
  l1Constants;
28
+ lagInEpochsForValidatorSet = 2;
25
29
  constructor(l1Constants = {}){
26
30
  this.l1Constants = {
27
31
  ...DEFAULT_L1_CONSTANTS,
28
32
  ...l1Constants
29
33
  };
30
34
  }
35
+ setLagInEpochsForValidatorSet(lag) {
36
+ this.lagInEpochsForValidatorSet = lag;
37
+ return this;
38
+ }
31
39
  /**
32
40
  * Sets the committee members. Used in validation and attestation flows.
33
41
  * @param committee - Array of committee member addresses.
@@ -83,6 +91,9 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
83
91
  getL1Constants() {
84
92
  return this.l1Constants;
85
93
  }
94
+ getLagInEpochsForValidatorSet() {
95
+ return this.lagInEpochsForValidatorSet;
96
+ }
86
97
  getCommittee(_slot) {
87
98
  const epoch = getEpochAtSlot(this.currentSlot, this.l1Constants);
88
99
  return Promise.resolve({
@@ -92,27 +103,52 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
92
103
  isEscapeHatchOpen: this.escapeHatchOpen
93
104
  });
94
105
  }
106
+ getSlotNow() {
107
+ return this.currentSlot;
108
+ }
109
+ getTargetSlot() {
110
+ return SlotNumber(this.currentSlot + PROPOSER_PIPELINING_SLOT_OFFSET);
111
+ }
112
+ getEpochNow() {
113
+ return getEpochAtSlot(this.currentSlot, this.l1Constants);
114
+ }
115
+ getTargetEpoch() {
116
+ return getEpochAtSlot(this.getTargetSlot(), this.l1Constants);
117
+ }
95
118
  getEpochAndSlotNow() {
96
- const epoch = getEpochAtSlot(this.currentSlot, this.l1Constants);
97
- const ts = getTimestampRangeForEpoch(epoch, this.l1Constants)[0];
119
+ // Model "now" as the start of the current slot (mirroring the real EpochCache, which derives nowMs
120
+ // from the wall clock). Using the slot start rather than the epoch start keeps nowMs consistent with
121
+ // currentSlot, which the pipelining receive-window check (clock_tolerance) relies on.
122
+ const epochNow = getEpochAtSlot(this.currentSlot, this.l1Constants);
123
+ const ts = getTimestampForSlot(this.currentSlot, this.l1Constants);
98
124
  return {
99
- epoch,
125
+ epoch: epochNow,
100
126
  slot: this.currentSlot,
101
127
  ts,
102
128
  nowMs: ts * 1000n
103
129
  };
104
130
  }
105
131
  getEpochAndSlotInNextL1Slot() {
106
- const now = getTimestampRangeForEpoch(getEpochAtSlot(this.currentSlot, this.l1Constants), this.l1Constants)[0];
107
- const nextSlotTs = now + BigInt(this.l1Constants.ethereumSlotDuration);
132
+ const nowTs = getTimestampRangeForEpoch(getEpochAtSlot(this.currentSlot, this.l1Constants), this.l1Constants)[0];
133
+ const nextSlotTs = nowTs + BigInt(this.l1Constants.ethereumSlotDuration);
108
134
  const nextSlot = getSlotAtTimestamp(nextSlotTs, this.l1Constants);
109
- const epoch = getEpochAtSlot(nextSlot, this.l1Constants);
110
- const ts = getTimestampRangeForEpoch(epoch, this.l1Constants)[0];
135
+ const epochNow = getEpochAtSlot(nextSlot, this.l1Constants);
136
+ const ts = getTimestampRangeForEpoch(epochNow, this.l1Constants)[0];
111
137
  return {
112
- epoch,
138
+ epoch: epochNow,
113
139
  slot: nextSlot,
114
140
  ts,
115
- now
141
+ nowSeconds: nowTs
142
+ };
143
+ }
144
+ getTargetEpochAndSlotInNextL1Slot() {
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)
116
152
  };
117
153
  }
118
154
  getProposerIndexEncoding(epoch, slot, seed) {
@@ -126,9 +162,19 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
126
162
  return BigInt(slot) % size;
127
163
  }
128
164
  getCurrentAndNextSlot() {
165
+ const currentSlot = this.getSlotNow();
166
+ const next = this.getEpochAndSlotInNextL1Slot();
129
167
  return {
130
- currentSlot: this.currentSlot,
131
- nextSlot: SlotNumber(this.currentSlot + 1)
168
+ currentSlot,
169
+ nextSlot: next.slot
170
+ };
171
+ }
172
+ getTargetAndNextSlot() {
173
+ const targetSlot = this.getTargetSlot();
174
+ const next = this.getTargetEpochAndSlotInNextL1Slot();
175
+ return {
176
+ targetSlot,
177
+ nextSlot: next.slot
132
178
  };
133
179
  }
134
180
  getProposerAttesterAddressInSlot(_slot) {
@@ -144,6 +190,9 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
144
190
  const committeeSet = new Set(this.committee.map((v)=>v.toString()));
145
191
  return Promise.resolve(validators.filter((v)=>committeeSet.has(v.toString())));
146
192
  }
193
+ isEscapeHatchOpen(_epoch) {
194
+ return Promise.resolve(this.escapeHatchOpen);
195
+ }
147
196
  isEscapeHatchOpenAtSlot(_slot) {
148
197
  return Promise.resolve(this.escapeHatchOpen);
149
198
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/epoch-cache",
3
- "version": "0.0.1-commit.c31f2472",
3
+ "version": "0.0.1-commit.c52d6e7",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -26,17 +26,16 @@
26
26
  "../package.common.json"
27
27
  ],
28
28
  "dependencies": {
29
- "@aztec/ethereum": "0.0.1-commit.c31f2472",
30
- "@aztec/foundation": "0.0.1-commit.c31f2472",
31
- "@aztec/l1-artifacts": "0.0.1-commit.c31f2472",
32
- "@aztec/stdlib": "0.0.1-commit.c31f2472",
33
- "@viem/anvil": "^0.0.10",
29
+ "@aztec/ethereum": "0.0.1-commit.c52d6e7",
30
+ "@aztec/foundation": "0.0.1-commit.c52d6e7",
31
+ "@aztec/l1-artifacts": "6.0.0-nightly.20260807",
32
+ "@aztec/stdlib": "0.0.1-commit.c52d6e7",
34
33
  "dotenv": "^16.0.3",
35
34
  "get-port": "^7.1.0",
36
35
  "jest-mock-extended": "^4.0.0",
37
36
  "tslib": "^2.4.0",
38
37
  "viem": "npm:@aztec/viem@2.38.2",
39
- "zod": "^3.23.8"
38
+ "zod": "^4"
40
39
  },
41
40
  "devDependencies": {
42
41
  "@jest/globals": "^30.0.0",