Secure Basic Infrastructure

In this tutorial, we’ll present a method to bake on the testnet as a trial. Baking on the mainnet is quite similar except that you don’t need to activate faucet accounts. Another trial alternative is to setup a private network and start baking on it. This method is quite simple, but more secure compared to the “unsafe” one, as the private key is managed by a hardware wallet, like a Ledger Nano S.

Prerequisites

We’ll assume that you already checked out the testnet branch of the gitlab repository and built the binaries. We assume you are running a testnet node which stores its state in $HOME/dune-testnet-2019-07-08, and with RPC port 8733 on the local loop 127.0.0.1. You might have to specify -A <addr> -P <port> after dune-client to specify different parameters before running some actions. 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.

You’ll need a Ledger Nano S on which you installed the Dune Ledger App. Alternatively, you may use Tezos baking App, which is still compatible with Dune Network for the moment. You may want to read this tutorial to prepare your ledger device.

Importing an Address From a Ledger

First connect your Ledger Nano S to your computer, enter your PIN code and start the Dune (or Tezos Baking) Ledger App. Once this is done, you can use the following command to list your ledger:

$ dune-client list connected ledgers
...
To use keys at BIP32 path m/44'/1729'/0'/0' (default Dune key path), use one
of:
  ./dune-client import secret key ledger_my_baker "ledger://previous-markhor-gleeful-ant/ed25519/0h/0h"
  ./dune-client import secret key ledger_my_baker "ledger://previous-markhor-gleeful-ant/secp256k1/0h/0h"
  ./dune-client import secret key ledger_my_baker "ledger://previous-markhor-gleeful-ant/P-256/0h/0h"

Now you can import a key from the ledger using, for instance:

$ ./dune-client import secret key ledger_my_baker "ledger://previous-markhor-gleeful-ant/ed25519/0h/0h" --force
...
Please validate (and write down) the public key hash displayed on the Ledger,
it should be equal
to `dn1RrJrx1y7hMYEJFWjZ3zDE5uS6CtEnnAS1`:

You may want to use option --force if a key with alias ledger_my_baker already exists. Confirm on the ledger device to finish importing the key.

Note that, if you are setting up a baker for the mainnet you probably already have your $DUNs on the ledger. In this case, you can directly go to the next section below to register your address as a delegate. If your are on testnet or private network, we’ll first send some coins to ledger_my_baker (there are different solutions for private networks).

We need to transfer some coins to this address to have rolls. On testnet, you should first download a faucet account from the address: https://faucet.dune.network/. Assuming the downloaded faucet account is dn1VR3s5M1ct6iGftzJEzKTexyxH5s1PA5sW.json, you can activate the account on the testnet as follows (we call the new account my-faucet):

$ dune-client -A 127.0.0.1 -P 8733 activate account my-faucet with <some/prefix/path/>dn1VR3s5M1ct6iGftzJEzKTexyxH5s1PA5sW.json
[...]
$ dune-client get balance for my-faucet
37888.263386 đ

Once the activation is done, we can transfer some of these coins to our baker’s address:

$ dune-client -A 127.0.0.1 -P 8733 transfer 37800 from my-faucet to ledger_my_baker --burn-cap 0.257
[...]

Note that we had to increase the burn cap if the ledger_my_baker received no transactions before this transfer.

Register The Address as a Delegate

The next step is to register our baker’s address as a baking account. This is done with the following command:

$ dune-client -A 127.0.0.1 -P 8733 register key ledger_my_baker as delegate

Our baker has 3 rolls. Once the registration is done, we should wait 7 cycles for our baker to receive baking/endorsements opportunities on the testnet or mainnet (~20 days on the mainnet, ~10 days on the testnet, it depends on protocol parameters for a private network).

Setting-up the Ledger to Bake

Dune Ledger App’s default mode is wallet. If you want to use it to bake, you need to switch it to baking mode mode first. This can be done with the following command:

$ dune-client dune ledger becomes baking ledger_my_baker

The next step is to configure the ledger device to bake for your key ledger_my_baker. For that, just run the following command:

$ dune-client setup ledger to bake for ledger_user --main-chain-id <chain-ID>

where <chain-ID> in the ID of the chain you would like to bake on. Chain (or Network) ID of the mainnet is NetXwhYbWGa82xo. At the time of writting this doc, testnet’s Network ID is NetXJr1E3KSpaPR. More generally, the chain ID can be retrieved with the following RPC: /chains/main/blocks/head/header

Start Different Binaries

Before you get baking/endorsements opportunities, we can already start different binaries. Normally, you would start all daemons in background with a logging file using, eg., screen or nohup commands.

First, the command to start the baker is of the form:

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

Then, the endorser:

$ dune-endorser-004-Pt24m4xi run ledger_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 them 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.