Skip to content

Commit

Permalink
Merge pull request #438 from trilitech/staging
Browse files Browse the repository at this point in the history
Publish updated DAL baker tutorial to main
  • Loading branch information
timothymcmackin authored Aug 28, 2024
2 parents 7569fa3 + 6d44666 commit d408999
Show file tree
Hide file tree
Showing 14 changed files with 391 additions and 177 deletions.
2 changes: 1 addition & 1 deletion docs/tutorials.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ These tutorials are intended for developers who are familiar with Tezos and want
/>

<TutorialCard
title="Join the DAL as a Weeklynet baker"
title="Join the DAL as a baker in 5 steps"
emoji="🍞"
href="/tutorials/join-dal-baker"
description="Learn how to participate to the DAL as a baker"
Expand Down
46 changes: 27 additions & 19 deletions docs/tutorials/join-dal-baker.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,55 @@
---
title: Join the DAL as a baker, in 5 steps
authors: Tezos core developers
title: Join the DAL as a baker in 5 steps
authors: Tezos core developers, Tim McMackin
last_update:
date: 10 June 2024
date: 19 August 2024
---

The Tezos data availability layer (DAL) is a key component for the scalability of Tezos.
In a nutshell, the DAL increases the data bandwidth available for Tezos Smart Rollups by providing a peer-to-peer network that they can use to fetch data without compromising security.

When users and dApps submit data to the DAL, layer 1 nodes attest that it is available and DAL nodes distribute it to Smart Rollup nodes, which can store the data and use it.

Just like layer 1, Tezos bakers ensure the security of the DAL.
Bakers not only produce blocks but also attest that other bakers' blocks are valid and properly published on layer 1.
In the same way, bakers attest that data published to the DAL is available.
In the current implementation of the DAL, bakers do not receive extra incentives for attesting DAL data, but they might in the future.
For now, bakers can join the DAL without risking any reward loss, ensuring a smooth transition.

This incentive-free version of the DAL is currently available on the Weeklynet test network.
In this tutorial you learn how to join Weeklynet as a baker and attest the publication of data on the DAL network.
In this tutorial, you learn how to join Ghostnet as a baker and attest the publication of data on the DAL network on Ghostnet.
The steps for participating on any other network, including Tezos Mainnet, are similar.

:::note Attestation rights delay

This tutorial includes setting up a baker to attest that data is available on the DAL.
Depending on the network, it takes time for bakers to get attestation rights.
The delay on Ghostnet is about 3.5 days, so in this tutorial you do setup work, wait 3.5 days for attestation rights, and verify that your DAL node and baker are working properly.

If you don't want to wait that long, you can use Weeklynet, where the delay is about an hour.
However, to use Weeklynet, you must use a specific version of the Octez suite.
You must also be aware that the network completely resets and moves to a new version of the Octez suite every Wednesday.
For information about using Weeklynet, see [Testing on sandboxes and testnets](../developing/testnets).

:::

## Tutorial diagram

In this tutorial, you set up the Octez client and several Octez daemons, including a layer 1 node, a baker, and a DAL baking node.
In this tutorial, you set up the Octez client and several Octez daemons, including a layer 1 node, a baker, and a DAL node.
The following diagram shows these daemons with a blue background:

![A diagram of the DAL architecture, with the daemons that you create in this tutorial highlighted](/img/tutorials/join-dal-baker-overview.png)
<!-- https://lucid.app/lucidchart/b6b076ec-194c-4011-8e20-fa348bb983f3/edit?page=0_0# -->

## Prerequisites

This tutorial requires a cloud-based computer or a computer that stays running constantly.

## References

