Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

miner.start() ,return "NULL" #15112

Closed
metal-young opened this issue Sep 7, 2017 · 8 comments
Closed

miner.start() ,return "NULL" #15112

metal-young opened this issue Sep 7, 2017 · 8 comments

Comments

@metal-young
Copy link

System information

Geth version: geth version
Geth
Version: 1.6.7-stable
Git Commit: ab5646c
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.8.1
Operating System: linux
GOPATH=
GOROOT=/usr/lib/go-1.8

OS & Version:
xiaoyu@xiaoyu-VirtualBox:~$ uname -a
Linux xiaoyu-VirtualBox 4.10.0-19-generic #21-Ubuntu SMP Thu Apr 6 17:04:57 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Commit hash : (if develop)

Expected behaviour

when i run miner.start() , it wil return true or false , BUT it return null

Actual behaviour

> miner.start()
null

Steps to reproduce the behaviour

xiaoyu@xiaoyu-VirtualBox:~/eth$ vim CustomGenesis.json 
xiaoyu@xiaoyu-VirtualBox:~/eth$ geth --datadir "/home/xiaoyu/eth" init CustomGenesis.json
WARN [09-07|17:24:27] No etherbase set and no accounts found as default 
INFO [09-07|17:24:27] Allocated cache and file handles         database=/home/xiaoyu/eth/geth/chaindata cache=16 handles=16
Fatal: Failed to write genesis block: genesis has no chain configuration
xiaoyu@xiaoyu-VirtualBox:~/eth$ ls
CustomGenesis.json  geth  keystore
xiaoyu@xiaoyu-VirtualBox:~/eth$ geth --datadir "/home/xiaoyu/eth" --nodiscover --rpcapi "db,eth,net,web3" --networkid 1999 console 2>>geth.log
Welcome to the Geth JavaScript console!

instance: Geth/v1.6.7-stable-ab5646c5/linux-amd64/go1.8.1
 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

> personal.newAccount("xiaoyu")
"0x20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7"
> personal.newAccount("xiaoyu2")
"0xf8047f8063fdc7df778aa8b4379c158536ad8a25"
> personal
{
  listAccounts: ["0x20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7", "0xf8047f8063fdc7df778aa8b4379c158536ad8a25"],
  listWallets: [{
      accounts: [{...}],
      status: "Locked",
      url: "keystore:///home/xiaoyu/eth/keystore/UTC--2017-09-07T09-29-43.278548578Z--20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7"
  }, {
      accounts: [{...}],
      status: "Locked",
      url: "keystore:///home/xiaoyu/eth/keystore/UTC--2017-09-07T09-29-57.512583773Z--f8047f8063fdc7df778aa8b4379c158536ad8a25"
  }],
  deriveAccount: function(),
  ecRecover: function(),
  getListAccounts: function(callback),
  getListWallets: function(callback),
  importRawKey: function(),
  lockAccount: function(),
  newAccount: function github.com/ethereum/go-ethereum/console.(*bridge).NewAccount-fm(),
  sendTransaction: function(),
  sign: function github.com/ethereum/go-ethereum/console.(*bridge).Sign-fm(),
  unlockAccount: function github.com/ethereum/go-ethereum/console.(*bridge).UnlockAccount-fm()
}
> miner
{
  getHashrate: function(),
  setEtherbase: function(),
  setExtra: function(),
  setGasPrice: function(),
  start: function(),
  stop: function()
}
> miner.start()
null
> miner.stop()
true
> miner.setEtherbase(personal.listAccounts[0])
true
> miner.start()
null
> personal.unlockAccount
function github.com/ethereum/go-ethereum/console.(*bridge).UnlockAccount-fm()
> personal.unlockAccount(0)
first argument must be the account to unlock
> personal.unlockAccount(personal.listAccounts[0])
Unlock account 0x20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7
Passphrase: 
Error: could not decrypt key with given passphrase
> personal.unlockAccount(personal.listAccounts[0])
Unlock account 0x20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7
Passphrase: 
true
> miner.setEtherbase(personal.listAccounts[0])
true
> miner.stop()
true
> miner.start()
null
> acc0 = eth.accounts[0]
"0x20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7"
> eth
{
  accounts: ["0x20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7", "0xf8047f8063fdc7df778aa8b4379c158536ad8a25"],
  blockNumber: 0,
  coinbase: "0x20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7",
  compile: {
    lll: function(),
    serpent: function(),
    solidity: function()
  },
  defaultAccount: undefined,
  defaultBlock: "latest",
  gasPrice: 18000000000,
  hashrate: 0,
  mining: true,
  pendingTransactions: [],
  protocolVersion: "0x3f",
  syncing: false,
  call: function(),
  contract: function(abi),
  estimateGas: function(),
  filter: function(fil, callback),
  getAccounts: function(callback),
  getBalance: function(),
  getBlock: function(),
  getBlockNumber: function(callback),
  getBlockTransactionCount: function(),
  getBlockUncleCount: function(),
  getCode: function(),
  getCoinbase: function(callback),
  getCompilers: function(),
  getGasPrice: function(callback),
  getHashrate: function(callback),
  getMining: function(callback),
  getPendingTransactions: function(callback),
  getProtocolVersion: function(callback),
  getRawTransaction: function(),
  getRawTransactionFromBlock: function(),
  getStorageAt: function(),
  getSyncing: function(callback),
  getTransaction: function(),
  getTransactionCount: function(),
  getTransactionFromBlock: function(),
  getTransactionReceipt: function(),
  getUncle: function(),
  getWork: function(),
  iban: function(iban),
  icapNamereg: function(),
  isSyncing: function(callback),
  namereg: function(),
  resend: function(),
  sendIBANTransaction: function(),
  sendRawTransaction: function(),
  sendTransaction: function(),
  sign: function(),
  signTransaction: function(),
  submitTransaction: function(),
  submitWork: function()
}
> eth.getBalance(acc0)
0
> eth.getBalance(acc0)
0
> ehh
ReferenceError: 'ehh' is not defined
    at <anonymous>:1:1

