Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-cosmos into feat/sdk50

# Conflicts:
#	app/app.go
#	app/upgrades/v6_5_5/constants.go
#	app/upgrades/v6_6_4/upgrade.go
#	app/upgrades/v6_6_4/upgrades_test.go
#	bech32-migration/gov/gov.go
#	bech32-migration/ica/ica.go
#	custom/ibc-transfer/keeper/keeper.go
#	go.mod
#	go.sum
#	scripts/test-upgrade.sh
#	scripts/upgrade/init-deps.sh
#	scripts/upgrade/upgrade.sh
#	x/transfermiddleware/ibc_middleware.go
  • Loading branch information
hoank101 committed May 16, 2024
2 parents 6060659 + 84b6893 commit beb1b64
Show file tree
Hide file tree
Showing 28 changed files with 944 additions and 152 deletions.
7 changes: 3 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package app

import (
"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"
"fmt"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
"io"
"os"
"path/filepath"
"github.com/notional-labs/composable/v6/app/upgrades/v6_6_4"

"cosmossdk.io/x/circuit"
circuittypes "cosmossdk.io/x/circuit/types"
Expand Down Expand Up @@ -133,7 +132,7 @@ import (
)

const (
Name = "picasso"
Name = "pica"
dirName = "banksy"
ForkHeight = 244008
)
Expand All @@ -147,7 +146,7 @@ var (
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
EnableSpecificProposals = ""

Upgrades = []upgrades.Upgrade{v7_0_1.Upgrade}
Upgrades = []upgrades.Upgrade{v7_0_1.Upgrade, v6_6_4.Upgrade}
Forks = []upgrades.Fork{}
)

Expand Down
Empty file.
24 changes: 24 additions & 0 deletions app/upgrades/v6_5_5/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package v6_5_5

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/notional-labs/composable/v6/app/keepers"

"github.com/notional-labs/composable/v6/app/upgrades"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
_ upgrades.BaseAppParamManager,
_ codec.Codec,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, configurator, vm)
}
}
20 changes: 20 additions & 0 deletions app/upgrades/v6_6_1/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package v6_6_1

import (
store "github.com/cosmos/cosmos-sdk/store/types"
"github.com/notional-labs/composable/v6/app/upgrades"
)

const (
// UpgradeName defines the on-chain upgrade name for the composable upgrade.
UpgradeName = "v6_6_1"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{},
Deleted: []string{},
},
}
60 changes: 60 additions & 0 deletions app/upgrades/v6_6_1/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package v6_6_1

import (
"github.com/CosmWasm/wasmd/x/wasm"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
ibchookstypes "github.com/notional-labs/composable/v6/x/ibc-hooks/types"
ibctransfermiddlewaretypes "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"

"github.com/notional-labs/composable/v6/app/keepers"
"github.com/notional-labs/composable/v6/app/upgrades"
bech32authmigration "github.com/notional-labs/composable/v6/bech32-migration/auth"
bech32govmigration "github.com/notional-labs/composable/v6/bech32-migration/gov"
bech32IbcHooksMigration "github.com/notional-labs/composable/v6/bech32-migration/ibchooks"
bench32ibctransfermiddleware "github.com/notional-labs/composable/v6/bech32-migration/ibctransfermiddleware"
bech32icamigration "github.com/notional-labs/composable/v6/bech32-migration/ica"
bech32mintmigration "github.com/notional-labs/composable/v6/bech32-migration/mint"
bech32PfmMigration "github.com/notional-labs/composable/v6/bech32-migration/pfmmiddleware"
bech32slashingmigration "github.com/notional-labs/composable/v6/bech32-migration/slashing"
bech32stakingmigration "github.com/notional-labs/composable/v6/bech32-migration/staking"
bech32transfermiddlewaremigration "github.com/notional-labs/composable/v6/bech32-migration/transfermiddleware"
bech32WasmMigration "github.com/notional-labs/composable/v6/bech32-migration/wasm"
transfermiddlewaretypes "github.com/notional-labs/composable/v6/x/transfermiddleware/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
_ upgrades.BaseAppParamManager,
codec codec.Codec,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
keys := keepers.GetKVStoreKey()
// Migration prefix
ctx.Logger().Info("First step: Migrate addresses stored in bech32 form to use new prefix")
bech32stakingmigration.MigrateAddressBech32(ctx, keys[stakingtypes.StoreKey], codec)
bech32stakingmigration.MigrateUnbonding(ctx, keys[stakingtypes.StoreKey], codec)
bech32slashingmigration.MigrateAddressBech32(ctx, keys[slashingtypes.StoreKey], codec)
bech32govmigration.MigrateAddressBech32(ctx, keys[govtypes.StoreKey], codec)
bech32authmigration.MigrateAddressBech32(ctx, keys[authtypes.StoreKey], codec)
bech32icamigration.MigrateAddressBech32(ctx, keys[icahosttypes.StoreKey], codec)
bech32mintmigration.MigrateAddressBech32(ctx, keys[minttypes.StoreKey], codec)
bech32transfermiddlewaremigration.MigrateAddressBech32(ctx, keys[transfermiddlewaretypes.StoreKey], codec)
bech32WasmMigration.MigrateAddressBech32(ctx, keys[wasm.StoreKey], codec)
bech32PfmMigration.MigrateAddressBech32(ctx, keys[routertypes.StoreKey], codec, keepers)
bench32ibctransfermiddleware.MigrateAddressBech32(ctx, keys[ibctransfermiddlewaretypes.StoreKey], codec)
bech32IbcHooksMigration.MigrateAddressBech32(ctx, keys[ibchookstypes.StoreKey], codec)
return mm.RunMigrations(ctx, configurator, vm)
}
}
20 changes: 20 additions & 0 deletions app/upgrades/v6_6_2/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package v6_6_2

