@aztec/epoch-cache 1.0.0-nightly.20250708 → 1.0.0-staging.1
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 +8 -9
- package/dest/epoch_cache.d.ts.map +1 -1
- package/dest/epoch_cache.js +6 -4
- package/package.json +5 -5
- package/src/epoch_cache.ts +11 -13
package/dest/epoch_cache.d.ts
CHANGED
|
@@ -13,9 +13,8 @@ export type EpochCommitteeInfo = {
|
|
|
13
13
|
seed: bigint;
|
|
14
14
|
epoch: bigint;
|
|
15
15
|
};
|
|
16
|
-
export type SlotTag = 'now' | 'next' | bigint;
|
|
17
16
|
export interface EpochCacheInterface {
|
|
18
|
-
getCommittee(slot:
|
|
17
|
+
getCommittee(slot: 'now' | 'next' | bigint | undefined): Promise<EpochCommitteeInfo>;
|
|
19
18
|
getEpochAndSlotNow(): EpochAndSlot;
|
|
20
19
|
getEpochAndSlotInNextL1Slot(): EpochAndSlot & {
|
|
21
20
|
now: bigint;
|
|
@@ -28,8 +27,7 @@ export interface EpochCacheInterface {
|
|
|
28
27
|
currentSlot: bigint;
|
|
29
28
|
nextSlot: bigint;
|
|
30
29
|
}>;
|
|
31
|
-
isInCommittee(
|
|
32
|
-
filterInCommittee(slot: SlotTag, validators: EthAddress[]): Promise<EthAddress[]>;
|
|
30
|
+
isInCommittee(validator: EthAddress): Promise<boolean>;
|
|
33
31
|
}
|
|
34
32
|
/**
|
|
35
33
|
* Epoch cache
|
|
@@ -69,7 +67,7 @@ export declare class EpochCache implements EpochCacheInterface {
|
|
|
69
67
|
* @param nextSlot - If true, get the validator set for the next slot.
|
|
70
68
|
* @returns The current validator set.
|
|
71
69
|
*/
|
|
72
|
-
getCommittee(slot?:
|
|
70
|
+
getCommittee(slot?: 'now' | 'next' | bigint): Promise<EpochCommitteeInfo>;
|
|
73
71
|
private getEpochAndTimestamp;
|
|
74
72
|
private computeCommittee;
|
|
75
73
|
/**
|
|
@@ -102,9 +100,10 @@ export declare class EpochCache implements EpochCacheInterface {
|
|
|
102
100
|
* If the committee is empty (i.e. target committee size is 0, and anyone can propose), we return undefined.
|
|
103
101
|
*/
|
|
104
102
|
private getProposerAttesterAddressAt;
|
|
105
|
-
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Check if a validator is in the current epoch's committee
|
|
105
|
+
*/
|
|
106
|
+
isInCommittee(validator: EthAddress): Promise<boolean>;
|
|
107
|
+
filterInCommittee(validators: EthAddress[]): Promise<EthAddress[]>;
|
|
109
108
|
}
|
|
110
109
|
//# 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,
|
|
1
|
+
{"version":3,"file":"epoch_cache.d.ts","sourceRoot":"","sources":["../src/epoch_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,cAAc,EAAuB,MAAM,iBAAiB,CAAC;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,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;;OAEG;IACG,aAAa,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAQtD,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAQzE"}
|
package/dest/epoch_cache.js
CHANGED
|
@@ -222,15 +222,17 @@ 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
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Check if a validator is in the current epoch's committee
|
|
227
|
+
*/ async isInCommittee(validator) {
|
|
228
|
+
const { committee } = await this.getCommittee();
|
|
227
229
|
if (!committee) {
|
|
228
230
|
return false;
|
|
229
231
|
}
|
|
230
232
|
return committee.some((v)=>v.equals(validator));
|
|
231
233
|
}
|
|
232
|
-
|
|
233
|
-
const { committee } = await this.getCommittee(
|
|
234
|
+
async filterInCommittee(validators) {
|
|
235
|
+
const { committee } = await this.getCommittee();
|
|
234
236
|
if (!committee) {
|
|
235
237
|
return [];
|
|
236
238
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/epoch-cache",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-staging.1",
|
|
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-
|
|
30
|
-
"@aztec/foundation": "1.0.0-
|
|
31
|
-
"@aztec/l1-artifacts": "1.0.0-
|
|
32
|
-
"@aztec/stdlib": "1.0.0-
|
|
29
|
+
"@aztec/ethereum": "1.0.0-staging.1",
|
|
30
|
+
"@aztec/foundation": "1.0.0-staging.1",
|
|
31
|
+
"@aztec/l1-artifacts": "1.0.0-staging.1",
|
|
32
|
+
"@aztec/stdlib": "1.0.0-staging.1",
|
|
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,10 +29,8 @@ export type EpochCommitteeInfo = {
|
|
|
29
29
|
epoch: bigint;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
export type SlotTag = 'now' | 'next' | bigint;
|
|
33
|
-
|
|
34
32
|
export interface EpochCacheInterface {
|
|
35
|
-
getCommittee(slot:
|
|
33
|
+
getCommittee(slot: 'now' | 'next' | bigint | undefined): Promise<EpochCommitteeInfo>;
|
|
36
34
|
getEpochAndSlotNow(): EpochAndSlot;
|
|
37
35
|
getEpochAndSlotInNextL1Slot(): EpochAndSlot & { now: bigint };
|
|
38
36
|
getProposerIndexEncoding(epoch: bigint, slot: bigint, seed: bigint): `0x${string}`;
|
|
@@ -43,8 +41,7 @@ export interface EpochCacheInterface {
|
|
|
43
41
|
currentSlot: bigint;
|
|
44
42
|
nextSlot: bigint;
|
|
45
43
|
}>;
|
|
46
|
-
isInCommittee(
|
|
47
|
-
filterInCommittee(slot: SlotTag, validators: EthAddress[]): Promise<EthAddress[]>;
|
|
44
|
+
isInCommittee(validator: EthAddress): Promise<boolean>;
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
/**
|
|
@@ -166,7 +163,7 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
166
163
|
* @param nextSlot - If true, get the validator set for the next slot.
|
|
167
164
|
* @returns The current validator set.
|
|
168
165
|
*/
|
|
169
|
-
public async getCommittee(slot:
|
|
166
|
+
public async getCommittee(slot: 'now' | 'next' | bigint = 'now'): Promise<EpochCommitteeInfo> {
|
|
170
167
|
const { epoch, ts } = this.getEpochAndTimestamp(slot);
|
|
171
168
|
|
|
172
169
|
if (this.cache.has(epoch)) {
|
|
@@ -188,7 +185,7 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
188
185
|
return epochData;
|
|
189
186
|
}
|
|
190
187
|
|
|
191
|
-
private getEpochAndTimestamp(slot:
|
|
188
|
+
private getEpochAndTimestamp(slot: 'now' | 'next' | bigint = 'now') {
|
|
192
189
|
if (slot === 'now') {
|
|
193
190
|
return this.getEpochAndSlotNow();
|
|
194
191
|
} else if (slot === 'next') {
|
|
@@ -280,18 +277,19 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
280
277
|
return committee[Number(proposerIndex)];
|
|
281
278
|
}
|
|
282
279
|
|
|
283
|
-
/**
|
|
284
|
-
|
|
285
|
-
|
|
280
|
+
/**
|
|
281
|
+
* Check if a validator is in the current epoch's committee
|
|
282
|
+
*/
|
|
283
|
+
async isInCommittee(validator: EthAddress): Promise<boolean> {
|
|
284
|
+
const { committee } = await this.getCommittee();
|
|
286
285
|
if (!committee) {
|
|
287
286
|
return false;
|
|
288
287
|
}
|
|
289
288
|
return committee.some(v => v.equals(validator));
|
|
290
289
|
}
|
|
291
290
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
const { committee } = await this.getCommittee(slot);
|
|
291
|
+
async filterInCommittee(validators: EthAddress[]): Promise<EthAddress[]> {
|
|
292
|
+
const { committee } = await this.getCommittee();
|
|
295
293
|
if (!committee) {
|
|
296
294
|
return [];
|
|
297
295
|
}
|