From 137d4db22181c820ee2c24749de9bf044c916a25 Mon Sep 17 00:00:00 2001 From: Matthew Whitehead Date: Mon, 10 Jul 2023 11:39:22 +0100 Subject: [PATCH] Rework 'isEthash' logic Signed-off-by: Matthew Whitehead --- .../org/hyperledger/besu/cli/BesuCommand.java | 15 ++------------- .../org/hyperledger/besu/cli/BesuCommandTest.java | 4 ++-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 896e6b8b134..831c52a74f4 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -2113,15 +2113,6 @@ private GenesisConfigOptions readGenesisConfigOptions() { return genesisConfigOptions; } - private boolean isEthashEnabled() { - if (genesisFile == null) { - return GenesisConfigFile.fromConfig(ethNetworkConfig.getGenesisConfig()) - .getConfigOptions() - .isEthHash(); - } - return genesisConfigOptions.isEthHash(); - } - private void issueOptionWarnings() { // Check that P2P options are able to work @@ -2142,7 +2133,7 @@ private void issueOptionWarnings() { "--remote-connections-max-percentage")); // Check that block producer options work - if (!isMergeEnabled() && isEthashEnabled()) { + if (!isMergeEnabled() && getActualGenesisConfigOptions().isEthHash()) { CommandLineUtils.checkOptionDependencies( logger, commandLine, @@ -2153,10 +2144,8 @@ private void issueOptionWarnings() { "--min-gas-price", "--min-block-occupancy-ratio", "--miner-extra-data")); - } - // Check that mining options are able to work - if (!isMergeEnabled() && isEthashEnabled()) { + // Check that mining options are able to work CommandLineUtils.checkOptionDependencies( logger, commandLine, diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index de87890b169..24691b88840 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -3684,7 +3684,7 @@ public void stratumMiningIsEnabledWhenSpecified() throws Exception { @Test public void stratumMiningOptionsRequiresServiceToBeEnabled() { - parseCommand("--miner-stratum-enabled"); + parseCommand("--network", "dev", "--miner-stratum-enabled"); verifyOptionsConstraintLoggerCall("--miner-enabled", "--miner-stratum-enabled"); @@ -3698,7 +3698,7 @@ public void stratumMiningOptionsRequiresServiceToBeEnabled() { public void stratumMiningOptionsRequiresServiceToBeEnabledToml() throws IOException { final Path toml = createTempFile("toml", "miner-stratum-enabled=true\n"); - parseCommand("--config-file", toml.toString()); + parseCommand("--network", "dev", "--config-file", toml.toString()); verifyOptionsConstraintLoggerCall("--miner-enabled", "--miner-stratum-enabled");