Skip to content

Commit

Permalink
feat: implement 3 pages to break tutorial up
Browse files Browse the repository at this point in the history
add construction flags for WIP pages
resolves #268
  • Loading branch information
jcstein committed Jan 6, 2024
1 parent 50a64c2 commit ab7b1f0
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 281 deletions.
6 changes: 4 additions & 2 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ function sidebarHome() {
items: [
// { text: 'Starter Rollup with Docker', link: '/tutorials/rollup-docker'},
// { text: 'Starter Rollup', link: '/tutorials/starter-rollup'},
{ text: 'GM World rollup', link: '/tutorials/gm-world'},
{ text: 'GM World frontend', link: '/tutorials/gm-world-frontend'},
{ text: 'GM world rollup: Part one, local devnet', link: '/tutorials/gm-world'},
{ text: 'GM world rollup: Part two, testnet', link: '/tutorials/gm-world-testnet'},
{ text: 'GM world rollup: Part three, mainnet', link: '/tutorials/gm-world-mainnet'},
{ text: 'GM world frontend', link: '/tutorials/gm-world-frontend'},
{ text: 'Recipe Book rollup', link: '/tutorials/recipe-book'},
{ text: 'How to restart your rollup', link: '/tutorials/restart-rollup'},
]
Expand Down
4 changes: 2 additions & 2 deletions learn/building-and-deploying-a-rollup.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ You can get started with the following tutorials:

## 1. Beginner {#beginner}

- [GM World](/tutorials/gm-world)
- [GM World frontend](/tutorials/gm-world-frontend)
- [GM world](/tutorials/gm-world)
- [GM world frontend](/tutorials/gm-world-frontend)
- [Recipe Book](/tutorials/recipe-book)
- [Restart your rollup](/tutorials/restart-rollup)

Expand Down
4 changes: 2 additions & 2 deletions learn/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ If you're familiar with Rollkit, you may want to skip to the [tutorials section]

#### Beginner

- [GM World rollup](/tutorials/gm-world)
- [GM World frontend](/tutorials/gm-world-frontend)
- [GM world rollup](/tutorials/gm-world)
- [GM world frontend](/tutorials/gm-world-frontend)
- [Recipe Book rollup](/tutorials/recipe-book)
- [How to restart your rollup](/tutorials/restart-rollup)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/block-times.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# How to change speed of block production

If you have gone through both the [GM World](./gm-world) and the
If you have gone through both the [GM world](./gm-world) and the
[Full and sequencer node rollup setup](./full-and-sequencer-node)
already, you're now ready to experiment with faster block times.

Expand Down
4 changes: 2 additions & 2 deletions tutorials/full-and-sequencer-node.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Full and sequencer node rollup setup

This guide will cover how to set up the GM World rollup example as
This guide will cover how to set up the GM world rollup example as
a multi-node network using a full and sequencer node.

## About
Expand All @@ -14,7 +14,7 @@ This is the same way that celestia-node syncs blocks over p2p.

## Prerequisites

First, you'll need to complete the [GM World](./gm-world) tutorial.
First, you'll need to complete the [GM world](./gm-world) tutorial.

In this demo, we'll be using the local-celestia-devnet setup used
in [Part One](./gm-world#part-one).
Expand Down
6 changes: 3 additions & 3 deletions tutorials/gm-world-frontend.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GM World frontend tutorial
# GM world frontend tutorial

In this tutorial, we'll learn how to use [Cosmology](https://cosmology.tech/) to
create a frontend for our [GM World](/tutorials/gm-world) rollup.
create a frontend for our [GM world](/tutorials/gm-world) rollup.

Cosmology enables developers to build web3 apps in the Interchain Ecosystem.
With Cosmology, it's simple to begin building apps that communicate with
Expand All @@ -17,7 +17,7 @@ In the end, you'll have something that looks like this
## Getting started

In order to complete this tutorial you will need to have completed
the [GM World tutorial](/tutorials/gm-world). This requires a running rollup
the [GM world tutorial](/tutorials/gm-world). This requires a running rollup
on your local machine.

## Setting up the frontend
Expand Down
52 changes: 52 additions & 0 deletions tutorials/gm-world-mainnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# GM world rollup: Part three

:::warning
This tutorial is under construction. 🏗️
:::

This tutorial is part three of the GM world rollup tutorials. In this tutorial,
it is expected that you've completed [part one](./gm-world.md) and
[part two](./gm-world-testnet.md) of the tutorial and are
familiar with running a local rollup devnet and posting to a
Celestia testnet.

## Deploying to Celestia Mainnet Beta

In this section, we will cover how to deploy to Celestia's Mainnet Beta.

For this portion, you will need to stop the rollup that you have
running from above using `Control + C` in the terminal.

1. Start your Celestia light node with state access
(using the `--core.ip string` flag), this time on `celestia`,
which is the chain ID for Mainnet Beta.

```bash
celestia light start --core.ip rpc.celestia.pops.one
```

2. Download the script for deploying to Celestia's Mainnet Beta:

<!-- markdownlint-disable MD013 -->
```bash
# From inside the `gm` directory
wget https://raw.githubusercontent.com/rollkit/docs/main/scripts/gm/init-mainnet.sh
```
<!-- markdownlint-enable MD013 -->

3. Ensure that the account for your light node is funded.

4. Run the `init-mainnet.sh` script:

```bash
bash init-mainnet.sh
```

5. Watch as your rollup posts blocks to Celestia!

To deploy to a different DA layer, modify the script to fit your architecture.

## Next steps

If you're interested in setting up a full node alongside your sequencer,
see the [Full and sequencer node rollup setup](./full-and-sequencer-node) tutorial.
235 changes: 235 additions & 0 deletions tutorials/gm-world-testnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
# GM world rollup: Part two

:::warning
This tutorial is under construction. 🏗️
:::

## Deploying to a Celestia testnet

This tutorial is part two of the GM world rollup tutorials. In this tutorial,
it is expected that you've completed [part one](./gm-world.md) of
the tutorial and are familiar with running a local rollup devnet.

### 🪶 Run a Celestia light node {#run-celestia-node}

Follow instructions to install and start your Celestia data availability
layer light node selecting the Arabica network. You can
find instructions to install and run the node [here](https://docs.celestia.org/nodes/light-node).

After you have Go and Ignite CLI installed, and your Celestia Light
Node running on your machine, you're ready to build, test, and launch your own
sovereign rollup.

An example start command on `arabica-9` would look like this:

```bash
celestia light start --core.ip consensus-full-arabica-9.celestia-arabica.com --p2p.network arabica
```

### 💬 Say gm world {#say-gm-world}

Now, we're going to get our blockchain to say `gm world!` - in order to do so
you need to make the following changes:

* Modify a protocol buffer file
* Create a keeper query function that returns data

Protocol buffer files contain proto RPC calls that define Cosmos SDK queries
and message handlers, and proto messages that define Cosmos SDK types. The RPC
calls are also responsible for exposing an HTTP API.

The `Keeper` is required for each Cosmos SDK module and is an abstraction for
modifying the state of the blockchain. Keeper functions allow us to query or
write to the state.

#### ✋ Create your first query {#create-first-query}

**Open a new terminal instance that is not the
same that you started the chain in.**

In your new terminal, `cd` into the `gm` directory and run this command
to create the `gm` query:

```bash
ignite scaffold query gm --response text
```

Response:

```bash
modify proto/gm/gm/query.proto
modify x/gm/client/cli/query.go
create x/gm/client/cli/query_gm.go
create x/gm/keeper/query_gm.go

🎉 Created a query `gm`.
```

What just happened? `query` accepts the name of the query (`gm`), an optional
list of request parameters (empty in this tutorial), and an optional
comma-separated list of response field with a `--response` flag (`text` in this
tutorial).

Navigate to the `gm/proto/gm/gm/query.proto` file, you’ll see that `Gm` RPC has
been added to the `Query` service:

```proto title="gm/proto/gm/gm/query.proto"
service Query {
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/gm/gm/params";
}
rpc Gm(QueryGmRequest) returns (QueryGmResponse) {
option (google.api.http).get = "/gm/gm/gm";
}
}
```

The `Gm` RPC for the `Query` service:

* is responsible for returning a `text` string
* Accepts request parameters (`QueryGmRequest`)
* Returns response of type `QueryGmResponse`
* The `option` defines the endpoint that is used by gRPC to generate an HTTP API

#### 📨 Query request and response types {#query-request-and-response-types}

In the same file, we will find:

* `QueryGmRequest` is empty because it does not require parameters
* `QueryGmResponse` contains `text` that is returned from the chain

```proto title="gm/proto/gm/gm/query.proto"
message QueryGmRequest {
}
message QueryGmResponse {
string text = 1;
}
```

#### 👋 Gm keeper function {#gm-keeper-function}

The `gm/x/gm/keeper/query_gm.go` file contains the `Gm` keeper function that
handles the query and returns data.

<!-- markdownlint-disable MD013 -->
<!-- markdownlint-disable MD010 -->
```go title="gm/x/gm/keeper/query_gm.go"
func (k Keeper) Gm(goCtx context.Context, req *types.QueryGmRequest) (*types.QueryGmResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
ctx := sdk.UnwrapSDKContext(goCtx)
_ = ctx
return &types.QueryGmResponse{}, nil
}
```
<!-- markdownlint-enable MD010 -->
<!-- markdownlint-enable MD013 -->

The `Gm` function performs the following actions:

* Makes a basic check on the request and throws an error if it’s `nil`
* Stores context in a `ctx` variable that contains information about the
environment of the request
* Returns a response of type `QueryGmResponse`

Currently, the response is empty and you'll need to update the keeper function.

Our `query.proto` file defines that the response accepts `text`. Use your text
editor to modify the keeper function in `gm/x/gm/keeper/query_gm.go` .

<!-- markdownlint-disable MD013 -->
<!-- markdownlint-disable MD010 -->
```go title="gm/x/gm/keeper/query_gm.go"
func (k Keeper) Gm(goCtx context.Context, req *types.QueryGmRequest) (*types.QueryGmResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
ctx := sdk.UnwrapSDKContext(goCtx)
_ = ctx
return &types.QueryGmResponse{Text: "gm world!"}, nil // [!code focus]
}
```
<!-- markdownlint-enable MD010 -->
<!-- markdownlint-enable MD013 -->

#### 🟢 Start your sovereign rollup {#start-your-sovereign-rollup}

We have a handy `init-testnet.sh` found in this repo
[here](https://github.com/rollkit/docs/tree/main/scripts/gm).

We can copy it over to our directory with the following commands:

<!-- markdownlint-disable MD013 -->
```bash
# From inside the `gm` directory
wget https://raw.githubusercontent.com/rollkit/docs/main/scripts/gm/init-testnet.sh
```
<!-- markdownlint-enable MD013 -->

This copies over our `init-testnet.sh` script to initialize our
`gm` rollup.

You can view the contents of the script to see how we
initialize the gm rollup.

##### Clear previous chain history

Before starting the rollup, we need to remove the old project folders:

```bash
rm -r $HOME/go/bin/gmd && rm -rf $HOME/.gm
```

##### Set the auth token for your light node

You will also need to set the auth token for your Celestia light node
before running the rollup. In the terminal that you will run the
`init-testnet.sh` script in, run the following:

```bash
export AUTH_TOKEN=$(celestia light auth admin --p2p.network arabica)
```

##### Start the new chain {#start-the-new-chain}

Now, you can initialize the script with the following command:

```bash
bash init-testnet.sh
```

With that, we have kickstarted our second `gmd` network!

The `query` command has also scaffolded
`x/gm/client/cli/query_gm.go` that
implements a CLI equivalent of the gm query and mounted this command in
`x/gm/client/cli/query.go`.

In a separate window, run the following command:

```bash
gmd q gm gm
```

We will get the following JSON response:

```bash
text: gm world!
```

![gm.png](/gm/gm.png)

Congratulations 🎉 you've successfully built your first rollup and queried it!

If you're interested in looking at the demo repository
for this tutorial, you can at [https://github.com/rollkit/gm](https://github.com/rollkit/gm).

## Next steps

In the next tutorial, you'll learn how to post data to Celestia's
Mainnet Beta.

If you're interested in setting up a full node alongside your sequencer,
see the [Full and sequencer node rollup setup](./full-and-sequencer-node) tutorial.
Loading

0 comments on commit ab7b1f0

Please sign in to comment.