diff --git a/CHANGELOG.md b/CHANGELOG.md index 306cc8b26d1..92afdaf8877 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) 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 901c2cf2629..023133f7ae2 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -1979,6 +1979,9 @@ private PrivacyParameters privacyParameters() { 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)); } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java index 84988aa2f09..3485e527be3 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java @@ -30,6 +30,9 @@ 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 void privacyWithCheckpointSyncMustError() { 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 void eeaWsApisWithPrivacyDisabledLogsWarning() { 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 argsPlusForest = new ArrayList<>(Arrays.stream(args).toList()); + argsPlusForest.add("--data-storage-format"); + argsPlusForest.add("FOREST"); + return super.parseCommand(argsPlusForest.toArray(String[]::new)); + } }