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

Remove Background Voting Loop #38

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
61 changes: 3 additions & 58 deletions contract/scripts/run-chain.sh
Original file line number Diff line number Diff line change
@@ -1,69 +1,14 @@
#!/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() (
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

# bring back chain process to foreground
wait
wait
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.5'

services:
agd:
# cf. https://github.com/Agoric/agoric-3-proposals
Expand Down
Loading