diff --git a/golang/cosmos/app/app.go b/golang/cosmos/app/app.go index f5932d90c95..2caf9b410c8 100644 --- a/golang/cosmos/app/app.go +++ b/golang/cosmos/app/app.go @@ -790,13 +790,18 @@ func NewAgoricApp( app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) + const ( + upgradeName = "agoric-upgrade-12" + upgradeNameTest = "agorictest-upgrade-12" + ) + app.UpgradeKeeper.SetUpgradeHandler( upgradeName, - upgrade11Handler(app, upgradeName), + upgrade12Handler(app, upgradeName), ) app.UpgradeKeeper.SetUpgradeHandler( upgradeNameTest, - upgrade11Handler(app, upgradeNameTest), + upgrade12Handler(app, upgradeNameTest), ) if loadLatest { @@ -819,108 +824,13 @@ func NewAgoricApp( return app } -type swingStoreMigrationEventHandler struct { - swingStore sdk.KVStore -} - -func (eventHandler swingStoreMigrationEventHandler) OnExportStarted(height uint64, retrieveSwingStoreExport func() error) error { - return retrieveSwingStoreExport() -} - -func (eventHandler swingStoreMigrationEventHandler) OnExportRetrieved(provider swingsetkeeper.SwingStoreExportProvider) (err error) { - exportDataReader, err := provider.GetExportDataReader() - if err != nil { - return err - } - defer exportDataReader.Close() - - var hasExportData bool - - for { - entry, err := exportDataReader.Read() - if err == io.EOF { - break - } else if err != nil { - return err - } - hasExportData = true - if !entry.HasValue() { - return fmt.Errorf("no value for export data key %s", entry.Key()) - } - eventHandler.swingStore.Set([]byte(entry.Key()), []byte(entry.StringValue())) - } - if !hasExportData { - return fmt.Errorf("export data had no entries") - } - return nil -} - -// upgrade11Handler performs standard upgrade actions plus custom actions for upgrade-11. -func upgrade11Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgradetypes.Plan, module.VersionMap) (module.VersionMap, error) { +// upgrade12Handler performs standard upgrade actions plus custom actions for upgrade-12. +func upgrade12Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgradetypes.Plan, module.VersionMap) (module.VersionMap, error) { return func(ctx sdk.Context, plan upgradetypes.Plan, fromVm module.VersionMap) (module.VersionMap, error) { app.CheckControllerInited(false) // Record the plan to send to SwingSet app.upgradePlan = &plan - // Perform swing-store migrations. We do this in the app upgrade handler - // since it involves multiple modules (x/vstorage and x/swingset) which - // don't strictly have a version change on their own. - - // We are at the begining of the upgrade block, so all stores are commited - // as of the end of the previous block - savedBlockHeight := uint64(ctx.BlockHeight() - 1) - - // First, repair swing-store metadata in case this node was previously - // initialized from a state-sync snapshot. This is done with a check on the - // block height to catch early any hangover related mismatch. - // Only entries related to missing historical metadata are imported, but we - // don't know what these look like here, so we provide it all. - getSwingStoreExportDataFromVstorage := func() (reader agorictypes.KVEntryReader, err error) { - return agorictypes.NewVstorageDataEntriesReader( - app.VstorageKeeper.ExportStorageFromPrefix(ctx, swingsetkeeper.StoragePathSwingStore), - ), nil - } - - // We're not restoring any artifact to swing-store, nor have any to provide - readNoArtifact := func() (artifact swingsettypes.SwingStoreArtifact, err error) { - return artifact, io.EOF - } - - err := app.SwingStoreExportsHandler.RestoreExport( - swingsetkeeper.SwingStoreExportProvider{ - BlockHeight: savedBlockHeight, - GetExportDataReader: getSwingStoreExportDataFromVstorage, - ReadNextArtifact: readNoArtifact, - }, - swingsetkeeper.SwingStoreRestoreOptions{ - ArtifactMode: swingsetkeeper.SwingStoreArtifactModeNone, - ExportDataMode: swingsetkeeper.SwingStoreExportDataModeRepairMetadata, - }, - ) - if err != nil { - return nil, err - } - - // Then migrate the swing-store shadow copy: - // 1. Remove the swing-store "export data" shadow-copy entries from vstorage. - // 2. Export swing-store "export-data" (as of the previous block) through a - // handler that writes every entry into the swingset module's new Store. - app.VstorageKeeper.RemoveEntriesWithPrefix(ctx, swingsetkeeper.StoragePathSwingStore) - err = app.SwingStoreExportsHandler.InitiateExport( - savedBlockHeight, - swingStoreMigrationEventHandler{swingStore: app.SwingSetKeeper.GetSwingStore(ctx)}, - swingsetkeeper.SwingStoreExportOptions{ - ArtifactMode: swingsetkeeper.SwingStoreArtifactModeNone, - ExportDataMode: swingsetkeeper.SwingStoreExportDataModeAll, - }, - ) - if err == nil { - err = swingsetkeeper.WaitUntilSwingStoreExportDone() - } - if err != nil { - return nil, err - } - // Always run module migrations mvm, err := app.mm.RunMigrations(ctx, app.configurator, fromVm) if err != nil { diff --git a/golang/cosmos/app/const.go b/golang/cosmos/app/const.go deleted file mode 100644 index 2e7f4a2f391..00000000000 --- a/golang/cosmos/app/const.go +++ /dev/null @@ -1,6 +0,0 @@ -package gaia - -const ( - upgradeName = "agoric-upgrade-11" - upgradeNameTest = "agorictest-upgrade-11" -) diff --git a/packages/boot/test/bootstrapTests/test-zcf-upgrade.js b/packages/boot/test/bootstrapTests/test-zcf-upgrade.js index b25aa1165a1..e93e5074c89 100644 --- a/packages/boot/test/bootstrapTests/test-zcf-upgrade.js +++ b/packages/boot/test/bootstrapTests/test-zcf-upgrade.js @@ -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. diff --git a/packages/deployment/upgrade-test/Dockerfile b/packages/deployment/upgrade-test/Dockerfile index b47e690b2ac..57ebcd04e99 100644 --- a/packages/deployment/upgrade-test/Dockerfile +++ b/packages/deployment/upgrade-test/Dockerfile @@ -1,5 +1,18 @@ +# Defaults ARG DEST_IMAGE=ghcr.io/agoric/agoric-sdk:dev ARG BOOTSTRAP_MODE=main + +# TODO different naming scheme for upgrade handler (in app.go) and the image name + +### +# Kinds of layers: +# START ag0, start of the chain +# UPGRADE+TEST legacy layer type in which the chain upgrade and its tests are comingled +# UPGRADE layer that only runs the upgrade handler +# TEST layer that only tests a previous upgrade +# DEST the final layer this build is producing, opening an interactive shell + +## START # on agoric-uprade-7-2, with upgrade to agoric-upgrade-8 FROM ghcr.io/agoric/ag0:agoric-upgrade-7-2 as agoric-upgrade-7-2 ARG BOOTSTRAP_MODE @@ -11,27 +24,31 @@ 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/ SHELL ["/bin/bash", "-c"] +# this is the only layer that starts ag0 RUN . ./upgrade-test-scripts/start_ag0.sh +## UPGRADE+TEST ## this is agoric-upgrade-8 aka pismoA FROM ghcr.io/agoric/agoric-sdk:29 as agoric-upgrade-8 ARG BOOTSTRAP_MODE ENV THIS_NAME=agoric-upgrade-8 BOOTSTRAP_MODE=${BOOTSTRAP_MODE} -WORKDIR /usr/src/agoric-sdk/ +# copy from previous build +COPY --from=agoric-upgrade-7-2 /root/.agoric /root/.agoric +# boilerplate to copy scripts for this upgrade +WORKDIR /usr/src/agoric-sdk/ COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./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 SHELL ["/bin/bash", "-c"] RUN . ./upgrade-test-scripts/start_to_to.sh +## UPGRADE+TEST ARG DEST_IMAGE #this is agoric-upgrade-8-1 aka pismoB FROM ghcr.io/agoric/agoric-sdk:30 as agoric-upgrade-8-1 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 ./${THIS_NAME} ./upgrade-test-scripts/${THIS_NAME}/ @@ -40,6 +57,7 @@ RUN chmod +x ./upgrade-test-scripts/*.sh SHELL ["/bin/bash", "-c"] RUN . ./upgrade-test-scripts/start_to_to.sh +# UPGRADE+TEST ARG DEST_IMAGE # this is agoric-upgrade-9 / pismoC with upgrade to agoric-upgrade-10 FROM ghcr.io/agoric/agoric-sdk:31 as agoric-upgrade-9 @@ -55,7 +73,7 @@ RUN chmod +x ./upgrade-test-scripts/*.sh SHELL ["/bin/bash", "-c"] RUN . ./upgrade-test-scripts/start_to_to.sh - +# UPGRADE+TEST ARG DEST_IMAGE #this is agoric-upgrade-10 / vaults FROM ghcr.io/agoric/agoric-sdk:35 as agoric-upgrade-10 @@ -70,15 +88,15 @@ RUN chmod +x ./upgrade-test-scripts/*.sh SHELL ["/bin/bash", "-c"] RUN . ./upgrade-test-scripts/start_to_to.sh +# UPGRADE ARG DEST_IMAGE #this is agoric-upgrade-10 upgrading to 11 #it's a separate target because agoric-upgrade-10 takes so long to test -FROM ghcr.io/agoric/agoric-sdk:35 as agoric-upgrade-10-to-11 +FROM ghcr.io/agoric/agoric-sdk:35 as propose-agoric-upgrade-11 # This default UPGRADE_INFO_11 is to test core proposals like the network vat. # TODO: Maybe replace with a Zoe core proposal, or remove when other paths test it. ARG BOOTSTRAP_MODE UPGRADE_INFO_11='{"coreProposals":["@agoric/builders/scripts/vats/init-network.js"]}' -ENV THIS_NAME=agoric-upgrade-10-to-11 UPGRADE_TO=agoric-upgrade-11 UPGRADE_INFO=${UPGRADE_INFO_11} BOOTSTRAP_MODE=${BOOTSTRAP_MODE} - +ENV THIS_NAME=propose-agoric-upgrade-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 ./${THIS_NAME} ./upgrade-test-scripts/${THIS_NAME}/ @@ -87,18 +105,49 @@ RUN chmod +x ./upgrade-test-scripts/*.sh SHELL ["/bin/bash", "-c"] RUN . ./upgrade-test-scripts/start_to_to.sh -ARG DEST_IMAGE +# TEST #this is agoric-upgrade-11 / vaults+1 -FROM ${DEST_IMAGE} as agoric-upgrade-11 +ARG DEST_IMAGE +FROM ghcr.io/agoric/agoric-sdk:36 as agoric-upgrade-11 ARG BOOTSTRAP_MODE ENV THIS_NAME=agoric-upgrade-11 BOOTSTRAP_MODE=${BOOTSTRAP_MODE} -# this boot doesn't need an upgrade +# start-chain boilerplate +WORKDIR /usr/src/agoric-sdk/ +COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./upgrade-test-scripts/ +COPY ./${THIS_NAME} ./upgrade-test-scripts/${THIS_NAME}/ +COPY --from=propose-agoric-upgrade-11 /root/.agoric /root/.agoric +RUN chmod +x ./upgrade-test-scripts/*.sh +SHELL ["/bin/bash", "-c"] +RUN . ./upgrade-test-scripts/start_to_to.sh +# UPGRADE +ARG DEST_IMAGE +FROM ghcr.io/agoric/agoric-sdk:36 as propose-agoric-upgrade-12 +# TODO: Replace with actual Zoe core proposal for upgrade 12 (MCS, Kread, Zoe, restart-contracts, etc) +ARG BOOTSTRAP_MODE UPGRADE_INFO_12='{"coreProposals":["@agoric/builders/scripts/vats/init-network.js"]}' +ENV THIS_NAME=propose-agoric-upgrade-12 UPGRADE_TO=agoric-upgrade-12 UPGRADE_INFO=${UPGRADE_INFO_12} BOOTSTRAP_MODE=${BOOTSTRAP_MODE} +COPY --from=agoric-upgrade-11 /root/.agoric /root/.agoric +# start-chain boilerplate WORKDIR /usr/src/agoric-sdk/ COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./upgrade-test-scripts/ COPY ./${THIS_NAME} ./upgrade-test-scripts/${THIS_NAME}/ -COPY --from=agoric-upgrade-10-to-11 /root/.agoric /root/.agoric +RUN chmod +x ./upgrade-test-scripts/*.sh +SHELL ["/bin/bash", "-c"] +RUN . ./upgrade-test-scripts/start_to_to.sh + +# DEST (TEST) +#this is agoric-upgrade-12 / multi-collateral, etc. +ARG DEST_IMAGE +FROM ${DEST_IMAGE} as agoric-upgrade-12 +ARG BOOTSTRAP_MODE +ENV THIS_NAME=agoric-upgrade-12 BOOTSTRAP_MODE=${BOOTSTRAP_MODE} +COPY --from=propose-agoric-upgrade-12 /root/.agoric /root/.agoric +# start-chain boilerplate +WORKDIR /usr/src/agoric-sdk/ +COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./package.json ./*.mjs ./upgrade-test-scripts/ +COPY ./${THIS_NAME} ./upgrade-test-scripts/${THIS_NAME}/ 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 diff --git a/packages/deployment/upgrade-test/Makefile b/packages/deployment/upgrade-test/Makefile index ec333adf335..50baf2d77d2 100644 --- a/packages/deployment/upgrade-test/Makefile +++ b/packages/deployment/upgrade-test/Makefile @@ -7,7 +7,7 @@ ifeq ($(BOOTSTRAP_MODE),main) else TAG_SUFFIX=-$(BOOTSTRAP_MODE) endif -TARGET?=agoric-upgrade-11 +TARGET?=agoric-upgrade-12 dockerLabel?=$(TARGET) ifdef TMUX_CC tmuxCC=1 @@ -38,12 +38,18 @@ agoric-upgrade-9: agoric-upgrade-8-1 agoric-upgrade-10: agoric-upgrade-9 $(BUILD) --target agoric-upgrade-10 -t $(REPOSITORY):agoric-upgrade-10$(TAG_SUFFIX) -agoric-upgrade-10-to-11: agoric-upgrade-10 - $(BUILD) --target agoric-upgrade-10-to-11 -t $(REPOSITORY):agoric-upgrade-10-to-11$(TAG_SUFFIX) +propose-agoric-upgrade-11: agoric-upgrade-10 + $(BUILD) --target propose-agoric-upgrade-11 -t $(REPOSITORY):propose-agoric-upgrade-11$(TAG_SUFFIX) -agoric-upgrade-11: agoric-upgrade-10-to-11 +agoric-upgrade-11: propose-agoric-upgrade-11 $(BUILD) --target agoric-upgrade-11 -t $(REPOSITORY):agoric-upgrade-11$(TAG_SUFFIX) +propose-agoric-upgrade-12: agoric-upgrade-11 + $(BUILD) --target propose-agoric-upgrade-12 -t $(REPOSITORY):propose-agoric-upgrade-12$(TAG_SUFFIX) + +agoric-upgrade-12: propose-agoric-upgrade-12 + $(BUILD) --target agoric-upgrade-12 -t $(REPOSITORY):agoric-upgrade-12$(TAG_SUFFIX) + # build main bootstrap build: $(TARGET) @@ -65,4 +71,4 @@ run: run_bash: $(RUN) --entrypoint /bin/bash $(REPOSITORY):$(dockerLabel) -.PHONY: local_sdk agoric-upgrade-7-2 agoric-upgrade-8 agoric-upgrade-8-1 agoric-upgrade-9 agoric-upgrade-10 agoric-upgrade-11 build build_test run +.PHONY: local_sdk agoric-upgrade-7-2 agoric-upgrade-8 agoric-upgrade-8-1 agoric-upgrade-9 agoric-upgrade-10 agoric-upgrade-11 agoric-upgrade-12 build build_test run diff --git a/packages/deployment/upgrade-test/Readme.md b/packages/deployment/upgrade-test/Readme.md index 3b3e233ecb4..44a6ce44268 100644 --- a/packages/deployment/upgrade-test/Readme.md +++ b/packages/deployment/upgrade-test/Readme.md @@ -102,6 +102,21 @@ docker exec -it sweet_edison bash To make the wallet ui talk to your local chain, set the network config to `https://local.agoric.net/network-config` +## To add an upgrade + +1. Update the upgrade handler in app.go +2. Duplicate the last pair of UPGRADE and TEST blocks +3. Update their number from the UPGRADE / DEST block at the end +4. Make directory for tests (e.g. `agoric-upgrade-12`) +4. Make directory for ugprade (e.g. `propose-agoric-upgrade-12` with a `.keep`) +5. Update the UPGRADE/DEST pair to be your new upgrade (THIS_NAME matching the upgrade handler string in app.go) +6. Update the `Makefile` + - the two targets to `Makefile` (e.g. `propose-agoric-upgrade-12` and `agoric-upgrade-12`) + - set the default TARGET (e.g. `agoric-upgrade-12`) + - add the DEST target to the `.phony` in `Makefile` +7. Test with `make local_sdk build run` + + ## Development You can iterate on a particular upgrade by targeting. When you exit and run again, it will be a fresh state. diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/actions.sh b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/actions.sh index 620d58403be..d10fcbee0d3 100755 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/actions.sh +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/actions.sh @@ -46,86 +46,3 @@ agops perf satisfaction --from "$GOV1ADDR" --executeOffer "$OFFER" --keyring-bac test_val $(agoric follow -l -F :published.vaultFactory.managers.manager0.vaults.vault3 -o jsonlines | jq -r '.vaultState') "closed" "vault3 is closed" test_val $(agoric follow -l -F :published.vaultFactory.managers.manager0.vaults.vault3 -o jsonlines | jq -r '.locked.value') "0" "vault3 contains no collateral" test_val $(agoric follow -l -F :published.vaultFactory.managers.manager0.vaults.vault3 -o jsonlines | jq -r '.debtSnapshot.debt.value') "0" "vault3 has no debt" - -upgrade11=$SDK/upgrade-test-scripts/agoric-upgrade-11 -cd $upgrade11 - -## build proposal and install bundles -waitForBlock 2 -./tools/mint-ist.sh -./wallet-all-ertp/wf-install-bundles.sh - -## upgrade wallet factory -./wallet-all-ertp/wf-propose.sh - -## start game1 -./wallet-all-ertp/wf-game-propose.sh - -# Pay 0.25IST join the game and get some places -node ./wallet-all-ertp/gen-game-offer.mjs Shire Mordor >/tmp/,join.json -agops perf satisfaction --from $GOV1ADDR --executeOffer /tmp/,join.json --keyring-backend=test - -cd $SDK - -###################################################################### -# FIXME: remove this line when these tests don't hardcode bundle hashes. -echo 1>&2 "FIXME: skipping zoe-full-upgrade tests"; return 0 - -# Pre-steps: -# * fill Wallets -# * build and install bundles -# * create instance of prober contract and run expecting no atomicRearrange -# -# Action: -# * upgrade Zoe and ZCF -# -# Finish -# * create instance of prober contract and run expecting to see atomicRearrange - -yarn --silent bundle-source --cache-json /tmp packages/zoe/src/contractFacet/vatRoot.js Zcf-upgrade -yarn --silent bundle-source --cache-json /tmp packages/vats/src/vat-zoe.js Zoe-upgrade -yarn --silent bundle-source --cache-json /tmp packages/boot/test/bootstrapTests/zcfProbe.js prober-contract - -echo +++ checking Zoe/Zcf hashes +++ -ZCF_HASH=`jq -r .endoZipBase64Sha512 /tmp/bundle-Zcf-upgrade.json` -ZOE_HASH=`jq -r .endoZipBase64Sha512 /tmp/bundle-Zoe-upgrade.json` -echo bundle-Zcf-upgrade.json $ZCF_HASH -grep $ZCF_HASH $upgrade11/zoe-full-upgrade/zcf-upgrade-script.js || exit 1 -echo bundle-Zoe-upgrade.json $ZOE_HASH -grep $ZOE_HASH $upgrade11/zoe-full-upgrade/zcf-upgrade-script.js || exit 1 - -echo +++ prober hash +++ -PROBER_HASH=`jq -r .endoZipBase64Sha512 /tmp/bundle-prober-contract.json` -echo bundle-prober-contract.json $PROBER_HASH -grep $PROBER_HASH $upgrade11/zoe-full-upgrade/run-prober-script.js || exit 1 - -echo +++++ fill wallet +++++ -agd tx bank send validator $GOV1ADDR 12340000000${ATOM_DENOM} --from validator --chain-id agoriclocal --keyring-backend test --yes -agops vaults open --wantMinted 10000 --giveCollateral 2000 > wantIST -agops perf satisfaction --executeOffer wantIST --from gov1 --keyring-backend test - - -echo +++++ install bundles +++++ -for f in /tmp/bundle-{Z*-upgrade,prober-contract}.json; do - echo installing $f - agd tx swingset install-bundle "@$f" \ - --from gov1 --keyring-backend=test --gas=auto \ - --chain-id=agoriclocal -bblock --yes -done - - -echo +++++ Run prober first time +++++ -$upgrade11/zoe-full-upgrade/run-prober.sh -test_val "$(agd query vstorage data published.prober-asid9a -o jsonlines | jq -r '.value' | jq -r '.values[0]')" "false" "Prober calling zcf.atomicReallocate()" - - -# upgrade zoe to a version that can change which ZCF is installed; tell Zoe to -# use a new version of ZCF. THIS MATCHES THE UPGRADE OF THE LIVE CHAIN -echo +++++ upgrade Zoe and ZCF +++++ -$upgrade11/zoe-full-upgrade/zcf-upgrade-driver.sh - - -echo +++++ Run prober second time +++++ -# Re-run prober test and expect internal atomicRearrange. -$upgrade11/zoe-full-upgrade/run-prober.sh -test_val "$(agd query vstorage data published.prober-asid9a -o jsonlines | jq -r '.value' | jq -r '.values[0]')" "true" "Prober called zcf.atomicReallocate()" diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/pre_test.sh b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/pre_test.sh index 347ebd4b190..f217ce3a4cc 100755 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/pre_test.sh +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/pre_test.sh @@ -5,14 +5,6 @@ echo Wait for upgrade to settle waitForBlock 5 -# CWD is agoric-sdk -upgrade11=./upgrade-test-scripts/agoric-upgrade-11 - -test_val "$(agd query vstorage children published.boardAux -o json | jq .children)" "[]" "no boardAux children yet" - -# zoe vat is at incarnation 0 -test_val "$(yarn --silent node $upgrade11/tools/vat-status.mjs zoe)" "0" "zoe vat incarnation" - # validate agoric-upgrade-10 metrics after update test_val $(agd q vstorage children published.vaultFactory.managers.manager0.vaults -o json | jq -r '.children | length') 3 "we have three vaults" diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/test.sh b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/test.sh index a063dc84866..a828ea1a05b 100755 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/test.sh +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/test.sh @@ -5,9 +5,6 @@ echo Wait for actions to settle waitForBlock 2 -# CWD is agoric-sdk -upgrade11=./upgrade-test-scripts/agoric-upgrade-11 - # verify swing-store export-data is consistent and perform genesis style "upgrade" killAgd EXPORT_DIR=$(mktemp -t -d swing-store-export-upgrade-11-XXX) @@ -23,49 +20,3 @@ mv $TMP_GENESIS_DIR/priv_validator_state.json $HOME/.agoric/data mv $TMP_GENESIS_DIR/* $HOME/.agoric/config/ startAgd rm -rf $EXPORT_DIR - -testMinChildren() { - path=$1 - min=$2 - line="$(agd query vstorage children $path -o jsonlines)" - 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("^[$](?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" diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/.gitignore b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/.gitignore similarity index 100% rename from packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/.gitignore rename to packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/.gitignore diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/actions.sh b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/actions.sh new file mode 100755 index 00000000000..62efb399d07 --- /dev/null +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/actions.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +# Dockerfile in upgrade-test sets: +# WORKDIR /usr/src/agoric-sdk/ +# Overriding it during development has occasionally been useful. +SDK=${SDK:-/usr/src/agoric-sdk} +. $SDK/upgrade-test-scripts/env_setup.sh + +# Enable debugging +set -x + +AGUP=$SDK/upgrade-test-scripts/agoric-upgrade-12 +cd $AGUP + +## build proposal and install bundles +waitForBlock 2 +./tools/mint-ist.sh +./wallet-all-ertp/wf-install-bundles.sh + +## upgrade wallet factory +./wallet-all-ertp/wf-propose.sh + +## start game1 +./wallet-all-ertp/wf-game-propose.sh + +# Pay 0.25IST join the game and get some places +node ./wallet-all-ertp/gen-game-offer.mjs Shire Mordor >/tmp/,join.json +agops perf satisfaction --from $GOV1ADDR --executeOffer /tmp/,join.json --keyring-backend=test + +cd $SDK + +###################################################################### +# FIXME: remove this line when these tests don't hardcode bundle hashes. +echo 1>&2 "FIXME: skipping zoe-full-upgrade tests"; return 0 + +# Pre-steps: +# * fill Wallets +# * build and install bundles +# * create instance of prober contract and run expecting no atomicRearrange +# +# Action: +# * upgrade Zoe and ZCF +# +# Finish +# * create instance of prober contract and run expecting to see atomicRearrange + +yarn --silent bundle-source --cache-json /tmp packages/zoe/src/contractFacet/vatRoot.js Zcf-upgrade +yarn --silent bundle-source --cache-json /tmp packages/vats/src/vat-zoe.js Zoe-upgrade +yarn --silent bundle-source --cache-json /tmp packages/boot/test/bootstrapTests/zcfProbe.js prober-contract + +echo +++ checking Zoe/Zcf hashes +++ +ZCF_HASH=`jq -r .endoZipBase64Sha512 /tmp/bundle-Zcf-upgrade.json` +ZOE_HASH=`jq -r .endoZipBase64Sha512 /tmp/bundle-Zoe-upgrade.json` +echo bundle-Zcf-upgrade.json $ZCF_HASH +grep $ZCF_HASH $AGUP/zoe-full-upgrade/zcf-upgrade-script.js || exit 1 +echo bundle-Zoe-upgrade.json $ZOE_HASH +grep $ZOE_HASH $AGUP/zoe-full-upgrade/zcf-upgrade-script.js || exit 1 + +echo +++ prober hash +++ +PROBER_HASH=`jq -r .endoZipBase64Sha512 /tmp/bundle-prober-contract.json` +echo bundle-prober-contract.json $PROBER_HASH +grep $PROBER_HASH $AGUP/zoe-full-upgrade/run-prober-script.js || exit 1 + +echo +++++ fill wallet +++++ +agd tx bank send validator $GOV1ADDR 12340000000${ATOM_DENOM} --from validator --chain-id agoriclocal --keyring-backend test --yes +agops vaults open --wantMinted 10000 --giveCollateral 2000 > wantIST +agops perf satisfaction --executeOffer wantIST --from gov1 --keyring-backend test + + +echo +++++ install bundles +++++ +for f in /tmp/bundle-{Z*-upgrade,prober-contract}.json; do + echo installing $f + agd tx swingset install-bundle "@$f" \ + --from gov1 --keyring-backend=test --gas=auto \ + --chain-id=agoriclocal -bblock --yes +done + + +echo +++++ Run prober first time +++++ +$AGUP/zoe-full-upgrade/run-prober.sh +test_val "$(agd query vstorage data published.prober-asid9a -o jsonlines | jq -r '.value' | jq -r '.values[0]')" "false" "Prober calling zcf.atomicReallocate()" + + +# upgrade zoe to a version that can change which ZCF is installed; tell Zoe to +# use a new version of ZCF. THIS MATCHES THE UPGRADE OF THE LIVE CHAIN +echo +++++ upgrade Zoe and ZCF +++++ +$AGUP/zoe-full-upgrade/zcf-upgrade-driver.sh + + +echo +++++ Run prober second time +++++ +# Re-run prober test and expect internal atomicRearrange. +$AGUP/zoe-full-upgrade/run-prober.sh +test_val "$(agd query vstorage data published.prober-asid9a -o jsonlines | jq -r '.value' | jq -r '.values[0]')" "true" "Prober called zcf.atomicReallocate()" diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/env_setup.sh b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/env_setup.sh new file mode 100644 index 00000000000..c221fd9a60f --- /dev/null +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/env_setup.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +# agoric-upgrade-12 specific env here... diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/pre_test.sh b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/pre_test.sh new file mode 100755 index 00000000000..334821210f7 --- /dev/null +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/pre_test.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +. ./upgrade-test-scripts/env_setup.sh + +echo Wait for upgrade to settle +waitForBlock 5 + +# CWD is agoric-sdk +upgrade12=./upgrade-test-scripts/agoric-upgrade-12 + +test_val "$(agd query vstorage children published.boardAux -o json | jq .children)" "[]" "no boardAux children yet" + +# zoe vat is at incarnation 0 +test_val "$(yarn --silent node $upgrade12/tools/vat-status.mjs zoe)" "0" "zoe vat incarnation" diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/test.sh b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/test.sh new file mode 100755 index 00000000000..ad007522b6a --- /dev/null +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/test.sh @@ -0,0 +1,56 @@ +#!/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 + + +testMinChildren() { + path=$1 + min=$2 + line="$(agd query vstorage children $path -o jsonlines)" + 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("^[$](?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" diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/tools/mint-ist.sh b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/tools/mint-ist.sh similarity index 100% rename from packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/tools/mint-ist.sh rename to packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/tools/mint-ist.sh diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/tools/parseProposals.mjs b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/tools/parseProposals.mjs similarity index 100% rename from packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/tools/parseProposals.mjs rename to packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/tools/parseProposals.mjs diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/tools/vat-status.mjs b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/tools/vat-status.mjs similarity index 100% rename from packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/tools/vat-status.mjs rename to packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/tools/vat-status.mjs diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/wallet-all-ertp/gen-game-offer.mjs b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/wallet-all-ertp/gen-game-offer.mjs similarity index 100% rename from packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/wallet-all-ertp/gen-game-offer.mjs rename to packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/wallet-all-ertp/gen-game-offer.mjs diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/wallet-all-ertp/wf-game-propose.sh b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/wallet-all-ertp/wf-game-propose.sh similarity index 87% rename from packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/wallet-all-ertp/wf-game-propose.sh rename to packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/wallet-all-ertp/wf-game-propose.sh index 80b1e1d41b1..80c5e417eec 100755 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/wallet-all-ertp/wf-game-propose.sh +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/wallet-all-ertp/wf-game-propose.sh @@ -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" diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/wallet-all-ertp/wf-install-bundles.sh b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/wallet-all-ertp/wf-install-bundles.sh similarity index 84% rename from packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/wallet-all-ertp/wf-install-bundles.sh rename to packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/wallet-all-ertp/wf-install-bundles.sh index b4432fdf7a7..c04aec12bd7 100755 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/wallet-all-ertp/wf-install-bundles.sh +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-12/wallet-all-ertp/wf-install-bundles.sh @@ -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