Don't throw NoSuchElementException when the last checkpoint range fails validation. (#1049)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/1055/head
Adrian Sutton 5 years ago committed by GitHub
parent 4d18598d21
commit ce98e68fcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/CheckpointHeaderValidationStep.java

@ -47,14 +47,20 @@ public class CheckpointHeaderValidationStep<C>
if (isValid(rangeStart, firstHeaderToImport)) {
return checkpointRangeHeaders.getHeadersToImport().stream();
} else {
final BlockHeader rangeEnd = checkpointRangeHeaders.getCheckpointRange().getEnd();
final String rangeEndDescription;
if (checkpointRangeHeaders.getCheckpointRange().hasEnd()) {
final BlockHeader rangeEnd = checkpointRangeHeaders.getCheckpointRange().getEnd();
rangeEndDescription =
String.format("#%d (%s)", rangeEnd.getNumber(), rangeEnd.getBlockHash());
} else {
rangeEndDescription = "chain head";
}
final String errorMessage =
String.format(
"Invalid checkpoint headers. Headers downloaded between #%d (%s) and #%d (%s) do not connect at #%d (%s)",
"Invalid checkpoint headers. Headers downloaded between #%d (%s) and %s do not connect at #%d (%s)",
rangeStart.getNumber(),
rangeStart.getHash(),
rangeEnd.getNumber(),
rangeEnd.getHash(),
rangeEndDescription,
firstHeaderToImport.getNumber(),
firstHeaderToImport.getHash());
throw new InvalidBlockException(

Loading…
Cancel
Save