diff --git a/CHANGELOG.md b/CHANGELOG.md index 379c87ee08..5bcbfa51b7 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 41402fa04b..c8c0eaf6ab 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -2701,7 +2701,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable { builder .setDataStorage(dataStorageOptions.normalizeDataStorageFormat()) - .setSyncMode(syncMode.normalize()); + .setSyncMode(syncMode.normalize()) + .setSyncMinPeers(syncMinPeerCount); if (jsonRpcConfiguration != null && jsonRpcConfiguration.isEnabled()) { builder @@ -2738,6 +2739,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { 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 b2f89a349e..fc11ed84f8 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java @@ -46,6 +46,7 @@ public class ConfigurationOverviewBuilder { private String customGenesisFileName; private String dataStorage; private String syncMode; + private Integer syncMinPeers; private Integer rpcPort; private Collection rpcHttpApis; private Integer enginePort; @@ -57,6 +58,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; @@ -148,6 +150,17 @@ public class ConfigurationOverviewBuilder { return this; } + /** + * Sets sync min peers. + * + * @param syncMinPeers number of min peers for sync + * @return the builder + */ + public ConfigurationOverviewBuilder setSyncMinPeers(final int syncMinPeers) { + this.syncMinPeers = syncMinPeers; + return this; + } + /** * Sets rpc port. * @@ -245,6 +258,18 @@ public class ConfigurationOverviewBuilder { 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 * @@ -340,6 +365,10 @@ public class ConfigurationOverviewBuilder { lines.add("Sync mode: " + syncMode); } + if (syncMinPeers != null) { + lines.add("Sync min peers: " + syncMinPeers); + } + if (rpcHttpApis != null) { lines.add("RPC HTTP APIs: " + String.join(",", rpcHttpApis)); } @@ -373,6 +402,10 @@ public class ConfigurationOverviewBuilder { 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 816d9df00a..e8a330c2ef 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