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

Update DAL file server tutorial for Ghostnet #424

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 10 additions & 10 deletions docs/tutorials/build-files-archive-with-dal.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
---
title: Implement a file archive with the DAL and a Smart Rollup
authors: 'Tezos Core Developers'
authors: Tezos Core Developers
last_update:
date: 10 June 2024
date: 10 September 2024
---

The Data Availability Layer (DAL) is a companion peer-to-peer network for the Tezos blockchain, designed to provide additional data bandwidth to Smart Rollups.
It allows users to share large amounts of data in a way that is decentralized and permissionless, because anyone can join the network and post and read data on it.

In this tutorial, you will set up a file archive that stores and retrieves files with the DAL.
This tutorial uses the Ghostnet test network, but you can use the information in it to work with other test networks or Tezos Mainnet.

In this tutorial, you set up a file archive that stores and retrieves files with the DAL.
You will learn:

- How data is organized and shared with the DAL and the reveal data channel
- How to read data from the DAL in a Smart Rollup
- How to host a DAL node
- How to publish data and files with the DAL

This tutorial uses the [Weeklynet test network](https://teztnets.com/weeklynet-about).
Weeklynet runs just like other Tezos networks like Mainnet and Ghostnet, with its own nodes, bakers, and accusers, so you don't need to run your own nodes and bakers.

See these links for more information about the DAL:

- For technical information about how the DAL works, see [Data Availability Layer](https://tezos.gitlab.io/shell/dal.html) in the Octez documentation.
Expand All @@ -29,18 +28,19 @@ See these links for more information about the DAL:
In this tutorial, you set up these components:

- The Octez client, which you use to manage a local wallet, deploy a Smart Rollup, and send data to the DAL
- A layer 1 node to provide a connection to Tezos and information about the
- A Data Availability Layer node (not to be confused with a layer 1 node), which stores data temporarily and distributes it to Smart Rollups
- A Smart Rollup that listens for data published to the DAL, retrieves it from the DAL node, and stores it locally
- A Smart Rollup node that runs your Smart Rollup

For simplicity, you do not set up a layer 1 node or a baker, which are responsible for verifying that the data is available before Smart Rollups can access it.
Instead, you use the existing nodes and bakers that are running on Weeklynet.
For simplicity, you do not set up a baker, which is responsible for verifying and attesting that the data is available before Smart Rollups can access it.
For instructions on running a layer 1 node and baker with the DAL, see the tutorial [Join the DAL as a baker, in 5 steps](/tutorials/join-dal-baker).

## Tutorial diagram

Here is a diagram that shows the components that you set up in this tutorial in a light blue background:

![A diagram of the DAL file tutorial, highlighting the Octez client, DAL node, and Smart Rollup that you create with a light blue background to distinguish them from the existing DAL nodes, layer 1 nodes, and bakers](/img/tutorials/dal-file-tutorial-setup.png)
![A diagram of the DAL file tutorial, highlighting the Octez client, DAL node, layer 1 node, and Smart Rollup that you create with a light blue background to distinguish them from the existing DAL nodes, layer 1 nodes, and bakers](/img/tutorials/dal-file-tutorial-setup.png)

<!-- https://lucid.app/lucidchart/58f5577e-91b5-4237-89c4-a8cdf81c71ad/edit -->

Expand Down Expand Up @@ -89,7 +89,7 @@ The DAL works like this:
For example, if a certificate is included in level 100 and the attestation lag is 4, bakers must attest that the data is available in level 104, along with their usual attestations that build on level 103.

If enough shards are attested in that level, the data becomes available to Smart Rollups at the end of layer 104.
If not enough shards are attested in that level, the certificate is considered bogus and the related data is dropped.
If not enough shards are attested in that level, the certificate is considered bogus, the related data is dropped, and Smart Rollups cannot access it.

1. The Smart Rollup node monitors the blocks and when it sees attested DAL data, it connects to a DAL node to request the data.
Smart Rollups must store the data if they need it because it is available on the DAL for only a short time.
Expand Down
61 changes: 34 additions & 27 deletions docs/tutorials/build-files-archive-with-dal/get-dal-params.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Part 2: Getting the DAL parameters"
authors: 'Tezos Core Developers'
authors: Tezos core developers, Tim McMackin
last_update:
date: 14 February 2024
date: 12 August 2024
---

The Data Availability Layer stores information about the available data in layer 1 blocks.
Expand All @@ -27,7 +27,7 @@ Different networks can have different DAL parameters.
Future changes to the protocol may allow the DAL to resize dynamically based on usage.

Therefore, clients must get information about the DAL before sending data to it.
In these steps, you set up a simple Smart Rollup to get the current DAL parameters and print them to the log.
Smart contracts can't access the DAL; it is intended for Smart Rollups, so in these steps you set up a simple Smart Rollup to get the current DAL parameters and print them to the log.

## Prerequisites

Expand All @@ -52,10 +52,13 @@ To get the DAL parameters, you can use built-in functions in the Tezos [Rust SDK
tezos-smart-rollup = { version = "0.2.2", features = [ "proto-alpha" ] }
```

If you set up your Docker container with a connected folder on the host machine, you can create this file in the connected folder and it will appear in the Docker container.

As a reminder, the kernel of a Smart Rollup is a WASM program.
The `proto-alpha` feature is necessary to get access to the functions specific to the DAL because they are not yet released in the main version of the Smart Rollup toolkit.

If you need a text editor inside the Docker container, you can run `sudo apk add nano` to install the [Nano text editor](https://www.nano-editor.org/).
If you set up the container with a volume, you can use any editor on your host machine to edit the file and it appears in the linked folder in the container.

1. Create a file named `src/lib.rs` to be the kernel.

Expand All @@ -74,10 +77,15 @@ To get the DAL parameters, you can use built-in functions in the Tezos [Rust SDK

This function gets the DAL parameters of the currently connected network and prints them to the log.

1. From the folder that contains the `Cargo.toml` file, run these commands to build the kernel:
1. From the folder that contains the `Cargo.toml` file, run this command to build the kernel:

```bash
cargo build --release --target wasm32-unknown-unknown
```

1. Run this command to copy the compiled kernel to the current folder:

```bash
cp target/wasm32-unknown-unknown/release/files_archive.wasm .
```

Expand All @@ -98,30 +106,27 @@ Now the Smart Rollup is ready to deploy.

## Deploying the Smart Rollup and starting a node

Follow these steps to deploy the Smart Rollup to Weeklynet and start a node:
Follow these steps to deploy the Smart Rollup to Ghostnet and start a node:

1. Run this command to deploy the Smart Rollup, replacing `$MY_ACCOUNT` with your account alias and `$ENDPOINT` with the RPC endpoint:
1. Run this command to deploy the Smart Rollup, replacing `my_wallet` with your Octez client account alias:

```bash
octez-client --endpoint ${ENDPOINT} \
originate smart rollup files_archive from ${MY_ACCOUNT} \
octez-client originate smart rollup files_archive from my_wallet \
of kind wasm_2_0_0 of type unit with kernel "$(cat installer.hex)" \
--burn-cap 2.0 --force
```

1. Start the node with this command:
1. Start the Smart Rollup node with this command:

```bash
octez-smart-rollup-node --endpoint ${ENDPOINT} \
octez-smart-rollup-node --endpoint http://127.0.0.1:8732 \
run observer for files_archive with operators \
--data-dir ./_rollup_node --log-kernel-debug
```

For simplicity, this command runs the Smart Rollup in observer mode, which does not require a stake of 10,000 tez to publish commitments.

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. Leave the node running in that terminal window and open a new terminal window in the same environment.

1. Run this command to watch the node's log:

Expand All @@ -132,11 +137,12 @@ To get the name of the Docker container, you run the `docker ps` command.
The log prints the current DAL parameters, as in this example:

```
RollupDalParameters { number_of_slots: 32, attestation_lag: 4, slot_size: 65536, page_size: 4096 }
RollupDalParameters { number_of_slots: 32, attestation_lag: 4, slot_size: 65536, page_size: 4096 }
RollupDalParameters { number_of_slots: 32, attestation_lag: 4, slot_size: 65536, page_size: 4096 }
RollupDalParameters { number_of_slots: 32, attestation_lag: 4, slot_size: 65536, page_size: 4096 }
RollupDalParameters { number_of_slots: 32, attestation_lag: 4, slot_size: 65536, page_size: 4096 }
RollupDalParameters { number_of_slots: 32, attestation_lag: 8, slot_size: 126944, page_size: 3967 }
RollupDalParameters { number_of_slots: 32, attestation_lag: 8, slot_size: 126944, page_size: 3967 }
RollupDalParameters { number_of_slots: 32, attestation_lag: 8, slot_size: 126944, page_size: 3967 }
RollupDalParameters { number_of_slots: 32, attestation_lag: 8, slot_size: 126944, page_size: 3967 }
RollupDalParameters { number_of_slots: 32, attestation_lag: 8, slot_size: 126944, page_size: 3967 }
RollupDalParameters { number_of_slots: 32, attestation_lag: 8, slot_size: 126944, page_size: 3967 }
```

These parameters are:
Expand All @@ -148,11 +154,11 @@ These parameters are:

## Setting up a deployment script

In later parts of this tutorial, you will update and redeploy the Smart Rollup multiple times.
In later parts of this tutorial, you update and redeploy the Smart Rollup multiple times.
To simplify the process, you can use this script:

```bash
#!/usr/bin/bash
#!/bin/sh

alias="${1}"

Expand All @@ -167,25 +173,26 @@ cp target/wasm32-unknown-unknown/release/files_archive.wasm .
smart-rollup-installer get-reveal-installer -P _rollup_node/wasm_2_0_0 \
-u files_archive.wasm -o installer.hex

octez-client --endpoint ${ENDPOINT} \
originate smart rollup files_archive from "${alias}" of kind wasm_2_0_0 \
octez-client originate smart rollup files_archive from "${alias}" of kind wasm_2_0_0 \
of type unit with kernel "$(cat installer.hex)" --burn-cap 2.0 --force

octez-smart-rollup-node --endpoint ${ENDPOINT} \
octez-smart-rollup-node --endpoint http://127.0.0.1:8732 \
run observer for files_archive with operators --data-dir _rollup_node \
--dal-node http://localhost:10732 --log-kernel-debug
```

To use it, save it in a file with an `sh` extension, such as `deploy_smart_rollup.sh` and give it executable permission.
To use it, save it in a file with an `sh` extension, such as `deploy_smart_rollup.sh` and give it executable permission by running `chmod +x deploy_smart_rollup.sh`.
Then you can run it any tme you update the `lib.rs` or `Cargo.toml` files to deploy a new Smart Rollup by passing your account alias, as in this example:

```bash
./deploy_smart_rollup.sh $MY_ACCOUNT
./deploy_smart_rollup.sh my_wallet
```

This script assumes that your local node is running at http://127.0.0.1:8732.

If you run this script and see an error that says that the file was not found, update the first line of the script (the shebang) to the path to your shell interpreter.
For example, if you are using the Tezos Docker image, the path is `/bin/sh`, so the first line becomes `#!/bin/sh`.
Then try the command `./deploy_smart_rollup.sh $MY_ACCOUNT` again.
For example, if you are using the Tezos Docker image, the path is `/bin/sh`, so the first line is `#!/bin/sh`.
Then try the command `./deploy_smart_rollup.sh my_wallet` again.

In the next section, you will get information about the state of slots in the DAL.
See [Part 3: Getting slot information](/tutorials/build-files-archive-with-dal/get-slot-info).
71 changes: 43 additions & 28 deletions docs/tutorials/build-files-archive-with-dal/get-slot-info.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Part 3: Getting slot information"
authors: 'Tezos Core Developers'
authors: Tezos core developers, Tim McMackin
last_update:
date: 14 February 2024
date: 11 September 2024
---

When clients send data to the DAL, they must choose which slot to put it in.
Expand All @@ -11,9 +11,8 @@ If more than one client tries to write to the same slot and a baker includes tho
The other operations fail and the clients must re-submit the data to be included in a future block.

For this reason, clients should check the status of slots to avoid conflicts.
For example, slots 0, 30, and 31 are often used for regression tests.

To see which slots are in use, you can use the Explorus indexer at https://explorus.io/dal and select Weeklynet.
To see which slots are in use, you can use the Explorus indexer at https://explorus.io/dal and select your network.
For example, this screenshot shows that slots 10 and 25 are in use:

![The Explorus indexer, showing the slots that are in use in each block](/img/tutorials/dal-explorus-slots.png)
Expand All @@ -24,16 +23,34 @@ Similarly, the protocol assigns bakers to monitor certain slots.

## Starting a DAL node

To run a DAL node, use the Octez `octez-dal-node` command and pass the slots to monitor in the `--producer-profiles` argument.
To run a DAL node, you must configure a set of cryptographic parameters for it and the use the Octez `octez-dal-node` command and pass the slots to monitor in the `--observer-profiles` argument:

Run this command to start a DAL node and monitor slot 0:
1. In a new terminal window in the Docker container, run this command to download the trusted setup scripts:

```bash
octez-dal-node run --endpoint ${ENDPOINT} \
--producer-profiles=0 --data-dir _dal_node
```
```bash
wget https://gitlab.com/tezos/tezos/-/raw/master/scripts/install_dal_trusted_setup.sh https://gitlab.com/tezos/tezos/-/raw/master/scripts/version.sh
```

1. Run this command to make the scripts executable:

```bash
chmod +x install_dal_trusted_setup.sh version.sh
```

1. Run this command to install the trusted setup:

Leave this process running in terminal window.
```bash
./install_dal_trusted_setup.sh --legacy
```

1. Run this command to start a DAL node and monitor slot 0:

```bash
octez-dal-node run --endpoint http://127.0.0.1:8732 \
--observer-profiles=0 --data-dir _dal_node
```

Leave this process running in the terminal window.

## Accessing the slot data from a Smart Rollup

Expand Down Expand Up @@ -122,14 +139,13 @@ Follow these steps to update the Smart Rollup to access information about slot 0
tezos-smart-rollup-host = { version = "0.2.2", features = [ "proto-alpha" ] }
```

1. Stop the Smart Rollup process.

1. Run the commands to build and deploy the Smart Rollup and start the node.
1. Stop the process that is running the `octez-smart-rollup-node` program.

1. Run the commands to build and deploy the Smart Rollup and start the Smart Rollup node.

If you set up the deployment script as described in [Part 2: Getting the DAL parameters](/tutorials/build-files-archive-with-dal/get-dal-params), you can run `./deploy_smart_rollup.sh $MY_ACCOUNT`.
If you set up the deployment script as described in [Part 2: Getting the DAL parameters](/tutorials/build-files-archive-with-dal/get-dal-params), you can run `./deploy_smart_rollup.sh my_wallet`, where `my_wallet` is the Octez client alias of your address.

If not, run these commands, using your account alias for `MY_ACCOUNT`:
If not, run these commands, where `my_wallet` is the Octez client alias of your address:

```bash
rm -rf _rollup_node
Expand All @@ -139,11 +155,10 @@ Follow these steps to update the Smart Rollup to access information about slot 0
smart-rollup-installer get-reveal-installer -P _rollup_node/wasm_2_0_0 \
-u files_archive.wasm -o installer.hex

octez-client --endpoint ${ENDPOINT} \
originate smart rollup files_archive from "${MY_ACCOUNT}" of kind wasm_2_0_0 \
octez-client originate smart rollup files_archive from my_wallet of kind wasm_2_0_0 \
of type unit with kernel "$(cat installer.hex)" --burn-cap 2.0 --force

octez-smart-rollup-node --endpoint ${ENDPOINT} \
octez-smart-rollup-node --endpoint http://127.0.0.1:8732 \
run observer for files_archive with operators --data-dir _rollup_node \
--dal-node http://localhost:10732 --log-kernel-debug
```
Expand All @@ -153,21 +168,21 @@ Follow these steps to update the Smart Rollup to access information about slot 0
The log shows information about slot 0, as in this example:

```
RollupDalParameters { number_of_slots: 32, attestation_lag: 4, slot_size: 65536, page_size: 4096 }
No attested slot at index 0 for level 56875
RollupDalParameters { number_of_slots: 32, attestation_lag: 8, slot_size: 126944, page_size: 3967 }
No attested slot at index 0 for level 7325504
See you in the next level
RollupDalParameters { number_of_slots: 32, attestation_lag: 4, slot_size: 65536, page_size: 4096 }
Attested slot at index 0 for level 56876: [16, 0, 0, 2, 89, 87, 0, 0, 0, 0]
RollupDalParameters { number_of_slots: 32, attestation_lag: 8, slot_size: 126944, page_size: 3967 }
No attested slot at index 0 for level 7325505
See you in the next level
RollupDalParameters { number_of_slots: 32, attestation_lag: 4, slot_size: 65536, page_size: 4096 }
No attested slot at index 0 for level 56877
RollupDalParameters { number_of_slots: 32, attestation_lag: 8, slot_size: 126944, page_size: 3967 }
No attested slot at index 0 for level 7325506
See you in the next level
```

For the first 4 Tezos blocks produced after the origination of the Smart Rollup, the kernel will report that no slot has been attested for the targeted level, _even if Explorus states the opposite_.
For the first 8 Tezos blocks produced after the origination of the Smart Rollup, the kernel will report that no slot has been attested for the targeted level, _even if Explorus states the opposite_.
This is because, as of January, 2024, a Smart Rollup cannot fetch the content of a slot published before it is originated.
This is why you must wait for 4 blocks before seeing slot page contents being
This is why you must wait for 8 blocks before seeing slot page contents being
logged.

Now that you can see the state of the slots, you can find an unused slot and publish data to it.
When you are ready, continue to [Part 3: Publishing on the DAL](/tutorials/build-files-archive-with-dal/publishing-on-the-dal).
When you are ready, continue to [Part 4: Publishing on the DAL](/tutorials/build-files-archive-with-dal/publishing-on-the-dal).
Loading
Loading