From 2d04c3c75c93dfb421ee5ad37b2aff5b93545656 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 27 Jul 2020 10:51:08 +0200 Subject: [PATCH 1/4] Add build-coral to the Makefile --- Makefile | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 49eecbedce1..b1c1b2aca95 100644 --- a/Makefile +++ b/Makefile @@ -60,14 +60,24 @@ endif ldflags += $(LDFLAGS) ldflags := $(strip $(ldflags)) +coral_ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=coral \ + -X github.com/cosmos/cosmos-sdk/version.ServerName=corald \ + -X github.com/cosmos/cosmos-sdk/version.ClientName=coral \ + -X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \ + -X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \ + -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" + +coral_ldflags += $(LDFLAGS) +coral_ldflags := $(strip $(coral_ldflags)) + BUILD_FLAGS := -tags $(build_tags_comma_sep) -ldflags '$(ldflags)' -trimpath +CORAL_BUILD_FLAGS := -tags $(build_tags_comma_sep) -ldflags '$(coral_ldflags)' -trimpath all: install lint test build: go.sum ifeq ($(OS),Windows_NT) - go build -mod=readonly $(BUILD_FLAGS) -o build/wasmd.exe ./cmd/wasmd - go build -mod=readonly $(BUILD_FLAGS) -o build/wasmgovd.exe ./cmd/wasmgovd + # wasmd nodes not supported on windows, maybe the cli? go build -mod=readonly $(BUILD_FLAGS) -o build/wasmcli.exe ./cmd/wasmcli else go build -mod=readonly $(BUILD_FLAGS) -o build/wasmd ./cmd/wasmd @@ -75,6 +85,15 @@ else go build -mod=readonly $(BUILD_FLAGS) -o build/wasmcli ./cmd/wasmcli endif +build-coral: go.sum +ifeq ($(OS),Windows_NT) + # wasmd nodes not supported on windows, maybe the cli? + go build -mod=readonly $(CORAL_BUILD_FLAGS) -o build/coral.exe ./cmd/wasmcli +else + go build -mod=readonly $(CORAL_BUILD_FLAGS) -o build/corald ./cmd/wasmd + go build -mod=readonly $(CORAL_BUILD_FLAGS) -o build/coral ./cmd/wasmcli +endif + build-linux: go.sum LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build From c3fe4d83b97defc9b34c7a1527d15eece2f393c5 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 27 Jul 2020 11:02:02 +0200 Subject: [PATCH 2/4] Set different dirs for coral binary --- Makefile | 2 ++ app/app.go | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b1c1b2aca95..791cfe4a12e 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,8 @@ coral_ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=coral \ -X github.com/cosmos/cosmos-sdk/version.ClientName=coral \ -X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \ -X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \ + -X github.com/CosmWasm/wasmd/app.CLIDir=.coral \ + -X github.com/CosmWasm/wasmd/app.NodeDir=.corald \ -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" coral_ldflags += $(LDFLAGS) diff --git a/app/app.go b/app/app.go index 01c5d4a95dc..68b2772860e 100644 --- a/app/app.go +++ b/app/app.go @@ -40,11 +40,15 @@ import ( const appName = "WasmApp" var ( + // We pull these out so we can set them with LDFLAGS in the Makefile + CLIDir = ".wasmcli" + NodeDir = ".wasmd" + // DefaultCLIHome default home directories for wasmcli - DefaultCLIHome = os.ExpandEnv("$HOME/.wasmcli") + DefaultCLIHome = os.ExpandEnv("$HOME/") + CLIDir // DefaultNodeHome default home directories for wasmd - DefaultNodeHome = os.ExpandEnv("$HOME/.wasmd") + DefaultNodeHome = os.ExpandEnv("$HOME/") + NodeDir // ModuleBasics The module BasicManager is in charge of setting up basic, // non-dependant module elements, such as codec registration From 5f48074a8a122c5edc93cf508de9279e65e39397 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 27 Jul 2020 11:10:07 +0200 Subject: [PATCH 3/4] Make the bech32 prefix configurable in Makefile, unique for coral --- Makefile | 1 + app/app.go | 28 ++++++++++++++++++++++++---- cmd/wasmcli/main.go | 6 +++--- cmd/wasmd/main.go | 6 +++--- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 791cfe4a12e..0a03819e329 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,7 @@ coral_ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=coral \ -X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \ -X github.com/CosmWasm/wasmd/app.CLIDir=.coral \ -X github.com/CosmWasm/wasmd/app.NodeDir=.corald \ + -X github.com/CosmWasm/wasmd/app.Bech32Prefix=coral \ -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" coral_ldflags += $(LDFLAGS) diff --git a/app/app.go b/app/app.go index 68b2772860e..9126471dc90 100644 --- a/app/app.go +++ b/app/app.go @@ -39,17 +39,37 @@ import ( const appName = "WasmApp" +// We pull these out so we can set them with LDFLAGS in the Makefile var ( - // We pull these out so we can set them with LDFLAGS in the Makefile - CLIDir = ".wasmcli" - NodeDir = ".wasmd" + CLIDir = ".wasmcli" + NodeDir = ".wasmd" + Bech32Prefix = sdk.Bech32MainPrefix +) +// These constants are derived from the above variables. +// These are the ones we will want to use in the code, based on +// any overrides above +var ( // DefaultCLIHome default home directories for wasmcli DefaultCLIHome = os.ExpandEnv("$HOME/") + CLIDir - // DefaultNodeHome default home directories for wasmd DefaultNodeHome = os.ExpandEnv("$HOME/") + NodeDir + // Bech32PrefixAccAddr defines the Bech32 prefix of an account's address + Bech32PrefixAccAddr = Bech32Prefix + // Bech32PrefixAccPub defines the Bech32 prefix of an account's public key + Bech32PrefixAccPub = Bech32Prefix + sdk.PrefixPublic + // Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address + Bech32PrefixValAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + // Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key + Bech32PrefixValPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic + // Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address + Bech32PrefixConsAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + // Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key + Bech32PrefixConsPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic +) + +var ( // ModuleBasics The module BasicManager is in charge of setting up basic, // non-dependant module elements, such as codec registration // and genesis verification. diff --git a/cmd/wasmcli/main.go b/cmd/wasmcli/main.go index d7e6f42ecc8..d32221393eb 100644 --- a/cmd/wasmcli/main.go +++ b/cmd/wasmcli/main.go @@ -35,9 +35,9 @@ func main() { // Read in the configuration file for the sdk config := sdk.GetConfig() - config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub) - config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub) - config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub) + config.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub) + config.SetBech32PrefixForValidator(app.Bech32PrefixValAddr, app.Bech32PrefixValPub) + config.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub) config.Seal() // TODO: setup keybase, viper object, etc. to be passed into diff --git a/cmd/wasmd/main.go b/cmd/wasmd/main.go index 3afec0de8da..c849b7c9541 100644 --- a/cmd/wasmd/main.go +++ b/cmd/wasmd/main.go @@ -32,9 +32,9 @@ func main() { cdc := app.MakeCodec() config := sdk.GetConfig() - config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub) - config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub) - config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub) + config.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub) + config.SetBech32PrefixForValidator(app.Bech32PrefixValAddr, app.Bech32PrefixValPub) + config.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub) config.Seal() ctx := server.NewDefaultContext() From cd9ae0447ba647b5a15ffaf30b24768e220c2c09 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 27 Jul 2020 11:13:34 +0200 Subject: [PATCH 4/4] Update binary name in help text --- cmd/wasmcli/main.go | 9 +++++---- cmd/wasmd/main.go | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/wasmcli/main.go b/cmd/wasmcli/main.go index d32221393eb..a4e12a2460a 100644 --- a/cmd/wasmcli/main.go +++ b/cmd/wasmcli/main.go @@ -5,6 +5,9 @@ import ( "os" "path" + "github.com/spf13/cobra" + "github.com/spf13/viper" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/keys" @@ -17,8 +20,6 @@ import ( authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" "github.com/cosmos/cosmos-sdk/x/bank" bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli" - "github.com/spf13/cobra" - "github.com/spf13/viper" "github.com/tendermint/go-amino" "github.com/tendermint/tendermint/libs/cli" @@ -45,8 +46,8 @@ func main() { // with the cdc rootCmd := &cobra.Command{ - Use: "wasmcli", - Short: "Command line interface for interacting with wasmd", + Use: version.ClientName, + Short: "Command line interface for interacting with " + version.ServerName, } // Add --chain-id to persistent flags and mark it required diff --git a/cmd/wasmd/main.go b/cmd/wasmd/main.go index c849b7c9541..99b75db4708 100644 --- a/cmd/wasmd/main.go +++ b/cmd/wasmd/main.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "github.com/cosmos/cosmos-sdk/version" "io" "github.com/CosmWasm/wasmd/app" @@ -40,7 +41,7 @@ func main() { ctx := server.NewDefaultContext() cobra.EnableCommandSorting = false rootCmd := &cobra.Command{ - Use: "wasmd", + Use: version.ServerName, Short: "Wasm Daemon (server) with wasm gov proposals disabled\",", PersistentPreRunE: server.PersistentPreRunEFn(ctx), }