@aztec/epoch-cache 0.0.1-commit.993d52e → 0.0.1-commit.9a89641

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,14 +56,14 @@ 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, targetCommitteeSize] = 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(),
@@ -65,7 +71,8 @@ import { getEpochCacheConfigEnvVars } from './config.js';
65
71
  rollup.getEpochDuration(),
66
72
  rollup.getLagInEpochsForValidatorSet(),
67
73
  rollup.getLagInEpochsForRandao(),
68
- rollup.getTargetCommitteeSize()
74
+ rollup.getTargetCommitteeSize(),
75
+ rollup.getManaLimit()
69
76
  ]);
70
77
  const l1RollupConstants = {
71
78
  l1StartBlock,
@@ -76,13 +83,39 @@ import { getEpochCacheConfigEnvVars } from './config.js';
76
83
  ethereumSlotDuration: config.ethereumSlotDuration,
77
84
  lagInEpochsForValidatorSet: Number(lagInEpochsForValidatorSet),
78
85
  lagInEpochsForRandao: Number(lagInEpochsForRandao),
79
- targetCommitteeSize: Number(targetCommitteeSize)
86
+ targetCommitteeSize: Number(targetCommitteeSize),
87
+ rollupManaLimit: Number(rollupManaLimit)
80
88
  };
81
- return new EpochCache(rollup, l1RollupConstants, deps.dateProvider);
89
+ return new EpochCache(rollup, l1RollupConstants, deps.dateProvider, {
90
+ cacheSize: 12,
91
+ validatorRefreshIntervalSeconds: 60
92
+ });
82
93
  }
83
94
  getL1Constants() {
84
95
  return this.l1constants;
85
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
+ }
86
119
  getEpochAndSlotNow() {
87
120
  const nowMs = BigInt(this.dateProvider.now());
88
121
  const nowSeconds = nowMs / 1000n;
@@ -91,48 +124,41 @@ import { getEpochCacheConfigEnvVars } from './config.js';
91
124
  nowMs
92
125
  };
93
126
  }
94
- nowInSeconds() {
95
- return BigInt(Math.floor(this.dateProvider.now() / 1000));
96
- }
97
127
  getEpochAndSlotAtSlot(slot) {
98
- const epoch = getEpochAtSlot(slot, this.l1constants);
99
- const ts = getTimestampRangeForEpoch(epoch, this.l1constants)[0];
100
- return {
101
- epoch,
102
- ts,
103
- slot
104
- };
128
+ return this.getEpochAndSlotAtTimestamp(getTimestampForSlot(slot, this.l1constants));
105
129
  }
106
130
  getEpochAndSlotInNextL1Slot() {
107
- const now = this.nowInSeconds();
108
- const nextSlotTs = now + BigInt(this.l1constants.ethereumSlotDuration);
131
+ const nowSeconds = this.dateProvider.nowInSeconds();
132
+ const nextSlotTs = getNextL1SlotTimestamp(nowSeconds, this.l1constants);
109
133
  return {
110
134
  ...this.getEpochAndSlotAtTimestamp(nextSlotTs),
111
- 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)
112
146
  };
113
147
  }
114
148
  getEpochAndSlotAtTimestamp(ts) {
115
149
  const slot = getSlotAtTimestamp(ts, this.l1constants);
150
+ const epoch = getEpochNumberAtTimestamp(ts, this.l1constants);
116
151
  return {
117
- epoch: getEpochNumberAtTimestamp(ts, this.l1constants),
118
- ts: getTimestampForSlot(slot, this.l1constants),
119
- slot
152
+ slot,
153
+ epoch,
154
+ ts: getTimestampForSlot(slot, this.l1constants)
120
155
  };
121
156
  }
122
157
  getCommitteeForEpoch(epoch) {
123
158
  const [startSlot] = getSlotRangeForEpoch(epoch, this.l1constants);
124
159
  return this.getCommittee(startSlot);
125
160
  }
126
- /**
127
- * Returns whether the escape hatch is open for the given epoch.
128
- *
129
- * Uses the already-cached EpochCommitteeInfo when available. If not cached, it will fetch
130
- * the epoch committee info (which includes the escape hatch flag) and return it.
131
- */ async isEscapeHatchOpen(epoch) {
132
- const cached = this.cache.get(epoch);
133
- if (cached) {
134
- return cached.isEscapeHatchOpen;
135
- }
161
+ /** Returns whether the escape hatch is open for the given epoch. */ async isEscapeHatchOpen(epoch) {
136
162
  const info = await this.getCommitteeForEpoch(epoch);
137
163
  return info.isEscapeHatchOpen;
138
164
  }
@@ -142,30 +168,47 @@ import { getEpochCacheConfigEnvVars } from './config.js';
142
168
  * This is a lightweight helper intended for callers that already have a slot number and only
143
169
  * need the escape hatch flag (without pulling full committee info).
144
170
  */ async isEscapeHatchOpenAtSlot(slot = 'now') {
145
- 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);
146
172
  return await this.isEscapeHatchOpen(epoch);
147
173
  }
