Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
167 changes: 167 additions & 0 deletions .github/workflows/chain-liveness.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: Liveness Tests

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:

jobs:
rollkit-liveness:
name: Ignite Rollkit App Liveness Test
runs-on: ubuntu-latest
timeout-minutes: 30
env:
DO_NOT_TRACK: true

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "stable"
cache: true

- name: Install Ignite CLI
run: |
curl -sSL https://get.ignite.com/cli@v28.10.0! | bash

- name: Start Local DA
run: |
# clone rollkit repository (#TODO install via go install when possible)
git clone https://github.com/rollkit/rollkit --depth 1 rollkit-repo
cd rollkit-repo/da/cmd/local-da
# start the local da in the background
go run . &
# capture the background process PID
echo "DA_PID=$!" >> $GITHUB_ENV
# give it a moment to start
sleep 3

- name: Scaffold & Init Rollkit Chain
run: |
# get the path to the current checkout of ignite apps
ROLLKIT_APP_DIR=$(pwd)/rollkit

# scaffold a new chain
ignite scaffold chain gm --no-module --skip-git
cd gm

# install rollkit app
ignite app install $ROLLKIT_APP_DIR

# add rollkit to the chain
ignite rollkit add
go mod tidy

# build the chain
ignite chain build --skip-proto

# initialize rollkit
ignite rollkit init

- name: Start Chain and Wait for Blocks
run: |
cd gm

# start the chain and send output to a log file
gmd start --rollkit.node.aggregator --log_format=json > chain.log 2>&1 &
CHAIN_PID=$!
echo "CHAIN_PID=$CHAIN_PID" >> $GITHUB_ENV

echo "Waiting for chain to produce blocks..."

# wait for chain to start and check for 5 blocks
BLOCKS_FOUND=0
MAX_ATTEMPTS=60
ATTEMPT=0

while [ $BLOCKS_FOUND -lt 5 ] && [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
sleep 2
ATTEMPT=$((ATTEMPT+1))

# check if the chain is still running
if ! ps -p $CHAIN_PID > /dev/null; then
echo "Chain process died unexpectedly"
cat chain.log
exit 1
fi

# count blocks in log
BLOCKS_FOUND=$(grep -c "block executed successfully" chain.log || true)
echo "Found $BLOCKS_FOUND blocks so far (attempt $ATTEMPT/$MAX_ATTEMPTS)"
done

if [ $BLOCKS_FOUND -lt 5 ]; then
echo "Failed to find 5 blocks within time limit"
cat chain.log
exit 1
fi

echo "Success! Chain produced at least 5 blocks."

- name: Test Transaction Submission and Query
run: |
cd gm

# get bob's address
BOB_ADDRESS=$(gmd keys show bob -a)
ALICE_ADDRESS=$(gmd keys show alice -a)
echo "Bob's address: $BOB_ADDRESS"
echo "Alice's address: $ALICE_ADDRESS"

# query bob's initial balance
echo "Querying Bob's initial balance..."
INITIAL_BALANCE=$(gmd query bank balances $BOB_ADDRESS --output json | jq '.balances[0].amount' -r)
echo "Bob's initial balance: $INITIAL_BALANCE stake"

# check that bob has funds
if [ "$INITIAL_BALANCE" == "" ] || [ "$INITIAL_BALANCE" == "null" ] || [ "$INITIAL_BALANCE" -lt 100 ]; then
echo "Error: Bob's account not properly funded"
exit 1
fi

# send transaction from bob to alice and get tx hash
echo "Sending 100stake from Bob to Alice..."
TX_HASH=$(gmd tx bank send $BOB_ADDRESS $ALICE_ADDRESS 100stake -y --output json | jq -r .txhash)

sleep 3

# query the transaction
TX_RESULT=$(gmd query tx $TX_HASH --output json)
TX_CODE=$(echo $TX_RESULT | jq -r '.code')
if [ "$TX_CODE" != "0" ]; then
echo "Error: Transaction failed with code $TX_CODE"
echo $TX_RESULT | jq
exit 1
fi

# query bob's balance after transaction
FINAL_BALANCE=$(gmd query bank balances $BOB_ADDRESS --output json | jq '.balances[0].amount' -r)
echo "Bob's final balance: $FINAL_BALANCE"

# calculate and verify the expected balance
EXPECTED_BALANCE=$((INITIAL_BALANCE - 100))
if [ "$FINAL_BALANCE" != "$EXPECTED_BALANCE" ]; then
echo "Error: Balance mismatch. Expected: $EXPECTED_BALANCE, Actual: $FINAL_BALANCE"
exit 1
fi

echo "✅ Transaction test successful! Balance correctly updated."

- name: Cleanup Processes
if: always()
run: |
# kill chain process if it exists
if [[ -n "${CHAIN_PID}" ]]; then
kill -9 $CHAIN_PID || true
fi

# kill DA process if it exists
if [[ -n "${DA_PID}" ]]; then
kill -9 $DA_PID || true
fi
4 changes: 2 additions & 2 deletions rollkit/template/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const (

const (
GoExecPackage = "github.com/rollkit/go-execution-abci"
GoExecVersion = "v0.2.1-0.20250507114132-4abb42ac7c60" // TODO(@julienrbrt): use tag when available
GoExecVersion = "v0.2.1-0.20250521112925-012f1f753eb4" // TODO(@julienrbrt): use tag when available

RollkitPackage = "github.com/rollkit/rollkit"
RollkitVersion = "v0.14.2-0.20250506085607-c574d7c79224" // TODO(@julienrbrt): use tag when available
RollkitVersion = "v0.14.2-0.20250521111736-d1e1eee29233" // TODO(@julienrbrt): use tag when available
)
Loading