From bd8fc1158eed699a6765ecab96cebdcc2f7ee2f4 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Thu, 20 Jul 2023 16:59:28 +0200 Subject: [PATCH 01/30] initial commit for gmbuilder --- .github/workflows/test-tutorial.yml | 10 ++++++ gmbuilder-docker-compose.yml | 23 ++++++++++++ gmbuilder.Dockerfile | 9 +++++ script.sh | 55 +++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 .github/workflows/test-tutorial.yml create mode 100644 gmbuilder-docker-compose.yml create mode 100644 gmbuilder.Dockerfile create mode 100755 script.sh diff --git a/.github/workflows/test-tutorial.yml b/.github/workflows/test-tutorial.yml new file mode 100644 index 000000000000..7ca7187d209c --- /dev/null +++ b/.github/workflows/test-tutorial.yml @@ -0,0 +1,10 @@ +name: Test GM Tutorial +on: workflow_dispatch + +permissions: + contents: read + +jobs: + test: + runs-on: golang:1.20.3 + steps: \ No newline at end of file diff --git a/gmbuilder-docker-compose.yml b/gmbuilder-docker-compose.yml new file mode 100644 index 000000000000..4165c40f1cea --- /dev/null +++ b/gmbuilder-docker-compose.yml @@ -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 + environment: + COSMOS_CHECKOUT: "c615611b4" + depends_on: + celestia: + condition: service_healthy diff --git a/gmbuilder.Dockerfile b/gmbuilder.Dockerfile new file mode 100644 index 000000000000..c0bc46cbeae7 --- /dev/null +++ b/gmbuilder.Dockerfile @@ -0,0 +1,9 @@ +FROM golang:1.20.3 + +WORKDIR / + +ADD ./ /cosmos-sdk/ + +COPY script.sh /script.sh +RUN chmod +x /script.sh +ENTRYPOINT /bin/bash /script.sh diff --git a/script.sh b/script.sh new file mode 100755 index 000000000000..71eedfb38eff --- /dev/null +++ b/script.sh @@ -0,0 +1,55 @@ +apt update +apt install jq -y +curl https://get.ignite.com/cli@v0.26.1! | 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/cometbft@v0.0.0-20230524013049-75272ebaee38 +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 +gmd tendermint unsafe-reset-all + +# initialize the validator with the chain ID you set +gmd init $VALIDATOR_NAME --chain-id $CHAIN_ID + +# add keys for key 1 and key 2 to keyring-backend test +echo y | gmd keys add $KEY_NAME --keyring-backend test +echo y | 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!" +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 From ed32a9d3972cc99e3f5b00d71e4e7037d18d2335 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Mon, 24 Jul 2023 17:30:18 +0200 Subject: [PATCH 02/30] fleshed out github action --- .github/workflows/test-tutorial.yml | 15 ++++++++++++--- gmbuilder-docker-compose.yml | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-tutorial.yml b/.github/workflows/test-tutorial.yml index 7ca7187d209c..6fb6902eb013 100644 --- a/.github/workflows/test-tutorial.yml +++ b/.github/workflows/test-tutorial.yml @@ -1,10 +1,19 @@ name: Test GM Tutorial -on: workflow_dispatch +on: push permissions: contents: read jobs: test: - runs-on: golang:1.20.3 - steps: \ No newline at end of file + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Run GM tutorial in docker-compose + uses: isbang/compose-action@v1.5.0 + with: + compose-file: "./gmbuilder-docker-compose.yml" + up-flags: "--build" + - name: Test the GM tutorial + run: ./script.sh \ No newline at end of file diff --git a/gmbuilder-docker-compose.yml b/gmbuilder-docker-compose.yml index 4165c40f1cea..e9712fbd46ec 100644 --- a/gmbuilder-docker-compose.yml +++ b/gmbuilder-docker-compose.yml @@ -16,8 +16,8 @@ services: build: context: . dockerfile: gmbuilder.Dockerfile - environment: - COSMOS_CHECKOUT: "c615611b4" depends_on: celestia: condition: service_healthy + ports: + - "36657:26657" \ No newline at end of file From b9e5760b2cebab9cdc13771f5cbff61585e7ce6c Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Mon, 24 Jul 2023 17:35:22 +0200 Subject: [PATCH 03/30] try to fix gm builder --- script.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script.sh b/script.sh index 71eedfb38eff..01e190cb40a3 100755 --- a/script.sh +++ b/script.sh @@ -1,9 +1,10 @@ +#!/bin/bash apt update apt install jq -y curl https://get.ignite.com/cli@v0.26.1! | 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/cosmos/cosmos-sdk=./cosmos-sdk go mod edit -replace github.com/tendermint/tendermint=github.com/rollkit/cometbft@v0.0.0-20230524013049-75272ebaee38 go mod tidy go mod download From 9ed1d2564960f64632da65bf94eee675675602b8 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Mon, 24 Jul 2023 17:41:06 +0200 Subject: [PATCH 04/30] try to fix again --- script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.sh b/script.sh index 01e190cb40a3..1e211e96143f 100755 --- a/script.sh +++ b/script.sh @@ -4,7 +4,7 @@ apt install jq -y curl https://get.ignite.com/cli@v0.26.1! | 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/cosmos/cosmos-sdk=../ go mod edit -replace github.com/tendermint/tendermint=github.com/rollkit/cometbft@v0.0.0-20230524013049-75272ebaee38 go mod tidy go mod download From 2f0b66ab4c7e9fb898bcc99464eccac5e6c5ef68 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Mon, 24 Jul 2023 17:51:34 +0200 Subject: [PATCH 05/30] run bashrc, try to find this binary --- script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/script.sh b/script.sh index 1e211e96143f..82754ec55494 100755 --- a/script.sh +++ b/script.sh @@ -1,4 +1,5 @@ #!/bin/bash +/bin/bash ~/.bashrc apt update apt install jq -y curl https://get.ignite.com/cli@v0.26.1! | bash From 743ef821cf14d51afed15c99499453791e914e2c Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Mon, 24 Jul 2023 18:21:48 +0200 Subject: [PATCH 06/30] seemingly fixed the task --- script.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script.sh b/script.sh index 82754ec55494..c90d3774c182 100755 --- a/script.sh +++ b/script.sh @@ -1,11 +1,13 @@ #!/bin/bash -/bin/bash ~/.bashrc +echo $PWD +echo "running ls:" +ls apt update apt install jq -y curl https://get.ignite.com/cli@v0.26.1! | bash ignite scaffold chain gm --address-prefix gm cd gm -go mod edit -replace github.com/cosmos/cosmos-sdk=../ +go mod edit -replace github.com/cosmos/cosmos-sdk=/cosmos-sdk go mod edit -replace github.com/tendermint/tendermint=github.com/rollkit/cometbft@v0.0.0-20230524013049-75272ebaee38 go mod tidy go mod download From ebd3c5b61c49a519f7f1b80b1ca55b47e291d4fe Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Mon, 24 Jul 2023 18:30:44 +0200 Subject: [PATCH 07/30] added cd .. --- script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/script.sh b/script.sh index c90d3774c182..98b7da6f18a9 100755 --- a/script.sh +++ b/script.sh @@ -1,4 +1,5 @@ #!/bin/bash +cd .. echo $PWD echo "running ls:" ls From 887c86aca21405b5cfb85306a32a3465fb770d5a Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Mon, 24 Jul 2023 18:39:03 +0200 Subject: [PATCH 08/30] trying more things --- script.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/script.sh b/script.sh index 98b7da6f18a9..bfda50fb2c55 100755 --- a/script.sh +++ b/script.sh @@ -8,7 +8,7 @@ apt install jq -y curl https://get.ignite.com/cli@v0.26.1! | 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/cosmos/cosmos-sdk=../cosmos-sdk go mod edit -replace github.com/tendermint/tendermint=github.com/rollkit/cometbft@v0.0.0-20230524013049-75272ebaee38 go mod tidy go mod download @@ -27,6 +27,13 @@ echo $NAMESPACE_ID # build the gm chain with Rollkit ignite chain build +echo "PWD is:" +echo $PWD +echo "running ls -a" +ls -a +echo "going back 1" +cd .. +ls -a # reset any existing genesis/chain data gmd tendermint unsafe-reset-all From 92c3dd0d741c5889acc9dacba089c65a97b42efd Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Tue, 25 Jul 2023 14:16:39 +0200 Subject: [PATCH 09/30] tried to yeet the checkout --- .github/workflows/test-tutorial.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test-tutorial.yml b/.github/workflows/test-tutorial.yml index 6fb6902eb013..1bf0ad83b062 100644 --- a/.github/workflows/test-tutorial.yml +++ b/.github/workflows/test-tutorial.yml @@ -8,12 +8,10 @@ jobs: test: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v3 - name: Run GM tutorial in docker-compose uses: isbang/compose-action@v1.5.0 with: compose-file: "./gmbuilder-docker-compose.yml" up-flags: "--build" - name: Test the GM tutorial - run: ./script.sh \ No newline at end of file + run: ./script.sh From 485eb921ffe0d16851a3a11fa5ddb84bf11d0ca6 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Tue, 25 Jul 2023 14:17:19 +0200 Subject: [PATCH 10/30] nvm --- .github/workflows/test-tutorial.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-tutorial.yml b/.github/workflows/test-tutorial.yml index 1bf0ad83b062..6fef76050e5b 100644 --- a/.github/workflows/test-tutorial.yml +++ b/.github/workflows/test-tutorial.yml @@ -8,6 +8,8 @@ jobs: test: runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v3 - name: Run GM tutorial in docker-compose uses: isbang/compose-action@v1.5.0 with: From 86ab44a13c2e248eb7cf43cde0b5f9817fbd2187 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Tue, 25 Jul 2023 14:19:07 +0200 Subject: [PATCH 11/30] nvm --- script.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/script.sh b/script.sh index bfda50fb2c55..78d3424fc7a4 100755 --- a/script.sh +++ b/script.sh @@ -33,7 +33,16 @@ echo "running ls -a" ls -a echo "going back 1" cd .. +echo "PWD is:" +echo $PWD +ls -a +echo "going into cosmos-sdk" +cd cosmos-sdk ls -a +echo "going into gm" +cd gm +ls -a + # reset any existing genesis/chain data gmd tendermint unsafe-reset-all From a844797754b558aa0a7e5a99ee7089ab8ea73624 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Tue, 25 Jul 2023 15:40:58 +0200 Subject: [PATCH 12/30] messing around. --- script.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script.sh b/script.sh index 78d3424fc7a4..40dd50e7ce42 100755 --- a/script.sh +++ b/script.sh @@ -42,6 +42,10 @@ ls -a echo "going into gm" cd gm ls -a +echo "trying to go to home..." +cd /home/ +echo "did it work? $PWD" +ls -a # reset any existing genesis/chain data gmd tendermint unsafe-reset-all From c8a1c4ffb9045f33fe18afe6c08179113fd98387 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Tue, 25 Jul 2023 16:06:24 +0200 Subject: [PATCH 13/30] debugging the path --- script.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/script.sh b/script.sh index 40dd50e7ce42..1a381375c2a4 100755 --- a/script.sh +++ b/script.sh @@ -46,6 +46,12 @@ echo "trying to go to home..." cd /home/ echo "did it work? $PWD" ls -a +cd /home/runner/ +echo "pwd: $PWD" +ls -a +cd /home/runner/work +echo "pwd: $PWD" +ls -a # reset any existing genesis/chain data gmd tendermint unsafe-reset-all From 24b4f368aeb3607d061210bb5465f57cb788d0f8 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Tue, 25 Jul 2023 16:33:07 +0200 Subject: [PATCH 14/30] absolute path --- script.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/script.sh b/script.sh index 1a381375c2a4..de1dc7a327ec 100755 --- a/script.sh +++ b/script.sh @@ -52,26 +52,28 @@ ls -a cd /home/runner/work echo "pwd: $PWD" ls -a +cat .bashrc + # reset any existing genesis/chain data -gmd tendermint unsafe-reset-all +/home/runner/gmd tendermint unsafe-reset-all # initialize the validator with the chain ID you set -gmd init $VALIDATOR_NAME --chain-id $CHAIN_ID +/home/runner/gmd init $VALIDATOR_NAME --chain-id $CHAIN_ID # add keys for key 1 and key 2 to keyring-backend test -echo y | gmd keys add $KEY_NAME --keyring-backend test -echo y | gmd keys add $KEY_2_NAME --keyring-backend test +echo y | /home/runner/gmd keys add $KEY_NAME --keyring-backend test +echo y | /home/runner/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 +/home/runner/gmd add-genesis-account $KEY_NAME $TOKEN_AMOUNT --keyring-backend test +/home/runner/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 +/home/runner/gmd gentx $KEY_NAME $STAKING_AMOUNT --chain-id $CHAIN_ID --keyring-backend test # collect genesis transactions -gmd collect-gentxs +/home/runner/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 @@ -83,4 +85,4 @@ echo $DA_BLOCK_HEIGHT # start the chain echo "Starting rollup in foreground!" -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 +/home/runner/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 From 910c4f7a6d98abb3386431afa482f408cfea25f9 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Wed, 26 Jul 2023 11:24:51 +0200 Subject: [PATCH 15/30] fix path --- script.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/script.sh b/script.sh index de1dc7a327ec..7ae9411ce3a7 100755 --- a/script.sh +++ b/script.sh @@ -56,24 +56,24 @@ cat .bashrc # reset any existing genesis/chain data -/home/runner/gmd tendermint unsafe-reset-all +/home/runner/go/bin/gmd tendermint unsafe-reset-all # initialize the validator with the chain ID you set -/home/runner/gmd init $VALIDATOR_NAME --chain-id $CHAIN_ID +/home/runner/go/bin/gmd init $VALIDATOR_NAME --chain-id $CHAIN_ID # add keys for key 1 and key 2 to keyring-backend test -echo y | /home/runner/gmd keys add $KEY_NAME --keyring-backend test -echo y | /home/runner/gmd keys add $KEY_2_NAME --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 -/home/runner/gmd add-genesis-account $KEY_NAME $TOKEN_AMOUNT --keyring-backend test -/home/runner/gmd add-genesis-account $KEY_2_NAME $TOKEN_AMOUNT --keyring-backend test +/home/runner/go/bin/gmd add-genesis-account $KEY_NAME $TOKEN_AMOUNT --keyring-backend test +/home/runner/go/bin/gmd add-genesis-account $KEY_2_NAME $TOKEN_AMOUNT --keyring-backend test # set the staking amounts in the genesis transaction -/home/runner/gmd gentx $KEY_NAME $STAKING_AMOUNT --chain-id $CHAIN_ID --keyring-backend test +/home/runner/go/bin/gmd gentx $KEY_NAME $STAKING_AMOUNT --chain-id $CHAIN_ID --keyring-backend test # collect genesis transactions -/home/runner/gmd collect-gentxs +/home/runner/go/bin/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 @@ -85,4 +85,4 @@ echo $DA_BLOCK_HEIGHT # start the chain echo "Starting rollup in foreground!" -/home/runner/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 +/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 From 0fd756762a4129aaa0d0b3db8ff0187acdf2654e Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Wed, 26 Jul 2023 13:14:05 +0200 Subject: [PATCH 16/30] cleaned up debug --- script.sh | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/script.sh b/script.sh index 7ae9411ce3a7..fcfb0811700f 100755 --- a/script.sh +++ b/script.sh @@ -1,8 +1,5 @@ #!/bin/bash cd .. -echo $PWD -echo "running ls:" -ls apt update apt install jq -y curl https://get.ignite.com/cli@v0.26.1! | bash @@ -27,34 +24,6 @@ echo $NAMESPACE_ID # build the gm chain with Rollkit ignite chain build -echo "PWD is:" -echo $PWD -echo "running ls -a" -ls -a -echo "going back 1" -cd .. -echo "PWD is:" -echo $PWD -ls -a -echo "going into cosmos-sdk" -cd cosmos-sdk -ls -a -echo "going into gm" -cd gm -ls -a -echo "trying to go to home..." -cd /home/ -echo "did it work? $PWD" -ls -a -cd /home/runner/ -echo "pwd: $PWD" -ls -a -cd /home/runner/work -echo "pwd: $PWD" -ls -a -cat .bashrc - - # reset any existing genesis/chain data /home/runner/go/bin/gmd tendermint unsafe-reset-all From 3b6fbb749659f27f92c037716a9d16f93cac557e Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Wed, 26 Jul 2023 16:38:19 +0200 Subject: [PATCH 17/30] fix script name --- .github/workflows/test-tutorial.yml | 2 +- gm-tester.sh | 42 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 gm-tester.sh diff --git a/.github/workflows/test-tutorial.yml b/.github/workflows/test-tutorial.yml index 6fef76050e5b..5e148825d620 100644 --- a/.github/workflows/test-tutorial.yml +++ b/.github/workflows/test-tutorial.yml @@ -16,4 +16,4 @@ jobs: compose-file: "./gmbuilder-docker-compose.yml" up-flags: "--build" - name: Test the GM tutorial - run: ./script.sh + run: ./gm-tester.sh diff --git a/gm-tester.sh b/gm-tester.sh new file mode 100755 index 000000000000..675bcae6e44c --- /dev/null +++ b/gm-tester.sh @@ -0,0 +1,42 @@ +URL=localhost:26657/block\?height=3 +EXPECTED_RESULT='{"jsonrpc":"2.0","error":{"code":-32603,"message":"","data":"failed to load hash from index: failed to load block hash for height: datastore: key not found"},"id":-1}' + +# 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 [[ "$RESULT" != "$EXPECTED_RESULT" && -n "$RESULT" ]]; then + echo "Success! The result is now different from the error" + echo $RESULT + exit 0 + break + fi + echo "EXPECTED " $EXPECTED_RESULT + echo "GOT " $RESULT + + # 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 From 0db14eb09f3dd98893b978de79fdbba3816b457d Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Wed, 26 Jul 2023 16:42:11 +0200 Subject: [PATCH 18/30] debugging tester --- gm-tester.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gm-tester.sh b/gm-tester.sh index 675bcae6e44c..bd0e545eb861 100755 --- a/gm-tester.sh +++ b/gm-tester.sh @@ -18,7 +18,13 @@ while [[ $RETRY_COUNT -lt $MAX_RETRIES ]]; do # Compare the result with the expected string or null string if [[ "$RESULT" != "$EXPECTED_RESULT" && -n "$RESULT" ]]; then echo "Success! The result is now different from the error" + echo "got result:" echo $RESULT + if [ -z "$RESULT" ]; then + echo "Result is null. not good" + else + echo "result is NOT NULL" + fi exit 0 break fi From d8e0bc1d15c79b11d2126950ac60e01843f672ce Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Wed, 26 Jul 2023 16:44:35 +0200 Subject: [PATCH 19/30] print expected --- gm-tester.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gm-tester.sh b/gm-tester.sh index bd0e545eb861..79371fc4138d 100755 --- a/gm-tester.sh +++ b/gm-tester.sh @@ -20,6 +20,8 @@ while [[ $RETRY_COUNT -lt $MAX_RETRIES ]]; do echo "Success! The result is now different from the error" echo "got result:" echo $RESULT + echo "but we expected this:" + echo $EXPECTED_RESULT if [ -z "$RESULT" ]; then echo "Result is null. not good" else From 7f4bf93415d7841342dd87275f44e37e2e917bac Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Wed, 26 Jul 2023 16:48:24 +0200 Subject: [PATCH 20/30] strip whitespsace in tester scripts --- gm-tester.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gm-tester.sh b/gm-tester.sh index 79371fc4138d..32b32039ec55 100755 --- a/gm-tester.sh +++ b/gm-tester.sh @@ -1,5 +1,6 @@ URL=localhost:26657/block\?height=3 EXPECTED_RESULT='{"jsonrpc":"2.0","error":{"code":-32603,"message":"","data":"failed to load hash from index: failed to load block hash for height: datastore: key not found"},"id":-1}' +EXPECTED_RESULT="${EXPECTED_RESULT#"${EXPECTED_RESULT%%[![:space:]]*}"}" # Define the maximum number of retries MAX_RETRIES=50 @@ -14,6 +15,7 @@ RETRY_COUNT=0 while [[ $RETRY_COUNT -lt $MAX_RETRIES ]]; do # Execute the curl command and capture the result RESULT=$(curl -s "$URL") + RESULT="${RESULT#"${RESULT%%[![:space:]]*}"}" # Compare the result with the expected string or null string if [[ "$RESULT" != "$EXPECTED_RESULT" && -n "$RESULT" ]]; then From 14974a66ba03e96115ea04d940f00b8ab8618091 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Wed, 26 Jul 2023 17:11:16 +0200 Subject: [PATCH 21/30] try to remove unnecessary usage of absolute paths --- script.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/script.sh b/script.sh index fcfb0811700f..2a6ceb37accb 100755 --- a/script.sh +++ b/script.sh @@ -25,24 +25,26 @@ 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 +#/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 +#/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 -/home/runner/go/bin/gmd add-genesis-account $KEY_NAME $TOKEN_AMOUNT --keyring-backend test -/home/runner/go/bin/gmd add-genesis-account $KEY_2_NAME $TOKEN_AMOUNT --keyring-backend test +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 -/home/runner/go/bin/gmd gentx $KEY_NAME $STAKING_AMOUNT --chain-id $CHAIN_ID --keyring-backend test +gmd gentx $KEY_NAME $STAKING_AMOUNT --chain-id $CHAIN_ID --keyring-backend test # collect genesis transactions -/home/runner/go/bin/gmd collect-gentxs +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 From fe85a927eb9f08a7e92f8b8be83aa646ffa1aa61 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Wed, 26 Jul 2023 19:04:14 +0200 Subject: [PATCH 22/30] adapted the script to use jq --- gm-tester.sh | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/gm-tester.sh b/gm-tester.sh index 32b32039ec55..798617544a0f 100755 --- a/gm-tester.sh +++ b/gm-tester.sh @@ -1,6 +1,4 @@ URL=localhost:26657/block\?height=3 -EXPECTED_RESULT='{"jsonrpc":"2.0","error":{"code":-32603,"message":"","data":"failed to load hash from index: failed to load block hash for height: datastore: key not found"},"id":-1}' -EXPECTED_RESULT="${EXPECTED_RESULT#"${EXPECTED_RESULT%%[![:space:]]*}"}" # Define the maximum number of retries MAX_RETRIES=50 @@ -14,26 +12,16 @@ 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") - RESULT="${RESULT#"${RESULT%%[![:space:]]*}"}" + RESULT=$(curl -s "$URL" | jq '.result') # Compare the result with the expected string or null string - if [[ "$RESULT" != "$EXPECTED_RESULT" && -n "$RESULT" ]]; then - echo "Success! The result is now different from the error" - echo "got result:" + if ["$RESULT" != "null"]; then + echo "Success! The result is now not null. Specifically, it's:" echo $RESULT - echo "but we expected this:" - echo $EXPECTED_RESULT - if [ -z "$RESULT" ]; then - echo "Result is null. not good" - else - echo "result is NOT NULL" - fi exit 0 break fi - echo "EXPECTED " $EXPECTED_RESULT - echo "GOT " $RESULT + echo "i think the result is null." # Increment the retry count ((RETRY_COUNT++)) From ac96adfc224acad91688cdab63ecbe8007149e1b Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Wed, 26 Jul 2023 19:04:41 +0200 Subject: [PATCH 23/30] tried replace apt with apt-get and used sudo --- script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script.sh b/script.sh index 2a6ceb37accb..fa891dc52a9a 100755 --- a/script.sh +++ b/script.sh @@ -1,7 +1,7 @@ #!/bin/bash cd .. -apt update -apt install jq -y +sudo apt-get update +sudo apt-get install jq -y curl https://get.ignite.com/cli@v0.26.1! | bash ignite scaffold chain gm --address-prefix gm cd gm From 153591831a0f6fee4f25fea5773422aa584ec965 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Wed, 26 Jul 2023 19:07:45 +0200 Subject: [PATCH 24/30] fix script --- gm-tester.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gm-tester.sh b/gm-tester.sh index 798617544a0f..fd6d2d245ff4 100755 --- a/gm-tester.sh +++ b/gm-tester.sh @@ -15,7 +15,7 @@ while [[ $RETRY_COUNT -lt $MAX_RETRIES ]]; do RESULT=$(curl -s "$URL" | jq '.result') # Compare the result with the expected string or null string - if ["$RESULT" != "null"]; then + if [["$RESULT" != "null"]]; then echo "Success! The result is now not null. Specifically, it's:" echo $RESULT exit 0 From 200c89c8bc647660bd3e528d46ed519eed273edf Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Wed, 26 Jul 2023 19:11:51 +0200 Subject: [PATCH 25/30] tweak jq command --- gm-tester.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gm-tester.sh b/gm-tester.sh index fd6d2d245ff4..d15ac2ba81ec 100755 --- a/gm-tester.sh +++ b/gm-tester.sh @@ -12,7 +12,7 @@ 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" | jq '.result') + RESULT=$(curl -s "$URL" | jq -r '.result') # Compare the result with the expected string or null string if [["$RESULT" != "null"]]; then From 26e3f5ea30390e283a87008735737bf9be2712f3 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Wed, 26 Jul 2023 19:22:07 +0200 Subject: [PATCH 26/30] try another suggestion --- gm-tester.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gm-tester.sh b/gm-tester.sh index d15ac2ba81ec..a3ebe3d5fd49 100755 --- a/gm-tester.sh +++ b/gm-tester.sh @@ -12,16 +12,25 @@ 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" | jq -r '.result') + RESULT=$(curl -s "$URL") # Compare the result with the expected string or null string - if [["$RESULT" != "null"]]; then - echo "Success! The result is now not null. Specifically, it's:" + if jq -e '.result' <<< "$RESULT" > /dev/null; then + echo "Success! The result is now different from the error" + echo "got result:" echo $RESULT + echo "but we expected this:" + echo $EXPECTED_RESULT + if [ -z "$RESULT" ]; then + echo "Result is null. not good" + else + echo "result is NOT NULL" + fi exit 0 break fi - echo "i think the result is null." + echo "EXPECTED " $EXPECTED_RESULT + echo "GOT " $RESULT # Increment the retry count ((RETRY_COUNT++)) From 76edd3d5eb2006124ad7458f4ee5f071473af557 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Wed, 26 Jul 2023 19:27:38 +0200 Subject: [PATCH 27/30] it works. cleanup outputs --- gm-tester.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/gm-tester.sh b/gm-tester.sh index a3ebe3d5fd49..6820db05b44a 100755 --- a/gm-tester.sh +++ b/gm-tester.sh @@ -16,21 +16,11 @@ while [[ $RETRY_COUNT -lt $MAX_RETRIES ]]; do # Compare the result with the expected string or null string if jq -e '.result' <<< "$RESULT" > /dev/null; then - echo "Success! The result is now different from the error" - echo "got result:" + echo "Rollup has produced block #3:" echo $RESULT - echo "but we expected this:" - echo $EXPECTED_RESULT - if [ -z "$RESULT" ]; then - echo "Result is null. not good" - else - echo "result is NOT NULL" - fi exit 0 break fi - echo "EXPECTED " $EXPECTED_RESULT - echo "GOT " $RESULT # Increment the retry count ((RETRY_COUNT++)) From 4f5823b63f74067160238d18219fec6a4db0bc67 Mon Sep 17 00:00:00 2001 From: c-node Date: Thu, 27 Jul 2023 13:46:15 +0200 Subject: [PATCH 28/30] Update gm-tester.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add shebang line to gm-tester.sh Co-authored-by: Jose Ramon MaƱes <32740567+jrmanes@users.noreply.github.com> --- gm-tester.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/gm-tester.sh b/gm-tester.sh index 6820db05b44a..ce297d83304c 100755 --- a/gm-tester.sh +++ b/gm-tester.sh @@ -1,3 +1,4 @@ +#!/bin/sh URL=localhost:26657/block\?height=3 # Define the maximum number of retries From 9e1a4733992bef1d23777109de80e2ba12c0aab9 Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Thu, 27 Jul 2023 13:47:46 +0200 Subject: [PATCH 29/30] inline chmod --- gmbuilder.Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gmbuilder.Dockerfile b/gmbuilder.Dockerfile index c0bc46cbeae7..0deba4896e56 100644 --- a/gmbuilder.Dockerfile +++ b/gmbuilder.Dockerfile @@ -4,6 +4,5 @@ WORKDIR / ADD ./ /cosmos-sdk/ -COPY script.sh /script.sh -RUN chmod +x /script.sh +COPY --chmod=+x script.sh /script.sh ENTRYPOINT /bin/bash /script.sh From 9503c60167ce2bf360fe00938601c110bc5ba75b Mon Sep 17 00:00:00 2001 From: Connor O'Hara Date: Thu, 27 Jul 2023 13:49:30 +0200 Subject: [PATCH 30/30] whoops meant to specify bash --- gm-tester.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gm-tester.sh b/gm-tester.sh index ce297d83304c..3f87e51eb8eb 100755 --- a/gm-tester.sh +++ b/gm-tester.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash URL=localhost:26657/block\?height=3 # Define the maximum number of retries