@aztec/epoch-cache 3.0.0-nightly.20251125 → 3.0.0-nightly.20251126
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/epoch_cache.d.ts +2 -1
- package/dest/epoch_cache.d.ts.map +1 -1
- package/dest/epoch_cache.js +7 -5
- package/package.json +5 -5
- package/src/epoch_cache.ts +25 -13
package/dest/epoch_cache.d.ts
CHANGED
|
@@ -54,7 +54,8 @@ export declare class EpochCache implements EpochCacheInterface {
|
|
|
54
54
|
private lastValidatorRefresh;
|
|
55
55
|
private readonly log;
|
|
56
56
|
constructor(rollup: RollupContract, l1constants: L1RollupConstants & {
|
|
57
|
-
|
|
57
|
+
lagInEpochsForValidatorSet: number;
|
|
58
|
+
lagInEpochsForRandao: number;
|
|
58
59
|
}, dateProvider?: DateProvider, config?: {
|
|
59
60
|
cacheSize: number;
|
|
60
61
|
validatorRefreshIntervalSeconds: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epoch_cache.d.ts","sourceRoot":"","sources":["../src/epoch_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,cAAc,EAAuB,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,KAAK,iBAAiB,EAOvB,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAAE,KAAK,gBAAgB,EAA8B,MAAM,aAAa,CAAC;AAEhF,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,E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,CAAC,UAAU,EAAE,CAAC;CAUvD"}
|
package/dest/epoch_cache.js
CHANGED
|
@@ -53,13 +53,14 @@ import { getEpochCacheConfigEnvVars } from './config.js';
|
|
|
53
53
|
});
|
|
54
54
|
rollup = new RollupContract(publicClient, rollupOrAddress.toString());
|
|
55
55
|
}
|
|
56
|
-
const [l1StartBlock, l1GenesisTime, proofSubmissionEpochs, slotDuration, epochDuration,
|
|
56
|
+
const [l1StartBlock, l1GenesisTime, proofSubmissionEpochs, slotDuration, epochDuration, lagInEpochsForValidatorSet, lagInEpochsForRandao] = await Promise.all([
|
|
57
57
|
rollup.getL1StartBlock(),
|
|
58
58
|
rollup.getL1GenesisTime(),
|
|
59
59
|
rollup.getProofSubmissionEpochs(),
|
|
60
60
|
rollup.getSlotDuration(),
|
|
61
61
|
rollup.getEpochDuration(),
|
|
62
|
-
rollup.
|
|
62
|
+
rollup.getLagInEpochsForValidatorSet(),
|
|
63
|
+
rollup.getLagInEpochsForRandao()
|
|
63
64
|
]);
|
|
64
65
|
const l1RollupConstants = {
|
|
65
66
|
l1StartBlock,
|
|
@@ -68,7 +69,8 @@ import { getEpochCacheConfigEnvVars } from './config.js';
|
|
|
68
69
|
slotDuration: Number(slotDuration),
|
|
69
70
|
epochDuration: Number(epochDuration),
|
|
70
71
|
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
71
|
-
|
|
72
|
+
lagInEpochsForValidatorSet: Number(lagInEpochsForValidatorSet),
|
|
73
|
+
lagInEpochsForRandao: Number(lagInEpochsForRandao)
|
|
72
74
|
};
|
|
73
75
|
return new EpochCache(rollup, l1RollupConstants, deps.dateProvider);
|
|
74
76
|
}
|
|
@@ -154,8 +156,8 @@ import { getEpochCacheConfigEnvVars } from './config.js';
|
|
|
154
156
|
includeTransactions: false
|
|
155
157
|
}).then((b)=>b.timestamp)
|
|
156
158
|
]);
|
|
157
|
-
const {
|
|
158
|
-
const sub = BigInt(
|
|
159
|
+
const { lagInEpochsForValidatorSet, epochDuration, slotDuration } = this.l1constants;
|
|
160
|
+
const sub = BigInt(lagInEpochsForValidatorSet) * BigInt(epochDuration) * BigInt(slotDuration);
|
|
159
161
|
if (ts - sub > l1Timestamp) {
|
|
160
162
|
throw new Error(`Cannot query committee for future epoch ${epoch} with timestamp ${ts} (current L1 time is ${l1Timestamp}). Check your Ethereum node is synced.`);
|
|
161
163
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/epoch-cache",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251126",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"../package.common.json"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
30
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
31
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
32
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
29
|
+
"@aztec/ethereum": "3.0.0-nightly.20251126",
|
|
30
|
+
"@aztec/foundation": "3.0.0-nightly.20251126",
|
|
31
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20251126",
|
|
32
|
+
"@aztec/stdlib": "3.0.0-nightly.20251126",
|
|
33
33
|
"@viem/anvil": "^0.0.10",
|
|
34
34
|
"dotenv": "^16.0.3",
|
|
35
35
|
"get-port": "^7.1.0",
|
package/src/epoch_cache.ts
CHANGED
|
@@ -64,7 +64,10 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
64
64
|
|
|
65
65
|
constructor(
|
|
66
66
|
private rollup: RollupContract,
|
|
67
|
-
private readonly l1constants: L1RollupConstants & {
|
|
67
|
+
private readonly l1constants: L1RollupConstants & {
|
|
68
|
+
lagInEpochsForValidatorSet: number;
|
|
69
|
+
lagInEpochsForRandao: number;
|
|
70
|
+
},
|
|
68
71
|
private readonly dateProvider: DateProvider = new DateProvider(),
|
|
69
72
|
protected readonly config = { cacheSize: 12, validatorRefreshIntervalSeconds: 60 },
|
|
70
73
|
) {
|
|
@@ -94,15 +97,23 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
94
97
|
rollup = new RollupContract(publicClient, rollupOrAddress.toString());
|
|
95
98
|
}
|
|
96
99
|
|
|
97
|
-
const [
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
const [
|
|
101
|
+
l1StartBlock,
|
|
102
|
+
l1GenesisTime,
|
|
103
|
+
proofSubmissionEpochs,
|
|
104
|
+
slotDuration,
|
|
105
|
+
epochDuration,
|
|
106
|
+
lagInEpochsForValidatorSet,
|
|
107
|
+
lagInEpochsForRandao,
|
|
108
|
+
] = await Promise.all([
|
|
109
|
+
rollup.getL1StartBlock(),
|
|
110
|
+
rollup.getL1GenesisTime(),
|
|
111
|
+
rollup.getProofSubmissionEpochs(),
|
|
112
|
+
rollup.getSlotDuration(),
|
|
113
|
+
rollup.getEpochDuration(),
|
|
114
|
+
rollup.getLagInEpochsForValidatorSet(),
|
|
115
|
+
rollup.getLagInEpochsForRandao(),
|
|
116
|
+
] as const);
|
|
106
117
|
|
|
107
118
|
const l1RollupConstants = {
|
|
108
119
|
l1StartBlock,
|
|
@@ -111,7 +122,8 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
111
122
|
slotDuration: Number(slotDuration),
|
|
112
123
|
epochDuration: Number(epochDuration),
|
|
113
124
|
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
114
|
-
|
|
125
|
+
lagInEpochsForValidatorSet: Number(lagInEpochsForValidatorSet),
|
|
126
|
+
lagInEpochsForRandao: Number(lagInEpochsForRandao),
|
|
115
127
|
};
|
|
116
128
|
|
|
117
129
|
return new EpochCache(rollup, l1RollupConstants, deps.dateProvider);
|
|
@@ -200,8 +212,8 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
200
212
|
this.rollup.getSampleSeedAt(ts),
|
|
201
213
|
this.rollup.client.getBlock({ includeTransactions: false }).then(b => b.timestamp),
|
|
202
214
|
]);
|
|
203
|
-
const {
|
|
204
|
-
const sub = BigInt(
|
|
215
|
+
const { lagInEpochsForValidatorSet, epochDuration, slotDuration } = this.l1constants;
|
|
216
|
+
const sub = BigInt(lagInEpochsForValidatorSet) * BigInt(epochDuration) * BigInt(slotDuration);
|
|
205
217
|
if (ts - sub > l1Timestamp) {
|
|
206
218
|
throw new Error(
|
|
207
219
|
`Cannot query committee for future epoch ${epoch} with timestamp ${ts} (current L1 time is ${l1Timestamp}). Check your Ethereum node is synced.`,
|