Make your own NKM (New Kind of Miner) out of a Raspberry pi

Hi yilun
Hi zbruceli

It looks good right now, but there is a single problem left: ID trx generation. First attempt crashed (broken pipe over ssh) after 8 hours, last attempt crashed after about 9 hours. This is actually not a NKN issue I guess.
However, is there a possibility to generate the ID on another, more powerful machine and then transfer it to the raspberry?

I’ve started the ID generation within systemctl… (to avoid broken pipe when my workstation goes down or what ever).

Thanks for your support.

Yes you can do that, and there are two ways:

  1. Generate a wallet on another machine, use that to generate ID, and when it finishes, stop that nknd and copy wallet.json (and password) back to raspberry pi
  2. Copy the wallet.json (and password) to another machine, when generating ID is done, stop that nknd and start nknd on raspberry pi

Basically generating ID is a on-chain transaction, and it doesn’t matter which machine you use to do it as long as it’s using the same wallet

Thanks yilun for your advice.

Hi yilun,

Ok, generating ID worked as expected.
I’ve used a win10 workstation. There is a web UI on :30000 to see the current state of the node. Is there something similar for rasp? The port 30000 is used (on rasp) but not accessible from another node inside the same network.

Thanks :slight_smile:

You can use --web-gui-listen-address argument to let nknd listen on a different address instead of 127.0.0.1, something like 0.0.0.0 will work. You can use nknd -h to see the argument and info

Hello, I followed all the steps above but I hit a brick wall where I cannot make from source code.
I’m installing on a Raspberry 3B+, fresh install, current Rasbian, Go 1.11 is installed. Yet I get these errors Can you help me?
/////////////////////////////////
pi@raspberrypi:~/nkn $ sudo make
make build_local || make build_local_with_proxy
make[1]: Entering directory ‘/home/pi/nkn’
make build BUILD_DIR=. BIN_DIR=.
make[2]: Entering directory ‘/home/pi/nkn’
GOPROXY= GOOS= GOARCH= GOARM= GO111MODULE=on go build -ldflags “-s -w -X github.com/nknorg/nkn/v2/config.Version=v2.0.7-1-g0498” -o ././nknd ./cmd/nknd/
build github.com/nknorg/nkn/v2/cmd/nknd: cannot find module for path crypto/ed25519
make[2]: *** [Makefile:29: build] Error 1
make[2]: Leaving directory ‘/home/pi/nkn’
make[1]: *** [Makefile:71: build_local] Error 2
make[1]: Leaving directory ‘/home/pi/nkn’
make[1]: Entering directory ‘/home/pi/nkn’
make build_local GOPROXY=https://goproxy.io
make[2]: Entering directory ‘/home/pi/nkn’
make build BUILD_DIR=. BIN_DIR=.
make[3]: Entering directory ‘/home/pi/nkn’
GOPROXY=https://goproxy.io GOOS= GOARCH= GOARM= GO111MODULE=on go build -ldflags “-s -w -X github.com/nknorg/nkn/v2/config.Version=v2.0.7-1-g0498-dirty” -o ././nknd ./cmd/nknd/
build github.com/nknorg/nkn/v2/cmd/nknd: cannot find module for path crypto/ed25519
make[3]: *** [Makefile:29: build] Error 1
make[3]: Leaving directory ‘/home/pi/nkn’
make[2]: *** [Makefile:71: build_local] Error 2
make[2]: Leaving directory ‘/home/pi/nkn’
make[1]: *** [Makefile:75: build_local_with_proxy] Error 2
make[1]: Leaving directory ‘/home/pi/nkn’
make: *** [Makefile:79: build_local_or_with_proxy] Error 2

Welcome to the NKN community!

According to our CTO’s recent software release notes: “Starting from previous version v2.0.5, minimal Golang version required is 1.13”. So please upgrade your go version first.

