5

I had some test code working fine over IPC using out-of-the-box geth. I tried to set up a test network and it broke the IPC client.

I want to run two processes -- a miner geth process, which stands in for the community at large, and an IPC server geth process, which stands in for what would be running on my own web server.

Here is the script which captures what I think I should be doing.

#!/bin/bash

E="/store/ethereum/"

H="/store/home/"

D="$H/.ethereum-test"

G="geth --networkid 1100 --maxpeers 5"

PORT="--port 33301"

RPC="--rpcport 33302"

WSRPC="--wsport 33303"

IPC="--ipcapi 'admin,eth,miner,db,net,web3,personal' --ipcpath \"$E/geth.ipc\""

MINE="--mine  --minerthreads 1 -rpccorsdomain \"*\""

KS="--keystore \"$E/keystore\""

if [[ "$1" == "setup" ]]
then
    # Start fresh
    rm -rf "$D-miner"
    rm -rf "$D-client"

    # Accept conditions and type exit.
    $G --genesis test-genesis.json -nodiscover -maxpeers 0 --datadir "$D-miner" console
elif [[ "$1" == "newacc" ]]
then
    # Enter passphrase and note address.
    # Last generated address:
    # bcd47eee60f5d8f73977785a55ab081bf8f37582
    # 5b3e83ff30e61287cf2d8eed5b8c1ead40d10432
    # a770c607f4bde0cdf1fa84e8721e9b53fce8a176
    # (older)
    $G $KS --datadir $D-miner account new
elif [[ "$1" == "mine" ]]
then
    # Mine
    $G $MINE $KS --datadir $D-miner $PORT
elif [[ "$1" == "ipc" ]]
then
    $G --datadir $D-client $IPC
else
    echo "Argument: setup newacc mine or ipc"
fi

I use it like this.

In terminal A:

./testnet setup
./testnet newacc
./testnet mine

Mining works fine.

In terminal B:

./testnet ipc

This one appears to work fine. It outputs that it created $E/geth.ipc as promised.

Then here is the NodeJS which worked fine before:

var web3_extended = require ('web3_extended');

var options =
{
        host:     './geth.ipc',
        ipc:      true,
        personal: true, 
        admin:    false,
        debug:    false
};

var web3 = web3_extended .create (options);

This yields

IPC Connection Error { [Error: connect ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'connect' }

What's odd is that geth in terminal B outputs this line

I0427 12:53:00.381003 node/node.go:298] IPC endpoint opened: "/ethereum/geth.ipc"

But if I ls /ethereum/geth.ipc

No such file is created (as it was with vanilla geth). Yes, I have write permissions to this directory. The miner in terminal A creates its geth.ipc elsewhere.

What's gone wrong?

EDIT

Miner produces this output when started with

geth --networkid 1100 --maxpeers 5 --mine --minerthreads 1 -rpccorsdomain "*" --datadir /ethereum/.ethereum-test-miner --port 33301

And IPC server produces this output when started with

geth --networkid 1100 --maxpeers 5 --datadir /ethereum/.ethereum-test-client --ipcapi 'admin,eth,miner,db,net,web3,personal' --ipcpath "/ethereum/geth.ipc"
1

1 Answer 1

3

(This page will be reorganised when this problem is solved)

EDIT 30/04/2016

@spraff, looking at your latest data:

Miner produces this output when started with

geth --networkid 1100 --maxpeers 5 --mine --minerthreads 1 -rpccorsdomain "*" --datadir /ethereum/.ethereum-test-miner --port 33301

And IPC server produces this output when started with

geth --networkid 1100 --maxpeers 5 --datadir /ethereum/.ethereum-test-client --ipcapi 'admin,eth,miner,db,net,web3,personal' --ipcpath "/ethereum/geth.ipc"

the IPC file paths look correct. It does however seems like you are trying to link your miner with your IPC client using the IPC protocol.

The IPC protocol is meant to link a node (mining or non-mining) to a client (e.g. console viewer like geth attach ipc://path/geth.ipc, Ethereum Wallet or web client).

What you probably want to do is to create a private Ethereum network with both your mining clients and non-mining clients connected to the same blockchain network. This is done using the same --networkid and --genesis flags, AND you then link all mining and non-mining clients using the --bootnodes parameter, or using either the static-nodes.json or trusted-nodes.json configuration file.

You can find the method to link the clients at Peer discovery not working on private network . Some information is also available at Connection between peers never happen on custom blockchain .


OLD STUFF BELOW



Question For @spraff

  1. What version geth are you running in your different terminals?

    You seem to be running the develop branch version of geth in the terminal where you are encountering the --ipcpath issue.

    You may want to try using the master branch version of geth where the --ipcpath seems to be working.

    You should still lodge a bug report as suggested by @Péter Szilágyi if the --ipcpath does not work with the develop branch version of geth.

  2. Is there more than one version of geth installed on your computer (and in your different terminals) ? Check with the commands:

    find / -name 'geth'
    ls -al `which geth`
    

    Are you running the version of geth that you intend to run?



Unrolling your commands

Your script file is a little bit complicated to read, so I've unrolled the commands.

Terminal A

# ./testnet setup
rm -rf /store/home//.ethereum-test-miner
rm -rf /store/home//.ethereum-test-client
geth --networkid 1100 --maxpeers 5                    \
  --genesis test-genesis.json -nodiscover -maxpeers 0 \
  --datadir "/store/home//.ethereum-test-miner" console

# ./testnet newacc
geth --networkid 1100 --maxpeers 5      \
  --keystore "/store/ethereum//keystore" \
  --datadir /store/home//.ethereum-test-miner account new

# ./testnet mine
geth --networkid 1100 --maxpeers 5            \
  --mine  --minerthreads 1 -rpccorsdomain "*" \
  --keystore "/store/ethereum//keystore"      \
  --datadir /store/home//.ethereum-test-miner \
  --port 33301

Terminal B

# ./testnet ipc
geth --networkid 1100 --maxpeers                  \
  --datadir /store/home//.ethereum-test-client    \
  --ipcapi 'admin,eth,miner,db,net,web3,personal' \
  --ipcpath "/store/ethereum//geth.ipc"

This one appears to work fine. It outputs that it created $E/geth.ipc as promised.

So the IPC file /store/ethereum/geth.ipc is created as expected

What's odd is that geth in terminal B outputs this line

I0427 12:53:00.381003 node/node.go:298] IPC endpoint opened: "/ethereum/geth.ipc"

