|
|
@ -77,10 +77,11 @@ public class EngineForkchoiceUpdated extends ExecutionEngineJsonRpcMethod { |
|
|
|
forkChoice.getHeadBlockHash(), maybeFinalizedHash, forkChoice.getSafeBlockHash()); |
|
|
|
forkChoice.getHeadBlockHash(), maybeFinalizedHash, forkChoice.getSafeBlockHash()); |
|
|
|
|
|
|
|
|
|
|
|
if (mergeContext.isSyncing()) { |
|
|
|
if (mergeContext.isSyncing()) { |
|
|
|
return syncingResponse(requestId); |
|
|
|
return syncingResponse(requestId, forkChoice); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mergeCoordinator.isBadBlock(forkChoice.getHeadBlockHash())) { |
|
|
|
if (mergeCoordinator.isBadBlock(forkChoice.getHeadBlockHash())) { |
|
|
|
|
|
|
|
logForkchoiceUpdatedCall(INVALID, forkChoice); |
|
|
|
return new JsonRpcSuccessResponse( |
|
|
|
return new JsonRpcSuccessResponse( |
|
|
|
requestId, |
|
|
|
requestId, |
|
|
|
new EngineUpdateForkchoiceResult( |
|
|
|
new EngineUpdateForkchoiceResult( |
|
|
@ -96,25 +97,21 @@ public class EngineForkchoiceUpdated extends ExecutionEngineJsonRpcMethod { |
|
|
|
mergeCoordinator.getOrSyncHeaderByHash(forkChoice.getHeadBlockHash()); |
|
|
|
mergeCoordinator.getOrSyncHeaderByHash(forkChoice.getHeadBlockHash()); |
|
|
|
|
|
|
|
|
|
|
|
if (newHead.isEmpty()) { |
|
|
|
if (newHead.isEmpty()) { |
|
|
|
return syncingResponse(requestId); |
|
|
|
return syncingResponse(requestId, forkChoice); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LOG.info( |
|
|
|
|
|
|
|
"Consensus fork-choice-update: head: {}, finalized: {}, safeBlockHash: {}", |
|
|
|
|
|
|
|
forkChoice.getHeadBlockHash(), |
|
|
|
|
|
|
|
forkChoice.getFinalizedBlockHash(), |
|
|
|
|
|
|
|
forkChoice.getSafeBlockHash()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
maybePayloadAttributes.ifPresentOrElse( |
|
|
|
maybePayloadAttributes.ifPresentOrElse( |
|
|
|
this::logPayload, () -> LOG.debug("Payload attributes are null")); |
|
|
|
this::logPayload, () -> LOG.debug("Payload attributes are null")); |
|
|
|
|
|
|
|
|
|
|
|
if (!isValidForkchoiceState( |
|
|
|
if (!isValidForkchoiceState( |
|
|
|
forkChoice.getSafeBlockHash(), forkChoice.getFinalizedBlockHash(), newHead.get())) { |
|
|
|
forkChoice.getSafeBlockHash(), forkChoice.getFinalizedBlockHash(), newHead.get())) { |
|
|
|
|
|
|
|
logForkchoiceUpdatedCall(INVALID, forkChoice); |
|
|
|
return new JsonRpcErrorResponse(requestId, JsonRpcError.INVALID_FORKCHOICE_STATE); |
|
|
|
return new JsonRpcErrorResponse(requestId, JsonRpcError.INVALID_FORKCHOICE_STATE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: post-merge cleanup, this should be unnecessary after merge
|
|
|
|
// TODO: post-merge cleanup, this should be unnecessary after merge
|
|
|
|
if (!mergeCoordinator.latestValidAncestorDescendsFromTerminal(newHead.get())) { |
|
|
|
if (!mergeCoordinator.latestValidAncestorDescendsFromTerminal(newHead.get())) { |
|
|
|
|
|
|
|
logForkchoiceUpdatedCall(INVALID, forkChoice); |
|
|
|
return new JsonRpcSuccessResponse( |
|
|
|
return new JsonRpcSuccessResponse( |
|
|
|
requestId, |
|
|
|
requestId, |
|
|
|
new EngineUpdateForkchoiceResult( |
|
|
|
new EngineUpdateForkchoiceResult( |
|
|
@ -137,6 +134,7 @@ public class EngineForkchoiceUpdated extends ExecutionEngineJsonRpcMethod { |
|
|
|
payloadAttributes.getSuggestedFeeRecipient()))); |
|
|
|
payloadAttributes.getSuggestedFeeRecipient()))); |
|
|
|
|
|
|
|
|
|
|
|
if (!result.isValid()) { |
|
|
|
if (!result.isValid()) { |
|
|
|
|
|
|
|
logForkchoiceUpdatedCall(INVALID, forkChoice); |
|
|
|
return handleNonValidForkchoiceUpdate(requestId, result); |
|
|
|
return handleNonValidForkchoiceUpdate(requestId, result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -158,6 +156,7 @@ public class EngineForkchoiceUpdated extends ExecutionEngineJsonRpcMethod { |
|
|
|
pid::toHexString, |
|
|
|
pid::toHexString, |
|
|
|
() -> maybePayloadAttributes.map(EnginePayloadAttributesParameter::serialize))); |
|
|
|
() -> maybePayloadAttributes.map(EnginePayloadAttributesParameter::serialize))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logForkchoiceUpdatedCall(VALID, forkChoice); |
|
|
|
return new JsonRpcSuccessResponse( |
|
|
|
return new JsonRpcSuccessResponse( |
|
|
|
requestId, |
|
|
|
requestId, |
|
|
|
new EngineUpdateForkchoiceResult( |
|
|
|
new EngineUpdateForkchoiceResult( |
|
|
@ -256,8 +255,20 @@ public class EngineForkchoiceUpdated extends ExecutionEngineJsonRpcMethod { |
|
|
|
return mergeCoordinator.isDescendantOf(maybeSafeBlock.get(), newBlock); |
|
|
|
return mergeCoordinator.isDescendantOf(maybeSafeBlock.get(), newBlock); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private JsonRpcResponse syncingResponse(final Object requestId) { |
|
|
|
private JsonRpcResponse syncingResponse( |
|
|
|
|
|
|
|
final Object requestId, final EngineForkchoiceUpdatedParameter forkChoice) { |
|
|
|
|
|
|
|
logForkchoiceUpdatedCall(SYNCING, forkChoice); |
|
|
|
return new JsonRpcSuccessResponse( |
|
|
|
return new JsonRpcSuccessResponse( |
|
|
|
requestId, new EngineUpdateForkchoiceResult(SYNCING, null, null, Optional.empty())); |
|
|
|
requestId, new EngineUpdateForkchoiceResult(SYNCING, null, null, Optional.empty())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void logForkchoiceUpdatedCall( |
|
|
|
|
|
|
|
final EngineStatus status, final EngineForkchoiceUpdatedParameter forkChoice) { |
|
|
|
|
|
|
|
LOG.info( |
|
|
|
|
|
|
|
"{} for fork-choice-update: head: {}, finalized: {}, safeBlockHash: {}", |
|
|
|
|
|
|
|
status.name(), |
|
|
|
|
|
|
|
forkChoice.getHeadBlockHash(), |
|
|
|
|
|
|
|
forkChoice.getFinalizedBlockHash(), |
|
|
|
|
|
|
|
forkChoice.getSafeBlockHash()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|