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

Extend whois with more useful information #794

Merged
merged 14 commits into from
Sep 24, 2024
Merged

Conversation

alexggh
Copy link
Contributor

@alexggh alexggh commented Sep 16, 2024

polkadot-whois

Fixes: #771

A tool for converting and querying information about validators using interchangeable unique identifiers, information about a validator can be queried using the following indentifiers:

  • Validator index in paraSessionInfo pallet.
  • The account key.
  • The authority discovery id, provided in the hex format, it is the same format as what is displayed in session.next_keys.
  • The peer id, the network peer id used for connecting to other nodes.

It prints a list of information for each queried validator, E.g:

validator_index=<INDEX<>>, account=<ACCOUNT>, peer_id=<PEER_ID>, authorithy_id_discover=0x<AUTHORITY_DISCOVERY>, addresses=<KNOWN_ADDRESSES>, version="POLKADOT_NODE_VERSION"

It uses the subp2p-explorer for querying the DHT information about each validator in the network.

Usage:

Query by validator index

cargo run  --bin polkadot-whois -- \
 --ws=wss://rpc.polkadot.io:443 \
 --bootnodes /dns/polkadot-bootnode-0.polkadot.io/tcp/30333/p2p/12D3KooWSz8r2WyCdsfWHgPyvD8GKQdJ1UAiRmrcrs8sQB3fe2KU \
 --session-index 9442 \
 by-validator-index 295 293

Query by peer id

cargo run  --bin polkadot-whois -- \
 --ws=wss://rpc.polkadot.io:443 \
 --bootnodes /dns/polkadot-bootnode-0.polkadot.io/tcp/30333/p2p/12D3KooWSz8r2WyCdsfWHgPyvD8GKQdJ1UAiRmrcrs8sQB3fe2KU \
 --session-index 9442 \
 by-peer-id 12D3KooWEtD4vrMGsaAmETPx9VXuAu3UyFc7hL92x7ky3TJZwnT7 \
 12D3KooWJJC4ACkC6fvsDuAvcgiebPMVNjMsfL3LtgmitAKhC39N
 

Query by authority discovery key

cargo run  --bin polkadot-whois -- \
 --ws=wss://rpc.polkadot.io:443 \
 --bootnodes /dns/polkadot-bootnode-0.polkadot.io/tcp/30333/p2p/12D3KooWSz8r2WyCdsfWHgPyvD8GKQdJ1UAiRmrcrs8sQB3fe2KU \
 --session-index 9442 \
 by-authority-discovery 0x1cbbd313b592c053da0dc85fe0ae3c010d7bfc3c858a303418a1707846b6507d \
 0xf2fe41ba85a8b16db8642126fd7d4bd3f9cf46c45e9852d528867f3d19474972

Query by account id

cargo run  --bin polkadot-whois -- \
 --ws=wss://rpc.polkadot.io:443 \
 --bootnodes /dns/polkadot-bootnode-0.polkadot.io/tcp/30333/p2p/12D3KooWSz8r2WyCdsfWHgPyvD8GKQdJ1UAiRmrcrs8sQB3fe2KU \
 --session-index 9442 \
 by-account 5D8DuA8a3obyN6ADUTJPUvx5yj8nnKmE1PqsKBQYCRoiqEak

Dump all

cargo run  --bin polkadot-whois -- \
 --ws=wss://rpc.polkadot.io:443 \
 --bootnodes /dns/polkadot-bootnode-0.polkadot.io/tcp/30333/p2p/12D3KooWSz8r2WyCdsfWHgPyvD8GKQdJ1UAiRmrcrs8sQB3fe2KU \
 --session-index 9442 \
 dump-all

Usage examples by network.

Polkadot

cargo run  --bin polkadot-whois -- \
 --ws=wss://rpc.polkadot.io:443 \
 --bootnodes /dns/polkadot-bootnode-0.polkadot.io/tcp/30333/p2p/12D3KooWSz8r2WyCdsfWHgPyvD8GKQdJ1UAiRmrcrs8sQB3fe2KU \
 --session-index 9442 \
 by-validator-index 295 293

Kusama

cargo run  --bin polkadot-whois -- \
 --ws=wss://kusama-rpc.polkadot.io:443 \
 --bootnodes /dns/kusama-bootnode-0.polkadot.io/tcp/30333/p2p/12D3Koo
WSueCPH3puP2PcvqPJdNaDNF3jMZjtJtDiSy35pWrbt5h \
 --session-index 42088 \
 by-validator-index 295 293

Westend

cargo run  --bin polkadot-whois -- \
 --ws=wss://westend-rpc.polkadot.io:443 \
 --bootnodes /dns/westend-bootnode-0.polkadot.io/tcp/30333/p2p/12D3KooWKer94o1REDPtAhjtYR4SdLehnSrN8PEhBnZm5NBoCrMC \
 --session-index 42088 \
 by-validator-index 5 2

Rococo

cargo run  --bin polkadot-whois -- \
 --ws=wss://rococo-rpc.polkadot.io:443 \
 --bootnodes /dns/rococo-bootnode-0.polkadot.io/tcp/30333/p2p/12D3KooWGikJMBmRiG5ofCqn8aijCijgfmZR5H9f53yUF3srm6Nm \
 --session-index 42088 \
 by-validator-index 295 293

Paseo

cargo run  --bin polkadot-whois -- \
 --ws=wss://paseo-rpc.dwellir.com:443 \
 --bootnodes /dns/paseo.bootnode.amforc.com/tcp/29999/wss/p2p/12D3KooWSdf63rZjtGdeWXpQwQwPh8K8c22upcB3B1VmqW8rxrjw \
 --session-index 42088 \
 by-validator-index 11 12

TODO:

  • Graciously handle old sessions.

Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
@AndreiEres AndreiEres self-requested a review September 18, 2024 13:25
Copy link
Collaborator

@AndreiEres AndreiEres left a comment

Choose a reason for hiding this comment

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

Left a few comments

whois/Cargo.toml Outdated Show resolved Hide resolved
whois/Cargo.toml Outdated Show resolved Hide resolved
whois/README.md Show resolved Hide resolved
whois/README.md Show resolved Hide resolved
whois/src/main.rs Outdated Show resolved Hide resolved
whois/src/main.rs Show resolved Hide resolved
Copy link
Collaborator

@AndreiEres AndreiEres left a comment

Choose a reason for hiding this comment

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

Really good, thank you!

whois/README.md Outdated Show resolved Hide resolved
whois/README.md Show resolved Hide resolved
whois/src/main.rs Show resolved Hide resolved
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Copy link
Collaborator

@sandreim sandreim left a comment

Choose a reason for hiding this comment

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

Nice work Alex!

Signed-off-by: Alexandru Gheorghe <[email protected]>
@alexggh alexggh merged commit d2fced9 into master Sep 24, 2024
6 checks passed
@alexggh alexggh deleted the alexggh/whois-rewrite branch September 24, 2024 09:27
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.

Convert between peer-id, authorithy-id, account_id and any other per-validator key.
3 participants