7 RPC cookbook
Ștefan Talpalaru edited this page 2021-10-12 22:22:15 +02:00

count peers by client

curl -sd '{"jsonrpc":"2.0","method":"get_v1_node_peers","params":[["connected"]],"id":1}' -H 'Content-Type: application/json' localhost:9190 | jq -r '.result[] | .agent' | cut -d'/' -f1 | sort | uniq -c | sort -n

      1 Lighthouse
      4 nimbus
     68 teku
     87 Prysm

peers that advertise a single IP address and it's a reserved one

curl -sd '{"jsonrpc":"2.0","method":"peers","params":[],"id":1}' -H 'Content-Type: application/json' localhost:9190 | jq -r '.result.peers[].info | [.agentVersion,.addrs] | flatten | join(" ")' | grep '^\S\+ \S\+$' | grep -E '/127\.|/10\.|/0\.|/192\.168\.'

https://en.wikipedia.org/wiki/Reserved_IP_addresses

Prysm/v1.0.3/fc7c6776f66c675dfc0e26a9f16141720bf9f2df /ip4/192.168.219.106/tcp/13000
teku/teku/v20.11.1/linux-x86_64/-ubuntu-openjdk64bitservervm-java-11 /ip4/127.0.1.1/tcp/9000/p2p/16Uiu2HAmL2epufGxLKgymWvkaSvHsZrpQFwci2dzfEMW8T1c3tcF
Prysm/v1.0.2/b150acffca3d93e8cf1f404ff7e4602391017186 /ip4/10.0.2.100/tcp/13000
teku/teku/v20.11.1/linux-x86_64/-ubuntu-openjdk64bitservervm-java-11 /ip4/127.0.1.1/tcp/9000/p2p/16Uiu2HAm6fLmHr3MvUHVhRbew7qD7W34CMoCLowakRRAqLVSyhex

genesis state

curl -sd '{"jsonrpc":"2.0","method":"get_v1_debug_beacon_states_stateId","params":["genesis"],"id":1}' -H 'Content-Type: application/json' localhost:9190 | jq -r '.result' | less

all peer info

curl -sd '{"jsonrpc":"2.0","method":"peers","params":[],"id":1}' -H 'Content-Type: application/json' localhost:9190 | jq -r '.result' | less

validator dump with balance

curl -sd '{"jsonrpc":"2.0","method":"get_v1_debug_beacon_states_stateId","params":["head"],"id":1}' -H 'Content-Type: application/json' localhost:9190 | jq '.result | [[{"balance":.balances.data[]}], .validators.data] | transpose | map(add) | map({(.pubkey): .}) | add | del(.[].pubkey)'

futures info

Only works after a special define: make -j8 NIMFLAGS="-d:chronosFutureTracking" nimbus_beacon_node

curl -sd '{"jsonrpc":"2.0","method":"debug_getChronosFutures","params":[],"id":1}' -H 'Content-Type: application/json' localhost:9190 | jq '.result[]' | grep state | sort | uniq -c