Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent startup with privacy and bonsai enabled #6809

Merged
merged 6 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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<String> argsPlusForest = new ArrayList<>(Arrays.stream(args).toList());
argsPlusForest.add("--data-storage-format");
argsPlusForest.add("FOREST");
return super.parseCommand(argsPlusForest.toArray(String[]::new));
}
}
Loading