148
174
  /**
149
- * Get the current validator set
150
- * @param nextSlot - If true, get the validator set for the next slot.
151
- * @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.
152
180
  */ async getCommittee(slot = 'now') {
153
181
  const { epoch, ts } = this.getEpochAndTimestamp(slot);
154
- if (this.cache.has(epoch)) {
155
- 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;
156
186
  }
157
- const epochData = await this.computeCommittee({
158
- epoch,
159
- ts
160
- });
161
- // If the committee size is 0 or undefined, then do not cache
162
- if (!epochData.committee || epochData.committee.length === 0) {
163
- 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;
164
211
  }
165
- this.cache.set(epoch, epochData);
166
- const toPurge = Array.from(this.cache.keys()).sort((a, b)=>Number(b - a)).slice(this.config.cacheSize);
167
- toPurge.forEach((key)=>this.cache.delete(key));
168
- return epochData;
169
212
  }
170
213
  getEpochAndTimestamp(slot = 'now') {
171
214
  if (slot === 'now') {
@@ -176,27 +219,121 @@ import { getEpochCacheConfigEnvVars } from './config.js';
176
219
  return this.getEpochAndSlotAtSlot(slot);
177
220
  }
178
221
  }
179
- async computeCommittee(when) {
180
- const { ts, epoch } = when;
181
- 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([
182
305
  this.rollup.getCommitteeAt(ts),
183
306
  this.rollup.getSampleSeedAt(ts),
184
- this.rollup.client.getBlock({
307
+ prefetched?.latestBlock ?? this.rollup.client.getBlock({
185
308
  includeTransactions: false
186
- }).then((b)=>b.timestamp),
309
+ }),
310
+ prefetched !== undefined ? prefetched.finalizedBlock : getFinalizedL1Block(this.rollup.client),
187
311
  this.rollup.isEscapeHatchOpen(epoch)
188
312
  ]);
189
- const { lagInEpochsForValidatorSet, epochDuration, slotDuration } = this.l1constants;
190
- const sub = BigInt(lagInEpochsForValidatorSet) * BigInt(epochDuration) * BigInt(slotDuration);
191
- if (ts - sub > l1Timestamp) {
192
- 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.`);
193
316
  }
194
- 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 = {
195
322
  committee,
196
323
  seed: seedBuffer.toBigInt(),
197
324
  epoch,
198
325
  isEscapeHatchOpen
199
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;
200
337
  }
201
338
  /**
202
339
  * Get the ABI encoding of the proposer index - see ValidatorSelectionLib.sol computeProposerIndex
@@ -227,14 +364,26 @@ import { getEpochCacheConfigEnvVars } from './config.js';
227
364
  }
228
365
  return BigInt(keccak256(this.getProposerIndexEncoding(epoch, slot, seed))) % size;
229
366
  }
230
- /** Returns the current and next L2 slot numbers. */ getCurrentAndNextSlot() {
231
- const current = this.getEpochAndSlotNow();
367
+ /** Returns the current and next L2 slot in next eth L1 Slot. */ getCurrentAndNextSlot() {
368
+ const currentSlot = this.getSlotNow();
232
369
  const next = this.getEpochAndSlotInNextL1Slot();
233
370
  return {
234
- currentSlot: current.slot,
371
+ currentSlot,
235
372
  nextSlot: next.slot
236
373
  };
237
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
+ }
238
387
  /**
239
388
  * Get the proposer attester address in the given L2 slot
240
389
  * @returns The proposer attester address. If the committee does not exist, we throw a NoCommitteeError.
@@ -292,10 +441,11 @@ import { getEpochCacheConfigEnvVars } from './config.js';
292
441
  async getRegisteredValidators() {
293
442
  const validatorRefreshIntervalMs = this.config.validatorRefreshIntervalSeconds * 1000;
294
443
  const validatorRefreshTime = this.lastValidatorRefresh + validatorRefreshIntervalMs;
295
- if (validatorRefreshTime < this.dateProvider.now()) {
296
- 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)));
297
447
  this.allValidators = new Set(currentSet.map((v)=>v.toString()));
298
- this.lastValidatorRefresh = this.dateProvider.now();
448
+ this.lastValidatorRefresh = now;
299
449
  }
300
450
  return Array.from(this.allValidators.keys()).map((v)=>EthAddress.fromString(v));
301
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdF9lcG9jaF9jYWNoZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3QvdGVzdF9lcG9jaF9jYWNoZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmd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AU,CAAC;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,5 +1,6 @@
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,
@@ -7,7 +8,8 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
7
8
  epochDuration: 16,
8
9
  ethereumSlotDuration: 12,
9
10
  proofSubmissionEpochs: 2,
10
- targetCommitteeSize: 48
11
+ targetCommitteeSize: 48,
12
+ rollupManaLimit: Number.MAX_SAFE_INTEGER
11
13
  };
12
14
  /**
13
15
  * A test implementation of EpochCacheInterface that allows manual configuration
@@ -23,12 +25,17 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
23
25
  seed = 0n;
24
26
  registeredValidators = [];
25
27
  l1Constants;
28
+ lagInEpochsForValidatorSet = 2;
26
29
  constructor(l1Constants = {}){
27
30
  this.l1Constants = {
28
31
  ...DEFAULT_L1_CONSTANTS,
29
32
  ...l1Constants
30
33
  };
31
34
  }
35
+ setLagInEpochsForValidatorSet(lag) {
36
+ this.lagInEpochsForValidatorSet = lag;
37
+ return this;
38
+ }
32
39
  /**
33
40
  * Sets the committee members. Used in validation and attestation flows.
34
41
  * @param committee - Array of committee member addresses.
@@ -84,6 +91,9 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
84
91
  getL1Constants() {
85
92
  return this.l1Constants;
86
93
  }
94
+ getLagInEpochsForValidatorSet() {
95
+ return this.lagInEpochsForValidatorSet;
96
+ }
87
97
  getCommittee(_slot) {
88
98
  const epoch = getEpochAtSlot(this.currentSlot, this.l1Constants);
89
99
  return Promise.resolve({
@@ -93,27 +103,52 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
93
103
  isEscapeHatchOpen: this.escapeHatchOpen
94
104
  });
95
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
+ }
96
118
  getEpochAndSlotNow() {
97
- const epoch = getEpochAtSlot(this.currentSlot, this.l1Constants);
98
- 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);
99
124
  return {
100
- epoch,
125
+ epoch: epochNow,
101
126
  slot: this.currentSlot,
102
127
  ts,
103
128
  nowMs: ts * 1000n
104
129
  };
105
130
  }
106
131
  getEpochAndSlotInNextL1Slot() {
107
- const now = getTimestampRangeForEpoch(getEpochAtSlot(this.currentSlot, this.l1Constants), this.l1Constants)[0];
108
- 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);
109
134
  const nextSlot = getSlotAtTimestamp(nextSlotTs, this.l1Constants);
110
- const epoch = getEpochAtSlot(nextSlot, this.l1Constants);
111
- const ts = getTimestampRangeForEpoch(epoch, this.l1Constants)[0];
135
+ const epochNow = getEpochAtSlot(nextSlot, this.l1Constants);
136
+ const ts = getTimestampRangeForEpoch(epochNow, this.l1Constants)[0];
112
137
  return {
113
- epoch,
138
+ epoch: epochNow,
114
139
  slot: nextSlot,
115
140
  ts,
116
- 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)
117
152
  };
118
153
  }
119
154
  getProposerIndexEncoding(epoch, slot, seed) {
@@ -127,9 +162,19 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
127
162
  return BigInt(slot) % size;
128
163
  }
129
164
  getCurrentAndNextSlot() {
165
+ const currentSlot = this.getSlotNow();
166
+ const next = this.getEpochAndSlotInNextL1Slot();
130
167
  return {
131
- currentSlot: this.currentSlot,
132
- 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
133
178
  };
134
179
  }
135
180
  getProposerAttesterAddressInSlot(_slot) {
@@ -145,6 +190,9 @@ import { getEpochAtSlot, getSlotAtTimestamp, getTimestampRangeForEpoch } from '@
145
190
  const committeeSet = new Set(this.committee.map((v)=>v.toString()));
146
191
  return Promise.resolve(validators.filter((v)=>committeeSet.has(v.toString())));
147
192
  }
193
+ isEscapeHatchOpen(_epoch) {
194
+ return Promise.resolve(this.escapeHatchOpen);
195
+ }
148
196
  isEscapeHatchOpenAtSlot(_slot) {
149
197
  return Promise.resolve(this.escapeHatchOpen);
150
198
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/epoch-cache",
3
- "version": "0.0.1-commit.993d52e",
3
+ "version": "0.0.1-commit.9a89641",
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.993d52e",
30
- "@aztec/foundation": "0.0.1-commit.993d52e",
31
- "@aztec/l1-artifacts": "0.0.1-commit.993d52e",
32
- "@aztec/stdlib": "0.0.1-commit.993d52e",
33
- "@viem/anvil": "^0.0.10",
29
+ "@aztec/ethereum": "0.0.1-commit.9a89641",
30
+ "@aztec/foundation": "0.0.1-commit.9a89641",
31
+ "@aztec/l1-artifacts": "6.0.0-nightly.20260807",
32
+ "@aztec/stdlib": "0.0.1-commit.9a89641",
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",