From 4c58a8681da1665e10441fca9b482f00fe0a35ad Mon Sep 17 00:00:00 2001 From: Matthew Whitehead Date: Fri, 7 Jun 2024 16:39:22 +0100 Subject: [PATCH] Add more logs --- CHANGELOG.md | 1 + .../main/java/org/hyperledger/besu/cli/BesuCommand.java | 4 ++-- .../hyperledger/besu/controller/BesuControllerBuilder.java | 4 +++- .../besu/consensus/qbft/BFTPivotSelectorFromPeers.java | 7 +++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5348456dd0..ff60515526e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Default bonsai to use full-flat db and code-storage-by-code-hash [#6984](https://github.com/hyperledger/besu/pull/6894) - New RPC methods miner_setExtraData and miner_getExtraData [#7078](https://github.com/hyperledger/besu/pull/7078) - Disconnect peers that have multiple discovery ports since they give us bad neighbours [#7089](https://github.com/hyperledger/besu/pull/7089) +- `--Xsnapsync-bft-enabled` option enables experimental support for snap sync with IBFT/QBFT permissioned chains [#7140](https://github.com/hyperledger/besu/pull/7140) ### Bug fixes - Fix parsing `gasLimit` parameter when its value is > `Long.MAX_VALUE` [#7116](https://github.com/hyperledger/besu/pull/7116) 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 1ac480d738c..bb7c25d75f3 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -1506,11 +1506,11 @@ private void validateOptions() { } private void validateConsensusSyncCompatibilityOptions() { - // snap and checkpoint can't be used with BFT but can for clique + // snap and checkpoint are experimental for BFT if ((genesisConfigOptionsSupplier.get().isIbftLegacy() || genesisConfigOptionsSupplier.get().isIbft2() || genesisConfigOptionsSupplier.get().isQbft()) - && genesisConfigOptionsSupplier.get().isEthHash()) { + && !unstableSynchronizerOptions.isSnapSyncBftEnabled()) { final String errorSuffix = "can't be used with BFT networks"; if (SyncMode.CHECKPOINT.equals(syncMode) || SyncMode.X_CHECKPOINT.equals(syncMode)) { throw new ParameterException( diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java index a6a3555a9f5..29f945f5f91 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -837,7 +837,9 @@ private PivotBlockSelector createPivotSelector( final MetricsSystem metricsSystem) { if (genesisConfigOptions.isQbft() || genesisConfigOptions.isIbft2()) { - LOG.info("QBFT is configured, creating initial sync for BFT"); + LOG.info( + "{} is configured, creating initial sync for BFT", + genesisConfigOptions.getConsensusEngine().toUpperCase()); return new BFTPivotSelectorFromPeers( ethContext, syncConfig, syncState, metricsSystem, protocolContext, nodeKey); } else if (genesisConfigOptions.getTerminalTotalDifficulty().isPresent()) { diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/BFTPivotSelectorFromPeers.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/BFTPivotSelectorFromPeers.java index 61034dd990c..9092e836a7f 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/BFTPivotSelectorFromPeers.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/BFTPivotSelectorFromPeers.java @@ -67,6 +67,9 @@ public Optional selectNewPivotBlock() { // pivot distance if (bestPeer.get().chainState().getEstimatedHeight() <= syncConfig.getFastSyncPivotDistance()) { + LOG.info( + "Best peer for sync found but chain height hasn't reached minimum sync pivot distance {}, exiting sync process", + syncConfig.getFastSyncPivotDistance()); throw new NoSyncRequiredException(); } @@ -78,6 +81,7 @@ public Optional selectNewPivotBlock() { && validatorProvider .getValidatorsAtHead() .contains(Util.publicKeyToAddress(nodeKey.getPublicKey()))) { + LOG.info("This node is the only BFT validator, exiting sync process"); throw new NoSyncRequiredException(); } @@ -105,6 +109,9 @@ public Optional selectNewPivotBlock() { // assume this is a new chain // and skip waiting for any more peers to sync with. The worst case is this puts us into // full sync mode. + LOG.info( + "Peered with {} validators but no best peer found to sync from. Assuming new BFT chain, exiting sync process", + peerValidatorCount.get()); throw new NoSyncRequiredException(); } }