Thank you for your reply. I did so, I’m on go version go1.15.6 linux/arm now. I purged the github download and nkn folders and started the process all over, I’m facing a differnt issue now.
I’m not well versed in Linux enough to identify the problem… Can you help me further?
//////////////////////////////////
pi@raspberrypi:~/go/src/github.com/nknorg/nkn $ sudo make
make build_local || make build_local_with_proxy
make[1]: Entering directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make build BUILD_DIR=. BIN_DIR=.
make[2]: Entering directory ‘/home/pi/go/src/github.com/nknorg/nkn’
GOPROXY= GOOS= GOARCH= GOARM= GO111MODULE=on go build -ldflags “-s -w -X github.com/nknorg/nkn/v2/config.Version=v2.0.7-1-g0498” -o ././nknd ./cmd/nknd/
/bin/sh: 1: go: not found
make[2]: *** [Makefile:29: build] Error 127
make[2]: Leaving directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make[1]: *** [Makefile:71: build_local] Error 2
make[1]: Leaving directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make[1]: Entering directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make build_local GOPROXY=https://goproxy.io
make[2]: Entering directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make build BUILD_DIR=. BIN_DIR=.
make[3]: Entering directory ‘/home/pi/go/src/github.com/nknorg/nkn’
GOPROXY=https://goproxy.io GOOS= GOARCH= GOARM= GO111MODULE=on go build -ldflags “-s -w -X github.com/nknorg/nkn/v2/config.Version=v2.0.7-1-g0498” -o ././nknd ./cmd/nknd/
/bin/sh: 1: go: not found
make[3]: *** [Makefile:29: build] Error 127
make[3]: Leaving directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make[2]: *** [Makefile:71: build_local] Error 2
make[2]: Leaving directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make[1]: *** [Makefile:75: build_local_with_proxy] Error 2
make[1]: Leaving directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make: *** [Makefile:79: build_local_or_with_proxy] Error 2

I believe it might be related to setting up the Go environment. Have you tried the one-line script from our CTO below? Please do it as root user.

curl https://gist.githubusercontent.com/yilunzhang/2f5edffc16c2b6a999c33cb1c13d6728/raw/4101eee4b5e4a1406accbdf3ddeb1dc40189c484/nkn-old-1-click-upgrade-golang.sh | sh

If the above does not work, please try this tutorial:

Works like a dream :slight_smile:
Thanks for all your support.

1 Like

on the second raspberry i have a different error

`sudo make

make build_local || make build_local_with_proxy
make[1]: Entering directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make build BUILD_DIR=. BIN_DIR=.
make[2]: Entering directory ‘/home/pi/go/src/github.com/nknorg/nkn’
GOPROXY= GOOS= GOARCH= GOARM= GO111MODULE=on go build -ldflags “-s -w -X github.com/nknorg/nkn/v2/config.Version=v2.0.8” -o ././nknd ./cmd/nknd/
/bin/sh: 1: go: not found
make[2]: *** [Makefile:28: build] Error 127
make[2]: Leaving directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make[1]: *** [Makefile:70: build_local] Error 2
make[1]: Leaving directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make[1]: Entering directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make build_local GOPROXY=https://goproxy.io
make[2]: Entering directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make build BUILD_DIR=. BIN_DIR=.
make[3]: Entering directory ‘/home/pi/go/src/github.com/nknorg/nkn’
GOPROXY=https://goproxy.io GOOS= GOARCH= GOARM= GO111MODULE=on go build -ldflags “-s -w -X github.com/nknorg/nkn/v2/config.Version=v2.0.8” -o ././nknd ./cmd/nknd/
/bin/sh: 1: go: not found
make[3]: *** [Makefile:28: build] Error 127
make[3]: Leaving directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make[2]: *** [Makefile:70: build_local] Error 2
make[2]: Leaving directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make[1]: *** [Makefile:74: build_local_with_proxy] Error 2
make[1]: Leaving directory ‘/home/pi/go/src/github.com/nknorg/nkn’
make: *** [Makefile:78: build_local_or_with_proxy] Error 2`

Hi there,