import (
store "github.com/cosmos/cosmos-sdk/store/types"
"github.com/notional-labs/composable/v6/app/upgrades"
)

const (
// UpgradeName defines the on-chain upgrade name for the composable upgrade.
UpgradeName = "v6_6_2"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{},
Deleted: []string{},
},
}
32 changes: 32 additions & 0 deletions app/upgrades/v6_6_2/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package v6_6_2

import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ibchookstypes "github.com/notional-labs/composable/v6/x/ibc-hooks/types"
ibctransfermiddlewaretypes "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"

"github.com/notional-labs/composable/v6/app/keepers"
"github.com/notional-labs/composable/v6/app/upgrades"
bech32IbcHooksMigration "github.com/notional-labs/composable/v6/bech32-migration/ibchooks"
bench32ibctransfermiddleware "github.com/notional-labs/composable/v6/bech32-migration/ibctransfermiddleware"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
_ upgrades.BaseAppParamManager,
codec codec.Codec,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
keys := keepers.GetKVStoreKey()
// Migration prefix
ctx.Logger().Info("First step: Migrate addresses stored in bech32 form to use new prefix")
bench32ibctransfermiddleware.MigrateAddressBech32(ctx, keys[ibctransfermiddlewaretypes.StoreKey], codec)
bech32IbcHooksMigration.MigrateAddressBech32(ctx, keys[ibchookstypes.StoreKey], codec)
return mm.RunMigrations(ctx, configurator, vm)
}
}
20 changes: 20 additions & 0 deletions app/upgrades/v6_6_4/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package v6_6_4

import (
store "github.com/cosmos/cosmos-sdk/store/types"
"github.com/notional-labs/composable/v6/app/upgrades"
)

const (
// UpgradeName defines the on-chain upgrade name for the composable upgrade.
UpgradeName = "v6_6_4"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{},
Deleted: []string{},
},
}
29 changes: 29 additions & 0 deletions bech32-migration/ibchooks/ibchooks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ibchooks

import (
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/notional-labs/composable/v6/bech32-migration/utils"
)

func MigrateAddressBech32(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) {
ctx.Logger().Info("Migration of address bech32 for ibchooks module begin")
totalAddr := uint64(0)
store := ctx.KVStore(storeKey)
channelKey := []byte("channel")
iterator := sdk.KVStorePrefixIterator(store, channelKey)
for ; iterator.Valid(); iterator.Next() {
totalAddr++
fullKey := iterator.Key()
contract := string(store.Get(fullKey))
contract = utils.SafeConvertAddress(contract)
totalAddr++
store.Set(fullKey, []byte(contract))
}

ctx.Logger().Info(
"Migration of address bech32 for ibchooks module done",
"totalAddr", totalAddr,
)
}
32 changes: 32 additions & 0 deletions bech32-migration/ibctransfermiddleware/ibctransfermiddleware.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ibctransfermiddleware

import (
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/notional-labs/composable/v6/bech32-migration/utils"
"github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
)

func MigrateAddressBech32(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) {
ctx.Logger().Info("Migration of address bech32 for ibctransfermiddleware module begin")
totalAddr := uint64(0)
store := ctx.KVStore(storeKey)
bz := store.Get(types.ParamsKey)
if bz == nil {
return
}
var params types.Params
cdc.MustUnmarshal(bz, &params)
for i := range params.ChannelFees {
totalAddr++
params.ChannelFees[i].FeeAddress = utils.SafeConvertAddress(params.ChannelFees[i].FeeAddress)
}
bz = cdc.MustMarshal(&params)
store.Set(types.ParamsKey, bz)

ctx.Logger().Info(
"Migration of address bech32 for ibctransfermiddleware module done",
"totalAddr", totalAddr,
)
}
4 changes: 2 additions & 2 deletions cmd/picad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) {
WithViper("ICA")

rootCmd := &cobra.Command{
Use: app.Name + "d",
Short: "Composable App",
Use: "picad",
Short: "Picasso",
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
// set the default command outputs
cmd.SetOut(cmd.OutOrStdout())
Expand Down
8 changes: 4 additions & 4 deletions contrib/docker/goreleaser.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ COPY ./dist/ /root/

ARG TARGETARCH
RUN if [ "${TARGETARCH}" = "arm64" ]; then \
cp linux_linux_arm64/centaurid /root/centaurid; \
cp linux_linux_arm64/picad /root/picad; \
else \
cp linux_linux_amd64_v1/centaurid /root/centaurid; \
cp linux_linux_amd64_v1/picad /root/picad; \
fi

FROM alpine:latest

RUN apk --no-cache add ca-certificates jq
COPY --from=builder /root/centaurid /usr/local/bin/centaurid
COPY --from=builder /root/picad /usr/local/bin/picad

RUN addgroup --gid 1025 -S composable && adduser --uid 1025 -S composable -G composable

Expand All @@ -29,5 +29,5 @@ EXPOSE 26657
# grpc
EXPOSE 9090

ENTRYPOINT ["centaurid"]
ENTRYPOINT ["picad"]
CMD [ "start" ]
Loading

0 comments on commit beb1b64

Please sign in to comment.