Geth
Version: 1.7.2-unstable
Git Commit: 41b77455296526c249abdf812e17f449e7f362e4
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.9.1
Operating System: linux
GOPATH=
GOROOT=/usr/local/go
Launching the command here to initialize the genesis block should not fail: http://www.ethdocs.org/en/latest/network/test-networks.html#launching-geth
build/bin/geth --identity "testnode" --datadir "$HOME/.etest" --nodiscover --maxpeers 0 --networkid 1999 init genesis.json
It fails with:
Fatal: invalid genesis file: json: cannot unmarshal hex string of odd length into Go struct field Genesis.extraData of type hexutil.Bytes
Then I empty the extraData field and I get this other output:
WARN [10-14|01:06:34] No etherbase set and no accounts found as default
INFO [10-14|01:06:34] Allocated cache and file handles database=/somewhere cache=16 handles=16
Fatal: Failed to write genesis block: genesis has no chain configuration
Create a genesis.json as per http://www.ethdocs.org/en/latest/network/test-networks.html#launching-geth :
{
"nonce": "0x0000000000000042",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0",
"gasLimit": "0x8000000",
"difficulty": "0x400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"alloc": {}
}
Then run:
build/bin/geth --identity "testnode" --datadir "$HOME/.etest" --nodiscover --maxpeers 0 --networkid 1999 init genesis.json
I've noticed that the genesis_test.go calls geth init but doesn't check for the status code to be zero. This means the test passed even though it should have failed.
Code reference: https://github.com/ethereum/go-ethereum/blob/master/cmd/geth/genesis_test.go#L33
In fact the output of build/env.sh go test github.com/ethereum/go-ethereum/cmd/geth -run TestCustomGenesis -v is:
=== RUN TestCustomGenesis
--- PASS: TestCustomGenesis (1.18s)
test_cmd.go:231: (stderr) WARN [10-14|01:10:00] No etherbase set and no accounts found as default
test_cmd.go:231: (stderr) INFO [10-14|01:10:00] Allocated cache and file handles database=/tmp/geth-test598189369/geth/chaindata cache=16 handles=16
test_cmd.go:231: (stderr) Fatal: Failed to write genesis block: genesis has no chain configuration
[...]
PASS
I'm willing to contribute. All I need to know is:
{
"nonce": "0x0000000000000042",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x8000000",
"difficulty": "0x400",
"config": {},
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333", "alloc": { }
obviously, don't put the dashes !!
the extraData part can be either empty or set to "0x"
to eliminate the second error, I added the part :-
"config": {}
that's all,
try this, it should work
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
try using the following text as the genesis.json
{
"nonce": "0x0000000000000042",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x8000000",
"difficulty": "0x400",
"config": {},
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333", "alloc": { }
}
obviously, don't put the dashes !!
the extraData part can be either empty or set to "0x"
to eliminate the second error, I added the part :-
"config": {}
that's all,
try this, it should work