From 21e95a9efbdb95e7f70dfe5d89e76956c642c06e Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Fri, 4 Oct 2024 19:27:14 +1000 Subject: [PATCH 1/5] add correct default to rpcHost (#7725) --------- Signed-off-by: Sally MacFarlane Co-authored-by: Simon Dudley --- .../besu/cli/options/stable/JsonRpcHttpOptions.java | 3 ++- .../test/java/org/hyperledger/besu/cli/BesuCommandTest.java | 6 ++++++ .../besu/ethereum/api/jsonrpc/JsonRpcConfiguration.java | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java index 1c7e0f543e9..7d08a6f9aa6 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.cli.options.stable; import static java.util.Arrays.asList; +import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_HOST; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_PORT; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_PRETTY_JSON_ENABLED; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_RPC_APIS; @@ -65,7 +66,7 @@ public class JsonRpcHttpOptions { paramLabel = DefaultCommandValues.MANDATORY_HOST_FORMAT_HELP, description = "Host for JSON-RPC HTTP to listen on (default: ${DEFAULT-VALUE})", arity = "1") - private String rpcHttpHost; + private String rpcHttpHost = DEFAULT_JSON_RPC_HOST; @CommandLine.Option( names = {"--rpc-http-port"}, diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index d63ffef7fa6..de209f65e4d 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -1029,6 +1029,12 @@ public void p2pHostAndPortOptionsAreRespected() { assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); + + // rpc host should remain default ie 127.0.0.1 + verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); + verify(mockRunnerBuilder).build(); + + assertThat(jsonRpcConfigArgumentCaptor.getValue().getHost()).isEqualTo("127.0.0.1"); } @Test diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcConfiguration.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcConfiguration.java index 2ed9c56d540..726e205d1c6 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcConfiguration.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcConfiguration.java @@ -32,7 +32,7 @@ import com.google.common.base.MoreObjects; public class JsonRpcConfiguration { - private static final String DEFAULT_JSON_RPC_HOST = "127.0.0.1"; + public static final String DEFAULT_JSON_RPC_HOST = "127.0.0.1"; public static final int DEFAULT_JSON_RPC_PORT = 8545; public static final int DEFAULT_ENGINE_JSON_RPC_PORT = 8551; public static final int DEFAULT_MAX_ACTIVE_CONNECTIONS = 80; From a7e1f6ace0167bbaff89f00f7a0e94747160a06b Mon Sep 17 00:00:00 2001 From: kingnhcomcast <114761064+kingnhcomcast@users.noreply.github.com> Date: Mon, 7 Oct 2024 12:46:58 -0400 Subject: [PATCH 2/5] 7536 use head for snap sync (#7718) * Add support to sync to head instead of safe block during snapsync Signed-off-by: Kevin King Signed-off-by: kingnhcomcast <114761064+kingnhcomcast@users.noreply.github.com> --- CHANGELOG.md | 3 +- .../org/hyperledger/besu/cli/BesuCommand.java | 1 + .../cli/ConfigurationOverviewBuilder.java | 17 ++ .../options/unstable/SynchronizerOptions.java | 26 ++- .../controller/BesuControllerBuilder.java | 30 +++- .../MergeBesuControllerBuilderTest.java | 39 +++- .../sync/fastsync/PivotSelectorFromBlock.java | 167 ++++++++++++++++++ .../fastsync/PivotSelectorFromHeadBlock.java | 58 ++++++ .../fastsync/PivotSelectorFromSafeBlock.java | 138 ++------------- .../sync/snapsync/SnapSyncConfiguration.java | 7 + .../sync/snapsync/SnapSyncMetricsManager.java | 4 +- .../sync/fastsync/FastSyncActionsTest.java | 52 +++++- 12 files changed, 408 insertions(+), 134 deletions(-) create mode 100644 ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotSelectorFromBlock.java create mode 100644 ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotSelectorFromHeadBlock.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 379c87ee08c..5bcbfa51b7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,8 @@ - Add configuration of Consolidation Request Contract Address via genesis configuration [#7647](https://github.com/hyperledger/besu/pull/7647) - Interrupt pending transaction processing on block creation timeout [#7673](https://github.com/hyperledger/besu/pull/7673) - Align gas cap calculation for transaction simulation to Geth approach [#7703](https://github.com/hyperledger/besu/pull/7703) -- Expose chainId in the `BlockchainService` [#7702](https://github.com/hyperledger/besu/pull/7702) +- Expose chainId in the `BlockchainService` [7702](https://github.com/hyperledger/besu/pull/7702) +- Use head block instead of safe block for snap sync [7536](https://github.com/hyperledger/besu/issues/7536) - Add support for `chainId` in `CallParameters` [#7720](https://github.com/hyperledger/besu/pull/7720) ### Bug fixes 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 41402fa04b3..125cf3435c5 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -2738,6 +2738,7 @@ && getDataStorageConfiguration().getBonsaiLimitTrieLogsEnabled()) { builder.setSnapServerEnabled(this.unstableSynchronizerOptions.isSnapsyncServerEnabled()); builder.setSnapSyncBftEnabled(this.unstableSynchronizerOptions.isSnapSyncBftEnabled()); + builder.setSnapSyncToHeadEnabled(this.unstableSynchronizerOptions.isSnapSyncToHeadEnabled()); 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 b2f89a349e2..8cb815e7702 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java @@ -57,6 +57,7 @@ public class ConfigurationOverviewBuilder { private Integer trieLogsPruningWindowSize = null; private boolean isSnapServerEnabled = false; private boolean isSnapSyncBftEnabled = false; + private boolean isSnapSyncToHeadEnabled = true; private TransactionPoolConfiguration.Implementation txPoolImplementation; private EvmConfiguration.WorldUpdaterMode worldStateUpdateMode; private Map environment; @@ -245,6 +246,18 @@ public ConfigurationOverviewBuilder setSnapSyncBftEnabled(final boolean snapSync return this; } + /** + * Sets snap sync to head enabled/disabled + * + * @param snapSyncToHeadEnabled bool to indicate if snap sync to head is enabled + * @return the builder + */ + public ConfigurationOverviewBuilder setSnapSyncToHeadEnabled( + final boolean snapSyncToHeadEnabled) { + isSnapSyncToHeadEnabled = snapSyncToHeadEnabled; + return this; + } + /** * Sets trie logs pruning window size * @@ -373,6 +386,10 @@ public String build() { lines.add("Experimental Snap Sync for BFT enabled"); } + if (isSnapSyncToHeadEnabled) { + lines.add("Snap Sync to Head 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 816d9df00a1..e8a330c2eff 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 @@ -87,6 +87,8 @@ public class SynchronizerOptions implements CLIOptions