Skip to content

Commit

Permalink
ICA Genesis State x Docker builds x Wasmd 0.29-rc1 (CosmosContracts#297)
Browse files Browse the repository at this point in the history
* hotfix: wasmvm 1.0.0 -> 1.1.0

* hotfix: update shasums

* hotfix: enable cosmwasm_1_1 in app.go

* Add genica command to instantiate default ICA params, and add that to docker build

* wasmd 0.29.0-rc0 -> 0.29.0-rc1

* chore: tidy

* tooling: Dockerfile libwasm 1.1.0 -> 1.1.1

* ci: update to new refs that account for changes in rc

* chore: add ICA changes from v10

* chore: also update compose file

* chore: update ICA allowed messages to match v10.0.2

* fix: multisend isn't actually in v10.0.2, msgvoteweighted is

* feat: separate upgrade handlers out so they remain documented

* chore: add instantiate2 msg to match wasmd 0.29

* chore: add placeholders for messages that will be added in v11

* chore: shut up the pendantic linter

* ci: remove superlinter as it adds no value

* deps: wasmd 0.29.0-rc1 -> rc2
  • Loading branch information
the-frey authored Oct 6, 2022
1 parent 6378bf5 commit 1e03aae
Show file tree
Hide file tree
Showing 20 changed files with 229 additions and 48 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
version: 2
updates:
- package-ecosystem: github-actions
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
on: [push, pull_request]
name: every commit
jobs:
Expand All @@ -10,7 +11,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.18
- run: go build ./...

test:
Expand All @@ -20,13 +21,13 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.18
- name: Checkout code
uses: actions/checkout@v3
- name: Test
run: go test ./...

# Use --check or --exit-code when available (Go 1.19?)
# Use --check or --exit-code when available (Go 1.18?)
# https://github.com/golang/go/issues/27005
tidy:
runs-on: ubuntu-latest
Expand All @@ -36,7 +37,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.18
- run: |
go mod tidy
CHANGES_IN_REPO=$(git status --porcelain)
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Build Docker Image on PR

on:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# THIS GITHUB ACTION LIFTED WITH LOVE FROM THE COSMOS-SDK
name: "CodeQL"

Expand Down Expand Up @@ -26,7 +27,7 @@ jobs:
uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.18
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Build and Push Docker Image

on:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: golangci-lint
on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gov_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: 'CosmosContracts/cw-unity-prop'
ref: 'v0.3.3'
ref: 'v0.3.4-alpha'
- name: Test gov deploy
run: |
chmod a+x ./scripts/deploy_ci.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gov_submit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: 'CosmosContracts/cw-unity-prop'
ref: 'v0.3.3'
ref: 'v0.3.4-alpha'
- name: Test smart contract gov prop
run: |
chmod a+x ./scripts/submit_gov_ci.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: 'envoylabs/whoami'
ref: 'v0.7.0'
ref: 'v0.7.1-alpha'
- name: Run deploy script
run: |
chmod a+x ./scripts/deploy_ci.sh
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: release binary

on:
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/superlinter.yml

This file was deleted.

8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ WORKDIR /code
COPY . /code/

# See https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.1.1/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.1.1/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 9ecb037336bd56076573dc18c26631a9d2099a7f2b40dc04b6cae31ffb4c8f9a
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 6e4de7ba9bad4ae9679c7f9ecf7e283dd0160e71567c6a7be6ae47c81ebe7f32

# Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc`
RUN cp "/lib/libwasmvm_muslc.$(uname -m).a" /lib/libwasmvm_muslc.a
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func New(

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
supportedFeatures := "iterator,staking,stargate"
supportedFeatures := "iterator,staking,stargate,cosmwasm_1_1"
app.wasmKeeper = wasm.NewKeeper(
appCodec,
keys[wasm.StoreKey],
Expand Down
100 changes: 100 additions & 0 deletions app/upgrades/upgrade_handlers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package upgrades

import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icahostkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"

icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"
)

// CreateV10UpgradeHandler makes an upgrade handler for v11 of Juno
func CreateV10UpgradeHandler(mm *module.Manager, cfg module.Configurator, icahostkeeper *icahostkeeper.Keeper) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {

// update ICA Host to catch missed msg
// enumerate all because it's easier to reason about
newIcaHostParams := icahosttypes.Params{
HostEnabled: true,
AllowMessages: []string{
sdk.MsgTypeURL(&ibctransfertypes.MsgTransfer{}), // missed but asked for

sdk.MsgTypeURL(&banktypes.MsgSend{}),
sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}),
sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}), // this was missed last time
sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}),
sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}),
sdk.MsgTypeURL(&stakingtypes.MsgEditValidator{}),
sdk.MsgTypeURL(&distrtypes.MsgWithdrawDelegatorReward{}),
sdk.MsgTypeURL(&distrtypes.MsgSetWithdrawAddress{}),
sdk.MsgTypeURL(&distrtypes.MsgWithdrawValidatorCommission{}),
sdk.MsgTypeURL(&distrtypes.MsgFundCommunityPool{}),
sdk.MsgTypeURL(&govtypes.MsgVote{}),
sdk.MsgTypeURL(&govtypes.MsgVoteWeighted{}), // required by quick
sdk.MsgTypeURL(&authz.MsgExec{}),
sdk.MsgTypeURL(&authz.MsgGrant{}),
sdk.MsgTypeURL(&authz.MsgRevoke{}),
// wasm msgs here
// note we only support these three for now
sdk.MsgTypeURL(&wasmtypes.MsgStoreCode{}),
sdk.MsgTypeURL(&wasmtypes.MsgInstantiateContract{}),
sdk.MsgTypeURL(&wasmtypes.MsgExecuteContract{}),
},
}
icahostkeeper.SetParams(ctx, newIcaHostParams)

