From 84860e877a03ae9da06388fb5e517ace9eafd14f Mon Sep 17 00:00:00 2001 From: Matthew Sevey <15232757+MSevey@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:15:32 -0500 Subject: [PATCH] feat: docs restructuring, add deploy section, bring in v0.14.x (#493) * chore: remove Rollkit has menu section and update naming Remove GM tutorial, add language around choosing DA and Execution * feat: create deploy your rollup section Remove kurtosis from wordle tutorial. Rename wordle tutorial in menu to build your rollup. Create overview for deployments sections. Create docker compose deployment tutorial. Create kurtosis deployment tutorial. Refactor tutorials to reduce duplication. * chore: bump rollkit version and sha to v0.14.0 * chore: various updates while debugging * chore: update menu titles * chore: change rollup to chain and adjust capitalzation * chore: clean up rollup vs chain usage in wordle tutorial * chore: bump rollkit to v0.14.1-rc.0 * feat: update ignite app how to guide * fix: clean up wordle tutorial * fix: docker compose turtorial * chore: edit kurtosis disclaimer * chore: remove kurtosis tutorial * chore: bump rollkit version * build: bump versions --------- Co-authored-by: Yarik Bratashchuk --- .vitepress/config.ts | 106 +++--- .vitepress/constants/constants.js | 6 +- guides/ignite-rollkit.md | 43 +-- tutorials/deploy-overview.md | 20 ++ tutorials/docker-compose.md | 258 ++++++++++++++ tutorials/kurtosis.md | 286 ++++++++++++++++ tutorials/wordle.md | 535 +++++------------------------- 7 files changed, 733 insertions(+), 521 deletions(-) create mode 100644 tutorials/deploy-overview.md create mode 100644 tutorials/docker-compose.md create mode 100644 tutorials/kurtosis.md diff --git a/.vitepress/config.ts b/.vitepress/config.ts index d318f9730..39bc9dfc4 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -174,7 +174,7 @@ function nav() { { text: "Learn", link: "/learn/intro" }, { text: "Tutorials", link: "/tutorials/quick-start" }, { text: "How To Guides", link: "/guides/overview" }, - { text: "Testnets", link: "/testnets/cosmwasm-testnet" }, + // { text: "Testnets", link: "/testnets/cosmwasm-testnet" }, { text: "Blog", link: "/blog/overview" }, ]; } @@ -218,17 +218,7 @@ function sidebarHome() { text: "Quick start guide", link: "/tutorials/quick-start", }, - { - text: "Rollkit", - collapsed: true, - items: [ - { - text: "GM world rollup", - link: "/tutorials/gm-world", - }, - { text: "Wordle app", link: "/tutorials/wordle" }, - ], - }, + { text: "Build a chain", link: "/tutorials/wordle" }, { text: "DA", collapsed: true, @@ -273,18 +263,42 @@ function sidebarHome() { text: "Execution", collapsed: true, items: [ - { text: "CosmWasm rollup", link: "/tutorials/cosmwasm" }, - { + { text: "CosmWasm", link: "/tutorials/cosmwasm" }, + { text: "EVM", - collapsed: true, - items: [ + collapsed: true, + items: [ { text: "Omni Octane EVM", link: "/tutorials/octane-evm" }, - { text: "BeaconKit EVM", link: "/tutorials/beaconkit" }, - { text: "Artela EVM++", link: "/tutorials/artela-evm-plus-plus" }, - { text: "Contract interaction", link: "/tutorials/evm-contract-interaction" }, - ] - }, - ], + { text: "BeaconKit EVM", link: "/tutorials/beaconkit" }, + { + text: "Artela EVM++", + link: "/tutorials/artela-evm-plus-plus", + }, + { + text: "Contract interaction", + link: "/tutorials/evm-contract-interaction", + }, + ], + }, + ], + }, + { + text: "Deploy your chain", + collapsed: true, + items: [ + { + text: "Overview", + link: "/tutorials/deploy-overview", + }, + { + text: "Docker Compose", + link: "/tutorials/docker-compose", + }, + // { + // text: "Kurtosis", + // link: "/tutorials/kurtosis", + // }, + ], }, ], }, @@ -350,32 +364,32 @@ function sidebarHome() { text: "Integrations", collapsed: true, items: [ - { - text: "Test and deploy cosmwasm smart-contracts", - link: "/guides/cw-orch", - }, - { text: "Add zkML to your EVM rollup", link: "/guides/zkml" }, - { - text: "Add an IBC connection to your rollup", - link: "/guides/ibc-connection", - }, - { - text: "Integrate Range with your rollup", - link: "/guides/rollkit-monitoring", - }, - { - text: "Use IBC token (TIA) as gas token in your rollup", - link: "/guides/use-tia-for-gas", - }, - ], - }, + { + text: "Test and deploy cosmwasm smart-contracts", + link: "/guides/cw-orch", + }, + { text: "Add zkML to your EVM rollup", link: "/guides/zkml" }, + { + text: "Add an IBC connection to your rollup", + link: "/guides/ibc-connection", + }, + { + text: "Integrate Range with your rollup", + link: "/guides/rollkit-monitoring", + }, + { + text: "Use IBC token (TIA) as gas token in your rollup", + link: "/guides/use-tia-for-gas", + }, + ], + }, ], }, - { - text: "Testnets", - collapsed: true, - items: [{ text: "CosmWasm Testnet", link: "/testnets/cosmwasm-testnet" }], - }, + // { + // text: "Testnets", + // collapsed: true, + // items: [{ text: "CosmWasm Testnet", link: "/testnets/cosmwasm-testnet" }], + // }, { text: "Blog", collapsed: true, diff --git a/.vitepress/constants/constants.js b/.vitepress/constants/constants.js index dfefe9368..da60e0ca0 100644 --- a/.vitepress/constants/constants.js +++ b/.vitepress/constants/constants.js @@ -4,13 +4,13 @@ const constants = Object.freeze({ nodeVersion: "21.7.2", yarnVersion: "1.22.19", - rollkitLatestTag: "v0.13.7", - rollkitLatestSha: "8deede4", + rollkitLatestTag: "v0.14.1", + rollkitLatestSha: "5a8693e", rollkitCosmosSDKVersion: "v0.50.6-rollkit-v0.13.3-no-fraud-proofs", rollkitIgniteAppVersion: "rollkit/v0.2.1", localDALatestTag: "v0.3.1", - goSequencingLatestTag: "v0.4.0", + goSequencingLatestTag: "v0.4.1", igniteVersionTag: "v28.5.3", }); export default constants; diff --git a/guides/ignite-rollkit.md b/guides/ignite-rollkit.md index 900196782..275b497d5 100644 --- a/guides/ignite-rollkit.md +++ b/guides/ignite-rollkit.md @@ -30,26 +30,6 @@ This will create the `gm` blockchain. Navigate to the blockchain directory: cd gm ``` -## Run a local Data Availability (DA) node {#run-local-da-node} - -First, set up a local data availability network node: - -```bash-vue -cd $HOME && curl -sSL https://rollkit.dev/install-local-da.sh | sh -s {{constants.localDALatestTag}} -``` - -This script builds and runs a DA node, which will listen on port `7980`. - -## Run a local Sequencer node {#run-local-sequencer-node} - -First, set up a local sequencer node: - -```bash-vue -cd $HOME && curl -sSL https://rollkit.dev/install-local-sequencer.sh | sh -s {{constants.goSequencingLatestTag}} gm -``` - -This script builds and runs a local sequencer node, which will listen on port `50051`. - ## Install Ignite App Rollkit {#install-ignite-app-rollkit} In a new terminal window, you'll now install and run the Ignite App Rollkit. @@ -70,6 +50,14 @@ Enhance your blockchain by adding Rollkit features. Use the following command: ignite rollkit add ``` +## Build your chain {#build-your-chain} + +Build your chain using the following command: + +```bash +ignite chain build +``` + ## Initialize Your Blockchain {#initialize-your-blockchain} Before starting your blockchain, you need to initialize it with Rollkit support. Initialize the blockchain with Local DA as follows: @@ -88,16 +76,21 @@ rollkit toml init This will set up the Rollkit configuration file rollkit.toml, allowing you to use the Rollkit CLI for managing and running your blockchain. -## Start Your Rollup {#start-your-blockchain} +## Start your chain {#start-your-chain} + +Now you are ready to start your chain. We need to include 2 flags: + +1. `--rollkit.aggregator` to signal that this node is the block producer +2. `--rollkit.sequencer_rollup_id gm` to share the chain ID with the sequencer. -Finally, start your rollup (blockchain) using the following command: +Start your chain using the following command: ```bash -rollkit start --rollkit.aggregator --rollkit.da_address http://localhost:7980 +rollkit start --rollkit.aggregator --rollkit.sequencer_rollup_id gm ``` -Your rollkit app is now up and running. +Your rollkit chain is now up and running. ## Summary -By following these steps, you've successfully installed Ignite, set up Local DA, integrated Rollkit features into your blockchain, and configured the Rollkit CLI. +By following these steps, you've successfully installed Ignite, integrated Rollkit features into your blockchain, and configured the Rollkit CLI to run your chain against a mock DA and mock sequencer. diff --git a/tutorials/deploy-overview.md b/tutorials/deploy-overview.md new file mode 100644 index 000000000..72f81fffe --- /dev/null +++ b/tutorials/deploy-overview.md @@ -0,0 +1,20 @@ +--- +description: This page provides an overview of some common ways to deploy rollups. +--- + +# Deploying Your Rollup + +One of the benefits of building rollups with Rollkit is the flexibility you have as a developer to choose things like the DA layer, the settlement scheme, and the execution environment. + +The challenge that comes with this flexibility is that there are more services that now need to be deployed and managed while running your rollup. + +In the tutorials so far, you've seen various helper scripts used to make things easier. While great for tutorials, there are better ways to deploy and manage rollups than using various bash scripts. + +In this section, you'll see a few examples of how you can deploy your rollup environment with all your services running in a more production-ready way. + +:::warning Disclaimer +These examples are for educational purposes only. Before deploying your rollup for production use you should fully understand the services you are deploying and your choice in deployment method. +::: + +* [Deploy with Docker Compose](/tutorials/docker-compose) + diff --git a/tutorials/docker-compose.md b/tutorials/docker-compose.md new file mode 100644 index 000000000..51fbc7c18 --- /dev/null +++ b/tutorials/docker-compose.md @@ -0,0 +1,258 @@ +# 🐳 Docker Compose + +This tutorial is going to show you how to deploy the [wordle chain](/tutorials/wordle.md) using Docker Compose. + +You can learn more about Docker Compose [here](https://docs.docker.com/compose/). + + + + +:::tip + +::: + + +## 💻 Pre-requisites {#prerequisites} + +Make sure you have your wordle chain ready by completing [the Build your chain tutorial](/tutorials/wordle.md). + +## 🛠️ Dependencies {#dependencies} + +### 💻 Docker Compose {#docker-compose} + +You can [install docker compose here](https://docs.docker.com/compose/install/). + +Once installed, you can verify the installation by running: + +```bash +docker compose version +``` +```bash +Docker Compose version v2.23.0-desktop.1 +``` + +## 🛠️ Setting up your environment {#setting-up-your-environment} + +In addition to our chain, we need to run a DA and Sequencer node. + +We will use the [local-da](https://github.com/rollkit/local-da) and [local-sequencer](https://github.com/rollkit/go-sequencing) for this tutorial and run it with our chain. + +To save time, we can use their respective Dockerfiles: +* [local-da Dockerfile](https://github.com/rollkit/local-da/blob/main/Dockerfile) +* [local-sequencer Dockerfile](https://github.com/rollkit/go-sequencing/blob/main/Dockerfile) + +This will allow us to focus on how we can run the wordle chain with Docker Compose. + +### 🐳 Dockerfile {#dockerfile} + +First, we need to create a Dockerfile for our wordle chain. Create a new file called `Dockerfile` in the root of the `wordle` directory and add the following code: + +```dockerfile-vue +# Stage 1: Install ignite CLI and rollkit +FROM golang as base + +# Install dependencies +RUN apt update && \ + apt-get install -y \ + build-essential \ + ca-certificates \ + curl + +# Install rollkit +RUN curl -sSL https://rollkit.dev/install.sh | sh -s {{constants.rollkitLatestTag}} + +# Install ignite +RUN curl https://get.ignite.com/cli@{{constants.igniteVersionTag}}! | bash + +# Set the working directory +WORKDIR /app + +# cache dependencies. +COPY ./go.mod . +COPY ./go.sum . +RUN go mod download + +# Copy all files from the current directory to the container +COPY . . + +# Remove the rollkit.toml and entrypoint files if they exist. This is to avoid cross OS issues. +RUN rm entrypoint rollkit.toml + +# Build the chain +RUN ignite chain build && ignite rollkit init + +# Initialize the rollkit.toml file +RUN rollkit toml init + +# Run rollkit command to initialize the entrypoint executable +RUN rollkit + +# Stage 2: Set up the runtime environment +FROM debian:bookworm-slim + +# Install jq +RUN apt update && \ + apt-get install -y \ + jq + +# Set the working directory +WORKDIR /root + +# Copy over the rollkit binary from the build stage +COPY --from=base /go/bin/rollkit /usr/bin + +# Copy the entrypoint and rollkit.toml files from the build stage +COPY --from=base /app/entrypoint ./entrypoint +COPY --from=base /app/rollkit.toml ./rollkit.toml + +# Copy the $HOME/.wordle directory from the build stage. +# This directory contains all your chain config. +COPY --from=base /root/.wordle /root/.wordle + +# Ensure the entrypoint script is executable +RUN chmod +x ./entrypoint + +# Keep the container running after it has been started +# CMD tail -f /dev/null + +ENTRYPOINT [ "rollkit" ] +CMD [ "start", "--rollkit.aggregator", "--rollkit.sequencer_rollup_id", "wordle"] + +``` + +This Dockerfile sets up the environment to build the chain and run the wordle node. It then sets up the runtime environment to run the chain. This allows you as the developer to modify any files, and then simply rebuild the Docker image to run the new chain. + +Build the docker image by running the following command: + +```bash +docker build -t wordle . +``` + +You can then see the built image by running: + +```bash +docker images +``` + +You should see the following output: + +```bash +REPOSITORY TAG IMAGE ID CREATED SIZE +wordle latest 5d3533c1ea1c 8 seconds ago 443MB +``` + +### 🐳 Docker Compose file {#docker-compose-file} + +Next we need to create our `compose.yaml` file for docker compose to use. + +In the root of the `wordle` directory, create a new file called `compose.yaml` and add the following code: + +```yml-vue +services: + # Define the wordle chain service + wordle: + # Set the name of the docker container for ease of use + container_name: wordle + # Use the image we just built + image: wordle + # Used for networking between the two services + network_mode: host + # The command config is used for launching the chain once the Docker container is running + command: + [ + "start", + "--rollkit.aggregator", + "--rollkit.da_address", + "http://0.0.0.0:7980", + "--rollkit.sequencer_address", + "0.0.0.0:50051", + "--rollkit.sequencer_rollup_id", + "wordle", + ] + # Ensures the local-da service is up and running before starting the chain + depends_on: + - local-da + - local-sequencer + + # Define the local DA service + local-da: + # Use the published image from rollkit + image: + ghcr.io/rollkit/local-da:{{constants.localDALatestTag}} + # Set the name of the docker container for ease of use + container_name: local-da + # Publish the ports to connect + ports: + - "7980:7980" + + # Define the local sequencer service + local-sequencer: + # Use the published image from rollkit + image: + ghcr.io/rollkit/go-sequencing:{{constants.goSequencingLatestTag}} + # Set the name of the docker container for ease of use + container_name: local-sequencer + # Start the sequencer with the listen all flag and the rollup id set to wordle + command: ["-listen-all", "-rollup-id=wordle"] + # Publish the ports to connect + ports: + - "50051:50051" +``` + +We now have all we need to run the wordle chain and connect to a local DA node. + +### 🚀 Run Wordle chain {#run-wordle-chain} + +Run your wordle chain by running the following command: + +```bash +docker compose up +``` + +You'll see logs of your chain being output. + +Congratulations! You have successfully run the wordle chain with Docker Compose. + +## 🚀 Interacting with the chain {#interacting-with-the-chain} + +Since we are using docker images, we can interact with the chain by entering the docker container. + +You can see the docker containers running with the wordle chain and the local DA node by running the following command: + +```bash +docker ps +``` + +You should see output like the following: + +```bash +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +86f9bfa5b6d2 wordle "rollkit start --rol…" 7 minutes ago Up 3 seconds wordle +67a2c3058e01 local-sequencer "local-sequencer -li…" 11 minutes ago Up 3 seconds 0.0.0.0:50051->50051/tcp local-sequencer +dae3359665f8 local-da "local-da -listen-all" 2 hours ago Up 3 seconds 0.0.0.0:7980->7980/tcp local-da +``` + +We can see the wordle chain running in container `wordle` and the local DA network running in container `local-da`. + +Since our chain is running in a docker container, we want to enter the docker container to interact with it via the Rollkit CLI. We can do this by running: + +```bash +docker exec -it wordle sh +``` + +Now that you are in the docker container, you can interact with the chain using the Rollkit CLI and the example commands you used in the [Wordle tutorial](/tutorials/wordle#interacting-with-the-chain). + +Once you are done interacting with your chain, you can exit out of your docker container with: + +```bash +exit +``` + +Then you can shut down your chain environment by running `CRTL+C` in your terminal. + +## 🎉 Next steps + +Congratulations again! You now know how to run your chain with docker compose and interact with it using the Rollkit CLI in the docker container. diff --git a/tutorials/kurtosis.md b/tutorials/kurtosis.md new file mode 100644 index 000000000..51d6b1660 --- /dev/null +++ b/tutorials/kurtosis.md @@ -0,0 +1,286 @@ +# 🟩 Kurtosis + +This tutorial is going to show you how to deploy the [wordle chain](/tutorials/wordle.md) using Kurtosis. + +You can learn more about Kurtosis [here](https://docs.kurtosis.com/). + +:::warning Disclaimer +Kurtosis currently does not fully support data persistence across runs, because of this it is not recommended for production use. + +This tutorial is WIP and does not currently support the new sequencing API introduced in rollkit v0.14.0 +::: + + + + +:::tip + +::: + + +## 💻 Pre-requisites {#prerequisites} + +Make sure you have your wordle chain ready by completing [the Build your chain tutorial](/tutorials/wordle.md). + +## 🛠️ Dependencies {#dependencies} + +### 💻 Kurtosis CLI {#kurtosis-cli} + +You can [install the kurtosis cli here](https://docs.kurtosis.com/install). + +Once installed, you can verify the installation by running: + +```bash +kurtosis version +``` +```bash +CLI Version: 1.3.1 + +To see the engine version (provided it is running): kurtosis engine status +``` + +## 🛠️ Setting up your environment {#setting-up-your-environment} + +The wordle chain is a relatively simple chain in that there are just 2 nodes involved: the chain and the data availability network (DA) node. + +We will use a local DA node for this tutorial and run it in the same Kurtosis enclave as our chain. + +To save time, we can use the [local DA kurtosis package found here.](https://github.com/rollkit/local-da/blob/main/main.star) + +This will allow us to focus on how we can run the wordle chain in Kurtosis. + +### 🐳 Dockerfile {#dockerfile} + +First, we need to create a Dockerfile for our wordle chain. + +Create a new file called `Dockerfile` in the root of the `wordle` directory and add the following code from the [Docker Compose tutorial](/tutorials/docker-compose#dockerfile). + +This Dockerfile sets up the environment to build the chain and run the wordle node. It then sets up the runtime environment to run the chain. This allows you as the developer to modify any files, and then simply rebuild the Docker image to run the new chain. + +Build the docker image by running the following command: + +```bash +docker build -t wordle . +``` + +You can then see the built image by running: + +```bash +docker images +``` + +You should see the following output: + +```bash +REPOSITORY TAG IMAGE ID CREATED SIZE +wordle latest 5d3533c1ea1c 8 seconds ago 443MB +``` + +### 🟢 Kurtosis {#kurtosis-init} + +To initialize a kurtosis package, run the following command: + +```bash +kurtosis package init +``` + +This will create a `kurtosis.yml` file and a `main.star` file. The `kurtosis.yml` file is where you define your package. Open it and update it to something like the following: + +```yaml +name: github.com/rollkit/wordle +description: |- + # github.com/rollkit/wordle + A simple wordle chain for the Rollkit tutorial. +replace: {} +``` + +You should replace `github.com/rollkit/wordle` with your own repository name. + +The `main.star` file is where we define the kurtosis package. Open it up and replace the contents with the following code: + +```python +# This Kurtosis package spins up a wordle chain that connects to a DA node + +# Import the local da kurtosis package +da_node = import_module("github.com/rollkit/local-da/main.star@v0.3.0") + + +def run(plan): + # Start the DA node + da_address = da_node.run( + plan, + ) + plan.print("connecting to da layer via {0}".format(da_address)) + + # Define the wordle start command + wordle_start_cmd = [ + "rollkit", + "start", + "--rollkit.aggregator", + "--rollkit.da_address {0}".format(da_address), + "--rollkit.sequencer_address {0}".format(sequencer_address), + "--rollkit.sequencer_rollup_id wordle", + ] + # Define the jsonrpc ports + wordle_ports = { + "jsonrpc": PortSpec( + number=26657, transport_protocol="TCP", application_protocol="http" + ), + } + # Start the wordle chain + wordle = plan.add_service( + name="wordle", + config=ServiceConfig( + # Use the wordle image we just built + image="wordle", + # Set the command to start the wordle chain in the docker container + cmd=["/bin/sh", "-c", " ".join(wordle_start_cmd)], + ports=wordle_ports, + public_ports=wordle_ports, + ), + ) +``` + +We now have all we need to run the wordle chain and connect to a local DA node. + +### 🚀 Run Wordle chain {#run-wordle-chain} + +Run your wordle chain by running the following command: + +```bash +kurtosis run . +``` + +You'll see an output like the following: + +```bash +INFO[2024-07-16T14:56:39-04:00] No Kurtosis engine was found; attempting to start one... +INFO[2024-07-16T14:56:39-04:00] Starting the centralized logs components... +INFO[2024-07-16T14:56:39-04:00] Centralized logs components started. +INFO[2024-07-16T14:56:40-04:00] Reverse proxy started. +INFO[2024-07-16T14:56:43-04:00] Successfully started Kurtosis engine +INFO[2024-07-16T14:56:43-04:00] Creating a new enclave for Starlark to run inside... +INFO[2024-07-16T14:56:46-04:00] Enclave 'yearning-bog' created successfully +INFO[2024-07-16T14:56:46-04:00] Executing Starlark package at '/Users/matt/Code/test/wordle' as the passed argument '.' looks like a directory +INFO[2024-07-16T14:56:46-04:00] Compressing package 'github.com/example-org/example-package' at '.' for upload +INFO[2024-07-16T14:56:48-04:00] Uploading and executing package 'github.com/example-org/example-package' + +Container images used in this run: +> ghcr.io/rollkit/local-da:v0.2.1 - locally cached +> wordle - locally cached + +Adding service with name 'local-da' and image 'ghcr.io/rollkit/local-da:v0.2.1' +Service 'local-da' added with service UUID '775883b14f7f4db393addcebe3afe34d' + +Printing a message +connecting to da layer via http://172.16.0.5:7980 + +Adding service with name 'wordle' and image 'wordle' +Service 'wordle' added with service UUID '5a969765174a47ada0727bd68e087f36' + +Starlark code successfully run. No output was returned. + +⭐ us on GitHub - https://github.com/kurtosis-tech/kurtosis +INFO[2024-07-16T14:56:54-04:00] ===================================================== +INFO[2024-07-16T14:56:54-04:00] || Created enclave: yearning-bog || +INFO[2024-07-16T14:56:54-04:00] ===================================================== +Name: yearning-bog +UUID: dc4026b38a60 +Status: RUNNING +Creation Time: Tue, 16 Jul 2024 14:56:43 EDT +Flags: + +========================================= Files Artifacts ========================================= +UUID Name + +========================================== User Services ========================================== +UUID Name Ports Status +775883b14f7f local-da jsonrpc: 7980/tcp -> http://127.0.0.1:7980 RUNNING +5a969765174a wordle jsonrpc: 26657/tcp -> http://127.0.0.1:26657 RUNNING +``` + +Congratulations! You have successfully run the wordle chain in Kurtosis. + +## 🚀 Interacting with the chain {#interacting-with-the-chain} + +Since we used the docker image to run the chain in Kurtosis, we can interact with the chain by entering the docker container. + +You can see the docker containers running with the wordle chain and the local DA node by running the following command: + +```bash +docker ps +``` + +You should see the following output: + +```bash +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +cbf66a881cb2 wordle:latest "/bin/sh -c 'rollkit…" 5 seconds ago Up 4 seconds 0.0.0.0:26657->26657/tcp wordle--5a969765174a47ada0727bd68e087f36 +09bdf1e94862 ghcr.io/rollkit/local-da:v0.2.1 "local-da -listen-all" 6 seconds ago Up 5 seconds 0.0.0.0:7980->7980/tcp local-da--775883b14f7f4db393addcebe3afe34d +2b50989f65cd kurtosistech/core:0.90.1 "/bin/sh -c ./api-co…" 14 seconds ago Up 13 seconds 0.0.0.0:57050->7443/tcp kurtosis-api--dc4026b38a604b82af88a0cd9bedb245 +74b6708de48e fluent/fluent-bit:1.9.7 "/fluent-bit/bin/flu…" 14 seconds ago Up 13 seconds 2020/tcp kurtosis-logs-collector--dc4026b38a604b82af88a0cd9bedb245 +f1a64151bd29 kurtosistech/engine:0.90.1 "/bin/sh -c ./kurtos…" 18 seconds ago Up 17 seconds 0.0.0.0:8081->8081/tcp, 0.0.0.0:9710-9711->9710-9711/tcp, 0.0.0.0:9779->9779/tcp kurtosis-engine--089b9be758464668857fa46c2187bfe3 +ce2291909a3d traefik:2.10.6 "/bin/sh -c 'mkdir -…" 19 seconds ago Up 18 seconds 80/tcp, 0.0.0.0:9730-9731->9730-9731/tcp kurtosis-reverse-proxy--089b9be758464668857fa46c2187bfe3 +2e8da9bdf81f timberio/vector:0.31.0-debian "/bin/sh -c 'printf …" 19 seconds ago Up 18 seconds kurtosis-logs-aggregator +``` + +We can see the wordle chain running in container `wordle--5a969765174a47ada0727bd68e087f36` and the local DA network running in container `local-da--775883b14f7f4db393addcebe3afe34d`. + +Let's hold on to the container name for the world chain as we will need it later. + +```bash +WORDLE=$(docker ps --format '{{.Names}}' | grep wordle) +echo $WORDLE +``` + +You can verify the chain is running by checking the logs: + +```bash +docker logs $WORDLE +``` + +You should see the following output: + +```bash +... +6:56PM INF executed block app_hash=313F7C52E30B3DEE3511D66B3E2C1B2A56DF4CDE54A90B02AC79678D822B644A height=5 module=BlockManager +6:56PM INF indexed block events height=5 module=txindex +6:56PM INF Creating and publishing block height=6 module=BlockManager +6:56PM INF finalized block block_app_hash=826541369149F3F8DE5A53F5B4174C51975BCC665F0E73B1DB69D9206E4F5563 height=6 module=BlockManager num_txs_res=0 num_val_updates=0 +6:56PM INF executed block app_hash=826541369149F3F8DE5A53F5B4174C51975BCC665F0E73B1DB69D9206E4F5563 height=6 module=BlockManager +6:56PM INF indexed block events height=6 module=txindex +6:57PM INF Creating and publishing block height=7 module=BlockManager +6:57PM INF finalized block block_app_hash=8C751BA9EDCFAD7F92E0E940995B0155BDC856070B876373299E7820C32F0B8B height=7 module=BlockManager num_txs_res=0 num_val_updates=0 +6:57PM INF executed block app_hash=8C751BA9EDCFAD7F92E0E940995B0155BDC856070B876373299E7820C32F0B8B height=7 module=BlockManager +6:57PM INF indexed block events height=7 module=txindex +6:57PM INF Creating and publishing block height=8 module=BlockManager +6:57PM INF finalized block block_app_hash=C93D26AEE9B611952C8122DEB67DBAD95B3604F5C9C5DFBA95A3E7A4CF0AF641 height=8 module=BlockManager num_txs_res=0 num_val_updates=0 +... +``` + +Since our chain is running in a docker container, we want to enter the docker container to interact with it via the Rollkit CLI. We can do this by running: + +```bash +docker exec -it $WORDLE sh +``` + +Now that you are in the docker container, you can interact with the chain using the Rollkit CLI and the example commands you used in the [Wordle tutorial](/tutorials/wordle#interacting-with-the-chain). + +Once you are done interacting with your chain, you can exit out of your docker container with: + +```bash +exit +``` + +Then you can shut down your chain and kurtosis by running: + +```bash +kurtosis clean -a +``` + +## 🎉 Next steps + +Congratulations again! You now know how to run your chain with Kurtosis and interact with it using the Rollkit CLI in the docker container. diff --git a/tutorials/wordle.md b/tutorials/wordle.md index 18abe41e7..e88522d19 100644 --- a/tutorials/wordle.md +++ b/tutorials/wordle.md @@ -26,59 +26,14 @@ import constants from '../.vitepress/constants/constants.js' ## 💻 Pre-requisites {#prerequisites} This tutorial is targeted for developers who have some experience -in the [Cosmos-SDK](https://docs.cosmos.network/). We will go through the steps to build the rollup, but for more information on how the Cosmos-SDK components work, [check out the Cosmos-SDK Docs](https://docs.cosmos.network/). +in the [Cosmos-SDK](https://docs.cosmos.network/). We will go through the steps to build the chain, but for more information on how the Cosmos-SDK components work, [check out the Cosmos-SDK Docs](https://docs.cosmos.network/). -Additionally, we recommend that you have gone over the [GM world](/tutorials/gm-world) tutorial first to see an example of a running rollup. +Additionally, we recommend that you have gone over the [quick start guide](/tutorials/quick-start) first to see an example of a running chain. -## 🛠️ Dependencies {#dependencies} - -### 🟩 Kurtosis {#kurtosis} -As with the [GM Rollup](https://rollkit.dev/tutorials/gm-world), we use [kurtosis](https://docs.kurtosis.com/) to help with managing all the services we need to run. You can [install kurtosis here](https://docs.kurtosis.com/install). - -Once installed, you can verify the installation by running: - -```bash -kurtosis version -``` -```bash -CLI Version: 0.90.1 - -To see the engine version (provided it is running): kurtosis engine status -``` - -### 🔥 Ignite {#ignite} - -Ignite is an amazing CLI tool to help us get started building our own blockchains for cosmos-sdk apps. It provides lots of power toolings and scaffoldings for adding messages, types, and modules with a host of cosmos-sdk libraries provided. - -You can read more about Ignite [here](https://docs.ignite.com). - -To install Ignite, you can run this command in your terminal: +You also need to have Rollkit CLI installed. You can install it by running: ```bash-vue -curl https://get.ignite.com/cli@{{constants.igniteVersionTag}}! | bash -``` - -This installs Ignite CLI in your local machine. You can verify by running the `version` command and confirming it matches the version you installed. - -```bash -ignite version -``` - -You should see the following: - -```bash -Ignite CLI version: v28.4.0 -Ignite CLI build date: 2024-05-15T13:42:13Z -Ignite CLI source hash: 83ee9ba5f81f2d2104ed91808f2cb72719a23e41 -Ignite CLI config version: v1 -Cosmos SDK version: v0.50.6 -Your OS: darwin -Your arch: amd64 -Your Node.js version: v18.17.1 -Your go version: go version go1.22.4 darwin/amd64 -Your uname -a: Darwin Carl 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:09:52 PDT 2024; root:xnu-10063.121.3~5/RELEASE_X86_64 x86_64 -Your cwd: /Users/matt/Code/test -Is on Gitpod: false +curl -sSL https://rollkit.dev/install.sh | sh -s {{constants.rollkitLatestTag}} ``` ## 📖 Design implementation {#design-implementation} @@ -115,9 +70,43 @@ We will go over the architecture to achieve this further in the guide. But for now, we will get started setting up our development environment. -## ⛓️ Scaffolding the wordle chain {#scaffolding-wordle-chain} +## ⛓️ Ignite and scaffolding the wordle chain {#ignite-scaffold-wordle-chain} +### 🔥 Ignite {#ignite} + +Ignite is an amazing CLI tool to help us get started building +our own blockchains for cosmos-sdk apps. It provides lots of +power toolings and scaffoldings for adding messages, types, +and modules with a host of cosmos-sdk libraries provided. + +You can read more about Ignite [here](https://docs.ignite.com). + +To install Ignite, you can run this command in your terminal: + +```bash-vue +curl https://get.ignite.com/cli@{{constants.igniteVersionTag}}! | bash +``` + +This installs Ignite CLI in your local machine. +This tutorial uses a macOS but it should work for Windows. +For Windows users, check out the Ignite docs on installation +for Windows machines. + +Now, refresh your terminal using `source` or open a new terminal +session for the change to take place. + +If you run the following: + +```bash +ignite --help +``` + +You should see an output of help commands meaning Ignite +was installed successfully! + +### ⛓️ Scaffolding the wordle chain {#scaffolding-wordle-chain} + Now, comes the fun part, creating a new blockchain! With Ignite, the process is pretty easy and straightforward. @@ -176,7 +165,7 @@ Most of the tutorial work will happen inside the `x` directory. Before we continue with building our Wordle App, we need to set up Rollkit on our codebase. -### 🗞️ Installing Rollkit Ignite App {#installing-rollkit-ignite-app} +### 🗞️ Installing Rollkit {#installing-rollkit} To install the Rollkit app to Ignite, run the following command: @@ -543,6 +532,8 @@ interface in order to allow sending the reward to the right guesser. ```go title="x/wordle/types/expected_keepers.go" type BankKeeper interface { + ... + // Methods imported from bank should be defined here SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error } @@ -554,304 +545,48 @@ compile the blockchain and take it out for a test drive. ## ⛓️ Run the wordle chain -In order to run our wordle chain, we need to also run a DA node. Like in previous tutorials, we will use kurtosis to manage running all the nodes. - -### 🐳 Dockerfile {#dockerfile} - -First, we need to create a Dockerfile for our wordle chain. Create a new file called `Dockerfile` in the root of the `wordle` directory and add the following code: - -```dockerfile -# Stage 1: Install ignite CLI and rollkit -FROM golang as base - -# Install dependencies -RUN apt update && \ - apt-get install -y \ - build-essential \ - ca-certificates \ - curl - -# Install rollkit -RUN curl -sSL https://rollkit.dev/install.sh | sh -s v0.13.6 - -# Install ignite -RUN curl https://get.ignite.com/cli@v28.4.0! | bash - -# Set the working directory -WORKDIR /app - -# cache dependencies. -COPY ./go.mod . -COPY ./go.sum . -RUN go mod download - -# Copy all files from the current directory to the container -COPY . . - -# Build the chain -RUN ignite chain build && ignite rollkit init - -# Initialize the rollkit.toml file -RUN rollkit toml init - -# Run rollkit command to initialize the entrypoint executable -RUN rollkit - -# Stage 2: Set up the runtime environment -FROM debian:bookworm-slim - -# Install jq -RUN apt update && \ - apt-get install -y \ - jq - -# Set the working directory -WORKDIR /root - -# Copy over the rollkit binary from the build stage -COPY --from=base /go/bin/rollkit /usr/bin - -# Copy the entrypoint and rollkit.toml files from the build stage -COPY --from=base /app/entrypoint ./entrypoint -COPY --from=base /app/rollkit.toml ./rollkit.toml - -# Copy the $HOME/.wordle directory from the build stage. -# This directory contains all your chain config. -COPY --from=base /root/.wordle /root/.wordle - -# Ensure the entrypoint script is executable -RUN chmod +x ./entrypoint - -# Keep the container running after it has been started -CMD tail -f /dev/null -``` - -This Dockerfile sets up the environment to build the chain and run the rollkit node. It then sets up the runtime environment to run the chain. This allows you as the developer to modify any files, and then simply rebuild the Docker image to run the new chain. - -Build the docker image by running the following command: - -```bash -docker build -t wordle . -``` - -You can then see the built image by running: - -```bash -docker images -``` - -You should see the following output: - -```bash -REPOSITORY TAG IMAGE ID CREATED SIZE -wordle latest 5d3533c1ea1c 8 seconds ago 443MB -``` - -### 🟢 Kurtosis {#kurtosis-init} - -To initialize a kurtosis package, run the following command: - -```bash -kurtosis package init -``` - -This will create a `kurtosis.yml` file and a `main.star` file. The `kurtosis.yml` file is where you define your package. Open it and update it to something like the following: - -```yaml -name: github.com/rollkit/wordle -description: |- - # github.com/rollkit/wordle - A simple wordle chain for the Rollkit tutorial. -replace: {} -``` - -You should replace `github.com/rollkit/wordle` with your own repository name. - -The `main.star` file is where we define the kurtosis package. Open it up and replace the contents with the following code: +### 🟢 Building and running wordle chain {#build-and-run-wordle-chain} -```python -# This Kurtosis package spins up a wordle rollup that connects to a DA node - -# Import the local da kurtosis package -da_node = import_module("github.com/rollkit/local-da/main.star@v0.3.0") - - -def run(plan): - # Start the DA node - da_address = da_node.run( - plan, - ) - plan.print("connecting to da layer via {0}".format(da_address)) - - # Define the wordle start command - wordle_start_cmd = [ - "rollkit", - "start", - "--rollkit.aggregator", - "--rollkit.da_address {0}".format(da_address), - ] - # Define the jsonrpc ports - wordle_ports = { - "jsonrpc": PortSpec( - number=26657, transport_protocol="TCP", application_protocol="http" - ), - } - # Start the wordle chain - wordle = plan.add_service( - name="wordle", - config=ServiceConfig( - # Use the wordle image we just built - image="wordle", - # Set the command to start the wordle chain in the docker container - cmd=["/bin/sh", "-c", " ".join(wordle_start_cmd)], - ports=wordle_ports, - public_ports=wordle_ports, - ), - ) -``` - -We now have all we need to run the wordle chain and connect to a local DA node. - -### 🚀 Run Wordle Chain {#run-wordle-chain} - -Run your wordle chain by running the following command: +Initialize the Rollkit chain configuration for a local DA network with this command: ```bash -kurtosis run . +ignite chain build && ignite rollkit init ``` -You'll see an output like the following: - -```bash -INFO[2024-07-16T14:56:39-04:00] No Kurtosis engine was found; attempting to start one... -INFO[2024-07-16T14:56:39-04:00] Starting the centralized logs components... -INFO[2024-07-16T14:56:39-04:00] Centralized logs components started. -INFO[2024-07-16T14:56:40-04:00] Reverse proxy started. -INFO[2024-07-16T14:56:43-04:00] Successfully started Kurtosis engine -INFO[2024-07-16T14:56:43-04:00] Creating a new enclave for Starlark to run inside... -INFO[2024-07-16T14:56:46-04:00] Enclave 'yearning-bog' created successfully -INFO[2024-07-16T14:56:46-04:00] Executing Starlark package at '/Users/matt/Code/test/wordle' as the passed argument '.' looks like a directory -INFO[2024-07-16T14:56:46-04:00] Compressing package 'github.com/example-org/example-package' at '.' for upload -INFO[2024-07-16T14:56:48-04:00] Uploading and executing package 'github.com/example-org/example-package' - -Container images used in this run: -> ghcr.io/rollkit/local-da:v0.2.1 - locally cached -> wordle - locally cached - -Adding service with name 'local-da' and image 'ghcr.io/rollkit/local-da:v0.2.1' -Service 'local-da' added with service UUID '775883b14f7f4db393addcebe3afe34d' - -Printing a message -connecting to da layer via http://172.16.0.5:7980 - -Adding service with name 'wordle' and image 'wordle' -Service 'wordle' added with service UUID '5a969765174a47ada0727bd68e087f36' - -Starlark code successfully run. No output was returned. - -⭐ us on GitHub - https://github.com/kurtosis-tech/kurtosis -INFO[2024-07-16T14:56:54-04:00] ===================================================== -INFO[2024-07-16T14:56:54-04:00] || Created enclave: yearning-bog || -INFO[2024-07-16T14:56:54-04:00] ===================================================== -Name: yearning-bog -UUID: dc4026b38a60 -Status: RUNNING -Creation Time: Tue, 16 Jul 2024 14:56:43 EDT -Flags: - -========================================= Files Artifacts ========================================= -UUID Name - -========================================== User Services ========================================== -UUID Name Ports Status -775883b14f7f local-da jsonrpc: 7980/tcp -> http://127.0.0.1:7980 RUNNING -5a969765174a wordle jsonrpc: 26657/tcp -> http://127.0.0.1:26657 RUNNING -``` +This will create a `~/.wordle` directory with all the necessary files to run a chain. -You can see the docker containers running with the wordle chain and the local DA node by running the following command: +It will also initialize 2 accounts `alice` and `bob`: ```bash -docker ps -``` +Initializing accounts... +✔ Added account alice ... -You should see the following output: - -```bash -CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES -cbf66a881cb2 wordle:latest "/bin/sh -c 'rollkit…" 5 seconds ago Up 4 seconds 0.0.0.0:26657->26657/tcp wordle--5a969765174a47ada0727bd68e087f36 -09bdf1e94862 ghcr.io/rollkit/local-da:v0.2.1 "local-da -listen-all" 6 seconds ago Up 5 seconds 0.0.0.0:7980->7980/tcp local-da--775883b14f7f4db393addcebe3afe34d -2b50989f65cd kurtosistech/core:0.90.1 "/bin/sh -c ./api-co…" 14 seconds ago Up 13 seconds 0.0.0.0:57050->7443/tcp kurtosis-api--dc4026b38a604b82af88a0cd9bedb245 -74b6708de48e fluent/fluent-bit:1.9.7 "/fluent-bit/bin/flu…" 14 seconds ago Up 13 seconds 2020/tcp kurtosis-logs-collector--dc4026b38a604b82af88a0cd9bedb245 -f1a64151bd29 kurtosistech/engine:0.90.1 "/bin/sh -c ./kurtos…" 18 seconds ago Up 17 seconds 0.0.0.0:8081->8081/tcp, 0.0.0.0:9710-9711->9710-9711/tcp, 0.0.0.0:9779->9779/tcp kurtosis-engine--089b9be758464668857fa46c2187bfe3 -ce2291909a3d traefik:2.10.6 "/bin/sh -c 'mkdir -…" 19 seconds ago Up 18 seconds 80/tcp, 0.0.0.0:9730-9731->9730-9731/tcp kurtosis-reverse-proxy--089b9be758464668857fa46c2187bfe3 -2e8da9bdf81f timberio/vector:0.31.0-debian "/bin/sh -c 'printf …" 19 seconds ago Up 18 seconds kurtosis-logs-aggregator +✔ Added account bob ... ``` -We can see the wordle rollup running in container `wordle--5a969765174a47ada0727bd68e087f36` and the local DA network running in container `local-da--775883b14f7f4db393addcebe3afe34d`. +We will use these accounts to submit transactions. -Let's hold on to the container name for the world rollup as we will need it later. +Now let's initialize a `rollkit.toml` file in the `worldle` directory by running: ```bash -WORDLE=$(docker ps --format '{{.Names}}' | grep wordle) -echo $WORDLE +rollkit toml init ``` -You can verify the rollup is running by checking the logs: +To start running the Wordle chain, run the following command: ```bash -docker logs $WORDLE +rollkit start --rollkit.aggregator --rollkit.sequencer_rollup_id wordle ``` -You should see the following output: +With that, we have kickstarted our wordle network! -```bash -... -6:56PM INF executed block app_hash=313F7C52E30B3DEE3511D66B3E2C1B2A56DF4CDE54A90B02AC79678D822B644A height=5 module=BlockManager -6:56PM INF indexed block events height=5 module=txindex -6:56PM INF Creating and publishing block height=6 module=BlockManager -6:56PM INF finalized block block_app_hash=826541369149F3F8DE5A53F5B4174C51975BCC665F0E73B1DB69D9206E4F5563 height=6 module=BlockManager num_txs_res=0 num_val_updates=0 -6:56PM INF executed block app_hash=826541369149F3F8DE5A53F5B4174C51975BCC665F0E73B1DB69D9206E4F5563 height=6 module=BlockManager -6:56PM INF indexed block events height=6 module=txindex -6:57PM INF Creating and publishing block height=7 module=BlockManager -6:57PM INF finalized block block_app_hash=8C751BA9EDCFAD7F92E0E940995B0155BDC856070B876373299E7820C32F0B8B height=7 module=BlockManager num_txs_res=0 num_val_updates=0 -6:57PM INF executed block app_hash=8C751BA9EDCFAD7F92E0E940995B0155BDC856070B876373299E7820C32F0B8B height=7 module=BlockManager -6:57PM INF indexed block events height=7 module=txindex -6:57PM INF Creating and publishing block height=8 module=BlockManager -6:57PM INF finalized block block_app_hash=C93D26AEE9B611952C8122DEB67DBAD95B3604F5C9C5DFBA95A3E7A4CF0AF641 height=8 module=BlockManager num_txs_res=0 num_val_updates=0 -... -``` - -Since our rollup is running in a docker container, we want to enter the docker container to interact with it via the Rollkit CLI. We can do this by running: - -```bash -docker exec -it $WORDLE sh -``` - - -You can see the two accounts that were created by running the following command: - -```bash -rollkit keys list --keyring-backend test -``` - -You should see the following output: - -```bash -- address: cosmos17sdyjz0zjsefd79k8nt9uvvfk732d0w7tzxfck - name: alice - pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AkWmEZ0oYewolMY9AqJspcMDsoVPoG7t24r93rZaTuBZ"}' - type: local -- address: cosmos13uevxd5zen4ywjuqr7cz4903uyktqm0swvfjly - name: bob - pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AnqNse6cuVtx5AIUN9U3vxNq7rw9e2G0R4pCPRySqzAn"}' - type: local -``` +### 🚀 Interacting with the chain {#interacting-with-the-chain} -Let's have Bob submit a Wordle for the day: +In another window, from the `~/wordle` directory (where rollkit.toml is located) run the following command to submit a Wordle from `alice`: ```bash -rollkit tx wordle submit-wordle giant --from bob --keyring-backend test --chain-id wordle -b async +rollkit tx wordle submit-wordle giant --from alice --keyring-backend test --chain-id wordle -b async ``` @@ -880,16 +615,15 @@ body: memo: "" messages: - '@type': /wordle.wordle.MsgSubmitWordle - creator: cosmos13uevxd5zen4ywjuqr7cz4903uyktqm0swvfjly + creator: cosmos1mr9p6wql4mmtp9xvsuklpw7fxx6g0qte7qd5q9 word: giant non_critical_extension_options: [] timeout_height: "0" signatures: [] - -confirm transaction before signing and broadcasting [y/N]: // [!code focus] +confirm transaction before signing and broadcasting [y/N]: ``` -Confirm with a Y. +Confirm with a `y`. You will then get a response with a transaction hash as shown here: @@ -909,7 +643,7 @@ tx: null txhash: F159E11116EC9505FC2C0D97E605357FEC0F3DAE06B57BFB17EA6A548905043E ``` -Let's hold onto the txhash as we will need it to query the transaction. +Let's grab the `txhash` for later: ```bash TX_HASH=F159E11116EC9505FC2C0D97E605357FEC0F3DAE06B57BFB17EA6A548905043E @@ -921,128 +655,64 @@ the block yet or if there are any errors. ```bash -rollkit query tx --type=hash $TX_HASH --chain-id wordle --output json | jq +rollkit query tx --type=hash $TX_HASH --output json | jq -r '.raw_log' ``` This should display an output like the following: ```json -{"events":[{"type":"message","at{ - "height": "843", - "txhash": "2B80B61FA136132F929CB288E17E640BEFAD01548A9178CAF9809BBC9154AA4E", - "codespace": "", - "code": 0, - "data": "12280A262F776F72646C652E776F72646C652E4D73675375626D6974576F72646C65526573706F6E7365", - "raw_log": "", // [!code focus] - "logs": [], - "info": "", - "gas_wanted": "200000", - "gas_used": "84990", - "tx": { - "@type": "/cosmos.tx.v1beta1.Tx", - "body": { - "messages": [ - { - "@type": "/wordle.wordle.MsgSubmitWordle", - "creator": "cosmos13uevxd5zen4ywjuqr7cz4903uyktqm0swvfjly", - "word": "giant" - } - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - ... - }, - "timestamp": "2024-07-16T14:24:45Z", - "events": [ - ... - ] -} +[{"events":[{"type":"message","attributes":[{"key":"action","value":"submit_wordle" +}]}]}] ``` -That's a lot of information! The main thing we are looking at right now is the log to see if there were any errors. We can filter the output with `-r '.raw_logs'`. Let's run the command again. - -```bash -rollkit query tx --type=hash $TX_HASH --chain-id wordle --output json | jq -r '.raw_log' -``` - -Now you shouldn't see any output from this because there was no error. Excellent! - -Let's test out a few things for fun. First let's try submitting an invalid guess. - -The following command as some shortcuts to auto confirm the transaction and store the txhash in a variable for you: +Test out a few things for fun: ```bash -TX_HASH=$(rollkit tx wordle submit-guess 12345 --from bob --keyring-backend test --chain-id wordle -b async -y | grep txhash | cut -d ' ' -f 2) +rollkit tx wordle submit-guess 12345 --from bob --keyring-backend test --chain-id wordle -b async -y ``` -Now let's query the transaction: - -```bash -rollkit query tx --type=hash $TX_HASH --chain-id wordle --output json | jq -r '.raw_log' -``` - -You will see the following response because you submitted integers: - -```bash -failed to execute message; message index: 0: Guess Must Only Consist of Alphabet Letters!: invalid request -``` +After confirming the transaction, query the `txhash` +given the same way you did above. You will see the response shows +an Invalid Error because you submitted integers. -Now let's try a guess that is too long: +Now try: ```bash -TX_HASH=$(rollkit tx wordle submit-guess toolong --from bob --keyring-backend test --chain-id wordle -b async -y | grep txhash | cut -d ' ' -f 2) -``` - -And let's query the transaction: - -```bash -rollkit query tx --type=hash $TX_HASH --chain-id wordle --output json | jq -r '.raw_log' +rollkit tx wordle submit-guess ABCDEFG --from bob --keyring-backend test --chain-id wordle -b async -y ``` -You will see the following response: - -```bash -failed to execute message; message index: 0: Guess Must Be A 5 Letter Word!: invalid request -``` +After confirming the transaction, query the `txhash` given the same +way you did above. You will see the response shows +an Invalid Error because you submitted a word larger than 5 characters. Now try to submit another wordle even though one was already submitted ```bash -TX_HASH=$(rollkit tx wordle submit-wordle meter --from bob --keyring-backend test --chain-id wordle -b async -y | grep txhash | cut -d ' ' -f 2) -``` - - -And let's query the transaction: - -```bash -rollkit query tx --type=hash $TX_HASH --chain-id wordle --output json | jq -r '.raw_log' +rollkit tx wordle submit-wordle meter --from bob --keyring-backend test --chain-id wordle -b async -y ``` -You will see the following response: - -```bash -failed to execute message; message index: 0: Wordle of the Day is Already Submitted: invalid request -``` +After submitting the transactions and confirming, query the `txhash` +given the same way you did above. You will get an error that a wordle +has already been submitted for the day. -Alright, enough testing the error cases, let’s try to guess a five letter word: +Now let’s try to guess a five letter word: ```bash -TX_HASH=$(rollkit tx wordle submit-guess least --from bob --keyring-backend test --chain-id wordle -b async -y | grep txhash | cut -d ' ' -f 2) +rollkit tx wordle submit-guess least --from bob --keyring-backend test --chain-id wordle -b async -y ``` -Given you didn’t guess the correct word, it will increment the guess count for wordle-key's account. +After submitting the transactions and confirming, query the `txhash` +given the same way you did above. Given you didn’t guess the correct +word, it will increment the guess count for bob's account. We can verify this by querying the list: @@ -1053,38 +723,9 @@ rollkit q wordle list-guess --output json This outputs all Guess objects submitted so far, with the index being today’s date and the address of the submitter. -```json -{ - "guess": [ - { - "index": "7df4afc694ef096cb285544db57282bbdc28fcbdf75f7457d5dec4bf4367a9de", - "word": "6bab65a2bddec8af5dbc7f8b24ef22fc58acc385abcde4a6c4e34387d3b29261", - "submitter": "cosmos13uevxd5zen4ywjuqr7cz4903uyktqm0swvfjly", - "count": "1" - } - ], - "pagination": { - "total": "1" - } -} -``` - With that, we implemented a basic example of Wordle using -Cosmos-SDK and Ignite and Rollkit. - -You can exit out of your docker container with: - -```bash -exit -``` - -Then you can shut down your rollup and kurtosis by running: - -```bash -kurtosis clean -a -``` - -Read on to how you can extend the code base. +Cosmos-SDK and Ignite and Rollkit. Read on to how you can +extend the code base. ### 🔮 Extending in the future {#extending-in-the-future} @@ -1104,4 +745,4 @@ There are many ways this codebase can be extended: ## 🎉 Next steps -Congratulations! You've built a Wordle app using Cosmos-SDK and Rollkit. Now, explore connecting your rollup to DA networks like Celestia. +Congratulations! You've built a Wordle app using Cosmos-SDK and Rollkit. Now, explore connecting your chain to DA networks like Celestia.