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 44 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 @@ -19,6 +19,7 @@
.glide/
vendor
build
bin
tools/bin/*
docs/_build
docs/tutorial
Expand All @@ -28,6 +29,7 @@ dist
tools-stamp
proto-tools-stamp
golangci-lint
keyring_test_cosmos

# Testing
coverage.txt
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

* (build) [\#378](https://github.com/ChainSafe/ethermint/pull/378) Create multi-node, local, automated testnet setup with `make localnet-start`.
* (rpc) [\#330](https://github.com/ChainSafe/ethermint/issues/330) Implement `PublicFilterAPI`'s `EventSystem` which subscribes to Tendermint events upon `Filter` creation.
* (rpc) [\#231](https://github.com/ChainSafe/ethermint/issues/231) Implement `NewBlockFilter` in rpc/filters.go which instantiates a polling block filter
* Polls for new blocks via `BlockNumber` rpc call; if block number changes, it requests the new block via `GetBlockByNumber` rpc call and adds it to its internal list of blocks
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ COPY --from=build-env /go/src/github.com/Chainsafe/ethermint/build/emintd /usr/b
COPY --from=build-env /go/src/github.com/Chainsafe/ethermint/build/emintcli /usr/bin/emintcli

# Run emintd by default
CMD ["emintd"]
CMD ["emintd"]
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
236 changes: 101 additions & 135 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-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:
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-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 @@ -55,31 +60,26 @@ verify:
@echo "--> Verifying dependencies have not been modified"
${GO_MOD} go mod verify

docker:
docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} .
docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:latest
docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:${COMMIT_HASH}
# update old container
docker rm ethermint
# create a new container from the latest image
docker create --name ethermint -t -i cosmos/ethermint:latest ethermint
# move the binaries to the ./build directory
mkdir -p ./build/
docker cp ethermint:/usr/bin/emintd ./build/ ; \
docker cp ethermint:/usr/bin/emintcli ./build/
Comment on lines +63 to +74
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@araskachoi this could possibly be improved


docker-localnet:
# build the image
docker build -f ./networks/local/ethermintnode/Dockerfile . -t emintd/node

############################
### 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 +91,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 @@ -155,15 +112,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

docker:
docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} .
docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:latest
docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:${COMMIT_HASH}
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

.PHONY: build install update-tools tools godocs clean format lint \
test-cli test-race test-unit test test-import
Expand Down Expand Up @@ -256,50 +238,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 @@ -311,4 +253,28 @@ 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: localnet-stop
mkdir -p ./build/
@$(MAKE) docker-localnet

if ! [ -f build/node0/$(ETHERMINT_DAEMON_BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/ethermint:Z emintd/node "emintd testnet --v 4 -o /ethermint --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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ parent:
<a href="https://goreportcard.com/report/github.com/ChainSafe/ethermint">
<img alt="Go report card" src="https://goreportcard.com/badge/github.com/ChainSafe/ethermint"/>
</a>
<a href="https://codecov.io/gh/cosmos/ethermint">
<img alt="Code Coverage" src="https://codecov.io/gh/ChainSafe/ethermint/branch/development/graph/badge.svg"/>
<a href="https://codecov.io/gh/ChainSafe/ethermint">
<img alt="Code Coverage" src="https://codecov.io/gh/ChainSafe/ethermint/branch/development/graph/badge.svg" />
</a>
</div>
<div align="center">
Expand Down
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 @@ -75,7 +75,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