Skip to content

Commit

Permalink
test: separate upgrade-12
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Aug 25, 2023
1 parent 22c3573 commit c75d010
Show file tree
Hide file tree
Showing 18 changed files with 218 additions and 55 deletions.
2 changes: 1 addition & 1 deletion packages/boot/test/bootstrapTests/test-zcf-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ test('run restart-vats proposal', async t => {
const zcfProbeBundle = await bundleSource(source);
await controller.validateAndInstallBundle(zcfProbeBundle);
// This test self-sufficiently builds all the artifacts it needs. The test in
// .../packages/deployment/upgradeTest/upgradeTest-scripts/agoric-upgrade-11/zoe-upgrade/
// .../packages/deployment/upgradeTest/upgradeTest-scripts/agoric-upgrade-12/zoe-upgrade/
// needs a bundled copy of ./zcfProbe.js as of the final commit that will be
// installed on-chain. Uncomment the following line and add
// `import fs from "fs";` to generate a bundle of the contract.
Expand Down
7 changes: 4 additions & 3 deletions packages/deployment/upgrade-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ SHELL ["/bin/bash", "-c"]
RUN . ./upgrade-test-scripts/start_to_to.sh

ARG DEST_IMAGE
#this is agoric-upgrade-11 / vaults+1
FROM ${DEST_IMAGE} as agoric-upgrade-11
# this is agoric-upgrade-12 supporting wallets with non-vbank assets
FROM ${DEST_IMAGE} as agoric-upgrade-12
ARG BOOTSTRAP_MODE
ENV THIS_NAME=agoric-upgrade-11 BOOTSTRAP_MODE=${BOOTSTRAP_MODE}
ENV THIS_NAME=agoric-upgrade-12 BOOTSTRAP_MODE=${BOOTSTRAP_MODE}
# this boot doesn't need an upgrade

WORKDIR /usr/src/agoric-sdk/
Expand All @@ -101,4 +101,5 @@ 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
# enter image in interactive shell
ENTRYPOINT /usr/src/agoric-sdk/upgrade-test-scripts/start_to_to.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,3 @@ testMinChildren() {
ok=$(echo $line | jq ".children | length | . > $min")
test_val "$ok" "true" "$path: more than $min children"
}

# Check brand aux data for more than just vbank assets
testMinChildren published.boardAux 3

testDisplayInfo() {
name=$1
expected=$2

line="$(agoric follow -lF :published.agoricNames.brand -o text)"
# find brand by name, then corresponding slot
id=$(echo $line | jq --arg name "$name" -r '.slots as $slots | .body | gsub("^#";"") | fromjson | .[] | select(.[0] == $name) | .[1] | capture("^[$](?<slot>0|[1-9][0-9]*)") | .slot | $slots[. | tonumber]')
echo $name Id: $id

line="$(agoric follow -lF :published.boardAux.$id -o jsonlines)"
displayInfo="$(echo $line | jq -c .displayInfo)"
test_val "$displayInfo" "$expected" "$name displayInfo from boardAux"
}

testDisplayInfo IST '{"assetKind":"nat","decimalPlaces":6}'

testPurseValuePayload() {
addr=$1
wkAsset=$2
expected=$3

line="$(agoric follow -lF :published.wallet.$addr.current -o jsonlines)"
# HACK: selecting brand by allegedName
payload=$(echo $line | jq --arg name "$wkAsset" -c '.purses[] | select(.brand | contains($name)) | .balance.value.payload')
test_val "$payload" "$expected" "$wkAsset purse for $addr"
}

# Smart wallet handles game Place assets?
testDisplayInfo Place '{"assetKind":"copyBag"}'
testPurseValuePayload $GOV1ADDR Place '[["Shire","1"],["Mordor","1"]]'

# zoe vat is at incarnation 1
echo "FIXME: bypassed zoe-full-upgrade validation"; return 0
test_val "$(yarn --silent node $upgrade11/tools/vat-status.mjs zoe)" "1" "zoe vat incarnation"
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#!/bin/bash

# agoric-upgrade-12 specific env here...
export USER2ADDR=$($binary keys show user2 -a --keyring-backend="test" 2> /dev/null)

printKeys() {
echo "========== GOVERNANCE KEYS =========="
echo "gov1: $GOV1ADDR"
cat ~/.agoric/gov1.key || true
echo "gov2: $GOV2ADDR"
cat ~/.agoric/gov2.key || true
echo "gov3: $GOV3ADDR"
cat ~/.agoric/gov3.key || true
echo "validator: $VALIDATORADDR"
cat ~/.agoric/validator.key || true
echo "user1: $USER1ADDR"
cat ~/.agoric/user1.key || true
echo "user2: $USER2ADDR"
cat ~/.agoric/user2.key || true
echo "========== GOVERNANCE KEYS =========="
}

pushPrice () {
echo ACTIONS pushPrice $1
newPrice="${1:-10.00}"
for oracleNum in {1..2}; do
if [[ ! -e "$HOME/.agoric/lastOracle" ]]; then
echo "$GOV1ADDR" > "$HOME/.agoric/lastOracle"
fi

lastOracle=$(cat "$HOME/.agoric/lastOracle")
nextOracle="$GOV1ADDR"
if [[ "$lastOracle" == "$GOV1ADDR" ]]; then
nextOracle="$GOV2ADDR"
fi
echo "Pushing Price from oracle $nextOracle"

oid="${nextOracle}_ORACLE"
offer=$(mktemp -t pushPrice.XXX)
agops oracle pushPriceRound --price "$newPrice" --oracleAdminAcceptOfferId "${!oid}" >|"$offer"
sleep 1
timeout --preserve-status 15 yarn run --silent agops perf satisfaction --from $nextOracle --executeOffer "$offer" --keyring-backend test
if [ $? -ne 0 ]; then
echo "WARNING: pushPrice for $nextOracle failed!"
fi
echo "$nextOracle" > "$HOME/.agoric/lastOracle"
done
}


# variant of pushPrice() that figures out which oracle to send from
# WIP because it doesn't always work
pushPriceOnce () {
echo ACTIONS pushPrice $1
newPrice="${1:-10.00}"
timeout 3 agoric follow -lF :published.priceFeed.ATOM-USD_price_feed.latestRound -ojson > "$HOME/.agoric/latestRound-ATOM.json"

lastStartedBy=$(jq -r .startedBy "$HOME/.agoric/latestRound-ATOM.json" || echo null)
echo lastStartedBy $lastStartedBy
nextOracle="ERROR"
# cycle to next among oracles (first of the two governance accounts)
case $lastStartedBy in
"$GOV1ADDR") nextOracle=$GOV2ADDR;;
"$GOV2ADDR") nextOracle=$GOV1ADDR;;
*)
echo last price was pushed by a different account, using GOV1
nextOracle=$GOV1ADDR
;;
esac
echo nextOracle $nextOracle

