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 50eca10ca0..bdc4c9f61d 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -587,9 +587,10 @@ public class BesuCommand implements DefaultCommandValues, Runnable { @Option( names = {"--pruning-enabled"}, + hidden = true, description = - "Enable pruning of world state of blocks older than the retention period (default: true if fast sync is enabled, false otherwise)") - private Boolean pruningOverride; + "Enable pruning of world state of blocks older than the retention period (default: ${DEFAULT-VALUE})") + private final Boolean isPruningEnabled = false; @Option( names = {"--pruning-blocks-retained"}, @@ -1011,7 +1012,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { logger, commandLine, "--pruning-enabled", - !isPruningEnabled(), + !isPruningEnabled, asList("--pruning-block-confirmations", "--pruning-blocks-retained")); } @@ -1087,7 +1088,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { .clock(Clock.systemUTC()) .isRevertReasonEnabled(isRevertReasonEnabled) .storageProvider(keyStorageProvider(keyValueStorageName)) - .isPruningEnabled(isPruningEnabled()) + .isPruningEnabled(isPruningEnabled) .pruningConfiguration(buildPruningConfiguration()) .genesisConfigOverrides(genesisConfigOverrides) .targetGasLimit(targetGasLimit == null ? Optional.empty() : Optional.of(targetGasLimit)) @@ -1374,10 +1375,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { return new PruningConfiguration(pruningBlockConfirmations, pruningBlocksRetained); } - private boolean isPruningEnabled() { - return Optional.ofNullable(pruningOverride).orElse(syncMode == SyncMode.FAST); - } - // Blockchain synchronisation from peers. private void synchronize( final BesuController controller, diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java index c52bbadf5d..472245fb07 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -159,8 +159,8 @@ public abstract class BesuControllerBuilder { return this; } - public BesuControllerBuilder isPruningEnabled(final boolean isPruningEnabled) { - this.isPruningEnabled = isPruningEnabled; + public BesuControllerBuilder isPruningEnabled(final boolean pruningEnabled) { + this.isPruningEnabled = pruningEnabled; return this; } 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 bbc0f75fba..5704da843e 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -2327,29 +2327,7 @@ public class BesuCommandTest extends CommandTestAbstract { } @Test - public void pruningIsEnabledIfSyncModeIsFast() { - parseCommand("--sync-mode", "FAST"); - - verify(mockControllerBuilder).isPruningEnabled(true); - verify(mockControllerBuilder).build(); - - assertThat(commandOutput.toString()).isEmpty(); - assertThat(commandErrorOutput.toString()).isEmpty(); - } - - @Test - public void pruningIsDisabledIfSyncModeIsFull() { - parseCommand("--sync-mode", "FULL"); - - verify(mockControllerBuilder).isPruningEnabled(false); - verify(mockControllerBuilder).build(); - - assertThat(commandOutput.toString()).isEmpty(); - assertThat(commandErrorOutput.toString()).isEmpty(); - } - - @Test - public void pruningEnabledExplicitly() { + public void pruningIsEnabledWhenSpecified() throws Exception { parseCommand("--pruning-enabled"); verify(mockControllerBuilder).isPruningEnabled(true); @@ -2359,17 +2337,6 @@ public class BesuCommandTest extends CommandTestAbstract { assertThat(commandErrorOutput.toString()).isEmpty(); } - @Test - public void pruningDisabledExplicitly() { - parseCommand("--pruning-enabled=false"); - - verify(mockControllerBuilder).isPruningEnabled(false); - verify(mockControllerBuilder).build(); - - assertThat(commandOutput.toString()).isEmpty(); - assertThat(commandErrorOutput.toString()).isEmpty(); - } - @Test public void pruningOptionsRequiresServiceToBeEnabled() { diff --git a/besu/src/test/resources/everything_config.toml b/besu/src/test/resources/everything_config.toml index b480d4f125..dfa3c03285 100644 --- a/besu/src/test/resources/everything_config.toml +++ b/besu/src/test/resources/everything_config.toml @@ -83,9 +83,6 @@ miner-coinbase="0x0000000000000000000000000000000000000002" miner-extra-data="0x444F4E27542050414E4943202120484F444C2C20484F444C2C20484F444C2021" min-gas-price=1 -# Pruning -pruning-enabled=true - # Permissioning permissions-nodes-config-file-enabled=false permissions-nodes-config-file="./permissions_config.toml"