Skip to content

Commit

Permalink
Merge pull request #83 from KiFoundation/dev/v5-t12
Browse files Browse the repository at this point in the history
Dev/v5 t12
  • Loading branch information
TarekAwwad committed Mar 14, 2023
2 parents d362ebd + 1d7ed76 commit 7d1b489
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 246 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.45
version: v1.51.2
args: --timeout 10m
github-token: ${{ secrets.github_token }}
if: "env.GIT_DIFF != ''"
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG IMG_TAG=latest
ARG PLATFORM="linux/amd64"

# Compile the kid binary
FROM --platform=${PLATFORM} golang:1.18.0-alpine3.15 AS kid-builder
FROM --platform=${PLATFORM} golang:1.19-alpine3.16 AS kid-builder
WORKDIR /src/app/
COPY go.mod go.sum* ./
RUN go mod download
Expand All @@ -11,10 +11,10 @@ COPY . .
# From https://github.com/CosmWasm/wasmd/blob/master/Dockerfile
# For more details see https://github.com/CosmWasm/wasmvm#builds-of-libwasmvm
ARG ARCH=x86_64
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
RUN cp /lib/libwasmvm_muslc.${ARCH}.a /lib/libwasmvm_muslc.a

ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::
DOCKER := $(shell which docker)
BUILDDIR ?= $(CURDIR)/build

GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)

export GO111MODULE = on

# process build tags
Expand Down Expand Up @@ -96,14 +98,19 @@ endif
###############################################################################
### Documentation ###
###############################################################################
check_version:
ifneq ($(GO_MINOR_VERSION),19)
@echo "ERROR: Go version 1.19 is required for this version of Ki-tools."
exit 1
endif

all: install lint test

BUILD_TARGETS := build install

build: BUILD_ARGS=-o $(BUILDDIR)/

$(BUILD_TARGETS): go.sum $(BUILDDIR)/
$(BUILD_TARGETS): check_version go.sum $(BUILDDIR)/
go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./...

