@aztec/epoch-cache 3.0.0-nightly.20250911 → 3.0.0-nightly.20250912
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/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/epoch_cache.d.ts +7 -1
- package/dest/epoch_cache.d.ts.map +1 -1
- package/dest/epoch_cache.js +29 -13
- package/package.json +5 -5
- package/src/config.ts +1 -6
- package/src/epoch_cache.ts +47 -22
package/dest/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type L1ContractsConfig, type L1ReaderConfig } from '@aztec/ethereum';
|
|
2
|
-
export type EpochCacheConfig = Pick<L1ReaderConfig & L1ContractsConfig, 'l1RpcUrls' | 'l1ChainId' | 'viemPollingIntervalMS' | '
|
|
2
|
+
export type EpochCacheConfig = Pick<L1ReaderConfig & L1ContractsConfig, 'l1RpcUrls' | 'l1ChainId' | 'viemPollingIntervalMS' | 'ethereumSlotDuration'>;
|
|
3
3
|
export declare function getEpochCacheConfigEnvVars(): EpochCacheConfig;
|
|
4
4
|
//# sourceMappingURL=config.d.ts.map
|
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAGpB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,cAAc,GAAG,iBAAiB,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAGpB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,cAAc,GAAG,iBAAiB,EAClC,WAAW,GAAG,WAAW,GAAG,uBAAuB,GAAG,sBAAsB,CAC7E,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,gBAAgB,CAE7D"}
|
package/dest/epoch_cache.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export declare class EpochCache implements EpochCacheInterface {
|
|
|
54
54
|
cacheSize: number;
|
|
55
55
|
validatorRefreshIntervalSeconds: number;
|
|
56
56
|
});
|
|
57
|
-
static create(
|
|
57
|
+
static create(rollupOrAddress: EthAddress | RollupContract, config?: EpochCacheConfig, deps?: {
|
|
58
58
|
dateProvider?: DateProvider;
|
|
59
59
|
}): Promise<EpochCache>;
|
|
60
60
|
getL1Constants(): L1RollupConstants;
|
|
@@ -93,6 +93,12 @@ export declare class EpochCache implements EpochCacheInterface {
|
|
|
93
93
|
currentProposer: EthAddress | undefined;
|
|
94
94
|
nextProposer: EthAddress | undefined;
|
|
95
95
|
}>;
|
|
96
|
+
/**
|
|
97
|
+
* Get the proposer attester address in the gien slot
|
|
98
|
+
* @returns The proposer attester address. If the committee does not exist, we throw a NoCommitteeError.
|
|
99
|
+
* If the committee is empty (i.e. target committee size is 0, and anyone can propose), we return undefined.
|
|
100
|
+
*/
|
|
101
|
+
getProposerAttesterAddressInSlot(slot: bigint): Promise<EthAddress | undefined>;
|
|
96
102
|
/**
|
|
97
103
|
* Get the proposer attester address in the next slot
|
|
98
104
|
* @returns The proposer attester address. If the committee does not exist, we throw a NoCommitteeError.
|
|
@@ -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,gBAAg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AW,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;IACI,gCAAgC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAKtF;;;;OAIG;IACI,oCAAoC,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAK9E;;;;;OAKG;YACW,4BAA4B;IAanC,6BAA6B,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAclH,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;IASjF,uBAAuB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;CAUvD"}
|
package/dest/epoch_cache.js
CHANGED
|
@@ -46,29 +46,37 @@ import { getEpochCacheConfigEnvVars } from './config.js';
|
|
|
46
46
|
initialEpoch
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
static async create(
|
|
49
|
+
static async create(rollupOrAddress, config, deps = {}) {
|
|
50
50
|
config = config ?? getEpochCacheConfigEnvVars();
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
// Load the rollup contract if we were given an address
|
|
52
|
+
let rollup;
|
|
53
|
+
if ('address' in rollupOrAddress) {
|
|
54
|
+
rollup = rollupOrAddress;
|
|
55
|
+
} else {
|
|
56
|
+
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
57
|
+
const publicClient = createPublicClient({
|
|
58
|
+
chain: chain.chainInfo,
|
|
59
|
+
transport: fallback(config.l1RpcUrls.map((url)=>http(url))),
|
|
60
|
+
pollingInterval: config.viemPollingIntervalMS
|
|
61
|
+
});
|
|
62
|
+
rollup = new RollupContract(publicClient, rollupOrAddress.toString());
|
|
63
|
+
}
|
|
64
|
+
const [l1StartBlock, l1GenesisTime, initialValidators, sampleSeed, epochNumber, proofSubmissionEpochs, slotDuration, epochDuration] = await Promise.all([
|
|
59
65
|
rollup.getL1StartBlock(),
|
|
60
66
|
rollup.getL1GenesisTime(),
|
|
61
67
|
rollup.getCurrentEpochCommittee(),
|
|
62
68
|
rollup.getCurrentSampleSeed(),
|
|
63
|
-
rollup.
|
|
64
|
-
rollup.getProofSubmissionEpochs()
|
|
69
|
+
rollup.getCurrentEpochNumber(),
|
|
70
|
+
rollup.getProofSubmissionEpochs(),
|
|
71
|
+
rollup.getSlotDuration(),
|
|
72
|
+
rollup.getEpochDuration()
|
|
65
73
|
]);
|
|
66
74
|
const l1RollupConstants = {
|
|
67
75
|
l1StartBlock,
|
|
68
76
|
l1GenesisTime,
|
|
69
77
|
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
70
|
-
slotDuration:
|
|
71
|
-
epochDuration:
|
|
78
|
+
slotDuration: Number(slotDuration),
|
|
79
|
+
epochDuration: Number(epochDuration),
|
|
72
80
|
ethereumSlotDuration: config.ethereumSlotDuration
|
|
73
81
|
};
|
|
74
82
|
return new EpochCache(rollup, epochNumber, initialValidators?.map((v)=>EthAddress.fromString(v)), sampleSeed, l1RollupConstants, deps.dateProvider);
|
|
@@ -204,6 +212,14 @@ import { getEpochCacheConfigEnvVars } from './config.js';
|
|
|
204
212
|
};
|
|
205
213
|
}
|
|
206
214
|
/**
|
|
215
|
+
* Get the proposer attester address in the gien slot
|
|
216
|
+
* @returns The proposer attester address. If the committee does not exist, we throw a NoCommitteeError.
|
|
217
|
+
* If the committee is empty (i.e. target committee size is 0, and anyone can propose), we return undefined.
|
|
218
|
+
*/ getProposerAttesterAddressInSlot(slot) {
|
|
219
|
+
const epochAndSlot = this.getEpochAndSlotAtSlot(slot);
|
|
220
|
+
return this.getProposerAttesterAddressAt(epochAndSlot);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
207
223
|
* Get the proposer attester address in the next slot
|
|
208
224
|
* @returns The proposer attester address. If the committee does not exist, we throw a NoCommitteeError.
|
|
209
225
|
* If the committee is empty (i.e. target committee size is 0, and anyone can propose), we return undefined.
|
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.20250912",
|
|
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.20250912",
|
|
30
|
+
"@aztec/foundation": "3.0.0-nightly.20250912",
|
|
31
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20250912",
|
|
32
|
+
"@aztec/stdlib": "3.0.0-nightly.20250912",
|
|
33
33
|
"@viem/anvil": "^0.0.10",
|
|
34
34
|
"dotenv": "^16.0.3",
|
|
35
35
|
"get-port": "^7.1.0",
|
package/src/config.ts
CHANGED
|
@@ -7,12 +7,7 @@ import {
|
|
|
7
7
|
|
|
8
8
|
export type EpochCacheConfig = Pick<
|
|
9
9
|
L1ReaderConfig & L1ContractsConfig,
|
|
10
|
-
| '
|
|
11
|
-
| 'l1ChainId'
|
|
12
|
-
| 'viemPollingIntervalMS'
|
|
13
|
-
| 'aztecSlotDuration'
|
|
14
|
-
| 'ethereumSlotDuration'
|
|
15
|
-
| 'aztecEpochDuration'
|
|
10
|
+
'l1RpcUrls' | 'l1ChainId' | 'viemPollingIntervalMS' | 'ethereumSlotDuration'
|
|
16
11
|
>;
|
|
17
12
|
|
|
18
13
|
export function getEpochCacheConfigEnvVars(): EpochCacheConfig {
|
package/src/epoch_cache.ts
CHANGED
|
@@ -82,36 +82,52 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
static async create(
|
|
85
|
-
|
|
85
|
+
rollupOrAddress: EthAddress | RollupContract,
|
|
86
86
|
config?: EpochCacheConfig,
|
|
87
87
|
deps: { dateProvider?: DateProvider } = {},
|
|
88
88
|
) {
|
|
89
89
|
config = config ?? getEpochCacheConfigEnvVars();
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
// Load the rollup contract if we were given an address
|
|
92
|
+
let rollup: RollupContract;
|
|
93
|
+
if ('address' in rollupOrAddress) {
|
|
94
|
+
rollup = rollupOrAddress;
|
|
95
|
+
} else {
|
|
96
|
+
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
97
|
+
const publicClient = createPublicClient({
|
|
98
|
+
chain: chain.chainInfo,
|
|
99
|
+
transport: fallback(config.l1RpcUrls.map(url => http(url))),
|
|
100
|
+
pollingInterval: config.viemPollingIntervalMS,
|
|
101
|
+
});
|
|
102
|
+
rollup = new RollupContract(publicClient, rollupOrAddress.toString());
|
|
103
|
+
}
|
|
97
104
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
const [
|
|
106
|
+
l1StartBlock,
|
|
107
|
+
l1GenesisTime,
|
|
108
|
+
initialValidators,
|
|
109
|
+
sampleSeed,
|
|
110
|
+
epochNumber,
|
|
111
|
+
proofSubmissionEpochs,
|
|
112
|
+
slotDuration,
|
|
113
|
+
epochDuration,
|
|
114
|
+
] = await Promise.all([
|
|
115
|
+
rollup.getL1StartBlock(),
|
|
116
|
+
rollup.getL1GenesisTime(),
|
|
117
|
+
rollup.getCurrentEpochCommittee(),
|
|
118
|
+
rollup.getCurrentSampleSeed(),
|
|
119
|
+
rollup.getCurrentEpochNumber(),
|
|
120
|
+
rollup.getProofSubmissionEpochs(),
|
|
121
|
+
rollup.getSlotDuration(),
|
|
122
|
+
rollup.getEpochDuration(),
|
|
123
|
+
] as const);
|
|
108
124
|
|
|
109
125
|
const l1RollupConstants: L1RollupConstants = {
|
|
110
126
|
l1StartBlock,
|
|
111
127
|
l1GenesisTime,
|
|
112
128
|
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
113
|
-
slotDuration:
|
|
114
|
-
epochDuration:
|
|
129
|
+
slotDuration: Number(slotDuration),
|
|
130
|
+
epochDuration: Number(epochDuration),
|
|
115
131
|
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
116
132
|
};
|
|
117
133
|
|
|
@@ -236,7 +252,7 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
236
252
|
* We return the next proposer's attester address as the node will check if it is the proposer at the next ethereum block,
|
|
237
253
|
* which can be the next slot. If this is the case, then it will send proposals early.
|
|
238
254
|
*/
|
|
239
|
-
async getProposerAttesterAddressInCurrentOrNextSlot(): Promise<{
|
|
255
|
+
public async getProposerAttesterAddressInCurrentOrNextSlot(): Promise<{
|
|
240
256
|
currentSlot: bigint;
|
|
241
257
|
nextSlot: bigint;
|
|
242
258
|
currentProposer: EthAddress | undefined;
|
|
@@ -253,14 +269,23 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
253
269
|
};
|
|
254
270
|
}
|
|
255
271
|
|
|
272
|
+
/**
|
|
273
|
+
* Get the proposer attester address in the gien slot
|
|
274
|
+
* @returns The proposer attester address. If the committee does not exist, we throw a NoCommitteeError.
|
|
275
|
+
* If the committee is empty (i.e. target committee size is 0, and anyone can propose), we return undefined.
|
|
276
|
+
*/
|
|
277
|
+
public getProposerAttesterAddressInSlot(slot: bigint): Promise<EthAddress | undefined> {
|
|
278
|
+
const epochAndSlot = this.getEpochAndSlotAtSlot(slot);
|
|
279
|
+
return this.getProposerAttesterAddressAt(epochAndSlot);
|
|
280
|
+
}
|
|
281
|
+
|
|
256
282
|
/**
|
|
257
283
|
* Get the proposer attester address in the next slot
|
|
258
284
|
* @returns The proposer attester address. If the committee does not exist, we throw a NoCommitteeError.
|
|
259
285
|
* If the committee is empty (i.e. target committee size is 0, and anyone can propose), we return undefined.
|
|
260
286
|
*/
|
|
261
|
-
getProposerAttesterAddressInNextSlot(): Promise<EthAddress | undefined> {
|
|
287
|
+
public getProposerAttesterAddressInNextSlot(): Promise<EthAddress | undefined> {
|
|
262
288
|
const epochAndSlot = this.getEpochAndSlotInNextL1Slot();
|
|
263
|
-
|
|
264
289
|
return this.getProposerAttesterAddressAt(epochAndSlot);
|
|
265
290
|
}
|
|
266
291
|
|