I’m running into a problem similar to @nebeleben, I think. I’m stuck at the creation of the ID.

2021/04/15 12:24:13 Set SyncHeaderMaxSize to 5394
2021/04/15 12:24:13 Set SyncBatchWindowSize to 26
2021/04/15 12:24:13 Set TxPoolMaxMemorySize to 1
2021/04/15 12:24:13.977156 [INFO ] GID 1, Discovering NAT gateway...
2021/04/15 12:24:18.370084 [INFO ] GID 1, Mapped external port 30001 to internal port 30001
2021/04/15 12:24:18.499124 [INFO ] GID 1, Mapped external port 30002 to internal port 30002
2021/04/15 12:24:18.647823 [INFO ] GID 1, Mapped external port 30004 to internal port 30004
2021/04/15 12:24:18.761895 [INFO ] GID 1, Mapped external port 30003 to internal port 30003
2021/04/15 12:24:18.928069 [INFO ] GID 1, Mapped external port 30005 to internal port 30005
2021/04/15 12:24:18.971638 [INFO ] GID 1, Node version: v2.0.8
2021/04/15 12:24:21.368069 [INFO ] GID 1, Getting my IP address...
2021/04/15 12:24:21.927973 [INFO ] GID 1, GetMyExtIP got resp: {"id":"1","jsonrpc":"2.0","result":{"RemoteAddr":"xx.xx.xx.xx"}} from http://mainnet-seed-0009.nkn.org:30003
2021/04/15 12:24:21.940313 [INFO ] GID 1, From http://mainnet-seed-0009.nkn.org:30003 got myself ExtIP: {"id":"1","jsonrpc":"2.0","result":{"RemoteAddr":"xx.xx.xx.xx"}}
2021/04/15 12:24:21.948851 [INFO ] GID 1, My IP address is xx.xx.xx.xx
2021/04/15 12:24:21.965735 [INFO ] GID 1, set default cert domain to: xx-xx-xx-xx.ipv4.nknlabs.io
2021/04/15 12:24:21.974248 [INFO ] GID 1, use default https certs
2021/04/15 12:24:21.979543 [INFO ] GID 1, use default wss certs
2021/04/15 12:24:22.318272 [INFO ] GID 1, database Version: 1
2021/04/15 12:24:22.324771 [INFO ] GID 1, State root: xxxxxxxxxxxxxxxxxxx
2021/04/15 12:24:22.327716 [INFO ] GID 1, Start pruning...
2021/04/15 12:24:22.332777 [INFO ] GID 1, get height of trie pruned error: leveldb: not found
2021/04/15 12:24:22.335340 [INFO ] GID 1, get compact height error: leveldb: not found
2021/04/15 12:24:22.338604 [INFO ] GID 1, get no ID from local ledger
2021/04/15 12:24:22.694123 [INFO ] GID 1, GetID got resp: {"error":{"code":-45022,"data":null,"message":"INTERNAL ERROR, there is no ID in account"},"id":"1","jsonrpc":"2.0"} from http://mainnet-seed-0001.nkn.org:30003
2021/04/15 12:24:22.749861 [INFO ] GID 88, read resourceFile err: open certs/xx-xx-xx-xx.ipv4.nknlabs.io.resource.json: no such file or directory
2021/04/15 12:24:22 [INFO] [xx-xx-xx-xx.ipv4.nknlabs.io] acme: Obtaining bundled SAN certificate
2021/04/15 12:24:23.088935 [INFO ] GID 1, GetID got resp: {"error":{"code":-45022,"data":null,"message":"INTERNAL ERROR, there is no ID in account"},"id":"1","jsonrpc":"2.0"} from http://mainnet-seed-0016.nkn.org:30003
2021/04/15 12:24:23.304369 [ERROR] GID 88, apply cert failed: acme: error: 429 :: POST :: https://acme-v02.api.letsencrypt.org/acme/new-order :: urn:ietf:params:acme:error:rateLimited :: Error creating new order :: too many certificates already issued for: nknlabs.io: see https://letsencrypt.org/docs/rate-limits/, url: 
2021/04/15 12:24:23.550995 [INFO ] GID 1, GetID got resp: {"error":{"code":-45022,"data":null,"message":"INTERNAL ERROR, there is no ID in account"},"id":"1","jsonrpc":"2.0"} from http://mainnet-seed-0042.nkn.org:30003
2021/04/15 12:24:23.695072 [INFO ] GID 1, GetNonceByAddr got resp: {"id":"1","jsonrpc":"2.0","result":{"currentHeight":2530094,"nonce":0,"nonceInTxPool":0}} from http://mainnet-seed-0030.nkn.org:30003
2021/04/15 12:24:23.709311 [INFO ] GID 1, Creating generate ID txn. This process may take quite a few minutes...
2021/04/15 12:24:24.016879 [INFO ] GID 88, read resourceFile err: open certs/xx-xx-xx-xx.ipv4.nknlabs.io.resource.json: no such file or directory
2021/04/15 12:29:22.006335 [INFO ] GID 90, https server is unavailable yet

