Bitcoin Forum
June 21, 2024, 06:50:50 PM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Exploring alternative full node implementations - Bcoin  (Read 114 times)
ABCbits (OP)
Legendary
*
Offline Offline

Activity: 2912
Merit: 7577


Crypto Swap Exchange


View Profile
October 15, 2022, 09:37:41 AM
Last edit: October 17, 2022, 08:46:16 AM by ETFbitcoin
Merited by o_e_l_e_o (4), BlackHatCoiner (4), seoincorporation (1), HeRetiK (1), DdmrDdmr (1), vv181 (1)
 #1

Intro

Continuing previous thread "Exploring alternative full node implementations - Gocoin"[1], this time i decide to try Bcoin[2]. I choose Bcoin since it's 4th fastest node implementation according to Jameson Lopp benchmark[3] and it has been around for some time.

Basic information

  • Bcoin is written in JavaScript language.
  • Bcoin is developed since 2014[4].
  • Bcoin is built for businesses, miners, wallets, and hobbyists.
  • Bcoin already used on business/production environment, including purse.io[5].
  • Bcoin can be used either as full node, wallet (with some accounting feature), data API (through JSON-RPC) or JavaScript library.

My system

  • Debian-based OS
  • Old 6 core CPU
  • 32GB RAM
  • 3.5" HDD (Both Bitcoin Core and Bcoin data stored here)
  • Node.js v16.17.1
  • Bitcoin Core 23.0
  • Gocoin 2.2.0

Compile and installation

The documentation mention several requirement[6], but i already have all of them installed in my system. Although it surprise me Bcoin still support Node.js v10.0.0 which already reach end of life. The compile/installation process is very simple and i didn't experience any problem.

Code:
git clone --depth=1 --branch=v2.2.0 https://github.com/bcoin-org/bcoin
cd bcoin/
npm rebuild
npm install

You can install Bcoin locally or globally. I decide to install it locally since i'd rather not mess with my system. But take note if you install it locally, bcoin binary is located inside directory bin where you ran npm install and bcoin binary is't available on $PATH[7].

Bcoin configuration

To configure Bcoin, there are 4 available options[8]. Those options are config file, CLI parameter, environment variable & JS object constructor. You also can combine them, but you'll have to pay attention to how Bcoin prioritize the configuration options. Bcoin have both node and wallet functionality, so you'll need to make 2 config file.

If you check list of available configuration, you'll find out Bcoin have feature to index transaction and address. But since it could make initial sync/IBD longer, i decide not to enable those features.

I decide to use config file, which is more convenient than typing long CLI parameter or messing with environment variable. If you use non-default directory path, you'll need to explicitly mention on wallet config file[9]. Aside from configuring Bcoin to only connect to my Bitcoin Core node, i try to make configuration which utilize 100% of my system. But there's no guarantee this is most optimal configuration.

Code:
# bcoin.conf
workers: true
workers-size: 6
sigcache-size: 4000000
prefix: /path/to/bcoin/directory
max-files: 7000
cache-size: 16384
log-level: info
mempool-size: 300
replace-by-fee: true
persistent-mempool: true
port: 48333
only: 127.0.0.1:8333
http-port: 48332
api-key: test_bcoin

Code:
# wallet.conf
prefix: /path/to/bcoin/directory
http-port: 48334

I store both config file on directory which used to store blockchain and other files created by bcoin. In addition, i run bcoin on terminal by specifying directory path so bcoin locate config file automatically.

Code:
./bin/bcoin --prefix=/path/to/bcoin/directory

Initial Block Download (IBD)

It took 9 days to complete initial sync/IBD until block 758232. But since i do not turn on my computer 24/7, actually it took about 90 hours 31 minutes (based on Bcoin log files). During sync i notice Bcoin ask for more block/data after few hours. So it's likely bcoin could sync faster if i turn on my computer 24/7.



Despite configuring bcoin to use all CPU and lots of RAM, bcoin doesn't use much of my system. I did not perform detailed logging, but i never see bcoin use more than 3.1GB of RAM and 300% CPU (according to htop). When i use iotop, i found out bcoin perform lots of disk read/write. After short monitoring with iotop -a, Bcoin perform 4.1GB read and 56.9GB write. This is clearly the reason Bcoin is far slower than gocoin during sync (6.8h[10] vs 90h31m).

And talking about disk read/write, size of block/UTXO on Bcoin is only slightly bigger than Bitcoin Core.

Code:
# Bitcoin Core
$ du -sh *
...
459G    blocks
4.8G    chainstate
...

Code:
# Bcoin
$ du -sh *
...
461G    blocks
6.2G    chain
...

Post IBD

After Bcoin finished initial sync/IBD, Bcoin begin to fill the mempool with unconfirmed transaction. What surprise me Bcoin print lots of error message with code "nonstandard" or "duplicate". After quick search, i found it might happen due to limited Taproot support[11], where only Bech32m address format is supported[12]. I also found out Bcoin isn't actively developed[13], which bring concern about future of Bcoin.

Code:
(net) Error: Verification failure: bad-txns-inputs-spent (code=duplicate score=0 hash=de81bda3cd4a2d10efbe2133a9caa3cf7e36c71c1ba014dafbc2c80ccfdd1a01)
(net) Error: Verification failure: scriptpubkey (code=nonstandard score=0 hash=38911ac69ebdc26d6480115f1745d9800f4505cbf3cd17572003097f0f896ac6)



[1] https://bitcointalk.org/index.php?topic=5407675.0
[2] https://bcoin.io/
[3] https://blog.lopp.net/2021-bitcoin-node-performance-tests-2/
[4] https://github.com/bcoin-org/bcoin#license
[5] https://purse.io/shop, scroll down to bottom page to see text "Powered by bcoin"
[6] https://github.com/bcoin-org/bcoin/blob/v2.2.0/docs/getting-started.md#requirements
[7] https://github.com/bcoin-org/bcoin/blob/v2.2.0/docs/getting-started.md#starting-up-your-first-bcoin-node
[8] https://github.com/bcoin-org/bcoin/blob/v2.2.0/docs/configuration.md
[9] https://github.com/bcoin-org/bcoin/issues/645
[10] https://bitcointalk.org/index.php?topic=5407675.0
[11] https://github.com/bcoin-org/bcoin/issues/1032
[12] https://github.com/bcoin-org/bcoin/pull/1038
[13] https://github.com/bcoin-org/bcoin/issues/1044

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!