diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..0f1475398d --- /dev/null +++ b/Makefile @@ -0,0 +1,76 @@ +#!/usr/bin/make -f + +VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//') +COMMIT := $(shell git log -1 --format='%H') + +export GO111MODULE = on + +# process build tags + +LEDGER_ENABLED ?= true +build_tags = netgo +ifeq ($(LEDGER_ENABLED),true) + ifeq ($(OS),Windows_NT) + GCCEXE = $(shell where gcc.exe 2> NUL) + ifeq ($(GCCEXE),) + $(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false) + else + build_tags += ledger + endif + else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S),OpenBSD) + $(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)) + else + GCC = $(shell command -v gcc 2> /dev/null) + ifeq ($(GCC),) + $(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false) + else + build_tags += ledger + endif + endif + endif +endif + +build_tags += $(BUILD_TAGS) +build_tags := $(strip $(build_tags)) + +whitespace := +whitespace += $(whitespace) +comma := , +build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) + +# process linker flags + +ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=sei \ + -X github.com/cosmos/cosmos-sdk/version.ServerName=seid \ + -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)" + +ifeq ($(LINK_STATICALLY),true) + ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static" +endif +ldflags += $(LDFLAGS) +ldflags := $(strip $(ldflags)) + +BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' + +#### Command List #### + +all: lint install + +install: go.sum + go install $(BUILD_FLAGS) ./cmd/seid + +go.sum: go.mod + @echo "--> Ensure dependencies have not been modified" + @go mod verify + +lint: + golangci-lint run + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s + go mod verify + +build: + go build $(BUILD_FLAGS) -o ./build/seid ./cmd/seid diff --git a/app/app.go b/app/app.go index eac0fed470..61e504bff2 100644 --- a/app/app.go +++ b/app/app.go @@ -115,7 +115,7 @@ import ( const ( AccountAddressPrefix = "cosmos" - Name = "sei-chain" + Name = "sei" ) // this line is used by starport scaffolding # stargate/wasm/app/enabledProposals @@ -245,6 +245,8 @@ type App struct { // sm is the simulation manager sm *module.SimulationManager + configurator module.Configurator + tracingInfo *tracing.TracingInfo } @@ -571,7 +573,8 @@ func New( app.mm.RegisterInvariants(&app.CrisisKeeper) app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) - app.mm.RegisterServices(module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())) + app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) + app.mm.RegisterServices(app.configurator) // create the simulation manager and define the order of the modules for deterministic simulations app.sm = module.NewSimulationManager( @@ -595,6 +598,7 @@ func New( ) app.sm.RegisterStoreDecoders() + app.RegisterUpgradeHandlers() // initialize stores app.MountKVStores(keys) app.MountTransientStores(tkeys) diff --git a/app/upgrades.go b/app/upgrades.go new file mode 100644 index 0000000000..54368089d6 --- /dev/null +++ b/app/upgrades.go @@ -0,0 +1,21 @@ +package app + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +const UPGRADE_1_0_1_BETA = "upgrade-1.0.1beta" + +func (app App) RegisterUpgradeHandlers() { + app.UpgradeKeeper.SetUpgradeHandler(UPGRADE_1_0_1_BETA, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // Upgrade specific logic goes here + // For now, remove dex, epoch and oracle from the version map since + // they do not yet have upgrade logic + delete(fromVM, "dex") + delete(fromVM, "epoch") + delete(fromVM, "oracle") + return app.mm.RunMigrations(ctx, app.configurator, fromVM) + }) +} diff --git a/cmd/sei-chaind/main.go b/cmd/seid/main.go similarity index 100% rename from cmd/sei-chaind/main.go rename to cmd/seid/main.go diff --git a/cmd/sei-chaind/root.go b/cmd/seid/root.go similarity index 100% rename from cmd/sei-chaind/root.go rename to cmd/seid/root.go diff --git a/readme.md b/readme.md index d2a5d31182..4732226abc 100644 --- a/readme.md +++ b/readme.md @@ -14,22 +14,22 @@ starport chain serve ### Internal tool First build the tool ``` -go build -o build/seid ./cmd/sei-chaind/ +make install ``` If you've run the chain before, you may have leftover cruft. Run the following to reset the state. ``` -./build/seid unsafe-reset-all +seid unsafe-reset-all ``` Next, initialize the chain. This creates the genesis field: ``` -./build/seid init demo --chain-id sei-chain +seid init {moniker} --chain-id sei-chain ``` Finally, start the chain: ``` -./build/seid start +seid start ``` diff --git a/scripts/initialize_local_test_node.sh b/scripts/initialize_local_test_node.sh index 3d78237725..c5c2931387 100644 --- a/scripts/initialize_local_test_node.sh +++ b/scripts/initialize_local_test_node.sh @@ -26,7 +26,7 @@ docker run -d --name jaeger \ jaegertracing/all-in-one:1.33 echo "Building..." -go build -o build/seid ./cmd/sei-chaind/ +go build -o build/seid ./cmd/seid/ echo $password | sudo -S rm -r ~/.sei-chain/ echo $password | sudo -S rm -r ~/test_accounts/ ./build/seid unsafe-reset-all