// mint module consensus version bumped
return mm.RunMigrations(ctx, cfg, vm)

}
}

// CreateV11UpgradeHandler makes an upgrade handler for v11 of Juno
func CreateV11UpgradeHandler(mm *module.Manager, cfg module.Configurator, icahostkeeper *icahostkeeper.Keeper) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {

// update ICA Host to add new messages available
// enumerate all because it's easier to reason about
newIcaHostParams := icahosttypes.Params{
HostEnabled: true,
AllowMessages: []string{
sdk.MsgTypeURL(&ibctransfertypes.MsgTransfer{}), // added in v10

sdk.MsgTypeURL(&banktypes.MsgSend{}),
sdk.MsgTypeURL(&banktypes.MsgMultiSend{}), // this was missed last time
sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}),
sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}), // added in v10
sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}),
sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}),
sdk.MsgTypeURL(&stakingtypes.MsgEditValidator{}),
sdk.MsgTypeURL(&distrtypes.MsgWithdrawDelegatorReward{}),
sdk.MsgTypeURL(&distrtypes.MsgSetWithdrawAddress{}),
sdk.MsgTypeURL(&distrtypes.MsgWithdrawValidatorCommission{}),
sdk.MsgTypeURL(&distrtypes.MsgFundCommunityPool{}),
sdk.MsgTypeURL(&govtypes.MsgVote{}),
sdk.MsgTypeURL(&govtypes.MsgVoteWeighted{}), // added in v10
sdk.MsgTypeURL(&authz.MsgExec{}),
sdk.MsgTypeURL(&authz.MsgGrant{}),
sdk.MsgTypeURL(&authz.MsgRevoke{}),
// wasm msgs here
// note we only support three atm
sdk.MsgTypeURL(&wasmtypes.MsgStoreCode{}),
sdk.MsgTypeURL(&wasmtypes.MsgInstantiateContract{}),
sdk.MsgTypeURL(&wasmtypes.MsgInstantiateContract2{}), // added in wasmd 0.29.0
sdk.MsgTypeURL(&wasmtypes.MsgExecuteContract{}),
},
}
icahostkeeper.SetParams(ctx, newIcaHostParams)

return mm.RunMigrations(ctx, cfg, vm)

}
}
99 changes: 99 additions & 0 deletions cmd/junod/genica.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package main

import (
"encoding/json"
"fmt"
"github.com/spf13/cobra"

icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
)