$(BUILDDIR)/:
Expand Down
57 changes: 15 additions & 42 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ import (

"github.com/CosmWasm/wasmd/x/wasm"
wasmclient "github.com/CosmWasm/wasmd/x/wasm/client"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts"
icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"
Expand Down Expand Up @@ -207,7 +207,7 @@ var (
// KitoolsApp extends an ABCI application, but with most of its parameters exported.
// They are exported for convenience in creating helper functions, as object
// capabilities aren't needed for testing.
type KitoolsApp struct { // nolint: golint
type KitoolsApp struct { //nolint: golint
*baseapp.BaseApp
legacyAmino *codec.LegacyAmino
appCodec codec.Codec
Expand Down Expand Up @@ -697,47 +697,22 @@ func NewKitoolsApp(
app.UpgradeKeeper.SetUpgradeHandler(
upgradeName,
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("start to run module migrations...")

params := app.WasmKeeper.GetParams(ctx)

uploadAddresses := []string{"ki12u4jtcczpg2m3nt50muh3srte7zed77qsfyng4", "ki12qmzh8ewtp90qxtsrvrgl52qydauerhkl8f6u2"}

ctx.Logger().Info("Initialize ICA")
fromVM[icatypes.ModuleName] = icaModule.ConsensusVersion()

// create ICS27 Controller submodule params
controllerParams := icacontrollertypes.Params{}

// create ICS27 Host submodule params
hostParams := icahosttypes.Params{
HostEnabled: true,
AllowMessages: []string{
authzMsgExec,
authzMsgGrant,
authzMsgRevoke,
bankMsgSend,
bankMsgMultiSend,
distrMsgSetWithdrawAddr,
distrMsgWithdrawValidatorCommission,
distrMsgFundCommunityPool,
distrMsgWithdrawDelegatorReward,
feegrantMsgGrantAllowance,
feegrantMsgRevokeAllowance,
govMsgVoteWeighted,
govMsgSubmitProposal,
govMsgDeposit,
govMsgVote,
stakingMsgEditValidator,
stakingMsgDelegate,
stakingMsgUndelegate,
stakingMsgBeginRedelegate,
stakingMsgCreateValidator,
vestingMsgCreateVestingAccount,
transferMsgTransfer,
wasmMsgExecuteContract,
},
if address.Bech32MainPrefix == "tki" {
uploadAddresses = []string{"tki1vexd57shjr2rax74ym5g8nqwq7ve04n5gz0kaj", "tki1mxag493xqx5rwqug950n0uer3kayjnw3ctxpxu"}
}

// initialize ICS27 module
icaModule.InitModule(ctx, controllerParams, hostParams)
params.CodeUploadAccess = wasmtypes.AccessConfig{
Permission: wasmtypes.AccessTypeAnyOfAddresses,
Addresses: uploadAddresses,
}

ctx.Logger().Info("start to run module migrations...")
app.WasmKeeper.SetParams(ctx, params)

return app.mm.RunMigrations(ctx, app.configurator, fromVM)
},
Expand All @@ -749,9 +724,7 @@ func NewKitoolsApp(
}

if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := store.StoreUpgrades{
Added: []string{icahosttypes.StoreKey},
}
storeUpgrades := store.StoreUpgrades{}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
Expand Down
26 changes: 1 addition & 25 deletions app/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,5 @@ package kitools
/* #nosec */
const (
appName = "KitoolsApp"
upgradeName = "v4"

authzMsgExec = "/cosmos.authz.v1beta1.MsgExec"
authzMsgGrant = "/cosmos.authz.v1beta1.MsgGrant"
authzMsgRevoke = "/cosmos.authz.v1beta1.MsgRevoke"
bankMsgSend = "/cosmos.bank.v1beta1.MsgSend"
bankMsgMultiSend = "/cosmos.bank.v1beta1.MsgMultiSend"
distrMsgSetWithdrawAddr = "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress"
distrMsgWithdrawValidatorCommission = "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission"
distrMsgFundCommunityPool = "/cosmos.distribution.v1beta1.MsgFundCommunityPool"
distrMsgWithdrawDelegatorReward = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward"
feegrantMsgGrantAllowance = "/cosmos.feegrant.v1beta1.MsgGrantAllowance"
feegrantMsgRevokeAllowance = "/cosmos.feegrant.v1beta1.MsgRevokeAllowance"
govMsgVoteWeighted = "/cosmos.gov.v1beta1.MsgVoteWeighted"
govMsgSubmitProposal = "/cosmos.gov.v1beta1.MsgSubmitProposal"
govMsgDeposit = "/cosmos.gov.v1beta1.MsgDeposit"
govMsgVote = "/cosmos.gov.v1beta1.MsgVote"
stakingMsgEditValidator = "/cosmos.staking.v1beta1.MsgEditValidator"
stakingMsgDelegate = "/cosmos.staking.v1beta1.MsgDelegate"
stakingMsgUndelegate = "/cosmos.staking.v1beta1.MsgUndelegate"
stakingMsgBeginRedelegate = "/cosmos.staking.v1beta1.MsgBeginRedelegate"
stakingMsgCreateValidator = "/cosmos.staking.v1beta1.MsgCreateValidator"
vestingMsgCreateVestingAccount = "/cosmos.vesting.v1beta1.MsgCreateVestingAccount"
transferMsgTransfer = "/ibc.applications.transfer.v1.MsgTransfer"
wasmMsgExecuteContract = "/cosmwasm.wasm.v1.MsgExecuteContract"
upgradeName = "v5"
)
3 changes: 2 additions & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func (app *KitoolsApp) ExportAppStateAndValidators(

// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
// in favour of export at a block height
//
// in favour of export at a block height
func (app *KitoolsApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
applyAllowedAddrs := false

Expand Down
4 changes: 2 additions & 2 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func interBlockCacheOpt() func(*baseapp.BaseApp) {
return baseapp.SetInterBlockCache(store.NewCommitKVStoreCacheManager())
}

//// TODO: Make another test for the fuzzer itself, which just has noOp txs
//// and doesn't depend on the application.
// // TODO: Make another test for the fuzzer itself, which just has noOp txs
// // and doesn't depend on the application.
func TestAppStateDeterminism(t *testing.T) {
if !simapp.FlagEnabledValue {
t.Skip("skipping application simulation")
Expand Down
2 changes: 2 additions & 0 deletions cmd/kid/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ func (ac appCreator) newApp(
baseapp.SetSnapshotStore(snapshotStore),
baseapp.SetSnapshotInterval(cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval))),
baseapp.SetSnapshotKeepRecent(cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent))),
baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))),
baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(server.FlagDisableIAVLFastNode))),
)
}

Expand Down
Loading

0 comments on commit 7d1b489

Please sign in to comment.