Skip to content

Commit

Permalink
fix some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Oct 14, 2024
1 parent 3bde374 commit 332f23e
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,8 @@ private ExecutionRequests getExecutionRequestsFromBuilderFlow(
// from the builder bid
.flatMap(BuilderBid::getOptionalExecutionRequests)
// from the local fallback
.orElse(
builderBidOrFallbackData
.getFallbackDataRequired()
.getExecutionRequests()
.orElseThrow());
.or(() -> builderBidOrFallbackData.getFallbackDataRequired().getExecutionRequests())
.orElseThrow();
}

public Consumer<SignedBeaconBlockUnblinder> createBlockUnblinderSelector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,45 @@ void shouldGetExecutionRequestsForLocallyProducedBlocks() {
assertThat(bodyBuilder.executionRequests).isEqualTo(expectedExecutionRequests);
}

@Test
void shouldIncludeExecutionRequestsInBlindedBlock() {
final UInt64 slot = UInt64.valueOf(2);
final BeaconState blockSlotState = dataStructureUtil.randomBeaconState(slot);

final ExecutionRequests executionRequests = dataStructureUtil.randomExecutionRequests();

final ExecutionPayloadContext executionPayloadContextWithValidatorRegistration =
dataStructureUtil.randomPayloadExecutionContext(false, true);
when(forkChoiceNotifier.getPayloadId(any(), any()))
.thenReturn(
SafeFuture.completedFuture(
Optional.of(executionPayloadContextWithValidatorRegistration)));

prepareBlindedBlockWithBlobsAndExecutionRequestsProduction(
dataStructureUtil.randomExecutionPayloadHeader(),
executionPayloadContextWithValidatorRegistration,
blockSlotState,
dataStructureUtil.randomBlobKzgCommitments(),
executionRequests,
dataStructureUtil.randomUInt256());

final CapturingBeaconBlockBodyBuilder bodyBuilder =
new CapturingBeaconBlockBodyBuilder(true, true);

safeJoin(
factory
.createSelector(
parentRoot,
blockSlotState,
dataStructureUtil.randomSignature(),
Optional.empty(),
Optional.empty(),
BlockProductionPerformance.NOOP)
.apply(bodyBuilder));

assertThat(bodyBuilder.executionRequests).isEqualTo(executionRequests);
}

private void prepareBlockProductionWithPayload(
final ExecutionPayload executionPayload,
final ExecutionPayloadContext executionPayloadContext,
Expand Down Expand Up @@ -1158,6 +1197,33 @@ private void prepareBlindedBlockAndBlobsProduction(
executionPayloadContext, SafeFuture.completedFuture(builderBidOrFallbackData)));
}

private void prepareBlindedBlockWithBlobsAndExecutionRequestsProduction(
final ExecutionPayloadHeader executionPayloadHeader,
final ExecutionPayloadContext executionPayloadContext,
final BeaconState blockSlotState,
final SszList<SszKZGCommitment> blobKzgCommitments,
final ExecutionRequests executionRequests,
final UInt256 executionPayloadValue) {
final BuilderBidOrFallbackData builderBidOrFallbackData =
BuilderBidOrFallbackData.create(
dataStructureUtil.randomBuilderBid(
builder -> {
builder.header(executionPayloadHeader);
builder.blobKzgCommitments(blobKzgCommitments);
builder.executionRequests(executionRequests);
builder.value(executionPayloadValue);
}));
when(executionLayer.initiateBlockProduction(
executionPayloadContext,
blockSlotState,
true,
Optional.empty(),
BlockProductionPerformance.NOOP))
.thenReturn(
ExecutionPayloadResult.createForBuilderFlow(
executionPayloadContext, SafeFuture.completedFuture(builderBidOrFallbackData)));
}

private void prepareBlindedBlockAndBlobsProductionWithFallBack(
final ExecutionPayload executionPayload,
final ExecutionPayloadContext executionPayloadContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ public BuilderBid build() {
@Override
protected void validate() {
super.validate();
checkNotNull(blobKzgCommitments, "blobKzgCommitments must be specified");
checkNotNull(executionRequests, "executionRequests must be specified");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

package tech.pegasys.teku.spec.datastructures.builder.versions.electra;

import java.util.Optional;
import org.apache.tuweni.units.bigints.UInt256;
import tech.pegasys.teku.bls.BLSPublicKey;
import tech.pegasys.teku.infrastructure.ssz.SszList;
Expand Down Expand Up @@ -54,11 +53,6 @@ public ExecutionPayloadHeader getHeader() {
return getField0();
}

@Override
public Optional<ExecutionRequests> getOptionalExecutionRequests() {
return Optional.empty();
}

@Override
public SszList<SszKZGCommitment> getBlobKzgCommitments() {
return getField1();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,9 @@ public BuilderBid randomBuilderBid(final Consumer<BuilderBidBuilder> builderModi
schemaDefinitions
.toVersionDeneb()
.ifPresent(__ -> builder.blobKzgCommitments(randomBlobKzgCommitments()));
schemaDefinitions
.toVersionElectra()
.ifPresent(__ -> builder.executionRequests(randomExecutionRequests()));
// 1 ETH is 10^18 wei, Uint256 max is more than 10^77, so just to avoid
// overflows in
// computation
Expand Down

0 comments on commit 332f23e

Please sign in to comment.