And if I wait, the last line outputs again every couple of minutes.

This line catches my attention:

Error creating new order :: too many certificates already issued for: nknlabs.io: see https://letsencrypt.org/docs/rate-limits/

But I’ve tried this command multiple times, so perhaps I have exceeded the limit for my IP address.

@nebeleben was suggested to generate the ID on a separate machine. Do you also think I have to do that? I would prefer not to, since I have no idea how - I would need a full tutorial for that.

Update:

I’ve managed to run nknd from my Mac using the same wallet.json file I had in the Raspberry Pi. ID generation is then successful, yay!

But… when I copy that wallet back to the Raspberry and run nknd there, it fails again. :frowning:

It give me:

[INFO ] GID 1, GetID got resp: {"error":{"code":-45022,"data":null,"message":"INTERNAL ERROR, there is no ID in account"},"id":"1","jsonrpc":"2.0"} from http://mainnet-seed-0040.nkn.org:30003

At that same point, my Mac gets this instead:

[INFO ] GID 1, GetID got resp: {"id":"1","jsonrpc":"2.0","result":{"id":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}} from http://mainnet-seed-0021.nkn.org:30003

And is able to continue. Any ideas @yilun or @zbruceli?

This is quite strange. Are you sure you are using the same wallet.json on both side? And they are both in your current working directory when you start nknd?

Ouch! I had a different wallet on the Raspi. My bad. I was convinced I synced the wallets in the two devices, but I must have missed something in the process.

Now it seems to be running the node. Or at least trying to! I see a lot of lines like:

Ping ... error: Wait for reply timeout
Error sending sync messge to node
Get consensus state from neighbor ... error: Wait for reply timeout

and only every now and then also

DropTxns: X txns (XXX bytes) in txpool, no need to drop

Is that normal?

OK, after fiddling with the router config, I’m getting better results. Turns out removing my manually added Port Forwarding rules works better. Now the raspi/router adds the rules as “Automatically added by UPnP” and the node seems to have more successful connections. Now I’m getting many more of these lines:

Remote node connect from xx.xx.xx.xx:41322 to local address xx.xx.xx.xx:30001

Still I’m getting an overwhelming amount of errors like the ones I mentioned above in between. Is that normal?

All of the logs you mentioned are normal. The default log level is pretty verbose, just in case you need some info to debug :slight_smile:

1 Like

So, my Raspberry Pi seems to have been mining for almost 24 hours, however nStatus still says “node offline.” NKNx on the other hand took very long to start listing the node, and when it did, it has it under “WAIT_FOR_SYNCING.” Is that also normal?

That typically means your port forwarding is not set up correctly on your router.

PS: currently nknx is not updating node status and they are working on it. Check their pinned msg in #nknx channel in discord for more info.

Turns out it is super important to upgrade the version of GO. Only after downloading and extracting the latest tar ball did the compilation work. Thank you for this.