harmony icon indicating copy to clipboard operation
harmony copied to clipboard

Add RPC for Boot Nodes

Open GheisMohammadi opened this issue 6 months ago • 1 comments

Description

This PR enhances the visibility and monitoring capabilities of boot nodes by adding an RPC server. Previously, boot nodes lacked any RPCs and did not expose any meta data, limiting our ability to monitor them effectively. By adding RPC for boot nodes, this PR introduces several APIs that allow for better and more efficient monitoring, enabling us to observe and track the connectivity and peers connected to the boot node.

The PR would add these RPC methods for both hmyboot and hmybootv2 domains:

echo "=======[hmyboot_getNodeMetadata]================="

curl -d '{
  "jsonrpc":"2.0",
  "method":"hmyboot_getNodeMetadata",
  "params":[],
  "id":1
 }' -H 'Content-Type:application/json' -X POST '0.0.0.0:8888'

 #{"jsonrpc":"2.0","id":1,"result":{"blskey":null,"chain-config":{"AllowlistEpoch":null,"FeeCollectEpoch":null,"chain-id":null,"eth-compatible-chain-id":null,"eth-compatible-shard-0-chain-id":null},"consensus":{"blocknum":0,"finality":0,"mode":"","phase":"","viewChangeId":0,"viewId":0},"current-block-number":0,"current-epoch":0,"dns-zone":"","is-archival":false,"is-backup":false,"is-leader":false,"network":"","node-unix-start-time":1724318966,"p2p-connectivity":{"connected":24,"not-connected":1,"total-known-peers":25},"peerid":"","role":"","shard-id":0,"version":"Harmony (C) 2023. bootnode, version v8421-v2024.0.0-83-g1cb52f7f0-dirty (root@ 2024-08-22T17:29:12+0800)"}}

 echo "=======[hmyboot_getPeerInfo]================="

curl -d '{
  "jsonrpc":"2.0",
  "method":"hmyboot_getPeerInfo",
  "params":[],
  "id":1
 }' -H 'Content-Type:application/json' -X POST '0.0.0.0:8888'

 #{"jsonrpc":"2.0","id":1,"result":{"blocked-peers":[],"connected-peers":[],"peerid":""}}
 
 echo "=======[hmyboot_protocolVersion]================="

curl -d '{
  "jsonrpc":"2.0",
  "method":"hmyboot_protocolVersion",
  "params":[],
  "id":1
 }' -H 'Content-Type:application/json' -X POST '0.0.0.0:8888'

 #{"jsonrpc":"2.0","id":1,"result":"0x1"}

Additionally, this PR includes a redefinition of the node and RPC folder structure, making the codebase more organized and well structured to add boot nodes functions as well.

Importantly, the changes made in this PR do not alter any logic for Harmony nodes, ensuring that the merge is safe and will not affect existing functionality. This improvement aims to facilitate better network management and monitoring of boot nodes.

GheisMohammadi avatar Aug 13 '24 14:08 GheisMohammadi