3

I have created the data directory in /home/ubuntu/ethchain. Then I created two accounts in this directory using the command (ran the command twice) geth -datadir "/home/ubuntu/ethchain" -dev account new Then I run the following command geth -fast console -dev to start the geth instance. Then I run following command geth -datadir "/home/ubuntu/ethchain" -dev attach ipc:/tmp/ethereum_dev_mode/geth.ipc

Now when I run the above command, I expect that since I have mentioned the data directory, any account query which I run in the interactive javascript console,i.e.,eth.accounts should return me details of the accounts I have created in the directory /home/ubuntu/ethchain. But it returns me an empty list. So how do I change the default data directory? Is there any change in some config file?

1 Answer 1

1

DevMode seems to be very strict. See source code here: https://github.com/ethereum/go-ethereum/blob/master/cmd/utils/flags.go, in particular the following lines:

Starting at line 798:

if ctx.GlobalBool(DevModeFlag.Name) {
        // --dev mode can't use p2p networking.
        cfg.MaxPeers = 0
        cfg.ListenAddr = ":0"
        cfg.DiscoveryV5Addr = ":0"
        cfg.NoDiscovery = true
        cfg.DiscoveryV5 = false
}

At line 816:

switch {
    case ctx.GlobalIsSet(DataDirFlag.Name):
        cfg.DataDir = ctx.GlobalString(DataDirFlag.Name)
    case ctx.GlobalBool(DevModeFlag.Name):
        cfg.DataDir = filepath.Join(os.TempDir(), "ethereum_dev_mode")
    case ctx.GlobalBool(TestnetFlag.Name):
        cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet")
    case ctx.GlobalBool(RinkebyFlag.Name):
        cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby")
}

At line 991:

case ctx.GlobalBool(DevModeFlag.Name):
    cfg.Genesis = core.DevGenesisBlock()

So based on my understanding of RTFS, whatever DataDir you try to provide, DevMode will always override it.

I suspect that DevMode is more useful for geth developers than it is for developers who want to use a geth private network to play around with smart contracts.

FWIW I wrote up a guide to getting my first private network set up, that might be more use to you than trying to twist DevMode to your needs: https://alanbuxton.wordpress.com/2017/07/19/first-steps-with-ethereum-private-networks-and-smart-contracts-on-ubuntu-16-04/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.