Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish updated DAL baker tutorial to main #438

Merged
merged 38 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0f4c008
update DAL baker tutorial for Ghostnet
timothymcmackin Aug 12, 2024
5693bb4
Correct tutorial title
timothymcmackin Aug 13, 2024
5b1e2c5
Info about Weeklynet
timothymcmackin Aug 13, 2024
77cf334
Clarify delay on other networks
timothymcmackin Aug 13, 2024
f04dd37
Remove complex warning about running on the same machine
timothymcmackin Aug 13, 2024
eba7704
One way to do this...
timothymcmackin Aug 13, 2024
85b1f94
Remove warning about staking too much
timothymcmackin Aug 13, 2024
ac08e43
built on the Gossipsub P2P protocol.
timothymcmackin Aug 13, 2024
24c36da
Correct this reference to the next lesson
timothymcmackin Aug 13, 2024
b8de176
You do not need to leave the nodes and baker running for the entire d…
timothymcmackin Aug 13, 2024
b88dcb7
Verify that the DAL node is bootstrapped
timothymcmackin Aug 13, 2024
1a146df
The DAL node waits for the block to be finalized
timothymcmackin Aug 13, 2024
141664b
Time to bootstrapping
timothymcmackin Aug 13, 2024
00ad294
Looking up attestations on Explorus
timothymcmackin Aug 13, 2024
27109b7
Formatting
timothymcmackin Aug 13, 2024
937643f
How to debug getting marked inactive
timothymcmackin Aug 16, 2024
55178b3
Clarify bootstrapped behavior
timothymcmackin Aug 16, 2024
47c2330
Remove Docker and run on an always on server
timothymcmackin Aug 19, 2024
252f572
Link to first lesson
timothymcmackin Aug 19, 2024
a35830e
Shorten title for sidebar to keep it on one line
timothymcmackin Aug 20, 2024
cbdb910
Resize image
timothymcmackin Aug 21, 2024
d3bfcac
Delete snapshot file
timothymcmackin Aug 22, 2024
6bd7617
Skip to step 3 if you've got a baker already
timothymcmackin Aug 22, 2024
c7a0212
Clarify which branch to use
timothymcmackin Aug 22, 2024
06bdda5
Better screencap of DAL attestation
timothymcmackin Aug 22, 2024
b0e9193
Or restart an existing node
timothymcmackin Aug 22, 2024
4619f3b
Example systemctl service file
timothymcmackin Aug 22, 2024
4ec07b0
Accuser not relevant
timothymcmackin Aug 22, 2024
c0c1d9a
Handle case for existing baker
timothymcmackin Aug 22, 2024
4624148
Assume 24/7 baker
timothymcmackin Aug 22, 2024
a857a23
Rework steps for running the DAL node
timothymcmackin Aug 22, 2024
070b452
Easier way to get status
timothymcmackin Aug 22, 2024
9052e89
Remove grace period
timothymcmackin Aug 22, 2024
665d1ed
Clarify consensus_rights_delay
timothymcmackin Aug 22, 2024
9d9b768
Remove mention of "Other Octez daemons"
timothymcmackin Aug 27, 2024
1ec6bc1
--public-addr argument
timothymcmackin Aug 27, 2024
2b7e811
They need to be persistent, too
timothymcmackin Aug 27, 2024
6d44666
Merge pull request #423 from trilitech/update-dal-baker-tutorial
timothymcmackin Aug 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading