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

fix: miscellaneous cleanups #39

Merged
merged 5 commits into from
Jan 17, 2024
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
2 changes: 1 addition & 1 deletion packages/synthetic-chain/src/lib/agd-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export const makeAgd = ({ execFileSync }) => {
...keyringArgs,
...[`--from`, from],
'tx',
...txArgs,
...['--broadcast-mode', 'block'],
...txArgs,
...yesArg,
...outJson,
];
Expand Down
2 changes: 1 addition & 1 deletion packages/synthetic-chain/src/lib/cliHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const agd = {
return JSON.parse(data);
},
tx: async (...params) => {
const newParams = ['tx', ...params, '-o json'];
const newParams = ['tx', '-bblock', ...params, '-o json'];
const data = await executeCommand(BINARY, newParams, { shell: true });
return JSON.parse(data);
},
Expand Down
16 changes: 9 additions & 7 deletions packages/synthetic-chain/upgrade-test-scripts/env_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ provisionSmartWallet() {
addr="$1"
amount="$2"
echo "funding $addr"
agd tx bank send "validator" "$addr" "$amount" -y --keyring-backend=test --chain-id="$CHAINID"
agd tx -bblock bank send "validator" "$addr" "$amount" -y --keyring-backend=test --chain-id="$CHAINID"
waitForBlock
echo "provisioning $addr"
agd tx swingset provision-one my-wallet "$addr" SMART_WALLET --keyring-backend=test --yes --chain-id="$CHAINID" --from="$addr"
agd tx -bblock swingset provision-one my-wallet "$addr" SMART_WALLET --keyring-backend=test --yes --chain-id="$CHAINID" --from="$addr"
echo "Waiting for wallet $addr to reach vstorage"
waitForBlock 5
echo "Reading $addr from vstorage"
Expand Down Expand Up @@ -164,19 +164,21 @@ voteLatestProposalAndWait() {
waitForBlock
proposal=$($binary q gov proposals -o json | jq -r '.proposals[-1].proposal_id')
waitForBlock
$binary tx gov deposit $proposal 50000000ubld --from=validator --chain-id="$CHAINID" --yes --keyring-backend test
$binary tx -bblock gov deposit $proposal 50000000ubld --from=validator --chain-id="$CHAINID" --yes --keyring-backend test
waitForBlock
$binary tx gov vote $proposal yes --from=validator --chain-id="$CHAINID" --yes --keyring-backend test
$binary tx -bblock gov vote $proposal yes --from=validator --chain-id="$CHAINID" --yes --keyring-backend test
waitForBlock

while true; do
status=$($binary q gov proposal $proposal -ojson | jq -r .status)
json=$($binary q gov proposal $proposal -ojson)
status=$(echo "$json" | jq -r .status)
case $status in
PROPOSAL_STATUS_PASSED)
break
;;
PROPOSAL_STATUS_REJECTED)
echo "Proposal rejected"
PROPOSAL_STATUS_REJECTED | PROPOSAL_STATUS_FAILED)
echo "Proposal did not pass (status=$status)"
echo "$json" | jq .
exit 1
;;
*)
Expand Down
43 changes: 23 additions & 20 deletions packages/synthetic-chain/upgrade-test-scripts/start_ag0.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#!/bin/bash

# The name of the binary is an implementation detail.
agd () {
ag0 ${1+"$@"}
}

export CHAINID=agoriclocal
ag0 init localnet --chain-id "$CHAINID"
agd init localnet --chain-id "$CHAINID"

allaccounts=("gov1" "gov2" "gov3" "user1" "validator")
for i in "${allaccounts[@]}"; do
ag0 keys add $i --keyring-backend=test 2>&1 | tee "$HOME/.agoric/$i.out"
agd keys add $i --keyring-backend=test 2>&1 | tee "$HOME/.agoric/$i.out"
cat "$HOME/.agoric/$i.out" | tail -n1 | tee "$HOME/.agoric/$i.key"
done

Expand All @@ -25,7 +30,7 @@ contents="$(jq ".app_state.gov.deposit_params.min_deposit[0].denom = \"ubld\"" "
contents="$(jq ".app_state.staking.params.bond_denom = \"ubld\"" "$HOME/.agoric/config/genesis.json")" && echo -E "${contents}" >"$HOME/.agoric/config/genesis.json"
contents="$(jq ".app_state.slashing.params.signed_blocks_window = \"20000\"" "$HOME/.agoric/config/genesis.json")" && echo -E "${contents}" >"$HOME/.agoric/config/genesis.json"
contents=$(jq '. * { app_state: { gov: { voting_params: { voting_period: "10s" } } } }' "$HOME/.agoric/config/genesis.json") && echo -E "${contents}" >"$HOME/.agoric/config/genesis.json"
export GENACCT=$(ag0 keys show validator -a --keyring-backend="test")
export GENACCT=$(agd keys show validator -a --keyring-backend="test")
echo "Genesis Account $GENACCT"

