Skip to content

Commit

Permalink
feat: update wordle
Browse files Browse the repository at this point in the history
  • Loading branch information
jcstein committed Jan 12, 2024
1 parent 5e8331c commit 511d6ac
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 38 deletions.
27 changes: 12 additions & 15 deletions scripts/wordle/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,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 wordle chain with Rollkit
ignite chain build
Expand All @@ -33,24 +29,25 @@ wordled init $VALIDATOR_NAME --chain-id $CHAIN_ID
wordled keys add $KEY_NAME --keyring-backend test

# add a genesis account
wordled add-genesis-account $KEY_NAME $TOKEN_AMOUNT --keyring-backend test
wordled genesis add-genesis-account $KEY_NAME $TOKEN_AMOUNT --keyring-backend test

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

# collect genesis transactions
wordled collect-gentxs
wordled genesis collect-gentxs

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

# create a restart-testnet.sh file to restart the chain later
[ -f restart-wordle.sh ] && rm restart-wordle.sh
echo "DA_BLOCK_HEIGHT=$DA_BLOCK_HEIGHT" >> restart-wordle.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 "wordled 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-wordle.sh

# start the chain
wordled 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
wordled 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"
80 changes: 57 additions & 23 deletions tutorials/wordle.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# 🕹️ Wordle app

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

![wordle-app](/wordle/wordle.png)

This tutorial guide will go over building a cosmos-sdk app
Expand Down Expand Up @@ -94,7 +90,7 @@ You can read more about Ignite [here](https://docs.ignite.com).
To install Ignite, you can run this command in your terminal:

```bash
curl https://get.ignite.com/cli@v0.27.1! | bash
curl https://get.ignite.com/cli@v28.1.0! | bash
sudo mv ignite /usr/local/bin/
```

Expand Down Expand Up @@ -179,24 +175,12 @@ Rollkit on our codebase.

Run the following command inside the `wordle` directory.

::: code-group

```bash [local-celestia-devnet]
go mod edit -replace github.com/cosmos/cosmos-sdk=github.com/rollkit/[email protected]
go mod edit -replace github.com/gogo/protobuf=github.com/regen-network/[email protected]
go mod tidy
go mod download
```

```bash [Arabica Devnet]
go mod edit -replace github.com/cosmos/cosmos-sdk=github.com/rollkit/[email protected]
go mod edit -replace github.com/gogo/protobuf=github.com/regen-network/[email protected]
```bash
go mod edit -replace github.com/cosmos/cosmos-sdk=github.com/rollkit/[email protected]
go mod tidy
go mod download
```

:::

With that, we have Rollkit changes added to the project directory. Now,
let's build the Wordle app!

Expand Down Expand Up @@ -567,10 +551,57 @@ compile the blockchain and take it out for a test drive.

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

Follow instructions to install and start your Celestia Data
Availability layer Light Node selecting the network that
you had previously used. You can find instructions to install
and run the node [here](https://docs.celestia.org/nodes/light-node).
Follow instructions to install and start your Celestia Data Availability
layer Light Node selecting the Arabica Devnet. 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.

Be sure you have initialized your node before trying to start it.
Your start command should look similar to:

<!-- markdownlint-disable MD013 -->
```bash
celestia light start --p2p.network arabica
```
<!-- markdownlint-enable MD013 -->

After you have synced your node and funded it from the faucet,
you will need to stop it to restart it with `celestia-da`.

To do so, use the following command:

```bash
docker run -d \
-e NODE_TYPE=light \
-e P2P_NETWORK=arabica \
-p 26650:26650 \
-p 26658:26658 \
-p 26659:26659 \
-v $HOME/.celestia-light-arabica-11/:/home/celestia/.celestia-light-arabica-11/ \
ghcr.io/rollkit/celestia-da:v0.12.4-rc1 \
celestia-da light start \
--p2p.network=arabica \
--da.grpc.namespace=00000000776f72646c65 \
--da.grpc.listen=0.0.0.0:26650 \
--core.ip validator-1.celestia-arabica-11.com \
--gateway
```

:::tip
You can either use the default `00000000776f72646c65`, "wordle" in
plaintext, namespace above, or set your own by using a command
similar to this (or, you could get creative 😎):

```bash
openssl rand -hex 10
```

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

:::

After you have Go and Ignite CLI installed, and your Celestia
Light Node running on your machine, you're ready to build,
Expand Down Expand Up @@ -604,6 +635,9 @@ bash init.sh

With that, we have kickstarted our `wordled` network!

Find
[your account address on an Arabica explorer to see your `PayForBlobs` transactions](https://explorer.modular.cloud/celestia-arabica/addresses/celestia10rdu7l3gzeuxplpnr5vxchvxxflx7ym0q6wt5v).

In another window, run the following to submit a Wordle:

<!-- markdownlint-disable MD013 -->
Expand Down

0 comments on commit 511d6ac

Please sign in to comment.