Skip to content
/ besu Public
forked from hyperledger/besu

Commit

Permalink
Prevent startup with privacy and bonsai enabled (hyperledger#6809)
Browse files Browse the repository at this point in the history
* 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>
Signed-off-by: amsmota <antonio.mota@citi.com>
  • Loading branch information
macfarla authored and amsmota committed Apr 16, 2024
1 parent 298340c commit ced9302
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
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));
}
}

0 comments on commit ced9302

Please sign in to comment.