> How to Bake
Preparation
Installing MavBake CLI and using it to setup your Mavryk baker is very simple. You will need the following tools:
- Spare computer or existing computer with Linux installed. The recommended requirements are provided by Nomadic Labs
- 3 CPU cores (arm64 or amd64/x86-64 architectures) – 2 are needed by the Mavkit node and 1 is needed by the Mavkit baker;
- 8GB RAM + 8GB swap (or 16GB RAM);
- 100GB SSD storage (or similar I/O performance);
- a low-latency, reliable broadband internet connection.
- Ledger Nano S Plus or Nano X hardware wallet with Mavryk Wallet & Baker apps installed. (note: it’s necessary to use Ledger Live to install the Mavryk Wallet & Baking applications; to install the latter, enable developer mode in Ledger Live settings)
Installation
Download and copy mavbake
To begin, run the script below, which will download the latest version of MavBake and copy it to your /usr/sbin directory. This script works with both x86_64 and arm64 architectures.
wget -q https://github.com/mavryk-network/mavbake/raw/main/install.sh -O /tmp/install.sh && sudo sh /tmp/install.sh
# you may be prompted for sudo password
Setup Mavryk node, signer and install mavbake dependencies
mavbake setup
# you may be prompted for sudo password
Bootstrap Mavryk node
At this stage, it’s necessary to bootstrap your node, meaning to download a copy of the blockchain so you don’t have to synchronize block-by-block, which takes hours at best.
mavbake bootstrap-node <url> <block_hash>
# example:
mavbake bootstrap-node https://snapshots.mavryk.network/rolling BLVo8bPM1MU2h6dnKkxHkRmXcEigQbtLd9XwNrCHbKEwERSgZDy
You can replace
euabove withusorasiaif you prefer to use a different mirror closer to you.
Get the block hash and block level from the snapshot provider’s website: https://snapshots.mavryk.network/rolling.html
The
<block_hash>argument is optional but encouraged. If you don’t want to borther with this protection, use the second method below which will also be faster.
Verify the hash/checksum provided by the snapshot provider to ensure the snapshot is valid. You can find the correct hashes for all blocks on Mavryk blockchain explorer: https://nexus.mavryk.org/explorer
Simply search for the block level in the search field and verify the hash of the block matches the hash provided by the snapshot provider.
Start Mavryk node
After importing the snapshot, you need to start your node and wait until it’s fully synchronized before importing your Ledger key.
mavbake start
After starting the node, run the following command over and over every few minutes and monitor the “level” displayed.
mavbake info
Level refers to the latest block number on mainnet. Navigate to https://nexus.mavryk.org and observe the latest block. Once the level in your command matches the latest block on your blockchain explorer, your node is in full sync and you can keep following the steps below.
https://nexus.mavryk.org provides Basenet and Testnet block explorers as well. Make sure you’re looking at the right explorer.
Import Ledger key or soft key and register as baker
Now that your node is in full sync, you can proceed with the most important part: (1) your baker parameters import into your baker node and (2) submit your baker registration on the blockchain.
You have the option to use the secure Ledger hardware wallet or simply use a local, unencrypted software key (a.k.a. soft key). The secure Ledger hardware wallet is the recommended option for mainnet baking.
You will have to first fund your baker address with enough mav (6000 minimum) to cover the bond requirement. You can do this by sending mav from your main account or exchange to the baker address.
(Option 1 - RECOMMENDED) Import Ledger key to MavBake signer
mavbake setup-ledger --platform --import-key --authorize --hwm 1
# If you have a custom derivation path, you can specify it as shown: (`--import-key="ed25519/0h/0h"`; change ed to bip as needed for your individual needs; the default is ed25519/0h/0h which works just fine)
# `--hwm 1` works great if you're setting up for the first time. If you're setting up a device that's been used to bake before, you want to change this (`1`) to the current block height on the blockchain for your safety.
# If you're importing for the second time after already trying again but failing, you can use `--force` to force the import.
Once imported, you can see your baker address by running
mavbake info
The ledger will ask you twice to confirm this operation. Make sure the baker you see on the ledger screen matches the one you want to use. If you don’t have this information yet, don’t worry. To get the address of the ledger that’s used by default simply go to https://kukai.app and login with ledger, accepting the default derivation path.
BLS (i.e. bip) signatures are designed to offer greater flexibility and scalability for certain applications compared to the default ED25519 algorithm.
Putting the baker on a non-default derivation path provides an additional layer of security for your baker at the cost of extra complexity for you. Make sure your setup is clearly documented for your own records.
If your device was used to bake before it might have a “high watermark” aka HWM. If you try to use this device on a testnet, it will not work because the block height on test networks usually starts with 1 while mainnet is up to over a couple of million blocks at the time of writing. If you used to bake on mainnet with the same ledger as you’re trying to use now but it’s been a while, it’s highly recommended to change the 1 above to the current block on the network that will be used for the device going forward.
The watermark is simply a record of the lack block number your ledger helped to bake or attest. If you’re setting up a brand new device that’s not been used for baking before, there is no need to alter the default command above.
Always make sure you’re not accidentally going to double bake by using your production ledger and/or setup to bake on a testnet. It’s really easy to make this mistake and the only thing preventing it are your personal standard operating procedures, the documentation you keep, and the care you take when setting up your baker.
To double bake or attest due to baker setup error means having 2 different bakers with the same key on the same network. This is a serious offense and can lead to loss of bond and other penalties. Always double-check your setup and make sure you’re not accidentally double baking or attesting.
(Option 2 - INSECURE) Import Soft key to MavBake signer
First, generate the baker key for MavBake signer:
mavbake signer - gen keys baker
Make sure to backup your key in a secure location. You can get the key by running the following command:
cat /mavpay/signer/data/.mavryk-signer/secret_keys
Then, import the baker public key hash to MavBake node:
Get the mv1-mv3 address which is the hashed public key of the baker key:
cat /mavpay/signer/data/.mavryk-signer/public_key_hashs
Import the hashed key to the MavBake node:
mavbake node client import secret key baker http://127.0.0.1:20090/mv1WyiGYVL8D6CE81AYnQseALR6zh8v3J3Dr
Change the mv1WyiGYVL8D6CE81AYnQseALR6zh8v3J3Dr to the hashed key you got from the previous command.
Register Ledger key as baker on the blockchain
For this step your node level must be synced with the latest block on the blockchain explorer. You must also temporarily open your Ledger Mavryk Wallet app to register your key as a baker (note: as well as when voting). For all other baker operations, you must use the Mavryk Baking app.
mavbake register-key
Registering is not necessary if this is already an active baker ledger which is being setup on some kind of failover machine or in a situation where it has not been over 2 weeks of baking inactivity.
Registering applies to new bakers and to inactive bakers. If you’re setting up a new baker, you must register it. If you’re setting up a baker that’s been inactive for over 2 weeks, you must register it. If you’re setting up a baker that’s been inactive for less than 2 weeks, you don’t need to register it. The best way to find out if you need to register your baker again is to look into your baking rights schedule and see if they stopped coming in. If they did, you need to register your baker again.
Any questions/comments/concerns? Please contact the Mavryk Dynamics team on Telegram