> eth
{
  accounts: ["0x20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7", "0xf8047f8063fdc7df778aa8b4379c158536ad8a25"],
  blockNumber: 0,
  coinbase: "0x20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7",
  compile: {
    lll: function(),
    serpent: function(),
    solidity: function()
  },
  defaultAccount: undefined,
  defaultBlock: "latest",
  gasPrice: 18000000000,
  hashrate: 0,
  mining: true,
  pendingTransactions: [],
  protocolVersion: "0x3f",
  syncing: false,
  call: function(),
  contract: function(abi),
  estimateGas: function(),
  filter: function(fil, callback),
  getAccounts: function(callback),
  getBalance: function(),
  getBlock: function(),
  getBlockNumber: function(callback),
  getBlockTransactionCount: function(),
  getBlockUncleCount: function(),
  getCode: function(),
  getCoinbase: function(callback),
  getCompilers: function(),
  getGasPrice: function(callback),
  getHashrate: function(callback),
  getMining: function(callback),
  getPendingTransactions: function(callback),
  getProtocolVersion: function(callback),
  getRawTransaction: function(),
  getRawTransactionFromBlock: function(),
  getStorageAt: function(),
  getSyncing: function(callback),
  getTransaction: function(),
  getTransactionCount: function(),
  getTransactionFromBlock: function(),
  getTransactionReceipt: function(),
  getUncle: function(),
  getWork: function(),
  iban: function(iban),
  icapNamereg: function(),
  isSyncing: function(callback),
  namereg: function(),
  resend: function(),
  sendIBANTransaction: function(),
  sendRawTransaction: function(),
  sendTransaction: function(),
  sign: function(),
  signTransaction: function(),
  submitTransaction: function(),
  submitWork: function()
}
> eth.getBalance(acc0)
0
> eth
{
  accounts: ["0x20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7", "0xf8047f8063fdc7df778aa8b4379c158536ad8a25"],
  blockNumber: 0,
  coinbase: "0x20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7",
  compile: {
    lll: function(),
    serpent: function(),
    solidity: function()
  },
  defaultAccount: undefined,
  defaultBlock: "latest",
  gasPrice: 18000000000,
  hashrate: 5743,
  mining: true,
  pendingTransactions: [],
  protocolVersion: "0x3f",
  syncing: false,
  call: function(),
  contract: function(abi),
  estimateGas: function(),
  filter: function(fil, callback),
  getAccounts: function(callback),
  getBalance: function(),
  getBlock: function(),
  getBlockNumber: function(callback),
  getBlockTransactionCount: function(),
  getBlockUncleCount: function(),
  getCode: function(),
  getCoinbase: function(callback),
  getCompilers: function(),
  getGasPrice: function(callback),
  getHashrate: function(callback),
  getMining: function(callback),
  getPendingTransactions: function(callback),
  getProtocolVersion: function(callback),
  getRawTransaction: function(),
  getRawTransactionFromBlock: function(),
  getStorageAt: function(),
  getSyncing: function(callback),
  getTransaction: function(),
  getTransactionCount: function(),
  getTransactionFromBlock: function(),
  getTransactionReceipt: function(),
  getUncle: function(),
  getWork: function(),
  iban: function(iban),
  icapNamereg: function(),
  isSyncing: function(callback),
  namereg: function(),
  resend: function(),
  sendIBANTransaction: function(),
  sendRawTransaction: function(),
  sendTransaction: function(),
  sign: function(),
  signTransaction: function(),
  submitTransaction: function(),
  submitWork: function()
}
> eth.getWork()
["0x5633f236122a8300c5d597e992f18611b079bdeca6fc8069b1f949fcbbb048b6", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000040080100200400801002004008010020040080100200400801002004"]
> eth.getBlockNumber()
undefined
> eth.getMining
function(callback)
> eth.getMining()
undefined
> eth
{
  accounts: ["0x20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7", "0xf8047f8063fdc7df778aa8b4379c158536ad8a25"],
  blockNumber: 0,
  coinbase: "0x20becac25bc3ab00dbd6ac511c3cd4e5e54abfd7",
  compile: {
    lll: function(),
    serpent: function(),
    solidity: function()
  },
  defaultAccount: undefined,
  defaultBlock: "latest",
  gasPrice: 18000000000,
  hashrate: 7975,
  mining: true,
  pendingTransactions: [],
  protocolVersion: "0x3f",
  syncing: false,
  call: function(),
  contract: function(abi),
  estimateGas: function(),
  filter: function(fil, callback),
  getAccounts: function(callback),
  getBalance: function(),
  getBlock: function(),
  getBlockNumber: function(callback),
  getBlockTransactionCount: function(),
  getBlockUncleCount: function(),
  getCode: function(),
  getCoinbase: function(callback),
  getCompilers: function(),
  getGasPrice: function(callback),
  getHashrate: function(callback),
  getMining: function(callback),
  getPendingTransactions: function(callback),
  getProtocolVersion: function(callback),
  getRawTransaction: function(),
  getRawTransactionFromBlock: function(),
  getStorageAt: function(),
  getSyncing: function(callback),
  getTransaction: function(),
  getTransactionCount: function(),
  getTransactionFromBlock: function(),
  getTransactionReceipt: function(),
  getUncle: function(),
  getWork: function(),
  iban: function(iban),
  icapNamereg: function(),
  isSyncing: function(callback),
  namereg: function(),
  resend: function(),
  sendIBANTransaction: function(),
  sendRawTransaction: function(),
  sendTransaction: function(),
  sign: function(),
  signTransaction: function(),
  submitTransaction: function(),
  submitWork: function()
}

CustomGenesis.json

{
    "nonce": "0x0000000000000042",     "timestamp": "0x0",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "",     "gasLimit": "0x8000000",     "difficulty": "0x400",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0x3333333333333333333333333333333333333333",     "alloc": {     }
}

Backtrace

[backtrace]
@sirnicolas21
Copy link

what miner.start(1) returns?

@metal-young
Copy link
Author

@sirnicolas21

> miner.start(1)
null

@metal-young
Copy link
Author

@sirnicolas21

log


INFO [09-07|18:35:06] Generating DAG in progress               epoch=1 percentage=90 elapsed=44m59.958s
INFO [09-07|18:35:27] Generating DAG in progress               epoch=1 percentage=91 elapsed=45m21.692s
INFO [09-07|18:35:49] Generating DAG in progress               epoch=1 percentage=92 elapsed=45m43.037s
INFO [09-07|18:36:13] Generating DAG in progress               epoch=1 percentage=93 elapsed=46m6.883s
INFO [09-07|18:36:33] Generating DAG in progress               epoch=1 percentage=94 elapsed=46m27.773s
INFO [09-07|18:36:58] Generating DAG in progress               epoch=1 percentage=95 elapsed=46m52.273s
INFO [09-07|18:37:19] Generating DAG in progress               epoch=1 percentage=96 elapsed=47m13.411s
INFO [09-07|18:37:44] Generating DAG in progress               epoch=1 percentage=97 elapsed=47m38.104s
INFO [09-07|18:38:06] Generating DAG in progress               epoch=1 percentage=98 elapsed=48m0.333s
INFO [09-07|18:38:28] Generating DAG in progress               epoch=1 percentage=99 elapsed=48m22.344s
INFO [09-07|18:38:28] Generated ethash verification cache      epoch=1 elapsed=48m22.351s
INFO [09-07|18:58:51] Updated mining threads                   threads=1
INFO [09-07|18:59:26] Updated mining threads                   threads=1
INFO [09-07|18:59:26] Transaction pool price threshold updated price=18000000000
INFO [09-07|18:59:26] Starting mining operation 
INFO [09-07|18:59:26] Commit new mining work                   number=1 txs=0 uncles=0 elapsed=298.451µs

@karalabe
Copy link
Member

karalabe commented Sep 7, 2017

miner.start() doesn't return anything. The console needs to interpret is somehow, so it prints null. Why does it matter what it returns, it it started mining properly as seen above?

Btw, the error is that you didn't initialize your custom chain and started mining on mainnet. From your logs:

$ geth --datadir "/home/xiaoyu/eth" init CustomGenesis.json
[...]
Fatal: Failed to write genesis block: genesis has no chain configuration

Your genesis json needs to have a config section, like described in https://github.com/ethereum/go-ethereum#defining-the-private-genesis-state

@karalabe karalabe closed this as completed Sep 7, 2017
@trungtt198x
Copy link

The parameter passed to miner.start() is the max number of threads? If not, what exactly is it?

@shessenauer
Copy link

@trungtt1981 It is just the number of threads you use.

@hellochueng
Copy link

hellochueng commented Jul 30, 2018

I also had this problem,
my genens.json is:

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

and the result don't have any failed result, after i init :

WARN [07-30|14:15:19] No etherbase set and no accounts found as default
INFO [07-30|14:15:19] Allocated cache and file handles database=/root/eth2/geth/chaindata cache=16 handles=16
INFO [07-30|14:15:19] Writing custom genesis block
INFO [07-30|14:15:19] Successfully wrote genesis state database=chaindata hash=bf2891…ad1419
INFO [07-30|14:15:19] Allocated cache and file handles database=/root/eth2/geth/lightchaindata cache=16 handles=16
INFO [07-30|14:15:19] Writing custom genesis block
INFO [07-30|14:15:19] Successfully wrote genesis state database=lightchaindata hash=bf2891…ad1419

but when i use geth to connect my chainnode and use miner.start() to start mining,the result show null

eth.accounts
[]
personal.newAccount("123456")
"0xb3d3dda3f47c1da6aa1449f0bff666a61984ab2d"
eth.coinbase
"0xb3d3dda3f47c1da6aa1449f0bff666a61984ab2d"
miner.setEtherbase(personal.listAccounts[0])
true
miner.start()
null
eth.blockNumber
0
miner.stop()
true
miner.start()
null
eth.getBalance(eth.coinbase)
0


somebody say is due to no transaction to commit,so is cant mining,but when i init a chainnode and new a account, there is no Balance on the new Account,and i can't to commit Transaction,so i interrupt in this
@karalabe

@Jagdish0886
Copy link

Both the functions returns null in my case. The genesis block is created successfully, as I see it from the logs. Can someone please help. Is it because of NO transactions to mine?

miner.start()
null

miner.stop();
null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants