Skip to content

Commit

Permalink
changes as per feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Jul 4, 2023
1 parent 8612815 commit bdccc81
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static org.mockito.Mockito.when;

import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -81,10 +80,7 @@ public void shouldReturnFailedExecutionWhenEngineClientRequestFails() {
.thenReturn(dummyFailedResponse(errorResponseFromClient));

final JsonRpcRequestParams params =
new JsonRpcRequestParams.Builder()
.add(executionPayload)
.addOptional(Optional.of(blobVersionedHashes))
.build();
new JsonRpcRequestParams.Builder().add(executionPayload).add(blobVersionedHashes).build();

assertThat(jsonRpcMethod.execute(params))
.succeedsWithin(1, TimeUnit.SECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ public SafeFuture<ForkChoiceUpdatedResult> engineForkChoiceUpdated(
return methodsResolver
.getMilestoneMethod(
EngineApiMethod.ENGINE_FORK_CHOICE_UPDATED,
() -> spec.atSlot(forkChoiceState.getHeadBlockSlot()).getMilestone(),
() -> {
final UInt64 slot =
payloadBuildingAttributes
.map(PayloadBuildingAttributes::getBlockSlot)
.orElse(forkChoiceState.getHeadBlockSlot());
return spec.atSlot(slot).getMilestone();
},
ForkChoiceUpdatedResult.class)
.execute(params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,44 @@ void engineForkChoiceUpdated_shouldCallEngineForkChoiceUpdatedV2() {
final ForkChoiceState forkChoiceState = dataStructureUtil.randomForkChoiceState(false);
final ForkChoiceStateV1 forkChoiceStateV1 =
ForkChoiceStateV1.fromInternalForkChoiceState(forkChoiceState);
final SafeFuture<Response<ForkChoiceUpdatedResult>> dummyResponse =
SafeFuture.completedFuture(
new Response<>(
new ForkChoiceUpdatedResult(
new PayloadStatusV1(
ExecutionPayloadStatus.ACCEPTED, dataStructureUtil.randomBytes32(), ""),
dataStructureUtil.randomBytes8())));
when(executionEngineClient.forkChoiceUpdatedV2(forkChoiceStateV1, Optional.empty()))
.thenReturn(dummyResponse);
final SafeFuture<tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult> future =
handler.engineForkChoiceUpdated(forkChoiceState, Optional.empty());
verify(executionEngineClient).forkChoiceUpdatedV2(forkChoiceStateV1, Optional.empty());
assertThat(future).isCompleted();
}

@Test
void engineForkChoiceUpdatedBuildingBlockOnForkTransition_shouldCallEngineForkChoiceUpdatedV2() {
final UInt64 capellaForkEpoch = UInt64.valueOf(42);
spec = TestSpecFactory.createMinimalWithCapellaForkEpoch(capellaForkEpoch);
final ExecutionClientHandler handler = getHandler();
// building block for Capella
final UInt64 blockSlot = spec.computeStartSlotAtEpoch(capellaForkEpoch);
final PayloadBuildingAttributes attributes =
new PayloadBuildingAttributes(
dataStructureUtil.randomUInt64(),
dataStructureUtil.randomBytes32(),
dataStructureUtil.randomEth1Address(),
Optional.empty(),
Optional.of(List.of()),
dataStructureUtil.randomUInt64());
blockSlot);
final Optional<PayloadAttributesV2> payloadAttributes =
PayloadAttributesV2.fromInternalPayloadBuildingAttributesV2(Optional.of(attributes));
// headBlockSlot in ForkChoiceState is still in Bellatrix
final ForkChoiceState forkChoiceState =
dataStructureUtil.randomForkChoiceState(
blockSlot.minusMinZero(1), dataStructureUtil.randomBytes32(), false);
final ForkChoiceStateV1 forkChoiceStateV1 =
ForkChoiceStateV1.fromInternalForkChoiceState(forkChoiceState);
final SafeFuture<Response<ForkChoiceUpdatedResult>> dummyResponse =
SafeFuture.completedFuture(
new Response<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ public Optional<BLSPublicKey> getValidatorRegistrationPublicKey() {
signedValidatorRegistration -> signedValidatorRegistration.getMessage().getPublicKey());
}

public Optional<UInt64> getValidatorRegistrationGasLimit() {
return validatorRegistration.map(
signedValidatorRegistration -> signedValidatorRegistration.getMessage().getGasLimit());
}

public Optional<List<Withdrawal>> getWithdrawals() {
return maybeWithdrawals;
}
Expand Down

0 comments on commit bdccc81

Please sign in to comment.