README
¶
#+TITLE: Polygon CLI
#+DATE:
#+AUTHOR: John Hilliard
#+EMAIL: jhilliard@polygon.technology
#+CREATOR: John Hilliard
#+DESCRIPTION:
#+OPTIONS: toc:nil
#+LATEX_HEADER: \usepackage{geometry}
#+LATEX_HEADER: \usepackage{lmodern}
#+LATEX_HEADER: \geometry{left=1in,right=1in,top=1in,bottom=1in}
#+LaTeX_CLASS_OPTIONS: [letterpaper]
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.
* Hash
The ~hash~ command provides a simple mechanism to perform hashes on
files, standard input, and arguments. Below shows various ways to
provide input.
#+begin_src bash
$ echo -n "hello" > hello.txt
$ polycli hash sha1 --file hello.txt
aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
$ echo -n "hello" | polycli hash sha1
aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
$ polycli hash sha1 hello
aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
#+end_src
We've provided many standard hashing functions
#+begin_src shell :results output
echo -n "hello" | polycli hash md4
echo -n "hello" | polycli hash md5
echo -n "hello" | polycli hash sha1
echo -n "hello" | polycli hash sha224
echo -n "hello" | polycli hash sha256
echo -n "hello" | polycli hash sha384
echo -n "hello" | polycli hash sha512
echo -n "hello" | polycli hash ripemd160
echo -n "hello" | polycli hash sha3_224
echo -n "hello" | polycli hash sha3_256
echo -n "hello" | polycli hash sha3_384
echo -n "hello" | polycli hash sha3_512
echo -n "hello" | polycli hash sha512_224
echo -n "hello" | polycli hash sha512_256
echo -n "hello" | polycli hash blake2s_256
echo -n "hello" | polycli hash blake2b_256
echo -n "hello" | polycli hash blake2b_384
echo -n "hello" | polycli hash blake2b_512
echo -n "hello" | polycli hash keccak256
echo -n "hello" | polycli hash keccak512
#+end_src
#+RESULTS:
#+begin_example
866437cb7a794bce2b727acc0362ee27
5d41402abc4b2a76b9719d911017c592
aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
ea09ae9cc6768c50fcee903ed054556e5bfc8347907f12598aa24193
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f
9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043
108f07b8382412612c048d07d13f814118445acd
b87f88c72702fff1748e58b87e9141a42c0dbedc29a78cb0d4a5cd81
3338be694f50c5f338814986cdf0686453a888b84f424d792af4b9202398f392
720aea11019ef06440fbf05d87aa24680a2153df3907b23631e7177ce620fa1330ff07c0fddee54699a4c3ee0ee9d887
75d527c368f2efe848ecf6b073a36767800805e9eef2b1857d5f984f036eb6df891d75f72d9b154518c1cd58835286d1da9a38deba3de98b5a53e5ed78a84976
fe8509ed1fb7dcefc27e6ac1a80eddbec4cb3d2c6fe565244374061c
e30d87cfa2a75db545eac4d61baf970366a8357c7f72fa95b52d0accb698f13a
19213bacc58dee6dbde3ceb9a47cbb330b3d86f8cca8997eb00be456f140ca25
324dcf027dd4a30a932c441f365a25e86b173defa4b8e58948253471b81b72cf
85f19170be541e7774da197c12ce959b91a280b2f23e3113d6638a3335507ed72ddc30f81244dbe9fa8d195c23bceb7e
e4cfa39a3d37be31c59609e807970799caa68a19bfaa15135f165085e01d41a65ba1e1b146aeb6bd0092b49eac214c103ccfa3a365954bbbe52f74a2b3620c94
1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8
52fa80662e64c128f8389c9ea6c73d4c02368004bf4463491900d11aaadca39d47de1b01361f207c512cfa79f0f92c3395c67ff7928e3f5ce3e3c852b392f976
#+end_example
* Mnemonic
The ~mnemonic~ command is a simple way to generate [[https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki][BIP-0039]] mnemonics.
#+begin_src shell :results output verbatim
polycli mnemonic
polycli mnemonic --language spanish
polycli mnemonic --language spanish --words 12
#+end_src
#+RESULTS:
: speak connect shrug luggage frequent seminar mango wreck enrich head express uphold coach radar sting arm large excess crawl cube reform biology salad sun
: frito aries meter joroba insecto manco batalla tajo freno innato jueves abuso calidad peñón ocupar balde cine novela nevera puerta imitar ágil informe payaso
: puño museo programa tocino vacío gris acción marfil chivo forro bocina margen
* Wallet
The ~wallet~ command can generate portable wallets to be used across ETH, BTC, Polygon, Avail, etc.
In the example, we're generating a wallet with a few flags that are
used to configure how many wallets are generated and how the seed
phrase is used to generate the wallets.
#+begin_src shell :results output verbatim
polycli wallet create --raw-entropy --root-only --words 15 --language english
#+end_src
#+RESULTS:
#+begin_example
{
"RootKey": "xprv9s21ZrQH143K3sEMkuj3J6R1PR3Cy59pmzXi9hU9wErM7cfA5CHSpmb2NCMJZKBvsjLPteu654ood1Ywh39ECpRqKtvrABqPj88ekSuhcUu",
"Seed": "7c2c08fd2a5817f0dc2365e22e5fdfd95b5a016a78aff5aa30bfae2ca563e44dacfac44f5b24ba19c0ecd29f4f79167522a7ca67384707013054a3c051ebafba",
"Mnemonic": "narrow elite clean enjoy figure zoo able dwarf grunt simple math spice harsh pair mystery",
"HexPublicKey": "035280c1851e63c17aa830cd3692a2df3f1dd6dd632db1dc34b733270139d80fce",
"HexPrivateKey": "4995a99088d0ef08871eb29015c2a9d0e08e97cc125f75fa96acc5fcc9665424",
"ETHAddress": "0x8f425808c36fe365566ad334708ad7aa173089d9",
"BTCAddress": "1BtwdDnoKMYKZQEnWCJypJs1tTCMHXV76n",
"WIF": "KygkSTenbC5L3d2cwwGPyx3eoHpfYihrAPEFZNtBmuZkM6PDrnMT",
"ECDSAAddress": "02b0af3aaf7df9501780feefef7f1eadb623ffff94006d557d26e8702223d02d47",
"Sr25519Address": "8c4f00a7447c9496cbe28b0532a9584931d3e4532362ccb966fb1dc359192970",
"Ed25519Address": "561a7a4a39d12385f8b3e6cbbe8d34a61371612941a126b4bf79a654bf753380",
"ECDSAAddressSS58": "KW6vKDuuTK3KxrEu2RV63ZLhPG7oQi2HvytUSvKsutGXZ73Lf",
"Sr25519AddressSS58": "5FEg2g6Qw2bg74q137BsZhLUhK19twVbjdrKxRspFxqP19rL",
"Ed25519AddressSS58": "5E1bqiagD4ccNL2SbtH9aSNyDDSv6GJHrXSRzyrv6UYVhFFK"
}
#+end_example
In addition to generating wallets with new mnemonics, you can use a
known mnemonic to generate wallets. *Caution* entering your seed
phrase in the command line should only be done for test
mnemonics. Never do this with a real seed phrase. The example below is a test vector from Substrate [[https://github.com/paritytech/substrate-bip39/blob/eef2f86337d2dab075806c12948e8a098aa59d59/src/lib.rs#L74][BIP-0039]] where the expected seed is ~44e9d125f037ac1d51f0a7d3649689d422c2af8b1ec8e00d71db4d7bf6d127e33f50c3d5c84fa3e5399c72d6cbbbbc4a49bf76f76d952f479d74655a2ef2d453~
#+begin_src shell :results output verbatim
polycli wallet inspect --raw-entropy --root-only --language english --password "Substrate" --mnemonic "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
#+end_src
#+RESULTS:
#+begin_example
{
"RootKey": "xprv9s21ZrQH143K3v7mpEZ2Evq5Shr7Gkueh57mCpzcQevKhm89A92iWThnLw7XwgQQWDD2U6AReNrSJ4MpW7C3vftFqJt6cAqocyx5ztZjhSt",
"Seed": "44e9d125f037ac1d51f0a7d3649689d422c2af8b1ec8e00d71db4d7bf6d127e33f50c3d5c84fa3e5399c72d6cbbbbc4a49bf76f76d952f479d74655a2ef2d453",
"Mnemonic": "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
"Passphrase": "Substrate",
"HexPublicKey": "03dc2260947d4b1c8b8a99da0b9501be7cf54ca4f81a75b688fc4826e7e673b679",
"HexPrivateKey": "ab06fea379c62a731c114ee1f3e1369c38640dd8e81d5c6cc0fac5c6743734b3",
"ETHAddress": "0x783fe366c65d45d29536e30ea89af7c99309ab5e",
"BTCAddress": "12Pgdh34QMjHRqZw5tFqybRHLLhZwK6KHZ",
"WIF": "L2xAZVcyY4na1AyiiKyYtKDbzvzsezRN47Xz1jYXQ1W6S3oCnbGA",
"ECDSAAddress": "0252697cb92cdaeaceaec4c04dee8d418d608d19e5c4af9ffe91b8085dfaf7e82a",
"Sr25519Address": "7ca8f71a700a713e470b93fd69e9e43ba08abac5fdeb7cb349c7fc157c72b803",
"Ed25519Address": "08ea85c02d6a6de8ef0e0a0ab2c4b92088886c5009dd1e20a54f4bab118ffbb6",
"ECDSAAddressSS58": "KW4ni1DcDYw6PKZFGnKdW2TFs8Jy2SDgCdDe137ugf4ppHv5C",
"Sr25519AddressSS58": "5Et9zFyTmAeRcmcwCGVPvMTktj2RtWChpcH8th5GzUc4GzaM",
"Ed25519AddressSS58": "5CGPucdtecQrEqc5iuChLgmCYpH8VwARrAzbbsCfgxCR8dG5"
}
#+end_example
This command also leverages the BIP-0032 library for hierarchically derived wallets.
#+begin_src shell
polycli wallet create --path "m/44'/0'/0'" --addresses 5
#+end_src
* Loadtest
The ~loadtest~ tool is meant to generate various types of load against
RPC end points. It leverages the [[https://pkg.go.dev/github.com/ethereum/go-ethereum/ethclient][~ethclient~]] library Go Ethereum to
interact with the blockchain.
#+begin_src shell :results output verbati
polycli loadtest --help
#+end_src
#+RESULTS:
#+begin_example
Loadtest gives us a simple way to run a generic load test against an eth/EVM style json RPC endpoint
Usage:
polycli loadtest rpc-endpoint [flags]
Flags:
--chain-id uint The chain id for the transactions that we're going to send (default 1256)
-c, --concurrency int Number of multiple requests to perform at a time. Default is one request at a time. (default 1)
-f, --function --mode f A specific function to be called if running with --mode f (default 1)
-h, --help help for loadtest
-i, --iterations uint If we're making contract calls, this controls how many times the contract will execute the instruction in a loop (default 100)
-m, --mode string t - sending transactions
d - deploy contract
c - call random contract functions
f - call specific contract function (default "t")
--pretty-logs Should we log in pretty format or JSON (default true)
--private-key string The hex encoded private key that we'll use to sending transactions (default "42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa")
--rate-limit float An overall limit to the number of requests per second. Give a number less than zero to remove this limit all together (default 4)
-n, --requests int Number of requests to perform for the benchmarking session. The default is to just perform a single request which usually leads to non-representative benchmarking results. (default 1)
--send-amount string The amount of wei that we'll send every transaction (default "0x38D7EA4C68000")
-t, --time-limit int Maximum number of seconds to spend for benchmarking. Use this to benchmark within a fixed total amount of time. Per default there is no timelimit. (default -1)
--to-address string The address that we're going to send to (default "0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF")
-v, --verbosity int 0 - Silent
100 Fatals
200 Errors
300 Warnings
400 INFO
500 Debug
600 Trace (default 200)
Global Flags:
--config string config file (default is $HOME/.polygon-cli.yaml)
#+end_example
Most of the options are expected in the help text. The default private
key is:
~42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa~. We
can use ~wallet inspect~ to get more information about this address,
in particular its ~ETHAddress~ if you want to check balance or
pre-mine value for this particular account.
#+begin_src shell :results output verbatim
polycli wallet inspect --mnemonic "code code code code code code code code code code code quality" --addresses 1
#+end_src
#+RESULTS:
#+begin_example
{
"RootKey": "xprv9s21ZrQH143K3ZLntW1qBWUaHqzxKZNCGVdFsnYofyo29KSyx656ra83jfTumFmimz5wvTg9HNTrokBQKhtnv2JF7zebWkXwgUAdpHKQB9f",
"Seed": "4057b0ec6b31714b08814519d7f9fa8e86fca3c25c092bc5e01569b2a94f14db5444afceefbad61580146873c31d7ed91410d9e756a567009b22f29a15f3bc56",
"Mnemonic": "code code code code code code code code code code code quality",
"DerivationPath": "m/44'/60'/0'",
"AccountPublicKey": "xpub6CNTeRn5mEp1n7yXWwLR1Gi5gsLbs3v2m4EYezFTUyojRTPW6SdVYtDcsyaz5LUFXyM8egPaqmYPo1HRrbQyKeZFW2LARwa8JXVq6RtEeEH",
"AccountPrivateKey": "xprv9yP7EvFBvsFiZdu4QuoQe8mM8qW7TbCBPqJwrbqqveGkYf4MYuKF15u92hXxobFws8EcHJ8nxpRb2QrK6rdykYGnkFSU1C6Tyb24NFNEFsh",
"BIP32PublicKey": "xpub6DiTzbwn4XuuVu8s6goxEXNPS9YpdQf5haz9m277RSWQeynoBjBoERaTBkNpABKZBCvfZa1yxmaZytb1cz2mkQhigRsjr2BzSKaR1sWNy9m",
"BIP32PrivateKey": "xprv9zj7b6QtEAMcHR4PzfGwsPRet7iLDwwELN4YxdhVs6yRnBTeeBsYgdFyLSAGu5vTwZKch69zV94LbMqsbqcaDjV95eQNdgo2Ec1sqwrPDnP",
"Addresses": [
{
"Path": "m/44'/60'/0'/0/0",
"HexPublicKey": "03507cf9a75e053cda6922467721ddb10412da9bec30620347d9529cc77fca2433",
"HexPrivateKey": "42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa",
"ETHAddress": "0x85da99c8a7c2c95964c8efd687e95e632fc533d6",
"BTCAddress": "1HdqWQqsVD41pKNHVrpFGNHqW6t3fuAfkh",
"WIF": "KyTPrvjtqbyu9J4bRAvJgnBeYAdrdvCAToceM1RwDGFjEAdra6Fa"
}
]
}
#+end_example
The ~--mode~ flag is important for this command:
- ~t~ We'll only performance transfers to the ~--to-address~. This is
a fast and common operation.
- ~d~ Will deploy the load testing contract over and over again
- ~c~ Will call random functions in our load test contract
- ~f~ will call a specific function on the load test contract. The
function is specified using the ~-f~ flag
This example is very simple. It runs 1000 requests at a max rate of 1
request per second against the http rpc endpoint on localhost. t's
running in transaction mode so it will perform simple transactions
send to the default address.
#+begin_src shell
polycli loadtest --verbosity 700 --chain-id 1256 --concurrency 1 --requests 1000 --rate-limit 1 --mode t http://localhost:8888
#+end_src
This example runs slower and specifically calls the [[https://www.evm.codes/#a4][LOG4]] function in
the load test contract in a loop for 25,078 iterations. That number
was picked specifically to require almost all of the gas for a single
transaction.
#+begin_src shell
polycli loadtest --verbosity 700 --chain-id 1256 --concurrency 1 --requests 50 --rate-limit 0.5 --mode f --function 164 --iterations 25078 http://private.validator-001.devnet02.pos-v3.polygon.private:8545
#+end_src
* Monitor
[[file:assets/polycli-monitor.gif]]
This is a basic tool for monitoring block production on a local RPC
end point.
If you're using the terminal UI and you'd like to be able to select
text for copying, you might need to use a modifier key.
* Nodekey
The ~nodekey~ command is still in progress, but the idea is to have a
simple command for generating a node key. Most clients will generate
this on the fly, but if we want to store the key pair during an
automated provisioning process, it's helpful to have the output be
structured
#+begin_src shell :results output verbatim
polycli nodekey
#+end_src
#+RESULTS:
: {"PublicKey":"17ffba3cf930eb2b35bf5b79b9d8e5f0431452be921280dc15210f454b6523cfa73e16a216ab44e0743250d1eede57167d00edb4654ed75a103d06645634a364\n","PrivateKey":"f997cbdd5e7cd57852bdabbe8287d8e881bf367134c1a6eaa4e90fccaca55acc","ENR":"enode://17ffba3cf930eb2b35bf5b79b9d8e5f0431452be921280dc15210f454b6523cfa73e16a216ab44e0743250d1eede57167d00edb4654ed75a103d06645634a364@0.0.0.0:30303?discport=40886"}
* RPC
This is a simple tool to avoid typing JSON on the command line while
making RPC calls. The implementation is generic and this is meant to
be a complete generic RPC tool.
#+begin_src shell
polycli rpc https://polygon-rpc.com eth_blockNumber
polycli rpc https://polygon-rpc.com eth_getBlockByNumber 0x1e99576 true
#+end_src
* Dumpblocks
For various reasons, we might want to dump a large range of blocks for
analytics or replay purposes. This is a simple util to export over RPC
a range of blocks.
This would download the first 500K blocks and zip them and then look
for blocks with transactions that create an account.
#+begin_src shell
polycli dumpblocks http://172.26.26.12:8545/ 0 500000 | gzip > foo.gz
zcat < foo.gz | jq '. | select(.transactions | length > 0) | select(.transactions[].to == null)'
#+end_src
* Metrics To Dash
Given an openmetrics / prometheus response, create a json file that
can be used to create a dashboard with all of the metrics in one view
#+begin_src shell
go run main.go metrics-to-dash -i avail-metrics.txt -p avail. -t "Avail Devnet Dashboard" -T basedn -D devnet01.avail.polygon.private -T host -D validator-001 -s substrate_ -s sub_ -P true -S true
go run main.go metrics-to-dash -i avail-light-metrics.txt -p avail_light. -t "Avail Light Devnet Dashboard" -T basedn -D devnet01.avail.polygon.private -T host -D validator-001 -s substrate_ -s sub_ -P true -S true
#+end_src
* Adding Commands
Script to setup this repo
#+BEGIN_SRC bash
cobra-cli init
cobra-cli add version
cobra-cli add hash
cobra-cli add mnemonic
#+END_SRC
This is the content of my ~~/.cobra.yaml~ file
#+begin_src yaml
---
author: Polygon <engineering@polygon.technology>
license: lgpl-3.0
useViper: true
#+end_src
* Testing with Geth
While working on some of the Polygon CLI tools, we'll run geth in dev
mode in order to make sure the various functions work properly. First,
we'll startup geth.
#+begin_src shell
# Geth
./build/bin/geth --dev --dev.period 2 --http --http.addr localhost --http.port 8545 --http.api admin,debug,web3,eth,txpool,personal,miner,net --verbosity 5 --rpc.gascap 50000000 --rpc.txfeecap 0 --miner.gaslimit 10 --miner.gasprice 1 --gpo.blocks 1 --gpo.percentile 1 --gpo.maxprice 10 --gpo.ignoreprice 2 --dev.gaslimit 50000000
# v3
go run cmd/borv3/main.go server --dev \
--dev.period 2 \
--ws --ws.port 8546 \
--http --http.port 8545 \
--jsonrpc.modules eth,web3,personal,net \
--log-level debug \
--ipcpath ./borv3ipc \
--rpc.gascap 18446744073709551615 \
--rpc.txfeecap 0 \
--miner.gaslimit 10 \
--miner.gasprice 1 \
--gpo.blocks 1 \
--gpo.percentile 1 \
--gpo.maxprice 10 \
--gpo.ignoreprice 2
#+end_src
Simple startup script for borv3 from our testing
#+begin_src bash
#!/bin/bash
num=4
rm -rf test-dir-*
rm genesis.json
# rm borv3
# go build -o borv3 cmd/borv3/main.go
./borv3 init-account --datadir test-dir --num $num
./borv3 init-genesis --premine 0x85da99c8a7c2c95964c8efd687e95e632fc533d6
seq 1 $num | while read -r line
do
./borv3 server --chain genesis.json --datadir test-dir-$line --port 3030$line --mine --http --http.port 854$line --jsonrpc.modules eth --rpc.gascap 18446744073709551615 &
done
# ps aux | grep borv3 | grep -v grep | awk '{print $2}' | xargs kill -9
#+end_src
In the logs, we'll see a line that says IPC endpoint opened:
#+begin_example
INFO [08-14|16:09:31.451] Starting peer-to-peer node instance=Geth/v1.10.21-stable-67109427/darwin-arm64/go1.18.1
WARN [08-14|16:09:31.451] P2P server will be useless, neither dialing nor listening
DEBUG[08-14|16:09:31.452] IPCs registered namespaces=admin,debug,web3,eth,txpool,personal,clique,miner,net,engine
INFO [08-14|16:09:31.452] IPC endpoint opened url=/var/folders/zs/k8swqskj1t79cgnjh6yt0fqm0000gn/T/geth.ipc
INFO [08-14|16:09:31.452] Generated ephemeral JWT secret secret=0xdfa5c30e07ef1041d15a2dbf0865386305330128b792d4a461cddb9bf38e416e
#+end_example
I'll usually then use that line to attach
#+begin_src shell
./build/bin/geth attach /var/folders/zs/k8swqskj1t79cgnjh6yt0fqm0000gn/T/geth.ip
#+end_src
After attaching to geth, we can fund the default load testing account
with some currency.
#+begin_src shell
eth.coinbase==eth.accounts[0]
eth.sendTransaction({from: eth.coinbase, to: "0x85da99c8a7c2c95964c8efd687e95e632fc533d6", value: web3.toWei(5000, "ether")})
#+end_src
Then we can generate some load to make sure that there are some blocks
with transactions being created. ~1337~ is the chain id that's used in
local geth.
#+begin_src shell
polycli loadtest --verbosity 700 --chain-id 1337 --concurrency 1 --requests 1000 --rate-limit 5 --mode c http://127.0.0.1:8545
#+end_src
Then we can monitor the chain:
* Reference
Sending some value to the default load testing account
Listening for re-orgs
#+begin_src shell
socat - UNIX-CONNECT:/var/folders/zs/k8swqskj1t79cgnjh6yt0fqm0000gn/T/geth.ipc
{"id": 1, "method": "eth_subscribe", "params": ["newHeads"]}
#+end_src
Useful RPCs when testing
#+begin_src shell
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 '{"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
#+end_src
#+begin_src shell
websocat ws://34.208.176.205:9944
{"jsonrpc":"2.0", "id": 1, "method": "chain_subscribeNewHead", "params": []}
#+end_src
* Load Test Contract
The codebase has a contract that used for load testing. It's written
in Yul and Solidity. The workflow for modifying this contract is.
1. Make changes to file:contracts/LoadTester.sol
2. Compile the contracts:
- ~solc LoadTester.sol --bin --abi -o . --overwrite~
3. Run ~abigen~
- ~abigen --abi LoadTester.abi --pkg contracts --type LoadTester --bin LoadTester.bin --out loadtester.go~
4. Run the loadtester to enure it deploys and runs sucessfully
- ~go run main.go loadtest --verbosity 700 http://127.0.0.1:8541~
Documentation
¶
Overview ¶
Copyright © 2022 Polygon <engineering@polygon.technology>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Click to show internal directories.
Click to hide internal directories.