mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-24 21:40:03 +00:00
inspector: add readme entry, decoding option
This commit is contained in:
parent
963f23e5ea
commit
8c104a0b94
20
README.md
20
README.md
@ -36,6 +36,7 @@ You can check where the beacon chain fits in the Ethereum ecosystem our Two-Poin
|
|||||||
- [State transition simulation](#state-transition-simulation)
|
- [State transition simulation](#state-transition-simulation)
|
||||||
- [Local network simulation](#local-network-simulation)
|
- [Local network simulation](#local-network-simulation)
|
||||||
- [Visualising simulation metrics](#visualising-simulation-metrics)
|
- [Visualising simulation metrics](#visualising-simulation-metrics)
|
||||||
|
- [Network inspection](#network-inspection)
|
||||||
- [For developers](#for-developers)
|
- [For developers](#for-developers)
|
||||||
- [Windows dev environment](#windows-dev-environment)
|
- [Windows dev environment](#windows-dev-environment)
|
||||||
- [Linux, MacOS](#linux-macos)
|
- [Linux, MacOS](#linux-macos)
|
||||||
@ -182,6 +183,25 @@ The dashboard you need to import in Grafana is "tests/simulation/beacon-chain-si
|
|||||||
|
|
||||||
![monitoring dashboard](./media/monitoring.png)
|
![monitoring dashboard](./media/monitoring.png)
|
||||||
|
|
||||||
|
### Network inspection
|
||||||
|
|
||||||
|
The [inspector tool](./beacon_chain/inspector.nim) can help monitor the libp2p network and the various channels where blocks and attestations are being transmitted, showing message and connectivity metadata. By default, it will monitor all ethereum 2 gossip traffic.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
. ./env.sh
|
||||||
|
# Build inspector for minimal config:
|
||||||
|
./env.sh nim c -d:const_preset=minimal -o:build/inspector_minimal beacon_chain/inspector.nim
|
||||||
|
|
||||||
|
# Build inspector for mainnet config:
|
||||||
|
./env.sh nim c -d:const_preset=mainnet -o:build/inspector_mainnet beacon_chain/inspector.nim
|
||||||
|
|
||||||
|
# See available options
|
||||||
|
./env.sh build/inspector_minimal --help
|
||||||
|
|
||||||
|
# Connect to a network from eth2 testnet repo bootstrap file - --decode option attempts to decode the messages as well
|
||||||
|
./env.sh build/inspector_minimal --decode -b:$(curl -s https://raw.githubusercontent.com/eth2-clients/eth2-testnets/master/nimbus/testnet0/bootstrap_nodes.txt | head -n1)
|
||||||
|
```
|
||||||
|
|
||||||
## For developers
|
## For developers
|
||||||
|
|
||||||
Latest updates happen in the `devel` branch which is merged into `master` every week on Tuesday before deploying a new testnets
|
Latest updates happen in the `devel` branch which is merged into `master` every week on Tuesday before deploying a new testnets
|
||||||
|
@ -8,7 +8,7 @@ import strutils, os, tables
|
|||||||
import confutils, chronicles, chronos, libp2p/daemon/daemonapi,
|
import confutils, chronicles, chronos, libp2p/daemon/daemonapi,
|
||||||
libp2p/multiaddress
|
libp2p/multiaddress
|
||||||
import stew/byteutils as bu
|
import stew/byteutils as bu
|
||||||
import spec/network
|
import spec/[crypto, datatypes, network, digest], ssz
|
||||||
|
|
||||||
const
|
const
|
||||||
InspectorName* = "Beacon-Chain Network Inspector"
|
InspectorName* = "Beacon-Chain Network Inspector"
|
||||||
@ -88,6 +88,11 @@ type
|
|||||||
abbr: "b"
|
abbr: "b"
|
||||||
name: "bootnodes" }: seq[string]
|
name: "bootnodes" }: seq[string]
|
||||||
|
|
||||||
|
decode* {.
|
||||||
|
desc: "Try to decode message using SSZ"
|
||||||
|
abbr: "d"
|
||||||
|
defaultValue: false }: bool
|
||||||
|
|
||||||
proc getTopic(filter: TopicFilter): string {.inline.} =
|
proc getTopic(filter: TopicFilter): string {.inline.} =
|
||||||
case filter
|
case filter
|
||||||
of TopicFilter.Blocks:
|
of TopicFilter.Blocks:
|
||||||
@ -176,6 +181,22 @@ proc run(conf: InspectorConf) {.async.} =
|
|||||||
mtopics = $message.topics,
|
mtopics = $message.topics,
|
||||||
message = bu.toHex(message.data),
|
message = bu.toHex(message.data),
|
||||||
zpeers = len(pubsubPeers)
|
zpeers = len(pubsubPeers)
|
||||||
|
|
||||||
|
if conf.decode:
|
||||||
|
try:
|
||||||
|
if ticket.topic.startsWith(topicBeaconBlocks):
|
||||||
|
info "BeaconBlock", msg = SSZ.decode(message.data, BeaconBlock)
|
||||||
|
elif ticket.topic.startsWith(topicAttestations):
|
||||||
|
info "Attestation", msg = SSZ.decode(message.data, Attestation)
|
||||||
|
elif ticket.topic.startsWith(topicVoluntaryExits):
|
||||||
|
info "VoluntaryExit", msg = SSZ.decode(message.data, VoluntaryExit)
|
||||||
|
elif ticket.topic.startsWith(topicProposerSlashings):
|
||||||
|
info "ProposerSlashing", msg = SSZ.decode(message.data, ProposerSlashing)
|
||||||
|
elif ticket.topic.startsWith(topicAttesterSlashings):
|
||||||
|
info "AttesterSlashing", msg = SSZ.decode(message.data, AttesterSlashing)
|
||||||
|
except CatchableError as exc:
|
||||||
|
info "Unable to decode message", msg = exc.msg
|
||||||
|
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
if len(conf.topics) > 0:
|
if len(conf.topics) > 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user