Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Local Testnet command #378

Merged
merged 45 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f481ff6
evm: fix non-determinism
fedekunze Jul 2, 2020
e139d96
fixes
fedekunze Jul 2, 2020
9601ed1
typo
fedekunze Jul 2, 2020
1a5991c
Merge branch 'development' of github.com:ChainSafe/ethermint into fix…
fedekunze Jul 7, 2020
a64afb6
fix tests
fedekunze Jul 7, 2020
cacc374
local testnet command
fedekunze Jul 7, 2020
9d35880
fix testnet cmd (#383)
Jul 9, 2020
776fc27
merge development
fedekunze Jul 9, 2020
8f4fc91
Merge branch 'fix-non-determinism' of github.com:ChainSafe/ethermint …
fedekunze Jul 9, 2020
f50b833
Merge branch 'testnet' of github.com:ChainSafe/ethermint into testnet
fedekunze Jul 9, 2020
f21b88e
fixes
fedekunze Jul 9, 2020
c36f498
update docker
fedekunze Jul 9, 2020
caa492a
merge development
fedekunze Jul 13, 2020
3e1b09b
minor changes
fedekunze Jul 13, 2020
b4c20e1
fix build-docker-local-ethermint
fedekunze Jul 14, 2020
f004dc9
fix dockerfile
fedekunze Jul 14, 2020
0392949
update Makefile
fedekunze Jul 14, 2020
cf3d14a
update denoms
fedekunze Jul 14, 2020
0495592
update genesis file
fedekunze Jul 14, 2020
1fc38d6
Merge branch 'development' of github.com:ChainSafe/ethermint into tes…
fedekunze Jul 15, 2020
b8545e6
Merge branch 'development' into testnet
fedekunze Jul 15, 2020
a22f4bb
Merge branch 'testnet' of github.com:ChainSafe/ethermint into testnet
fedekunze Jul 15, 2020
ab6c564
update makefile
fedekunze Jul 15, 2020
592dde7
fix docker-compose.yml images
fedekunze Jul 15, 2020
de3f05d
fix localnet execution (#398)
alessio Jul 21, 2020
ff3060c
Merge branch 'development' into testnet
fedekunze Jul 21, 2020
81e95cd
fix conflicts
fedekunze Jul 21, 2020
184c9ab
finish documentation
fedekunze Jul 21, 2020
505c17b
changelog and comment rpc tests workflow
fedekunze Jul 21, 2020
fe11029
update codecov
fedekunze Jul 21, 2020
ed72b0d
Merge branch 'development' into testnet
fedekunze Jul 21, 2020
7b573e5
update testnet docs
fedekunze Jul 22, 2020
8efa6ba
Merge branch 'testnet' of github.com:ChainSafe/ethermint into testnet
fedekunze Jul 22, 2020
d7bea0d
fix docker-compose execution
fedekunze Jul 22, 2020
79fd45d
update docs
fedekunze Jul 22, 2020
a9983c3
fix errors and make testnet work (#403)
araskachoi Jul 29, 2020
b7eb14d
Merge branch 'development' into testnet
fedekunze Jul 29, 2020
ced5dc9
update entrypoint and docs
araskachoi Jul 29, 2020
e196178
fix conflicts
fedekunze Jul 30, 2020
5b3236d
Merge branch 'testnet' of github.com:ChainSafe/ethermint into testnet
fedekunze Jul 30, 2020
43f396e
update logs
fedekunze Jul 30, 2020
1a220c4
try fix rpc
fedekunze Jul 31, 2020
28442ee
build docker image
araskachoi Jul 31, 2020
0d886c5
Merge branch 'testnet' of github.com:ChainSafe/ethermint into testnet
araskachoi Jul 31, 2020
0f776c0
Update Dockerfile
fedekunze Jul 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ dist
tools-stamp
proto-tools-stamp
golangci-lint
local_testnet
keyring_test_cosmos

# Testing
coverage.txt
Expand Down
22 changes: 12 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
FROM golang:alpine AS build-env

# Set up dependencies
ENV PACKAGES git build-base
# Install minimum necessary dependencies
ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3
RUN apk add --no-cache $PACKAGES

# Set working directory for the build
WORKDIR /go/src/github.com/Chainsafe/ethermint

# Install dependencies
RUN apk add --update $PACKAGES
WORKDIR /go/src/github.com/ChainSafe/ethermint

# Add source files
COPY . .

# Make the binary
RUN make build
# build Cosmos SDK, remove packages
RUN make build-ethermint && \
cp ./build/emint* /go/bin
fedekunze marked this conversation as resolved.
Show resolved Hide resolved


# Final image
FROM alpine
FROM alpine:edge

# Install ca-certificates
RUN apk add --update ca-certificates
Expand All @@ -26,5 +26,7 @@ WORKDIR /root
COPY --from=build-env /go/src/github.com/Chainsafe/ethermint/build/emintd /usr/bin/emintd
COPY --from=build-env /go/src/github.com/Chainsafe/ethermint/build/emintcli /usr/bin/emintcli

# Run emintd by default
EXPOSE 26656 26657 1317

# Run emintd by default, omit entrypoint to ease using container with emintcli
CMD ["emintd"]
215 changes: 84 additions & 131 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,32 @@ ETHERMINT_DAEMON_BINARY = emintd
ETHERMINT_CLI_BINARY = emintcli
GO_MOD=GO111MODULE=on
BINDIR ?= $(GOPATH)/bin
BUILDDIR ?= $(CURDIR)/build
SIMAPP = github.com/cosmos/ethermint/app
RUNSIM = $(BINDIR)/runsim

all: tools verify install

#######################
### Build / Install ###
#######################
###############################################################################
### Build ###
###############################################################################

build: go.sum
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@J-Thompson12 can you test these commands on your machine? 🙏

go build -mod=readonly ./...

build:
ifeq ($(OS),Windows_NT)
${GO_MOD} go build $(BUILD_FLAGS) -o build/$(ETHERMINT_DAEMON_BINARY).exe ./cmd/emintd
${GO_MOD} go build $(BUILD_FLAGS) -o build/$(ETHERMINT_CLI_BINARY).exe ./cmd/emintcli
else
${GO_MOD} go build $(BUILD_FLAGS) -o build/$(ETHERMINT_DAEMON_BINARY) ./cmd/emintd/
${GO_MOD} go build $(BUILD_FLAGS) -o build/$(ETHERMINT_CLI_BINARY) ./cmd/emintcli/
endif
build-ethermint: go.sum
mkdir -p $(BUILDDIR)
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR) ./cmd/$(ETHERMINT_DAEMON_BINARY)
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR) ./cmd/$(ETHERMINT_CLI_BINARY)

build-ethermint-linux: go.sum
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 $(MAKE) build-ethermint

.PHONY: build build-ethermint build-ethermint-linux

install:
${GO_MOD} go install $(BUILD_FLAGS) ./cmd/emintd
${GO_MOD} go install $(BUILD_FLAGS) ./cmd/emintcli
${GO_MOD} go install $(BUILD_FLAGS) ./cmd/$(ETHERMINT_DAEMON_BINARY)
${GO_MOD} go install $(BUILD_FLAGS) ./cmd/$(ETHERMINT_CLI_BINARY)

clean:
@rm -rf ./build ./vendor
Expand All @@ -56,30 +61,9 @@ verify:
${GO_MOD} go mod verify


############################
### Tools / Dependencies ###
############################

##########################################################
### TODO: Move tool depedencies to a separate makefile ###
##########################################################

GOLINT = github.com/tendermint/lint/golint
GOCILINT = github.com/golangci/golangci-lint/cmd/golangci-lint
UNCONVERT = github.com/mdempsky/unconvert
INEFFASSIGN = github.com/gordonklaus/ineffassign
MISSPELL = github.com/client9/misspell/cmd/misspell
ERRCHECK = github.com/kisielk/errcheck
UNPARAM = mvdan.cc/unparam

GOLINT_CHECK := $(shell command -v golint 2> /dev/null)
GOCILINT_CHECK := $(shell command -v golangci-lint 2> /dev/null)
UNCONVERT_CHECK := $(shell command -v unconvert 2> /dev/null)
INEFFASSIGN_CHECK := $(shell command -v ineffassign 2> /dev/null)
MISSPELL_CHECK := $(shell command -v misspell 2> /dev/null)
ERRCHECK_CHECK := $(shell command -v errcheck 2> /dev/null)
UNPARAM_CHECK := $(shell command -v unparam 2> /dev/null)

###############################################################################
### Tools & Dependencies ###
###############################################################################

# Install the runsim binary with a temporary workaround of entering an outside
# directory as the "go get" command ignores the -mod option and will polute the
Expand All @@ -91,53 +75,10 @@ $(RUNSIM):
@(cd /tmp && go get github.com/cosmos/tools/cmd/[email protected])

tools: $(RUNSIM)
ifdef GOLINT_CHECK
@echo "Golint is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing golint"
${GO_MOD} go get -v $(GOLINT)
endif
ifdef GOCILINT_CHECK
@echo "golangci-lint is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing golangci-lint"
${GO_MOD} go get -v $(GOCILINT)
endif
ifdef UNCONVERT_CHECK
@echo "Unconvert is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing unconvert"
${GO_MOD} go get -v $(UNCONVERT)
endif
ifdef INEFFASSIGN_CHECK
@echo "Ineffassign is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing ineffassign"
${GO_MOD} go get -v $(INEFFASSIGN)
endif
ifdef MISSPELL_CHECK
@echo "misspell is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing misspell"
${GO_MOD} go get -v $(MISSPELL)
endif
ifdef ERRCHECK_CHECK
@echo "errcheck is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing errcheck"
${GO_MOD} go get -v $(ERRCHECK)
endif
ifdef UNPARAM_CHECK
@echo "unparam is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing unparam"
${GO_MOD} go get -v $(UNPARAM)
endif


#######################
### Testing / Misc. ###
#######################

###############################################################################
### Tests & Simulation ###
###############################################################################

test: test-unit

Expand All @@ -154,9 +95,40 @@ test-import:
test-rpc:
./scripts/integration-test-all.sh -q 1 -z 1 -s 2

godocs:
@echo "--> Wait a few seconds and visit http://localhost:6060/pkg/github.com/cosmos/ethermint"
godoc -http=:6060
test-sim-nondeterminism:
@echo "Running non-determinism test..."
@go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
-NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h

test-sim-custom-genesis-fast:
@echo "Running custom genesis simulation..."
@echo "By default, ${HOME}/.$(ETHERMINT_DAEMON_BINARY)/config/genesis.json will be used."
@go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Genesis=${HOME}/.$(ETHERMINT_DAEMON_BINARY)/config/genesis.json \
-Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h

test-sim-import-export: runsim
@echo "Running Ethermint import/export simulation. This may take several minutes..."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 25 5 TestAppImportExport

test-sim-after-import: runsim
@echo "Running Ethermint simulation-after-import. This may take several minutes..."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 25 5 TestAppSimulationAfterImport

test-sim-custom-genesis-multi-seed: runsim
@echo "Running multi-seed custom genesis simulation..."
@echo "By default, ${HOME}/.$(ETHERMINT_DAEMON_BINARY)/config/genesis.json will be used."
@$(BINDIR)/runsim -Jobs=4 -Genesis=${HOME}/.$(ETHERMINT_DAEMON_BINARY)/config/genesis.json 400 5 TestFullAppSimulation

test-sim-multi-seed-long: runsim
@echo "Running multi-seed application simulation. This may take awhile!"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 500 50 TestFullAppSimulation

test-sim-multi-seed-short: runsim
@echo "Running multi-seed application simulation. This may take awhile!"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 50 10 TestFullAppSimulation

.PHONY: runsim test-sim-nondeterminism test-sim-custom-genesis-fast test-sim-fast sim-import-export \
test-sim-simulation-after-import test-sim-custom-genesis-multi-seed test-sim-multi-seed

docker:
docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} .
Expand Down Expand Up @@ -255,50 +227,10 @@ proto-update-deps:

.PHONY: proto-all proto-gen proto-lint proto-check-breaking proto-update-deps

#######################
### Simulations ###
#######################

test-sim-nondeterminism:
@echo "Running non-determinism test..."
@go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
-NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h

test-sim-custom-genesis-fast:
@echo "Running custom genesis simulation..."
@echo "By default, ${HOME}/.emintd/config/genesis.json will be used."
@go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Genesis=${HOME}/.emintd/config/genesis.json \
-Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h

test-sim-import-export: runsim
@echo "Running Ethermint import/export simulation. This may take several minutes..."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 25 5 TestAppImportExport

test-sim-after-import: runsim
@echo "Running Ethermint simulation-after-import. This may take several minutes..."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 25 5 TestAppSimulationAfterImport

test-sim-custom-genesis-multi-seed: runsim
@echo "Running multi-seed custom genesis simulation..."
@echo "By default, ${HOME}/.emintd/config/genesis.json will be used."
@$(BINDIR)/runsim -Jobs=4 -Genesis=${HOME}/.emintd/config/genesis.json 400 5 TestFullAppSimulation

test-sim-multi-seed-long: runsim
@echo "Running multi-seed application simulation. This may take awhile!"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 500 50 TestFullAppSimulation

test-sim-multi-seed-short: runsim
@echo "Running multi-seed application simulation. This may take awhile!"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 50 10 TestFullAppSimulation

