Skip to content

Commit

Permalink
update getMaxBlobsPerBlockForHighestMilestone
Browse files Browse the repository at this point in the history
  • Loading branch information
tbenr committed Nov 15, 2024
1 parent 199d08c commit 712e8c0
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions ethereum/spec/src/main/java/tech/pegasys/teku/spec/Spec.java
Original file line number Diff line number Diff line change
Expand Up @@ -948,13 +948,34 @@ public boolean isAvailabilityOfBlobSidecarsRequiredAtEpoch(
.isLessThanOrEqualTo(specConfigDeneb.getMinEpochsForBlobSidecarsRequests());
}

/**
* This method is used to setup caches and limits during the initialization of the node. We
* normally increase the blobs with each fork, but in case we will decrease them, let's consider
* the last two forks.
*/
public Optional<Integer> getMaxBlobsPerBlockForHighestMilestone() {
final SpecMilestone highestSupportedMilestone =
getForkSchedule().getHighestSupportedMilestone();
return forMilestone(highestSupportedMilestone)
.getConfig()
.toVersionDeneb()
.map(SpecConfigDeneb::getMaxBlobsPerBlock);
final Optional<Integer> highestMaxBlobsPerBlock =
forMilestone(highestSupportedMilestone)
.getConfig()
.toVersionDeneb()
.map(SpecConfigDeneb::getMaxBlobsPerBlock);

final Optional<Integer> secondHighestMaxBlobsPerBlock =
highestSupportedMilestone
.getPreviousMilestoneIfExists()
.map(this::forMilestone)
.map(SpecVersion::getConfig)
.flatMap(SpecConfig::toVersionDeneb)
.map(SpecConfigDeneb::getMaxBlobsPerBlock);

if (highestMaxBlobsPerBlock.isEmpty() && secondHighestMaxBlobsPerBlock.isEmpty()) {
return Optional.empty();
}

return Optional.of(
Math.max(highestMaxBlobsPerBlock.orElse(0), secondHighestMaxBlobsPerBlock.orElse(0)));
}

public UInt64 computeSubnetForBlobSidecar(final BlobSidecar blobSidecar) {
Expand Down

0 comments on commit 712e8c0

Please sign in to comment.