Installing your own node


#1

Now that the blockchain has been started, you might want to install your own instance of uCoin to either:

  • Participate to the writing of the blockchain
  • Just have a local passive node for mirroring

Doing so is super easy, given the fact you have:

  • A Linux distribution with node.js + npm installed
  • Access to your Internet box & are able to open a TCP port + redirect it to your PC/server

Let’s go!

1. Installing uCoin

Simply run:

$ sudo npm install -g ucoin

You can check installed version by using:

$ ucoind --version
0.9.1

2. Configure your node

As a first installation, you only need to make a basic configuration. Here is how:

$ ucoind wizard basic

This command is an helper to configure your node without making too much errors. My configuration looks like:

[?] Key's salt: ***********
[?] Key's password: *********
[?] IPv4 interface: eth0 192.168.1.18
[?] IPv6 interface: None
[?] Port: 9101
[?] Remote IPv4 88.163.127.43
[?] Remote IPv6 None
[?] Remote port: 9101
[2014-11-21 19:08:55.694] [DEBUG] ucoind - Configuration saved.

Where salt & password are the values I use for my personal key of member. If what you want is to write into the blockchain, you should do this too. Otherwise, you can put whatever values for salt & password.

Remote parameters

On above config, you can see 3 special parameters:

[?] Remote IPv4 88.163.127.43
[?] Remote IPv6 None
[?] Remote port: 9101

These are the network configuration for others to reach your node outside your private network, for example from the Internet.

This data will be publicly available, since your node will send it to ucoin network so your node can be forwarded new data (blocks, peers, …).

This is where you might need to access your Internet box and open a port, and redirect it to your local ucoin instance whose parameters are (for example):

[?] IPv4 interface: eth0 192.168.1.18
[?] IPv6 interface: None
[?] Port: 9101

Proof-of-Work parameters

You will also need to configure Proof-of-Work parameters:

$ ucoind wizard pow
[?] Participate writing the blockchain (when member) Yes
[?] Start computation of a new block if none received since (seconds) 1200
[2014-11-21 19:15:53.635] [DEBUG] ucoind - Configuration saved.

Here, if you do not want to participate to the writing of the blockchain, just answer “No” to the first question. Otherwise, you will be asked for a delay to wait before computing next block. I suggest value 1200 here. You can put whatever value you want, this is for computation (CPU) saving purposes. This value is in seconds.

3. Synchronize with an existing node

Just run:

$ ucoind sync twiced.fr 9101
[2014-11-21 19:26:14.367] [INFO] sync - Connecting remote host...
[2014-11-21 19:26:14.370] [INFO] sync - Sync started.
[2014-11-21 19:26:14.370] [INFO] sync - Downloading Blockchain...
[2014-11-21 19:26:14.699] [INFO] blockchain - Block #0 added to the blockchain
[2014-11-21 19:26:14.898] [INFO] blockchain - Block #1 added to the blockchain
[2014-11-21 19:26:15.016] [INFO] blockchain - Block #2 added to the blockchain
[2014-11-21 19:26:15.134] [INFO] blockchain - Block #3 added to the blockchain
[2014-11-21 19:26:15.311] [INFO] sync - Sync finished.

Good! We have downloaded & applied an existing blockchain on our node.

4. Start your node

ucoind start

5. Enjoy!

There we are! You should have your node either computing next block, or just waiting for new data.


#2

I installed mine and its working perfectly :slight_smile:

If there any clean way to demonize it ?


#3

Yep! Using forever.

$ sudo npm install -g forever

And daemonization:

$ forever start /usr/bin/ucoind start

You can see your processes using:

$ forever list

And check ucoin’s logs with (given ucoin is your first forever process):

$ forever logs 0 -f

#4

Perfect, thanks :slight_smile:

My node is running on inso.ovh:8033


#5

I’m sorry, but you will have to reset your node :confused: since I’ve found 2 bugs that:

  • stuck the blockchain on B#11 (it is waiting for a UD that will never come)
  • avoid peer’s discovering, so both you & I are currently not notified if one or the other find a new valid block

Shortly, you need to update ucoin:

$ forever stop 0
$ sudo npm install -g ucoin

Check version:

$ ucoind --version
0.9.2

Reset data (not config):

$ ucoind reset data

Resync:

$ ucoind sync twiced.fr 9101

And restart your node:

$ forever start /usr/bin/ucoind start

That said, your node is indeed working, I’ve just checked http://inso.ovh:8033/blockchain/current :wink: Great!


#6

I was indeed thinking that the errors in my logs were not intended… :smile:

I upgraded my node, no more errors !


#7

Congratulations! Block#15 was written by your node :wink:

http://inso.ovh:8033/blockchain/block/15
http://twiced.fr:9101/blockchain/block/15

Hope folks will add their own node, so we can start the uBlockchain symphony! :slight_smile:


#8

Could you update to v0.9.4 ? I’ve changed proof-of-work difficulty rule, which was unfair.

If your current block is still B#20, you do not need to reset data.

Thanks :grin:


#9

No problem…

Done :wink:


#10

I tried to setup a server, but failed.

After launching ‘ucoind wizard basic’, nothing happens and it seems to be waiting for something (a network connection somewhere ?).
I then tried ‘uciond reset all’, and had the following message :
ucoind reset all

