@aztec/epoch-cache 1.0.0-nightly.20250704 → 1.0.0-nightly.20250705
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 +9 -8
- package/dest/epoch_cache.d.ts.map +1 -1
- package/dest/epoch_cache.js +4 -6
- package/package.json +5 -5
- package/src/epoch_cache.ts +13 -11
package/dest/epoch_cache.d.ts
CHANGED
|
@@ -13,8 +13,9 @@ export type EpochCommitteeInfo = {
|
|
|
13
13
|
seed: bigint;
|
|
14
14
|
epoch: bigint;
|
|
15
15
|
};
|
|
16
|
+
export type SlotTag = 'now' | 'next' | bigint;
|
|
16
17
|
export interface EpochCacheInterface {
|
|
17
|
-
getCommittee(slot:
|
|
18
|
+
getCommittee(slot: SlotTag | undefined): Promise<EpochCommitteeInfo>;
|
|
18
19
|
getEpochAndSlotNow(): EpochAndSlot;
|
|
19
20
|
getEpochAndSlotInNextL1Slot(): EpochAndSlot & {
|
|
20
21
|
now: bigint;
|
|
@@ -27,7 +28,8 @@ export interface EpochCacheInterface {
|
|
|
27
28
|
currentSlot: bigint;
|
|
28
29
|
nextSlot: bigint;
|
|
29
30
|
}>;
|
|
30
|
-
isInCommittee(validator: EthAddress): Promise<boolean>;
|
|
31
|
+
isInCommittee(slot: SlotTag, validator: EthAddress): Promise<boolean>;
|
|
32
|
+
filterInCommittee(slot: SlotTag, validators: EthAddress[]): Promise<EthAddress[]>;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* Epoch cache
|
|
@@ -67,7 +69,7 @@ export declare class EpochCache implements EpochCacheInterface {
|
|
|
67
69
|
* @param nextSlot - If true, get the validator set for the next slot.
|
|
68
70
|
* @returns The current validator set.
|
|
69
71
|
*/
|
|
70
|
-
getCommittee(slot?:
|
|
72
|
+
getCommittee(slot?: SlotTag): Promise<EpochCommitteeInfo>;
|
|
71
73
|
private getEpochAndTimestamp;
|
|
72
74
|
private computeCommittee;
|
|
73
75
|
/**
|
|
@@ -100,10 +102,9 @@ export declare class EpochCache implements EpochCacheInterface {
|
|
|
100
102
|
* If the committee is empty (i.e. target committee size is 0, and anyone can propose), we return undefined.
|
|
101
103
|
*/
|
|
102
104
|
private getProposerAttesterAddressAt;
|
|
103
|
-
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
filterInCommittee(validators: EthAddress[]): Promise<EthAddress[]>;
|
|
105
|
+
/** Check if a validator is in the given slot's committee */
|
|
106
|
+
isInCommittee(slot: SlotTag, validator: EthAddress): Promise<boolean>;
|
|
107
|
+
/** From the set of given addresses, return all that are on the committee for the given slot */
|
|
108
|
+
filterInCommittee(slot: SlotTag, validators: EthAddress[]): Promise<EthAddress[]>;
|
|
108
109
|
}
|
|
109
110
|
//# sourceMappingURL=epoch_cache.d.ts.map
|
|
@@ -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,EAEL,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,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,YAAY,CAAC,IA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EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAKvE;;;;OAIG;IACU,YAAY,CAAC,IAAI,GAAE,OAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAsB7E,OAAO,CAAC,oBAAoB;YAUd,gBAAgB;IAO9B;;OAEG;IACH,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE;IAWlF,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAQrF;;;;;OAKG;IACG,6CAA6C,IAAI,OAAO,CAAC;QAC7D,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,eAAe,EAAE,UAAU,GAAG,SAAS,CAAC;QACxC,YAAY,EAAE,UAAU,GAAG,SAAS,CAAC;KACtC,CAAC;IAYF;;;;OAIG;IACH,oCAAoC,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAMvE;;;;;OAKG;YACW,4BAA4B;IAa1C,4DAA4D;IACtD,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ3E,+FAA+F;IACzF,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAQxF"}
|
package/dest/epoch_cache.js
CHANGED
|
@@ -222,17 +222,15 @@ import { getEpochCacheConfigEnvVars } from './config.js';
|
|
|
222
222
|
const proposerIndex = this.computeProposerIndex(slot, epoch, seed, BigInt(committee.length));
|
|
223
223
|
return committee[Number(proposerIndex)];
|
|
224
224
|
}
|
|
225
|
-
/**
|
|
226
|
-
|
|
227
|
-
*/ async isInCommittee(validator) {
|
|
228
|
-
const { committee } = await this.getCommittee();
|
|
225
|
+
/** Check if a validator is in the given slot's committee */ async isInCommittee(slot, validator) {
|
|
226
|
+
const { committee } = await this.getCommittee(slot);
|
|
229
227
|
if (!committee) {
|
|
230
228
|
return false;
|
|
231
229
|
}
|
|
232
230
|
return committee.some((v)=>v.equals(validator));
|
|
233
231
|
}
|
|
234
|
-
async filterInCommittee(validators) {
|
|
235
|
-
const { committee } = await this.getCommittee();
|
|
232
|
+
/** From the set of given addresses, return all that are on the committee for the given slot */ async filterInCommittee(slot, validators) {
|
|
233
|
+
const { committee } = await this.getCommittee(slot);
|
|
236
234
|
if (!committee) {
|
|
237
235
|
return [];
|
|
238
236
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/epoch-cache",
|
|
3
|
-
"version": "1.0.0-nightly.
|
|
3
|
+
"version": "1.0.0-nightly.20250705",
|
|
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": "1.0.0-nightly.
|
|
30
|
-
"@aztec/foundation": "1.0.0-nightly.
|
|
31
|
-
"@aztec/l1-artifacts": "1.0.0-nightly.
|
|
32
|
-
"@aztec/stdlib": "1.0.0-nightly.
|
|
29
|
+
"@aztec/ethereum": "1.0.0-nightly.20250705",
|
|
30
|
+
"@aztec/foundation": "1.0.0-nightly.20250705",
|
|
31
|
+
"@aztec/l1-artifacts": "1.0.0-nightly.20250705",
|
|
32
|
+
"@aztec/stdlib": "1.0.0-nightly.20250705",
|
|
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
|
@@ -29,8 +29,10 @@ export type EpochCommitteeInfo = {
|
|
|
29
29
|
epoch: bigint;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
export type SlotTag = 'now' | 'next' | bigint;
|
|
33
|
+
|
|
32
34
|
export interface EpochCacheInterface {
|
|
33
|
-
getCommittee(slot:
|
|
35
|
+
getCommittee(slot: SlotTag | undefined): Promise<EpochCommitteeInfo>;
|
|
34
36
|
getEpochAndSlotNow(): EpochAndSlot;
|
|
35
37
|
getEpochAndSlotInNextL1Slot(): EpochAndSlot & { now: bigint };
|
|
36
38
|
getProposerIndexEncoding(epoch: bigint, slot: bigint, seed: bigint): `0x${string}`;
|
|
@@ -41,7 +43,8 @@ export interface EpochCacheInterface {
|
|
|
41
43
|
currentSlot: bigint;
|
|
42
44
|
nextSlot: bigint;
|
|
43
45
|
}>;
|
|
44
|
-
isInCommittee(validator: EthAddress): Promise<boolean>;
|
|
46
|
+
isInCommittee(slot: SlotTag, validator: EthAddress): Promise<boolean>;
|
|
47
|
+
filterInCommittee(slot: SlotTag, validators: EthAddress[]): Promise<EthAddress[]>;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
/**
|
|
@@ -163,7 +166,7 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
163
166
|
* @param nextSlot - If true, get the validator set for the next slot.
|
|
164
167
|
* @returns The current validator set.
|
|
165
168
|
*/
|
|
166
|
-
public async getCommittee(slot:
|
|
169
|
+
public async getCommittee(slot: SlotTag = 'now'): Promise<EpochCommitteeInfo> {
|
|
167
170
|
const { epoch, ts } = this.getEpochAndTimestamp(slot);
|
|
168
171
|
|
|
169
172
|
if (this.cache.has(epoch)) {
|
|
@@ -185,7 +188,7 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
185
188
|
return epochData;
|
|
186
189
|
}
|
|
187
190
|
|
|
188
|
-
private getEpochAndTimestamp(slot:
|
|
191
|
+
private getEpochAndTimestamp(slot: SlotTag = 'now') {
|
|
189
192
|
if (slot === 'now') {
|
|
190
193
|
return this.getEpochAndSlotNow();
|
|
191
194
|
} else if (slot === 'next') {
|
|
@@ -277,19 +280,18 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
277
280
|
return committee[Number(proposerIndex)];
|
|
278
281
|
}
|
|
279
282
|
|
|
280
|
-
/**
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
async isInCommittee(validator: EthAddress): Promise<boolean> {
|
|
284
|
-
const { committee } = await this.getCommittee();
|
|
283
|
+
/** Check if a validator is in the given slot's committee */
|
|
284
|
+
async isInCommittee(slot: SlotTag, validator: EthAddress): Promise<boolean> {
|
|
285
|
+
const { committee } = await this.getCommittee(slot);
|
|
285
286
|
if (!committee) {
|
|
286
287
|
return false;
|
|
287
288
|
}
|
|
288
289
|
return committee.some(v => v.equals(validator));
|
|
289
290
|
}
|
|
290
291
|
|
|
291
|
-
|
|
292
|
-
|
|
292
|
+
/** From the set of given addresses, return all that are on the committee for the given slot */
|
|
293
|
+
async filterInCommittee(slot: SlotTag, validators: EthAddress[]): Promise<EthAddress[]> {
|
|
294
|
+
const { committee } = await this.getCommittee(slot);
|
|
293
295
|
if (!committee) {
|
|
294
296
|
return [];
|
|
295
297
|
}
|