Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ethstats support #1239

Merged
merged 18 commits into from
Aug 4, 2020
Merged

Add ethstats support #1239

merged 18 commits into from
Aug 4, 2020

Conversation

matkt
Copy link
Contributor

@matkt matkt commented Jul 20, 2020

PR description

Added support for ethstat in Besu. To send stats you have to start Besu with

--Xethstats=node-name:secret@host:port --Xethstats-contact=karim.taam@consensys.net

Support with or without SSL

Tested

Fixed Issue(s)

matkt added 10 commits July 20, 2020 18:15
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
@matkt matkt marked this pull request as ready for review July 20, 2020 17:54
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

public class AuthenticationData {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this and the other object be created using the Immutables framework? There are some special annotations for immutables: https://immutables.github.io/json.html#jackson

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, it is a good opportunity to integrate Immutables into Besu. I just did it

Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Copy link
Contributor

@AbdelStark AbdelStark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add stop method.

@@ -122,6 +126,9 @@ public void start() {
writeBesuNetworksToFile();
autoTransactionLogBloomCachingService.ifPresent(AutoTransactionLogBloomCachingService::start);
writePidFile();

ethStatsService.ifPresent(EthStatsService::start);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you missed the stop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, I just added it

matkt added 2 commits July 23, 2020 11:29
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Copy link
Contributor

@AbdelStark AbdelStark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@@ -169,8 +177,7 @@ public void start() {
// send a full report after the connection
sendFullReport();
} else {
LOG.error("Failed to login to ethstats server");
retryConnect();
LOG.error("Failed to login to ethstats server " + ack);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOG.error("Failed to login to ethstats server " + ack);
LOG.error("Failed to login to ethstats server {}", ack);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

.id(enodeURL.getNodeId().toHexString())
.currentTime(String.valueOf(pingTimestamp))
.build();
sendMessage(webSocket, new EthStatsRequest(NODE_PING, pingReport));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this look with the @Parameter annotation on the key fields? That would open up the .of(...) static method and these singe use cases could become (I'm guesssing on the auto-formattting)...

    sendMessage(
      webSocket, 
      new EthStatsRequest(
        NODE_PING, 
        ImmutablePingReport.of(
          enodeURL.getNodeId().toHexString(),
          String.valueOf(pingTimestamp))));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I added this in everything except in two object because having the builder allow to use this feature https://immutables.github.io/immutable.html#wrappertupple-initializers-inlined-as-alternative-setters-with-deep- immutables-detection

@@ -1039,6 +1040,21 @@ void setBannedNodeIds(final List<String> values) {
arity = "1")
private final Long wsTimeoutSec = TimeoutOptions.defaultOptions().getTimeoutSeconds();

@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"})
@Option(
names = {"--ethstats"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's start these out as --X options and make them standard after one dot-dot release cycle without issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

matkt added 2 commits July 24, 2020 11:11
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
@matkt matkt force-pushed the add-ethstats-socket branch from 25780ac to aaecf78 Compare July 24, 2020 09:42
matkt added 2 commits July 24, 2020 11:45
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
@matkt matkt force-pushed the add-ethstats-socket branch from aaecf78 to 028bff7 Compare July 24, 2020 09:46
@shemnon
Copy link
Contributor

shemnon commented Jul 28, 2020

LGTM

@matkt matkt deleted the add-ethstats-socket branch August 14, 2020 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants