From e5e3d48a6dac3da8337722df92c880e3595c5b3c Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 19 Jul 2018 17:16:48 -0400 Subject: [PATCH] Merge pull request #447: Initial Application Skeleton Structure --- Gopkg.lock | 26 ++++++++++++++++-- Gopkg.toml | 4 +++ Makefile | 57 ++++++++++++++++++++++++++++++---------- app/ethermint.go | 45 +++++++++++++++++++++++++++++++ cmd/ethermintcli/main.go | 7 +++++ cmd/ethermintd/main.go | 7 +++++ server/start.go | 1 + types/context.go | 8 ++++++ version/version.go | 10 +++++++ x/.keep | 0 10 files changed, 149 insertions(+), 16 deletions(-) create mode 100644 app/ethermint.go create mode 100644 cmd/ethermintcli/main.go create mode 100644 cmd/ethermintd/main.go create mode 100644 server/start.go create mode 100644 types/context.go create mode 100644 version/version.go create mode 100644 x/.keep diff --git a/Gopkg.lock b/Gopkg.lock index 2245ec99..c0cedd10 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -22,9 +22,12 @@ [[projects]] name = "github.com/cosmos/cosmos-sdk" packages = [ + "baseapp", "store", "types", - "wire" + "version", + "wire", + "x/auth" ] revision = "1a1373cc220e402397ad536aee6b8f5b068914c6" version = "v0.21.0" @@ -138,6 +141,12 @@ ] revision = "0fb14efe8c47ae851c0034ed7a448854d3d34cf3" +[[projects]] + name = "github.com/inconshreveable/mousetrap" + packages = ["."] + revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" + version = "v1.0" + [[projects]] branch = "master" name = "github.com/jmhodges/levigo" @@ -162,6 +171,18 @@ revision = "ca016a06a5753f8ba03029c0aa5e54afb1bf713f" version = "v1.4.0" +[[projects]] + name = "github.com/spf13/cobra" + packages = ["."] + revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385" + version = "v0.0.3" + +[[projects]] + name = "github.com/spf13/pflag" + packages = ["."] + revision = "583c0c0531f06d5278b7d917446061adc344b5cd" + version = "v1.0.1" + [[projects]] branch = "master" name = "github.com/syndtr/goleveldb" @@ -206,6 +227,7 @@ [[projects]] name = "github.com/tendermint/tendermint" packages = [ + "abci/server", "abci/types", "crypto", "crypto/merkle", @@ -327,6 +349,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "df6cfdfe013b00b662a5b9ebd45319d0c114859e865b3034b0e984f15e698b45" + inputs-digest = "6c999da3cbcf5eac93468232147f2d8e372236a297ddd09275edb065f1bc23ae" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 0282dbf3..dfa46868 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -9,6 +9,10 @@ [[constraint]] name = "github.com/hashicorp/golang-lru" +[[constraint]] + name = "github.com/spf13/cobra" + version = "~0.0.1" + [[override]] name = "google.golang.org/genproto" revision = "7fd901a49ba6a7f87732eb344f6e3c5b19d1b200" diff --git a/Makefile b/Makefile index fcc0cecf..f7f71338 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,24 @@ +# Copyright 2018 Tendermint. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + PACKAGES=$(shell go list ./... | grep -v '/vendor/') COMMIT_HASH := $(shell git rev-parse --short HEAD) BUILD_FLAGS = -tags netgo -ldflags "-X github.com/cosmos/ethermint/version.GitCommit=${COMMIT_HASH}" DOCKER_TAG = unstable DOCKER_IMAGE = tendermint/ethermint +ETHERMINT_DAEMON_BINARY = emintd +ETHERMINT_CLI_BINARY = emintcli DEP = github.com/golang/dep/cmd/dep GOLINT = github.com/tendermint/lint/golint @@ -26,17 +42,22 @@ GOCYCLO_CHECK := $(shell command -v gocyclo 2> /dev/null) all: tools deps install -ci: tools deps install +####################### +### Build / Install ### +####################### build: ifeq ($(OS),Windows_NT) - go build $(BUILD_FLAGS) -o build/ethermint.exe ./*.go + go build $(BUILD_FLAGS) -o build/$(ETHERMINT_DAEMON_BINARY).exe ./cmd/ethermintd + go build $(BUILD_FLAGS) -o build/$(ETHERMINT_CLI_BINARY).exe ./cmd/ethermintcli else - go build $(BUILD_FLAGS) -o build/ethermint ./*.go + go build $(BUILD_FLAGS) -o build/$(ETHERMINT_DAEMON_BINARY) ./cmd/ethermintd/ + go build $(BUILD_FLAGS) -o build/$(ETHERMINT_CLI_BINARY) ./cmd/ethermintcli/ endif install: - go install $(BUILD_FLAGS) ./*.go + go install $(BUILD_FLAGS) ./cmd/ethermintd + go install $(BUILD_FLAGS) ./cmd/ethermintcli clean: rm -rf ./build ./vendor @@ -45,57 +66,61 @@ update-tools: @echo "Updating golang dependencies" go get -u -v $(DEP) $(GOLINT) $(GOMETALINTER) $(UNCONVERT) $(INEFFASSIGN) $(MISSPELL) $(ERRCHECK) $(UNPARAM) $(GOCYCLO) +############################ +### Tools / Dependencies ### +############################ + tools: ifdef DEP_CHECK - @echo "Dep is already installed. Run 'make update-tools' to update." + @echo "Dep is already installed. Run 'make update-tools' to update." else @echo "Installing dep" go get -v $(DEP) endif ifdef GOLINT_CHECK - @echo "Golint is already installed. Run 'make update-tools' to update." + @echo "Golint is already installed. Run 'make update-tools' to update." else @echo "Installing golint" go get -v $(GOLINT) endif ifdef GOMETALINTER_CHECK - @echo "Gometalinter.v2 is already installed. Run 'make update-tools' to update." + @echo "Gometalinter.v2 is already installed. Run 'make update-tools' to update." else @echo "Installing gometalinter.v2" go get -v $(GOMETALINTER) endif ifdef UNCONVERT_CHECK - @echo "Unconvert is already installed. Run 'make update-tools' to update." + @echo "Unconvert is already installed. Run 'make update-tools' to update." else @echo "Installing unconvert" go get -v $(UNCONVERT) endif ifdef INEFFASSIGN_CHECK - @echo "Ineffassign is already installed. Run 'make update-tools' to update." + @echo "Ineffassign is already installed. Run 'make update-tools' to update." else @echo "Installing ineffassign" go get -v $(INEFFASSIGN) endif ifdef MISSPELL_CHECK - @echo "misspell is already installed. Run 'make update-tools' to update." + @echo "misspell is already installed. Run 'make update-tools' to update." else @echo "Installing misspell" go get -v $(MISSPELL) endif ifdef ERRCHECK_CHECK - @echo "errcheck is already installed. Run 'make update-tools' to update." + @echo "errcheck is already installed. Run 'make update-tools' to update." else @echo "Installing errcheck" go get -v $(ERRCHECK) endif ifdef UNPARAM_CHECK - @echo "unparam is already installed. Run 'make update-tools' to update." + @echo "unparam is already installed. Run 'make update-tools' to update." else @echo "Installing unparam" go get -v $(UNPARAM) endif ifdef GOCYCLO_CHECK - @echo "goyclo is already installed. Run 'make update-tools' to update." + @echo "goyclo is already installed. Run 'make update-tools' to update." else @echo "Installing goyclo" go get -v $(GOCYCLO) @@ -106,6 +131,10 @@ deps: @echo "--> Running dep ensure" @dep ensure -v +####################### +### Testing / Misc. ### +####################### + godocs: @echo "--> Wait a few seconds and visit http://localhost:6060/pkg/github.com/cosmos/ethermint" godoc -http=:6060 @@ -115,4 +144,4 @@ docker: docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:latest docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:${COMMIT_HASH} -.PHONY: build install update-tools tools deps godocs +.PHONY: build install update-tools tools deps godocs clean diff --git a/app/ethermint.go b/app/ethermint.go new file mode 100644 index 00000000..ff68ac69 --- /dev/null +++ b/app/ethermint.go @@ -0,0 +1,45 @@ +package app + +import ( + bam "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/wire" +) + +const ( + appName = "Ethermint" +) + +// EthermintApp implements an extended ABCI application. +type EthermintApp struct { + *bam.BaseApp + + codec *wire.Codec + sealed bool + + // TODO: stores and keys + + // TODO: keepers + + // TODO: mappers +} + +// NewEthermintApp returns a reference to a new initialized Ethermint +// application. +func NewEthermintApp(opts ...func(*EthermintApp)) *EthermintApp { + app := &EthermintApp{} + + // TODO: implement constructor + + for _, opt := range opts { + opt(app) + } + + app.seal() + return app +} + +// seal seals the Ethermint application and prohibits any future modifications +// that change critical components. +func (app *EthermintApp) seal() { + app.sealed = true +} diff --git a/cmd/ethermintcli/main.go b/cmd/ethermintcli/main.go new file mode 100644 index 00000000..e769e031 --- /dev/null +++ b/cmd/ethermintcli/main.go @@ -0,0 +1,7 @@ +package main + +func main() { + // TODO: Implement CLI commands and logic + // + // Ref: https://github.com/cosmos/ethermint/issues/432 +} diff --git a/cmd/ethermintd/main.go b/cmd/ethermintd/main.go new file mode 100644 index 00000000..33176840 --- /dev/null +++ b/cmd/ethermintd/main.go @@ -0,0 +1,7 @@ +package main + +func main() { + // TODO: Implement daemon command and logic + // + // Ref: https://github.com/cosmos/ethermint/issues/433 +} diff --git a/server/start.go b/server/start.go new file mode 100644 index 00000000..abb4e431 --- /dev/null +++ b/server/start.go @@ -0,0 +1 @@ +package server diff --git a/types/context.go b/types/context.go new file mode 100644 index 00000000..f9943fe4 --- /dev/null +++ b/types/context.go @@ -0,0 +1,8 @@ +package types + +// AppContext provides the ability for the application to pass around and +// obtain immutable objects easily. More importantly, it allows for the +// utilization of the object-capability model in which components gain access +// to other components for which they truly need. +type AppContext struct { +} diff --git a/version/version.go b/version/version.go new file mode 100644 index 00000000..44d4e60f --- /dev/null +++ b/version/version.go @@ -0,0 +1,10 @@ +package version + +// Version contains the application semantic version. +// +// TODO: How do we want to version this being that an initial Ethermint has +// been developed? +const Version = "0.0.0" + +// GitCommit contains the git SHA1 short hash set by build flags. +var GitCommit = "" diff --git a/x/.keep b/x/.keep new file mode 100644 index 00000000..e69de29b