Baking/Validating

Dune’s blockchain uses LDPOS (Liquid Delegatable Proof Of Stake) to perform its consensus (inherited from Tezos’ Emmy+ consensus algorithm). Dune does not have a static list of validators (called bakers), but instead, anybody with enough tokens can start its own validator.

Here are a few tutorials on how to setup a baker for Dune.

Overview and Terminology

To setup a baker, you need to understand a few things and terms on Dune. The first one is about stake: to be able to bake, you will need to have rolls: one roll is 10,000 DUN. The Change, the DUNs that don’t make a roll, are not taken into account in evaluating the Staking Balance.

Other stakers can delegate their DUNs to your baker. Cumulating them will allow you to have more rolls. However, when validating, you will need to put some of your stake in deposit. When validating, you will also receive rewards and fees. All of them (deposits, rewards and fees) are called the frozen balance, which is frozen for a given number of cycles. A cycle is currently 4096 blocks, and the freeze lasts for 7 cycles currently.

To become a baker, you must declare yourself as a delegate with a client. snapshots of all roll owners are taken a few times during every cycle, and one of them is chosen to decide who will bake, 7 cycles later. It means that, once you have declared yourself a baker, you will have to wait for 7 cycles before having the opportunity to bake.

A baker/validator performs 3 main tasks:

  • Baking: creating a new block with the new operations of users

  • Endorsing: each block can be endorsed by 32 validators

  • Accusing: if another baker double-bakes (creates two blocks at the same level) or double-endorses (creates two endorsements for two different blocks at the same level), a baker can send an evidence and earn some parts of its rewards

These tasks are performed by 3 different programs. The baker itself must be run on the same computer as the Dune node.

In the following scenarii, we will suppose that a node is running in $HOME/dune-testnet-2019-07-08, with RPC port 8733 on the local loop 127.0.0.1 (either on Testnet for testing or Mainnet for real deployment). You might have to specify -A <addr> -P <port> after dune-client to specify different parameters. We also suppose that the current protocol is 004-Pt24m4xi, you might have to change the names of the commands to accomodate with the current protocol.

Baking with an encrypted key on disk

This is the most simple scenario, but also the least secure, as your cryptographic key is stored on the computer.

You will need a local key with some tokens on it:

$ dune-client gen keys my-baker
Key my-baker registered

Let’s get more information on this key:

$ dune-client list known addresses
my-baker: dn1VR3s5M1ct6iGftzJEzKTexyxH5s1PA5sW (unencrypted sk known)

$ dune-client show address my-baker
Hash: dn1VR3s5M1ct6iGftzJEzKTexyxH5s1PA5sW
Public Key: edpkujfZ7WcmVGe9rUUm9hDMT6uSnwiT1wYdhhUGFy9aVGDudd4b9m

We need some rolls on this key. You will need to transfer some tokens on it. If we are on the Testnet, we can use a faucet from https://faucet.tzalpha.net/. We download a file tz1VnXdZpCLnJeF5kHng6UMxzfr2WgsbUZFw.json, that we can use to create an account my-faucet:

$ dune-client activate account my-faucet with tz1VnXdZpCLnJeF5kHng6UMxzfr2WgsbUZFw.json
[...]
$ dune-client get balance for my-faucet
37888.263386 

We can now transfer these tokens to our baker:

$ dune-client transfer 37888 from my-faucet to my-baker --burn-cap 0.257
[...]

Note that we had to increase the burn cap because the my-baker account was empty before this transfer.

The next step is to declare our account as a baking account:

$ dune-client register key my-baker as delegate $HOME/dune-testnet-2019-07-08

We can now wait for 7 cycles for our baker to be able to receive baking opportunities. yet, we can already launch the daemons. First, the baker:

$ dune-baker-004-Pt24m4xi run with local node $HOME/dune-testnet-2019-07-08 my-baker
Waiting for the node to be synchronized with its peers...
Node synchronized.
Baker started.

Normally, you would start all daemons in background with a logging file. Now, the endorser:

$ dune-endorser-004-Pt24m4xi run my-baker
Waiting for the node to be synchronized with its peers...
Node synchronized.
Endorser started.

Finally, we can start the accuser:

$ dune-accuser-004-Pt24m4xi run
Waiting for the node to be synchronized with its peers...
Node synchronized.
Accuser started.

Note that the accuser does not take the key as argument: it will send evidences without caring about which baker is going to include the evidence in its block. Indeed, the accuser will not receive any reward. Running a few accusers is nice, but there is no need for all bakers to run one.

Baking with a Ledger Nano S

First, you will need to setup a Ledger Nano S. Check the section.

Ledger on the Same Computer

This is a more secure scenario, as the key is stored in a hardware wallet, here a Ledger Nano S. Yet, it requires to have everything on the same computer.

Ledger on a Remote Computer

This is the most secure scenario: the key is stored in a hardware wallet, on a diffent computer from the one running the validator.