Revert "[PAN-2798] Enable pruning by default for fast sync (#135)" (#164)

This reverts commit 7e2497bf95.

Signed-off-by: Joshua Fernandes <joshua.fernandes@consensys.net>
pull/165/head
Joshua Fernandes 5 years ago committed by GitHub
parent 4549a95ec6
commit 761cfb3435
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  2. 4
      besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
  3. 35
      besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
  4. 3
      besu/src/test/resources/everything_config.toml

@ -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,

@ -159,8 +159,8 @@ public abstract class BesuControllerBuilder<C> {
return this;
}
public BesuControllerBuilder<C> isPruningEnabled(final boolean isPruningEnabled) {
this.isPruningEnabled = isPruningEnabled;
public BesuControllerBuilder<C> isPruningEnabled(final boolean pruningEnabled) {
this.isPruningEnabled = pruningEnabled;
return this;
}

@ -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() {

@ -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"

Loading…
Cancel
Save