Bitcoin Node and Development
These are my experiences on setting up and running a full Bitcoin node, one that can also be used for development.
The reason for both of these is because I believe in Bitcoin and want to give something back. Jeff Garzik (of of the top core dev) has six suggestions on how to support Bitcoin core development. I am attempting to address suggestions 2. and 3. (help with testing and running a node).
The whole process takes almost a week.
This guide here has similar instructions.
Contents |
Why Run a Full Node?
Nodes are how the Bitcoin network processes transactions and keeps the Blockchain. Any node can be a ‘bad node’. As long as most of the nodes are good, Bitcoin runs just fine. Of course, what is good and bad is a matter of perspective, so I am attempting to influence the network to what I think is good. This happens to be running the ‘core’ or ‘reference’ Bitcoin code at this time.
Why Help Development?
Only small number of people (only 254) contribute to the core Bitcoin code base. This code is run on most of the nodes in a world, without question/review. Another set of eyes is a good thing. Also, there is a lot to do, especially with respect to testing.
Personally, I want to know how the code works at a deeper level, as well as practice contributing to an open source project, something I’ve been neglecting to do for a while.
Machine Setup
This section details the setup of my development machine running a node.
Hardware
- Dell Inspiron 6000 Laptop (~2005)
- 1.3 GHz, 32 bit
- 1.25 GB RAM
- 80 GB HDD (which ended up failing… will try again soonish)
- Ethernet Port
- TP-Link N600 Network Router
- Debian OS with Desktop UI
Debian 7.7.0 Installation Steps [4 hours]
- Download network install .iso [1.5 hours]
- Burn that to a CD-R
- Put disk in laptop and booted to it (F12 on boot screen)
- Installed it as a desktop OS [2 hours, periodic interaction]
- I also needed some non-free drivers from here on a USB dongle
- Chose the following components
- Debian desktop environment
- SSH Server
- Laptop
- Standard system utilities
Getting and Building Core Bitcoin Code Steps [6 hours]
- Put main/default user in the
sudoers
filesu
- enter root password
visudo
- Find ‘root’ and copy/paste that line
- Rename ‘root’ to ‘youUserNameHere’
- Save and quit text editor
exit
- Install Supporting Packages [3 hours]
- Update apt-get source list
sudo vi /etc/apt/sources.list
- append the following lines
deb http://ftp.us.debian.org/debian oldstable main
deb http://ftp.us.debian.org/debian jessie main
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
- Some failed to install:
ppa.launchpand.net.*
ones
- Some failed to install:
sudo apt-get dist-upgrade -y
- Took over 2 hours, with occational prompts
- I had to force power off, then restart, but appears to have worked
sudo apt-get install git -y
sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev -y
sudo apt-get install libboost-all-dev -y
sudo apt-get install libminiupnpc-dev -y
sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler -y
sudo apt-get install libqrencode-dev -y
sudo apt-get install libdb4.8-dev -y
sudo apt-get install libdb4.8++-dev -y
- Update apt-get source list
- Grab the repository
cd ~
git clone https://github.com/bitcoin/bitcoin.git
- Build [1 hour]
cd ~/bitcoin
./autogen.sh
./configure
make
sudo make install
Get the Block Chain [> 30 GB Download]###
-
cd ~
-
wget https://bitcoin.org/bin/blockchain/bootstrap.dat.torrent
-
sudo apt-get install rtorrent
- To quit rtorrent, press
ctrl + q
- To quit rtorrent, press
-
mkdir ~/rDownloads
-
mkdir ~/session
-
Create
~/.rtorrent.rc
with the following content (replaceyour_userName
with your username twice):# Maximum and minimum number of peers to connect to per torrent. min_peers = 50 max_peers = 80 # Same as above but for seeding completed torrents (-1 = same as downloading) min_peers_seed = 1 max_peers_seed = 50 # Maximum number of uploads single torrent may use max_uploads = 4 # Maximum number of simultaneous downloads max_downloads_global = 10 # Maximum number of simultaneous uploads max_uploads_global = 20 # Global upload and download rate in KiB. "0" for unlimited. download_rate = 0 upload_rate = 50 # Default directory to save the downloaded torrents. directory = /home/your_username/rDownloads # Default session directory. Make sure you don't run multiple instance # of rtorrent using the same session directory. Perhaps using a # relative path? session = /home/your_username/session # Watch a directory for new torrents, and stop those that have been # deleted. schedule = watch_directory,5,5,load_start=./rtactive/*.torrent schedule = tied_directory,6,5,start_tied= schedule = untied_directory,7,5,stop_untied= # Close torrents when diskspace is low. schedule = low_diskspace,5,60,close_low_diskspace=2000M # Periodically save session data schedule = session_save,240,300,session_save= # Enable the default ratio group. ratio.enable= # Change the limits, the defaults should be sufficient. # Upload to a minimum ratio of 4.0 ratio.min.set=400 # Upload to a maximum ratio of 20.0 ratio.max.set=2000 # Upload a minimum of 250 MB ratio.upload.set=250M # When seeding ratio is reached close the torrent system.method.set = group.seeding.ratio.command, d.close= # Move files to ./unsorted when download completes system.method.set_key = event.download.finished,move_complete,"execute=mv,-n,$d.get_base_path=,./unsorted/;d.set_directory=./unsorted/" # Port range to use for listening. port_range = 60125-64125 # Start opening ports at a random position within the port range. port_random = yes # Check hash for finished torrents. Might be useful until the bug is # fixed that causes lack of diskspace not to be properly reported. check_hash = yes # Encryption options, set to none (default) or any combination of the following: # allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext # # The example value allows incoming encrypted connections, starts unencrypted # outgoing connections but retries with encryption if they fail, preferring # plaintext to RC4 encryption after the encrypted handshake # encryption = allow_incoming,try_outgoing ,enable_retry dht = auto # UDP port to use for DHT. # dht_port = 63425 # Enable peer exchange (for torrents not marked private) # peer_exchange = yes # Sort the main view by ratio view.sort_current = main,greater=d.get_ratio= view.sort_new = main,less=d.get_ratio= view.sort = main # Sort the seeding view by the upload rate and only show torrents with peers view.sort_current = seeding,greater=d.get_up_rate= view.filter = seeding,"and=d.get_complete=,d.get_peers_connected=" view.sort_new = seeding,less=d.get_up_rate= view.sort = seeding # Sort the leeching view by name view.sort_current = leeching,greater=d.get_name= view.sort_new = leeching,greater=d.get_name= view.sort = leeching # Filter the active view by connected peers view.sort_current = active,less=d.get_name= view.sort_new = leeching,less=d.get_name= view.filter = active,d.get_peers_connected= view.sort = active schedule = sort_main,11,5,view.sort=main schedule = sort_seeding,12,5,view.sort=seeding schedule = sort_leeching,13,5,view.sort=leeching schedule = sort_active,14,5,view.sort=active
-
rtorrent
-
Hit
Enter
-
bootstrap.dat.torrent
(Press enter) -
Press
Up Arrow
Key (see stars/asterisks appear) -
Press
ctrl + s
to start the download- If you need, press
ctrl + d
to stop, again to delete
- If you need, press
-
Wait 6 hours to 3 days for the download to complete
And my HDD failed… TBC. I booted to a recovery CD/Live OS and ran
fsck.ext4 -y /dev/sda1/
and that seemed to fixed things. We’ll try again.
I first had to ctrl + d
inside rtorrent to remove the previous attempt.
- Press
ctrl + q
to quit rTorrent once the blockchain is downloaded- Though I’d recommend you keep it open after syncing the blockchain
cd ~
mkdir .bitcoin
mv rDownloads/bootstrap.dat .bitcoin
Verify and Sync Blockchain [72 hours]###
bitcoin-qt
- Wait for the wallet to sync
- See “Importing blocks from disk”
- Progress should advance several weeks/minute to start, then slow
Forward Port 8333
At this point, your node is connected and can receive data, but will not send any data. It is being selfish.
- If you hover over the connection bars, you’ll see “8 connections”
- This means you are not contributing
- Open you network settings (click network icon in top rightish)
- Click
Wi-Fi Settings
or similar for ethernet - Click the gear icon
- Select
IPv4
on the left and enter a unique IP address, netmask and gateway:192.168.0.22
255.255.255.0
192.168.0.22
(IP Address of your router)
- Reconnect to your network
- Click
- Visit your router (visit its IP address, log in)
- Find the port forwarding section and forward
TCP
on port8333
to you IP address (192.168.0.22
if using the example above)
- Find the port forwarding section and forward
- I reset my computer, not sure if this is required
- In a terminal, launch
bitcoin-qt
- Hover over the connection bars in the Qt bitcoin client
- Verify you get more than 8 connections
- You can optionally move the
bootstrap.dat.old
back to your~/rDownloads
directory and start up the rT orrent to allow others access to it.
Congratulations, you are now running a full node.
When I get time, I will begin testing the code and will share my progress here.