denoms=(
Expand All @@ -47,28 +52,27 @@ for i in "${denoms[@]}"; do
coins="${coins},${camount}${i}"
done

ag0 add-genesis-account "$GENACCT" "$coins"
agd add-genesis-account "$GENACCT" "$coins"

ag0 gentx validator 5000000000ubld --keyring-backend="test" --chain-id "$CHAINID"
ag0 collect-gentxs
ag0 start --log_level warn &
ag0_PID=$!
agd gentx validator 5000000000ubld --keyring-backend="test" --chain-id "$CHAINID"
agd collect-gentxs
agd start --log_level warn &
agd_PID=$!
wait_for_bootstrap
waitForBlock 2

voting_period_s=10
latest_height=$(ag0 status | jq -r .SyncInfo.latest_block_height)
height=$(($latest_height + $voting_period_s + 10))

latest_height=$(agd status | jq -r .SyncInfo.latest_block_height)
Copy link
Member

Choose a reason for hiding this comment

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

nit: the ag0 -> agd rename here should be in the previous commit

Copy link
Member

Choose a reason for hiding this comment

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

Agree. Though I think it's worth letting slide to land this now.

height=$((latest_height + voting_period_s + 20))
info=${UPGRADE_INFO-"{}"}
if echo "$info" | jq .; then
:
echo "upgrade-info: $info"
else
status=$?
echo "Upgrade info is not valid JSON: $info"
exit $status
fi
ag0 tx gov submit-proposal software-upgrade "$UPGRADE_TO" \
agd tx -bblock gov submit-proposal software-upgrade "$UPGRADE_TO" \
--upgrade-height="$height" --upgrade-info="$info" \
--title="Upgrade to ${UPGRADE_TO}" --description="upgrades" \
--from=validator --chain-id="$CHAINID" \
Expand All @@ -80,16 +84,15 @@ voteLatestProposalAndWait
echo "Chain in to-be-upgraded state for $UPGRADE_TO"

while true; do
latest_height=$(ag0 status | jq -r .SyncInfo.latest_block_height)
if [ "$latest_height" != "$height" ]; then
echo "Waiting for upgrade height to be reached (need $height, have $latest_height)"
sleep 1
else
echo "Upgrade height for $UPGRADE_TO reached. Killing ag0"
latest_height=$(agd status | jq -r .SyncInfo.latest_block_height)
if [ "$latest_height" -ge "$height" ]; then
echo "Upgrade height for $UPGRADE_TO reached. Killing agd"
echo "(CONSENSUS FAILURE above for height $height is expected)"
break
fi
echo "Waiting for upgrade height for $UPGRADE_TO to be reached (need $height, have $latest_height)"
sleep 1
done

kill $ag0_PID
kill $agd_PID
echo "state directory $HOME/.agoric ready for upgrade to $UPGRADE_TO"
11 changes: 5 additions & 6 deletions packages/synthetic-chain/upgrade-test-scripts/start_to_to.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fi

voting_period_s=10
latest_height=$(agd status | jq -r .SyncInfo.latest_block_height)
height=$((latest_height + voting_period_s + 10))
height=$((latest_height + voting_period_s + 20))
info=${UPGRADE_INFO-"{}"}
if echo "$info" | jq .; then
echo "upgrade-info: $info"
Expand All @@ -25,7 +25,7 @@ else
echo "Upgrade info is not valid JSON: $info"
exit $status
fi
agd tx gov submit-proposal software-upgrade "$UPGRADE_TO" \
agd tx -bblock gov submit-proposal software-upgrade "$UPGRADE_TO" \
--upgrade-height="$height" --upgrade-info="$info" \
--title="Upgrade to ${UPGRADE_TO}" --description="upgrades" \
--from=validator --chain-id="$CHAINID" \
Expand All @@ -38,14 +38,13 @@ echo "Chain in to-be-upgraded state for $UPGRADE_TO"

while true; do
latest_height=$(agd status | jq -r .SyncInfo.latest_block_height)
if [ "$latest_height" != "$height" ]; then
echo "Waiting for upgrade height for $UPGRADE_TO to be reached (need $height, have $latest_height)"
sleep 1
else
if [ "$latest_height" -ge "$height" ]; then
echo "Upgrade height for $UPGRADE_TO reached. Killing agd"
echo "(CONSENSUS FAILURE above for height $height is expected)"
break
fi
echo "Waiting for upgrade height for $UPGRADE_TO to be reached (need $height, have $latest_height)"
sleep 1
done

sleep 2
Expand Down
2 changes: 1 addition & 1 deletion proposals/16:upgrade-8/use.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ waitForBlock 2
waitForBlock 3
# fund provision pool
stakeamount="20000000${USDC_DENOM}"
agd tx bank send "validator" "agoric1megzytg65cyrgzs6fvzxgrcqvwwl7ugpt62346" "$stakeamount" -y --keyring-backend=test --chain-id="$CHAINID"
agd tx bank send "validator" "agoric1megzytg65cyrgzs6fvzxgrcqvwwl7ugpt62346" "$stakeamount" -y --keyring-backend=test --chain-id="$CHAINID" -bblock
michaelfig marked this conversation as resolved.
Show resolved Hide resolved
waitForBlock 3

govaccounts=("$GOV1ADDR" "$GOV2ADDR" "$GOV3ADDR")
Expand Down