diff --git a/app/app.go b/app/app.go index d52444c386..9ea3964647 100644 --- a/app/app.go +++ b/app/app.go @@ -262,10 +262,8 @@ func NewWasmApp( ) // Create IBC Keeper - // TODO: remove amino codec dependency once Tendermint version is upgraded with - // protobuf changes app.ibcKeeper = ibckeeper.NewKeeper( - app.cdc, appCodec, keys[ibchost.StoreKey], app.stakingKeeper, scopedIBCKeeper, + appCodec, keys[ibchost.StoreKey], app.stakingKeeper, scopedIBCKeeper, ) // Create Transfer Keepers diff --git a/app/encoding.go b/app/encoding.go index fe229330d7..7dc454fa77 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -1,14 +1,36 @@ package app import ( - "github.com/CosmWasm/wasmd/x/wasm" - "github.com/cosmos/cosmos-sdk/simapp" - simparams "github.com/cosmos/cosmos-sdk/simapp/params" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/std" + "github.com/cosmos/cosmos-sdk/x/auth/tx" ) -func MakeEncodingConfig() simparams.EncodingConfig { - encodingConfig := simapp.MakeEncodingConfig() // todo: this is the simapp !!! - wasm.RegisterCodec(encodingConfig.Amino) - wasm.RegisterInterfaces(encodingConfig.InterfaceRegistry) - return encodingConfig +// EncodingConfig specifies the concrete encoding types to use for a given app. +// This is provided for compatibility between protobuf and amino implementations. +type EncodingConfig struct { + InterfaceRegistry types.InterfaceRegistry + Marshaler codec.Marshaler + TxConfig client.TxConfig + Amino *codec.Codec +} + +func MakeEncodingConfig() EncodingConfig { + amino := codec.New() + interfaceRegistry := types.NewInterfaceRegistry() + marshaler := codec.NewHybridCodec(amino, interfaceRegistry) + txGen := tx.NewTxConfig(codec.NewProtoCodec(interfaceRegistry), std.DefaultPublicKeyCodec{}, tx.DefaultSignModes) + + std.RegisterCodec(amino) + std.RegisterInterfaces(interfaceRegistry) + ModuleBasics.RegisterCodec(amino) + ModuleBasics.RegisterInterfaces(interfaceRegistry) + return EncodingConfig{ + InterfaceRegistry: interfaceRegistry, + Marshaler: marshaler, + TxConfig: txGen, + Amino: amino, + } } diff --git a/cmd/wasmcli/main.go b/cmd/wasmcli/main.go index 9067ed5b59..2738e3f18c 100644 --- a/cmd/wasmcli/main.go +++ b/cmd/wasmcli/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "fmt" "os" @@ -43,7 +44,7 @@ func main() { WithInput(os.Stdin). WithAccountRetriever(authtypes.NewAccountRetriever(encodingConfig.Marshaler)). WithBroadcastMode(flags.BroadcastBlock). - WithHomeDir(app.DefaultNodeHome) + WithHomeDir(app.DefaultCLIHome) rootCmd := &cobra.Command{ Use: "wasmcli", @@ -70,10 +71,19 @@ func main() { cli.NewCompletionCmd(rootCmd, true), ) - // Add flags and prefix all env exposed with WM - executor := cli.PrepareMainCmd(rootCmd, "WM", app.DefaultCLIHome) + // Create and set a client.Context on the command's Context. During the pre-run + // of the root command, a default initialized client.Context is provided to + // seed child command execution with values such as AccountRetriver, Keyring, + // and a Tendermint RPC. This requires the use of a pointer reference when + // getting and setting the client.Context. Ideally, we utilize + // https://github.com/spf13/cobra/pull/1118. + ctx := context.Background() + ctx = context.WithValue(ctx, client.ClientContextKey, &client.Context{}) + ctx = context.WithValue(ctx, server.ServerContextKey, server.NewDefaultContext()) + + executor := cli.PrepareBaseCmd(rootCmd, "WM", app.DefaultCLIHome) + err := executor.ExecuteContext(ctx) - err := executor.Execute() if err != nil { fmt.Printf("Failed executing CLI command: %s, exiting...\n", err) os.Exit(1) diff --git a/cmd/wasmd/main.go b/cmd/wasmd/main.go index 0f4f4077b6..b92903384a 100644 --- a/cmd/wasmd/main.go +++ b/cmd/wasmd/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "encoding/json" "io" "os" @@ -74,13 +75,23 @@ func main() { debug.Cmd(), ) - server.AddCommands(rootCmd, newApp, exportAppStateAndTMValidators) + server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, exportAppStateAndTMValidators) + + // Create and set a client.Context on the command's Context. During the pre-run + // of the root command, a default initialized client.Context is provided to + // seed child command execution with values such as AccountRetriver, Keyring, + // and a Tendermint RPC. This requires the use of a pointer reference when + // getting and setting the client.Context. Ideally, we utilize + // https://github.com/spf13/cobra/pull/1118. + ctx := context.Background() + ctx = context.WithValue(ctx, client.ClientContextKey, &client.Context{}) + ctx = context.WithValue(ctx, server.ServerContextKey, server.NewDefaultContext()) // prepare and add flags executor := cli.PrepareBaseCmd(rootCmd, "WM", app.DefaultNodeHome) rootCmd.PersistentFlags().UintVar(&invCheckPeriod, flagInvCheckPeriod, 0, "Assert registered invariants every N blocks") - err := executor.Execute() + err := executor.ExecuteContext(ctx) if err != nil { panic(err) } diff --git a/docker/run_all.sh b/docker/run_all.sh deleted file mode 100755 index f183d532e2..0000000000 --- a/docker/run_all.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -#set -euo pipefail - -mkdir -p /root/log -touch /root/log/wasmd.log -./run_wasmd.sh $1 >> /root/log/wasmd.log & - -sleep 4 -echo Starting Rest Server... - -./run_rest_server.sh diff --git a/docker/run_rest_server.sh b/docker/run_rest_server.sh deleted file mode 100755 index 368a90d341..0000000000 --- a/docker/run_rest_server.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -#set -euo pipefail - -wasmcli rest-server --laddr tcp://0.0.0.0:1317 --trust-node --cors diff --git a/docker/setup.sh b/docker/setup.sh index d6829a1f6a..f5a67b1d1a 100755 --- a/docker/setup.sh +++ b/docker/setup.sh @@ -19,5 +19,5 @@ for addr in "$@"; do wasmd add-genesis-account "$addr" "1000000000$STAKE,1000000000$FEE" done # submit a genesis validator tx -(echo "$PASSWORD"; echo "$PASSWORD"; echo "$PASSWORD") | wasmd gentx --name validator --amount "250000000$STAKE" +(echo "$PASSWORD"; echo "$PASSWORD"; echo "$PASSWORD") | wasmd gentx validator --chain-id=testing --amount "250000000$STAKE" wasmd collect-gentxs diff --git a/go.mod b/go.mod index 0f74d63ae4..089a08c82c 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.14 require ( // Note: update ENV GO_COSMWASM in Dockerfile when updating this github.com/CosmWasm/go-cosmwasm v0.9.1 - github.com/cosmos/cosmos-sdk v0.34.4-0.20200806092156-3076a8b12ec3 + github.com/cosmos/cosmos-sdk v0.34.4-0.20200807102022-3322e269a184 github.com/dvsekhvalnov/jose2go v0.0.0-20180829124132-7f401d37b68a github.com/gogo/protobuf v1.3.1 github.com/google/gofuzz v1.0.0 diff --git a/go.sum b/go.sum index a66e0b1a7f..3798fdcfc1 100644 --- a/go.sum +++ b/go.sum @@ -100,8 +100,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200806092156-3076a8b12ec3 h1:22rm9uHzeJtlGjVMRIqTUkRFapFU3nwN9xy8KLvLStg= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200806092156-3076a8b12ec3/go.mod h1:7fv4+b5E8Iq9m0MKzR/v/QOLDKcpp+rBZW2JiNRtqMY= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200807102022-3322e269a184 h1:Ogtqklf+8k2mdVl5JVwPVaBIk1Io9KyKdMzoxhq1cw8= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200807102022-3322e269a184/go.mod h1:7fv4+b5E8Iq9m0MKzR/v/QOLDKcpp+rBZW2JiNRtqMY= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=