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( @Option(
names = {"--pruning-enabled"}, names = {"--pruning-enabled"},
hidden = true,
description = description =
"Enable pruning of world state of blocks older than the retention period (default: true if fast sync is enabled, false otherwise)") "Enable pruning of world state of blocks older than the retention period (default: ${DEFAULT-VALUE})")
private Boolean pruningOverride; private final Boolean isPruningEnabled = false;
@Option( @Option(
names = {"--pruning-blocks-retained"}, names = {"--pruning-blocks-retained"},
@ -1011,7 +1012,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
logger, logger,
commandLine, commandLine,
"--pruning-enabled", "--pruning-enabled",
!isPruningEnabled(), !isPruningEnabled,
asList("--pruning-block-confirmations", "--pruning-blocks-retained")); asList("--pruning-block-confirmations", "--pruning-blocks-retained"));
} }
@ -1087,7 +1088,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
.clock(Clock.systemUTC()) .clock(Clock.systemUTC())
.isRevertReasonEnabled(isRevertReasonEnabled) .isRevertReasonEnabled(isRevertReasonEnabled)
.storageProvider(keyStorageProvider(keyValueStorageName)) .storageProvider(keyStorageProvider(keyValueStorageName))
.isPruningEnabled(isPruningEnabled()) .isPruningEnabled(isPruningEnabled)
.pruningConfiguration(buildPruningConfiguration()) .pruningConfiguration(buildPruningConfiguration())
.genesisConfigOverrides(genesisConfigOverrides) .genesisConfigOverrides(genesisConfigOverrides)
.targetGasLimit(targetGasLimit == null ? Optional.empty() : Optional.of(targetGasLimit)) .targetGasLimit(targetGasLimit == null ? Optional.empty() : Optional.of(targetGasLimit))
@ -1374,10 +1375,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
return new PruningConfiguration(pruningBlockConfirmations, pruningBlocksRetained); return new PruningConfiguration(pruningBlockConfirmations, pruningBlocksRetained);
} }
private boolean isPruningEnabled() {
return Optional.ofNullable(pruningOverride).orElse(syncMode == SyncMode.FAST);
}
// Blockchain synchronisation from peers. // Blockchain synchronisation from peers.
private void synchronize( private void synchronize(
final BesuController<?> controller, final BesuController<?> controller,

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

@ -2327,29 +2327,7 @@ public class BesuCommandTest extends CommandTestAbstract {
} }
@Test @Test
public void pruningIsEnabledIfSyncModeIsFast() { public void pruningIsEnabledWhenSpecified() throws Exception {
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() {
parseCommand("--pruning-enabled"); parseCommand("--pruning-enabled");
verify(mockControllerBuilder).isPruningEnabled(true); verify(mockControllerBuilder).isPruningEnabled(true);
@ -2359,17 +2337,6 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString()).isEmpty(); 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 @Test
public void pruningOptionsRequiresServiceToBeEnabled() { public void pruningOptionsRequiresServiceToBeEnabled() {

@ -83,9 +83,6 @@ miner-coinbase="0x0000000000000000000000000000000000000002"
miner-extra-data="0x444F4E27542050414E4943202120484F444C2C20484F444C2C20484F444C2021" miner-extra-data="0x444F4E27542050414E4943202120484F444C2C20484F444C2C20484F444C2021"
min-gas-price=1 min-gas-price=1
# Pruning
pruning-enabled=true
# Permissioning # Permissioning
permissions-nodes-config-file-enabled=false permissions-nodes-config-file-enabled=false
permissions-nodes-config-file="./permissions_config.toml" permissions-nodes-config-file="./permissions_config.toml"

Loading…
Cancel
Save