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 client id to admin_peers RPC API #7706

Closed
wants to merge 2 commits into from

Conversation

anhnhgutech
Copy link
Contributor

@anhnhgutech anhnhgutech commented Nov 4, 2024

Add client id to admin_peers RPC API

Related #7536

Changes

  • Add id to admin_peers RPC API
  • Update clientId -> name

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Screenshots

Screenshot 2024-11-04 at 13 42 38

Notes

Regarding updating the clientId parameter to name, I believe that refers to the client name. However, I've only updated it in the admin_peers RPC API, keeping clientId unchanged in other functions.

@LukaszRozmej
Copy link
Member

Regarding updating the clientId parameter to name, I believe that refers to the client name. However, I've only updated it in the admin_peers RPC API, keeping clientId unchanged in other functions.

Where else should we check?

@anhnhgutech
Copy link
Contributor Author

Regarding updating the clientId parameter to name, I believe that refers to the client name. However, I've only updated it in the admin_peers RPC API, keeping clientId unchanged in other functions.

Where else should we check?

You use ClientId in many places, but I think it is currently like a client name, right?
In this PR, I only updated the API; if you want, I can create another PR to change all var name ClientId to ClientName
Ex:

Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>
@LukaszRozmej
Copy link
Member

LukaszRozmej commented Nov 4, 2024

Regarding updating the clientId parameter to name, I believe that refers to the client name. However, I've only updated it in the admin_peers RPC API, keeping clientId unchanged in other functions.

Where else should we check?

You use ClientId in many places, but I think it is currently like a client name, right? In this PR, I only updated the API; if you want, I can create another PR to change all var name ClientId to ClientName Ex:

Nah lets leave P2P messages out of this, it is a different context.
Hello message specs it as clientId: https://github.com/ethereum/devp2p/blob/master/rlpx.md#hello-0x00
Hence the naming in Peers as they are constructed based on that.

@@ -36,7 +38,8 @@ public PeerInfo(Peer peer, bool includeDetails)
$"{nameof(PeerInfo)} cannot be created for a {nameof(Peer)} with an unknown {peer.Node}");
}

ClientId = peer.Node.ClientId;
Name = peer.Node.ClientId;
Id = CalculateClientId(peer.Node.Id);
Copy link
Member

Choose a reason for hiding this comment

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

Btw do we need to calculate it here, we have already peer.Node.IdHash?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, let me check again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see that IdHash is calculated by PrefixedBytes, this isn’t the clientId.

IdHash = Keccak.Compute(PublicKey.PrefixedBytes);

I think we should use new CalculateClientId function, right?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure, it is your PR ;)
Best to check with Geth code.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah IdHash should be fine

Copy link
Member

@LukaszRozmej LukaszRozmej left a comment

Choose a reason for hiding this comment

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

Change to IdHash

@anhnhgutech
Copy link
Contributor Author

anhnhgutech commented Nov 5, 2024

Change to IdHash

@LukaszRozmej
I mean, the IdHash doesn't seem to be the same as ClientId, they are different.
By the way, as you can see, in admin_nodeInfo, the Nethermind team calculates ClientId the same way as in my PR

private void BuildNodeInfo()
{
_nodeInfo = new NodeInfo();
_nodeInfo.Name = ProductInfo.ClientId;
_nodeInfo.Enode = _enode.Info;
byte[] publicKeyBytes = _enode.PublicKey?.Bytes;
_nodeInfo.Id = (publicKeyBytes is null ? Keccak.Zero : Keccak.Compute(publicKeyBytes)).ToString(false);
_nodeInfo.Ip = _enode.HostIp?.ToString();
_nodeInfo.ListenAddress = $"{_enode.HostIp}:{_enode.Port}";
_nodeInfo.Ports.Discovery = _networkConfig.DiscoveryPort;
_nodeInfo.Ports.Listener = _networkConfig.P2PPort;
UpdateEthProtocolInfo();
}

@LukaszRozmej
Copy link
Member

Closing in favor of #7717

@anhnhgutech anhnhgutech deleted the add-client-id branch November 6, 2024 01:08
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.

2 participants