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

Commit 10cc3b2

Browse files
authored
feat: upgrade sdk to v0.44.0 (#13)
1 parent a4d5c00 commit 10cc3b2

File tree

5 files changed

+489
-55
lines changed

5 files changed

+489
-55
lines changed

cosmoscmd/encoding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
// This is provided for compatibility between protobuf and amino implementations.
1414
type EncodingConfig struct {
1515
InterfaceRegistry types.InterfaceRegistry
16-
Marshaler codec.Marshaler
16+
Marshaler codec.Codec
1717
TxConfig client.TxConfig
1818
Amino *codec.LegacyAmino
1919
}

cosmoscmd/genaccounts.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
4040
Args: cobra.ExactArgs(2),
4141
RunE: func(cmd *cobra.Command, args []string) error {
4242
clientCtx := client.GetClientContextFromCmd(cmd)
43-
depCdc := clientCtx.JSONMarshaler
44-
cdc := depCdc.(codec.Marshaler)
43+
depCdc := clientCtx.JSONCodec
44+
cdc := depCdc.(codec.Codec)
4545

4646
serverCtx := server.GetServerContextFromCmd(cmd)
4747
config := serverCtx.Config

cosmoscmd/root.go

Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ import (
66
"os"
77
"path/filepath"
88

9-
"github.com/spf13/cast"
10-
"github.com/spf13/cobra"
11-
"github.com/spf13/pflag"
12-
13-
tmcli "github.com/tendermint/tendermint/libs/cli"
14-
"github.com/tendermint/tendermint/libs/log"
15-
dbm "github.com/tendermint/tm-db"
16-
179
"github.com/cosmos/cosmos-sdk/baseapp"
1810
"github.com/cosmos/cosmos-sdk/client"
1911
"github.com/cosmos/cosmos-sdk/client/config"
@@ -22,18 +14,24 @@ import (
2214
"github.com/cosmos/cosmos-sdk/client/keys"
2315
"github.com/cosmos/cosmos-sdk/client/rpc"
2416
"github.com/cosmos/cosmos-sdk/server"
17+
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
2518
servertypes "github.com/cosmos/cosmos-sdk/server/types"
2619
"github.com/cosmos/cosmos-sdk/snapshots"
2720
"github.com/cosmos/cosmos-sdk/store"
2821
sdk "github.com/cosmos/cosmos-sdk/types"
2922
"github.com/cosmos/cosmos-sdk/types/module"
30-
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
3123
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
3224
"github.com/cosmos/cosmos-sdk/x/auth/types"
3325
vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli"
3426
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
3527
"github.com/cosmos/cosmos-sdk/x/crisis"
3628
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
29+
"github.com/spf13/cast"
30+
"github.com/spf13/cobra"
31+
"github.com/spf13/pflag"
32+
tmcli "github.com/tendermint/tendermint/libs/cli"
33+
"github.com/tendermint/tendermint/libs/log"
34+
dbm "github.com/tendermint/tm-db"
3735
)
3836

3937
type (
@@ -125,7 +123,7 @@ func NewRootCmd(
125123

126124
encodingConfig := MakeEncodingConfig(moduleBasics)
127125
initClientCtx := client.Context{}.
128-
WithJSONMarshaler(encodingConfig.Marshaler).
126+
WithCodec(encodingConfig.Marshaler).
129127
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
130128
WithTxConfig(encodingConfig.TxConfig).
131129
WithLegacyAmino(encodingConfig.Amino).
@@ -150,7 +148,9 @@ func NewRootCmd(
150148
return err
151149
}
152150

153-
return server.InterceptConfigsPreRunHandler(cmd)
151+
customAppTemplate, customAppConfig := initAppConfig()
152+
153+
return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig)
154154
},
155155
}
156156

@@ -178,8 +178,6 @@ func initRootCmd(
178178
buildApp AppBuilder,
179179
options rootOptions,
180180
) {
181-
authclient.Codec = encodingConfig.Marshaler
182-
183181
rootCmd.AddCommand(
184182
genutilcli.InitCmd(moduleBasics, defaultNodeHome),
185183
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, defaultNodeHome),
@@ -400,3 +398,59 @@ func (a appCreator) appExport(
400398

401399
return exportableApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs)
402400
}
401+
402+
// initAppConfig helps to override default appConfig template and configs.
403+
// return "", nil if no custom configuration is required for the application.
404+
func initAppConfig() (string, interface{}) {
405+
// The following code snippet is just for reference.
406+
407+
// WASMConfig defines configuration for the wasm module.
408+
type WASMConfig struct {
409+
// This is the maximum sdk gas (wasm and storage) that we allow for any x/wasm "smart" queries
410+
QueryGasLimit uint64 `mapstructure:"query_gas_limit"`
411+
412+
// Address defines the gRPC-web server to listen on
413+
LruSize uint64 `mapstructure:"lru_size"`
414+
}
415+
416+
type CustomAppConfig struct {
417+
serverconfig.Config
418+
419+
WASM WASMConfig `mapstructure:"wasm"`
420+
}
421+
422+
// Optionally allow the chain developer to overwrite the SDK's default
423+
// server config.
424+
srvCfg := serverconfig.DefaultConfig()
425+
// The SDK's default minimum gas price is set to "" (empty value) inside
426+
// app.toml. If left empty by validators, the node will halt on startup.
427+
// However, the chain developer can set a default app.toml value for their
428+
// validators here.
429+
//
430+
// In summary:
431+
// - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their
432+
// own app.toml config,
433+
// - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their
434+
// own app.toml to override, or use this default value.
435+
//
436+
// In simapp, we set the min gas prices to 0.
437+
srvCfg.MinGasPrices = "0stake"
438+
439+
customAppConfig := CustomAppConfig{
440+
Config: *srvCfg,
441+
WASM: WASMConfig{
442+
LruSize: 1,
443+
QueryGasLimit: 300000,
444+
},
445+
}
446+
447+
customAppTemplate := serverconfig.DefaultConfigTemplate + `
448+
[wasm]
449+
# This is the maximum sdk gas (wasm and storage) that we allow for any x/wasm "smart" queries
450+
query_gas_limit = 300000
451+
# This is the number of wasm vm instances we keep cached in memory for speed-up
452+
# Warning: this is currently unstable and may lead to crashes, best to keep for 0 unless testing locally
453+
lru_size = 0`
454+
455+
return customAppTemplate, customAppConfig
456+
}

go.mod

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ module github.com/tendermint/spm
33
go 1.16
44

55
require (
6-
github.com/cosmos/cosmos-sdk v0.42.6
6+
github.com/cosmos/cosmos-sdk v0.44.0
77
github.com/google/gofuzz v1.2.0 // indirect
88
github.com/kr/text v0.2.0 // indirect
99
github.com/spf13/cast v1.3.1
1010
github.com/spf13/cobra v1.1.3
1111
github.com/spf13/pflag v1.0.5
12-
github.com/tendermint/tendermint v0.34.11
12+
github.com/stretchr/testify v1.7.0
13+
github.com/tendermint/tendermint v0.34.12
1314
github.com/tendermint/tm-db v0.6.4
14-
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11 // indirect
15-
golang.org/x/text v0.3.4 // indirect
1615
)
1716

18-
replace google.golang.org/grpc => google.golang.org/grpc v1.33.2
19-
20-
replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
17+
replace (
18+
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
19+
google.golang.org/grpc => google.golang.org/grpc v1.33.2
20+
)

0 commit comments

Comments
 (0)