|
|
@ -19,8 +19,9 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.Executi |
|
|
|
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID_BLOCK_HASH; |
|
|
|
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID_BLOCK_HASH; |
|
|
|
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.SYNCING; |
|
|
|
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.SYNCING; |
|
|
|
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID; |
|
|
|
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID; |
|
|
|
import static org.hyperledger.besu.util.Slf4jLambdaHelper.infoLambda; |
|
|
|
import static org.hyperledger.besu.util.Slf4jLambdaHelper.debugLambda; |
|
|
|
import static org.hyperledger.besu.util.Slf4jLambdaHelper.traceLambda; |
|
|
|
import static org.hyperledger.besu.util.Slf4jLambdaHelper.traceLambda; |
|
|
|
|
|
|
|
import static org.hyperledger.besu.util.Slf4jLambdaHelper.warnLambda; |
|
|
|
|
|
|
|
|
|
|
|
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator; |
|
|
|
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator; |
|
|
|
import org.hyperledger.besu.datatypes.Hash; |
|
|
|
import org.hyperledger.besu.datatypes.Hash; |
|
|
@ -155,7 +156,6 @@ public class EngineNewPayload extends ExecutionEngineJsonRpcMethod { |
|
|
|
protocolContext.getBlockchain().getBlockHeader(blockParam.getParentHash()); |
|
|
|
protocolContext.getBlockchain().getBlockHeader(blockParam.getParentHash()); |
|
|
|
if (parentHeader.isPresent() |
|
|
|
if (parentHeader.isPresent() |
|
|
|
&& (blockParam.getTimestamp() <= parentHeader.get().getTimestamp())) { |
|
|
|
&& (blockParam.getTimestamp() <= parentHeader.get().getTimestamp())) { |
|
|
|
LOG.info("method parameter timestamp not greater than parent"); |
|
|
|
|
|
|
|
return respondWithInvalid( |
|
|
|
return respondWithInvalid( |
|
|
|
reqId, |
|
|
|
reqId, |
|
|
|
blockParam, |
|
|
|
blockParam, |
|
|
@ -167,7 +167,7 @@ public class EngineNewPayload extends ExecutionEngineJsonRpcMethod { |
|
|
|
new Block(newBlockHeader, new BlockBody(transactions, Collections.emptyList())); |
|
|
|
new Block(newBlockHeader, new BlockBody(transactions, Collections.emptyList())); |
|
|
|
|
|
|
|
|
|
|
|
if (mergeContext.isSyncing() || parentHeader.isEmpty()) { |
|
|
|
if (mergeContext.isSyncing() || parentHeader.isEmpty()) { |
|
|
|
LOG.info( |
|
|
|
LOG.debug( |
|
|
|
"isSyncing: {} parentHeaderMissing: {}, adding {} to backwardsync", |
|
|
|
"isSyncing: {} parentHeaderMissing: {}, adding {} to backwardsync", |
|
|
|
mergeContext.isSyncing(), |
|
|
|
mergeContext.isSyncing(), |
|
|
|
parentHeader.isEmpty(), |
|
|
|
parentHeader.isEmpty(), |
|
|
@ -185,7 +185,6 @@ public class EngineNewPayload extends ExecutionEngineJsonRpcMethod { |
|
|
|
|
|
|
|
|
|
|
|
// TODO: post-merge cleanup
|
|
|
|
// TODO: post-merge cleanup
|
|
|
|
if (!mergeCoordinator.latestValidAncestorDescendsFromTerminal(newBlockHeader)) { |
|
|
|
if (!mergeCoordinator.latestValidAncestorDescendsFromTerminal(newBlockHeader)) { |
|
|
|
LOG.warn("payload did not descend from terminal: {}", newBlockHeader.toLogString()); |
|
|
|
|
|
|
|
mergeCoordinator.addBadBlock(block); |
|
|
|
mergeCoordinator.addBadBlock(block); |
|
|
|
return respondWithInvalid( |
|
|
|
return respondWithInvalid( |
|
|
|
reqId, |
|
|
|
reqId, |
|
|
@ -217,7 +216,7 @@ public class EngineNewPayload extends ExecutionEngineJsonRpcMethod { |
|
|
|
final EnginePayloadParameter param, |
|
|
|
final EnginePayloadParameter param, |
|
|
|
final Hash latestValidHash, |
|
|
|
final Hash latestValidHash, |
|
|
|
final EngineStatus status) { |
|
|
|
final EngineStatus status) { |
|
|
|
infoLambda( |
|
|
|
debugLambda( |
|
|
|
LOG, |
|
|
|
LOG, |
|
|
|
"New payload: number: {}, hash: {}, parentHash: {}, latestValidHash: {}, status: {}", |
|
|
|
"New payload: number: {}, hash: {}, parentHash: {}, latestValidHash: {}, status: {}", |
|
|
|
() -> param.getBlockNumber(), |
|
|
|
() -> param.getBlockNumber(), |
|
|
@ -229,20 +228,26 @@ public class EngineNewPayload extends ExecutionEngineJsonRpcMethod { |
|
|
|
requestId, new EnginePayloadStatusResult(status, latestValidHash, Optional.empty())); |
|
|
|
requestId, new EnginePayloadStatusResult(status, latestValidHash, Optional.empty())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// engine api calls are synchronous, no need for volatile
|
|
|
|
|
|
|
|
private long lastInvalidWarn = System.currentTimeMillis(); |
|
|
|
|
|
|
|
|
|
|
|
JsonRpcResponse respondWithInvalid( |
|
|
|
JsonRpcResponse respondWithInvalid( |
|
|
|
final Object requestId, |
|
|
|
final Object requestId, |
|
|
|
final EnginePayloadParameter param, |
|
|
|
final EnginePayloadParameter param, |
|
|
|
final Hash latestValidHash, |
|
|
|
final Hash latestValidHash, |
|
|
|
final String validationError) { |
|
|
|
final String validationError) { |
|
|
|
infoLambda( |
|
|
|
if (lastInvalidWarn + ENGINE_API_LOGGING_THRESHOLD < System.currentTimeMillis()) { |
|
|
|
LOG, |
|
|
|
lastInvalidWarn = System.currentTimeMillis(); |
|
|
|
"Invalid new payload: number: {}, hash: {}, parentHash: {}, latestValidHash: {}, status: {}, validationError: {}", |
|
|
|
warnLambda( |
|
|
|
() -> param.getBlockNumber(), |
|
|
|
LOG, |
|
|
|
() -> param.getBlockHash(), |
|
|
|
"Invalid new payload: number: {}, hash: {}, parentHash: {}, latestValidHash: {}, status: {}, validationError: {}", |
|
|
|
() -> param.getParentHash(), |
|
|
|
() -> param.getBlockNumber(), |
|
|
|
() -> latestValidHash == null ? null : latestValidHash.toHexString(), |
|
|
|
() -> param.getBlockHash(), |
|
|
|
INVALID::name, |
|
|
|
() -> param.getParentHash(), |
|
|
|
() -> validationError); |
|
|
|
() -> latestValidHash == null ? null : latestValidHash.toHexString(), |
|
|
|
|
|
|
|
INVALID::name, |
|
|
|
|
|
|
|
() -> validationError); |
|
|
|
|
|
|
|
} |
|
|
|
return new JsonRpcSuccessResponse( |
|
|
|
return new JsonRpcSuccessResponse( |
|
|
|
requestId, |
|
|
|
requestId, |
|
|
|
new EnginePayloadStatusResult(INVALID, latestValidHash, Optional.of(validationError))); |
|
|
|
new EnginePayloadStatusResult(INVALID, latestValidHash, Optional.of(validationError))); |
|
|
|