From 80eb1ac9e9e8c6a41a215b42ab9f288f50928185 Mon Sep 17 00:00:00 2001 From: garyschulte Date: Fri, 15 Mar 2024 17:10:13 -0700 Subject: [PATCH] add snapserver experimental flag, refactor snap server start Signed-off-by: garyschulte --- .../org/hyperledger/besu/cli/BesuCommand.java | 2 + .../cli/ConfigurationOverviewBuilder.java | 16 ++ .../options/unstable/SynchronizerOptions.java | 22 ++- .../controller/BesuControllerBuilder.java | 14 +- .../bonsai/storage/flat/FlatDbStrategy.java | 4 + .../storage/flat/FlatDbStrategyProvider.java | 2 +- .../worldstate/DataStorageConfiguration.java | 12 -- .../WorldStateStorageCoordinator.java | 5 + .../ethereum/eth/manager/snap/SnapServer.java | 153 +++++++++--------- .../sync/snapsync/SnapSyncConfiguration.java | 7 + .../eth/manager/snap/SnapServerTest.java | 35 +++- 11 files changed, 174 insertions(+), 98 deletions(-) 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 d5b6468a90c..4baf1e15ef8 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -2778,6 +2778,8 @@ private String generateConfigurationOverview() { getDataStorageConfiguration().getUnstable().getBonsaiTrieLogPruningWindowSize()); } + builder.setSnapServerEnabled(this.unstableSynchronizerOptions.isSnapsyncServerEnabled()); + builder.setTxPoolImplementation(buildTransactionPoolConfiguration().getTxPoolImplementation()); builder.setWorldStateUpdateMode(unstableEvmOptions.toDomainObject().worldUpdaterMode()); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java index bf03c675d8d..51c88798158 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java @@ -55,6 +55,7 @@ public class ConfigurationOverviewBuilder { private boolean isBonsaiLimitTrieLogsEnabled = false; private long trieLogRetentionLimit = 0; private Integer trieLogsPruningWindowSize = null; + private boolean isSnapServerEnabled = false; private TransactionPoolConfiguration.Implementation txPoolImplementation; private EvmConfiguration.WorldUpdaterMode worldStateUpdateMode; private Map environment; @@ -219,6 +220,17 @@ public ConfigurationOverviewBuilder setTrieLogRetentionLimit(final long limit) { return this; } + /** + * Sets snap server enabled/disabled + * + * @param snapServerEnabled bool to indicate if is snap server is enabled + * @return the builder + */ + public ConfigurationOverviewBuilder setSnapServerEnabled(final boolean snapServerEnabled) { + isSnapServerEnabled = snapServerEnabled; + return this; + } + /** * Sets trie logs pruning window size * @@ -339,6 +351,10 @@ public String build() { lines.add("Using " + worldStateUpdateMode + " worldstate update mode"); + if (isSnapServerEnabled) { + lines.add("Experimental Snap Sync server enabled"); + } + if (isBonsaiLimitTrieLogsEnabled) { final StringBuilder trieLogPruningString = new StringBuilder(); trieLogPruningString diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java index 7c9de815797..82393adbcf5 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java @@ -82,6 +82,8 @@ public class SynchronizerOptions implements CLIOptions