Part 1: Setting up the application
To set up the application for the tutorial, you must configure Rust to build the kernel and start a Docker container that has resources that are needed to debug and deploy it.
Building the application
Follow these steps to get the application code and build it:
-
Clone the repository with the tutorial application:
git clone https://gitlab.com/trili/hello-world-kernel.git
cd hello-world-kernel/ -
Configure Rust to build WebAssembly applications:
-
Verify that you have Rust version 1.73.0 or later installed by running
rustc --version
. -
If you have an earlier version of Rust, use the
rustup
command to use version 1.73.0:rustup override set 1.73.0
-
Add WASM as a compilation target for Rust by running this command:
rustup target add wasm32-unknown-unknown
-
-
Build the application by running this command:
cargo build --target wasm32-unknown-unknown
If the application builds correctly, the terminal shows a message that looks like "Finished dev [unoptimized + debuginfo] target(s) in 0.44s." You can see the compiled application in the
target/wasm32-unknown-unknown/debug
folder. In particular, the compiled kernel is in thehello_world_kernel.wasm
file.
Now the kernel is compiled into a single file that nodes can run.
Start the Docker container
Tezos provides a Docker image that contains the Octez client, which allows you to interact with Tezos from the command line. Later, you will use this image to run a sandbox Tezos environment for testing the rollup.
-
Make sure that Docker desktop is running.
-
Pull the most recent Tezos Docker image, which contains the most recent version of Octez:
docker pull tezos/tezos:master
You can install Octez directly on your system, but keeping it in Docker is faster and more convenient for running the tutorial application.
-
Make sure you are in the
hello-world-kernel
folder, at the same level as theCargo.toml
andsandbox_node.sh
files. -
Run this command to start the Docker image, open a command-line terminal in that image, and mount the
hello-world-kernel
folder in it:docker run -it --rm --volume $(pwd):/home/tezos/hello-world-kernel --entrypoint /bin/sh --name octez-container tezos/tezos:master
Your command-line prompt changes to indicate that it is now inside the running Docker container. This image includes the Octez command-line client and other Tezos tools. It also uses the docker
--volume
argument to mount the contents of thehello-world-kernel
folder in the container so you can use those files within the container. -
Verify that the container has the necessary tools by running these commands:
octez-node --version
octez-smart-rollup-wasm-debugger --version
octez-smart-rollup-node --version
octez-client --versionEach of these commands should print a version number. The specific version number is not important as long as you retrieved the latest image with the
docker pull tezos/tezos:master
command.Don't close this terminal window or exit the Docker terminal session, because Docker will close the container. If you accidentally close the container, you can run the
docker run ...
command again to open a new one.
Now the application is built and you have an environment that you can debug it in. For the rest of the tutorial, you must be aware of whether you are running commands inside or outside of the Docker container. The container has Octez but not Rust, so you run Rust commands outside of the container and Octez commands inside the container.