// AddGenesisAccountCmd returns add-genesis-account cobra Command.
func AddGenesisIcaCmd(defaultNodeHome string) *cobra.Command {
cmd := &cobra.Command{
Use: "add-ica-config",
Short: "Add ICA config to genesis.json",
Long: `Add default ICA configuration to genesis.json`,
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
serverCtx := server.GetServerContextFromCmd(cmd)
config := serverCtx.Config

config.SetRoot(clientCtx.HomeDir)

genFile := config.GenesisFile()
appState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile)
if err != nil {
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
}

controllerGenesisState := icatypes.DefaultControllerGenesis()
// no params set in upgrade handler, no params set here
controllerGenesisState.Params = icacontrollertypes.Params{}

hostGenesisState := icatypes.DefaultHostGenesis()
// add the messages we want
hostGenesisState.Params = icahosttypes.Params{
HostEnabled: true,
AllowMessages: []string{
"/cosmos.bank.v1beta1.MsgSend",
// uncomment this after v11 ships
// "/cosmos.bank.v1beta1.MsgMultiSend",
"/cosmos.staking.v1beta1.MsgDelegate",
"/cosmos.staking.v1beta1.MsgUndelegate",
"/cosmos.staking.v1beta1.MsgBeginRedelegate",
"/cosmos.staking.v1beta1.MsgCreateValidator",
"/cosmos.staking.v1beta1.MsgEditValidator",
"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward",
"/cosmos.distribution.v1beta1.MsgSetWithdrawAddress",
"/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission",
"/cosmos.distribution.v1beta1.MsgFundCommunityPool",
"/cosmos.gov.v1beta1.MsgVote",
"/cosmos.gov.v1beta1.MsgVoteWeighted",
"/cosmos.authz.v1beta1.MsgExec",
"/cosmos.authz.v1beta1.MsgGrant",
"/cosmos.authz.v1beta1.MsgRevoke",
"/cosmwasm.wasm.v1.MsgStoreCode",
"/cosmwasm.wasm.v1.MsgInstantiateContract",
// uncomment this after v11 ships
// "/cosmwasm.wasm.v1.InstantiateContract2",
"/cosmwasm.wasm.v1.MsgExecuteContract",
"/ibc.applications.transfer.v1.MsgTransfer",
},
}

newIcaGenState := icatypes.NewGenesisState(controllerGenesisState, hostGenesisState)

icaGenStateBz, err := clientCtx.Codec.MarshalJSON(newIcaGenState)
if err != nil {
return fmt.Errorf("failed to marshal auth genesis state: %w", err)
}

appState[icatypes.ModuleName] = icaGenStateBz

appStateJSON, err := json.Marshal(appState)
if err != nil {
return fmt.Errorf("failed to marshal application genesis state: %w", err)
}

genDoc.AppState = appStateJSON
return genutil.ExportGenesisFile(genDoc, genFile)
},
}

cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")
cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test)")

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
1 change: 1 addition & 0 deletions cmd/junod/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
genutilcli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome),
genutilcli.ValidateGenesisCmd(app.ModuleBasics),
AddGenesisAccountCmd(app.DefaultNodeHome),
AddGenesisIcaCmd(app.DefaultNodeHome),
AddGenesisWasmMsgCmd(app.DefaultNodeHome),
tmcli.NewCompletionCmd(rootCmd, true),
// testnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}),
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
version: "3"
services:
node:
Expand All @@ -11,5 +12,5 @@ services:
- 26656:26656 # p2p
- 26657:26657 # rpc
environment:
- GAS_LIMIT=${GAS_LIMIT:-100000000}
- GAS_LIMIT=${GAS_LIMIT:-10000000}
- STAKE_TOKEN=${STAKE_TOKEN:-ujunox}
1 change: 1 addition & 0 deletions docker/setup_junod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ else
echo "$GENESIS_FILE does not exist. Generating..."

junod init --chain-id "$CHAIN_ID" "$MONIKER"
junod add-ica-config
# staking/governance token is hardcoded in config, change this
sed -i "s/\"stake\"/\"$STAKE\"/" "$GENESIS_FILE"
# this is essential for sub-1s block times (or header times go crazy)
Expand Down
Loading

0 comments on commit 1e03aae

Please sign in to comment.