veth is a bash script that uses Docker to run multile instances of geth locally.
First - install docker, then download and install the script:
$ cd ~
$ docker run --rm binocarlos/veth:v0.0.8 > veth
$ sudo mv veth /usr/local/bin/veth
$ sudo chmod a+x /usr/local/bin/veth
Run all commands from the root of your project - veth keeps state in the .veth
folder which should be .gitignored
Each node has a name that you pass to each of the commands to dictate which node to operate on. If you are working with a single node you can omit the name and it will default to node1
.
Initialize your nodes:
$ veth init chain1
$ veth init chain2
This will create folders to hold blockchain state: .veth/{chain1,chain2}
Each state folder contains:
account.txt
- the account id for the miner accountpassword.txt
- the password for the miner account- state for the geth node
List the current blockchain folders:
$ veth list
To remove a node's state, delete it's state folder:
$ rm -f .veth/node2
Start chain1, then start chain2 pointing to chain1:
$ veth start chain1
$ veth start chain2 chain1
If you had a third node - you could point it to either chain1 or chain2:
$ veth start chain3 chain2
If you want to run veth on node A then run veth on node B connected to node A:
On node A:
$ export VETH_EXPOSE_RPC=1
$ veth init
$ veth cluster
$ veth enode
This will print the enode ID for node A - slack it ready for node B. You also need to slack the IP address of node A.
Then on node B:
$ export VETH_EXPOSE_RPC=1
$ veth init
$ veth connect 192.168.0.20 69905763c3afd831a58f3368093933a38038f56a453f63b3a11ecf9a66d5b3914682787f96ecc57d067d8bf227633488f225aac6211e8f838cffabc69ccd549e
To follows logs for a node:
$ veth logs chain1
To attach to the console for a node:
$ veth attach chain1
To run JS commands directly:
$ veth exec chain1 'admin.nodeInfo.id'
To stop a node:
$ veth stop chain1
To get a 2 node geth cluster running:
$ veth init chain1
$ veth init chain2
$ veth start chain1
$ veth start chain2 chain1
$ veth exec chain1 'admin.peers'
$ veth attach chain1
$ veth logs chain1
The networkID = 23422
- you can override this with:
$ GETH_NETWORK_ID=10050