.PHONY: runsim test-sim-nondeterminism test-sim-custom-genesis-fast test-sim-fast sim-import-export \
test-sim-simulation-after-import test-sim-custom-genesis-multi-seed test-sim-multi-seed \



#######################
### Documentation ###
#######################
###############################################################################
### Documentation ###
###############################################################################

# Start docs site at localhost:8080
docs-serve:
Expand All @@ -310,4 +242,25 @@ docs-serve:
docs-build:
@cd docs && \
npm install && \
npm run build
npm run build

godocs:
@echo "--> Wait a few seconds and visit http://localhost:6060/pkg/github.com/cosmos/ethermint"
godoc -http=:6060

###############################################################################
### Localnet ###
###############################################################################

build-docker-local-ethermint:
@$(MAKE) -C networks/local

# Run a 4-node testnet locally
localnet-start: build-ethermint-linux localnet-stop
@if ! [ -f build/node0/$(ETHERMINT_DAEMON_BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/$(ETHERMINT_DAEMON_BINARY):Z ethermint/node testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
docker-compose up -d

localnet-stop:
docker-compose down

.PHONY: build-docker-local-ethermint localnet-start localnet-stop
12 changes: 3 additions & 9 deletions cmd/emintcli/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import (
"bufio"
"io"

"github.com/tendermint/tendermint/crypto"

"github.com/cosmos/cosmos-sdk/client/flags"
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"

emintCrypto "github.com/cosmos/ethermint/crypto"
"github.com/cosmos/ethermint/crypto"

"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down Expand Up @@ -54,15 +52,15 @@ func keyCommands() *cobra.Command {

func getKeybase(transient bool, buf io.Reader) (keyring.Keybase, error) {
if transient {
return keyring.NewInMemory(keyring.WithKeygenFunc(ethermintKeygenFunc)), nil
return keyring.NewInMemory(keyring.WithKeygenFunc(crypto.EthermintKeygenFunc)), nil
}

return keyring.NewKeyring(
sdk.KeyringServiceName(),
viper.GetString(flags.FlagKeyringBackend),
viper.GetString(flags.FlagHome),
buf,
keyring.WithKeygenFunc(ethermintKeygenFunc))
keyring.WithKeygenFunc(crypto.EthermintKeygenFunc))
}

func runAddCmd(cmd *cobra.Command, args []string) error {
Expand All @@ -74,7 +72,3 @@ func runAddCmd(cmd *cobra.Command, args []string) error {

return clientkeys.RunAddCmd(cmd, args, kb, inBuf)
}

func ethermintKeygenFunc(bz []byte, algo keyring.SigningAlgo) (crypto.PrivKey, error) {
return emintCrypto.PrivKeySecp256k1(bz), nil
}
2 changes: 1 addition & 1 deletion cmd/emintd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func main() {
app.DefaultNodeHome, app.DefaultCLIHome,
),
genutilcli.ValidateGenesisCmd(ctx, cdc, app.ModuleBasics),

testnetCmd(ctx, cdc, app.ModuleBasics, bank.GenesisBalancesIterator{}),
// AddGenesisAccountCmd allows users to add accounts to the genesis file
AddGenesisAccountCmd(ctx, cdc, appCodec, app.DefaultNodeHome, app.DefaultCLIHome),
flags.NewCompletionCmd(rootCmd, true),
Expand Down
Loading