Prevent startup with privacy and bonsai enabled (#6809)

* prevent startup with bonsai and privacy

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

* tests for privacy specify forest

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

* changelog

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/6846/head
Sally MacFarlane 8 months ago committed by GitHub
parent 6c1991a075
commit ad49e21bf0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 3
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  3. 32
      besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java

@ -27,6 +27,7 @@
- Extend error handling of plugin RPC methods [#6759](https://github.com/hyperledger/besu/pull/6759)
- Added engine_newPayloadV4 and engine_getPayloadV4 methods [#6783](https://github.com/hyperledger/besu/pull/6783)
- Reduce storage size of receipts [#6602](https://github.com/hyperledger/besu/pull/6602)
- Prevent startup with BONSAI and privacy enabled [#6809](https://github.com/hyperledger/besu/pull/6809)
### Bug fixes
- Fix txpool dump/restore race condition [#6665](https://github.com/hyperledger/besu/pull/6665)

@ -1979,6 +1979,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
throw new ParameterException(
commandLine, String.format("%s %s", "Checkpoint sync", errorSuffix));
}
if (getDataStorageConfiguration().getDataStorageFormat().equals(DataStorageFormat.BONSAI)) {
throw new ParameterException(commandLine, String.format("%s %s", "Bonsai", errorSuffix));
}
if (isPruningEnabled()) {
throw new ParameterException(commandLine, String.format("%s %s", "Pruning", errorSuffix));
}

@ -30,6 +30,9 @@ import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.junit.jupiter.api.Test;
@ -192,6 +195,26 @@ public class PrivacyOptionsTest extends CommandTestAbstract {
assertThat(commandOutput.toString(UTF_8)).isEmpty();
}
@Test
public void privacyWithBonsaiDefaultMustError() {
// bypass overridden parseCommand method which specifies bonsai
super.parseCommand("--privacy-enabled");
assertThat(commandErrorOutput.toString(UTF_8))
.contains("Bonsai cannot be enabled with privacy.");
assertThat(commandOutput.toString(UTF_8)).isEmpty();
}
@Test
public void privacyWithBonsaiExplicitMustError() {
// bypass overridden parseCommand method which specifies bonsai
super.parseCommand("--privacy-enabled", "--data-storage-format", "BONSAI");
assertThat(commandErrorOutput.toString(UTF_8))
.contains("Bonsai cannot be enabled with privacy.");
assertThat(commandOutput.toString(UTF_8)).isEmpty();
}
@Test
public void privacyWithPruningMustError() {
parseCommand("--pruning-enabled", "--privacy-enabled");
@ -483,4 +506,13 @@ public class PrivacyOptionsTest extends CommandTestAbstract {
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Override
protected TestBesuCommand parseCommand(final String... args) {
// privacy requires forest to be specified
final List<String> argsPlusForest = new ArrayList<>(Arrays.stream(args).toList());
argsPlusForest.add("--data-storage-format");
argsPlusForest.add("FOREST");
return super.parseCommand(argsPlusForest.toArray(String[]::new));
}
}

Loading…
Cancel
Save