How Local and Delegated Harvesting Works


#1

read

When a block is created, all included transaction fees are harvested. However, there are two different methods for harvesting, thus resulting in potential confusion. In this tutorial we will describe how each method works and the differences in implementation that allow them to be used in differing ways.

What is harvesting?

Harvesting in NEM is the process of generating blocks (which contain transactions) and earning the transaction fees in that block as a reward for the contributed work. The POI (Proof-of-Importance) algorithm determines who is allowed to generate a block (or more precisely: which generated block is considered as valid). To be able to harvest, the account needs a vested(!) balance of at least 10,000 XEM.

You can compare harvesting to mining in Bitcoin, although with harvesting you don't create new XEM coins, but only earn the transaction fees.

Default method: local harvesting

If you didn't activate delegated harvesting explicitly, the default method will be used which is local harvesting. This method works only while your computer is running and as long as you are not using a remote NIS. (In this tutorial we will not explain in which cases it can be useful to use a remote NIS and how this can be done. Please take a look at other tutorials, if you are interested.)

When you start local harvesting for an account, the private key of the account is passed to your locally running NIS (NEM Infrastructure Server). This is needed because NIS needs to sign generated blocks with your private key. The private key will not leave your computer at any time, nor will it be broadcasted over the internet.

Alternative method: delegated harvesting

If you are connected to a remotely located NIS ("remote NIS") and want to start harvesting, you cannot do this with the default method (local harvesting), because the NEM software will block this. The reason for blocking is simple: Your account's private key would be sent to the remote NIS (remember: it is needed to sign generated blocks) and this would be a serious security issue, because if somebody got ahold of your private key, that person would gain full control over your funds.

The solution is easy: Activate delegated harvesting before you start harvesting on a remote NIS. This step will initiate a block chain transaction and therefore costs a fee of 6 XEM. The activation has to be done only once for an account. After 360 confirmations (approx. 6 hours) the activation is complete and you can start harvesting. Once a remote NIS started harvesting, you can even shut down the NEM software on your local computer - the remote NIS will continue to harvest for your account as long as it is being operated.

Note: If you activated delegated harvesting for an account, this doesn't mean you can only harvest on a remote NIS. It is still possible to harvest on your local NIS if you wish to do that. Note 2: You don't have to trust the remote NIS you are using. If it is acting fraudulent or it got hacked, your funds are not at risk.

For a detailed description how to start delegated harvesting, please see here.

The 'magic' behind delegated harvesting

Ok, you wanted to hear it: If you activate delegated harvesting, NCC (NEM Community Client) initiates an "importance transfer" transaction that is processed on the blockchain. This creates a mapping for the importance score of the account to an empty "proxy" account (balance: 0 XEM). When the activation of delegated harvesting has completed and you start harvesting on a remote NIS, the private key of the "proxy" account is then passed to the remote NIS to sign generated blocks, but the fees you earn are still directly sent to the original account. So you don't even have to trust the remote NIS. With the private key of the "proxy" account it is not possible to transfer your importance score to any other account, and because it has a balance of zero, no funds can be stolen either. Isn't that beautiful?

Conclusion

Practically, what this means is that users can put their main account into an offline storage and use a proxy account to harvest on behalf of the offline storage account. You can even give your proxy account's private key to any random individual and ask them to use it to harvest on your behalf without risking your funds. For more information about how to connect to remote servers when using delegated harvesting please visit the tutorial on connecting to a remote NIS.

Local harvesting + No setup required - just click "Start local harvesting" - Not possible if you are using a remote NIS - No "offline harvesting", therefore higher costs for electricity if you use a regular computer

Delegated harvesting + Always harvesting - even if your computer is turned off (remote NIS needed to harvest on your behalf) + Lower costs for electricity (if remote NIS runs on a VPS or micro computer like Raspberry Pi 2, Cubieboard 3 or similar) - Setup required (activation takes approx. 6 hours and costs a fee of 6 XEM)

Note: Your harvesting chance will be the same for both methods.

In conclusion, here is a little bonus tutorial material.

Here is a community made video tutorial (thanks PunkRock).

Please give it a watch.


This is a companion discussion topic for the original entry at http://blog.nem.io/how-local-and-delegated-harvesting-works/

Local Harvesting or Delegated?
#2

Two questions:

  1. Using the lightwallet (e.g. connecting to any supernode) I can’t harvest, can I? (assume vested balance >10k XEM).
  2. To harvest using local NIS/NCC installation I need to open ports on the LAN NAT Router or any firewalled device can just run for it?

#3

Hi r3n3,

I just set up the Standalone version for harvesting. For your questions:

  1. I can’t use lightwallet to harvest.
  2. I use Standalone version for Mac, and use this tutorial: https://blog.nem.io/mac-installation-guide-standalone/
    But before using this tutorial, I added the firewall setting for wallet (but maybe we don’t have to do it):
    Problem opening NEM Wallet on MacBook

#4

Hi!
The video example is not available anymore.


#5

I can’t see link to any video here (maybe still to early). Can you paste here video link that doesn’t work? You can also look at @tongokongo video:


#6

Thank you for the video. So here is the text with the link that does’nt work
"In conclusion, here is a little bonus tutorial material.
Here is a community made video example (Sr. Yuba).
Please give it a watch." Those lines were at the bottom of the post on this page https://blog.nem.io/how-local-and-delegated-harvesting-works/


#7

@benjoun
Ok I see now, video was removed. I think links + tongo video above should explain you all.