adminOfferId="${nextOracle}_ORACLE"

echo "Pushing Price from oracle $nextOracle with offer $adminOfferId"

offer=$(mktemp -t pushPrice.XXX)
agops oracle pushPriceRound --price "$newPrice" --oracleAdminAcceptOfferId "${adminOfferId}" >|"$offer"
cat "$offer"
sleep 1
timeout --preserve-status 15 yarn run --silent agops perf satisfaction --from $nextOracle --executeOffer "$offer" --keyring-backend test
if [ $? -eq 0 ]; then
echo SUCCESS
else
echo "ERROR: pushPrice failed (using $nextOracle)"
fi
}

export_genesis() {
GENESIS_EXPORT_DIR="$1"
shift
GENESIS_HEIGHT_ARG=

if [ -n "$1" ]; then
GENESIS_HEIGHT_ARG="--height $1"
shift
fi

agd export --export-dir "$GENESIS_EXPORT_DIR" $GENESIS_HEIGHT_ARG "$@"
}

make_swing_store_snapshot() {( set -euo pipefail
EXPORT_DIR="$1"
shift
/usr/src/agoric-sdk/packages/cosmic-swingset/src/export-kernel-db.js --home "$HOME/.agoric" --export-dir "$EXPORT_DIR" --verbose --artifact-mode replay --export-data-mode all "$@"

EXPORT_MANIFEST_FILE="$EXPORT_DIR/export-manifest.json"
EXPORT_HEIGHT=$(cat "$EXPORT_MANIFEST_FILE" | jq -r .blockHeight)

[ "x${WITHOUT_GENESIS_EXPORT:-0}" = "x1" ] || {
EXPORT_DATA_FILE="$EXPORT_DIR/$(cat "$EXPORT_MANIFEST_FILE" | jq -r .data)"
EXPORT_DATA_UNTRUSTED_FILE="${EXPORT_DATA_FILE%.*}-untrusted.jsonl"
EXPORT_MANIFEST="$(cat $EXPORT_MANIFEST_FILE)"

mv "$EXPORT_DATA_FILE" "$EXPORT_DATA_UNTRUSTED_FILE"
export_genesis "$EXPORT_DIR/genesis-export" $EXPORT_HEIGHT
cat $EXPORT_DIR/genesis-export/genesis.json | jq -cr '.app_state.swingset.swing_store_export_data[] | [.key,.value]' > "$EXPORT_DATA_FILE"

jq -n "$EXPORT_MANIFEST | .untrustedData=\"$(basename -- "$EXPORT_DATA_UNTRUSTED_FILE")\"" > "$EXPORT_MANIFEST_FILE"
}

echo "Successful swing-store export for block $EXPORT_HEIGHT"
)}

