Setup your own private Proof-of-Work Ethereum network with Geth
Step 1. Defining the private genesis state
genesis.json
{
"config": {
"chainId": 0,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc" : {},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20000",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}
If you'd like to pre-fund some accounts for easier testing, you can populate the alloc field with account configs:
"alloc": {
"0x0000000000000000000000000000000000000001": {"balance": "111111111"},
"0x0000000000000000000000000000000000000002": {"balance": "222222222"}
}
Step 2. Init the private network
With the genesis state defined in the above JSON file, you'll need to initialize every Geth node with it prior to starting it up to ensure all blockchain parameters are correctly set:
node 1
[furnace@localhost devnet]$ geth --datadir node1 init genesis.json
WARN [09-06|09:10:00.433] Sanitizing cache to Go's GC limits provided=1024 updated=613
INFO [09-06|09:10:00.434] Maximum peer count ETH=25 LES=0 total=25
INFO [09-06|09:10:00.434] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/network/private/pow/github/devnet/node1/geth/chaindata cache=16 handles=16
INFO [09-06|09:10:00.437] Writing custom genesis block
INFO [09-06|09:10:00.437] Persisted trie from memory database nodes=4 size=660.00B time=35.11µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [09-06|09:10:00.437] Successfully wrote genesis state database=chaindata hash=46c37c…95a840
INFO [09-06|09:10:00.437] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/network/private/pow/github/devnet/node1/geth/lightchaindata cache=16 handles=16
INFO [09-06|09:10:00.440] Writing custom genesis block
INFO [09-06|09:10:00.440] Persisted trie from memory database nodes=4 size=660.00B time=99.92µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [09-06|09:10:00.440] Successfully wrote genesis state database=lightchaindata hash=46c37c…95a840
[furnace@localhost devnet]$
Note
If you not config the datadir options, then the default datadir will be ~/.ethereum
node 2
[furnace@localhost devnet]$ geth --datadir node2 init genesis.json
WARN [09-06|09:10:09.024] Sanitizing cache to Go's GC limits provided=1024 updated=613
INFO [09-06|09:10:09.025] Maximum peer count ETH=25 LES=0 total=25
INFO [09-06|09:10:09.026] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/network/private/pow/github/devnet/node2/geth/chaindata cache=16 handles=16
INFO [09-06|09:10:09.029] Writing custom genesis block
INFO [09-06|09:10:09.029] Persisted trie from memory database nodes=4 size=660.00B time=34.941µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [09-06|09:10:09.029] Successfully wrote genesis state database=chaindata hash=46c37c…95a840
INFO [09-06|09:10:09.029] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/network/private/pow/github/devnet/node2/geth/lightchaindata cache=16 handles=16
INFO [09-06|09:10:09.032] Writing custom genesis block
INFO [09-06|09:10:09.032] Persisted trie from memory database nodes=4 size=660.00B time=99.267µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [09-06|09:10:09.032] Successfully wrote genesis state database=lightchaindata hash=46c37c…95a840
[furnace@localhost devnet]$
node 3
[furnace@localhost devnet]$ geth --datadir node3 init genesis.json
WARN [09-06|09:10:13.654] Sanitizing cache to Go's GC limits provided=1024 updated=613
INFO [09-06|09:10:13.655] Maximum peer count ETH=25 LES=0 total=25
INFO [09-06|09:10:13.655] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/network/private/pow/github/devnet/node3/geth/chaindata cache=16 handles=16
INFO [09-06|09:10:13.659] Writing custom genesis block
INFO [09-06|09:10:13.659] Persisted trie from memory database nodes=4 size=660.00B time=31.907µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [09-06|09:10:13.659] Successfully wrote genesis state database=chaindata hash=46c37c…95a840
INFO [09-06|09:10:13.659] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/network/private/pow/github/devnet/node3/geth/lightchaindata cache=16 handles=16
INFO [09-06|09:10:13.661] Writing custom genesis block
INFO [09-06|09:10:13.662] Persisted trie from memory database nodes=4 size=660.00B time=100.359µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [09-06|09:10:13.662] Successfully wrote genesis state database=lightchaindata hash=46c37c…95a840
[furnace@localhost devnet]$
Step 3. Creating the rendezvous point
[furnace@localhost devnet]$ bootnode --genkey=boot.key
[furnace@localhost devnet]$ bootnode --nodekey=boot.key
INFO [09-04|07:54:16.130] UDP listener up self=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf715286e812b3ce70a5c9c6797d71cdbd1432e2ac1a0f6cb06cab3e9e7dd33aea4@[::]:30301
Step 4. Starting up your member nodes
node 1
[furnace@localhost devnet]$ geth --datadir=node1 --bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf715286e812b3ce70a5c9c6797d71cdbd1432e2ac1a0f6cb06cab3e9e7dd33aea4@127.0.0.1:30301
WARN [09-04|07:57:20.117] Sanitizing cache to Go's GC limits provided=1024 updated=613
INFO [09-04|07:57:20.118] Maximum peer count ETH=25 LES=0 total=25
INFO [09-04|07:57:20.119] Starting peer-to-peer node instance=Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
INFO [09-04|07:57:20.119] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node1/geth/chaindata cache=459 handles=1024
INFO [09-04|07:57:20.122] Writing default main-net genesis block
INFO [09-04|07:57:20.337] Persisted trie from memory database nodes=12356 size=1.88mB time=40.700007ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [09-04|07:57:20.338] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
INFO [09-04|07:57:20.338] Disk storage enabled for ethash caches dir=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node1/geth/ethash count=3
INFO [09-04|07:57:20.338] Disk storage enabled for ethash DAGs dir=/home/furnace/.ethash count=2
INFO [09-04|07:57:20.338] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [09-04|07:57:20.338] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|07:57:20.338] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|07:57:20.338] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|07:57:20.338] Regenerated local transaction journal transactions=0 accounts=0
INFO [09-04|07:57:20.338] Starting P2P networking
INFO [09-04|07:57:22.442] UDP listener up self=enode://537df2a21cf62056d3008ca01b2d839adef3ea8fdc977bbe92eaba4422b51de6d7546a65ca7e912ccf9b58b786d6ab38d1a9cedba04cd9333920ce917d8b285f@[::]:30303
INFO [09-04|07:57:22.443] IPC endpoint opened url=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node1/geth.ipc
INFO [09-04|07:57:22.444] RLPx listener up self=enode://537df2a21cf62056d3008ca01b2d839adef3ea8fdc977bbe92eaba4422b51de6d7546a65ca7e912ccf9b58b786d6ab38d1a9cedba04cd9333920ce917d8b285f@[::]:30303
Note
The default port is 30303.
node 2
[furnace@localhost ~]$ geth --datadir=node2 --bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf715286e812b3ce70a5c9c6797d71cdbd1432e2ac1a0f6cb06cab3e9e7dd33aea4@127.0.0.1:30301
WARN [09-04|08:03:38.276] Sanitizing cache to Go's GC limits provided=1024 updated=613
INFO [09-04|08:03:38.277] Maximum peer count ETH=25 LES=0 total=25
INFO [09-04|08:03:38.277] Starting peer-to-peer node instance=Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
INFO [09-04|08:03:38.277] Allocated cache and file handles database=/home/furnace/node2/geth/chaindata cache=459 handles=1024
INFO [09-04|08:03:38.282] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
INFO [09-04|08:03:38.282] Disk storage enabled for ethash caches dir=/home/furnace/node2/geth/ethash count=3
INFO [09-04|08:03:38.282] Disk storage enabled for ethash DAGs dir=/home/furnace/.ethash count=2
INFO [09-04|08:03:38.282] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [09-04|08:03:38.283] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:03:38.283] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:03:38.283] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:03:38.283] Loaded local transaction journal transactions=0 dropped=0
INFO [09-04|08:03:38.283] Regenerated local transaction journal transactions=0 accounts=0
INFO [09-04|08:03:38.283] Starting P2P networking
Fatal: Error starting protocol stack: listen udp :30303: bind: address already in use
[furnace@localhost ~]$
Note
Startup failed because the default port 30303 was already in use. Fix it by point the port option.
Set option port to 30304
[furnace@localhost devnet]$ geth --datadir=node2 --bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf715286e812b3ce70a5c9c6797d71cdbd1432e2ac1a0f6cb06cab3e9e7dd33aea4@127.0.0.1:30301 --port=30304
WARN [09-04|08:28:01.495] Sanitizing cache to Go's GC limits provided=1024 updated=613
INFO [09-04|08:28:01.496] Maximum peer count ETH=25 LES=0 total=25
INFO [09-04|08:28:01.497] Starting peer-to-peer node instance=Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
INFO [09-04|08:28:01.497] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node2/geth/chaindata cache=459 handles=1024
INFO [09-04|08:28:01.500] Writing default main-net genesis block
INFO [09-04|08:28:01.710] Persisted trie from memory database nodes=12356 size=1.88mB time=39.611433ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [09-04|08:28:01.710] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
INFO [09-04|08:28:01.710] Disk storage enabled for ethash caches dir=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node2/geth/ethash count=3
INFO [09-04|08:28:01.710] Disk storage enabled for ethash DAGs dir=/home/furnace/.ethash count=2
INFO [09-04|08:28:01.710] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [09-04|08:28:01.710] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:28:01.710] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:28:01.710] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:28:01.710] Regenerated local transaction journal transactions=0 accounts=0
INFO [09-04|08:28:01.710] Starting P2P networking
INFO [09-04|08:28:03.814] UDP listener up self=enode://646be084b610b5187b6b2f59e572b2c421ed2b2dabb303d6cbb768641ada3e5082a740ae9bed0da5ca7558e468235289b885d458543319702f242a451a551027@[::]:30304
INFO [09-04|08:28:03.815] IPC endpoint opened url=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node2/geth.ipc
INFO [09-04|08:28:03.816] RLPx listener up self=enode://646be084b610b5187b6b2f59e572b2c421ed2b2dabb303d6cbb768641ada3e5082a740ae9bed0da5ca7558e468235289b885d458543319702f242a451a551027@[::]:30304
Step 5. Geth attach by ipc
Attach to node 1
[furnace@localhost devnet]$ geth attach node1/geth.ipc
WARN [09-04|07:58:34.653] Sanitizing cache to Go's GC limits provided=1024 updated=613
Welcome to the Geth JavaScript console!
instance: Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
> eth.blockNumber
0
> exit
[furnace@localhost devnet]$
Attach to node 2
[furnace@localhost devnet]$ geth attach node2/ge
geth/ geth.ipc
[furnace@localhost devnet]$ geth attach node2/geth.ipc
WARN [09-04|08:28:06.980] Sanitizing cache to Go's GC limits provided=1024 updated=613
Welcome to the Geth JavaScript console!
instance: Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
> eth.blockNumber
0
> exit
[furnace@localhost devnet]$
Step 6. Geth attach by rpc
[furnace@localhost devnet]$ geth attach http://127.0.0.1:8545
WARN [09-04|07:59:03.539] Sanitizing cache to Go's GC limits provided=1024 updated=613
Fatal: Failed to start the JavaScript console: api modules: Post http://127.0.0.1:8545: dial tcp 127.0.0.1:8545: connect: connection refused
[furnace@localhost devnet]$
note
This should startup node by set option rpc, and maybe rpcport when the default port was used.
Startup node 1 with rpc option
[furnace@localhost devnet]$ geth --datadir=node1 --bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf715286e812b3ce70a5c9c6797d71cdbd1432e2ac1a0f6cb06cab3e9e7dd33aea4@127.0.0.1:30301 --rpc
WARN [09-04|08:32:48.699] Sanitizing cache to Go's GC limits provided=1024 updated=613
INFO [09-04|08:32:48.700] Maximum peer count ETH=25 LES=0 total=25
INFO [09-04|08:32:48.700] Starting peer-to-peer node instance=Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
INFO [09-04|08:32:48.700] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node1/geth/chaindata cache=459 handles=1024
INFO [09-04|08:32:48.743] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
INFO [09-04|08:32:48.743] Disk storage enabled for ethash caches dir=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node1/geth/ethash count=3
INFO [09-04|08:32:48.743] Disk storage enabled for ethash DAGs dir=/home/furnace/.ethash count=2
INFO [09-04|08:32:48.743] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [09-04|08:32:48.743] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:32:48.743] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:32:48.743] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:32:48.743] Loaded local transaction journal transactions=0 dropped=0
INFO [09-04|08:32:48.743] Regenerated local transaction journal transactions=0 accounts=0
INFO [09-04|08:32:48.743] Starting P2P networking
INFO [09-04|08:32:50.853] UDP listener up self=enode://537df2a21cf62056d3008ca01b2d839adef3ea8fdc977bbe92eaba4422b51de6d7546a65ca7e912ccf9b58b786d6ab38d1a9cedba04cd9333920ce917d8b285f@[::]:30303
INFO [09-04|08:32:50.854] IPC endpoint opened url=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node1/geth.ipc
INFO [09-04|08:32:50.854] HTTP endpoint opened url=http://127.0.0.1:8545 cors= vhosts=localhost
INFO [09-04|08:32:50.855] RLPx listener up self=enode://537df2a21cf62056d3008ca01b2d839adef3ea8fdc977bbe92eaba4422b51de6d7546a65ca7e912ccf9b58b786d6ab38d1a9cedba04cd9333920ce917d8b285f@[::]:30303
Attach node 1 by rpc
[furnace@localhost devnet]$ geth attach http://localhost:8545
WARN [09-04|08:33:10.002] Sanitizing cache to Go's GC limits provided=1024 updated=613
Welcome to the Geth JavaScript console!
instance: Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
modules: eth:1.0 net:1.0 rpc:1.0 web3:1.0
> eth.blockNumber
0
> exit
[furnace@localhost devnet]$ geth attach http://127.0.0.1:8545
WARN [09-04|08:35:09.600] Sanitizing cache to Go's GC limits provided=1024 updated=613
Welcome to the Geth JavaScript console!
instance: Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
modules: eth:1.0 net:1.0 rpc:1.0 web3:1.0
> eth.blockNumber
0
> exit
[furnace@localhost devnet]$
Startup node 2 with rpc option
[furnace@localhost devnet]$ geth --datadir=node2 --bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf715286e812b3ce70a5c9c6797d71cdbd1432e2ac1a0f6cb06cab3e9e7dd33aea4@127.0.0.1:30301 --port=30304 --rpc
WARN [09-04|08:37:17.912] Sanitizing cache to Go's GC limits provided=1024 updated=613
INFO [09-04|08:37:17.912] Maximum peer count ETH=25 LES=0 total=25
INFO [09-04|08:37:17.913] Starting peer-to-peer node instance=Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
INFO [09-04|08:37:17.913] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node2/geth/chaindata cache=459 handles=1024
INFO [09-04|08:37:17.959] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
INFO [09-04|08:37:17.959] Disk storage enabled for ethash caches dir=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node2/geth/ethash count=3
INFO [09-04|08:37:17.959] Disk storage enabled for ethash DAGs dir=/home/furnace/.ethash count=2
INFO [09-04|08:37:17.959] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [09-04|08:37:17.960] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:37:17.960] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:37:17.960] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:37:17.960] Loaded local transaction journal transactions=0 dropped=0
INFO [09-04|08:37:17.960] Regenerated local transaction journal transactions=0 accounts=0
INFO [09-04|08:37:17.960] Starting P2P networking
INFO [09-04|08:37:20.066] UDP listener up self=enode://646be084b610b5187b6b2f59e572b2c421ed2b2dabb303d6cbb768641ada3e5082a740ae9bed0da5ca7558e468235289b885d458543319702f242a451a551027@[::]:30304
INFO [09-04|08:37:20.067] IPC endpoint opened url=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node2/geth.ipc
INFO [09-04|08:37:20.067] IPC endpoint closed endpoint=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node2/geth.ipc
INFO [09-04|08:37:20.067] Blockchain manager stopped
INFO [09-04|08:37:20.067] Stopping Ethereum protocol
INFO [09-04|08:37:20.068] RLPx listener up self=enode://646be084b610b5187b6b2f59e572b2c421ed2b2dabb303d6cbb768641ada3e5082a740ae9bed0da5ca7558e468235289b885d458543319702f242a451a551027@[::]:30304
INFO [09-04|08:37:20.068] Ethereum protocol stopped
INFO [09-04|08:37:20.068] Transaction pool stopped
INFO [09-04|08:37:20.068] Database closed database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node2/geth/chaindata
Fatal: Error starting protocol stack: listen tcp 127.0.0.1:8545: bind: address already in use
[furnace@localhost devnet]$
Note
The default rpc port 8545 was used. Fix this problem by set rpcport option to 8645.
[furnace@localhost devnet]$ geth --datadir=node2 --bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf715286e812b3ce70a5c9c6797d71cdbd1432e2ac1a0f6cb06cab3e9e7dd33aea4@127.0.0.1:30301 --port=30304 --rpc --rpcport=8645
WARN [09-04|08:39:05.389] Sanitizing cache to Go's GC limits provided=1024 updated=613
INFO [09-04|08:39:05.390] Maximum peer count ETH=25 LES=0 total=25
INFO [09-04|08:39:05.390] Starting peer-to-peer node instance=Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
INFO [09-04|08:39:05.390] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node2/geth/chaindata cache=459 handles=1024
INFO [09-04|08:39:05.397] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
INFO [09-04|08:39:05.397] Disk storage enabled for ethash caches dir=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node2/geth/ethash count=3
INFO [09-04|08:39:05.397] Disk storage enabled for ethash DAGs dir=/home/furnace/.ethash count=2
INFO [09-04|08:39:05.397] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [09-04|08:39:05.398] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:39:05.398] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:39:05.398] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:39:05.398] Loaded local transaction journal transactions=0 dropped=0
INFO [09-04|08:39:05.398] Regenerated local transaction journal transactions=0 accounts=0
INFO [09-04|08:39:05.398] Starting P2P networking
INFO [09-04|08:39:07.505] UDP listener up self=enode://646be084b610b5187b6b2f59e572b2c421ed2b2dabb303d6cbb768641ada3e5082a740ae9bed0da5ca7558e468235289b885d458543319702f242a451a551027@[::]:30304
INFO [09-04|08:39:07.506] IPC endpoint opened url=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node2/geth.ipc
INFO [09-04|08:39:07.506] HTTP endpoint opened url=http://127.0.0.1:8645 cors= vhosts=localhost
INFO [09-04|08:39:07.508] RLPx listener up self=enode://646be084b610b5187b6b2f59e572b2c421ed2b2dabb303d6cbb768641ada3e5082a740ae9bed0da5ca7558e468235289b885d458543319702f242a451a551027@[::]:30304
Attach node 2 by rpc
[furnace@localhost devnet]$ geth attach http://127.0.0.1:8645
WARN [09-04|08:39:19.784] Sanitizing cache to Go's GC limits provided=1024 updated=613
Welcome to the Geth JavaScript console!
instance: Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
modules: eth:1.0 net:1.0 rpc:1.0 web3:1.0
> eth.blockNumber
0
> exit
[furnace@localhost devnet]$
Appendix A. Programatically interfacing Geth nodes
As a developer, sooner rather than later you'll want to start interacting with Geth and the Ethereum network via your own programs and not manually through the console. To aid this, Geth has built-in support for a JSON-RPC based APIs (standard APIs and Geth specific APIs). These can be exposed via HTTP, WebSockets and IPC (unix sockets on unix based platforms, and named pipes on Windows).
The IPC interface is enabled by default and exposes all the APIs supported by Geth, whereas the HTTP and WS interfaces need to manually be enabled and only expose a subset of APIs due to security reasons. These can be turned on/off and configured as you'd expect.
HTTP based JSON-RPC API options:
- rpc Enable the HTTP-RPC server
- rpcaddr HTTP-RPC server listening interface (default: "localhost")
- rpcport HTTP-RPC server listening port (default: 8545)
- rpcapi API's offered over the HTTP-RPC interface (default: "eth,net,web3")
- rpccorsdomain Comma separated list of domains from which to accept cross origin requests (browser enforced)
- ws Enable the WS-RPC server
- wsaddr WS-RPC server listening interface (default: "localhost")
- wsport WS-RPC server listening port (default: 8546)
- wsapi API's offered over the WS-RPC interface (default: "eth,net,web3")
- wsorigins Origins from which to accept websockets requests
- ipcdisable Disable the IPC-RPC server
- ipcapi API's offered over the IPC-RPC interface (default: "admin,debug,eth,miner,net,personal,shh,txpool,web3")
- ipcpath Filename for IPC socket/pipe within the datadir (explicit paths escape it)
Appendix B. Running a private miner
Startup node 3 as miner
[furnace@localhost devnet]$ geth --datadir=node3 --bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf715286e812b3ce70a5c9c6797d71cdbd1432e2ac1a0f6cb06cab3e9e7dd33aea4@127.0.0.1:30301 --port=30305 --rpc --rpcport=8745 --mine --minerthreads=1 --etherbase=0x0000000000000000000000000000000000000000
WARN [09-04|08:46:40.525] Sanitizing cache to Go's GC limits provided=1024 updated=613
INFO [09-04|08:46:40.525] Maximum peer count ETH=25 LES=0 total=25
INFO [09-04|08:46:40.526] Starting peer-to-peer node instance=Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
INFO [09-04|08:46:40.526] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node3/geth/chaindata cache=459 handles=1024
INFO [09-04|08:46:40.532] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
INFO [09-04|08:46:40.532] Disk storage enabled for ethash caches dir=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node3/geth/ethash count=3
INFO [09-04|08:46:40.532] Disk storage enabled for ethash DAGs dir=/home/furnace/.ethash count=2
INFO [09-04|08:46:40.532] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [09-04|08:46:40.532] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:46:40.533] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:46:40.533] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:46:40.533] Loaded local transaction journal transactions=0 dropped=0
INFO [09-04|08:46:40.533] Regenerated local transaction journal transactions=0 accounts=0
INFO [09-04|08:46:40.533] Starting P2P networking
INFO [09-04|08:46:42.639] UDP listener up self=enode://7fc29b99d8e8d2459b263d03fd24cfd67c841a3318d27125095a72c5ce430e3a0b3f2133b0e9835a6a06d488ebdf9b622c7fbfd163df8b4b88378179b1097349@[::]:30305
INFO [09-04|08:46:42.639] IPC endpoint opened url=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node3/geth.ipc
INFO [09-04|08:46:42.640] HTTP endpoint opened url=http://127.0.0.1:8745 cors= vhosts=localhost
INFO [09-04|08:46:42.640] Transaction pool price threshold updated price=18000000000
INFO [09-04|08:46:42.640] Updated mining threads threads=1
INFO [09-04|08:46:42.640] Transaction pool price threshold updated price=18000000000
ERROR[09-04|08:46:42.640] Cannot start mining without etherbase err="etherbase must be explicitly specified"
Fatal: Failed to start mining: etherbase missing: etherbase must be explicitly specified
[furnace@localhost devnet]$
Note
The etherbase should be quoted.
[furnace@localhost devnet]$ geth --datadir=node3 --bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf715286e812b3ce70a5c9c6797d71cdbd1432e2ac1a0f6cb06cab3e9e7dd33aea4@127.0.0.1:30301 --port=30305 --rpc --rpcport=8745 --mine --minerthreads=1 --etherbase="0x0000000000000000000000000000000000000000"
WARN [09-04|08:48:41.798] Sanitizing cache to Go's GC limits provided=1024 updated=613
INFO [09-04|08:48:41.798] Maximum peer count ETH=25 LES=0 total=25
INFO [09-04|08:48:41.799] Starting peer-to-peer node instance=Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
INFO [09-04|08:48:41.799] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node3/geth/chaindata cache=459 handles=1024
INFO [09-04|08:48:41.805] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
INFO [09-04|08:48:41.805] Disk storage enabled for ethash caches dir=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node3/geth/ethash count=3
INFO [09-04|08:48:41.806] Disk storage enabled for ethash DAGs dir=/home/furnace/.ethash count=2
INFO [09-04|08:48:41.806] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [09-04|08:48:41.806] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:48:41.806] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:48:41.806] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:48:41.806] Loaded local transaction journal transactions=0 dropped=0
INFO [09-04|08:48:41.806] Regenerated local transaction journal transactions=0 accounts=0
INFO [09-04|08:48:41.806] Starting P2P networking
INFO [09-04|08:48:43.913] UDP listener up self=enode://7fc29b99d8e8d2459b263d03fd24cfd67c841a3318d27125095a72c5ce430e3a0b3f2133b0e9835a6a06d488ebdf9b622c7fbfd163df8b4b88378179b1097349@[::]:30305
INFO [09-04|08:48:43.914] IPC endpoint opened url=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node3/geth.ipc
INFO [09-04|08:48:43.914] HTTP endpoint opened url=http://127.0.0.1:8745 cors= vhosts=localhost
INFO [09-04|08:48:43.914] Transaction pool price threshold updated price=18000000000
INFO [09-04|08:48:43.914] Updated mining threads threads=1
INFO [09-04|08:48:43.914] Transaction pool price threshold updated price=18000000000
INFO [09-04|08:48:43.914] Etherbase automatically configured address=0x3ca39a64bC1eda8669D539631B44DbD4A43Ed0F8
INFO [09-04|08:48:43.914] Commit new mining work number=1 sealhash=f891fc…479d70 uncles=0 txs=0 gas=0 fees=0 elapsed=112.78µs
INFO [09-04|08:48:43.916] RLPx listener up self=enode://7fc29b99d8e8d2459b263d03fd24cfd67c841a3318d27125095a72c5ce430e3a0b3f2133b0e9835a6a06d488ebdf9b622c7fbfd163df8b4b88378179b1097349@[::]:30305
INFO [09-04|08:48:47.393] Generating DAG in progress epoch=0 percentage=0 elapsed=2.991s
INFO [09-04|08:48:50.359] Generating DAG in progress epoch=0 percentage=1 elapsed=5.957s
INFO [09-04|08:48:53.311] Generating DAG in progress epoch=0 percentage=2 elapsed=8.909s
Attach to node 3 and Create new accout
[furnace@localhost devnet]$ geth attach node3/geth.ipc
WARN [09-04|08:47:39.823] Sanitizing cache to Go's GC limits provided=1024 updated=613
Welcome to the Geth JavaScript console!
instance: Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
> personal.newAccount("123456")
"0x3ca39a64bc1eda8669d539631b44dbd4a43ed0f8"
> exit
[furnace@localhost devnet]$
[furnace@localhost devnet]$ geth --datadir=node3 --bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf715286e812b3ce70a5c9c6797d71cdbd1432e2ac1a0f6cb06cab3e9e7dd33aea4@127.0.0.1:30301 --port=30305 --rpc --rpcport=8745 --mine --minerthreads=1 --etherbase="0x3ca39a64bc1eda8669d539631b44dbd4a43ed0f8"
WARN [09-04|08:51:58.331] Sanitizing cache to Go's GC limits provided=1024 updated=613
INFO [09-04|08:51:58.332] Maximum peer count ETH=25 LES=0 total=25
INFO [09-04|08:51:58.332] Starting peer-to-peer node instance=Geth/v1.8.15-unstable-c1c003e4/linux-amd64/go1.11
INFO [09-04|08:51:58.332] Allocated cache and file handles database=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node3/geth/chaindata cache=459 handles=1024
INFO [09-04|08:51:58.338] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
INFO [09-04|08:51:58.338] Disk storage enabled for ethash caches dir=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node3/geth/ethash count=3
INFO [09-04|08:51:58.338] Disk storage enabled for ethash DAGs dir=/home/furnace/.ethash count=2
INFO [09-04|08:51:58.338] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [09-04|08:51:58.338] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:51:58.338] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:51:58.338] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [09-04|08:51:58.339] Loaded local transaction journal transactions=0 dropped=0
INFO [09-04|08:51:58.339] Regenerated local transaction journal transactions=0 accounts=0
INFO [09-04|08:51:58.339] Starting P2P networking
INFO [09-04|08:52:00.462] UDP listener up self=enode://7fc29b99d8e8d2459b263d03fd24cfd67c841a3318d27125095a72c5ce430e3a0b3f2133b0e9835a6a06d488ebdf9b622c7fbfd163df8b4b88378179b1097349@[::]:30305
INFO [09-04|08:52:00.463] IPC endpoint opened url=/home/furnace/bitbucket/zblockchain/ethereumcodes/linux/docs/devnet/node3/geth.ipc
INFO [09-04|08:52:00.463] HTTP endpoint opened url=http://127.0.0.1:8745 cors= vhosts=localhost
INFO [09-04|08:52:00.463] Transaction pool price threshold updated price=18000000000
INFO [09-04|08:52:00.463] Updated mining threads threads=1
INFO [09-04|08:52:00.463] Transaction pool price threshold updated price=18000000000
INFO [09-04|08:52:00.463] Commit new mining work number=1 sealhash=8e8d43…ca84bb uncles=0 txs=0 gas=0 fees=0 elapsed=142.335µs
INFO [09-04|08:52:00.465] RLPx listener up self=enode://7fc29b99d8e8d2459b263d03fd24cfd67c841a3318d27125095a72c5ce430e3a0b3f2133b0e9835a6a06d488ebdf9b622c7fbfd163df8b4b88378179b1097349@[::]:30305
INFO [09-04|08:52:04.025] Generating DAG in progress epoch=0 percentage=0 elapsed=3.075s
INFO [09-04|08:52:07.084] Generating DAG in progress epoch=0 percentage=1 elapsed=6.133s
INFO [09-04|08:52:10.146] Generating DAG in progress epoch=0 percentage=2 elapsed=9.196s
INFO [09-04|08:52:13.256] Generating DAG in progress epoch=0 percentage=3 elapsed=12.306s
INFO [09-04|08:52:16.326] Generating DAG in progress epoch=0 percentage=4 elapsed=15.376s
Appendix C. Whole directory struct
[furnace@localhost devnet]$ tree -L 3
.
├── boot.key
├── bootnode
│ ├── geth
│ │ ├── chaindata
│ │ └── lightchaindata
│ └── keystore
├── genesis.json
├── node1
│ ├── geth
│ │ ├── chaindata
│ │ ├── LOCK
│ │ ├── nodekey
│ │ ├── nodes
│ │ └── transactions.rlp
│ └── keystore
├── node2
│ ├── geth
│ │ ├── chaindata
│ │ ├── LOCK
│ │ ├── nodekey
│ │ ├── nodes
│ │ └── transactions.rlp
│ └── keystore
└── node3
├── geth
│ ├── chaindata
│ ├── LOCK
│ ├── nodekey
│ ├── nodes
│ └── transactions.rlp
├── geth.ipc
└── keystore
└── UTC--2018-09-04T12-47-55.147311372Z--3ca39a64bc1eda8669d539631b44dbd4a43ed0f8
20 directories, 13 files
[furnace@localhost devnet]$
[furnace@localhost .ethereum]$ tree -L 3
.
└── history
0 directories, 1 file
[furnace@localhost .ethereum]$ cd ../.ethash/
[furnace@localhost .ethash]$ tree -L 3
.
├── full-R23-0000000000000000
└── full-R23-290decd9548b62a8.4037200794235010051
0 directories, 2 files
[furnace@localhost .ethash]$
[furnace@localhost devnet]$ du -h --max-depth=1 ~
4.0K /home/furnace/.ethereum
2.1G /home/furnace/.ethash
[furnace@localhost devnet]$
[furnace@localhost ~]$ cd .ethash/
[furnace@localhost .ethash]$ ll -h
total 2.1G
-rw-rw-r--. 1 furnace furnace 1.0G Sep 4 08:57 full-R23-0000000000000000
-rw-rw-r--. 1 furnace furnace 1.1G Sep 4 09:08 full-R23-290decd9548b62a8
[furnace@localhost .ethash]$
Appendix D. The whole steps
1. Prepare
1.1 Create workspace
[furnace@localhost devnet] cd devnet
[furnace@localhost devnet]
1.2 Create accounts
[furnace@localhost devnet] geth --datadir node1 account new
[furnace@localhost devnet] echo "0x15b8f695c91015215473b3d6a2f2baadc8464cb3" >> node2/accounts.txt
[furnace@localhost devnet]$ echo '0x25f9e9382c87e9a080dce986b1b4e8355da8f43b' >> node3/accounts.txt
[furnace@localhost devnet] echo '123456' > node2/password.txt
[furnace@localhost devnet]$ echo '123456' > node3/password.txt
1.3 Create genesis file
By tool puppeth
.
2. Play
The following can execute by script deploy.sh
.
2.1 Clear nodes
[furnace@localhost devnet]$ rm -rf ~/.ethash/
[furnace@localhost devnet]$ rm -rf node1/geth/
[furnace@localhost devnet]$ rm -rf node2/geth/
[furnace@localhost devnet]$ rm -rf node3/geth/
[furnace@localhost devnet]$ rm -rf node1/eth_output.log
[furnace@localhost devnet]$ rm -rf node2/eth_output.log
[furnace@localhost devnet]$ rm -rf node3/eth_output.log
[furnace@localhost devnet]$ rm -rf bootnode_output.log
2.2 Init nodes
[furnace@localhost devnet] geth --datadir node2 init genesis.json
[furnace@localhost devnet]$ geth --datadir node3 init genesis.json
2.3 Create bootnode
[furnace@localhost devnet]$ bootnode -genkey boot.key
2.4 Startup bootnode
[furnace@localhost devnet]$ bootnode -nodekey boot.key -verbosity 9 -addr :30301
2.5 Startup node1
[furnace@localhost devnet]$ geth --datadir=node1 --bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf715286e812b3ce70a5c9c6797d71cdbd1432e2ac1a0f6cb06cab3e9e7dd33aea4@127.0.0.1:30301 --port=30303 --rpc --rpcaddr 0.0.0.0 --rpcport=8545 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --ws --wsaddr 0.0.0.0 --wsport 8546 --wsapi 'personal,db,eth,net,web3,txpool,miner' --wsorigins "*" --verbosity 3 console 2>>node1/eth_output.log
2.6 Startup node2
[furnace@localhost devnet]$ geth --datadir=node2 --bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf715286e812b3ce70a5c9c6797d71cdbd1432e2ac1a0f6cb06cab3e9e7dd33aea4@127.0.0.1:30301 --port=30304 --rpc --rpcaddr 0.0.0.0 --rpcport=8645 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --ws --wsaddr 0.0.0.0 --wsport 8646 --wsapi 'personal,db,eth,net,web3,txpool,miner' --wsorigins "*" --verbosity 3 console 2>>node2/eth_output.log
2.7 Startup node2
[furnace@localhost devnet]$ geth --datadir=node3 --bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf715286e812b3ce70a5c9c6797d71cdbd1432e2ac1a0f6cb06cab3e9e7dd33aea4@127.0.0.1:30301 --port=30305 --rpc --rpcaddr 0.0.0.0 --rpcport=8745 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --ws --wsaddr 0.0.0.0 --wsport 8646 --wsapi 'personal,db,eth,net,web3,txpool,miner' --wsorigins "*" --mine --minerthreads=1 --etherbase="0x3ca39a64bc1eda8669d539631b44dbd4a43ed0f8" --verbosity 3 console 2>>node3/eth_output.log
Reference
- README, https://github.com/ethereum/go-ethereum/blob/master/README.md
- JSON-RPC, https://github.com/ethereum/wiki/wiki/JSON-RPC
- Management-APIs, https://github.com/ethereum/go-ethereum/wiki/Management-APIs
Contributor
- Windstamp, https://github.com/windstamp