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
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ protected ValidationResult<RpcErrorType> validateParameters(
return ValidationResult.invalid(
RpcErrorType.INVALID_PARENT_BEACON_BLOCK_ROOT_PARAMS,
"Missing parent beacon block root field");
} else if (maybeRequestsParam.isPresent()) {
return ValidationResult.invalid(
RpcErrorType.INVALID_EXECUTION_REQUESTS_PARAMS,
"Unexpected execution requests field present");
} else {
return ValidationResult.valid();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@

public class ForkSupportHelper {
public static ValidationResult<RpcErrorType> validateForkSupported(
final HardforkId hardforkId,
final HardforkId firstSupportedHardforkId,
final Optional<Long> maybeForkMilestone,
final long blockTimestamp) {
if (maybeForkMilestone.isEmpty()) {
return ValidationResult.invalid(
RpcErrorType.UNSUPPORTED_FORK,
"Configuration error, no schedule for " + hardforkId.name() + " fork set");
"Configuration error, no schedule for " + firstSupportedHardforkId.name() + " fork set");
}

if (Long.compareUnsigned(blockTimestamp, maybeForkMilestone.get()) < 0) {
return ValidationResult.invalid(
RpcErrorType.UNSUPPORTED_FORK,
hardforkId.name() + " configured to start at timestamp: " + maybeForkMilestone.get());
firstSupportedHardforkId.name()
+ " configured to start at timestamp: "
+ maybeForkMilestone.get());
}

return ValidationResult.valid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void shouldInvalidVersionedHash_whenShortVersionedHash() {
}

@Test
public void shouldValidVersionedHash_whenListIsEmpty() {
public void validateVersionedHash_whenListIsPresentAndEmpty() {
final BlockHeader mockHeader =
setupValidPayload(
new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))),
Expand All @@ -153,10 +153,28 @@ public void shouldValidVersionedHash_whenListIsEmpty() {
payload,
Optional.of(List.of()),
Optional.of("0x0000000000000000000000000000000000000000000000000000000000000000"),
Optional.of(emptyList()));
Optional.empty());
assertThat(res.isValid()).isTrue();
}

@Test
public void validateExecutionRequests_whenPresent() {
final BlockHeader mockHeader =
setupValidPayload(
new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))),
Optional.empty());
final EnginePayloadParameter payload = mockEnginePayload(mockHeader, emptyList(), null);

ValidationResult<RpcErrorType> res =
method.validateParameters(
payload,
Optional.of(List.of()),
Optional.of("0x0000000000000000000000000000000000000000000000000000000000000000"),
Optional.of(emptyList()));
assertThat(res.isValid()).isFalse();
assertThat(res.getInvalidReason()).isEqualTo(RpcErrorType.INVALID_EXECUTION_REQUESTS_PARAMS);
}

@Override
protected BlockHeader createBlockHeader(final Optional<List<Withdrawal>> maybeWithdrawals) {
BlockHeader parentBlockHeader =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.mainnet.BodyValidation;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator;
import org.hyperledger.besu.ethereum.mainnet.requests.ProhibitedRequestValidator;
import org.hyperledger.besu.evm.gascalculator.PragueGasCalculator;
Expand Down Expand Up @@ -131,6 +133,42 @@ public void shouldReturnInvalidIfRequestsIsNotNull_WhenRequestsProhibited() {
verify(engineCallListener, times(1)).executionEngineCalled();
}

@Override
@Test
public void validateVersionedHash_whenListIsPresentAndEmpty() {
final BlockHeader mockHeader =
setupValidPayload(
new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))),
Optional.empty());
final EnginePayloadParameter payload = mockEnginePayload(mockHeader, emptyList(), null);

ValidationResult<RpcErrorType> res =
method.validateParameters(
payload,
Optional.of(List.of()),
Optional.of("0x0000000000000000000000000000000000000000000000000000000000000000"),
Optional.of(List.of()));
assertThat(res.isValid()).isTrue();
}

@Override
@Test
public void validateExecutionRequests_whenPresent() {
final BlockHeader mockHeader =
setupValidPayload(
new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))),
Optional.empty());
final EnginePayloadParameter payload = mockEnginePayload(mockHeader, emptyList(), null);

ValidationResult<RpcErrorType> res =
method.validateParameters(
payload,
Optional.of(List.of()),
Optional.of("0x0000000000000000000000000000000000000000000000000000000000000000"),
Optional.of(emptyList()));
assertThat(res.isValid()).isTrue();
}

private BlockHeader createValidBlockHeaderForV4(
final Optional<List<Withdrawal>> maybeWithdrawals) {
return createBlockHeaderFixtureForV3(maybeWithdrawals)
Expand Down