From 1bc1ff7c497d48b682313229a4b6c9e2b67f8026 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 26 Mar 2024 17:42:53 +1000 Subject: [PATCH 1/3] prevent startup with bonsai and privacy Signed-off-by: Sally MacFarlane --- .../main/java/org/hyperledger/besu/cli/BesuCommand.java | 3 +++ .../org/hyperledger/besu/cli/PrivacyOptionsTest.java | 9 +++++++++ 2 files changed, 12 insertions(+) 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 c993dda3d04..6f9e41b752e 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..e172b4ebd18 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java @@ -192,6 +192,15 @@ public void privacyWithCheckpointSyncMustError() { assertThat(commandOutput.toString(UTF_8)).isEmpty(); } + @Test + public void privacyWithBonsaiMustError() { + parseCommand("--privacy-enabled"); + + 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"); From 7b3f73e79249c6c8300e86c6bce44130bd0b23a4 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 26 Mar 2024 18:29:37 +1000 Subject: [PATCH 2/3] tests for privacy specify forest Signed-off-by: Sally MacFarlane --- .../besu/cli/PrivacyOptionsTest.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) 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 e172b4ebd18..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; @@ -193,8 +196,19 @@ public void privacyWithCheckpointSyncMustError() { } @Test - public void privacyWithBonsaiMustError() { - parseCommand("--privacy-enabled"); + 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."); @@ -492,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)); + } } From 58726a12df4ca71762757bc1fd477d4179bb3abd Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 26 Mar 2024 19:08:15 +1000 Subject: [PATCH 3/3] changelog Signed-off-by: Sally MacFarlane --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bacbc88d070..c220024de36 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)