|
| 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 | + |
| 5 | +Use the tabs below to switch between commands for Bor and Heimdall: |
| 6 | + |
| 7 | +<Tabs |
| 8 | + defaultValue="bor" |
| 9 | + values={[ |
| 10 | + { label: 'Bor Commands', value: 'bor', }, |
| 11 | + { label: 'Heimdall Commands', value: 'heimdall', }, |
| 12 | + ] |
| 13 | +}> |
| 14 | +<TabItem value="bor"> |
| 15 | + |
| 16 | +To execute Bor IPC commands, use the following syntax: |
| 17 | + |
| 18 | +```bash |
| 19 | +bor attach .bor/data/bor.ipc <command> |
| 20 | +``` |
| 21 | + |
| 22 | +| IPC Command | RPC Command | Description | |
| 23 | +| ----------- | ----------- | ----------- | |
| 24 | +| `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. | |
| 25 | +| `admin.nodeInfo` | | Provides detailed information about the node. | |
| 26 | +| `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`). | |
| 27 | +| `eth.syncing.highestBlock - eth.syncing.currentBlock` | | Compares the current block of your node to the highest block. | |
| 28 | +| `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. | |
| 29 | +| `debug.setHead("0x"+((eth.getBlock('latest').number) - 1000).toString(16))` | | Rewinds the blockchain to 1000 blocks prior. | |
| 30 | +| `admin.nodeInfo.enode` | | Retrieves the public enode URL of the node. | |
| 31 | +| `eth.syncing.currentBlock * 100 / eth.syncing.highestBlock` | | Calculates the remaining percentage for block synchronization. | |
| 32 | +| `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. | |
| 33 | +| | `curl http://YourIP:8545 -X POST -H "Content-Type: application/json" --data '{"method":"eth_chainId","params":[],"id":1,"jsonrpc":"2.0"}'` | Retrieves the `chainID`. | |
| 34 | + |
| 35 | +</TabItem> |
| 36 | +<TabItem value="heimdall"> |
| 37 | + |
| 38 | +| Command | Description | |
| 39 | +| ------- | ----------- | |
| 40 | +| `curl localhost:26657/net_info?` | Returns the number of connected peers using `jq .result.n_peers`. | |
| 41 | +| `curl -s localhost:26657/status` | Retrieves Heimdall's current block height using `jq .result.sync_info.latest_block_height`. | |
| 42 | +| `curl localhost:26657/net_info` | Queries the node using its moniker with `grep moniker`. | |
| 43 | +| `curl -s localhost:26657/status` | Checks if Heimdall is in sync using `jq .result.sync_info.catching_up`. | |
| 44 | +| `curl -s localhost:26657/status` | Verifies Heimdall's sync status using `jq .result \| jq .sync_info`. | |
| 45 | +| `heimdalld unsafe-reset-all` | Resets the database in case of issues. | |
| 46 | +| `curl localhost:26657/status` | Provides comprehensive information about Heimdall. | |
| 47 | + |
| 48 | +</TabItem> |
| 49 | +</Tabs> |
| 50 | + |
| 51 | +## Node Management Commands |
| 52 | + |
| 53 | +| Description | Command | |
| 54 | +| ------------------------------------- | ---------------------------------------------- | |
| 55 | +| **Locate Heimdall genesis file** | `$CONFIGPATH/heimdall/config/genesis.json` | |
| 56 | +| **Locate heimdall-config.toml** | `/etc/heimdall/config/heimdall-config.toml` | |
| 57 | +| **Locate config.toml** | `/etc/heimdall/config/config.toml` | |
| 58 | +| **Locate heimdall-seeds.txt** | `$CONFIGPATH/heimdall/heimdall-seeds.txt` | |
| 59 | +| **Start Heimdall** | `$ sudo service heimdalld start` | |
| 60 | +| **Start Heimdall rest-server** | `$ sudo service heimdalld-rest-server start` | |
| 61 | +| **Start Heimdall bridge-server** | `$ sudo service heimdalld-bridge start` | |
| 62 | +| **Locate Bor genesis file** | `$CONFIGPATH/bor/genesis.json` | |
| 63 | +| **Start Bor** | `sudo service bor start` | |
| 64 | +| **Retrieve Heimdall logs** | `/var/log/matic-logs/` | |
| 65 | +| **Check Heimdall logs** | `tail -f heimdalld.log` | |
| 66 | +| **Check Heimdall rest-server logs** | `tail -f heimdalld-rest-server.log` | |
| 67 | +| **Check Heimdall bridge logs** | `tail -f heimdalld-bridge.log` | |
| 68 | +| **Check Bor logs** | `tail -f bor.log` | |
| 69 | + |
| 70 | +## Useful Configuration Commands |
| 71 | + |
| 72 | +### Sync Status of Heimdall |
| 73 | + |
| 74 | +To check if Heimdall is synced, run: |
| 75 | + |
| 76 | +```bash |
| 77 | +curl http://localhost:26657/status |
| 78 | +``` |
| 79 | + |
| 80 | +### Latest Block Height on Heimdall |
| 81 | + |
| 82 | +To check the latest block height on Heimdall, run: |
| 83 | + |
| 84 | +```bash |
| 85 | +curl localhost:26657/status |
| 86 | +``` |
| 87 | + |
| 88 | +### Latest Block Height on Bor |
| 89 | + |
| 90 | +To check the latest block height on Bor, use: |
| 91 | + |
| 92 | +```bash |
| 93 | +curl http://<your ip>:8545 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"bor_getSigners", "params":["0x98b3ea"]}' |
| 94 | +``` |
| 95 | + |
| 96 | +### Cleanup: Deleting Remnants of Heimdall and Bor |
| 97 | + |
| 98 | +**For Linux package:** |
| 99 | + |
| 100 | +```bash |
| 101 | +sudo dpkg -i matic-bor |
| 102 | +sudo rm -rf /etc/bor |
| 103 | +``` |
| 104 | + |
| 105 | +**For Binaries:** |
| 106 | + |
| 107 | +```bash |
| 108 | +sudo rm -rf /etc/bor |
| 109 | +sudo rm /etc/heimdall |
| 110 | +``` |
| 111 | + |
| 112 | +### Terminate Bor Process |
| 113 | + |
| 114 | +**For Linux:** |
| 115 | + |
| 116 | +```bash |
| 117 | +ps -aux | grep bor |
| 118 | +sudo kill -9 <PID> |
| 119 | +``` |
| 120 | + |
| 121 | +**For Binaries:** |
| 122 | + |
| 123 | +```bash |
| 124 | +cd CS-2003/bor |
| 125 | +bash stop.sh |
| 126 | +``` |
| 127 | + |
| 128 | +### Retrieve Latest Peer Details |
| 129 | + |
| 130 | +To retrieve the latest peer details, run: |
| 131 | + |
| 132 | +```bash |
| 133 | +bor attach bor.ipc |
| 134 | +admin.peers.forEach(function(value){ |
| 135 | + console.log(value.enode+',') |
| 136 | +}) |
| 137 | +exit |
| 138 | +``` |
| 139 | + |
| 140 | +### Stop Heimdall and Bor Services |
| 141 | + |
| 142 | +**For Linux packages:** |
| 143 | + |
| 144 | +```bash |
| 145 | +sudo service heimdalld stop |
| 146 | +sudo service bor stop |
| 147 | +``` |
| 148 | + |
| 149 | +**For Binaries:** |
| 150 | + |
| 151 | +```bash |
| 152 | +pkill heimdalld |
| 153 | +pkill heimdalld-bridge |
| 154 | +cd CS-2001/bor |
| 155 | +bash stop.sh |
| 156 | +``` |
| 157 | + |
| 158 | +### Remove Heimdall and Bor Directories |
| 159 | + |
| 160 | +**For Linux packages:** |
| 161 | + |
| 162 | +```bash |
| 163 | +sudo rm -rf /etc/heimdall/* |
| 164 | +sudo rm -rf /etc/bor/* |
| 165 | +``` |
| 166 | + |
| 167 | +**For Binaries:** |
| 168 | + |
| 169 | +```bash |
| 170 | +sudo rm -rf /var/lib/heimdalld/ |
| 171 | +sudo rm -rf /var/lib/bor |
| 172 | +``` |
0 commit comments