Virtual Machine#
Machine configuration:
- 4 vCPU + 16 GB memory
- 1024 GB SSD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| uname -a
# Linux bitcoin-full-node-1024 5.10.0-27-cloud-amd64 #1 SMP Debian 5.10.205-2 (2023-12-31) x86_64 GNU/Linux
cat /etc/os-release
# PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
# NAME="Debian GNU/Linux"
# VERSION_ID="11"
# VERSION="11 (bullseye)"
# VERSION_CODENAME=bullseye
grep -m 1 'cpu cores' /proc/cpuinfo
# cpu cores : 2
lscpu | grep -E '^Thread|^Core|^Socket|^CPU\('
# CPU(s): 4
# Thread(s) per core: 2
# Core(s) per socket: 2
# Socket(s): 1
|
Add an HDD to the VM:
1
2
3
4
5
6
7
8
9
| # mount a new HDD
ls -l /dev/disk/by-id/google-*
# lrwxrwxrwx 1 root root 9 Jan 23 16:00 /dev/disk/by-id/google-extra-disk -> ../../sdb
# ...
sudo mkfs.ext4 -m 0 -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/sdb
sudo mkdir -p /mnt/disks/extraDisk
sudo mount -o discard,defaults /dev/sdb /mnt/disks/extraDisk
sudo chmod a+w /mnt/disks/extraDisk
|
Bitcoin Core#
Current blockchain size is 540+ GB, 82,000+ blocks (January, 2024).
Minimum requirements:
- 7 gigabytes of free disk space, accessible at a minimum read/write speed of 100 MB/s.
- 2 gigabytes of memory (RAM)
- It’s common for full nodes on high-speed connections to use 200 gigabytes upload or more a month. Download usage is around 20 gigabytes a month, plus around an additional 340 gigabytes the first time you start your node.
Setup:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
| # download and extract the binaries
wget https://bitcoin.org/bin/bitcoin-core-25.0/bitcoin-25.0-x86_64-linux-gnu.tar.gz
tar xzf bitcoin-25.0-x86_64-linux-gnu.tar.gz
# create a directory on HDD for the bitcoin blocks
mkdir -p /mnt/disks/extraDisk/bitcoin_blocks
# create a directory on SSD for the other bitcoin data
mkdir -p ~/.bitcoin
# set up rpc authentication
wget https://raw.githubusercontent.com/bitcoin/bitcoin/master/share/rpcauth/rpcauth.py
python3 rpcauth.py funfungho funfunghopw
# String to be appended to bitcoin.conf:
# rpcauth=funfungho:50a7f771594bbc3c612b4d21efe81bdb$074b211fd4b6b735a2ffa126d49a1ef8bd4c573a5cc97b1f003b38a5c0e74238
# Your password:
# funfunghopw
cp ~/bitcoin-25.0/bitcoin.conf ~/.bitcoin
cd ~/.bitcoin
vim bitcoin.conf
## ==== bitcoin.conf starts here ====
# Maintain a full transaction index, used by the getrawtransaction rpc
# call (default: 0)
txindex=1
# Accept command line and JSON-RPC commands
server=1
# Run in the background as a daemon and accept commands (default: 0)
daemon=1
# Specify directory to hold blocks subdirectory for *.dat files (default:
# <datadir>)
blocksdir=/mnt/disks/extraDisk/bitcoin_blocks
# Username and HMAC-SHA-256 hashed password for JSON-RPC connections. The
# field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A
# canonical python script is included in share/rpcauth. The client
# then connects normally using the
# rpcuser=<USERNAME>/rpcpassword=<PASSWORD> pair of arguments. This
# option can be specified multiple times
rpcauth=funfungho:50a7f771594bbc3c612b4d21efe81bdb$074b211fd4b6b735a2ffa126d49a1ef8bd4c573a5cc97b1f003b38a5c0e74238
# Allow JSON-RPC connections from specified source. Valid for <ip> are a
# single IP (e.g. 1.2.3.4), a network/netmask (e.g.
# 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This
# option can be specified multiple times
rpcallowip=127.0.0.1
rpcallowip=172.0.0.0/8
rpcallowip=192.168.0.0/16
# Bind to given address to listen for JSON-RPC connections. Do not expose
# the RPC server to untrusted networks such as the public internet!
# This option is ignored unless -rpcallowip is also passed. Port is
# optional and overrides -rpcport. Use [host]:port notation for
# IPv6. This option can be specified multiple times (default:
# 127.0.0.1 and ::1 i.e., localhost)
rpcbind=0.0.0.0
## ==== bitcoin.conf ends here ====
# start the bitcoin core daemon
bitcoind
# monitor sync log
tail -f ~/.bitcoin/debug.log
sudo apt install nload
# monitor network traffic
nload ens4
sudo apt install bc
# monitor sync progress
echo `bitcoin-cli getblockcount 2>&1`/`curl -s https://blockchain.info/q/getblockcount 2>/dev/null`*100 | bc -l
## bitcoin-cli stop
|
ElectrumX and HTTP Web Proxy For ElectrumX#
ElectrumX allows users to run their own Electrum server. It connects to your full node and indexes the blockchain, allowing efficient querying of history of arbitrary addresses. The server can be exposed publicly, and joined to the public network of servers via peer discovery.
When building the database from the genesis block, ElectrumX has to flush large quantities of data to disk and its DB. You will have a better experience if the database directory is on an SSD than on an HDD. Currently to around height 611,600 of the Bitcoin blockchain the final size of the leveldb database, and other ElectrumX file metadata comes to just over 46.9GB (43.7 GiB). LevelDB needs a bit more for brief periods, and the block chain is only getting longer, so I would recommend having at least 70-80GB of free space before starting.
Setup:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| ## install docker
# https://docs.docker.com/engine/install/debian/#install-using-the-repository
# https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user
# download the docker-compose.yml file
wget https://raw.githubusercontent.com/Next-DAO/atomicals-electrumx-proxy-docker/main/docker-compose.yml -O docker-compose-electrumx.yml
# config the deamon url
vim docker-compose-electrumx.yml
# ==== docker-compose-electrumx.yml starts here ====
image: lucky2077/atomicals-electrumx:v1.3.9.0
# rpcauth
- DAEMON_URL=funfungho:funfunghopw@10.202.0.7:8332
# ==== docker-compose-electrumx.yml ends here ====
# start the docker containers
docker compose -f docker-compose-electrumx.yml up -d
docker logs -f funfungho-electrumx-1
sudo apt install sysstat
# monitor disk IO
iostat -m -d 5
curl http://localhost:8080
# {"success":true,"info":{"note":"Atomicals ElectrumX Digital Object Proxy Online","usageInfo":{"note":"The service offers both POST and GET requests for proxying requests to ElectrumX. To handle larger broadcast transaction payloads use the POST method instead of GET.","POST":"POST /proxy/:method with string encoded array in the field \"params\" in the request body. ","GET":"GET /proxy/:method?params=[\"value1\"] with string encoded array in the query argument \"params\" in the URL."},"healthCheck":"GET /proxy/health","github":"https://github.com/atomicals/electrumx-proxy","license":"MIT"}}
curl http://localhost:8080/proxy/health
# {"success":true,"health":true}
|
References