mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-09 22:07:59 -05:00
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>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user