Skip to content

Commit 71a48f7

Browse files
authored
Merge pull request #533 from ethpandaops/pk910/show-full-bpo-schedule
show full bpo schedule from EL config when available
2 parents 7fdfc67 + 6f6d02e commit 71a48f7

File tree

2 files changed

+61
-18
lines changed

2 files changed

+61
-18
lines changed

clients/execution/chainstate.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ func (cache *ChainState) getBlobScheduleForTimestampFromConfig(timestamp time.Ti
223223
type BlobScheduleEntry struct {
224224
Timestamp time.Time
225225
Schedule rpc.EthConfigBlobSchedule
226+
IsBpo bool
226227
}
227228

228229
func (cache *ChainState) GetFullBlobSchedule() []BlobScheduleEntry {
@@ -273,6 +274,7 @@ func (cache *ChainState) GetFullBlobSchedule() []BlobScheduleEntry {
273274
Target: uint64(cache.config.Config.BlobScheduleConfig.BPO1.Target),
274275
BaseFeeUpdateFraction: uint64(cache.config.Config.BlobScheduleConfig.BPO1.UpdateFraction),
275276
},
277+
IsBpo: true,
276278
})
277279
}
278280

@@ -284,6 +286,7 @@ func (cache *ChainState) GetFullBlobSchedule() []BlobScheduleEntry {
284286
Target: uint64(cache.config.Config.BlobScheduleConfig.BPO2.Target),
285287
BaseFeeUpdateFraction: uint64(cache.config.Config.BlobScheduleConfig.BPO2.UpdateFraction),
286288
},
289+
IsBpo: true,
287290
})
288291
}
289292

@@ -295,6 +298,7 @@ func (cache *ChainState) GetFullBlobSchedule() []BlobScheduleEntry {
295298
Target: uint64(cache.config.Config.BlobScheduleConfig.BPO3.Target),
296299
BaseFeeUpdateFraction: uint64(cache.config.Config.BlobScheduleConfig.BPO3.UpdateFraction),
297300
},
301+
IsBpo: true,
298302
})
299303
}
300304

@@ -306,6 +310,7 @@ func (cache *ChainState) GetFullBlobSchedule() []BlobScheduleEntry {
306310
Target: uint64(cache.config.Config.BlobScheduleConfig.BPO4.Target),
307311
BaseFeeUpdateFraction: uint64(cache.config.Config.BlobScheduleConfig.BPO4.UpdateFraction),
308312
},
313+
IsBpo: true,
309314
})
310315
}
311316

@@ -317,6 +322,7 @@ func (cache *ChainState) GetFullBlobSchedule() []BlobScheduleEntry {
317322
Target: uint64(cache.config.Config.BlobScheduleConfig.BPO5.Target),
318323
BaseFeeUpdateFraction: uint64(cache.config.Config.BlobScheduleConfig.BPO5.UpdateFraction),
319324
},
325+
IsBpo: true,
320326
})
321327
}
322328

handlers/index.go

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -291,25 +291,62 @@ func buildIndexPageData() (*models.IndexPageData, time.Duration) {
291291
}
292292

293293
// Add BPO forks from BLOB_SCHEDULE
294-
for i, blobSchedule := range specs.BlobSchedule {
295-
// BPO forks use the fork version that's active at the time of BPO activation
296-
forkVersion := chainState.GetForkVersionAtEpoch(phase0.Epoch(blobSchedule.Epoch))
297-
blobParams := &consensus.BlobScheduleEntry{
298-
Epoch: blobSchedule.Epoch,
299-
MaxBlobsPerBlock: blobSchedule.MaxBlobsPerBlock,
300-
}
301-
forkDigest := chainState.GetForkDigest(forkVersion, blobParams)
294+
elBlobSchedule := services.GlobalBeaconService.GetExecutionChainState().GetFullBlobSchedule()
295+
if len(elBlobSchedule) > 0 {
296+
// get blob schedule from el config (we have the full blob schedule available)
297+
bpoIdx := 0
298+
for _, blobSchedule := range elBlobSchedule {
299+
if !blobSchedule.IsBpo {
300+
continue
301+
}
302302

303-
pageData.NetworkForks = append(pageData.NetworkForks, &models.IndexPageDataForks{
304-
Name: fmt.Sprintf("BPO%d", i+1),
305-
Epoch: blobSchedule.Epoch,
306-
Version: nil, // BPO forks don't have fork versions
307-
Time: uint64(chainState.EpochToTime(phase0.Epoch(blobSchedule.Epoch)).Unix()),
308-
Active: uint64(currentEpoch) >= blobSchedule.Epoch,
309-
Type: "bpo",
310-
MaxBlobsPerBlock: &blobSchedule.MaxBlobsPerBlock,
311-
ForkDigest: forkDigest[:],
312-
})
303+
bpoIdx++
304+
305+
bpoEpoch := phase0.Epoch(0)
306+
if blobSchedule.Timestamp.After(networkGenesis.GenesisTime) {
307+
bpoEpoch = chainState.EpochOfSlot(chainState.TimeToSlot(blobSchedule.Timestamp))
308+
}
309+
310+
forkVersion := chainState.GetForkVersionAtEpoch(bpoEpoch)
311+
blobParams := &consensus.BlobScheduleEntry{
312+
Epoch: uint64(bpoEpoch),
313+
MaxBlobsPerBlock: blobSchedule.Schedule.Max,
314+
}
315+
forkDigest := chainState.GetForkDigest(forkVersion, blobParams)
316+
317+
pageData.NetworkForks = append(pageData.NetworkForks, &models.IndexPageDataForks{
318+
Name: fmt.Sprintf("BPO%d", bpoIdx),
319+
Epoch: uint64(bpoEpoch),
320+
Version: nil,
321+
Time: uint64(blobSchedule.Timestamp.Unix()),
322+
Active: currentEpoch >= bpoEpoch,
323+
Type: "bpo",
324+
MaxBlobsPerBlock: &blobSchedule.Schedule.Max,
325+
ForkDigest: forkDigest[:],
326+
})
327+
}
328+
} else {
329+
// get blob schedule from cl specs (no el config available, so we only get the deduplicated blob schedule from the cl specs)
330+
for i, blobSchedule := range specs.BlobSchedule {
331+
// BPO forks use the fork version that's active at the time of BPO activation
332+
forkVersion := chainState.GetForkVersionAtEpoch(phase0.Epoch(blobSchedule.Epoch))
333+
blobParams := &consensus.BlobScheduleEntry{
334+
Epoch: blobSchedule.Epoch,
335+
MaxBlobsPerBlock: blobSchedule.MaxBlobsPerBlock,
336+
}
337+
forkDigest := chainState.GetForkDigest(forkVersion, blobParams)
338+
339+
pageData.NetworkForks = append(pageData.NetworkForks, &models.IndexPageDataForks{
340+
Name: fmt.Sprintf("BPO%d", i+1),
341+
Epoch: blobSchedule.Epoch,
342+
Version: nil, // BPO forks don't have fork versions
343+
Time: uint64(chainState.EpochToTime(phase0.Epoch(blobSchedule.Epoch)).Unix()),
344+
Active: uint64(currentEpoch) >= blobSchedule.Epoch,
345+
Type: "bpo",
346+
MaxBlobsPerBlock: &blobSchedule.MaxBlobsPerBlock,
347+
ForkDigest: forkDigest[:],
348+
})
349+
}
313350
}
314351

315352
// Sort all forks by epoch

0 commit comments

Comments
 (0)