|
| 1 | +This guide provides a curated list of common commands and Polygon-specific operations essential for node operators. Whether you're setting up a full node, validator node or troubleshooting, these commands will assist you in managing your Polygon PoS environment effectively. |
| 2 | + |
| 3 | +## Frequently used commands for Bor & Heimdall |
| 4 | +### Bor |
| 5 | + |
| 6 | +To execute Bor IPC commands, use the following syntax: |
| 7 | + |
| 8 | +```bash |
| 9 | +bor attach .bor/data/bor.ipc <command> |
| 10 | +``` |
| 11 | + |
| 12 | +| IPC Command | RPC Command | Description | |
| 13 | +| ----------- | ----------- | ----------- | |
| 14 | +| `admin.peers.length` | `curl -H "Content-Type: application/json" --data '{"jsonrpc": "2.0", "method": "net_peerCount", "params": [], "id": 74}' localhost:8545` | Retrieves the number of peers connected to the node. | |
| 15 | +| `admin.nodeInfo` | | Provides detailed information about the node. | |
| 16 | +| `eth.syncing` | `curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "eth_syncing","params": []}' localhost:8545` | Indicates whether the node is syncing (`true`) or not (`false`). | |
| 17 | +| `eth.syncing.highestBlock - eth.syncing.currentBlock` | | Compares the current block of your node to the highest block. | |
| 18 | +| `eth.blockNumber` | `curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "eth_blockNumber","params": []}' localhost:8545` | Returns the latest block number processed by the node. | |
| 19 | +| `debug.setHead("0x"+((eth.getBlock('latest').number) - 1000).toString(16))` | | Rewinds the blockchain to 1000 blocks prior. | |
| 20 | +| `admin.nodeInfo.enode` | | Retrieves the public enode URL of the node. | |
| 21 | +| `eth.syncing.currentBlock * 100 / eth.syncing.highestBlock` | | Calculates the remaining percentage for block synchronization. | |
| 22 | +| `eth.getBlock("latest").number` | `curl http://YourIP:8545 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"bor_getSigners", "params":["0x98b3ea"]}'` | Queries the height of the latest Bor block. | |
| 23 | +| | `curl http://YourIP:8545 -X POST -H "Content-Type: application/json" --data '{"method":"eth_chainId","params":[],"id":1,"jsonrpc":"2.0"}'` | Retrieves the `chainID`. | |
| 24 | + |
| 25 | +### Heimdall |
| 26 | + |
| 27 | +| Command | Description | |
| 28 | +| ------- | ----------- | |
| 29 | +| `curl localhost:26657/net_info?` | Returns the number of connected peers using `jq .result.n_peers`. | |
| 30 | +| `curl -s localhost:26657/status` | Retrieves Heimdall's current block height using `jq .result.sync_info.latest_block_height`. | |
| 31 | +| `curl localhost:26657/net_info` | Queries the node using its moniker with `grep moniker`. | |
| 32 | +| `curl -s localhost:26657/status` | Checks if Heimdall is in sync using `jq .result.sync_info.catching_up`. | |
| 33 | +| `curl -s localhost:26657/status` | Verifies Heimdall's sync status using `jq .result \| jq .sync_info`. | |
| 34 | +| `heimdalld unsafe-reset-all` | Resets the database in case of issues. | |
| 35 | +| `curl localhost:26657/status` | Provides comprehensive information about Heimdall. | |
| 36 | + |
| 37 | + |
| 38 | +## Node management commands |
| 39 | + |
| 40 | +| Description | Command | |
| 41 | +| ------------------------------------- | ---------------------------------------------- | |
| 42 | +| **Locate Heimdall genesis file** | `$CONFIGPATH/heimdall/config/genesis.json` | |
| 43 | +| **Locate heimdall-config.toml** | `/etc/heimdall/config/heimdall-config.toml` | |
| 44 | +| **Locate config.toml** | `/etc/heimdall/config/config.toml` | |
| 45 | +| **Locate heimdall-seeds.txt** | `$CONFIGPATH/heimdall/heimdall-seeds.txt` | |
| 46 | +| **Start Heimdall** | `$ sudo service heimdalld start` | |
| 47 | +| **Start Heimdall rest-server** | `$ sudo service heimdalld-rest-server start` | |
| 48 | +| **Start Heimdall bridge-server** | `$ sudo service heimdalld-bridge start` | |
| 49 | +| **Locate Bor genesis file** | `$CONFIGPATH/bor/genesis.json` | |
| 50 | +| **Start Bor** | `sudo service bor start` | |
| 51 | +| **Retrieve Heimdall logs** | `/var/log/matic-logs/` | |
| 52 | +| **Check Heimdall logs** | `tail -f heimdalld.log` | |
| 53 | +| **Check Heimdall rest-server logs** | `tail -f heimdalld-rest-server.log` | |
| 54 | +| **Check Heimdall bridge logs** | `tail -f heimdalld-bridge.log` | |
| 55 | +| **Check Bor logs** | `tail -f bor.log` | |
| 56 | + |
| 57 | +## Useful configuration commands |
| 58 | + |
| 59 | +### Sync status of Heimdall |
| 60 | + |
| 61 | +To check if Heimdall is synced, run: |
| 62 | + |
| 63 | +```bash |
| 64 | +curl http://localhost:26657/status |
| 65 | +``` |
| 66 | + |
| 67 | +### Latest block height on Heimdall |
| 68 | + |
| 69 | +To check the latest block height on Heimdall, run: |
| 70 | + |
| 71 | +```bash |
| 72 | +curl localhost:26657/status |
| 73 | +``` |
| 74 | + |
| 75 | +### Latest block height on Bor |
| 76 | + |
| 77 | +To check the latest block height on Bor, use: |
| 78 | + |
| 79 | +```bash |
| 80 | +curl http://<your ip>:8545 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"bor_getSigners", "params":["0x98b3ea"]}' |
| 81 | +``` |
| 82 | + |
| 83 | +### Cleanup: deleting remnants of Heimdall and Bor |
| 84 | + |
| 85 | +**For Linux package:** |
| 86 | + |
| 87 | +```bash |
| 88 | +sudo dpkg -i matic-bor |
| 89 | +sudo rm -rf /etc/bor |
| 90 | +``` |
| 91 | + |
| 92 | +**For Binaries:** |
| 93 | + |
| 94 | +```bash |
| 95 | +sudo rm -rf /etc/bor |
| 96 | +sudo rm /etc/heimdall |
| 97 | +``` |
| 98 | + |
| 99 | +### Terminate Bor process |
| 100 | + |
| 101 | +**For Linux:** |
| 102 | + |
| 103 | +```bash |
| 104 | +ps -aux | grep bor |
| 105 | +sudo kill -9 <PID> |
| 106 | +``` |
| 107 | + |
| 108 | +**For Binaries:** |
| 109 | + |
| 110 | +```bash |
| 111 | +cd CS-2003/bor |
| 112 | +bash stop.sh |
| 113 | +``` |
| 114 | + |
| 115 | +### Retrieve latest peer details |
| 116 | + |
| 117 | +To retrieve the latest peer details, run: |
| 118 | + |
| 119 | +```bash |
| 120 | +bor attach bor.ipc |
| 121 | +admin.peers.forEach(function(value){ |
| 122 | + console.log(value.enode+',') |
| 123 | +}) |
| 124 | +exit |
| 125 | +``` |
| 126 | + |
| 127 | +### Stop Heimdall and Bor services |
| 128 | + |
| 129 | +**For Linux packages:** |
| 130 | + |
| 131 | +```bash |
| 132 | +sudo service heimdalld stop |
| 133 | +sudo service bor stop |
| 134 | +``` |
| 135 | + |
| 136 | +**For binaries:** |
| 137 | + |
| 138 | +```bash |
| 139 | +pkill heimdalld |
| 140 | +pkill heimdalld-bridge |
| 141 | +cd CS-2001/bor |
| 142 | +bash stop.sh |
| 143 | +``` |
| 144 | + |
| 145 | +### Remove Heimdall and Bor directories |
| 146 | + |
| 147 | +**For Linux packages:** |
| 148 | + |
| 149 | +```bash |
| 150 | +sudo rm -rf /etc/heimdall/* |
| 151 | +sudo rm -rf /etc/bor/* |
| 152 | +``` |
| 153 | + |
| 154 | +**For binaries:** |
| 155 | + |
| 156 | +```bash |
| 157 | +sudo rm -rf /var/lib/heimdalld/ |
| 158 | +sudo rm -rf /var/lib/bor |
| 159 | +``` |
0 commit comments