[2014-12-09 22:26:48.051] [ERROR] ucoin_default - connection error: [Error: failed to connect to [localhost:27017]]
Error: failed to connect to [localhost:27017]
    at null. (/usr/local/lib/node_modules/ucoin/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:553:74)
    at EventEmitter.emit (events.js:106:17)
    at null. (/usr/local/lib/node_modules/ucoin/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
    at EventEmitter.emit (events.js:98:17)
    at Socket. (/usr/local/lib/node_modules/ucoin/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:512:10)
    at Socket.EventEmitter.emit (events.js:95:17)
    at net.js:441:14
    at process._tickCallback (node.js:415:13)

Any idea ? (sorry I don’t know nodejs)


#11

btw, I am using ucoind 0.9.5 (downloaded ~10 minutes ago)


#12

You need to install mongodb:

sudo apt-get install mongodb

Then, all your commands should work as expected.


#13

I installed a node in our server : http://server.e-is.pro:9101

To known this node, your node need to sync once (this is pending bug - known by @cgeek) :

ucoin sync server.e-is.pro 9101

#14

@cgeek : thanks, it was only a matter of ubuntu packages.

Now, I am not sure if I have the server in a proper state, after running ‘sync’, I get this

  ucoind sync twiced.fr 9101
[2014-12-19 09:22:49.944] [INFO] sync - Connecting remote host...
[2014-12-19 09:22:49.948] [INFO] sync - Sync started.
[2014-12-19 09:22:49.948] [INFO] sync - Downloading Blockchain...
[2014-12-19 09:22:50.403] [INFO] sync - Sync finished.
[2014-12-19 09:22:50.404] [ERROR] ucoind - Error during sync: Block must have a UniversalDividend field

An old block encountered with an old format I guess ?

I tried to launch the server anyway. I may have generated a block (bot not sure yet). Should my node be reachable from the outside to be able to publish a block ?
Could I be part of the blockchain generation with a dynamic IP ? (not a sync server but a blockchain participant)


#15

Yes. Update ucoin, this error is due to a protocol change about UD (it was not exactly symmetric).

$ ucoind --version
0.9.9

You will have to:

$ ucoind reset data
$ ucoind sync inso.ovh 8033

And restart your node.

No, but to receive blocks from outside it has to. I’ve not handled dynamic IP yet, but in theory there is no real difficulty: your peer can change of IP and broadcast this information.

edit: congrats! you have successfully written a block#1996!


#16

Arf, I forgot the “reset” step.
My node is running and I’ve been contributing to some blocks (not yet sure to have my node online very often)
Cool, thanks for the hard work !


#17

On a brand new ubuntu 14.4
I installed node.js + npm apparently with no problem like this
sudo apt-get install nodejs npm
Then
sudo npm install -g ucoin
gives…
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.13.0-43-generic
gyp ERR! command “nodejs” “/usr/bin/node-gyp” "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/ucoin/node_modules/scrypt
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! weird error 1
npm ERR! tar pack Error reading /root/tmp/npm-6553-cNzN9rVj/1419113651895-0.6043168399482965/package
npm ERR! addLocalDirectory Could not pack “/root/tmp/npm-6553-cNzN9rVj/1419113651895-0.6043168399482965/package” to “/root/.npm/multiparty/2.2.0/package.tgz”

kerberos@0.0.3 install /usr/local/lib/node_modules/ucoin/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos
(node-gyp rebuild 2> builderror.log) || (exit 0)

npm ERR! Error: ENOENT, lstat '/root/tmp/npm-6553-cNzN9rVj/1419113657047-0.12364506418816745/package/build/Release/bson.pdb’
npm ERR! System Linux 3.13.0-43-generic
npm ERR! command “/usr/bin/nodejs” “/usr/bin/npm” “install” “-g” "ucoin"
npm ERR! cwd /home/olivier
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! path /root/tmp/npm-6553-cNzN9rVj/1419113657047-0.12364506418816745/package/build/Release/bson.pdb
npm ERR! fstream_path /root/tmp/npm-6553-cNzN9rVj/1419113657047-0.12364506418816745/package/build/Release/bson.pdb
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/lib/nodejs/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
make: entrant dans le répertoire « /usr/local/lib/node_modules/ucoin/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos/build »
SOLINK_MODULE(target) Release/obj.target/kerberos.node
SOLINK_MODULE(target) Release/obj.target/kerberos.node: Finished
COPY Release/kerberos.node
make: quittant le répertoire « /usr/local/lib/node_modules/ucoin/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos/build »

bson@0.2.5 install /usr/local/lib/node_modules/ucoin/node_modules/mongoose/node_modules/mongodb/node_modules/bson
(node-gyp rebuild 2> builderror.log) || (exit 0)

npm http GET https://registry.npmjs.org/next-tick
make: entrant dans le répertoire « /usr/local/lib/node_modules/ucoin/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build »
CXX(target) Release/obj.target/bson/ext/bson.o

SOLINK_MODULE(target) Release/obj.target/bson.node
SOLINK_MODULE(target) Release/obj.target/bson.node: Finished
COPY Release/bson.node
make: quittant le répertoire « /usr/local/lib/node_modules/ucoin/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build »

npm WARN engine node-localstorage@0.3.4: wanted: {“node”:“0.8.x”} (current: {“node”:“v0.10.25”,“npm”:“1.3.10”})

vucoin@0.22.1 postuninstall /usr/local/lib/node_modules/ucoin/node_modules/vucoin
./postuninstall.sh
sh: 1: ./postuninstall.sh: not found
npm WARN continuing anyway undefined
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/olivier/npm-debug.log
npm ERR! not ok code 0


#18

You probably need to:

$ sudo apt-get install nodejs-legacy

And then reinstall ucoin.


#19

Thanks, it works better, but I still get:
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.13.0-43-generic
gyp ERR! command “nodejs” “/usr/bin/node-gyp” "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/ucoin/node_modules/scrypt
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! weird error 1
npm ERR! not ok code 0


#20

You should have something like:

$ node-gyp --version
v1.0.2

Could you try the following command?

$ sudo apt-get install node-gyp

And if you still do not have v1.0.2 version for node-gyp:

$ sudo npm install -g node-gyp