But if I ls /ethereum/geth.ipc No such file is created (as it was with vanilla geth). Yes, I have write permissions to this directory. The miner in terminal A creates its geth.ipc elsewhere. What's gone wrong?



Issue 1 - What version of geth are you running, or intend to run?

I've found node/node.go in the go-ethereum develop branch with the following code:

go func() {
    glog.V(logger.Info).Infof("IPC endpoint opened: %s", n.ipcEndpoint)

When I run geth on my computer, I get the following message:

I0428 00:42:38.207812   14842 ipc.go:112] IPC service started (/home/user/.ethereum/geth.ipc)
instance: Geth/v1.3.6/linux/go1.5.1

The --ipcpath command works correctly in my version of geth:

$ geth --ipcpath /tmp/geth.ipc console

I0428 01:24:01.896976   20433 ipc.go:112] IPC service started (/tmp/geth.ipc)
instance: Geth/v1.3.6/linux/go1.5.1



Testing IPC

I've used your latest command to test out the IPC file path:

user@Kumquat:/tmp$ geth --networkid 1100 --maxpeers 5 \
  --datadir ./eth/.ethereum-test-client               \
  --ipcapi 'admin,eth,miner,db,net,web3,personal'     \
  --ipcpath "./eth/geth.ipc"

...

I0428 09:14:09.309467   22639 cmd.go:115] Starting Geth/v1.3.6/linux/go1.5.1
I0428 09:14:10.789959   22639 ipc.go:112] IPC service started (eth/geth.ipc)

So it seems to be working for my geth version on Linux.

Here is your geth command with the output you provided in your link:

geth --networkid 1100 --maxpeers 5                \
  --datadir /eth/.ethereum-test-client            \
  --ipcapi 'admin,eth,miner,db,net,web3,personal' \
  --ipcpath "/eth/geth.ipc"
...
I0427 22:24:27.875773   30370 cmd.go:115] Starting Geth/v1.3.6/linux/go1.5.1
I0427 22:24:30.222976   30370 ipc.go:112] IPC service started ("/ethereum/geth.ipc")

But it is not working for your geth version on Linux as well.

Note: /ethereum is on your root directory. Normally processes cannot create files on the root directory without superuser permission. Perhaps this is the reason.

I've just re-tested using the command:

geth --networkid 1100 --maxpeers 5                \
  --datadir ./eth/.ethereum-test-client           \
  --ipcapi 'admin,eth,miner,db,net,web3,personal' \
  --ipcpath "/ethereum/geth.ipc"

And this is the error message I get:

Fatal: Error string IPC: mkdir /ethereum: permission denied

I created the subdirectory /ethereum without changing the permissions:

sudo mkdir /ethereum

And running the last geth command again, get a different error message:

Fatal: Error string IPC: listen unix /ethereum/geth.ipc: bind: permission denied

I'm now changing the ownership of the directory:

sudo chown user:user /ethereum

And it works:

I0428 09:29:10.777981   22740 ipc.go:112] IPC service started (/ethereum/geth.ipc)

Hmmm. I'll think about it a bit more.

9
  • Thanks this looks very helpful! I was running Version: 1.5.0-unstable from Ubuntu ethereum-dev PPA, purged it and reinstalled Version: 1.3.6 -- this could quite possibly be it although this version doesn't have the --keystore flag. Can you please comment on this? Thanks a lot.
    – spraff
    Commented Apr 27, 2016 at 17:11
  • If you need to set the keystore directory to anything other than under the --datadir sub directory, just use soft links as demonstrated in ethereum.stackexchange.com/questions/3402/… . Commented Apr 27, 2016 at 17:40
  • No, this isn't it. I dropped the keystore flags but the issue persists when I'm running 1.3.6 HOWEVER the command geth --ipcapi "db,eth,net,web3,personal" --ipcpath "$P/geth.ipc" works as normal (for the same binary) it's just that now I'm not on the testnet.
    – spraff
    Commented Apr 27, 2016 at 19:26
  • Can you provide the full details of the 1.3.6 command that does not work, with the options all expanded? Commented Apr 27, 2016 at 21:03
  • Miner: geth --networkid 1100 --maxpeers 5 --mine --minerthreads 1 -rpccorsdomain "*" --datadir /eth/.ethereum-test-miner --port 33301 IPC server: geth --networkid 1100 --maxpeers 5 --datadir /eth/.ethereum-test-client --ipcapi 'admin,eth,miner,db,net,web3,personal' --ipcpath "/eth/geth.ipc"
    – spraff
    Commented Apr 27, 2016 at 21:10

Your Answer

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

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