- For an overview of the DAL, see [Data Availability Layer](../architecture/data-availability-layer).
- For an introduction to how the DAL works, see the tutorial [Implement a file archive with the DAL and a Smart Rollup](./build-files-archive-with-dal).
- For technical information about the DAL, see [Data-Availability Layer](https://tezos.gitlab.io/shell/dal.html) in the Octez documentation.

:::warning
This tutorial uses a very simple setup running all required daemons on the same machine. In a production environment, we advise against running a DAL attester node under the same IP address than a baker's node because the DAL node may leak the IP address and ease DOS attacks on the baker. See also [the DAL documentation page on baking](https://tezos.gitlab.io/shell/dal_bakers.html).
:::

:::warning
The UX of the DAL components will be subject to changes with the feedback from the testers following this tutorial, so this tutorial will be updated accordingly. Feel free to file issues if it's not up-to-date.
:::
## Getting started

- [Step 1: Get a Weeklynet-compatible Octez version](./join-dal-baker/get-octez)
- [Step 2: Run an Octez node on Weeklynet](./join-dal-baker/run-node)
- [Step 3: Set up a baker account on Weeklynet](./join-dal-baker/prepare-account)
- [Step 4: Run an Octez DAL node on Weeklynet](./join-dal-baker/run-dal-node)
- [Step 5: Run an Octez baking daemon on Weeklynet](./join-dal-baker/run-baker)
- [Conclusion](./join-dal-baker/conclusion)
To get started, go to [Step 1: Run an Octez node](./join-dal-baker/run-node).
12 changes: 10 additions & 2 deletions docs/tutorials/join-dal-baker/conclusion.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
title: "Conclusion"
authors: Tezos core developers
last_update:
date: 23 January 2024
date: 13 August 2024
---

In this tutorial we have gone through all the steps needed to participate in the Weeklynet test network as a baker and DAL attester. We could further improve the setup by defining system services so that the daemons are automatically launched when the machine starts or when the network restarts on Wednesday. We could also plug a monitoring solution such as the Prometheus + Grafana combo; a Grafana dashboard template for DAL nodes is available in Grafazos. The interactions between our baker and the Weeklynet chain can be observed on the Explorus block explorer which is aware of the DAL and can in particular display which DAL slots are being used at each level.
In this tutorial you have gone through all the steps needed to participate as a baker and DAL node.
The steps for participating on any other network, including Tezos Mainnet, are similar, but other networks have different parameters.
For example, the attestation delay on Mainnet is 2 weeks.

You could further improve the setup by defining system services so that the daemons are automatically launched when the machine starts.
You could also plug a monitoring solution such as the Prometheus + Grafana combo; a Grafana dashboard template for DAL nodes is available in Grafazos.
The interactions between your baker and the chain can be observed on the Explorus block explorer which is aware of the DAL and can in particular display which DAL slots are being used at each level.

As a next step, you can create a Smart Rollup that uses DAL data in the tutorial [Implement a file archive with the DAL and a Smart Rollup](../build-files-archive-with-dal).
35 changes: 0 additions & 35 deletions docs/tutorials/join-dal-baker/get-octez.md

This file was deleted.

96 changes: 36 additions & 60 deletions docs/tutorials/join-dal-baker/prepare-account.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
---
title: "Step 3: Set up a baker account on Weeklynet"
authors: Tezos core developers
title: "Step 2: Set up a baker account"
authors: Tezos core developers, Tim McMackin
last_update:
date: 6 March 2024
date: 19 August 2024
---

Our baker needs a user account consisting of a pair of keys and an address.
In this section, you use the Octez client to create an account and register it as a delegate.
The baker needs a user account that stakes tez.
In this section, you use the Octez client to create an account, register it as a delegate, and stake tez with it.

1. Open a new terminal window in the same environment.
If you are using a Docker container, you can enter the container with the `docker exec` command, as in `docker exec -it my-image /bin/sh`.
To get the name of the Docker container, you run the `docker ps` command.
1. Connect the Octez client to your node by running this command:

```bash
octez-client -E http://localhost:8732 config update
```

If you see an error that says "Failed to acquire the protocol version from the node," ensure that your node is running and verify that the host name and port in the `config update` command are correct.

1. Make sure that the installation of the Octez client is using your node by running this command:

```bash
octez-client bootstrapped
```

The client waits until it is connected and the node is running at the current level.
When it is connected and the node is updated, the command prints the message `Node is bootstrapped`.
The time it takes depends on how many blocks the node must retrieve to catch up from the snapshot to the current head block.

1. Optional: Hide the Octez client's network warning message by running this command:

Expand All @@ -21,7 +35,7 @@ To get the name of the Docker container, you run the `docker ps` command.
This command suppresses the message that your instance of the Octez client is not using Mainnet.

1. Create or import an account in the Octez client.
The simplest way to get an account that works with Weeklynet is to use the Octez client to randomly generate an account.
The simplest way to get an account is to use the Octez client to randomly generate an account.
This command creates an account and associates it with the `my_baker` alias:

```bash
Expand All @@ -34,81 +48,43 @@ This command creates an account and associates it with the `my_baker` alias:
octez-client show address my_baker
```

1. Record this address in a shell variable so you can use it for commands that cannot get addresses by their Octez client aliases:

```bash
MY_BAKER="$(octez-client show address my_baker | head -n 1 | cut -d ' ' -f 2)"
```

At this point, the balance of the `my_baker` account is still zero, as you can see by running this command:

```bash
octez-client get balance for my_baker
```

If you get an error on this command, your local node isn't ready yet.
Until the node has finished bootstrapping, pass the public RPC endpoint for Weeklynet in the `--endpoint` argument, as in this example:

```bash
octez-client --endpoint https://rpc.weeklynet-2024-01-17.teztnets.com get balance for my_baker
```

Don't set the client endpoint to the public node permanently because it should use your local node whenever possible.
For bakers, it's important to set the Octez client to use their node rather than a public node because the baker daemon uses the client configuration and the baker daemon should use the local node.
1. Get at least 6,000 tez from the Ghostnet faucet.

1. Get some tez from the Weeklynet faucet.
The account must stake tez to get consensus and DAL rights.
To get tez, use the Ghostnet faucet linked from https://teztnets.com/ghostnet-about to send tez to the baker account.

In order to get some consensus and DAL rights, we need to put some tez in the account. Fortunately, getting free testnet tez is easy thanks to the testnet faucet. To use it, we need to enter the generated address in the Weeklynet faucet linked from https://teztnets.com/weeklynet-about. We need at least 6k tez for running a baker but the more tez we have the more rights we will get and the shorter we will have to wait to produce blocks and attestations. That being said, baking with too much stake prevents us from leaving the network without disturbing or even halting it so to avoid breaking the network for all other testers let's not be too greedy. 50k tez is enough to get enough rights to easily check if our baker behaves as expected while not disturbing the network too much when our baker stops operating.
Running a baker requires staking at least 6,000 tez, but the more tez it stakes, the more rights it gets and the less time it has to wait to produce blocks and make attestations.

1. Verify that the faucet sent the tez to the account with the same `get balance` command:

```bash
octez-client get balance for my_baker
```

At this point, the `my_baker` account owns enough stake to bake but has still no consensus or DAL rights because we haven't declared our intention to become a baker to the Tezos protocol.
If the balance still shows 0, the local node may not be ready yet.
In this case you can temporarily use the public RPC endpoint.

When the account receives its tez, it owns enough stake to bake but has still no consensus or DAL rights because it has not declared its intention to become a baker.

1. Register your account as a delegate by running the following command:

```bash
octez-client register key my_baker as delegate
```

Again, pass the `--endpoint` argument if your node has not finished bootstrapping.

1. Stake the tez, saving a small amount for transaction fees.
For example, if your account has 50k tez, stake 49990 tez by running this command:

```bash
octez-client stake 49990 for my_baker
```

Seven cycles later (about 1h40 on Weeklynet), our baker will start receiving rights. To see for instance its consensus attestation rights in the current cycle, we can use the following RPC call:

```bash
octez-client rpc get /chains/main/blocks/head/helpers/attestation_rights\?delegate="$MY_BAKER"
```

When your baker has attestation rights, the previous command returns information about them, as in this example:

```json
[ { "level": 9484,
"delegates":
[ { "delegate": "tz1Zs6zjxtLxmff51tK2AVgvm4PNmdNhLcHE",
"first_slot": 280, "attestation_power": 58,
"consensus_key": "tz1Zs6zjxtLxmff51tK2AVgvm4PNmdNhLcHE" } ] } ]
```

To see the DAL attestation rights of all bakers, we can use the following RPC call:
1. Stake at least 6,000 tez, saving a small amount for transaction fees,by running this command:

```bash
octez-client rpc get /chains/main/blocks/head/context/dal/shards
octez-client stake 6000 for my_baker
```

This command returns an array of DAL attestation rights. The 2048 shards which are expected to be attested at this level are shared between active bakers proportionally to their stake. Each baker is assigned a slice of shard indices represented in the output of this command by a pair consisting of the first index and the length of the slice. So to check if some rights were assigned to us we can filter the array to our baker by running this command:

```bash
octez-client rpc get /chains/main/blocks/head/context/dal/shards | grep "$MY_BAKER"
```
Now the account has staked enough tez to earn the right to make attestations, including attestations that data is available on the DAL.
However, it does not receive these rights until the baking daemon is running and a certain amount of time has passed.

When attestation rights are assigned to your baker, continue to [Step 4: Run an Octez DAL node on Weeklynet](./run-dal-node.md).
While you wait for attestation rights, continue to [Step 3: Run an Octez DAL node](./run-dal-node).
Loading

0 comments on commit d408999

Please sign in to comment.