bitcoin-tools / nodebuilder Goto Github PK
View Code? Open in Web Editor NEWRun a secure Bitcoin Core node with ease.
License: MIT No Attribution
Run a secure Bitcoin Core node with ease.
License: MIT No Attribution
Increase the hard-coded value for archival_node_required_disk_in_gib
(line 256).
The sweet spot is about 50 to 100 GB more than the size of blocks/
+ chainstate/
.
Back in June 2023, that sum was 522. Now, it's 586.
user1@comp1:~$ du -hd1 .bitcoin/
576G .bitcoin/blocks
9.9G .bitcoin/chainstate
586G .bitcoin/
Bring it back into the sweet spot.
Seems to be a regressoin.
This happens when running into an error while checking for internet:
user1@comp1:~/Documents/GitHub/nodebuilder$ ./nodebuilder
./nodebuilder: line 77: err: command not found
\E[6n
user1@comp1:~/Documents/GitHub/nodebuilder$ ^C
user1@comp1:~/Documents/GitHub/nodebuilder$ ^C
user1@comp1:~/Documents/GitHub/nodebuilder$ shellcheck nodebuilder
user1@comp1:~/Documents/GitHub/nodebuilder$ bash -x nodebuilder
+ set -o errexit
+ set -o nounset
+ set -o pipefail
+ trap handle_exit EXIT
+ trap 'handle_error ${LINENO:-}' ERR
+ target_bitcoin_version=26.0
++ uname -m
+ target_bitcoin_architecture=x86_64
+ case "$(uname -s)" in
++ uname -s
+ target_bitcoin_operating_system=linux-gnu
++ mktemp -d
+ temp_directory=/tmp/tmp.5redc0oxE7
+ bitcoin_core_data_dir=/home/user1/.bitcoin
+ user_data_dir=/home/user1/.local/share
+ shortcut_image_source=https://github.com/bitcoin-tools/nodebuilder/raw/master/data/bitcoin.png
+ shortcut_image_file=/home/user1/.local/share/images/bitcoin.png
+ timeout --preserve-status 0.1 nc -z 1.1.1.1 53
+ timeout --preserve-status 0.1 nc -z 8.8.8.8 53
+ timeout --preserve-status 0.5 nc -z bitcoincore.org 443
+ err 'ERROR: Check for active internet failed.'
nodebuilder: line 77: err: command not found
++ handle_error 77
++ ensure_cursor_is_on_column_one
++ printf %s '\E[6n'
\E[6n++ read -rsdR cursor_position
+++ handle_exit
+++ '[' -n /tmp/tmp.5redc0oxE7 ']'
+++ rm -rf -- /tmp/tmp.5redc0oxE7/
Inconsistent Behavior Across Different Systems
Another issue you might encounter is inconsistent behavior of the echo command across different systems. This is because the behavior of echo can vary depending on the system and the shell. For instance, some versions of echo support the ‘-e’ option, while others don’t.
If you’re writing a script that will be run on different systems, it might be better to use printf instead of echo, as printf has more consistent behavior.
Taken from https://ioflood.com/blog/bash-echo-newline/
This is the output to the user.
Syncing the block headers (second pass).\nHeaders synced: 747559\nChain sync size: 0 MiB\nDisk free space: 18 GiB\n\nSynchronizing can take weeks on a slow connection.\n
Something like this:
if command -v sha256sum >/dev/null; then
sha256sum_cmd="sha256sum"
elif command -v shasum >/dev/null; then
sha256sum_cmd="shasum -a 256"
else
>&2 echo "Either 'sha256sum' or 'shasum' must on PATH."
>&2 echo "Exiting..."
exit 1
fi
Taken from this GitHub commit
Use ~/Library/Application Support/Bitcoin
instead of ~/.bitcoin
.
When RAM is sufficient, set Bitcoin Core to run with increased dbcache.
No more than 25% of the total RAM on the system.
dbcache
.maxmempool
.maxconnections
.MALLOC_ARENA_MAX=1
.https://github.com/bitcoin/bitcoin/blob/master/doc/reduce-memory.md
...
Extracting Bitcoin Core... ok.
Running the unit tests... ok.
Installing Bitcoin Core... mkdir: cannot create directory '/usr/local/share/man/man1': Permission denied
user1@comp1: $ mkdir -p /usr/local/share/man/man1
mkdir: cannot create directory '/usr/local/share/man/man1/': Permission denied
user1@comp1: $ sudo mkdir -p /usr/local/share/man/man1
user1@comp1: $
From CI job https://github.com/bitcoin-tools/nodebuilder/actions/runs/7501247007/job/20421542028:
+ echo -n 'Performing a system upgrade... '
+ sudo NEEDRESTART_MODE=a apt-get -qq dist-upgrade --assume-yes
+ '[' -f /var/run/reboot-required ']'
++ cat /var/run/reboot-required.pkgs
+ echo -en '\nREBOOT REQUIRED to upgrade the following:\nlibc6\n\nPRESS ANY KEY to reboot or press Ctrl+C to exit... '
Performing a system upgrade...
REBOOT REQUIRED to upgrade the following:
libc6
+ read -rsn1
+ echo Rebooting.
+ sudo reboot
PRESS ANY KEY to reboot or press Ctrl+C to exit... Rebooting.
+ exit 0
+ handle_exit
+ '[' -n /tmp/tmp.m1PIsurix2 ']'
+ rm -rf -- /tmp/tmp.m[1](https://github.com/bitcoin-tools/nodebuilder/actions/runs/7501247007/job/20421542028?pr=3#step:10:1)PIsurix[2](https://github.com/bitcoin-tools/nodebuilder/actions/runs/7501247007/job/20421542028?pr=3#step:10:2)/
. ok.
Removing temporary files... ok.
Creating application shortcuts... grep: /proc/1/cgroup: No such file or directory
/bin/bash: line 266: [: : integer expression expected
ok.
Starting Bitcoin Core... grep: /proc/1/cgroup: No such file or directory
/bin/bash: line 383: [: : integer expression expected
ok.
and
Disk free space: 58 GiB
grep: /proc/1/cgroup: No such file or directory
/bin/bash: line 464: [: : integer expression expected
Synchronizing can take weeks on a slow connection.
This will be helpful as the project evolves to allow other projects to use the nodebuilder repo as a submodule.
Such as "install Bitcoin and perform the IBD, then afterwards run this other code that uses Bitcoin RPC calls."
Here's the contents of test_script_for_childparent.sh
:
#!/bin/bash
echo "state\$PPID is $(ps -o stat= -p $PPID)"
echo "state\$\$ is $(ps -o stat= -p $$)"
Here's what happens when you run it:
user1@comp1:~/Desktop$ ./test_script_for_childparent.sh
state$PPID is Ss
state$$ is S+
user1@comp1:~/Desktop$ ./test_script_for_childparent.sh &
[1] 10955
user1@comp1:~/Desktop$ state$PPID is Ss+
state$$ is S
[1]+ Done ./test_script_for_childparent.sh
Here's the contents of test_script_launcher.sh
:
#!/bin/bash
/bin/bash -c "./test_script_for_childparent.sh"
Here's what happens when you run it:
user1@comp1:~/Desktop$ ./test_script_launcher.sh
state$PPID is S+
state$$ is S+
user1@comp1:~/Desktop$ ./test_script_launcher.sh &
[1] 10967
user1@comp1:~/Desktop$ state$PPID is S
state$$ is S
[1]+ Done ./test_script_launcher.sh
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/upload-artifact@v3. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
During check for internet, increase the timeouts 10x from 0.1 -> 1 and 0.5 -> 5.
user1@comp1:~$ timeout --preserve-status 10 nc -z 1.1.1.1 53
user1@comp1:~$ echo $?
0
user1@comp1:~$ timeout --preserve-status 0.1 nc -z 1.1.1.1 53
user1@comp1:~$ echo $?
143
user1@comp1:~$ timeout --preserve-status 0.1 nc -z 1.1.1.1 53 && echo ok
user1@comp1:~$ timeout --preserve-status 1 nc -z 1.1.1.1 53 && echo ok
ok
Update/upgrade brew instead
+ printf %s 'Starting Bitcoin Core... '
+ '[' true = true ']'
+ bitcoind --daemonwait
Starting Bitcoin Core... Bitcoin Core starting
+ printf '%s\n' ok.
ok.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.