Learn and Be Curious

###Step 1 - Install geth (the Go-Ethereum command line client)

  • Run the following commands to install the latest developer version of go-ethereum
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum-qt
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo add-apt-repository -y ppa:ethereum/ethereum-dev
sudo apt-get update
sudo apt-get install ethereum

and type "Y" to install.

###Step 2 - Use geth to download the blockchain

Once you are satisfied with the generation of the Genesis block, you can load it into the clients using this command:

geth 

This command works exclusively with the ubuntu instance we suggested. You will need to say "y" to the Ethereum agreement.

This command will also "download" the full blockchain to your cloud machine before you can start mining. That is why we recommended to get at least 20+ GB of space!

Depending on how far we went into the livenet, this could take several hours (or even a full day!). Be patient :)

  • You will know that geth has finishing catching up with (i.e. downloading) the blockchain when instead of importing - say - 256 blocks at a time
Imported 256 block(s) (0 queued 0 ignored) in 449.34258ms #block_number.

...it will start importing only 1 block at a time...

Imported 1 block(s) (0 queued 0 ignored) in 3.2345ms #block_number.

Also, you can see what is the current block of the livenet by viewing the Ethereum net stats dashboard under the heading Best Block. For example, if under Best Block you have 610,002 and you reach this number in the download process, then you have finished downloading the blockchain.

  • Once this process is completed, you can type ctrl+c to exit geth

###Step 3 - Install the C++ miner (ethminer)

Let's do this, assuming you have done correctly Step 1 (i.e. you have already added the PPA repository):

sudo apt-get update
sudo apt-get install cpp-ethereum 
  • If you get an error because you have not added the PPA repositories, do:
sudo add-apt-repository -y ppa:ethereum/ethereum-qt
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install cpp-ethereum 

Note: Do not confuse Eth (the Command Line Interface client of C++ Ethereum) and EthMiner (which is the standalone miner). Both come with the installation package but they are two different things

Note 2: If you were just testing this guide with the free micro instance you have now reached a dead end, in fact you will read this message "modprobe: ERROR: could not insert 'nvidia': No such device" The system is telling you that the gpu, an nvidia graphic card, is missing. So, start over the guide and get the g2.8xlarge instance before proceeding any further.

  • Benchmark ethminer to check that your system is in order: (should give you your current hashrate, roughly 6MH/s)
ethminer -G -M 

###Step 4 - Create a new account on geth

So, once geth has finished its synchronisation with the blockchain, you have to generate a new account. This will be your "wallet", which will store the ether you mine. Your wallet will be stored in the hidden folder ~/.ethereum (in the /keystore subfolder). In the same folder you will find the files of the blockchain.

  • To generate a new account type:
geth account new
  • The system will ask for a 'Passphrase", aka a password. After the password is inputted (twice), you will be given an Address. Back it up in a notepad.

Note: If you lose your keys, you lose access to the account and its ether balance, permanently. Private keys cannot be generated from public ones (obviously) and the password you're asked for when creating the account is just a means to encrypt the private key, not regenerate it. Therefore, remember your password!!!!

  • You can view if the account generation was successful with
geth account list
  • At any time to check your Ether balance:
geth console
> web3.fromWei(eth.getBalance(eth.coinbase), "ether")
6.5
  • For more information on accounts and user interaction with accounts visit the Go-ethereum Wiki - Managing Your Accounts

Step 5 - Run the syncro between the Go and C++ clients and start mining Ether (finally!)

We're going to want both the RPC client (written in Go) and the Miner (written in C++) to run simultaneously. We also want them to run in the background so that in case we drop our SSH connection, the RPC and Miner keep running. To do that, we're going to use a tool called screen.

First lets start the Geth RPC client

screen
geth --rpc console

Then hit control-A, then hit control-D

Now lets start the miner

screen
ethminer -G --opencl-device 0

Then hit control-A then hit control-D.

Enter screen -ls and verify that you have two detached screens running in the background. You can enter back into that screen and check the output by entering screen -x ID_OF_SCREEN. You can exit out re-detach from the screen by entering control-A, then control-D

Note: If you're using the larger g2 instance with 4 GPUs (the 2.8) you may need to start ethminer 4 times, each time adding a --opencl-device <0..3> argument

So, you will need to start ethminer 3 more times with these commands:

ethminer -G --opencl-device 1
ethminer -G --opencl-device 2
ethminer -G --opencl-device 3
  • Now you should be able to see ethminer getting work packages from geth and hopefully even "mined a block" logs in geth.

Note: If you encounter any issue or bug on this part 2 of the guide, please see the notes and comments at Stephan Tual's GPU mining post

'dev > Blockchain' 카테고리의 다른 글

geth  (0) 2017.09.14
개발 모드에서 스마트 컨트랙(체인코드) 개발  (0) 2017.05.21
Hyperledger Fabric Docker 이미지 받기  (0) 2017.05.21
Go  (0) 2017.05.21