diff --git a/docs/tutorials/build-files-archive-with-dal.md b/docs/tutorials/build-files-archive-with-dal.md index c83e90379..224b36768 100644 --- a/docs/tutorials/build-files-archive-with-dal.md +++ b/docs/tutorials/build-files-archive-with-dal.md @@ -1,8 +1,8 @@ --- 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: 27 January 2025 dependencies: octez: 21.2 rust: 1.80.0 @@ -12,7 +12,9 @@ dependencies: 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 @@ -20,9 +22,6 @@ You will learn: - 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. @@ -33,18 +32,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 state of layer 1, including metadata about what data is available on the DAL - 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) @@ -93,7 +93,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. diff --git a/docs/tutorials/build-files-archive-with-dal/get-dal-params.md b/docs/tutorials/build-files-archive-with-dal/get-dal-params.md index 00d2db895..485dc3176 100644 --- a/docs/tutorials/build-files-archive-with-dal/get-dal-params.md +++ b/docs/tutorials/build-files-archive-with-dal/get-dal-params.md @@ -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: 27 Jan 2025 --- The Data Availability Layer stores information about the available data in layer 1 blocks. @@ -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 @@ -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. @@ -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 . ``` @@ -98,30 +106,33 @@ 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: + The Octez client assumes that your local node is running at http://127.0.0.1:8732. + If your node is running at a different host name or port, pass the host name and port of the node to the `--endpoint` argument. + For example, if the node is running on port 8733, include `--endpoint http://127.0.0.1:8733` in the command. + +1. Start the Smart Rollup node with this command: ```bash - octez-smart-rollup-node --endpoint ${ENDPOINT} \ - run observer for files_archive with operators \ - --data-dir ./_rollup_node --log-kernel-debug + octez-smart-rollup-node 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. + Like the `octez-client` command, this command assumes that your local node is running at http://127.0.0.1:8732. + If your node is running at a different host name or port, pass the host name and port of the node to the `--endpoint` argument. + +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: @@ -132,11 +143,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: @@ -148,11 +160,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}" @@ -167,25 +179,24 @@ 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} \ - run observer for files_archive with operators --data-dir _rollup_node \ +octez-smart-rollup-node 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 ``` 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). diff --git a/docs/tutorials/build-files-archive-with-dal/get-slot-info.md b/docs/tutorials/build-files-archive-with-dal/get-slot-info.md index d920b11f2..cd7d2fa83 100644 --- a/docs/tutorials/build-files-archive-with-dal/get-slot-info.md +++ b/docs/tutorials/build-files-archive-with-dal/get-slot-info.md @@ -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. @@ -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) @@ -24,16 +23,33 @@ 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 --observer-profiles=0 --data-dir _dal_node + ``` + +Leave this process running in the terminal window. ## Accessing the slot data from a Smart Rollup @@ -122,14 +138,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 @@ -139,12 +154,11 @@ 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} \ - run observer for files_archive with operators --data-dir _rollup_node \ + octez-smart-rollup-node run observer for files_archive \ + with operators --data-dir _rollup_node \ --dal-node http://localhost:10732 --log-kernel-debug ``` @@ -153,21 +167,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). diff --git a/docs/tutorials/build-files-archive-with-dal/publishing-on-the-dal.md b/docs/tutorials/build-files-archive-with-dal/publishing-on-the-dal.md index c9e992b78..d0a69ac5b 100644 --- a/docs/tutorials/build-files-archive-with-dal/publishing-on-the-dal.md +++ b/docs/tutorials/build-files-archive-with-dal/publishing-on-the-dal.md @@ -1,14 +1,14 @@ --- -title: "Part 3: Publishing on the DAL" -authors: 'Tezos Core Developers' +title: "Part 4: Publishing on the DAL" +authors: Tezos core developers, Tim McMackin last_update: - date: 26 January 2024 + date: 27 January 2025 --- Now that you can get information about the DAL, the next step is to publish data to it and verify that the kernel can access it. :::note Planning ahead -Before trying to run the code yourself, look at [Explorus](https://explorus.io/dal), select Weeklynet, and choose a slot that is not currently being used. +Before trying to run the code yourself, look at [Explorus](https://explorus.io/dal), select Ghostnet, and choose a slot that is not currently being used. ::: The examples in this tutorial use slot 10. @@ -18,15 +18,14 @@ Throughout the rest of this tutorial, replace slot 10 with the number of the slo When you have selected a slot that does not appear to be in use, follow these steps to restart the Smart Rollup and DAL node: -1. Stop the DAL node and restart it with a new `--producer-profiles` argument. +1. Stop the DAL node and restart it with a new `--observer-profiles` argument. For example, this command uses slot 10: ```bash - octez-dal-node run --endpoint ${ENDPOINT} \ - --producer-profiles=10 --data-dir _dal_node + octez-dal-node run --observer-profiles=10 --data-dir _dal_node ``` -1. Update the kernel to monitor that slot by updating this line: +1. In the `lib.rs` file, update the kernel to monitor that slot by updating this line: ```rust const SLOT_TO_MONITOR: u8 = 0; @@ -38,12 +37,12 @@ For example, this command uses slot 10: const SLOT_TO_MONITOR: u8 = 10; ``` -1. Run the commands to build and deploy the Smart Rollup and start the node. +1. Stop the Smart Rollup node and run the commands to build and deploy the Smart Rollup and start the node. You can use the script in [Part 2: Getting the DAL parameters](/tutorials/build-files-archive-with-dal/get-dal-params) to simplify the process. ## Publishing messages -The DAL node provides an RPC endpoint for clients to send data to be added to a slot: `POST /slot`, whose body is the contents of the slot. +The DAL node provides an RPC endpoint for clients to send data to be added to a slot: `POST /slots`, whose body is the contents of the slot. 1. Run this command to publish a message to the DAL: @@ -51,6 +50,8 @@ The DAL node provides an RPC endpoint for clients to send data to be added to a curl localhost:10732/slots --data '"Hello, world!"' -H 'Content-Type: application/json' ``` + Note that the value of the message is in double quotes because it must be a valid JSON string, as hinted by the `Content-Type` header. + This command assumes that you have not changed the default RPC server address. The command returns the certificate from the DAL node, which looks like this example: @@ -62,34 +63,39 @@ The DAL node provides an RPC endpoint for clients to send data to be added to a } ``` - Note that the value of the message is in double quotes because it must be a valid JSON string, as hinted by the `Content-Type` header. - -1. Using the values of the commitment and proof from the previous command, post the certificate to layer 1 with this command, being sure to set the slot number that you are using: +1. Using the values of the commitment and proof from the previous command, post the certificate to layer 1 with this command, being sure to set the slot number that you are using and replacing `my_wallet` with your Octez client alias of your address: ```bash commitment="sh1u3tr3YKPDYUp2wWKCfmV5KZb82FREhv8GtDeR3EJccsBerWGwJYKufsDNH8rk4XqGrXdooZ" proof="8229c63b8e858d9a96321c80a204756020dd13243621c11bec61f182a23714cf6e0985675fff45f1164657ad0c7b9418" - octez-client --endpoint ${ENDPOINT} \ - publish dal commitment "${commitment}" from ${MY_ACCOUNT} for slot 10 \ - with proof "${proof}" + octez-client publish dal commitment "${commitment}" from my_wallet for slot 10 with proof "${proof}" ``` If the Octez client successfully published the commitment, the response to the command shows the slot number and the block (level) that it was published in. - For example, this response shows that the commitment is in level 8455 in slot 10: + For example, this response shows that the commitment is in level 7325485 in slot 10: ``` Data availability slot header publishing: Slot: slot_index: 13, commitment: sh1u3tr3YKPDYUp2wWKCfmV5KZb82FREhv8GtDeR3EJccsBerWGwJYKufsDNH8rk4XqGrXdooZ This data availability slot header publishing was successfully applied - id:(published_level: 8455, index: 10), commitment: sh1u3tr3YKPDYUp2wWKCfmV5KZb82FREhv8GtDeR3EJccsBerWGwJYKufsDNH8rk4XqGrXdooZ + id:(published_level: 7325485, index: 10), commitment: sh1u3tr3YKPDYUp2wWKCfmV5KZb82FREhv8GtDeR3EJccsBerWGwJYKufsDNH8rk4XqGrXdooZ Consumed gas: 1331.033 ``` - After 4 blocks, you should see a message in the kernel log that looks like this: +1. Note the value of the `published_level` field in the response and look for that block number on [Explorus](https://explorus.io/dal). +The slot that you published the message to turns blue, as in this picture: + + ![The Explorus record of slots in use, showing slot 10 in use](/img/tutorials/dal-explorus-blue-slot.png) + + The blue slot means that data was published to the slot but has not been attested yet. + + After 8 blocks, the slot turns green if bakers attested to the availability of the data or red if they did not. + + If the slot turns green, you should see a message in the kernel log that looks like this: ``` - RollupDalParameters { number_of_slots: 32, attestation_lag: 4, slot_size: 65536, page_size: 4096 } - Attested slot at index 10 for level 8455: [72, 101, 108, 108, 111, 44, 32, 119, 111, 114] + RollupDalParameters { number_of_slots: 32, attestation_lag: 8, slot_size: 126944, page_size: 3967 } + Attested slot at index 10 for level 7325485: [72, 101, 108, 108, 111, 44, 32, 119, 111, 114] See you in the next level ``` @@ -103,24 +109,23 @@ If you don't see the message that the slot is attested and contains your data, t - Make sure that the Smart Rollup and the DAL node are both using the slot that you published the commitment to: - - In the file `lib/src.rs`, the line `const SLOT_TO_MONITOR: u8 = 13;` should use your slot. - - When you run the command to start the DAL node, make sure that the `--producer-profiles` argument is set to your slot: + - In the file `lib/src.rs`, the line `const SLOT_TO_MONITOR: u8 = 10;` should use your slot. + - When you run the command to start the DAL node, make sure that the `--observer-profiles` argument is set to your slot: ```bash - octez-dal-node run --endpoint ${ENDPOINT} \ - --producer-profiles=10 --data-dir _dal_node + octez-dal-node run --observer-profiles=10 --data-dir _dal_node ``` - When you run the command to publish the commitment to the DAL, make sure that you publish it to your slot: ```bash - octez-client --endpoint ${ENDPOINT} \ - publish dal commitment "${commitment}" from ${MY_ACCOUNT} for slot 10 \ - with proof "${proof}" + octez-client publish dal commitment "${commitment}" \ + from my_wallet for slot 10 with proof "${proof}" ``` -- Check the page at https://explorus.io/dal. - If that page shows red (unattested) slots, it's possible that the attesters for the network are offline. - You can also see the level that your commitment was published to in the result of the `octez-client publish dal commitment` command and check its status on https://explorus.io/dal. +- If the slot turned red, it's possible that the attesters for the network are offline. +In this case, your Smart Rollup cannot use the data on the DAL, but the blue slot in Explorus verifies that you published it successfully. +Without active attesters, you cannot continue with this tutorial. +You can try running your own attester by getting tez from the faucet and running a baker as described in [Join the DAL as a baker, in 5 steps](/tutorials/join-dal-baker). ## Publishing files @@ -147,35 +152,40 @@ If you are using the Tezos Docker image, you can run `sudo apk add jq xxd`. echo -n "${slot_size_bin}${slot_contents}" | xxd -p -r > "${target}" - certificate="$(curl localhost:10732/slot --data-binary "@${target}" -H 'Content-Type: application/octet-stream')" + certificate="$(curl localhost:10732/slots --data-binary "@${target}" -H 'Content-Type: application/octet-stream')" echo "${certificate}" commitment="$(echo -n ${certificate} | jq '.commitment' -r)" proof="$(echo -n ${certificate} | jq '.commitment_proof' -r)" - octez-client --endpoint ${ENDPOINT} \ - publish dal commitment "${commitment}" from "${alias}" \ - for slot "${index}" with proof "${proof}" + octez-client publish dal commitment "${commitment}" \ + from "${alias}" for slot "${index}" with proof "${proof}" rm "${target}" ``` +1. Make the script executable by running this command: + + ```bash + chmod +x upload_file.sh + ``` + +1. Try uploading a file with the script. + The script accepts three arguments: the file to send, the account alias to use and the slot index to use. - This script also assumes that the `PATH` and `ENDPOINT` environment variables are correctly set. + This script also assumes that the `PATH` environment variable is correctly set. For example, if you create a file named `myFile.txt` and are using slot 10, you can run this command: ```bash - ./upload_file.sh myFile.txt $MY_ACCOUNT 10 + ./upload_file.sh myFile.txt my_wallet 10 ``` 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`. - If you see the error "Wrong value for command line option --endpoint," make sure that the `ENDPOINT` environment variable is set and then make it available to the script by running `export ENDPOINT=$ENDPOINT`. - - Again, by inspecting the kernel logs, you should be able to see that the file that you wanted to publish is indeed the one fetched by the Smart Rollup. + In the next section, you see how to get the contents of the file that you published. Now you can publish data to the DAL and use it in a Smart Rollup. In the next section, you write to and retrieve the entire slot. -When you are ready, go to [Part 4: Using the entire slot](/tutorials/build-files-archive-with-dal/using-full-slot). +When you are ready, go to [Part 5: Using the entire slot](/tutorials/build-files-archive-with-dal/using-full-slot). diff --git a/docs/tutorials/build-files-archive-with-dal/set-up-environment.md b/docs/tutorials/build-files-archive-with-dal/set-up-environment.md index 9f5f43d80..c43645a8b 100644 --- a/docs/tutorials/build-files-archive-with-dal/set-up-environment.md +++ b/docs/tutorials/build-files-archive-with-dal/set-up-environment.md @@ -1,33 +1,30 @@ --- title: "Part 1: Setting up an environment" -authors: 'Tim McMackin' +authors: Tim McMackin last_update: - date: 14 February 2024 + date: 10 September 2024 --- -Because Weeklynet requires a specific version of the Octez suite, you can't use most wallet applications and installations of the Octez suite with it. -Instead, you must set up an environment with a specific version of the Octez suite and use it to create and fund an account. +These steps cover how to set up a development environment to work with Smart Rollups and the DAL. +To work with these elements, you need the Octez suite, which includes the Octez command-line client for interacting with Tezos and the binaries for the DAL node and Smart Rollup node. +You must use the same version of the Octez suite that the network is using. -:::note Weeklynet resets every week -Weeklynet is reset every Wednesday, which deletes all accounts, smart contracts, and Smart Rollups. -Therefore, you must recreate your environment and account and redeploy your smart Contracts and Smart Rollups after the network resets. -::: - -## Set up a Weeklynet environment and account - -The easiest way to use Weeklynet is to use the Docker image that is generated each time Weeklynet is reset and recreated. -As another option, you can build the specific version of the Octez suite locally. -For instructions, see the Weeklynet page at https://teztnets.com/weeklynet-about. +The easiest way to use the Octez suite is to use the `tezos/tezos` Docker image. +As another option, you can get the built version of the Octez suite from https://tezos.gitlab.io/ or build the specific version of the Octez suite locally. To set up an environment and account in a Docker container, follow these steps: -1. From the [Weeklynet](https://teztnets.com/weeklynet-about) page, find the Docker command to create a container from the correct Docker image, as in this example: +1. Retrieve the latest version of the `tezos/tezos` Docker image by running this command: ```bash - docker run -it --entrypoint=/bin/sh tezos/tezos:master_7f3bfc90_20240116181914 + docker pull tezos/tezos:latest ``` - The image tag in this command changes each time the network is reset. +1. Start a Docker container from the image: + + ```bash + docker run -it --entrypoint=/bin/sh tezos/tezos:latest + ``` :::tip If you're not used to working inside Docker containers, you can map a folder on your computer to a folder in the container to create a [Docker volume](https://docs.docker.com/storage/volumes/). @@ -35,30 +32,58 @@ To set up an environment and account in a Docker container, follow these steps: For example, to start a container and map the current folder to the `/home/tezos` folder in the container, run this command: ```bash - docker run -it --entrypoint=/bin/sh -v .:/home/tezos tezos/tezos:master_7f3bfc90_20240116181914 + docker run -it --entrypoint=/bin/sh -v .:/home/tezos tezos/tezos:latest ``` You can map a folder like this only when you create a container; you cannot add it later. ::: -1. Copy the URL of the public RPC endpoint for Weeklynet, such as `https://rpc.weeklynet-2024-01-17.teztnets.com`. -This endpoint also changes each time the network is reset. +1. In the container, configure the layer 1 node for Ghostnet: + + ```bash + octez-node config init --network ghostnet + ``` + + If you see an error that says that the node has a pre-existing configuration file, update the existing configuration file by running this command: + + ```bash + octez-node config update --network ghostnet + ``` + +1. Download a snapshot of Ghostnet from https://snapshot.tzinit.org based on the instructions on that site. +For example, the command to download the snapshot may look like this: -1. For convenience, you may want to set this endpoint as the value of the `ENDPOINT` environment variable. -The parts of the Octez suite don't use this environment variable directly, but you can save time by using this variable in commands. + ```bash + wget -O snapshot_file https://snapshots.eu.tzinit.org/ghostnet/rolling + ``` -1. In the container, initialize the Octez client with that endpoint, such as this example: +1. Load the snapshot in the node by running this command: ```bash - octez-client -E https://rpc.weeklynet-2024-01-17.teztnets.com config init + octez-node snapshot import snapshot_file ``` - or: +1. Run this command to start the node: + + ```bash + octez-node run --rpc-addr 127.0.0.1:8732 + ``` + +1. Leave the node running in that terminal window and 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, run the `docker ps` command. + +1. In the container, initialize the Octez client to use your node, such as this example: ```bash - octez-client -E $ENDPOINT config init + octez-client -E http://127.0.0.1:8732 config init ``` + This command uses the default port for the node, but you can change it if you are running the node somewhere else. + + If you get an error that says "Failed to acquire the protocol version from the node," the node is not ready yet. + Wait a few minutes for the node to be ready, run `rm -rf /home/tezos/.tezos-client/config` to remove the configuration file, and try the `config init` command again. + 1. Optional: Hide the network warning message by running this command: ```bash @@ -67,11 +92,11 @@ The parts of the Octez suite don't use this environment variable directly, but y This command suppresses the message that your instance of the Octez client is not using Mainnet. -1. Create an account with the command `octez-client gen keys $MY_ACCOUNT`, where `$MY_ACCOUNT` is an alias for your account. +1. Create an account with the command `octez-client gen keys my_wallet`, where `my_wallet` is an alias for your account. -1. Get the public key hash of the new account by running the command `octez-client show address $MY_ACCOUNT`. +1. Get the public key hash of the new account by running the command `octez-client show address my_wallet`. -1. From the [Weeklynet](https://teztnets.com/weeklynet-about) page, open the Weeklynet faucet and send some tez to the account. +1. From the [Ghostnet](https://teztnets.com/ghostnet-about) page, open the Ghostnet faucet and send some tez to the account. 50 tez is enough to get started, and you can always go back to the faucet to get more. Now you can use this account to deploy Smart Rollups. @@ -92,7 +117,13 @@ If you are using the Tezos Docker container, run `sudo apk add curl`. ``` 1. Follow the instructions in the Rust installation program. -For example, it may prompt you to run `source "$HOME/.cargo/env"` to configure your current terminal window to run Rust. +For example, it may prompt you to run `. "$HOME/.cargo/env"` to configure your current terminal window to run Rust. + +1. Set the version of Rust to 1.80 by running this command: + + ```bash + rustup override set 1.80 + ``` 1. Add WASM as a compilation target for Rust by running this command: @@ -107,7 +138,7 @@ For example, it may prompt you to run `source "$HOME/.cargo/env"` to configure y Clang and LLVM are required for compilation to WebAssembly. Version 11 or later of Clang is required. -If you are using the Tezos Docker container, run these commands: +If you are using the `tezos/tezos` Docker image, run these commands: ```bash sudo apk add clang diff --git a/docs/tutorials/build-files-archive-with-dal/using-full-slot.md b/docs/tutorials/build-files-archive-with-dal/using-full-slot.md index 6ee53c95b..a44a8887e 100644 --- a/docs/tutorials/build-files-archive-with-dal/using-full-slot.md +++ b/docs/tutorials/build-files-archive-with-dal/using-full-slot.md @@ -1,8 +1,8 @@ --- -title: "Part 4: Using the entire slot" -authors: 'Tezos Core Developers' +title: "Part 5: Using the entire slot" +authors: Tezos core developers, Tim McMackin last_update: - date: 18 January 2024 + date: 30 July 2024 --- In some cases, you may want to retrieve the entire contents of a slot. @@ -13,7 +13,7 @@ For example, it can be convenient to get the entire slot because it has a fixed Retrieving the full slot is similar to retrieving any data from the slot. In this case, you change the kernel to retrieve data of the exact size of the slot. -1. Update the `run` function in the `lib/rs` file to this code: +1. Update the `run` function in the `lib/rs` file to this code, without changing the rest of the file: ```rust pub fn run( @@ -92,7 +92,7 @@ In this case, you change the kernel to retrieve data of the exact size of the sl These dependencies use `tezos_crypto_rs` for hashing, and `hex` for encoding. -1. Add the matching dependencies to the `Cargo.toml` file: +1. Add the matching dependencies to the end of the `Cargo.toml` file: ```toml tezos_crypto_rs = { version = "0.5.2", default-features = false } @@ -105,8 +105,8 @@ In this case, you change the kernel to retrieve data of the exact size of the sl The Smart Rollup log shows the hash of the data, as in this example: ``` - RollupDalParameters { number_of_slots: 32, attestation_lag: 4, slot_size: 65536, page_size: 4096 } - Attested slot at index 10 for level 15482 + RollupDalParameters { number_of_slots: 32, attestation_lag: 8, slot_size: 126944, page_size: 3967 } + Attested slot at index 10 for level 7325751 Saving slot under `/6a578d1e6746d29243ff81923bcea6375e9344d719ca118e14cd9f3d3b00cd96' See you in the next level ``` @@ -130,7 +130,7 @@ The Smart Rollup log shows the hash of the data, as in this example: :::note Why `diff` won't work You cannot use `diff` to ensure that the file you originally published and the one that you downloaded from the rollup node are equal. -Indeed, they are not: because the size of a slot is fixed, the DAL node pads the value it receives from `POST /slot` in order to ensure that it has the correct slot size. +Indeed, they are not: because the size of a slot is fixed, the DAL node pads the value it receives from `POST /slots` in order to ensure that it has the correct slot size. ::: ## Next steps diff --git a/static/img/tutorials/dal-explorus-blue-slot.png b/static/img/tutorials/dal-explorus-blue-slot.png new file mode 100644 index 000000000..464a9735f Binary files /dev/null and b/static/img/tutorials/dal-explorus-blue-slot.png differ diff --git a/static/img/tutorials/dal-file-tutorial-setup.png b/static/img/tutorials/dal-file-tutorial-setup.png index 9434fadfc..d3058c47d 100644 Binary files a/static/img/tutorials/dal-file-tutorial-setup.png and b/static/img/tutorials/dal-file-tutorial-setup.png differ