Run on one VPS & Premining

+1 vote
This tutorial requires two server nodes.

As per above statement, If I am not wrong I need two VPS servers. Right?

I want to do premine blocks. Is there any way to do it?
asked Jan 4, 2018 by Dhwalin

1 Answer

0 votes

Yes, a couple of DigitalOcean or Linode servers will work fine.  Below are some quick Ubuntu 16.04 instructions;

First, open a couple of tabs and SSH to both of your VPSs using your root account (ssh root@11.22.33.44);

1. ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'     // TAKE NOTE OF LAN/WAN IPs
2. dpkg-reconfigure tzdata     // SET TIME
3. adduser yourName
4. usermod -aG sudo yourName

Open a third tab for localhost and create keys;

5. ssh-keygen    // IF YOU ALREADY HAVE KEYS, SKIP THIS STEP
6. ssh-copy-id root@ip.of.server        // USE YOUR ROOT PASSWORD
7. ssh-copy-id yourName@ip.of.server       // USE YOUR yourName PASSWORD

Return to SSH tabs;

8. sudo nano /etc/ssh/sshd_config
  PermitRootLogin without-password
  PasswordAuthentication no

9. sudo nano /etc/nanorc
    set tempfile
    set autoindent

10. export EDITOR=/usr/bin/nano
11. sudo systemctl reload sshd
12. exit      // LOG OUT ROOT

SSH back onto VPSs using yourName user accounts;

13. download [whatever version of] MultiChain and unzip
14. cp ~/multichaind multichain-cli multichain-util /usr/local/bin
15. multichain-util create yourChain     // ONLY DO THIS ON FIRST SERVER
16. sudo nano ~/.multichain/yourChain/params.dat     // ONLY DO THIS ON FIRST SERVER

    setup-first-blocks=60, initial-block-reward=50, first-block-reward=10000000000

The first item above is how many blocks it will take for the rules to activate, the second item is the per block miner reward, and the third item is the pre-mining.  Of course, set these to whatever values you like.  Also, make sure to set the consensus requirements correctly so that blocks are mined using your first and/or second node.... see https://www.multichain.com/developers/blockchain-parameters/ .  Save and close document.

The following instructions assume you set anyone-can-connect=true as one of the global permissions in the params.dat file.

17. multichain yourChain -daemon     // ONLY DO THIS ON FIRST SERVER
18. multichaind yourChain@xx.xx.xx.xx:1234     // DO THIS ON SECOND SERVER
19. multichain-cli yourChain     // getinfo (https://www.multichain.com/developers/json-rpc-api/)
20. multichain-cli yourChain stop   // TO QUIT

Otherwise, if yourChain was set to private(anyone-can-connect=false), use the instructions on this page to connect your second node; https://www.multichain.com/getting-started/

If/when you mess up, simply stop the service as per #20, and rm -R ~/.multichain and start over again beginning from step #15.

answered Jan 4, 2018 by ericjarvies
Thank you for your answer. I have started mining on server. But how can I allow people to start mining? I have downloaded GUIMiner, in host I put server ip, username:multichainrpc, password as mentioned in conf file.

When I press start mining it said TARGET MACHINE refunsing..
Well, you can send them; multichaind, multichain-cli, and multichain-util and give them yourName@11.22.33.44:1234 info... assuming anyone-can-connect=true.  If anyone-can-connect=false you will need to grant them permission (see https://www.multichain.com/getting-started/).  I do not have an answer for you regarding GUIMiner.
Alright. See two things happened. One creating block stops on server, & second when I tried to connect blockchain as per you said, it gave me error that please check multichaind is running at that address and that your firewall settings allow incoming server.

When inserted command on server multichaind mkcoin1, it said

IO error: lock /root/.multichain/mkcoin1/permissions.db/LOCK: Resource temporarily unavailable

ERROR: Couldn't initialize permission database for blockchain mkcoin1. Probably multichaind for this blockchain is already running. Exiting...
Ok I think setupblocks are 60, that is why it stopped & other users not able to connecting?
You need to make sure you have compatible settings for "consensus requirements" and "defaults for mining runtime parameters" and "native blockchain currency" and "advanced mining parameters" as are shown/explained on this page; https://www.multichain.com/developers/blockchain-parameters/

After 60 blocks, the rules you set kick-in/take effect, so if your rules have conflicts (as per only two nodes), than problems will occur.  Set the mining-requires-peers=false to begin with, so you can at least move forward... same with a few other settings... as you figure it out, you can add those back into the mix.
Thank you very much boss.
Still same error though....
You cannot run two copies of MultiChain on the same system (defined in terms of an operating system environment) unless you use the datadir setting to give at least one of them a different blockchain directory.
I have purchased 2 vps, started nodes on both. In more, I have started 3rd Node on my PC too. But nothing is happening. Neither increasing blocks nor creating any balances.

All balances go into first VPS in which I have setup node.

Now there are few questions:

1. why creating blocks stopped?
2. how to make transactions between wallets?
3. What is balance? is that reward for mining? if yes, how to transfer amount to another wallet?
If you want to mine blocks continuously -even if there are no transactions- you should set mine-empty-rounds = -1

Otherwise you need to make some transactions between accounts/nodes, e.g.-
sendasset 1bJKLjs6vZ8LEp4JG5LQiu3VuGUAvYv7KSnMb9 USD 10.00

Of course, this assumes you have already created some assets.  If not, go ahead and create at least one, e.g.-
issue 1YCDJ9HNpVNiUmv9jXtmoMRZJFqqd9ESviuAWp MOO 1000 0.01

*Remember to use one of 'your' addresses (don't use the ones above).

Point being... if there are no transactions occurring on your blockchain, there is no reason for it to create new blocks (unless mine-empty-rounds = -1).
If you wan't to see your native coin balance, run something like 'getmultibalances' and take note of the assetref group qty, and go ahead and do another 'sendasset' transaction, and run 'getmultibalances' again, and the amount should have increased on the subsequent mined block.
Thank you for your reply..

Can you please tell me why block is not increasing in my 3rd PC?

I have sent some balance with sendtoaddress to that pc node but balance did not increase.

Is there any way to pre define wallet id address before starting node? So reward get save in that wallet id?
I assume you are referring to the native coin balance?  If so, on the recipient node use 'getmultibalances' to view both the assets and the native coin balances.  The 'gettotalbalances' command will only display assets.

If you are still unable to see the balance (increase), run 'listwallettransactions' on the recipient node and see if the latest transaction is shown.  If it is not shown, run 'listwallettransactions' on the sending node and inspect the last transaction and see if you got the address wrong.

The mining reward is only able to go to the original node address.
Ok thank you very much
For your block count problem (not increasing), stop the 3rd PC;

multichain-cli [chain] stop

and reconnect it;

multichaind [chain]@[ip-address]:[port]

On all the nodes check the block count again;

multichain-cli [chain] getinfo
ok sure. (y)
...