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

chore: Remove Background Voting Loop #59

Merged
merged 2 commits into from
Sep 11, 2024
Merged
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
59 changes: 2 additions & 57 deletions contract/scripts/run-chain.sh
Original file line number Diff line number Diff line change
@@ -1,67 +1,12 @@
#!/bin/bash

wait_for_bootstrap() {
endpoint="localhost"
while true; do
if json=$(curl -s --fail -m 15 "$endpoint:26657/status"); then
if [[ "$(echo "$json" | jq -r .jsonrpc)" == "2.0" ]]; then
if last_height=$(echo "$json" | jq -r .result.sync_info.latest_block_height); then
if [[ "$last_height" != "1" ]]; then
echo "$last_height"
return
else
echo "$last_height"
fi
fi
fi
fi
echo "waiting for next block..."
sleep 5
done
echo "done"
}

waitForBlock() (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like waitForBlock is still in use. I see a call to it below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange that ci passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. In dapp-offer-up, we are pulling the definition of waitForBlock from /usr/src/upgrade-test-scripts/env_setup.sh rather than defining it here. I would rather keep run-chain.sh identical in both dapps. Let me know which one is preferable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, let's keep it identical.

echo "waiting for block..."
times=${1:-1}
echo "$times"
for ((i = 1; i <= times; i++)); do
b1=$(wait_for_bootstrap)
while true; do
b2=$(wait_for_bootstrap)
if [[ "$b1" != "$b2" ]]; then
echo "block produced"
break
fi
sleep 5
done
done
echo "done"
)

approveProposals() {
while true; do
proposals=$(make -s -C /workspace/contract gov-voting-q 2>/dev/null)
exit_status=$?
if [ $exit_status -eq 0 ]; then
echo "Approving proposals: $proposals"
printf $proposals | xargs -I {} make -s -C /workspace/contract vote PROPOSAL={}
else
echo "No proposals to approve, continuing..."
fi

sleep 10
done
}
. /usr/src/upgrade-test-scripts/env_setup.sh

# Start the chain in the background
/usr/src/upgrade-test-scripts/start_agd.sh &

# wait for blocks to start being produced
waitForBlock 2

# Approve any proposals forever in the background.
approveProposals &
waitForBlock 1

make -C /workspace/contract mint100

Expand Down