We run a lot of different blockchain technologies. Different tools often have inconsistent tooling and this makes automation and operations painful. The goal of this codebase is to standardize some of our commonly needed tools and provide interfaces and formats.
Requirements:
- Go
- make
- jq
- bc
- protoc (Only required for
make generate
)
To install, clone this repo and run:
make install
By default, the commands will be in $HOME/go/bin/
, so for ease, we recommend adding that path to your shell's startup file by adding the following line:
export PATH="$HOME/go/bin:$PATH"
Note: Do not modify this section! It is auto-generated by cobra
using make gen-doc
.
-
polycli abi - Provides encoding and decoding functionalities with contract signatures and ABI.
-
polycli dbbench - Perform a level/pebble db benchmark
-
polycli dumpblocks - Export a range of blocks from a JSON-RPC endpoint.
-
polycli ecrecover - Recovers and returns the public key of the signature
-
polycli enr - Convert between ENR and Enode format
-
polycli fork - Take a forked block and walk up the chain to do analysis.
-
polycli fund - Bulk fund crypto wallets automatically.
-
polycli hash - Provide common crypto hashing functions.
-
polycli loadtest - Run a generic load test against an Eth/EVM style JSON-RPC endpoint.
-
polycli metrics-to-dash - Create a dashboard from an Openmetrics / Prometheus response.
-
polycli mnemonic - Generate a BIP39 mnemonic seed.
-
polycli monitor - Monitor blocks using a JSON-RPC endpoint.
-
polycli nodekey - Generate node keys for different blockchain clients and protocols.
-
polycli p2p - Set of commands related to devp2p.
-
polycli parseethwallet - Extract the private key from an eth wallet.
-
polycli retest - Convert the standard ETH test fillers into something to be replayed against an RPC
-
polycli rpcfuzz - Continually run a variety of RPC calls and fuzzers.
-
polycli signer - Utilities for security signing transactions
-
polycli ulxly - Utilities for interacting with the lxly bridge
-
polycli version - Get the current version of this application
-
polycli wallet - Create or inspect BIP39(ish) wallets.
To test the features of polycli
, we'll run geth in dev
mode but you can run any node you want.
make geth
You can then fund the default load testing account and run some tests.
make geth-loadtest
You can view the state of the chain using polycli
.
polycli monitor --rpc-url http://127.0.0.1:8545
Note that if you want to debug the monitor, you can use the following command.
polycli monitor --rpc-url http://34.117.145.249:80 -v 700 &> log.txt
You can also interact manually with your node, you can attach a Javascript console to your node using IPC.
First, wait for the IPC endpoint to open.
INFO [07-10|10:44:29.250] Starting peer-to-peer node instance=Geth/v1.12.0-stable/darwin-amd64/go1.20.4
WARN [07-10|10:44:29.250] P2P server will be useless, neither dialing nor listening
INFO [07-10|10:44:29.255] Stored checkpoint snapshot to disk number=0 hash=039839..dcb5c1
DEBUG[07-10|10:44:29.255] IPCs registered namespaces=admin,debug,web3,eth,txpool,clique,miner,net,engine
INFO [07-10|10:44:29.256] IPC endpoint opened url=/var/folders/7m/3_x4ns7557x52hb6vncqkx8h0000gn/T/geth.ipc
INFO [07-10|10:44:29.256] Generated ephemeral JWT secret secret=0x7511b4e6312a1a63348d8fc8c6a586ed4ea69ed31c27b3c0cc5e41cb6d2d5822
Then, attach a console to your node.
geth attach /var/folders/7m/3_x4ns7557x52hb6vncqkx8h0000gn/T/geth.ipc
From there, you can do anything such as funding the default load testing account with some currency.
> eth.coinbase==eth.accounts[0]
true
> eth.sendTransaction({from: eth.coinbase, to: "0x85da99c8a7c2c95964c8efd687e95e632fc533d6", value: web3.toWei(5000, "ether")})
"0xd8223589989d198741e0543ab01d9d3ce2b81e38927cb213a56589e111dfd388"
You can then generate some load to make sure that blocks with transactions are being created. Note that the chain id of local geth is 1337
.
polycli loadtest --verbosity 700 --chain-id 1337 --concurrency 1 --requests 1000 --rate-limit 5 --mode c --rpc-url http://127.0.0.1:8545
For more discussions, please head to the R&D Discord
Sending some value to the default load testing account.
Listening for re-orgs.
socat - UNIX-CONNECT:/var/folders/zs/k8swqskj1t79cgnjh6yt0fqm0000gn/T/geth.ipc
{"id": 1, "method": "eth_subscribe", "params": ["newHeads"]}
Useful RPCs when testing.
curl -v -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0", "id": 1, "method": "net_version", "params": []}' https://polygon-rpc.com
curl -v -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0", "id": 1, "method": "eth_blockNumber", "params": []}' https://polygon-rpc.com
curl -v -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0", "id": 1, "method": "eth_getBlockByNumber", "params": ["0x1DE8531", true]}' https://polygon-rpc.com
curl -v -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0", "id": 1, "method": "clique_getSigner", "params": ["0x1DE8531", true]}' https://polygon-rpc.com
curl -v -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0", "id": 1, "method": "eth_getBalance", "params": ["0x85da99c8a7c2c95964c8efd687e95e632fc533d6", "latest"]}' https://polygon-rpc.com
curl -v -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0", "id": 1, "method": "eth_getCode", "params": ["0x79954f948079ee9ef1d15eff3e07ceaef7cdf3b4", "latest"]}' https://polygon-rpc.com
curl -v -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0", "id": 1, "method": "txpool_inspect", "params": []}' http://localhost:8545
curl -v -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0", "id": 1, "method": "txpool_status", "params": []}' http://localhost:8545
curl -v -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0", "id": 1, "method": "eth_gasPrice", "params": []}' http://localhost:8545
curl -v -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0", "id": 1, "method": "admin_peers", "params": []}' http://localhost:8545
websocat ws://34.208.176.205:9944
{"jsonrpc":"2.0", "id": 1, "method": "chain_subscribeNewHead", "params": []}
If you add a new loadtest mode, don't forget to update the loadtest mode string by running the following command: cd cmd/loadtest && stringer -type=loadTestMode
. You can install stringer with go install golang.org/x/tools/cmd/stringer@latest
.