Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update gm tutorial parts 2 testnet and 3 mainnet #290

Merged
merged 13 commits into from
Jan 10, 2024
6 changes: 3 additions & 3 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ function sidebarHome() {
items: [
// { text: 'Starter Rollup with Docker', link: '/tutorials/rollup-docker'},
// { text: 'Starter Rollup', link: '/tutorials/starter-rollup'},
{ 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 rollup: Part 1, local devnet', link: '/tutorials/gm-world'},
{ text: 'GM world rollup: Part 2, testnet', link: '/tutorials/gm-world-testnet'},
{ text: 'GM world rollup: Part 3, 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
2 changes: 1 addition & 1 deletion scripts/gm/init-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jq --argjson pubKey "$PUB_KEY" '.consensus["validators"]=[{"address": "'$ADDRESS
[ -f restart-local.sh ] && rm restart-local.sh
echo "DA_BLOCK_HEIGHT=$DA_BLOCK_HEIGHT" >> restart-local.sh

echo "gmd start --rollkit.aggregator true --rollkit.da_address=":26650" --rollkit.da_start_height \$DA_BLOCK_HEIGHT --rpc.laddr tcp://127.0.0.1:36657 --p2p.laddr \"0.0.0.0:36656\"" >> restart-local.sh
echo "gmd start --rollkit.aggregator true --rollkit.da_address=":26650" --rollkit.da_start_height \$DA_BLOCK_HEIGHT --rpc.laddr tcp://127.0.0.1:36657 --p2p.laddr \"0.0.0.0:36656\" --minimum-gas-prices="0.025stake"" >> restart-local.sh

# start the chain
gmd start --rollkit.aggregator true --rollkit.da_address=":26650" --rollkit.da_start_height $DA_BLOCK_HEIGHT --rpc.laddr tcp://127.0.0.1:36657 --p2p.laddr "0.0.0.0:36656" --minimum-gas-prices="0.025stake"
Expand Down
34 changes: 18 additions & 16 deletions scripts/gm/init-mainnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ CHAINFLAG="--chain-id ${CHAIN_ID}"
TOKEN_AMOUNT="10000000000000000000000000stake"
STAKING_AMOUNT="1000000000stake"

# use a custom namespace ID for your chain
# this example uses "rollkit" in hexadecimal
NAMESPACE=000000726f6c6c6b6974
echo $NAMESPACE

# query the DA Layer start height, in this case we are querying
# an RPC endpoint provided by Celestia Labs. The RPC endpoint is
# to allow users to interact with Celestia's core network by querying
# the node's state and broadcasting transactions on the Celestia
# network. This is for Arabica, if using another network, change the RPC.
DA_BLOCK_HEIGHT=$(curl https://rpc.lunaroasis.net/block |jq -r '.result.block.header.height')
echo $DA_BLOCK_HEIGHT
DA_BLOCK_HEIGHT=$(curl https://rpc.lunaroasis.net/block | jq -r '.result.block.header.height')
echo -e "\n Your DA_BLOCK_HEIGHT is $DA_BLOCK_HEIGHT \n"

# build the gm chain with Rollkit
ignite chain build
Expand All @@ -36,19 +31,26 @@ gmd keys add $KEY_NAME --keyring-backend test
gmd keys add $KEY_2_NAME --keyring-backend test

# add these as genesis accounts
gmd add-genesis-account $KEY_NAME $TOKEN_AMOUNT --keyring-backend test
gmd add-genesis-account $KEY_2_NAME $TOKEN_AMOUNT --keyring-backend test
gmd genesis add-genesis-account $KEY_NAME $TOKEN_AMOUNT --keyring-backend test
gmd genesis add-genesis-account $KEY_2_NAME $TOKEN_AMOUNT --keyring-backend test

# set the staking amounts in the genesis transaction
gmd gentx $KEY_NAME $STAKING_AMOUNT --chain-id $CHAIN_ID --keyring-backend test
gmd genesis gentx $KEY_NAME $STAKING_AMOUNT --chain-id $CHAIN_ID --keyring-backend test

# collect genesis transactions
gmd collect-gentxs
gmd genesis collect-gentxs

# copy centralized sequencer address into genesis.json
# Note: validator and sequencer are used interchangeably here
ADDRESS=$(jq -r '.address' ~/.gm/config/priv_validator_key.json)
PUB_KEY=$(jq -r '.pub_key' ~/.gm/config/priv_validator_key.json)
jq --argjson pubKey "$PUB_KEY" '.consensus["validators"]=[{"address": "'$ADDRESS'", "pub_key": $pubKey, "power": "1000", "name": "Rollkit Sequencer"}]' ~/.gm/config/genesis.json > temp.json && mv temp.json ~/.gm/config/genesis.json

# create a restart-mainnet.sh file to restart the chain later
[ -f restart-mainnet.sh ] && rm restart-mainnet.sh
echo "DA_BLOCK_HEIGHT=$DA_BLOCK_HEIGHT" >> restart-mainnet.sh

# export the Celestia light node's auth token to allow you to submit
# PayForBlobs to Celestia's data availability network
# this is for Arabica, if using another network, change the network name
AUTH_TOKEN=$(celestia light auth write)
echo "gmd start --rollkit.aggregator true --rollkit.da_address=":26650" --rollkit.da_start_height \$DA_BLOCK_HEIGHT --rpc.laddr tcp://127.0.0.1:36657 --p2p.laddr \"0.0.0.0:36656\" --minimum-gas-prices="0.025stake"" >> restart-mainnet.sh

# start the chain
gmd start --rollkit.aggregator true --rollkit.da_layer celestia --rollkit.da_config='{"base_url":"http://localhost:26658","timeout":60000000000,"fee":600000,"gas_limit":6000000,"auth_token":"'$AUTH_TOKEN'"}' --rollkit.namespace_id $NAMESPACE --rollkit.da_start_height $DA_BLOCK_HEIGHT --rollkit.lazy_aggregator
gmd start --rollkit.aggregator true --rollkit.da_address=":26650" --rollkit.da_start_height $DA_BLOCK_HEIGHT --rpc.laddr tcp://127.0.0.1:36657 --p2p.laddr "0.0.0.0:36656" --minimum-gas-prices="0.025stake"
29 changes: 13 additions & 16 deletions scripts/gm/init-testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ CHAINFLAG="--chain-id ${CHAIN_ID}"
TOKEN_AMOUNT="10000000000000000000000000stake"
STAKING_AMOUNT="1000000000stake"

# create a random Namespace ID for your rollup to post blocks to
NAMESPACE=$(openssl rand -hex 8)
echo $NAMESPACE

# query the DA Layer start height, in this case we are querying
# an RPC endpoint provided by Celestia Labs. The RPC endpoint is
# to allow users to interact with Celestia's core network by querying
# the node's state and broadcasting transactions on the Celestia
# network. This is for Arabica, if using another network, change the RPC.
DA_BLOCK_HEIGHT=$(curl https://rpc-arabica-9.consensus.celestia-arabica.com/block |jq -r '.result.block.header.height')
echo $DA_BLOCK_HEIGHT
DA_BLOCK_HEIGHT=$(curl https://rpc.celestia-arabica-11.com/block | jq -r '.result.block.header.height')
echo -e "\n Your DA_BLOCK_HEIGHT is $DA_BLOCK_HEIGHT \n"

# build the gm chain with Rollkit
ignite chain build
Expand All @@ -35,25 +31,26 @@ gmd keys add $KEY_NAME --keyring-backend test
gmd keys add $KEY_2_NAME --keyring-backend test

# add these as genesis accounts
gmd add-genesis-account $KEY_NAME $TOKEN_AMOUNT --keyring-backend test
gmd add-genesis-account $KEY_2_NAME $TOKEN_AMOUNT --keyring-backend test
gmd genesis add-genesis-account $KEY_NAME $TOKEN_AMOUNT --keyring-backend test
gmd genesis add-genesis-account $KEY_2_NAME $TOKEN_AMOUNT --keyring-backend test

# set the staking amounts in the genesis transaction
gmd gentx $KEY_NAME $STAKING_AMOUNT --chain-id $CHAIN_ID --keyring-backend test
gmd genesis gentx $KEY_NAME $STAKING_AMOUNT --chain-id $CHAIN_ID --keyring-backend test

# collect genesis transactions
gmd collect-gentxs
gmd genesis collect-gentxs

# copy centralized sequencer address into genesis.json
# Note: validator and sequencer are used interchangeably here
ADDRESS=$(jq -r '.address' ~/.gm/config/priv_validator_key.json)
PUB_KEY=$(jq -r '.pub_key' ~/.gm/config/priv_validator_key.json)
jq --argjson pubKey "$PUB_KEY" '. + {"validators": [{"address": "'$ADDRESS'", "pub_key": $pubKey, "power": "1000", "name": "Rollkit Sequencer"}]}' ~/.gm/config/genesis.json > temp.json && mv temp.json ~/.gm/config/genesis.json
jq --argjson pubKey "$PUB_KEY" '.consensus["validators"]=[{"address": "'$ADDRESS'", "pub_key": $pubKey, "power": "1000", "name": "Rollkit Sequencer"}]' ~/.gm/config/genesis.json > temp.json && mv temp.json ~/.gm/config/genesis.json

# create a restart-testnet.sh file to restart the chain later
[ -f restart-testnet.sh ] && rm restart-testnet.sh
echo "DA_BLOCK_HEIGHT=$DA_BLOCK_HEIGHT" >> restart-testnet.sh

# export the Celestia light node's auth token to allow you to submit
# PayForBlobs to Celestia's data availability network
# this is for Arabica, if using another network, change the network name
export AUTH_TOKEN=$(celestia light auth write --p2p.network arabica)
echo "gmd start --rollkit.aggregator true --rollkit.da_address=":26650" --rollkit.da_start_height \$DA_BLOCK_HEIGHT --rpc.laddr tcp://127.0.0.1:36657 --p2p.laddr \"0.0.0.0:36656\" --minimum-gas-prices="0.025stake"" >> restart-testnet.sh

# start the chain
gmd start --rollkit.aggregator true --rollkit.da_layer celestia --rollkit.da_config='{"base_url":"http://localhost:26658","timeout":60000000000,"fee":600000,"gas_limit":6000000,"auth_token":"'$AUTH_TOKEN'"}' --rollkit.namespace_id $NAMESPACE --rollkit.da_start_height $DA_BLOCK_HEIGHT
gmd start --rollkit.aggregator true --rollkit.da_address=":26650" --rollkit.da_start_height $DA_BLOCK_HEIGHT --rpc.laddr tcp://127.0.0.1:36657 --p2p.laddr "0.0.0.0:36656" --minimum-gas-prices="0.025stake"
4 changes: 4 additions & 0 deletions tutorials/cosmwasm.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 🗞️ CosmWasm rollup

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

CosmWasm is a smart contracting platform built for the Cosmos
ecosystem by making use of [WebAssembly](https://webassembly.org) (Wasm)
to build smart contracts for Cosmos-SDK. In this tutorial, we will be
Expand Down
6 changes: 5 additions & 1 deletion tutorials/full-and-sequencer-node.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Full and sequencer node rollup setup

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

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

Expand All @@ -17,7 +21,7 @@ This is the same way that celestia-node syncs blocks over p2p.
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).
in [part 1](./gm-world).

## Getting started

Expand Down
107 changes: 87 additions & 20 deletions tutorials/gm-world-mainnet.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,80 @@
# GM world rollup: Part three
# GM world rollup: Part 3

:::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
This tutorial is part 3 of the GM world rollup tutorials. In this tutorial,
it is expected that you've completed [part 1](./gm-world.md) and
[part 2](./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.
### 🪶 Run a Celestia light node {#run-celestia-node}

For this portion, you will need to stop the rollup that you have
running from above using `Control + C` in the terminal.
1. Fully sync and fund a light node
on Arabica devnet (`arabica-11`).
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](https://docs.celestia.org/nodes/light-node).
After the node is synced, stop the light node.

2. Use
[`celestia-da`](https://github.com/rollkit/celestia-da)
to connect to Rollkit. Your node does not need to be running
when you start `celestia-da`.

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.
Run this command to start celestia-da and 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
docker run -d \
-e NODE_TYPE=light \
-e P2P_NETWORK=celestia \
-p 26650:26650 \
-p 26658:26658 \
-p 26659:26659 \
-v $HOME/.celestia-light/:/home/celestia/.celestia-light/ \
ghcr.io/rollkit/celestia-da:v0.12.3 \
celestia-da light start \
--p2p.network=celestia \
--da.grpc.namespace=000000676d776f726c64 \
--da.grpc.listen=0.0.0.0:26650 \
--core.ip rpc.celestia.pops.one \
--gateway
```

2. Download the script for deploying to Celestia's Mainnet Beta:
:::tip
You can either use the default `000000676d776f726c64`, "gmworld" in
plaintext, namespace above, or set your own by using a command
similar to this:

```bash
NAMESPACE_ID=$(echo -n $NAMESPACE_NAME | openssl dgst -sha256 -binary | head -c | xxd -p)"
```

[Learn more about namespaces](https://celestiaorg.github.io/celestia-app/specs/namespace.html)

:::

After you have Go and Ignite CLI installed, and `celestia-da`
running on your machine, you're ready to run your own
sovereign 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
```

### Start the rollup on mainnet

For this portion, you will need to stop the rollup that you have
running from parts 1 and 2 of the tutorial,
using `Control + C` in the terminal.

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

<!-- markdownlint-disable MD013 -->
```bash
Expand All @@ -34,19 +83,37 @@ which is the chain ID for Mainnet Beta.
```
<!-- markdownlint-enable MD013 -->

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

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

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

5. Watch as your rollup posts blocks to Celestia!
4. Watch as your rollup posts blocks to Celestia!

5. View your rollup by
[finding your namespace or account Celenium](https://celenium.io).

To deploy to a different DA layer, modify the script to fit your architecture.
[View the example rollup's namespace on Celenium](https://celenium.io/namespace/000000000000000000000000000000000000000000676d776f726c64).

#### Restarting your rollup

When you ran `init-mainnet.sh`, the script generated a script called
`restart-mainnet.sh` in the `$HOME/gm` directory for you to use to
restart your rollup.

In order to do so, restart `celestia-da` and then run:

```bash
bash restart-mainnet.sh
```

## Next steps

Congratulations! You have a Rollkit rollup running on 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