@aztec/epoch-cache 1.0.0-nightly.20250605 → 1.0.0-nightly.20250607
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 +1 -1
- package/dest/epoch_cache.d.ts.map +1 -1
- package/dest/epoch_cache.js +8 -7
- package/package.json +5 -5
- package/src/epoch_cache.ts +8 -6
package/dest/epoch_cache.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare class EpochCache implements EpochCacheInterface {
|
|
|
52
52
|
getEpochAndSlotNow(): EpochAndSlot;
|
|
53
53
|
private nowInSeconds;
|
|
54
54
|
private getEpochAndSlotAtSlot;
|
|
55
|
-
|
|
55
|
+
getEpochAndSlotInNextL1Slot(): EpochAndSlot;
|
|
56
56
|
private getEpochAndSlotAtTimestamp;
|
|
57
57
|
getCommitteeForEpoch(epoch: bigint): Promise<EpochCommitteeInfo>;
|
|
58
58
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epoch_cache.d.ts","sourceRoot":"","sources":["../src/epoch_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAEL,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"epoch_cache.d.ts","sourceRoot":"","sources":["../src/epoch_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,iBAAiB,CAAC;AACtE,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,MAA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OAAO,CAAC,OAAO,CAAC;IAKtD,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAKzE"}
|
package/dest/epoch_cache.js
CHANGED
|
@@ -2,7 +2,7 @@ import { RollupContract, createEthereumChain } from '@aztec/ethereum';
|
|
|
2
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
-
import { EmptyL1RollupConstants, getEpochAtSlot, getEpochNumberAtTimestamp, getSlotAtTimestamp, getSlotRangeForEpoch, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
5
|
+
import { EmptyL1RollupConstants, getEpochAtSlot, getEpochNumberAtTimestamp, getSlotAtTimestamp, getSlotRangeForEpoch, getTimestampForSlot, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
6
6
|
import { createPublicClient, encodeAbiParameters, fallback, http, keccak256 } from 'viem';
|
|
7
7
|
import { getEpochCacheConfigEnvVars } from './config.js';
|
|
8
8
|
/**
|
|
@@ -85,15 +85,16 @@ import { getEpochCacheConfigEnvVars } from './config.js';
|
|
|
85
85
|
slot
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
getEpochAndSlotInNextL1Slot() {
|
|
89
89
|
const nextSlotTs = this.nowInSeconds() + BigInt(this.l1constants.ethereumSlotDuration);
|
|
90
90
|
return this.getEpochAndSlotAtTimestamp(nextSlotTs);
|
|
91
91
|
}
|
|
92
92
|
getEpochAndSlotAtTimestamp(ts) {
|
|
93
|
+
const slot = getSlotAtTimestamp(ts, this.l1constants);
|
|
93
94
|
return {
|
|
94
95
|
epoch: getEpochNumberAtTimestamp(ts, this.l1constants),
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
ts: getTimestampForSlot(slot, this.l1constants),
|
|
97
|
+
slot
|
|
97
98
|
};
|
|
98
99
|
}
|
|
99
100
|
getCommitteeForEpoch(epoch) {
|
|
@@ -126,7 +127,7 @@ import { getEpochCacheConfigEnvVars } from './config.js';
|
|
|
126
127
|
if (slot === 'now') {
|
|
127
128
|
return this.getEpochAndSlotNow();
|
|
128
129
|
} else if (slot === 'next') {
|
|
129
|
-
return this.
|
|
130
|
+
return this.getEpochAndSlotInNextL1Slot();
|
|
130
131
|
} else {
|
|
131
132
|
return this.getEpochAndSlotAtSlot(slot);
|
|
132
133
|
}
|
|
@@ -180,7 +181,7 @@ import { getEpochCacheConfigEnvVars } from './config.js';
|
|
|
180
181
|
* which can be the next slot. If this is the case, then it will send proposals early.
|
|
181
182
|
*/ async getProposerAttesterAddressInCurrentOrNextSlot() {
|
|
182
183
|
const current = this.getEpochAndSlotNow();
|
|
183
|
-
const next = this.
|
|
184
|
+
const next = this.getEpochAndSlotInNextL1Slot();
|
|
184
185
|
return {
|
|
185
186
|
currentProposer: await this.getProposerAttesterAddressAt(current),
|
|
186
187
|
nextProposer: await this.getProposerAttesterAddressAt(next),
|
|
@@ -189,7 +190,7 @@ import { getEpochCacheConfigEnvVars } from './config.js';
|
|
|
189
190
|
};
|
|
190
191
|
}
|
|
191
192
|
getProposerAttesterAddressInNextSlot() {
|
|
192
|
-
const epochAndSlot = this.
|
|
193
|
+
const epochAndSlot = this.getEpochAndSlotInNextL1Slot();
|
|
193
194
|
return this.getProposerAttesterAddressAt(epochAndSlot);
|
|
194
195
|
}
|
|
195
196
|
async getProposerAttesterAddressAt(when) {
|
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.20250607",
|
|
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.20250607",
|
|
30
|
+
"@aztec/foundation": "1.0.0-nightly.20250607",
|
|
31
|
+
"@aztec/l1-artifacts": "1.0.0-nightly.20250607",
|
|
32
|
+
"@aztec/stdlib": "1.0.0-nightly.20250607",
|
|
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
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
getEpochNumberAtTimestamp,
|
|
10
10
|
getSlotAtTimestamp,
|
|
11
11
|
getSlotRangeForEpoch,
|
|
12
|
+
getTimestampForSlot,
|
|
12
13
|
getTimestampRangeForEpoch,
|
|
13
14
|
} from '@aztec/stdlib/epoch-helpers';
|
|
14
15
|
|
|
@@ -133,16 +134,17 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
133
134
|
return { epoch, ts, slot };
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
public
|
|
137
|
+
public getEpochAndSlotInNextL1Slot(): EpochAndSlot {
|
|
137
138
|
const nextSlotTs = this.nowInSeconds() + BigInt(this.l1constants.ethereumSlotDuration);
|
|
138
139
|
return this.getEpochAndSlotAtTimestamp(nextSlotTs);
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
private getEpochAndSlotAtTimestamp(ts: bigint): EpochAndSlot {
|
|
143
|
+
const slot = getSlotAtTimestamp(ts, this.l1constants);
|
|
142
144
|
return {
|
|
143
145
|
epoch: getEpochNumberAtTimestamp(ts, this.l1constants),
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
ts: getTimestampForSlot(slot, this.l1constants),
|
|
147
|
+
slot,
|
|
146
148
|
};
|
|
147
149
|
}
|
|
148
150
|
|
|
@@ -182,7 +184,7 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
182
184
|
if (slot === 'now') {
|
|
183
185
|
return this.getEpochAndSlotNow();
|
|
184
186
|
} else if (slot === 'next') {
|
|
185
|
-
return this.
|
|
187
|
+
return this.getEpochAndSlotInNextL1Slot();
|
|
186
188
|
} else {
|
|
187
189
|
return this.getEpochAndSlotAtSlot(slot);
|
|
188
190
|
}
|
|
@@ -230,7 +232,7 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
230
232
|
nextProposer: EthAddress;
|
|
231
233
|
}> {
|
|
232
234
|
const current = this.getEpochAndSlotNow();
|
|
233
|
-
const next = this.
|
|
235
|
+
const next = this.getEpochAndSlotInNextL1Slot();
|
|
234
236
|
|
|
235
237
|
return {
|
|
236
238
|
currentProposer: await this.getProposerAttesterAddressAt(current),
|
|
@@ -241,7 +243,7 @@ export class EpochCache implements EpochCacheInterface {
|
|
|
241
243
|
}
|
|
242
244
|
|
|
243
245
|
getProposerAttesterAddressInNextSlot(): Promise<EthAddress> {
|
|
244
|
-
const epochAndSlot = this.
|
|
246
|
+
const epochAndSlot = this.getEpochAndSlotInNextL1Slot();
|
|
245
247
|
|
|
246
248
|
return this.getProposerAttesterAddressAt(epochAndSlot);
|
|
247
249
|
}
|