restore_swing_store_snapshot() {( set -euo pipefail
rm -f $HOME/.agoric/data/agoric/swingstore.sqlite
EXPORT_DIR="$1"
shift

/usr/src/agoric-sdk/packages/cosmic-swingset/src/import-kernel-db.js --home "$HOME/.agoric" --export-dir "$EXPORT_DIR" --verbose --artifact-mode replay --export-data-mode all "$@"
)}

compare_swing_store_export_data() {
EXPORT_DIR="$1"
EXPORT_MANIFEST_FILE="$EXPORT_DIR/export-manifest.json"
EXPORT_DATA_FILE="$(cat "$EXPORT_MANIFEST_FILE" | jq -r .data)"
EXPORT_DATA_UNTRUSTED_FILE="$(cat "$EXPORT_MANIFEST_FILE" | jq -r .untrustedData)"

if [ -z "$EXPORT_DATA_FILE" ]; then
echo "missing-export-data"
return
fi

if [ -z "$EXPORT_DATA_UNTRUSTED_FILE" ]; then
echo "missing-untrusted-export-data"
return
fi

diff <(cat "$EXPORT_DIR/$EXPORT_DATA_FILE" | sort) <(cat "$EXPORT_DIR/$EXPORT_DATA_UNTRUSTED_FILE" | sort) >&2 && {
echo "match"
} || {
echo "mismatch"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

. ./upgrade-test-scripts/env_setup.sh

echo Wait for actions to settle
waitForBlock 2

# CWD is agoric-sdk
upgrade12=./upgrade-test-scripts/agoric-upgrade-12

# Check brand aux data for more than just vbank assets
testMinChildren published.boardAux 3

testDisplayInfo() {
name=$1
expected=$2

line="$(agoric follow -lF :published.agoricNames.brand -o text)"
# find brand by name, then corresponding slot
id=$(echo $line | jq --arg name "$name" -r '.slots as $slots | .body | gsub("^#";"") | fromjson | .[] | select(.[0] == $name) | .[1] | capture("^[$](?<slot>0|[1-9][0-9]*)") | .slot | $slots[. | tonumber]')
echo $name Id: $id

line="$(agoric follow -lF :published.boardAux.$id -o jsonlines)"
displayInfo="$(echo $line | jq -c .displayInfo)"
test_val "$displayInfo" "$expected" "$name displayInfo from boardAux"
}

testDisplayInfo IST '{"assetKind":"nat","decimalPlaces":6}'

testPurseValuePayload() {
addr=$1
wkAsset=$2
expected=$3

line="$(agoric follow -lF :published.wallet.$addr.current -o jsonlines)"
# HACK: selecting brand by allegedName
payload=$(echo $line | jq --arg name "$wkAsset" -c '.purses[] | select(.brand | contains($name)) | .balance.value.payload')
test_val "$payload" "$expected" "$wkAsset purse for $addr"
}

# Smart wallet handles game Place assets?
testDisplayInfo Place '{"assetKind":"copyBag"}'
testPurseValuePayload $GOV1ADDR Place '[["Shire","1"],["Mordor","1"]]'

# zoe vat is at incarnation 1
echo "FIXME: bypassed zoe-full-upgrade validation"; return 0
test_val "$(yarn --silent node $upgrade12/tools/vat-status.mjs zoe)" "1" "zoe vat incarnation"
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# Propose and carry out starting game contract

SDK=${SDK:-/usr/src/agoric-sdk}
UP11=${UP11:-$SDK/upgrade-test-scripts/agoric-upgrade-11}
WFUP=${WFUP:-$UP11/wallet-all-ertp}
UP12=${UP12:-$SDK/upgrade-test-scripts/agoric-upgrade-12}
WFUP=${WFUP:-$UP12/wallet-all-ertp}

cd $WFUP

. $SDK/upgrade-test-scripts/env_setup.sh
. $UP11/env_setup.sh
. $UP12/env_setup.sh

TITLE="Start Game1 Contract"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
set -e

SDK=${SDK:-/usr/src/agoric-sdk}
UP11=${UP11:-$SDK/upgrade-test-scripts/agoric-upgrade-11}
UP12=${UP12:-$SDK/upgrade-test-scripts/agoric-upgrade-12}

cd $UP11/wallet-all-ertp
cd $UP12/wallet-all-ertp

echo +++ run walletFactory, game upgrade proposal builders +++
(agoric run $SDK/packages/builders/scripts/smart-wallet/build-walletFactory-upgrade.js; \
agoric run $SDK/packages/builders/scripts/smart-wallet/build-game1-start.js
)>/tmp/,run.log
bundles=$($UP11/tools/parseProposals.mjs </tmp/,run.log | jq -r '.bundles[]' | sort -u )
bundles=$($UP12/tools/parseProposals.mjs </tmp/,run.log | jq -r '.bundles[]' | sort -u )

echo +++ proposal evals for later +++
/bin/pwd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
set -e

SDK=${SDK:-/usr/src/agoric-sdk}
UP11=${UP11:-$SDK/upgrade-test-scripts/agoric-upgrade-11}
WFUP=${WFUP:-$UP11/wallet-all-ertp}
UP12=${UP12:-$SDK/upgrade-test-scripts/agoric-upgrade-12}
WFUP=${WFUP:-$UP12/wallet-all-ertp}

cd $WFUP

# import voteLatestProposalAndWait
. $UP11/env_setup.sh
. $UP11/../env_setup.sh
. $UP12/env_setup.sh
. $UP12/../env_setup.sh

TITLE="Add NFT/non-vbank support in WalletFactory"
DESC="Upgrade WalletFactory to support arbitrary ERTP assets such as NFTs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

set -euo pipefail

here='upgrade-test-scripts/agoric-upgrade-11/zoe-full-upgrade'
here='upgrade-test-scripts/agoric-upgrade-12/zoe-full-upgrade'

agd --chain-id=agoriclocal \
tx gov submit-proposal swingset-core-eval \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -euo pipefail
# zcf-upgrade-script.js. Instructions for updating the bundles are available
# in ../actions.sh

here='upgrade-test-scripts/agoric-upgrade-11/zoe-full-upgrade'
here='upgrade-test-scripts/agoric-upgrade-12/zoe-full-upgrade'

agd --chain-id=agoriclocal \
tx gov submit-proposal swingset-core-eval \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const ZCF_BUNDLE_ID =
'b1-3781ce16d40590a41588a472795d2487dbdd9c5f055ac9a82ff52a872cf24f1eb35c6f45d248bcbe13c12d2c1356aecaf5e81b73155ab109499f285ef83fdfd9';
const ZOE_BUNDLE_ID =
'b1-51ffc8e388df8dff7d16b670f5c2c5a2de51f23b7a9a411e90eb222c4a673b3845db2bd925bbf5f9e2bff5fb40e65aa2d366f45c186dd81d0f1517d456b8de58';
'b1-51ffc8e388df8dff7d16b670f5c2c5a2de51f23b7a9a412e90eb222c4a673b3845db2bd925bbf5f9e2bff5fb40e65aa2d366f45c186dd81d0f1517d456b8de58';

console.info('zoe upgrade: evaluating script');

Expand Down

0 comments on commit c75d010

Please sign in to comment.