Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: DireWolfM14 on September 27, 2021, 12:29:12 AM



Title: Help with mempool.space local install
Post by: DireWolfM14 on September 27, 2021, 12:29:12 AM
I need some help installing a local instance of mempool.space, hoping some of you with experience can chime in.

I've installed all the dependencies using apt, so they should all be stable LTS versions.  I also installed npm.  

I am trying to run this on separate hardware than my bitcoind and electrumx services.  On the mempool machine I set up the config file with the node server's local IP, and an rpc password generated using rpcauth.py.  On the node server I added the user authorization to the bitcoin.conf file, opened the applicable ports in ufw, and set port routing in my router.  I double checked all that over and over, so I'm sure that's not presenting any issues.

I installed nodejs and mariadb only on the machine that'll be running mempool, not on the machine running bitcoind/electrumx.

Here's the error I get when trying to run the backend:

Code:
direwolf@mempoolserver:/usr/local/bin/mempool/backend$ sudo npm run start

> mempool-backend@2.2.2 start /usr/local/bin/mempool/backend
> node --max-old-space-size=2048 dist/index.js

/usr/local/bin/mempool/backend/dist/index.js:24
    wss;
       ^

SyntaxError: Unexpected token ;
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mempool-backend@2.2.2 start: `node --max-old-space-size=2048 dist/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mempool-backend@2.2.2 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-09-26T23_59_21_850Z-debug.log

Here's my mempool-config.json file.  I only changed the rpc password in two places, and the IP address in thee places (as shown below.)

Code:
{
  "MEMPOOL": {
    "NETWORK": "mainnet",
    "BACKEND": "electrum",
    "HTTP_PORT": 8999,
    "SPAWN_CLUSTER_PROCS": 0,
    "API_URL_PREFIX": "/api/v1/",
    "POLL_RATE_MS": 2000,
    "CACHE_DIR": "./cache",
    "CLEAR_PROTECTION_MINUTES": 20,
    "RECOMMENDED_FEE_PERCENTILE": 50,
    "BLOCK_WEIGHT_UNITS": 4000000,
    "INITIAL_BLOCKS_AMOUNT": 8,
    "MEMPOOL_BLOCKS_AMOUNT": 8,
    "PRICE_FEED_UPDATE_INTERVAL": 3600
  },
  "CORE_RPC": {
    "HOST": "<local node server ip>",
    "PORT": 8332,
    "USERNAME": "mempool",
    "PASSWORD": "<rpcpassword generated by rpcauth.py>"
  },
  "ELECTRUM": {
    "HOST": "<local node server ip>",
    "PORT": 50002,
    "TLS_ENABLED": true
  },
  "ESPLORA": {
    "REST_API_URL": "http://127.0.0.1:3000"
  },
  "CORE_RPC_MINFEE": {
    "ENABLED": false,
    "HOST": "<local node server ip>",
    "PORT": 8332,
    "USERNAME": "mempool",
    "PASSWORD": "<rpcpassword generated by rpcauth.py>"
  },
  "DATABASE": {
    "ENABLED": true,
    "HOST": "127.0.0.1",
    "PORT": 3306,
    "DATABASE": "mempool",
    "USERNAME": "mempool",
    "PASSWORD": "mempool"
  },
  "SYSLOG": {
    "ENABLED": true,
    "HOST": "127.0.0.1",
    "PORT": 514,
    "MIN_PRIORITY": "info",
    "FACILITY": "local7"
  },
  "STATISTICS": {
    "ENABLED": true,
    "TX_PER_SECOND_SAMPLE_PERIOD": 150
  },
  "BISQ": {
    "ENABLED": false,
    "DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db"
  }
}

Thanks in advance.


Title: Re: Help with mempool.space local install
Post by: DireWolfM14 on September 27, 2021, 04:21:18 PM
Code:
/usr/local/bin/mempool/backend/dist/index.js:24
    wss;
       ^

SyntaxError: Unexpected token ;

I'm beginner at JS/TS, but looks like it's syntax error rather than mistake on file configuration. Did you grab the source code from release page (https://github.com/mempool/mempool/releases (https://github.com/mempool/mempool/releases)) or clone the master branch?

I followed the instructions in the README.md (https://raw.githubusercontent.com/mempool/mempool/master/README.md) file, so first I cloned the master:

Code:
git clone https://github.com/mempool/mempool

Then I checked out latest release:

Code:
latestrelease=$(curl -s https://api.github.com/repos/mempool/mempool/releases/latest|grep tag_name|head -1|cut -d '"' -f4)
git checkout $latestrelease

I've installed all the dependencies using apt, so they should all be stable LTS versions.  I also installed npm. 

It might be helpful to mention linux distro you use and version of your NodeJS.

Good point:

Both servers are running Ubuntu Server version 20.04.3 LTS.   I only installed NodeJS onto the machine I want to run mempool, the version installed by the app manager is 10.19.0.  I just looked up the NodeJS site, and noticed their latest LTS version is 14.17.16.  The version I have was originally released in February of 2020.  That may have something to do with it, odd that such an old package is the one installed by apt.

I'll try installing the newer LTS version of NodeJS, hope it helps.


Title: Re: Help with mempool.space local install
Post by: ABCbits on September 28, 2021, 08:51:11 AM
I followed the instructions in the README.md (https://raw.githubusercontent.com/mempool/mempool/master/README.md) file, so first I cloned the master:

Code:
git clone https://github.com/mempool/mempool

Then I checked out latest release:

Code:
latestrelease=$(curl -s https://api.github.com/repos/mempool/mempool/releases/latest|grep tag_name|head -1|cut -d '"' -f4)
git checkout $latestrelease

You checked out the latest stable version, so i think it's not the problem.

Both servers are running Ubuntu Server version 20.04.3 LTS.   I only installed NodeJS onto the machine I want to run mempool, the version installed by the app manager is 10.19.0.  I just looked up the NodeJS site, and noticed their latest LTS version is 14.17.16.  The version I have was originally released in February of 2020.  That may have something to do with it, odd that such an old package is the one installed by apt.

I'll try installing the newer LTS version of NodeJS, hope it helps.

IMO it's the problem. According to https://nodejs.org/en/about/releases/ (https://nodejs.org/en/about/releases/) and https://en.wikipedia.org/wiki/Node.js#Releases (https://en.wikipedia.org/wiki/Node.js#Releases), v10 was released on 2018 & no longer updated. Meanwhile v14 is released on 2020, but still actively supported until few years later. On a side note, you should use rolling-release linux distro if you really want up-to-date package.


Title: Re: Help with mempool.space local install
Post by: DireWolfM14 on September 28, 2021, 02:26:57 PM
IMO it's the problem. According to https://nodejs.org/en/about/releases/ (https://nodejs.org/en/about/releases/) and https://en.wikipedia.org/wiki/Node.js#Releases (https://en.wikipedia.org/wiki/Node.js#Releases), v10 was released on 2018 & no longer updated. Meanwhile v14 is released on 2020, but still actively supported until few years later. On a side note, you should use rolling-release linux distro if you really want up-to-date package.

I installed the npm package "n" and used that to update to the latest LTS version of Node.js.  The funny thing is it didn't update NodeJS, just Node.js.  To prevent the older version from being used I removed it using apt, then created a simlink to the new package.

That resolved the errors I was getting while trying to run the backend, but I got another error that I'm now trying to work out: ECONNREFUSED port 8332.  Once again I checked all my settings, but was unable to find from where the error is stemming.  Mempool connects to my Electrum server just fine, but Bitcoin Core is refusing the connection for some unknown reason.

I have the following lines in my bitcoin.conf file:

Code:
rpcbind:127.0.0.1
rpcallowip:<local mempool server ip>
rpcport:8332

I tried disabling all those one at a time, and also all three together but nothing helped.

@DaveF, please go easy on me.  :D


Title: Re: Help with mempool.space local install
Post by: vv181 on September 28, 2021, 04:56:42 PM
~
Try to add this on your bitcoin.conf, let's see if that solve the issue since I have a similar problem back then when I tried to set up mempool on my PC and node on my RasPi.

Code:
rpcbind:127.0.0.1
rpcbind:<local node server IP>
rpcallowip:<local mempool server ip>
rpcport:8332


Title: Re: Help with mempool.space local install
Post by: DireWolfM14 on September 28, 2021, 11:19:07 PM
~
Try to add this on your bitcoin.conf, let's see if that solve the issue since I have a similar problem back then when I tried to set up mempool on my PC and node on my RasPi.

Code:
rpcbind:127.0.0.1
rpcbind:<local node server IP>
rpcallowip:<local mempool server ip>
rpcport:8332

That did it, thanks for the suggestion!  My mempool backend is running!  Thank you for your help, gentlemen.  I'll see you when I have trouble with the frontend.  ;D


Title: Re: Help with mempool.space local install
Post by: NotATether on September 29, 2021, 08:07:15 AM
A side note: "Latest" or "Rolling" releases of node break a lot of packages that would otherwise build fine on older node versions, so you're probably better off with sticking to v14 LTS for now.


Title: Re: Help with mempool.space local install
Post by: DireWolfM14 on September 29, 2021, 12:46:35 PM
A side note: "Latest" or "Rolling" releases of node break a lot of packages that would otherwise build fine on older node versions, so you're probably better off with sticking to v14 LTS for now.

Yeah, to update I used the npm tool "n" with this command: sudo n lts, which installed the current LTS version, 14.17.6.


The funny thing is it didn't update NodeJS, just Node.js.

Those two are different? I thought it's just different name.

I believe they are interchangeable.  After updating, when I checked the version I got two different versions.  For example, when I checked the version of Node.js I got this:
Code:
~: node -v
v14.17.6

When I checked the version of NodeJS, I got the old version:
Code:
~: nodejs -v
v10.19.0

When I updated, a comment in the update log mentioned that the new package was installed in a new directory, the file location is /usr/local/bin/node.   NodeJS, however was installed at /usr/bin/nodejs.