1

Fedora 27, CentOS 1708, Go-ethereum 1.8.1

I am trying to make private block chain and coin using that for study.

Genesis.json:

{
  "config": {
        "chainId": 42,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "alloc": {},
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x1000000",
  "extraData"  : "",
  "gasLimit"   : "0x2fefd8",
  "nonce"      : "0x0000000012345678",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}

And I run geth in console with:

geth init genesis.json --datadir datadir
geth console --rpc --rpcport "8080" --rpccorsdomain "*" --datadir "datadir" --port "30303" --nodiscover --rpcapi "db,eth,net,web3" --networkid 7296

Then I made new account and started mining. It works. But when I restart geth, block chain state seems not saved.

INFO [03-05|11:39:03] Successfully sealed new block            number=21 hash=ef088f…8b62cb
INFO [03-05|11:39:03]  block reached canonical chain          number=16 hash=4dea2d…c41401
INFO [03-05|11:39:03]  mined potential block                  number=21 hash=ef088f…8b62cb
INFO [03-05|11:39:03] Commit new mining work                   number=22 txs=0 uncles=0 elapsed=101.305µs
> miner.stop()
true
> exit
INFO [03-05|11:39:28] IPC endpoint closed                      endpoint=/home/hansoli/.ethereum/geth.ipc
ERROR[03-05|11:39:28] Dangling trie nodes after full cleanup 
INFO [03-05|11:39:28] Blockchain manager stopped 
INFO [03-05|11:39:28] Stopping Ethereum protocol 
INFO [03-05|11:39:28] Ethereum protocol stopped 
INFO [03-05|11:39:28] Transaction pool stopped 
INFO [03-05|11:39:28] Database closed                          database=/home/hansoli/.ethereum/geth/chaindata
[hansoli@localhost ethereum]$ geth console --rpc --rpcport "8080" --rpccorsdomain "*" --datadir "datadir" --port "30303" --nodiscover --rpcapi "db,eth,net,web3" --networkid 7296
INFO [03-05|11:39:59] Maximum peer count                       ETH=25 LES=0 total=25
INFO [03-05|11:39:59] Starting peer-to-peer node               instance=Geth/v1.8.1-stable-1e67410e/linux-amd64/go1.9.4
INFO [03-05|11:39:59] Allocated cache and file handles         database=/home/hansoli/.ethereum/geth/chaindata cache=768 handles=512
INFO [03-05|11:39:59] Initialised chain configuration          config="{ChainID: 42 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: 0 EIP158: 0 Byzantium: <nil> Engine: unknown}"
INFO [03-05|11:39:59] Disk storage enabled for ethash caches   dir=/home/hansoli/.ethereum/geth/ethash count=3
INFO [03-05|11:39:59] Disk storage enabled for ethash DAGs     dir=/home/hansoli/.ethash               count=2
INFO [03-05|11:39:59] Initialising Ethereum protocol           versions="[63 62]" network=1
WARN [03-05|11:39:59] Head state missing, repairing chain      number=21 hash=ef088f…8b62cb
INFO [03-05|11:39:59] Rewound blockchain to past state         number=0  hash=7016ba…d4738f
INFO [03-05|11:39:59] Loaded most recent local header          number=21 hash=ef088f…8b62cb td=351436106
INFO [03-05|11:39:59] Loaded most recent local full block      number=0  hash=7016ba…d4738f td=16777216
INFO [03-05|11:39:59] Loaded most recent local fast block      number=21 hash=ef088f…8b62cb td=351436106
INFO [03-05|11:39:59] Loaded local transaction journal         transactions=0 dropped=0
INFO [03-05|11:39:59] Regenerated local transaction journal    transactions=0 accounts=0
INFO [03-05|11:39:59] Starting P2P networking 
INFO [03-05|11:39:59] RLPx listener up                         self="enode://0482a34d9871d20c8beee1b227d7bd0b8e54a5c084d4f55afc86fac65e8d92c4ab51f669aee196c112a4ca6e6461e069ee111a82208f1fcaaff138c3d1a6254b@[::]:30303?discport=0"
INFO [03-05|11:39:59] IPC endpoint opened                      url=/home/hansoli/.ethereum/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.8.1-stable-1e67410e/linux-amd64/go1.9.4
INFO [03-05|11:39:59] Etherbase automatically configured       address=0x8eDE74913b1BbFA2be354B3B1E70635E96B6b158
coinbase: 0x8ede74913b1bbfa2be354b3b1e70635e96b6b158
at block: 0 (Thu, 01 Jan 1970 09:00:00 KST)
 datadir: /home/hansoli/.ethereum
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> eth.blockNumber
0
> 

How to solve it? Can I keep block chain status after exit geth?

Obsidian Age
  • 41,205
  • 10
  • 48
  • 71
Jeong Hansol
  • 135
  • 1
  • 12
  • The `networkid` should match the `chainid` in your genesis.json (output shows your node is connecting to Mainnet (network=1)). Make sure you’re only running `init` once. And, why is your `datadir` in quotes? Output shows your saving to the default directory (database=/home/hansoli/.ethereum/geth/chaindata). There’s nothing technically wrong with using the default directory, but you’ll want to change so you can run different networks without stepping over each other. – Adam Kipnis Mar 05 '18 at 19:10
  • And `console` should come at the end of your `geth` command. – Adam Kipnis Mar 05 '18 at 19:11
  • @AdamKipnis Thanks for answer! I trying this command: `geth --rpc --rpcport 8080 --rpccorsdomain "*" --datadir datadir --port 30303 --nodiscover --rpcapi db,eth,net,web3 --networkid 42 console` and I could confirm network number is 42 and datadir is my datadir directory in console. But it still doesn't work. – Jeong Hansol Mar 06 '18 at 02:03
  • Did you rerun your mining as well? Your output shows the mining went to the wrong datadir directory as well. I recommend starting over from the beginning. Wipe out the data directory, re-initialize your blockchain, mine some transactions, then restart your console. Double check the output after every command to make sure the correct data directory, keystore directory, and network id are being used. I've just repeated the steps and everything was working fine. – Adam Kipnis Mar 06 '18 at 16:10
  • @AdamKipnis It seems a bug in geth. It works perfectly in geth 1.8.2 (released few days ago) – Jeong Hansol Mar 08 '18 at 02:50

1 Answers1

0

maybe a bug in the current version... start geth with option --gcmode "archive"

rob
  • 26