Guide: Casper Node Operation Tips + Tricks

Casper Network Guide: Operating with, Interacting with, and Querying your Casper node

Hello Casper community! Our broad community of validators and internal teams have worked to develop multiple scripts and casper-client commands to interact with, administer to, and gather intelligence from. Over the course of the testnets and now MainNet, helpful commands are everywhere and can accomplish a lot! Please see the below compiled helpful commands and their expected outputs.

Checking Node Status

There are multiple sections within the node status endpoint output. The output can be quite large if your node has a large amount of peers. These commands help you narrow down what you’re wanting to get a look at:

  • Standard status:
    curl -s http://localhost:8888/status | jq

You can drill down to a specific value in the reply by adding that object’s key name to the jq call:
curl -s http://localhost:8888/status | jq .<key_here>
With the available options:

.api_version
.chainspec_name
.starting_state_root_hash
.peers
.last_added_block_info
.our_public_signing_key
.round_length
.next_upgrade
.build_version

And each key provides:

  • api_version: the version of the RPC endpoint API (the current node version)
  • chainspec_name: the casper network the node is connected to (casper [MainNet], casper-test [TestNet])
  • starting_state_root_hash:
  • peers: nodes that have communicated network information with the node
  • last_added_block_info: Will display the following information about the last downloaded block in the chain:
    hash: the hash of the current block
    timestamp: UTC timestamp of the block's creation
    era_id: current era (eras last ~2 hours)
    height: block height, or block number
    state_root_hash: state root hash at this block
    creator: validator public key hex that proposed the current block
    

Checking Node Metrics

In order to check up on your node’s performance and some overall system stats, port 8888/metrics is available for text-based processing (tools like grep).

  • Base Metrics
    curl -s http://localhost:8888/metrics

There are a lot of metrics from this output, far too many to cover in this guide. The outputs produced here are all in formats that can be ingested by tools like grafana and Prometheus, so personal research into what metrics are important to you is recommended.

A few datapoints that might be of significance include:

  • Network Info:
    • pending_deploys: can show backup of processing and issues.
    • finalization_time: Shows slowdown of node or network
  • MEMORY:
    • allocated_ram_bytes: Shows total amount of bytes of RAM currently allocated to casper-node-launcher.service
    • mem_event_stream_server: memory (in bytes) currently in use by the event stream server (port 9999)
    • mem_linear_chain: memory (in bytes) currently in use by the linear chain (synchronization aspect of casper-node)
    • mem_net: total memory (in bytes) currently in use by the networking portions of the casper-node software.
    • mem_storage: total memory (in bytes) in use on the server for blockchain data
    • mem_total: total memory (in bytes) in use by casper-node in total

Cheatsheet of commands for node operations

Various commands for checking the network and node metrics exist throughout the community, along with several utility scripts. Some helpful commands to verify quick bits of info:

Get current era Auction information for your public key:

casper-client get-auction-info | grep -B 5 -A 5 $(cat /etc/casper/validator_keys/public_key_hex)

Monitor node while it synchronizes with the network:

watch -n 5 'echo -n "Peer Count: "; curl -s localhost:8888/status | jq ".peers | length"; echo; echo "last_added_block_info:"; curl -s localhost:8888/status | jq .last_added_block_info; echo; echo "casper-node-launcher status:"; systemctl status casper-node-launcher'

Transfer 555 unlocked/unbonded tokens (like to an exchange wallet):

casper-client transfer --node-address http://135.181.134.57:7777 --amount 555000000000 --target-account $PUBLIC_KEY_HEX_TARGET --payment-amount 10000 --secret-key path/to/secret_key.pem --chain-name casper --id 1

Get staked amount of tokens on the network:

casper-client get-auction-info --node-address http://localhost:7777 | jq -r '.result.auction_state.bids[] | select( .public_key == "$PUBLIC_KEY") | .bid.staked_amount | tonumber / 1000000000'

Query node for a deploy hash’s information:

curl --location --request POST 'http://localhost:7777/rpc' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0","method":"info_get_deploy","params":{"deploy_hash":""},"id" : 1234}' -H 'Content-Type: application/json'| jq

Conclusion

Thank you all for your time in reading this long, and eventually all-encompassing guide on node operations for validators and operations teams. Please feel free to post your own helpful commands and a brief explanation!