Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
feat: upgrade sdk to v0.44.0 (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgooz authored Sep 17, 2021
1 parent a4d5c00 commit 10cc3b2
Show file tree
Hide file tree
Showing 5 changed files with 489 additions and 55 deletions.
2 changes: 1 addition & 1 deletion cosmoscmd/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// This is provided for compatibility between protobuf and amino implementations.
type EncodingConfig struct {
InterfaceRegistry types.InterfaceRegistry
Marshaler codec.Marshaler
Marshaler codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
}
Expand Down
4 changes: 2 additions & 2 deletions cosmoscmd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
depCdc := clientCtx.JSONMarshaler
cdc := depCdc.(codec.Marshaler)
depCdc := clientCtx.JSONCodec
cdc := depCdc.(codec.Codec)

serverCtx := server.GetServerContextFromCmd(cmd)
config := serverCtx.Config
Expand Down
80 changes: 67 additions & 13 deletions cosmoscmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ import (
"os"
"path/filepath"

"github.com/spf13/cast"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

tmcli "github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
Expand All @@ -22,18 +14,24 @@ import (
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/server"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/snapshots"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
"github.com/cosmos/cosmos-sdk/x/auth/types"
vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
"github.com/spf13/cast"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
tmcli "github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
)

type (
Expand Down Expand Up @@ -125,7 +123,7 @@ func NewRootCmd(

encodingConfig := MakeEncodingConfig(moduleBasics)
initClientCtx := client.Context{}.
WithJSONMarshaler(encodingConfig.Marshaler).
WithCodec(encodingConfig.Marshaler).
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
WithTxConfig(encodingConfig.TxConfig).
WithLegacyAmino(encodingConfig.Amino).
Expand All @@ -150,7 +148,9 @@ func NewRootCmd(
return err
}

return server.InterceptConfigsPreRunHandler(cmd)
customAppTemplate, customAppConfig := initAppConfig()

return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig)
},
}

Expand Down Expand Up @@ -178,8 +178,6 @@ func initRootCmd(
buildApp AppBuilder,
options rootOptions,
) {
authclient.Codec = encodingConfig.Marshaler

rootCmd.AddCommand(
genutilcli.InitCmd(moduleBasics, defaultNodeHome),
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, defaultNodeHome),
Expand Down Expand Up @@ -400,3 +398,59 @@ func (a appCreator) appExport(

return exportableApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs)
}

// initAppConfig helps to override default appConfig template and configs.
// return "", nil if no custom configuration is required for the application.
func initAppConfig() (string, interface{}) {
// The following code snippet is just for reference.

// WASMConfig defines configuration for the wasm module.
type WASMConfig struct {
// This is the maximum sdk gas (wasm and storage) that we allow for any x/wasm "smart" queries
QueryGasLimit uint64 `mapstructure:"query_gas_limit"`

// Address defines the gRPC-web server to listen on
LruSize uint64 `mapstructure:"lru_size"`
}

type CustomAppConfig struct {
serverconfig.Config

WASM WASMConfig `mapstructure:"wasm"`
}

// Optionally allow the chain developer to overwrite the SDK's default
// server config.
srvCfg := serverconfig.DefaultConfig()
// The SDK's default minimum gas price is set to "" (empty value) inside
// app.toml. If left empty by validators, the node will halt on startup.
// However, the chain developer can set a default app.toml value for their
// validators here.
//
// In summary:
// - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their
// own app.toml config,
// - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their
// own app.toml to override, or use this default value.
//
// In simapp, we set the min gas prices to 0.
srvCfg.MinGasPrices = "0stake"

customAppConfig := CustomAppConfig{
Config: *srvCfg,
WASM: WASMConfig{
LruSize: 1,
QueryGasLimit: 300000,
},
}

customAppTemplate := serverconfig.DefaultConfigTemplate + `
[wasm]
# This is the maximum sdk gas (wasm and storage) that we allow for any x/wasm "smart" queries
query_gas_limit = 300000
# This is the number of wasm vm instances we keep cached in memory for speed-up
# Warning: this is currently unstable and may lead to crashes, best to keep for 0 unless testing locally
lru_size = 0`

return customAppTemplate, customAppConfig
}
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ module github.com/tendermint/spm
go 1.16

require (
github.com/cosmos/cosmos-sdk v0.42.6
github.com/cosmos/cosmos-sdk v0.44.0
github.com/google/gofuzz v1.2.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/spf13/cast v1.3.1
github.com/spf13/cobra v1.1.3
github.com/spf13/pflag v1.0.5
github.com/tendermint/tendermint v0.34.11
github.com/stretchr/testify v1.7.0
github.com/tendermint/tendermint v0.34.12
github.com/tendermint/tm-db v0.6.4
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11 // indirect
golang.org/x/text v0.3.4 // indirect
)

replace google.golang.org/grpc => google.golang.org/grpc v1.33.2

replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
replace (
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
Loading

0 comments on commit 10cc3b2

Please sign in to comment.