Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
pinges committed Jan 31, 2024
2 parents 549c8e0 + d47e526 commit 10efe34
Show file tree
Hide file tree
Showing 29 changed files with 62 additions and 60 deletions.
2 changes: 0 additions & 2 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,6 @@ static class MetricsOptionGroup {

@Option(
names = {"--pruning-blocks-retained"},
defaultValue = "1024",
paramLabel = "<INTEGER>",
description =
"Minimum number of recent blocks for which to keep entire world state (default: ${DEFAULT-VALUE})",
Expand All @@ -847,7 +846,6 @@ static class MetricsOptionGroup {

@Option(
names = {"--pruning-block-confirmations"},
defaultValue = "10",
paramLabel = "<INTEGER>",
description =
"Minimum number of confirmations on a block before marking begins (default: ${DEFAULT-VALUE})",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public static EvmOptions create() {
"size in kilobytes to allow the cache "
+ "of valid jump destinations to grow to before evicting the least recently used entry",
fallbackValue = "32000",
defaultValue = "32000",
hidden = true,
arity = "1")
private Long jumpDestCacheWeightKilobytes =
Expand All @@ -57,7 +56,6 @@ public static EvmOptions create() {
names = {WORLDSTATE_UPDATE_MODE},
description = "How to handle worldstate updates within a transaction",
fallbackValue = "STACKED",
defaultValue = "STACKED",
hidden = true,
arity = "1")
private EvmConfiguration.WorldUpdaterMode worldstateUpdateMode =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class MetricsCLIOptions implements CLIOptions<MetricsConfiguration.Builde
@CommandLine.Option(
names = TIMERS_ENABLED_FLAG,
hidden = true,
defaultValue = "true",
description = "Whether to enable timer metrics (default: ${DEFAULT-VALUE}).")
private Boolean timersEnabled = MetricsConfiguration.DEFAULT_METRICS_TIMERS_ENABLED;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class NetworkingOptions implements CLIOptions<NetworkingConfiguration> {
@CommandLine.Option(
names = INITIATE_CONNECTIONS_FREQUENCY_FLAG,
hidden = true,
defaultValue = "30",
paramLabel = "<INTEGER>",
description =
"The frequency (in seconds) at which to initiate new outgoing connections (default: ${DEFAULT-VALUE})")
Expand All @@ -52,7 +51,6 @@ public class NetworkingOptions implements CLIOptions<NetworkingConfiguration> {
@CommandLine.Option(
names = CHECK_MAINTAINED_CONNECTIONS_FREQUENCY_FLAG,
hidden = true,
defaultValue = "60",
paramLabel = "<INTEGER>",
description =
"The frequency (in seconds) at which to check maintained connections (default: ${DEFAULT-VALUE})")
Expand All @@ -69,14 +67,12 @@ public class NetworkingOptions implements CLIOptions<NetworkingConfiguration> {
@CommandLine.Option(
names = DISCOVERY_PROTOCOL_V5_ENABLED,
hidden = true,
defaultValue = "false",
description = "Whether to enable P2P Discovery Protocol v5 (default: ${DEFAULT-VALUE})")
private final Boolean isPeerDiscoveryV5Enabled = false;

@CommandLine.Option(
names = FILTER_ON_ENR_FORK_ID,
hidden = true,
defaultValue = "true",
description = "Whether to enable filtering of peers based on the ENR field ForkId)")
private final Boolean filterOnEnrForkId = NetworkingConfiguration.DEFAULT_FILTER_ON_ENR_FORK_ID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public void removeChainEstimatedHeightListener(final long listenerId) {
public void recordRequestTimeout(final int requestCode) {
LOG.atDebug()
.setMessage("Timed out while waiting for response from peer {}...")
.addArgument(this::getShortNodeId)
.addArgument(this::getLoggableId)
.log();
LOG.trace("Timed out while waiting for response from peer {}", this);
reputation.recordRequestTimeout(requestCode).ifPresent(this::disconnect);
Expand All @@ -222,7 +222,7 @@ public void recordUselessResponse(final String requestType) {
LOG.atTrace()
.setMessage("Received useless response for request type {} from peer {}...")
.addArgument(requestType)
.addArgument(this::getShortNodeId)
.addArgument(this::getLoggableId)
.log();
reputation.recordUselessResponse(System.currentTimeMillis()).ifPresent(this::disconnect);
}
Expand Down Expand Up @@ -264,7 +264,7 @@ public RequestManager.ResponseStream send(
LOG.atDebug()
.setMessage("Protocol {} unavailable for this peer {}...")
.addArgument(protocolName)
.addArgument(this.getShortNodeId())
.addArgument(this.getLoggableId())
.log();
return null;
}
Expand All @@ -274,7 +274,7 @@ public RequestManager.ResponseStream send(
LOG.info(
"Permissioning blocked sending of message code {} to {}...",
messageData.getCode(),
this.getShortNodeId());
this.getLoggableId());
if (LOG.isDebugEnabled()) {
LOG.debug(
"Permissioning blocked by providers {}",
Expand Down Expand Up @@ -608,7 +608,7 @@ public boolean hasSupportForMessage(final int messageCode) {
public String toString() {
return String.format(
"PeerId: %s... %s, validated? %s, disconnected? %s, client: %s, %s, %s",
getShortNodeId(),
getLoggableId(),
reputation,
isFullyValidated(),
isDisconnected(),
Expand All @@ -618,8 +618,9 @@ public String toString() {
}

@Nonnull
public String getShortNodeId() {
return nodeId().toString().substring(0, 20);
public String getLoggableId() {
// 8 bytes plus the 0x prefix is 18 characters
return nodeId().toString().substring(0, 18) + "...";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private boolean registerDisconnect(
if (peer.getReputation().getScore() > USEFULL_PEER_SCORE_THRESHOLD) {
LOG.debug("Disconnected USEFULL peer {}", peer);
} else {
LOG.debug("Disconnected EthPeer {}", peer.getShortNodeId());
LOG.debug("Disconnected EthPeer {}", peer.getLoggableId());
}
}
}
Expand Down Expand Up @@ -393,7 +393,7 @@ public void disconnectWorstUselessPeer() {
LOG.atDebug()
.setMessage(
"disconnecting peer {}. Waiting for better peers. Current {} of max {}")
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.addArgument(this::peerCount)
.addArgument(this::getMaxPeers)
.log();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,16 @@ public boolean shouldConnect(final Peer peer, final boolean incoming) {
if (peer.getForkId().map(forkIdManager::peerCheck).orElse(true)) {
LOG.atDebug()
.setMessage("ForkId OK or not available for peer {}")
.addArgument(peer::getId)
.addArgument(peer::getLoggableId)
.log();
if (ethPeers.shouldConnect(peer, incoming)) {
return true;
}
}
LOG.atDebug().setMessage("ForkId check failed for peer {}").addArgument(peer::getId).log();
LOG.atDebug()
.setMessage("ForkId check failed for peer {}")
.addArgument(peer::getLoggableId)
.log();
return false;
}

Expand All @@ -417,10 +420,10 @@ public void handleDisconnect(
final boolean initiatedByPeer) {
if (ethPeers.registerDisconnect(connection)) {
LOG.atDebug()
.setMessage("Disconnect - {} - {} - {}... - {} peers left")
.setMessage("Disconnect - {} - {} - {} - {} peers left")
.addArgument(initiatedByPeer ? "Inbound" : "Outbound")
.addArgument(reason::toString)
.addArgument(() -> connection.getPeer().getId().slice(0, 8))
.addArgument(() -> connection.getPeer().getLoggableId())
.addArgument(ethPeers::peerCount)
.log();
LOG.atTrace().setMessage("{}").addArgument(ethPeers::toString).log();
Expand Down Expand Up @@ -478,7 +481,7 @@ private void handleStatusMessage(final EthPeer peer, final Message message) {
} catch (final RLPException e) {
LOG.atDebug()
.setMessage("Unable to parse status message from peer {}... {}")
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.addArgument(e)
.log();
// Parsing errors can happen when clients broadcast network ids outside the int range,
Expand All @@ -488,7 +491,7 @@ private void handleStatusMessage(final EthPeer peer, final Message message) {
}

private Object getPeerOrPeerId(final EthPeer peer) {
return LOG.isTraceEnabled() ? peer : peer.getShortNodeId();
return LOG.isTraceEnabled() ? peer : peer.getLoggableId();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,19 @@ protected Optional<List<BlockHeader>> processResponse(
final List<BlockHeader> headers = headersMessage.getHeaders(protocolSchedule);
if (headers.isEmpty()) {
// Message contains no data - nothing to do
LOG.debug("headers.isEmpty. Peer: {}", peer.getShortNodeId());
LOG.debug("headers.isEmpty. Peer: {}", peer.getLoggableId());
return Optional.empty();
}
if (headers.size() > count) {
// Too many headers - this isn't our response
LOG.debug("headers.size()>count. Peer: {}", peer.getShortNodeId());
LOG.debug("headers.size()>count. Peer: {}", peer.getLoggableId());
return Optional.empty();
}

final BlockHeader firstHeader = headers.get(0);
if (!matchesFirstHeader(firstHeader)) {
// This isn't our message - nothing to do
LOG.debug("!matchesFirstHeader. Peer: {}", peer.getShortNodeId());
LOG.debug("!matchesFirstHeader. Peer: {}", peer.getLoggableId());
return Optional.empty();
}

Expand All @@ -100,7 +100,7 @@ protected Optional<List<BlockHeader>> processResponse(
header = headers.get(i);
if (header.getNumber() != prevBlockHeader.getNumber() + expectedDelta) {
// Skip doesn't match, this isn't our data
LOG.debug("header not matching the expected number. Peer: {}", peer.getShortNodeId());
LOG.debug("header not matching the expected number. Peer: {}", peer.getLoggableId());
return Optional.empty();
}
// if headers are supposed to be sequential check if a chain is formed
Expand All @@ -110,7 +110,7 @@ protected Optional<List<BlockHeader>> processResponse(
if (!parent.getHash().equals(child.getParentHash())) {
LOG.debug(
"Sequential headers must form a chain through hashes (BREACH_OF_PROTOCOL), disconnecting peer: {}",
peer.getShortNodeId());
peer.getLoggableId());
peer.disconnect(DisconnectMessage.DisconnectReason.BREACH_OF_PROTOCOL);
return Optional.empty();
}
Expand All @@ -129,7 +129,7 @@ protected Optional<List<BlockHeader>> processResponse(
.setMessage("Received {} of {} headers requested from peer {}...")
.addArgument(headersList::size)
.addArgument(count)
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.log();
return Optional.of(headersList);
}
Expand All @@ -138,7 +138,7 @@ private void updatePeerChainState(final EthPeer peer, final BlockHeader blockHea
if (blockHeader.getNumber() > peer.chainState().getEstimatedHeight()) {
LOG.atTrace()
.setMessage("Updating chain state for peer {}... to block header {}")
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.addArgument(blockHeader::toLogString)
.log();
peer.chainState().update(blockHeader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void handleMessage(
// Peer sent us malformed data - disconnect
LOG.debug(
"Disconnecting with BREACH_OF_PROTOCOL due to malformed message: {}",
peer.getShortNodeId(),
peer.getLoggableId(),
e);
LOG.trace("Peer {} Malformed message data: {}", peer, message.getData());
peer.disconnect(DisconnectReason.BREACH_OF_PROTOCOL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private void refreshPeers() {
LOG.atDebug()
.setMessage(
"Refresh peers disconnecting peer {} Waiting for better peers. Current {} of max {}")
.addArgument(peer::toString)
.addArgument(peer::getLoggableId)
.addArgument(peers::peerCount)
.addArgument(peers::getMaxPeers)
.log();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void requestTransactions() {
.setMessage("Got {} transactions of {} hashes requested from peer {}...")
.addArgument(retrievedTransactions::size)
.addArgument(task.getTransactionHashes()::size)
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.log();

transactionPool.addRemoteTransactions(retrievedTransactions);
Expand Down Expand Up @@ -121,7 +121,7 @@ private List<Hash> getTxHashesAnnounced() {
LOG.atTrace()
.setMessage(
"Transaction hashes to request from peer {}... fresh count {}, already seen count {}")
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.addArgument(toRetrieve::size)
.addArgument(alreadySeenCount)
.log();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected PendingPeerRequest sendRequest() {
.setMessage("Requesting {} headers (hash {}...) from peer {}...")
.addArgument(count)
.addArgument(referenceHash.slice(0, 6))
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.log();
return peer.getHeadersByHash(referenceHash, count, skip, reverse);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected PendingPeerRequest sendRequest() {
.setMessage("Requesting {} headers (blockNumber {}) from peer {}.")
.addArgument(count)
.addArgument(blockNumber)
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.log();
return peer.getHeadersByNumber(blockNumber, count, skip, reverse);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected PendingPeerRequest sendRequest() {
LOG.atTrace()
.setMessage("Requesting {} node data entries from peer {}...")
.addArgument(hashes::size)
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.log();
return peer.getNodeData(hashes);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected PendingPeerRequest sendRequest() {
LOG.atTrace()
.setMessage("Requesting {} transaction pool entries from peer {}...")
.addArgument(hashes::size)
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.log();
return peer.getPooledTransactions(new ArrayList<>(hashes));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected PendingPeerRequest sendRequest() {
LOG.atTrace()
.setMessage("Requesting {} receipts from peer {}...")
.addArgument(blockHeaders::size)
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.log();
return peer.getReceipts(blockHashes);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected CompletableFuture<PeerTaskResult<List<Block>>> executeTaskOnCurrentPee
if (peerResult.getResult().isEmpty()) {
currentPeer.recordUselessResponse("GetBodiesFromPeerTask");
throw new IncompleteResultsException(
"No blocks returned by peer " + currentPeer.getShortNodeId());
"No blocks returned by peer " + currentPeer.getLoggableId());
}

result.complete(peerResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected CompletableFuture<List<BlockHeader>> executeTaskOnCurrentPeer(
"No block headers for hash "
+ referenceHash
+ " returned by peer "
+ currentPeer.getShortNodeId());
+ currentPeer.getLoggableId());
}
result.complete(peerResult.getResult());
return peerResult.getResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static void trackChainHeadForPeers(
public void onPeerConnected(final EthPeer peer) {
LOG.atDebug()
.setMessage("Requesting chain head info from {}...")
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.log();
GetHeadersFromPeerByHashTask.forSingleHash(
protocolSchedule,
Expand All @@ -92,12 +92,12 @@ public void onPeerConnected(final EthPeer peer) {
+ " ("
+ chainHeadHeader.getBlockHash()
+ ")")
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.log();
} else {
LOG.atDebug()
.setMessage("Failed to retrieve chain head info. Disconnecting {}... {}")
.addArgument(peer::getShortNodeId)
.addArgument(peer::getLoggableId)
.addArgument(error)
.log();
peer.disconnect(DisconnectReason.USELESS_PEER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void enforceTrailingPeerLimit() {
"Enforcing trailing peers limit (min height {}, max trailing peers {}) by disconnecting {}... with height {}")
.addArgument(minimumHeightToBeUpToDate)
.addArgument(maxTrailingPeers)
.addArgument(peerToDisconnect::getShortNodeId)
.addArgument(peerToDisconnect::getLoggableId)
.addArgument(
peerToDisconnect.chainState() == null
? "(no chain state)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private long countPeersThatCanDeterminePivotBlock() {
private boolean canPeerDeterminePivotBlock(final EthPeer peer) {
LOG.debug(
"peer {} hasEstimatedHeight {} isFullyValidated? {}",
peer.getShortNodeId(),
peer.getLoggableId(),
peer.chainState().hasEstimatedHeight(),
peer.isFullyValidated());
return peer.chainState().hasEstimatedHeight() && peer.isFullyValidated();
Expand Down
Loading

0 comments on commit 10efe34

Please sign in to comment.