7632 - add sync-min-peers to log and config overview (#7732)

add sync-min-peers to log and config overview
Signed-off-by: Kevin King <kevin.king@consensys.net>
pull/7740/head
kingnhcomcast 2 months ago committed by GitHub
parent a7e1f6ace0
commit 1ce28daca5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  2. 16
      besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java
  3. 10
      besu/src/test/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilderTest.java
  4. 12
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncTargetManager.java
  5. 5
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManager.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

@ -46,6 +46,7 @@ public class ConfigurationOverviewBuilder {
private String customGenesisFileName;
private String dataStorage;
private String syncMode;
private Integer syncMinPeers;
private Integer rpcPort;
private Collection<String> rpcHttpApis;
private Integer enginePort;
@ -149,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.
*
@ -353,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));
}

@ -95,6 +95,16 @@ class ConfigurationOverviewBuilderTest {
assertThat(syncModeSet).contains("Sync mode: fast");
}
@Test
void setSyncMinPeers() {
final String noSyncMinPeersSet = builder.build();
assertThat(noSyncMinPeersSet).doesNotContain("Sync min peers:");
builder.setSyncMinPeers(3);
final String syncMinPeersSet = builder.build();
assertThat(syncMinPeersSet).contains("Sync min peers: 3");
}
@Test
void setRpcPort() {
final String noRpcPortSet = builder.build();

@ -47,6 +47,7 @@ public class SyncTargetManager extends AbstractSyncTargetManager {
private static final int LOG_INFO_REPEAT_DELAY = 120;
private static final int SECONDS_PER_REQUEST = 6; // 5s per request + 1s wait between retries
private final SynchronizerConfiguration config;
private final WorldStateStorageCoordinator worldStateStorageCoordinator;
private final ProtocolSchedule protocolSchedule;
private final ProtocolContext protocolContext;
@ -65,6 +66,7 @@ public class SyncTargetManager extends AbstractSyncTargetManager {
final MetricsSystem metricsSystem,
final FastSyncState fastSyncState) {
super(config, protocolSchedule, protocolContext, ethContext, metricsSystem);
this.config = config;
this.worldStateStorageCoordinator = worldStateStorageCoordinator;
this.protocolSchedule = protocolSchedule;
this.protocolContext = protocolContext;
@ -82,15 +84,17 @@ public class SyncTargetManager extends AbstractSyncTargetManager {
throttledLog(
LOG::debug,
String.format(
"Unable to find sync target. Currently checking %d peers for usefulness. Pivot block: %d",
ethContext.getEthPeers().peerCount(), pivotBlockHeader.getNumber()),
"Unable to find sync target. Waiting for %d peers minimum. Currently checking %d peers for usefulness. Pivot block: %d",
config.getSyncMinimumPeerCount(),
ethContext.getEthPeers().peerCount(),
pivotBlockHeader.getNumber()),
logDebug,
LOG_DEBUG_REPEAT_DELAY);
throttledLog(
LOG::info,
String.format(
"Unable to find sync target. Currently checking %d peers for usefulness.",
ethContext.getEthPeers().peerCount()),
"Unable to find sync target. Waiting for %d peers minimum. Currently checking %d peers for usefulness.",
config.getSyncMinimumPeerCount(), ethContext.getEthPeers().peerCount()),
logInfo,
LOG_INFO_REPEAT_DELAY);
return completedFuture(Optional.empty());

@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory;
class FullSyncTargetManager extends AbstractSyncTargetManager {
private static final Logger LOG = LoggerFactory.getLogger(FullSyncTargetManager.class);
private final SynchronizerConfiguration config;
private final ProtocolContext protocolContext;
private final EthContext ethContext;
private final SyncTerminationCondition terminationCondition;
@ -49,6 +50,7 @@ class FullSyncTargetManager extends AbstractSyncTargetManager {
final MetricsSystem metricsSystem,
final SyncTerminationCondition terminationCondition) {
super(config, protocolSchedule, protocolContext, ethContext, metricsSystem);
this.config = config;
this.protocolContext = protocolContext;
this.ethContext = ethContext;
this.terminationCondition = terminationCondition;
@ -77,7 +79,8 @@ class FullSyncTargetManager extends AbstractSyncTargetManager {
final Optional<EthPeer> maybeBestPeer = ethContext.getEthPeers().bestPeerWithHeightEstimate();
if (!maybeBestPeer.isPresent()) {
LOG.info(
"Unable to find sync target. Currently checking {} peers for usefulness",
"Unable to find sync target. Waiting for {} peers minimum. Currently checking {} peers for usefulness",
config.getSyncMinimumPeerCount(),
ethContext.getEthPeers().peerCount());
return completedFuture(Optional.empty());
} else {

Loading…
Cancel
Save