Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

ci: initial commit for gmbuilder #39

Merged
merged 30 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/test-tutorial.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test GM Tutorial
on: push

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run GM tutorial in docker-compose
uses: isbang/[email protected]
with:
compose-file: "./gmbuilder-docker-compose.yml"
up-flags: "--build"
- name: Test the GM tutorial
run: ./gm-tester.sh
39 changes: 39 additions & 0 deletions gm-tester.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
URL=localhost:26657/block\?height=3
S1nus marked this conversation as resolved.
Show resolved Hide resolved

# Define the maximum number of retries
MAX_RETRIES=50

# Define the delay between retries in seconds
RETRY_DELAY=5

# Counter for the number of retries
RETRY_COUNT=0

# Loop until the result is not equal to the expected string or maximum retries are reached
while [[ $RETRY_COUNT -lt $MAX_RETRIES ]]; do
# Execute the curl command and capture the result
RESULT=$(curl -s "$URL")

# Compare the result with the expected string or null string
if jq -e '.result' <<< "$RESULT" > /dev/null; then
echo "Rollup has produced block #3:"
echo $RESULT
exit 0
break
fi

# Increment the retry count
((RETRY_COUNT++))

# Display a retry message
echo "Retrying... (Attempt $RETRY_COUNT)"

# Sleep for the specified delay before the next retry
sleep $RETRY_DELAY
done

# Check if maximum retries are reached without success
if [[ $RETRY_COUNT -eq $MAX_RETRIES ]]; then
echo "Maximum retries reached. Unable to obtain a different result."
fi
exit 1
23 changes: 23 additions & 0 deletions gmbuilder-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: "3.9"
services:
celestia:
image: ghcr.io/rollkit/local-celestia-devnet:latest
# Rollup can't start until after DA starts.
# This ensures it waits 5 seconds so the rollup can query it.
ports:
- "26657:26657"
- "26659:26659"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:26657/block?height=1"]
interval: 5s
timeout: 10s
retries: 5
gm:
build:
context: .
dockerfile: gmbuilder.Dockerfile
depends_on:
celestia:
condition: service_healthy
ports:
- "36657:26657"
9 changes: 9 additions & 0 deletions gmbuilder.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.20.3

WORKDIR /

ADD ./ /cosmos-sdk/

COPY script.sh /script.sh
S1nus marked this conversation as resolved.
Show resolved Hide resolved
RUN chmod +x /script.sh
ENTRYPOINT /bin/bash /script.sh
59 changes: 59 additions & 0 deletions script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash
cd ..
sudo apt-get update
sudo apt-get install jq -y
curl https://get.ignite.com/[email protected]! | bash
ignite scaffold chain gm --address-prefix gm
cd gm
go mod edit -replace github.com/cosmos/cosmos-sdk=../cosmos-sdk
go mod edit -replace github.com/tendermint/tendermint=github.com/rollkit/[email protected]
go mod tidy
go mod download

VALIDATOR_NAME=validator1
CHAIN_ID=gm
KEY_NAME=gm-key
KEY_2_NAME=gm-key-2
CHAINFLAG="--chain-id ${CHAIN_ID}"
TOKEN_AMOUNT="10000000000000000000000000stake"
STAKING_AMOUNT="1000000000stake"

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

# build the gm chain with Rollkit
ignite chain build
# reset any existing genesis/chain data
#/home/runner/go/bin/gmd tendermint unsafe-reset-all
gmd tendermint unsafe-reset-all

# initialize the validator with the chain ID you set
#/home/runner/go/bin/gmd init $VALIDATOR_NAME --chain-id $CHAIN_ID
gmd init $VALIDATOR_NAME --chain-id $CHAIN_ID

# add keys for key 1 and key 2 to keyring-backend test
echo y | /home/runner/go/bin/gmd keys add $KEY_NAME --keyring-backend test
echo y | /home/runner/go/bin/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

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

# collect genesis transactions
gmd collect-gentxs

# query the DA Layer start height, in this case we are querying
# our local devnet at port 26657, the RPC. The RPC endpoint is
# to allow users to interact with Celestia's nodes by querying
# the node's state and broadcasting transactions on the Celestia
# network. The default port is 26657.
DA_BLOCK_HEIGHT=$(curl http://celestia:26657/block | jq -r '.result.block.header.height')
echo $DA_BLOCK_HEIGHT

# start the chain
echo "Starting rollup in foreground!"
/home/runner/go/bin/gmd start --rollkit.aggregator true --rollkit.da_layer celestia --rollkit.da_config='{"base_url":"http://celestia:26659","timeout":60000000000,"fee":6000,"gas_limit":6000000}' --rollkit.namespace_id $NAMESPACE_ID --rollkit.da_start_height $DA_BLOCK_HEIGHT
Loading