Skip to content

Commit

Permalink
WIP: add dockerfile changes
Browse files Browse the repository at this point in the history
  • Loading branch information
iomekam committed Aug 29, 2023
1 parent a711e53 commit 6fffcf2
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 127 deletions.
30 changes: 23 additions & 7 deletions packages/deployment/upgrade-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN echo "${BOOTSTRAP_MODE}"
RUN mkdir -p /usr/src/agoric-sdk/upgrade-test-scripts
WORKDIR /usr/src/agoric-sdk/
COPY ./start_ag0.sh ./upgrade-test-scripts/
COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./upgrade-test-scripts/
COPY ./bash_entrypoint.sh ./env.sh ./env_setup.sh ./start_to_to.sh ./package.json ./*.mjs ./upgrade-test-scripts/
SHELL ["/bin/bash", "-c"]
RUN . ./upgrade-test-scripts/start_ag0.sh

Expand All @@ -19,7 +19,7 @@ ARG BOOTSTRAP_MODE
ENV THIS_NAME=agoric-upgrade-8 BOOTSTRAP_MODE=${BOOTSTRAP_MODE}
WORKDIR /usr/src/agoric-sdk/

COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./upgrade-test-scripts/
COPY ./bash_entrypoint.sh ./env.sh ./env_setup.sh ./start_to_to.sh ./package.json ./*.mjs ./upgrade-test-scripts/
COPY ./${THIS_NAME} ./upgrade-test-scripts/${THIS_NAME}/
COPY --from=agoric-upgrade-7-2 /root/.agoric /root/.agoric
RUN chmod +x ./upgrade-test-scripts/*.sh
Expand All @@ -33,7 +33,7 @@ ARG BOOTSTRAP_MODE UPGRADE_INFO_9
ENV THIS_NAME=agoric-upgrade-8-1 UPGRADE_TO=agoric-upgrade-9 UPGRADE_INFO=${UPGRADE_INFO_9} BOOTSTRAP_MODE=${BOOTSTRAP_MODE}

WORKDIR /usr/src/agoric-sdk/
COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./upgrade-test-scripts/
COPY ./bash_entrypoint.sh ./env.sh ./env_setup.sh ./start_to_to.sh ./package.json ./*.mjs ./upgrade-test-scripts/
COPY ./${THIS_NAME} ./upgrade-test-scripts/${THIS_NAME}/
COPY --from=agoric-upgrade-8 /root/.agoric /root/.agoric
RUN chmod +x ./upgrade-test-scripts/*.sh
Expand All @@ -47,7 +47,7 @@ ARG BOOTSTRAP_MODE UPGRADE_INFO_10
ENV THIS_NAME=agoric-upgrade-9 UPGRADE_TO=agoric-upgrade-10 UPGRADE_INFO=${UPGRADE_INFO_10} BOOTSTRAP_MODE=${BOOTSTRAP_MODE}

WORKDIR /usr/src/agoric-sdk/
COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./upgrade-test-scripts/
COPY ./bash_entrypoint.sh ./env.sh ./env_setup.sh ./start_to_to.sh ./package.json ./*.mjs ./upgrade-test-scripts/
COPY ./${THIS_NAME} ./upgrade-test-scripts/${THIS_NAME}/
COPY --from=agoric-upgrade-8-1 /root/.agoric /root/.agoric
WORKDIR /usr/src/agoric-sdk/
Expand All @@ -63,11 +63,16 @@ ARG BOOTSTRAP_MODE
ENV THIS_NAME=agoric-upgrade-10 USE_JS=1 BOOTSTRAP_MODE=${BOOTSTRAP_MODE}

WORKDIR /usr/src/agoric-sdk/
COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./package.json ./*.mjs ./upgrade-test-scripts/
COPY ./bash_entrypoint.sh ./env.sh ./env_setup.sh ./start_to_to.sh ./package.json ./*.mjs ./upgrade-test-scripts/
COPY ./${THIS_NAME} ./upgrade-test-scripts/${THIS_NAME}/
COPY --from=agoric-upgrade-9 /root/.agoric /root/.agoric

RUN chmod +x ./upgrade-test-scripts/*.sh
WORKDIR /usr/src/agoric-sdk/upgrade-test-scripts
SHELL ["/bin/bash", "-c"]
RUN yarn
RUN echo '. /usr/src/agoric-sdk/upgrade-test-scripts/env.sh' >> ~/.bashrc
WORKDIR /usr/src/agoric-sdk/
RUN . ./upgrade-test-scripts/start_to_to.sh

ARG DEST_IMAGE
Expand All @@ -80,11 +85,16 @@ ARG BOOTSTRAP_MODE UPGRADE_INFO_11='{"coreProposals":["@agoric/builders/scripts/
ENV THIS_NAME=agoric-upgrade-10-to-11 UPGRADE_TO=agoric-upgrade-11 UPGRADE_INFO=${UPGRADE_INFO_11} BOOTSTRAP_MODE=${BOOTSTRAP_MODE}

WORKDIR /usr/src/agoric-sdk/
COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./upgrade-test-scripts/
COPY ./bash_entrypoint.sh ./env.sh ./env_setup.sh ./start_to_to.sh ./upgrade-test-scripts/
COPY ./${THIS_NAME} ./upgrade-test-scripts/${THIS_NAME}/
COPY --from=agoric-upgrade-10 /root/.agoric /root/.agoric

RUN chmod +x ./upgrade-test-scripts/*.sh
WORKDIR /usr/src/agoric-sdk/upgrade-test-scripts
SHELL ["/bin/bash", "-c"]
RUN yarn
RUN echo '. /usr/src/agoric-sdk/upgrade-test-scripts/env.sh' >> ~/.bashrc
WORKDIR /usr/src/agoric-sdk/
RUN . ./upgrade-test-scripts/start_to_to.sh

ARG DEST_IMAGE
Expand All @@ -95,10 +105,16 @@ ENV THIS_NAME=agoric-upgrade-11 BOOTSTRAP_MODE=${BOOTSTRAP_MODE} USE_JS=1
# this boot doesn't need an upgrade

WORKDIR /usr/src/agoric-sdk/
COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./package.json ./*.mjs ./upgrade-test-scripts/
COPY ./bash_entrypoint.sh ./env.sh ./env_setup.sh ./start_to_to.sh ./package.json ./*.mjs ./upgrade-test-scripts/
COPY ./${THIS_NAME} ./upgrade-test-scripts/${THIS_NAME}/
COPY --from=agoric-upgrade-10-to-11 /root/.agoric /root/.agoric
RUN apt install -y tmux
SHELL ["/bin/bash", "-c"]

RUN chmod +x ./upgrade-test-scripts/*.sh
WORKDIR /usr/src/agoric-sdk/upgrade-test-scripts
RUN yarn
RUN echo '. /usr/src/agoric-sdk/upgrade-test-scripts/env.sh' >> ~/.bashrc
WORKDIR /usr/src/agoric-sdk/

ENTRYPOINT /usr/src/agoric-sdk/upgrade-test-scripts/start_to_to.sh
120 changes: 120 additions & 0 deletions packages/deployment/upgrade-test/upgrade-test-scripts/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/bin/bash

# TODO what else should be in here?
export DEBUG="SwingSet:ls,SwingSet:vat"

export CHAINID=agoriclocal
shopt -s expand_aliases

alias agops="yarn run --silent agops"
if test -f "$HOME/.agoric/envs"; then
source "$HOME/.agoric/envs"
fi

export binary=ag0
if [ -x "$(command -v "agd")" ]; then
export binary=agd
fi
export GOV1ADDR=$($binary keys show gov1 -a --keyring-backend="test")
export GOV2ADDR=$($binary keys show gov2 -a --keyring-backend="test")
export GOV3ADDR=$($binary keys show gov3 -a --keyring-backend="test")
export VALIDATORADDR=$($binary keys show validator -a --keyring-backend="test")
export USER1ADDR=$($binary keys show user1 -a --keyring-backend="test")

if [[ "$binary" == "agd" ]]; then
configdir=/usr/src/agoric-sdk/packages/vm-config
test -d "$configdir" || configdir=/usr/src/agoric-sdk/packages/vats
# Support testnet addresses
sed -i "s/agoric1ldmtatp24qlllgxmrsjzcpe20fvlkp448zcuce/$GOV1ADDR/g" "$configdir"/*.json
sed -i "s/agoric140dmkrz2e42ergjj7gyvejhzmjzurvqeq82ang/$GOV2ADDR/g" "$configdir"/*.json
sed -i "s/agoric1w8wktaur4zf8qmmtn3n7x3r0jhsjkjntcm3u6h/$GOV3ADDR/g" "$configdir"/*.json

# Support mainnet addresses
sed -i "s/agoric1gx9uu7y6c90rqruhesae2t7c2vlw4uyyxlqxrx/$GOV1ADDR/g" "$configdir"/*.json
sed -i "s/agoric1d4228cvelf8tj65f4h7n2td90sscavln2283h5/$GOV2ADDR/g" "$configdir"/*.json
sed -i "s/agoric1zayxg4e9vd0es9c9jlpt36qtth255txjp6a8yc/$GOV3ADDR/g" "$configdir"/*.json
sed -i '/agoric14543m33dr28x7qhwc558hzlj9szwhzwzpcmw6a/d' "$configdir"/*.json
sed -i '/agoric13p9adwk0na5npfq64g22l6xucvqdmu3xqe70wq/d' "$configdir"/*.json
sed -i '/agoric1el6zqs8ggctj5vwyukyk4fh50wcpdpwgugd5l5/d' "$configdir"/*.json

# change names to gov1/2/3 since order is significant for invitation sending
sed -i "s/Jason Potts/gov1/g" "$configdir"/*.json
sed -i "s/Chloe White/gov2/g" "$configdir"/*.json
sed -i "s/Joe Clark/gov3/g" "$configdir"/*.json

# Oracle Addresses
sed -i "s/agoric1krunjcqfrf7la48zrvdfeeqtls5r00ep68mzkr/$GOV1ADDR/g" "$configdir"/*.json
sed -i "s/agoric1n4fcxsnkxe4gj6e24naec99hzmc4pjfdccy5nj/$GOV2ADDR/g" "$configdir"/*.json
sed -i '/agoric19uscwxdac6cf6z7d5e26e0jm0lgwstc47cpll8/d' "$configdir"/*.json
sed -i '/agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78/d' "$configdir"/*.json
sed -i '/agoric19d6gnr9fyp6hev4tlrg87zjrzsd5gzr5qlfq2p/d' "$configdir"/*.json

# committeeSize
sed -i 's/committeeSize": 6/committeeSize": 3/g' "$configdir"/*.json
sed -i 's/minSubmissionCount": 3/minSubmissionCount": 1/g' "$configdir"/*.json
fi

startAgd() {
agd start --log_level warn "$@" &
AGD_PID=$!
echo $AGD_PID > $HOME/.agoric/agd.pid
wait_for_bootstrap
waitForBlock 2
}

killAgd() {
AGD_PID=$(cat $HOME/.agoric/agd.pid)
kill $AGD_PID
rm $HOME/.agoric/agd.pid
wait $AGD_PID || true
}

waitAgd() {
wait $(cat $HOME/.agoric/agd.pid)
rm $HOME/.agoric/agd.pid
}

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
sleep 2
done
}

waitForBlock() (
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 1
done
done
)

export USDC_DENOM="ibc/toyusdc"
# Recent transfer to Emerynet
export ATOM_DENOM="ibc/06362C6F7F4FB702B94C13CD2E7C03DEC357683FD978936340B43FBFBC5351EB"
export PSM_PAIR="IST.ToyUSD"
if [[ "$BOOTSTRAP_MODE" == "main" ]]; then
export USDC_DENOM="ibc/295548A78785A1007F232DE286149A6FF512F180AF5657780FC89C009E2C348F"
export ATOM_DENOM="ibc/BA313C4A19DFBF943586C0387E6B11286F9E416B4DD27574E6909CABE0E342FA"
export PSM_PAIR="IST.USDC_axl"
fi
120 changes: 1 addition & 119 deletions packages/deployment/upgrade-test/upgrade-test-scripts/env_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,7 @@

echo ENV_SETUP starting

# TODO what else should be in here?
export DEBUG="SwingSet:ls,SwingSet:vat"

export CHAINID=agoriclocal
shopt -s expand_aliases

alias agops="yarn run --silent agops"
if test -f "$HOME/.agoric/envs"; then
source "$HOME/.agoric/envs"
fi

export binary=ag0
if [ -x "$(command -v "agd")" ]; then
export binary=agd
fi
export GOV1ADDR=$($binary keys show gov1 -a --keyring-backend="test")
export GOV2ADDR=$($binary keys show gov2 -a --keyring-backend="test")
export GOV3ADDR=$($binary keys show gov3 -a --keyring-backend="test")
export VALIDATORADDR=$($binary keys show validator -a --keyring-backend="test")
export USER1ADDR=$($binary keys show user1 -a --keyring-backend="test")

if [[ "$binary" == "agd" ]]; then
configdir=/usr/src/agoric-sdk/packages/vm-config
test -d "$configdir" || configdir=/usr/src/agoric-sdk/packages/vats
# Support testnet addresses
sed -i "s/agoric1ldmtatp24qlllgxmrsjzcpe20fvlkp448zcuce/$GOV1ADDR/g" "$configdir"/*.json
sed -i "s/agoric140dmkrz2e42ergjj7gyvejhzmjzurvqeq82ang/$GOV2ADDR/g" "$configdir"/*.json
sed -i "s/agoric1w8wktaur4zf8qmmtn3n7x3r0jhsjkjntcm3u6h/$GOV3ADDR/g" "$configdir"/*.json

# Support mainnet addresses
sed -i "s/agoric1gx9uu7y6c90rqruhesae2t7c2vlw4uyyxlqxrx/$GOV1ADDR/g" "$configdir"/*.json
sed -i "s/agoric1d4228cvelf8tj65f4h7n2td90sscavln2283h5/$GOV2ADDR/g" "$configdir"/*.json
sed -i "s/agoric1zayxg4e9vd0es9c9jlpt36qtth255txjp6a8yc/$GOV3ADDR/g" "$configdir"/*.json
sed -i '/agoric14543m33dr28x7qhwc558hzlj9szwhzwzpcmw6a/d' "$configdir"/*.json
sed -i '/agoric13p9adwk0na5npfq64g22l6xucvqdmu3xqe70wq/d' "$configdir"/*.json
sed -i '/agoric1el6zqs8ggctj5vwyukyk4fh50wcpdpwgugd5l5/d' "$configdir"/*.json

# change names to gov1/2/3 since order is significant for invitation sending
sed -i "s/Jason Potts/gov1/g" "$configdir"/*.json
sed -i "s/Chloe White/gov2/g" "$configdir"/*.json
sed -i "s/Joe Clark/gov3/g" "$configdir"/*.json

# Oracle Addresses
sed -i "s/agoric1krunjcqfrf7la48zrvdfeeqtls5r00ep68mzkr/$GOV1ADDR/g" "$configdir"/*.json
sed -i "s/agoric1n4fcxsnkxe4gj6e24naec99hzmc4pjfdccy5nj/$GOV2ADDR/g" "$configdir"/*.json
sed -i '/agoric19uscwxdac6cf6z7d5e26e0jm0lgwstc47cpll8/d' "$configdir"/*.json
sed -i '/agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78/d' "$configdir"/*.json
sed -i '/agoric19d6gnr9fyp6hev4tlrg87zjrzsd5gzr5qlfq2p/d' "$configdir"/*.json

# committeeSize
sed -i 's/committeeSize": 6/committeeSize": 3/g' "$configdir"/*.json
sed -i 's/minSubmissionCount": 3/minSubmissionCount": 1/g' "$configdir"/*.json
fi

startAgd() {
agd start --log_level warn "$@" &
AGD_PID=$!
echo $AGD_PID > $HOME/.agoric/agd.pid
wait_for_bootstrap
waitForBlock 2
}

killAgd() {
AGD_PID=$(cat $HOME/.agoric/agd.pid)
kill $AGD_PID
rm $HOME/.agoric/agd.pid
wait $AGD_PID || true
}

waitAgd() {
wait $(cat $HOME/.agoric/agd.pid)
rm $HOME/.agoric/agd.pid
}
. ./upgrade-test-scripts/env.sh

provisionSmartWallet() {
i="$1"
Expand All @@ -94,41 +22,6 @@ sendOffer() (
agoric wallet send --offer "$offer" --from "$from" --keyring-backend="test"
)

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
sleep 2
done
}

waitForBlock() (
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 1
done
done
)

runActions() {
action=${1:-"test"}
if [[ -v THIS_NAME ]]; then
Expand Down Expand Up @@ -238,17 +131,6 @@ printKeys() {
echo "========== GOVERNANCE KEYS =========="
}


export USDC_DENOM="ibc/toyusdc"
# Recent transfer to Emerynet
export ATOM_DENOM="ibc/06362C6F7F4FB702B94C13CD2E7C03DEC357683FD978936340B43FBFBC5351EB"
export PSM_PAIR="IST.ToyUSD"
if [[ "$BOOTSTRAP_MODE" == "main" ]]; then
export USDC_DENOM="ibc/295548A78785A1007F232DE286149A6FF512F180AF5657780FC89C009E2C348F"
export ATOM_DENOM="ibc/BA313C4A19DFBF943586C0387E6B11286F9E416B4DD27574E6909CABE0E342FA"
export PSM_PAIR="IST.USDC_axl"
fi

# additional env specific to a version
if test -f ./upgrade-test-scripts/$THIS_NAME/env_setup.sh; then
echo ENV_SETUP found $THIS_NAME specific env, importing...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ startAgd
if ! test -f "$HOME/.agoric/runActions-${THIS_NAME}"; then
if [[ "${USE_JS}" == "1" ]]; then
pushd upgrade-test-scripts
yarn
yarn upgrade-tests || exit 1
popd
runActions "legacy"
Expand Down

0 comments on commit 6fffcf2

Please sign in to comment.