Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add db reset for Ephemery network on restart #8213

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
import static org.hyperledger.besu.metrics.BesuMetricCategory.BLOCKCHAIN;
import static org.hyperledger.besu.metrics.BesuMetricCategory.NETWORK;

import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.chain.BlockchainStorage.Updater;
Expand Down Expand Up @@ -847,12 +848,22 @@ private void setGenesis(final Block genesisBlock, final String dataDirectory) {
throw new IllegalStateException("Blockchain is missing genesis block data.");
}
if (!genesisHash.get().equals(genesisBlock.getHash())) {
throw new InvalidConfigurationException(
"Supplied genesis block does not match chain data stored in "
+ dataDirectory
+ ".\n"
+ "Please specify a different data directory with --data-path, specify the original genesis file with "
+ "--genesis-file or supply a testnet/mainnet option with --network.");
if (NETWORK.getName().equals("Ephemery")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this NETWORK is a metrics category not the network name you're looking for

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also I'd use equalsIgnoreCase to allow variances

throw new InvalidConfigurationException(
"Supplied genesis block does not match chain data stored in "
+ dataDirectory
+ ".\n"
+ "This is expected when the Ephemery network has rolled over to a new genesis. "
+ "Please reset your data directory by removing or renaming: "
+ dataDirectory);
} else {
throw new InvalidConfigurationException(
"Supplied genesis block does not match chain data stored in "
+ dataDirectory
+ ".\n"
+ "Please specify a different data directory with --data-path, specify the original genesis file with "
+ "--genesis-file or supply a testnet/mainnet option with --network.");
}
}
}
}
Expand Down