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"
Best Answer
(This page will be reorganised when this problem is solved)
EDIT 30/04/2016
@spraff, looking at your latest data:
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 thestatic-nodes.json
ortrusted-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
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 ofgeth
.Is there more than one version of
geth
installed on your computer (and in your different terminals) ? Check with the commands: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
Terminal B
So the IPC file
/store/ethereum/geth.ipc
is created as expectedIssue 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:
When I run
geth
on my computer, I get the following message:The
--ipcpath
command works correctly in my version ofgeth
:Testing IPC
I've used your latest command to test out the IPC file path:
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: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:
And this is the error message I get:
I created the subdirectory
/ethereum
without changing the permissions:And running the last
geth
command again, get a different error message:I'm now changing the ownership of the directory:
And it works:
Hmmm. I'll think about it a bit more.