@lodestar/config 1.35.0-dev.ba92bd8a88 → 1.35.0-dev.c0078a16b5

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.
Files changed (55) hide show
  1. package/lib/chainConfig/configs/mainnet.js +0 -10
  2. package/lib/chainConfig/configs/mainnet.js.map +1 -1
  3. package/lib/chainConfig/configs/minimal.js +0 -10
  4. package/lib/chainConfig/configs/minimal.js.map +1 -1
  5. package/lib/chainConfig/types.d.ts +0 -5
  6. package/lib/chainConfig/types.js +0 -5
  7. package/lib/chainConfig/types.js.map +1 -1
  8. package/lib/default.d.ts +1 -1
  9. package/package.json +10 -12
  10. package/lib/beaconConfig.d.ts.map +0 -1
  11. package/lib/chainConfig/configs/mainnet.d.ts.map +0 -1
  12. package/lib/chainConfig/configs/minimal.d.ts.map +0 -1
  13. package/lib/chainConfig/default.d.ts.map +0 -1
  14. package/lib/chainConfig/index.d.ts.map +0 -1
  15. package/lib/chainConfig/json.d.ts.map +0 -1
  16. package/lib/chainConfig/networks/chiado.d.ts.map +0 -1
  17. package/lib/chainConfig/networks/ephemery.d.ts.map +0 -1
  18. package/lib/chainConfig/networks/gnosis.d.ts.map +0 -1
  19. package/lib/chainConfig/networks/holesky.d.ts.map +0 -1
  20. package/lib/chainConfig/networks/hoodi.d.ts.map +0 -1
  21. package/lib/chainConfig/networks/mainnet.d.ts.map +0 -1
  22. package/lib/chainConfig/networks/sepolia.d.ts.map +0 -1
  23. package/lib/chainConfig/types.d.ts.map +0 -1
  24. package/lib/configs.d.ts.map +0 -1
  25. package/lib/default.d.ts.map +0 -1
  26. package/lib/forkConfig/index.d.ts.map +0 -1
  27. package/lib/forkConfig/types.d.ts.map +0 -1
  28. package/lib/genesisConfig/index.d.ts.map +0 -1
  29. package/lib/genesisConfig/types.d.ts.map +0 -1
  30. package/lib/index.d.ts.map +0 -1
  31. package/lib/networks.d.ts.map +0 -1
  32. package/lib/utils/validateBlobSchedule.d.ts.map +0 -1
  33. package/src/beaconConfig.ts +0 -31
  34. package/src/chainConfig/configs/mainnet.ts +0 -158
  35. package/src/chainConfig/configs/minimal.ts +0 -153
  36. package/src/chainConfig/default.ts +0 -19
  37. package/src/chainConfig/index.ts +0 -27
  38. package/src/chainConfig/json.ts +0 -175
  39. package/src/chainConfig/networks/chiado.ts +0 -49
  40. package/src/chainConfig/networks/ephemery.ts +0 -71
  41. package/src/chainConfig/networks/gnosis.ts +0 -74
  42. package/src/chainConfig/networks/holesky.ts +0 -64
  43. package/src/chainConfig/networks/hoodi.ts +0 -64
  44. package/src/chainConfig/networks/mainnet.ts +0 -19
  45. package/src/chainConfig/networks/sepolia.ts +0 -61
  46. package/src/chainConfig/types.ts +0 -252
  47. package/src/configs.ts +0 -4
  48. package/src/default.ts +0 -6
  49. package/src/forkConfig/index.ts +0 -203
  50. package/src/forkConfig/types.ts +0 -59
  51. package/src/genesisConfig/index.ts +0 -180
  52. package/src/genesisConfig/types.ts +0 -29
  53. package/src/index.ts +0 -4
  54. package/src/networks.ts +0 -65
  55. package/src/utils/validateBlobSchedule.ts +0 -32
