Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ethereum/spec/src/main/java/tech/pegasys/teku/spec/Spec.java
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,9 @@ public Optional<Integer> getMaxBlobsPerBlockAtSlot(final UInt64 slot) {
default -> {
final UInt64 epoch = atSlot(slot).miscHelpers().computeEpochAtSlot(slot);
return Optional.of(
specVersion.miscHelpers().toVersionFulu().orElseThrow().getMaxBlobsPerBlock(epoch));
MiscHelpersFulu.required(specVersion.miscHelpers())
.getBlobParameters(epoch)
.maxBlobsPerBlock());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public BlockProcessorFulu(

@Override
public int getMaxBlobsPerBlock(final BeaconState state) {
return miscHelpersFulu.getMaxBlobsPerBlock(miscHelpers.computeEpochAtSlot(state.getSlot()));
return miscHelpersFulu
.getBlobParameters(miscHelpers.computeEpochAtSlot(state.getSlot()))
.maxBlobsPerBlock();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,6 @@ public Optional<MiscHelpersFulu> toVersionFulu() {
return Optional.of(this);
}

// get_max_blobs_per_block
public int getMaxBlobsPerBlock(final UInt64 epoch) {
final Optional<BlobScheduleEntry> maybeSchedule =
blobSchedule.stream()
.filter(blobSchedule -> blobSchedule.epoch().isLessThanOrEqualTo(epoch))
.max(Comparator.comparing(BlobScheduleEntry::epoch));
return maybeSchedule
.map(BlobScheduleEntry::maxBlobsPerBlock)
.orElseGet(specConfigFulu::getMaxBlobsPerBlock);
}

// compute_fork_version
public Bytes4 computeForkVersion(final UInt64 epoch) {
if (epoch.isGreaterThanOrEqualTo(specConfigFulu.getFuluForkEpoch())) {
Expand Down Expand Up @@ -173,6 +162,7 @@ public Optional<Integer> getHighestMaxBlobsPerBlockFromSchedule() {
.map(BlobScheduleEntry::maxBlobsPerBlock);
}

// get_blob_parameters
public BlobParameters getBlobParameters(final UInt64 epoch) {
return blobSchedule.stream()
.sorted(Comparator.comparing(BlobScheduleEntry::epoch).reversed())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.logic.versions.fulu.helpers.BlobParameters;
import tech.pegasys.teku.spec.logic.versions.fulu.helpers.MiscHelpersFulu;
import tech.pegasys.teku.spec.util.DataStructureUtil;

Expand Down Expand Up @@ -84,7 +85,7 @@ public void shouldOverrideBlobRelatedValuesValues() {
}

@Test
public void maxBlobsFuluEpoch() {
public void blobParametersFuluEpoch() {
final UInt64 fuluEpoch = UInt64.valueOf(11223344);
final int maxBlobsPerBlock = 512;
final SpecConfigAndParent<?> specConfigAndParent =
Expand All @@ -108,25 +109,29 @@ public void maxBlobsFuluEpoch() {
.miscHelpers()
.toVersionFulu()
.orElseThrow()
.getMaxBlobsPerBlock(fuluEpoch))
.isEqualTo(maxBlobsPerBlock);
.getBlobParameters(fuluEpoch))
.isEqualTo(new BlobParameters(fuluEpoch, maxBlobsPerBlock));
}

@Test
public void maxBlobsFuluEpochDefaultsToMaxBlobsPerBlockElectraWhenBlobScheduleIsNotConfigured() {
public void
blobParametersFuluEpochDefaultsToElectraBlobParametersWhenBlobScheduleIsNotConfigured() {
final UInt64 fuluEpoch = UInt64.valueOf(11223344);
final UInt64 electraEpoch = UInt64.valueOf(364032);

final SpecConfigAndParent<?> specConfigAndParent =
SpecConfigLoader.loadConfig(
"mainnet",
b -> b.fuluBuilder(fb -> fb.fuluForkEpoch(fuluEpoch).blobSchedule(List.of())));
final Spec fuluSpec = TestSpecFactory.create(specConfigAndParent, SpecMilestone.FULU);

// max blobs per block will default to MAX_BLOBS_PER_BLOCK_ELECTRA if blob schedule is empty
assertThat(
MiscHelpersFulu.required(fuluSpec.forMilestone(SpecMilestone.FULU).miscHelpers())
.getMaxBlobsPerBlock(fuluEpoch))
.getBlobParameters(fuluEpoch))
.isEqualTo(
SpecConfigFulu.required(fuluSpec.getSpecConfig(fuluEpoch)).getMaxBlobsPerBlock());
new BlobParameters(
electraEpoch,
SpecConfigFulu.required(fuluSpec.getSpecConfig(fuluEpoch)).getMaxBlobsPerBlock()));
}

@Test
Expand Down