How to Mine Zcash on Amazon EC2

Austin, thank you for the instructions, much appreciated. I cannot see any solution referring to the nonce issue, does this mean it is no longer an issue, as you mentioned in your post above?

1 Like

Yes. If I understand correctly, the native zcashd miner initializes the nonce to a random number now.

Can we get an ACK on this from anyone on the dev team?

1 Like

The nonce is randomized, as shown here:
https://github.com/zcash/zcash/blob/zc.v0.11.2.latest/src/miner.cpp#L358

2 Likes

:slight_smile:
Thank you. So happy to see this!

1 Like

Sorry, that was done on June 29 ( Randomise the nonce in the block header Ā· zcash/zcash@8e165d5 Ā· GitHub ) but I hadnā€™t seen that anyone had asked about it.

1 Like

Thanks for doing this guide Austin, good job! I choose option 2 and increased my poolsize to 30,000 before taking an image. I then created 2 instances. I have a few questions:

  1. I assume I need to backup only one wallet rather than each wallet on all instances, correct?
  2. When I start adding to the wallet, do I need to backup the wallet again?
  3. If I lose some or all of my AWS instances (say I delete them all after a night of partying)
    a. I wonā€™t have lost my previously mined zcash because of my backed up wallet, correct?
    b. Will I have lost my unconfirmed balances on each instance?

Thanks!

Hi everyone! - And thanks for putting in the time to write this guide, Austin!

I followed your guide and installed v0.11.2.z9, but Iā€™m getting a weird error when trying to start the miner:

ubuntu@ip-172-31-24-240:~$ ~/zcash/./src/zcashd -daemon
Zcash server starting
ubuntu@ip-172-31-24-240:~$ 

************************
EXCEPTION: St13runtime_error       
could not load param file at /home/ubuntu/.zcash-params/testnet3/z9-verifying.key       
bitcoin in AppInit()       

zcashd: /home/ubuntu/zcash/depends/x86_64-unknown-linux-gnu/include/boost/thread/pthread/condition_variable_fwd.hpp:81: boost::condition_variable::~condition_variable(): Assertion `!ret' failed.

Any idea what I might be doing wrong?

This is usually caused by not having a configuration file set up.
Make sure you have the zcash.conf file inside the .zcash folder.

1 Like

Thanks for helping out Shawn!

Iā€™ve run:

cd zcash
~/zcash$ mkdir ~/.zcash
nano ~/.zcash/zcash.conf

And saved the following contents in that file:

testnet=1
addnode=alphatestnet.z.cash
rpcuser=rpcusername
rpcpassword=rpcpassword
gen=1

Yet the error persists :frowning:

Iā€™ve had this error once before for some reason and fixed it by:
Stopping the server (zcash-cli stop)
Then remove the .zcash folder you created
Then restart the daemon (zcashd -testnet)
This will throw an error telling you that there is no config file and such, but it will also create the .zcash folder and the testnet3 folder for you.
Now you can place your zcash.conf file back inside the .zcash folder.
Restart the daemon normally (zcashd -daemon) and you should be good to go.

1 Like

I followed the steps in your last post but I keep getting the same error.
Should I also delete the testnet3 folder, and if so, where can I find it?

During install, did you see 4 lines that ended in ā€œOKā€ at the end of one of the steps? That would indicate your z9-proving.key and z9-verifying.key in .zcash-params/regtest and .zcash-params/testnet are there and OK. Look in those folders to make sure the proving key is 910 MB and the verifying key is 1.4 kb. I mean, the error message is saying it was not able to load one of those files.

Aha! I looked in ~/.zcash-params/regtest
and the only files that are there are

z7-proving.key z7-verifying.key

How do I update them to:

z9-proving.key z9-verifying.key

Thanks for bearing with me.

Since I do not know why youā€™re missing the z9 files, I would delete .zcash/testnet3, zcash, and .zcash-params, then start over following the alpha guide.

I assume I need to backup only one wallet rather than each wallet on all instances, correct?

Thatā€™s right. If you are using the same wallet.dat on all instances, and you have that wallet.dat file backed up, youā€™ll be fine.

When I start adding to the wallet, do I need to backup the wallet again?

If you add new keys to the keypool, then yes ā€“ you will need to make another backup of the wallet. But as long as you havenā€™t used up all 30,000 keys you donā€™t have to make another backup.

If I lose some or all of my AWS instances (say I delete them all after a night of partying) a. I wonā€™t have lost my previously mined zcash because of my backed up wallet, correct?

Thatā€™s right. Your coins arenā€™t stored in the AWS instances. They are stored on the public blockchain. Those coins are there forever. As long as you have the private keys stored somewhere (ie: in your backed up wallet.dat) youā€™ll have access to your coins.

b. Will I have lost my unconfirmed balances on each instance?

No. Unconfirmed balances/txns are the same as any other transactions. The rest of the network will process them whether or not your machines are online.

Iā€™m following the guide but run into build problems:
git checkout v0.11.2.z9 ./zcutil/fetch-params.sh
$ ./zcutil/build.sh -j4

Maching Iā€™m building on:
uname -amnprsv Linux ubuntu-512mb-ams2-01 4.4.0-36-generic #55-Ubuntu SMP Thu Aug 11 18:01:55 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial

The error:
ā€¦failed updating 1 targetā€¦
ā€¦skipped 6 targetsā€¦
ā€¦updated 97 targetsā€¦
funcs.mk:238: recipe for target ā€˜/root/zcash/depends/work/build/x86_64-unknown-linux-gnu/boost/1_57_0-bb538aabaee/./.stamp_builtā€™ failed
make: *** [/root/zcash/depends/work/build/x86_64-unknown-linux-gnu/boost/1_57_0-bb538aabaee/./.stamp_built] Error 1
make: Leaving directory ā€˜/root/zcash/dependsā€™

Ok, resolved. Not enough memory. Had to create swapfile.

I also got my miner up and running on the test net!
@Austin-Williams, @daira, @zawy and @Shawn thanks so much for your help!

2 Likes

What is the best way to terminate an EC2 instance mining with zcashd? Do we need to run zcash-cli stop before terminating. If we donā€™t, do we risk corrupting our wallet?

So far, Iā€™ve been simply setting my aws Instance State to ā€˜Terminateā€™ and this does not seem to harm my wallet. But Iā€™m not sure if I should be shutting down in a more controlled way. What is the recommended aws ec2 instance way to terminate?

1 Like

As long as you have your wallet.dat file backed up, it doesnā€™t matter at all how you shutdown your server/miner.