Skip to content

Commit

Permalink
fix event thread
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdi-aouadi committed Nov 6, 2024
1 parent 83f14de commit a8a2b32
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ public Optional<Integer> getMaxBlobsPerBlock() {
return Optional.of(SpecConfigDeneb.required(specConfig).getMaxBlobsPerBlock());
}

@Override
public Optional<Integer> getTargetBlobsPerBlock() {
return getMaxBlobsPerBlock().map(maxBlobsPerBlock -> maxBlobsPerBlock / 2);
}

@Override
public Optional<Integer> getBlobSidecarSubnetCount() {
return Optional.of(SpecConfigDeneb.required(specConfig).getBlobSidecarSubnetCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ public SafeFuture<Optional<PayloadBuildingAttributes>> calculatePayloadBuildingA
final ForkChoiceState forkChoiceState = forkChoiceUpdateData.getForkChoiceState();
final Bytes32 currentHeadBlockRoot = forkChoiceState.getHeadBlockRoot();
return getStateInEpoch(epoch)
.thenApply(
.thenApplyAsync(
maybeState ->
calculatePayloadBuildingAttributes(
currentHeadBlockRoot, blockSlot, epoch, maybeState, mandatory));
currentHeadBlockRoot, blockSlot, epoch, maybeState, mandatory),
eventThread);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import tech.pegasys.teku.ethereum.execution.types.Eth1Address;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.async.eventthread.EventThread;
import tech.pegasys.teku.infrastructure.async.eventthread.InlineEventThread;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.TestSpecContext;
Expand Down Expand Up @@ -121,15 +122,17 @@ void shouldSetMaxAndTargetBlobCount() throws ExecutionException, InterruptedExce
when(specMock.getMaxBlobsPerBlock(currentForkFirstSlot)).thenReturn(spec.getMaxBlobsPerBlock());
when(specMock.getTargetBlobsPerBlock(currentForkFirstSlot))
.thenReturn(spec.getTargetBlobsPerBlock(currentForkFirstSlot));
final InlineEventThread eventThread = new InlineEventThread();
manager =
new ProposersDataManager(
mock(EventThread.class),
eventThread,
specMock,
metricsSystem,
channel,
recentChainData,
Optional.of(defaultAddress),
true);
eventThread.markAsOnEventThread();
final ForkChoiceUpdateData forkChoiceUpdateDataMock = mock(ForkChoiceUpdateData.class);
when(forkChoiceUpdateDataMock.hasHeadBlockHash()).thenReturn(true);
final ForkChoiceState forkChoiceStateMock = mock(ForkChoiceState.class);
Expand All @@ -142,7 +145,6 @@ void shouldSetMaxAndTargetBlobCount() throws ExecutionException, InterruptedExce
when(recentChainData.getChainHead()).thenReturn(Optional.of(chainHeadMock));
final BeaconState beaconStateMock = mock(BeaconState.class);
when(chainHeadMock.getState()).thenReturn(SafeFuture.completedFuture(beaconStateMock));

final SafeFuture<Optional<PayloadBuildingAttributes>> payloadBuildingAttributesFuture =
manager.calculatePayloadBuildingAttributes(
currentForkFirstSlot, true, forkChoiceUpdateDataMock, false);
Expand Down

0 comments on commit a8a2b32

Please sign in to comment.