@@ -1,252 +0,0 @@
1
- import {PresetName} from "@lodestar/params";
2
-
3
- /**
4
- * Run-time chain configuration
5
- */
6
- export type ChainConfig = {
7
- PRESET_BASE: PresetName;
8
- /**
9
- * Free-form short name of the network that this configuration applies to - known
10
- * canonical network names include:
11
- * * 'mainnet' - there can be only one
12
- * * 'holesky' - testnet
13
- * Must match the regex: [a-z0-9\-]
14
- */
15
- CONFIG_NAME: string;
16
-
17
- // Transition
18
- TERMINAL_TOTAL_DIFFICULTY: bigint;
19
- TERMINAL_BLOCK_HASH: Uint8Array;
20
- TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH: number;
21
-
22
- // Genesis
23
- MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: number;
24
- MIN_GENESIS_TIME: number;
25
- GENESIS_FORK_VERSION: Uint8Array;
26
- GENESIS_DELAY: number;
27
-
28
- // Forking
29
- // Altair
30
- ALTAIR_FORK_VERSION: Uint8Array;
31
- ALTAIR_FORK_EPOCH: number;
32
- // Bellatrix
33
- BELLATRIX_FORK_VERSION: Uint8Array;
34
- BELLATRIX_FORK_EPOCH: number;
35
- // Capella
36
- CAPELLA_FORK_VERSION: Uint8Array;
37
- CAPELLA_FORK_EPOCH: number;
38
- // DENEB
39
- DENEB_FORK_VERSION: Uint8Array;
40
- DENEB_FORK_EPOCH: number;
41
- // ELECTRA
42
- ELECTRA_FORK_VERSION: Uint8Array;
43
- ELECTRA_FORK_EPOCH: number;
44
- // FULU
45
- FULU_FORK_VERSION: Uint8Array;
46
- FULU_FORK_EPOCH: number;
47
- // GLOAS
48
- GLOAS_FORK_VERSION: Uint8Array;
49
- GLOAS_FORK_EPOCH: number;
50
-
51
- // Time parameters
52
- SECONDS_PER_SLOT: number;
53
- SECONDS_PER_ETH1_BLOCK: number;
54
- MIN_VALIDATOR_WITHDRAWABILITY_DELAY: number;
55
- SHARD_COMMITTEE_PERIOD: number;
56
- ETH1_FOLLOW_DISTANCE: number;
57
-
58
- ATTESTATION_DUE_BPS_GLOAS: number;
59
- AGGREGATE_DUE_BPS_GLOAS: number;
60
- SYNC_MESSAGE_DUE_BPS_GLOAS: number;
61
- CONTRIBUTION_DUE_BPS_GLOAS: number;
62
- PAYLOAD_ATTESTATION_DUE_BPS: number;
63
-
64
- // Validator cycle
65
- INACTIVITY_SCORE_BIAS: number;
66
- INACTIVITY_SCORE_RECOVERY_RATE: number;
67
- EJECTION_BALANCE: number;
68
- MIN_PER_EPOCH_CHURN_LIMIT: number;
69
- MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: number;
70
- CHURN_LIMIT_QUOTIENT: number;
71
- MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: number;
72
- MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: number;
73
-
74
- // Fork choice
75
- PROPOSER_SCORE_BOOST: number;
76
- REORG_HEAD_WEIGHT_THRESHOLD: number;
77
- REORG_PARENT_WEIGHT_THRESHOLD: number;
78
- REORG_MAX_EPOCHS_SINCE_FINALIZATION: number;
79
-
80
- // Deposit contract
81
- DEPOSIT_CHAIN_ID: number;
82
- DEPOSIT_NETWORK_ID: number;
83
- DEPOSIT_CONTRACT_ADDRESS: Uint8Array;
84
-
85
- // Networking
86
- MAX_REQUEST_BLOCKS: number;
87
- MAX_REQUEST_BLOCKS_DENEB: number;
88
- MIN_EPOCHS_FOR_BLOCK_REQUESTS: number;
89
- MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: number;
90
- MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS: number;
91
- BLOB_SIDECAR_SUBNET_COUNT: number;
92
- MAX_BLOBS_PER_BLOCK: number;
93
- MAX_REQUEST_BLOB_SIDECARS: number;
94
- BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: number;
95
- DATA_COLUMN_SIDECAR_SUBNET_COUNT: number;
96
- MAX_BLOBS_PER_BLOCK_ELECTRA: number;
97
- MAX_REQUEST_BLOB_SIDECARS_ELECTRA: number;
98
- MAX_REQUEST_DATA_COLUMN_SIDECARS: number;
99
-
100
- // Fulu
101
- NUMBER_OF_CUSTODY_GROUPS: number;
102
- SAMPLES_PER_SLOT: number;
103
- CUSTODY_REQUIREMENT: number;
104
- VALIDATOR_CUSTODY_REQUIREMENT: number;
105
- BALANCE_PER_ADDITIONAL_CUSTODY_GROUP: number;
106
-
107
- // Blob Scheduling
108
- BLOB_SCHEDULE: BlobSchedule;
109
- };
110
-
111
- export const chainConfigTypes: SpecTypes<ChainConfig> = {
112
- PRESET_BASE: "string",
113
- CONFIG_NAME: "string",
114
-
115
- // Transition
116
- TERMINAL_TOTAL_DIFFICULTY: "bigint",
117
- TERMINAL_BLOCK_HASH: "bytes",
118
- TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH: "number",
119
-
120
- // Genesis
121
- MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: "number",
122
- MIN_GENESIS_TIME: "number",
123
- GENESIS_FORK_VERSION: "bytes",
124
- GENESIS_DELAY: "number",
125
-
126
- // Forking
127
- // Altair
128
- ALTAIR_FORK_VERSION: "bytes",
129
- ALTAIR_FORK_EPOCH: "number",
130
- // Bellatrix
131
- BELLATRIX_FORK_VERSION: "bytes",
132
- BELLATRIX_FORK_EPOCH: "number",
133
- // Capella
134
- CAPELLA_FORK_VERSION: "bytes",
135
- CAPELLA_FORK_EPOCH: "number",
136
- // DENEB
137
- DENEB_FORK_VERSION: "bytes",
138
- DENEB_FORK_EPOCH: "number",
139
- // ELECTRA
140
- ELECTRA_FORK_VERSION: "bytes",
141
- ELECTRA_FORK_EPOCH: "number",
142
- // FULU
143
- FULU_FORK_VERSION: "bytes",
144
- FULU_FORK_EPOCH: "number",
145
- // GLOAS
146
- GLOAS_FORK_VERSION: "bytes",
147
- GLOAS_FORK_EPOCH: "number",
148
-
149
- // Time parameters
150
- SECONDS_PER_SLOT: "number",
151
- SECONDS_PER_ETH1_BLOCK: "number",
152
- MIN_VALIDATOR_WITHDRAWABILITY_DELAY: "number",
153
- SHARD_COMMITTEE_PERIOD: "number",
154
- ETH1_FOLLOW_DISTANCE: "number",
155
-
156
- ATTESTATION_DUE_BPS_GLOAS: "number",
157
- AGGREGATE_DUE_BPS_GLOAS: "number",
158
- SYNC_MESSAGE_DUE_BPS_GLOAS: "number",
159
- CONTRIBUTION_DUE_BPS_GLOAS: "number",
160
- PAYLOAD_ATTESTATION_DUE_BPS: "number",
161
-
162
- // Validator cycle
163
- INACTIVITY_SCORE_BIAS: "number",
164
- INACTIVITY_SCORE_RECOVERY_RATE: "number",
165
- EJECTION_BALANCE: "number",
166
- MIN_PER_EPOCH_CHURN_LIMIT: "number",
167
- MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: "number",
168
- CHURN_LIMIT_QUOTIENT: "number",
169
- MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: "number",
170
- MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: "number",
171
-
172
- // Fork choice
173
- PROPOSER_SCORE_BOOST: "number",
174
- REORG_HEAD_WEIGHT_THRESHOLD: "number",
175
- REORG_PARENT_WEIGHT_THRESHOLD: "number",
176
- REORG_MAX_EPOCHS_SINCE_FINALIZATION: "number",
177
-
178
- // Deposit contract
179
- DEPOSIT_CHAIN_ID: "number",
180
- DEPOSIT_NETWORK_ID: "number",
181
- DEPOSIT_CONTRACT_ADDRESS: "bytes",
182
-
183
- // Networking
184
- MAX_REQUEST_BLOCKS: "number",
185
- MAX_REQUEST_BLOCKS_DENEB: "number",
186
- MIN_EPOCHS_FOR_BLOCK_REQUESTS: "number",
187
- MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: "number",
188
- MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS: "number",
189
- BLOB_SIDECAR_SUBNET_COUNT: "number",
190
- DATA_COLUMN_SIDECAR_SUBNET_COUNT: "number",
191
- MAX_BLOBS_PER_BLOCK: "number",
192
- MAX_REQUEST_BLOB_SIDECARS: "number",
193
- BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: "number",
194
- MAX_BLOBS_PER_BLOCK_ELECTRA: "number",
195
- MAX_REQUEST_BLOB_SIDECARS_ELECTRA: "number",
196
- MAX_REQUEST_DATA_COLUMN_SIDECARS: "number",
197
-
198
- // Fulu
199
- NUMBER_OF_CUSTODY_GROUPS: "number",
200
- SAMPLES_PER_SLOT: "number",
201
- CUSTODY_REQUIREMENT: "number",
202
- VALIDATOR_CUSTODY_REQUIREMENT: "number",
203
- BALANCE_PER_ADDITIONAL_CUSTODY_GROUP: "number",
204
-
205
- // Blob Scheduling
206
- BLOB_SCHEDULE: "blob_schedule",
207
- };
208
-
209
- export type BlobScheduleEntry = {
210
- EPOCH: number;
211
- MAX_BLOBS_PER_BLOCK: number;
212
- };
213
-
214
- export type BlobSchedule = BlobScheduleEntry[];
215
-
216
- export function isBlobSchedule(value: unknown): value is BlobSchedule {
217
- return (
218
- Array.isArray(value) &&
219
- value.every(
220
- (entry) =>
221
- typeof entry === "object" &&
222
- entry !== null &&
223
- typeof entry.EPOCH === "number" &&
224
- typeof entry.MAX_BLOBS_PER_BLOCK === "number"
225
- )
226
- );
227
- }
228
-
229
- /** Allows values in a Spec file */
230
- export type SpecValue = number | bigint | Uint8Array | string | BlobSchedule;
231
-
232
- /** Type value name of each spec field. Numbers are ignored since they are the most common */
233
- export type SpecValueType<V extends SpecValue> = V extends number
234
- ? "number"
235
- : V extends bigint
236
- ? "bigint"
237
- : V extends Uint8Array
238
- ? "bytes"
239
- : V extends string
240
- ? "string"
241
- : V extends BlobSchedule
242
- ? "blob_schedule"
243
- : never;
244
-
245
- /** All possible type names for a SpecValue */
246
- export type SpecValueTypeName = SpecValueType<SpecValue>;
247
-
248
- export type SpecTypes<Spec extends Record<string, SpecValue>> = {
249
- [K in keyof Spec]: SpecValueType<Spec[K]>;
250
- };
251
-
252
- export type SpecJson = Record<string, string | Record<string, string>[]>;
package/src/configs.ts DELETED
@@ -1,4 +0,0 @@
1
- import {chainConfig as mainnetChainConfig} from "./chainConfig/configs/mainnet.js";
2
- import {chainConfig as minimalChainConfig} from "./chainConfig/configs/minimal.js";
3
-
4
- export {mainnetChainConfig, minimalChainConfig};
package/src/default.ts DELETED
@@ -1,6 +0,0 @@
1
- import {createChainForkConfig} from "./beaconConfig.js";
2
- import {defaultChainConfig} from "./chainConfig/index.js";
3
-
4
- export const chainConfig = defaultChainConfig;
5
- // for testing purpose only
6
- export const config = createChainForkConfig(defaultChainConfig);
@@ -1,203 +0,0 @@
1
- import {
2
- ForkAll,
3
- ForkName,
4
- ForkPostAltair,
5
- ForkPostBellatrix,
6
- ForkPostDeneb,
7
- ForkSeq,
8
- GENESIS_EPOCH,
9
- SLOTS_PER_EPOCH,
10
- isForkPostAltair,
11
- isForkPostBellatrix,
12
- isForkPostDeneb,
13
- } from "@lodestar/params";
14
- import {Epoch, SSZTypesFor, Slot, Version, sszTypesFor} from "@lodestar/types";
15
- import {ChainConfig} from "../chainConfig/index.js";
16
- import {BlobParameters, ForkBoundary, ForkConfig, ForkInfo} from "./types.js";
17
-
18
- export * from "./types.js";
19
-
20
- export function createForkConfig(config: ChainConfig): ForkConfig {
21
- const phase0: ForkInfo = {
22
- name: ForkName.phase0,
23
- seq: ForkSeq.phase0,
24
- epoch: GENESIS_EPOCH,
25
- version: config.GENESIS_FORK_VERSION,
26
- // Will never be used
27
- prevVersion: config.GENESIS_FORK_VERSION,
28
- prevForkName: ForkName.phase0,
29
- };
30
- const altair: ForkInfo = {
31
- name: ForkName.altair,
32
- seq: ForkSeq.altair,
33
- epoch: config.ALTAIR_FORK_EPOCH,
34
- version: config.ALTAIR_FORK_VERSION,
35
- prevVersion: config.GENESIS_FORK_VERSION,
36
- prevForkName: ForkName.phase0,
37
- };
38
- const bellatrix: ForkInfo = {
39
- name: ForkName.bellatrix,
40
- seq: ForkSeq.bellatrix,
41
- epoch: config.BELLATRIX_FORK_EPOCH,
42
- version: config.BELLATRIX_FORK_VERSION,
43
- prevVersion: config.ALTAIR_FORK_VERSION,
44
- prevForkName: ForkName.altair,
45
- };
46
- const capella: ForkInfo = {
47
- name: ForkName.capella,
48
- seq: ForkSeq.capella,
49
- epoch: config.CAPELLA_FORK_EPOCH,
50
- version: config.CAPELLA_FORK_VERSION,
51
- prevVersion: config.BELLATRIX_FORK_VERSION,
52
- prevForkName: ForkName.bellatrix,
53
- };
54
- const deneb: ForkInfo = {
55
- name: ForkName.deneb,
56
- seq: ForkSeq.deneb,
57
- epoch: config.DENEB_FORK_EPOCH,
58
- version: config.DENEB_FORK_VERSION,
59
- prevVersion: config.CAPELLA_FORK_VERSION,
60
- prevForkName: ForkName.capella,
61
- };
62
- const electra: ForkInfo = {
63
- name: ForkName.electra,
64
- seq: ForkSeq.electra,
65
- epoch: config.ELECTRA_FORK_EPOCH,
66
- version: config.ELECTRA_FORK_VERSION,
67
- prevVersion: config.DENEB_FORK_VERSION,
68
- prevForkName: ForkName.deneb,
69
- };
70
- const fulu: ForkInfo = {
71
- name: ForkName.fulu,
72
- seq: ForkSeq.fulu,
73
- epoch: config.FULU_FORK_EPOCH,
74
- version: config.FULU_FORK_VERSION,
75
- prevVersion: config.ELECTRA_FORK_VERSION,
76
- prevForkName: ForkName.electra,
77
- };
78
- const gloas: ForkInfo = {
79
- name: ForkName.gloas,
80
- seq: ForkSeq.gloas,
81
- epoch: config.GLOAS_FORK_EPOCH,
82
- version: config.GLOAS_FORK_VERSION,
83
- prevVersion: config.FULU_FORK_VERSION,
84
- prevForkName: ForkName.fulu,
85
- };
86
-
87
- /** Forks in order order of occurence, `phase0` first */
88
- // Note: Downstream code relies on proper ordering.
89
- const forks = {phase0, altair, bellatrix, capella, deneb, electra, fulu, gloas};
90
-
91
- // Prevents allocating an array on every getForkInfo() call
92
- const forksAscendingEpochOrder = Object.values(forks);
93
- const forksDescendingEpochOrder = Object.values(forks).reverse();
94
-
95
- const blobScheduleDescendingEpochOrder = [...config.BLOB_SCHEDULE].sort((a, b) => b.EPOCH - a.EPOCH);
96
-
97
- const forkBoundariesAscendingEpochOrder: ForkBoundary[] = [
98
- // Normal hard-forks (phase0, altair, etc.)
99
- ...forksAscendingEpochOrder.map((fork) => ({
100
- fork: fork.name,
101
- epoch: fork.epoch,
102
- })),
103
- // Blob Parameter Only (BPO) forks
104
- // Note: Must be appended after normal hard-forks to have precedence if scheduled at the same epoch
105
- ...config.BLOB_SCHEDULE.map((entry) => ({
106
- fork: forksDescendingEpochOrder.find((f) => entry.EPOCH >= f.epoch)?.name ?? phase0.name,
107
- epoch: entry.EPOCH,
108
- })),
109
- ]
110
- // Remove unscheduled fork boundaries
111
- .filter(({epoch}) => epoch !== Infinity)
112
- // Sort by epoch in ascending order
113
- .sort((a, b) => a.epoch - b.epoch);
114
-
115
- const forkBoundariesDescendingEpochOrder = [...forkBoundariesAscendingEpochOrder].reverse();
116
-
117
- return {
118
- forks,
119
- forksAscendingEpochOrder,
120
- forksDescendingEpochOrder,
121
- forkBoundariesAscendingEpochOrder,
122
- forkBoundariesDescendingEpochOrder,
123
-
124
- // Fork convenience methods
125
- getForkInfo(slot: Slot): ForkInfo {
126
- const epoch = Math.floor(Math.max(slot, 0) / SLOTS_PER_EPOCH);
127
- return this.getForkInfoAtEpoch(epoch);
128
- },
129
- getForkInfoAtEpoch(epoch: Epoch): ForkInfo {
130
- return forks[this.getForkBoundaryAtEpoch(epoch).fork];
131
- },
132
- getForkBoundaryAtEpoch(epoch: Epoch): ForkBoundary {
133
- if (epoch < 0) epoch = 0;
134
- // NOTE: fork boundaries must be sorted by descending epoch, latest first
135
- for (const boundary of forkBoundariesDescendingEpochOrder) {
136
- if (epoch >= boundary.epoch) return boundary;
137
- }
138
- throw Error("Unreachable as phase0 is scheduled at epoch 0");
139
- },
140
- getForkName(slot: Slot): ForkName {
141
- return this.getForkInfo(slot).name;
142
- },
143
- getForkSeq(slot: Slot): ForkSeq {
144
- return this.getForkInfo(slot).seq;
145
- },
146
- getForkSeqAtEpoch(epoch: Epoch): ForkSeq {
147
- return this.getForkInfoAtEpoch(epoch).seq;
148
- },
149
- getForkVersion(slot: Slot): Version {
150
- return this.getForkInfo(slot).version;
151
- },
152
- getForkTypes<F extends ForkName = ForkAll>(slot: Slot): SSZTypesFor<F> {
153
- return sszTypesFor(this.getForkName(slot)) as SSZTypesFor<F>;
154
- },
155
- getPostBellatrixForkTypes(slot: Slot): SSZTypesFor<ForkPostBellatrix> {
156
- const forkName = this.getForkName(slot);
157
- if (!isForkPostBellatrix(forkName)) {
158
- throw Error(`Invalid slot=${slot} fork=${forkName} for post-bellatrix fork types`);
159
- }
160
- return sszTypesFor(forkName);
161
- },
162
- getPostAltairForkTypes(slot: Slot): SSZTypesFor<ForkPostAltair> {
163
- const forkName = this.getForkName(slot);
164
- if (!isForkPostAltair(forkName)) {
165
- throw Error(`Invalid slot=${slot} fork=${forkName} for post-altair fork types`);
166
- }
167
- return sszTypesFor(forkName);
168
- },
169
- getPostDenebForkTypes(slot: Slot): SSZTypesFor<ForkPostDeneb> {
170
- const forkName = this.getForkName(slot);
171
- if (!isForkPostDeneb(forkName)) {
172
- throw Error(`Invalid slot=${slot} fork=${forkName} for post-deneb fork types`);
173
- }
174
- return sszTypesFor(forkName);
175
- },
176
- getMaxBlobsPerBlock(epoch: Epoch): number {
177
- const fork = this.getForkInfoAtEpoch(epoch).name;
178
-
179
- switch (fork) {
180
- case ForkName.electra:
181
- return config.MAX_BLOBS_PER_BLOCK_ELECTRA;
182
- case ForkName.deneb:
183
- return config.MAX_BLOBS_PER_BLOCK;
184
- }
185
-
186
- return this.getBlobParameters(epoch).maxBlobsPerBlock;
187
- },
188
- getBlobParameters(epoch: Epoch): BlobParameters {
189
- if (epoch < config.FULU_FORK_EPOCH) {
190
- throw Error(`getBlobParameters is not available pre-fulu epoch=${epoch}`);
191
- }
192
-
193
- // Find the latest applicable value from blob schedule
194
- for (const entry of blobScheduleDescendingEpochOrder) {
195
- if (epoch >= entry.EPOCH) {
196
- return {epoch: entry.EPOCH, maxBlobsPerBlock: entry.MAX_BLOBS_PER_BLOCK};
197
- }
198
- }
199
-
200
- return {epoch: config.ELECTRA_FORK_EPOCH, maxBlobsPerBlock: config.MAX_BLOBS_PER_BLOCK_ELECTRA};
201
- },
202
- };
203
- }
@@ -1,59 +0,0 @@
1
- import {ForkAll, ForkName, ForkPostAltair, ForkPostBellatrix, ForkPostDeneb, ForkSeq} from "@lodestar/params";
2
- import {Epoch, SSZTypesFor, Slot, UintNum64, Version} from "@lodestar/types";
3
-
4
- export type ForkInfo = {
5
- name: ForkName;
6
- seq: ForkSeq;
7
- epoch: Epoch;
8
- version: Version;
9
- prevVersion: Version;
10
- prevForkName: ForkName;
11
- };
12
-
13
- /**
14
- * Fork boundaries include both normal hard-forks (phase0, altair, etc.)
15
- * and Blob Parameter Only (BPO) forks and are used to un-/subscribe to gossip topics
16
- * and compute the fork digest primarily for domain separation on the p2p layer.
17
- */
18
- export type ForkBoundary = {fork: ForkName; epoch: Epoch};
19
-
20
- export type BlobParameters = {epoch: Epoch; maxBlobsPerBlock: UintNum64};
21
-
22
- /**
23
- * Fork schedule and helper methods
24
- */
25
- export type ForkConfig = {
26
- /** Forks in order order of occurence, `phase0` first */
27
- forks: {[K in ForkName]: ForkInfo};
28
- forksAscendingEpochOrder: ForkInfo[];
29
- forksDescendingEpochOrder: ForkInfo[];
30
- forkBoundariesAscendingEpochOrder: ForkBoundary[];
31
- forkBoundariesDescendingEpochOrder: ForkBoundary[];
32
-
33
- /** Get the hard-fork info for the active fork at `slot` */
34
- getForkInfo(slot: Slot): ForkInfo;
35
- /** Get the hard-fork info for the active fork at `epoch` */
36
- getForkInfoAtEpoch(epoch: Epoch): ForkInfo;
37
- /** Get the active fork boundary at a given `epoch` */
38
- getForkBoundaryAtEpoch(epoch: Epoch): ForkBoundary;
39
- /** Get the hard-fork name at a given slot */
40
- getForkName(slot: Slot): ForkName;
41
- /** Get the hard-fork sequence number at a given slot */
42
- getForkSeq(slot: Slot): ForkSeq;
43
- /** Get the hard-fork sequence number at a given epoch */
44
- getForkSeqAtEpoch(epoch: Epoch): ForkSeq;
45
- /** Get the hard-fork version at a given slot */
46
- getForkVersion(slot: Slot): Version;
47
- /** Get SSZ types by hard-fork */
48
- getForkTypes<F extends ForkName = ForkAll>(slot: Slot): SSZTypesFor<F>;
49
- /** Get post-altair SSZ types by hard-fork*/
50
- getPostAltairForkTypes(slot: Slot): SSZTypesFor<ForkPostAltair>;
51
- /** Get post-bellatrix SSZ types by hard-fork*/
52
- getPostBellatrixForkTypes(slot: Slot): SSZTypesFor<ForkPostBellatrix>;
53
- /** Get post-deneb SSZ types by hard-fork*/
54
- getPostDenebForkTypes(slot: Slot): SSZTypesFor<ForkPostDeneb>;
55
- /** Get max blobs per block at a given epoch */
56
- getMaxBlobsPerBlock(epoch: Epoch): number;
57
- /** Get blob parameters at a given epoch */
58
- getBlobParameters(epoch: Epoch): BlobParameters;
59
- };