Skip to content

Commit

Permalink
Provide user-friendly message when initial state is incompatible (#7976)
Browse files Browse the repository at this point in the history
  • Loading branch information
zilm13 authored Feb 13, 2024
1 parent 1f61f24 commit c2f3aec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,15 @@ public void loadedInitialStateResource(
}
}

public void errorIncompatibleInitialState(final UInt64 epoch) {
log.error(
"Cannot start with provided initial state for the epoch {}, "
+ "checkpoint occurred on the empty slot, which is not yet supported.\n"
+ "If you are using remote checkpoint source, "
+ "please wait for the next epoch to finalize and retry.",
epoch);
}

public void warnInitialStateIgnored() {
log.warn("Not loading specified initial state as chain data already exists.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package tech.pegasys.teku.services.beaconchain;

import static tech.pegasys.teku.infrastructure.exceptions.ExitConstants.ERROR_EXIT_CODE;
import static tech.pegasys.teku.infrastructure.logging.StatusLogger.STATUS_LOG;
import static tech.pegasys.teku.networks.Eth2NetworkConfiguration.FINALIZED_STATE_URL_PATH;

Expand Down Expand Up @@ -85,6 +86,10 @@ private AnchorPoint getAnchorPoint(Spec spec, String stateResource, String sanit
throws IOException {
STATUS_LOG.loadingInitialStateResource(sanitizedResource);
final BeaconState state = ChainDataLoader.loadState(spec, stateResource);
if (state.getSlot().isGreaterThan(state.getLatestBlockHeader().getSlot())) {
STATUS_LOG.errorIncompatibleInitialState(spec.computeEpochAtSlot(state.getSlot()));
System.exit(ERROR_EXIT_CODE);
}
final AnchorPoint anchor = AnchorPoint.fromInitialState(spec, state);
STATUS_LOG.loadedInitialStateResource(
state.hashTreeRoot(),
Expand Down

0 comments on commit c2f3aec

Please sign in to comment.