Skip to content

Commit

Permalink
moves syncing check after badblock check
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Florentine <justin+github@florentine.us>
  • Loading branch information
jflo committed Oct 17, 2023
1 parent adbf35b commit 8d52b31
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
forkChoice.getHeadBlockHash(), forkChoice.getFinalizedBlockHash());

ForkchoiceResult forkchoiceResult = null;
if (maybeNewHead.isEmpty()) {
return syncingResponse(requestId, forkChoice);
} else if (!isValidForkchoiceState(
if (!isValidForkchoiceState(
forkChoice.getSafeBlockHash(), forkChoice.getFinalizedBlockHash(), maybeNewHead.get())) {
logForkchoiceUpdatedCall(INVALID, forkChoice);
return new JsonRpcErrorResponse(requestId, RpcErrorType.INVALID_FORKCHOICE_STATE);
Expand Down Expand Up @@ -148,16 +146,19 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
if (mergeCoordinator.isBadBlock(forkChoice.getHeadBlockHash())) {
logForkchoiceUpdatedCall(INVALID, forkChoice);
return new JsonRpcSuccessResponse(
requestId,
new EngineUpdateForkchoiceResult(
INVALID,
mergeCoordinator
.getLatestValidHashOfBadBlock(forkChoice.getHeadBlockHash())
.orElse(Hash.ZERO),
null,
Optional.of(forkChoice.getHeadBlockHash() + " is an invalid block")));
requestId,
new EngineUpdateForkchoiceResult(
INVALID,
mergeCoordinator
.getLatestValidHashOfBadBlock(forkChoice.getHeadBlockHash())
.orElse(Hash.ZERO),
null,
Optional.of(forkChoice.getHeadBlockHash() + " is an invalid block")));
}

if (maybeNewHead.isEmpty()) {
return syncingResponse(requestId, forkChoice);
}
final BlockHeader newHead = maybeNewHead.get();
if (maybePayloadAttributes.isPresent()) {
Optional<JsonRpcErrorResponse> maybeError =
Expand Down

0 comments on commit 8d52b31

Please sign in to comment.