Skip to content

Commit

Permalink
Merge pull request #8587 from Agoric/mhofman/8578-upgrade-name-master
Browse files Browse the repository at this point in the history
Unreleased upgrade name for master branch
  • Loading branch information
mergify[bot] authored Dec 1, 2023
2 parents 3238732 + 4a5710e commit 312271b
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 83 deletions.
18 changes: 6 additions & 12 deletions golang/cosmos/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ import (
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"

gaiaappparams "github.com/Agoric/agoric-sdk/golang/cosmos/app/params"
Expand Down Expand Up @@ -793,17 +792,17 @@ func NewAgoricApp(
app.SetEndBlocker(app.EndBlocker)

const (
upgradeName = "agoric-upgrade-12"
upgradeNameTest = "agorictest-upgrade-12"
upgradeName = "UNRELEASED_UPGRADE"
upgradeNameTest = "UNRELEASED_TEST_UPGRADE"
)

app.UpgradeKeeper.SetUpgradeHandler(
upgradeName,
upgrade12Handler(app, upgradeName),
unreleasedUpgradeHandler(app, upgradeName),
)
app.UpgradeKeeper.SetUpgradeHandler(
upgradeNameTest,
upgrade12Handler(app, upgradeNameTest),
unreleasedUpgradeHandler(app, upgradeNameTest),
)

if loadLatest {
Expand All @@ -826,18 +825,13 @@ func NewAgoricApp(
return app
}

// 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) {
// unreleasedUpgradeHandler performs standard upgrade actions plus custom actions for the unreleased upgrade.
func unreleasedUpgradeHandler(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

// Reflect default BlockParams.MaxBytes change to current params
cp := app.BaseApp.GetConsensusParams(ctx)
cp.Block.MaxBytes = tmtypes.DefaultBlockParams().MaxBytes
app.BaseApp.StoreConsensusParams(ctx, cp)

// Always run module migrations
mvm, err := app.mm.RunMigrations(ctx, app.configurator, fromVm)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/test/bootstrapTests/test-zcf-upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,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-12/zoe-upgrade/
// .../packages/deployment/upgradeTest/upgrade-test-scripts/unreleased-upgrade/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
16 changes: 8 additions & 8 deletions packages/deployment/upgrade-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ ARG BOOTSTRAP_MODE=main
# TODO different naming scheme for upgrade handler (in app.go) and the image name

# UPGRADE
FROM ${BASE_IMAGE} 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= UPGRADE_TO=agoric-upgrade-12 UPGRADE_INFO=${UPGRADE_INFO_12} BOOTSTRAP_MODE=${BOOTSTRAP_MODE}
FROM ${BASE_IMAGE} as propose-unreleased-upgrade
# TODO: Replace with actual Zoe core proposal for vat upgrades (MCS, Kread, Zoe, restart-contracts, etc)
ARG BOOTSTRAP_MODE UPGRADE_INFO='{"coreProposals":["@agoric/builders/scripts/vats/init-network.js"]}'
ENV THIS_NAME= UPGRADE_TO="UNRELEASED_UPGRADE" UPGRADE_INFO=${UPGRADE_INFO} BOOTSTRAP_MODE=${BOOTSTRAP_MODE}

WORKDIR /usr/src/agoric-sdk/
COPY --chmod=755 ./env_setup.sh ./start_to_to.sh ./upgrade-test-scripts/
SHELL ["/bin/bash", "-c"]
RUN . ./upgrade-test-scripts/start_to_to.sh

# DEST (TEST)
#this is agoric-upgrade-12 / multi-collateral, etc.
#this is unreleased-upgrade
ARG DEST_IMAGE
FROM ${DEST_IMAGE} as agoric-upgrade-12
FROM ${DEST_IMAGE} as unreleased-upgrade
ARG BOOTSTRAP_MODE
ENV THIS_NAME=agoric-upgrade-12 BOOTSTRAP_MODE=${BOOTSTRAP_MODE} USE_JS=1
COPY --from=propose-agoric-upgrade-12 /root/.agoric /root/.agoric
ENV THIS_NAME=unreleased-upgrade BOOTSTRAP_MODE=${BOOTSTRAP_MODE} USE_JS=1
COPY --from=propose-unreleased-upgrade /root/.agoric /root/.agoric
# start-chain boilerplate
WORKDIR /usr/src/agoric-sdk/
COPY ./env_setup.sh ./start_to_to.sh ./package.json ./*.js ./upgrade-test-scripts/
Expand Down
12 changes: 6 additions & 6 deletions packages/deployment/upgrade-test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ifeq ($(BOOTSTRAP_MODE),main)
else
TAG_SUFFIX=-$(BOOTSTRAP_MODE)
endif
TARGET?=agoric-upgrade-12
TARGET?=unreleased-upgrade
dockerLabel?=$(TARGET)
@echo target: $(TARGET)

Expand All @@ -18,11 +18,11 @@ BUILD = docker build --progress=plain $(BUILD_OPTS) \
--build-arg BOOTSTRAP_MODE=$(BOOTSTRAP_MODE) --build-arg DEST_IMAGE=$(DEST_IMAGE) \
-f Dockerfile upgrade-test-scripts

propose-agoric-upgrade-12:
$(BUILD) --target propose-agoric-upgrade-12 -t $(REPOSITORY):propose-agoric-upgrade-12$(TAG_SUFFIX)
propose-unreleased-upgrade:
$(BUILD) --target propose-unreleased-upgrade -t $(REPOSITORY):propose-unreleased-upgrade$(TAG_SUFFIX)

agoric-upgrade-12: propose-agoric-upgrade-12
$(BUILD) --target agoric-upgrade-12 -t $(REPOSITORY):agoric-upgrade-12$(TAG_SUFFIX)
unreleased-upgrade: propose-unreleased-upgrade
$(BUILD) --target unreleased-upgrade -t $(REPOSITORY):unreleased-upgrade$(TAG_SUFFIX)

# build main bootstrap
build: $(TARGET)
Expand Down Expand Up @@ -51,4 +51,4 @@ run_bash:
shell:
docker exec -it `docker ps --latest --format json | jq -r .Names` bash

.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
.PHONY: local_sdk unreleased-upgrade build build_test run
50 changes: 8 additions & 42 deletions packages/deployment/upgrade-test/Readme.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
# Dockerized Chain Upgrade Tester

This will build all previous upgrades and upgrade each one.

## Upgrades

| number | description | notes |
| ------ | -------------- | -------------------------------------------------------------------------- |
| 8 | PismoA | Runs with Pismo release agoric-sdk (including CLI) |
| 8.1 | PismoB |
| 9 | PismoC |
| 10 | --> Vaults | Runs with latest SDK. Tests backwards compatibility with Pismo vstorage. |
| 11 | Vaults --> V+1 | Anticipated upgrade. Tests that Vaults release _can be_ upgraded in place. |
This will build an image upgrade of [agoric-3-proposals](https://github.com/Agoric/agoric-3-proposals), a Docker based environment simulating the agoric-3 mainnet chain, using the latest agoric-sdk.

## Testing

**To build the images to latest**
**To build the upgrade image**

```shell
make build
Expand All @@ -24,7 +14,7 @@ By default pre-releases use the lastest image tagged `dev` in our [container rep
a specific build:

```shell
DEST_IMAGE=docker pull ghcr.io/agoric/agoric-sdk:20230515033839-e56ae7
DEST_IMAGE=ghcr.io/agoric/agoric-sdk:20230515033839-e56ae7
```
To use a build based on local changes:
```shell
Expand All @@ -33,7 +23,7 @@ make local_sdk build
# or DEST_IMAGE=ghcr.io/agoric/agoric-sdk:latest make build
```

**To run the latest upgrade interactively**
**To run the upgrade interactively**

```shell
make run
Expand All @@ -54,15 +44,6 @@ If you run into other problems, you might have a local `agoric-sdk:latest` that
is stale. Either `make local_sdk` or delete your local image so Docker pulls
from the repository instead.

**To build and run a specific upgrade**

```shell
TARGET=agoric-upgrade-10 make build run
```

This will put you in `/usr/src/agoric-sdk`. You'll run commands from here. `upgrade-test-scripts` is copied here with only the test scripts for the current image.


If you lose the connection and want to get back,
```sh
# find the container id
Expand All @@ -75,7 +56,7 @@ docker attach sweet_edison

```shell
json='{"some":"json","here":123}'
make build BUILD_OPTS="--build-arg UPGRADE_INFO_11='$json'"
make build BUILD_OPTS="--build-arg UPGRADE_INFO='$json'"
```

Search this directory for `UPGRADE_INFO` if you want to see how it is plumbed
Expand All @@ -101,24 +82,9 @@ make shell
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.
When you exit and run again, the container will be a fresh state.

By default targets that use "agoric-sdk:latest" will source from CI builds. To use your local checkout of agoric-sdk inside Docker run,

Expand All @@ -127,9 +93,9 @@ make local_sdk
```
Builds an image: ghcr.io/agoric/agoric-sdk:latest that will be used by all your builds.

That will produce the an image tagged agoric-sdk:latest in your local resolution. (Then run `make build run` again.)
That will produce an image tagged agoric-sdk:latest in your local resolution. (Then run `make build run` again.)

You can send information from one run to the next using `/envs`. A release N can append ENV variable setting shell commands to `"$HOME/.agoric/envs"`. The N+1 release will then have them in its environment. (Because `env_setup.sh` starts with `source "$HOME/.agoric/envs"`)
For more details about the docker upgrade test framework, refer to the [agoric-3-proposals](https://github.com/Agoric/agoric-3-proposals) repository.

### IDE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"scripts": {
"agops": "yarn --cwd /usr/src/agoric-sdk/ --silent agops",
"upgrade-tests": "ava --serial agoric-upgrade*/**/pre.test.js agoric-upgrade*/**/actions.test.js agoric-upgrade*/**/post.test.js"
"upgrade-tests": "ava --serial */**/pre.test.js */**/actions.test.js */**/post.test.js"
},
"ava": {
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,3 @@ test('Ensure Network Vat is at 0', async t => {
const incarnation = await getIncarnation('network');
t.is(incarnation, 0);
});

test('Ensure MaxBytes param was updated', async t => {
const { value: rawParams } = await agd.query(
'params',
'subspace',
'baseapp',
'BlockParams',
);
const blockParams = JSON.parse(rawParams);
t.is(blockParams.max_bytes, '5242880');
});
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-12/zoe-full-upgrade'
here='upgrade-test-scripts/unreleased-upgrade/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-12/zoe-full-upgrade'
here='upgrade-test-scripts/unreleased-upgrade/zoe-full-upgrade'

agd --chain-id=agoriclocal \
tx gov submit-proposal swingset-core-eval \
Expand Down

0 comments on commit 312271b

Please sign in to comment.