Skip to content

Commit

Permalink
Merge pull request #8588 from Agoric/mhofman/8578-upgrade-13-name
Browse files Browse the repository at this point in the history
agoric-upgrade-13
  • Loading branch information
mhofman authored Dec 1, 2023
2 parents 26244e8 + 6426775 commit 5fe83be
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 172 deletions.
18 changes: 6 additions & 12 deletions golang/cosmos/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,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 @@ -792,17 +791,17 @@ func NewAgoricApp(
app.SetEndBlocker(app.EndBlocker)

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

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

if loadLatest {
Expand All @@ -825,18 +824,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) {
// upgrade13Handler performs standard upgrade actions plus custom actions for upgrade-13.
func upgrade13Handler(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
16 changes: 8 additions & 8 deletions packages/deployment/upgrade-test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Defaults
ARG BASE_IMAGE=ghcr.io/agoric/agoric-3-proposals@sha256:ac10c09b5927d759d37b1525b5a0bc4aeb3034df8d0f0fbb15b51203555ffb1b
ARG BASE_IMAGE=ghcr.io/agoric/agoric-3-proposals:pr-33
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

# UPGRADE
FROM ${BASE_IMAGE} as propose-agoric-upgrade-12
ARG BOOTSTRAP_MODE UPGRADE_INFO_12
ENV THIS_NAME= UPGRADE_TO=agoric-upgrade-12 UPGRADE_INFO=${UPGRADE_INFO_12} BOOTSTRAP_MODE=${BOOTSTRAP_MODE}
FROM ${BASE_IMAGE} as propose-agoric-upgrade-13
ARG BOOTSTRAP_MODE UPGRADE_INFO
ENV THIS_NAME= UPGRADE_TO="agoric-upgrade-13" 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 agoric-upgrade-13
ARG DEST_IMAGE
FROM ${DEST_IMAGE} as agoric-upgrade-12
FROM ${DEST_IMAGE} as agoric-upgrade-13
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=agoric-upgrade-13 BOOTSTRAP_MODE=${BOOTSTRAP_MODE} USE_JS=1
COPY --from=propose-agoric-upgrade-13 /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 @@ -2,7 +2,7 @@ REPOSITORY = agoric/upgrade-test
# use :dev (latest prerelease image) unless we build local sdk
DEST_IMAGE ?= $(if $(findstring local_sdk,$(MAKECMDGOALS)),ghcr.io/agoric/agoric-sdk:latest,ghcr.io/agoric/agoric-sdk:dev)
BOOTSTRAP_MODE?=main
TARGET?=agoric-upgrade-12
TARGET?=agoric-upgrade-13
dockerLabel?=$(TARGET)
@echo target: $(TARGET)

Expand All @@ -13,11 +13,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-agoric-upgrade-13:
$(BUILD) --target propose-agoric-upgrade-13 -t $(REPOSITORY):propose-agoric-upgrade-13$(TAG_SUFFIX)

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

# build main bootstrap
build: $(TARGET)
Expand All @@ -43,4 +43,4 @@ run_test:
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 agoric-upgrade-13 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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import test from 'ava';

import { agops } from '../cliHelper.js';
import { GOV1ADDR } from '../constants.js';
import { adjustVault, closeVault, mintIST, openVault } from '../econHelpers.js';

test.before(async t => {
await mintIST(GOV1ADDR, 12340000000, 10000, 2000);
});

test.skip('Open Vaults', async t => {
const currentVaults = await agops.vaults('list', '--from', GOV1ADDR);
t.is(currentVaults.length, 5);

// TODO get as return value from openVault
const vaultId = 'vault6';
await openVault(GOV1ADDR, 7, 11);
await adjustVault(GOV1ADDR, vaultId, { giveMinted: 1.5 });
await adjustVault(GOV1ADDR, vaultId, { giveCollateral: 2.0 });
await closeVault(GOV1ADDR, vaultId, 5.75);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import test from 'ava';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import test from 'ava';

import { waitForBlock } from '../commonUpgradeHelpers.js';

test.before(async () => {
console.log('Wait for upgrade to settle');

await waitForBlock(5);
});

0 comments on commit 5fe83be

Please sign in to comment.