Developers Forum for XinFin XDC Network

go140point6
go140point6

Posted on • Updated on

[Informative] Setting up an Apothem Masternode on XDC 2.0

This post is meant to provide some information on what worked for me setting up a clean Apothem Masternode using XDC 2.0 code (v1.4.8-beta). Be aware there is a good chance what worked for me here won't necessarily work as development on XDC 2.0 continues. I also can't be 100% certain some of these issues weren't localized to me, so your mileage may vary. Use this as rough guide and please offer discussion below on what works/doesn't work for you.

I attempted to upgrade my 1.0 Apothem Masternode but was unsuccessful, likely due to user error on my part. I spent some time attempting to fix but in the end I decided to wipe the VPS and start over clean.

Before I wiped my VPS, I followed the general procedure ensuring I backed up my coinbase.txt and keystore/UTC--DateTime--Address file. This node was fully funded with 10 million Apothem XDC and was working as intended on 1.0 for over 6 months:
https://docs.xdc.community/run-a-node/full-node/how-to-migrate-an-xdc-node

I followed Method 3 documented here:
https://github.com/XinFinOrg/XinFin-Node

As of this writing, the format of the .env has changed from:

INSTANCE_NAME=YOUR_NODE_NAME
CONTACT_DETAILS=YOUR_EMAIL_ADDRESS
NODE_TYPE=full

to:

NODE_NAME=YOUR_NODE_NAME
CONTACT_DETAILS=YOUR_EMAIL_ADDRESS
NODE_TYPE=full

PORT=30304
RPC_PORT=8545
WS_PORT=8555

PRIVATE_KEYS=
NETWORK=testnet
LOG_LEVEL=3

There were two issues with Method 3 that I had to work around.

One: After filling in my NODE_NAME and CONTACT_DETAILS and starting up the node, nothing appeared to be happening. No xdcchain directory was created where it started to download the chain. Listing the container showed me it was in a reboot loop and inspecting the logs inside the container showed the problem was missing PRIVATE_KEYS in the .env:

sudo docker ps
sudo docker logs --tail 50 --follow --timestamps testnet_xinfinnetwork_1

I pulled out my private key (ciphertext) from my UTC--DateTime--Address file and used it in the .env and this allowed the node to start. I then:

  • stopped the container.
  • replaced the newly created coinbase.txt and copied over keystore\UTC--DateTime--Address from my backups.
  • started up the container.
  • deleted the new UTC--DateTime--Address file.

I'm currently waiting for it to sync from the beginning as the apothem.tar URL listed in the docs is no longer valid. The one for mainnet (xdcchain.tar) is still working as of this writing:
https://docs.xdc.community/run-a-node/full-node/full-node

Two: NODE_NAME in the .env doesn't seem to pass to the docker container. I suspect this will be resolved very shortly, as it's likely just a minor bug. I resolved it setting the following for now and restarting the container:
NODE_NAME="MyNodeNameOfChoice"

Note that as of this writing, https://apothem.network/#stats exposes the IP address and XDC address of the XDC 2.0 instances. I suspect this will likely be resolved shortly.

Questions that came up during this exercise:

  1. How does someone set up a completely new XDC Apothem 2.0 masternode without a previous private key? I assume they create an address manually in XDCPay or elsewhere, and export the private key to use.

  2. Once I have an up-to-date chain, how can I save that to help with future migrations and/or share with others as needed? Is it as simple as tarring up my xdcchain folder only omitting my coinbase and keystore\UTC--DateTime--Address files? Or is it enough to tar up and save only xdcchain\XDC?

  3. I need to start my node with the --enable-0x-prefix option but with the node startup script inside the container, it was difficult. I managed to make my needed changes and then create a copy of that image, and change docker-compose.yml to start my image instead. Is there a reason all the startup script info was moved into the docker container?

Discussion (5)

Collapse
go140point6 profile image
go140point6 Author

I added a 3rd question because with this new format, the start up script is inside the container and I can't make changes to either the script to pull a value from my .env or the command line itself in the script to hard code my needed option.

Collapse
go140point6 profile image
go140point6 Author

OK, figured out a work-around by making my changes to the running image and then making a copy of that image that I can start instead. Learning docker as I go I guess... :)

Collapse
inv4fee2020 profile image
inv4fee2020

@anilchinchawale @liamlai @rushabh_parmar can anyone offer guidance here?

Collapse
mitali_blocksscan profile image
Mitali_BlocksScan

@go140point6 ,
Thank you for providing your experience may the other users find it useful.

Collapse
inv4fee2020 profile image
inv4fee2020

Nice write up. Thanks 👍