mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 00:05:18 +00:00
c511c56560
* ibc v3 upgrade * ibc no longer uses confio * add proofs proto for ibc/v3 * wip add ethermint module * update cosmos to 0.45.0 * add ethermint proto & bug fixes * remove todo * update docs * fix a number of bugs * minor comments update * fix breaking tests * Wrap bank keeper for EVM to convert decimals (#1154) * Add bankkeeper wrapper for evm * Remove agas from init-new-chain.sh, use ukava for evm_denom * Fix sdk.Coins conversion, require min 1 coin amount * Remove gas from init script idk how this happened lol * Remove debug logging stmt * Restore original init ukava amounts * Fix inplace coins conversion * Use evmtypes.BankKeeper interface insteadof banktypes * Add TestGetBalance * Add doc comments, remove temp actualAmt vars actualAmt vars replaced with inline calls to make it more clear that the converted value is being used, as opposed to accidentally reusing the raw EVM amt. * Add TestSetBalance * Add TestIdempotentConversion * Panic if converted coin from EVM is 0 This happens if a value is less than 1ukava * Deep copy coins instead of in place modification * Update test coins amount * Add panic tests for small EVM amounts * Use evmtypes.BankKeeper as NewEVMBankKeeper param * Tidy test setup * ensure sdk config is set when creating new apps * Respond EVM bank keeper GetBalance with SpendableCoins Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com> * further speed up docker builds * feat: restore previous keys add defaults, add eth flag (#1172) * feat: restore previous keys add defaults, add eth flag * remove outdated comment * fix: remove redundant flag default * evm bank keeper with akava handling * fix issues * add remaining tests * add emv module to app * add missing imports * clean up comments * wip akava keeper * evm keeper * fix genesis import * reduce module permissions * add bank keeper tests * cleanup tests * genesis tests * change defaults * add eth faucet key & fix issues * switch to kava ethermint * add a lot of tests * add balances invariant * add evm tests * Remove panic if Swagger disabled in config (#1155) (#1183) Co-authored-by: Derrick Lee <derrick@dlee.dev> * add invariant to catch any akava balance > 1 ukava * clarify name of balances invariant * connect invariants to app * fix evmbankkeeper akava issues * add spec for evmutil * remove zero balance accounts from state * minor adustments * update to ethermint 0.10.0 * fix eth ante * add missing godoc comment * Update x/evmutil/spec/01_concepts.md Co-authored-by: Kevin Davis <karzak@users.noreply.github.com> * Update x/evmutil/spec/01_concepts.md Co-authored-by: Kevin Davis <karzak@users.noreply.github.com> * Update ethermint to v0.12 (#1203) * update to ethermint v0.12.2 * use app.Options for new evm options * fix missed references to app.Options * use ethermint branch while waiting on upstream fix * evm migrations for tesnet alpha 2 (#1206) * update to ethermint v0.12.2 * use app.Options for new evm options * fix missed references to app.Options * use ethermint branch while waiting on upstream fix * add upgrade handler for evm-alpha testnet 2 * v17 migration setup + evm modules * refactor migrate states * x/feemarket migration * v17 migrations setup + evm modules migration (#1210) * v17 migration setup + evm modules * refactor migrate states * update gen time * fix: update genesis time in test output Co-authored-by: karzak <kjydavis3@gmail.com> * add savings module to app blockers Co-authored-by: Derrick Lee <derrick@dlee.dev> Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com> Co-authored-by: rhuairahrighairigh <ruaridh.odonnell@gmail.com> Co-authored-by: Kevin Davis <karzak@users.noreply.github.com> Co-authored-by: Ruaridh <rhuairahrighairidh@users.noreply.github.com> Co-authored-by: karzak <kjydavis3@gmail.com>
270 lines
12 KiB
Makefile
270 lines
12 KiB
Makefile
#!/usr/bin/make -f
|
|
|
|
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
|
|
TM_PKG_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::')
|
|
COSMOS_PKG_VERSION := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::')
|
|
COMMIT := $(shell git log -1 --format='%H')
|
|
LEDGER_ENABLED ?= true
|
|
PROJECT_NAME = kava
|
|
DOCKER:=docker
|
|
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
|
|
HTTPS_GIT := https://github.com/Kava-Labs/kava.git
|
|
|
|
export GO111MODULE = on
|
|
|
|
# process build tags
|
|
|
|
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
|
|
|
|
ifeq ($(WITH_CLEVELDB),yes)
|
|
build_tags += gcc
|
|
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=kava \
|
|
-X github.com/cosmos/cosmos-sdk/version.AppName=kava \
|
|
-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)" \
|
|
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_PKG_VERSION)
|
|
|
|
ifeq ($(WITH_CLEVELDB),yes)
|
|
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
|
|
endif
|
|
ldflags += $(LDFLAGS)
|
|
ldflags := $(strip $(ldflags))
|
|
|
|
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
|
|
|
|
|
|
all: install
|
|
|
|
build: go.sum
|
|
ifeq ($(OS), Windows_NT)
|
|
go build -mod=readonly $(BUILD_FLAGS) -o build/$(shell go env GOOS)/kava.exe ./cmd/kava
|
|
else
|
|
go build -mod=readonly $(BUILD_FLAGS) -o build/$(shell go env GOOS)/kava ./cmd/kava
|
|
endif
|
|
|
|
build-linux: go.sum
|
|
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
|
|
|
|
install: go.sum
|
|
go install -mod=readonly $(BUILD_FLAGS) ./cmd/kava
|
|
|
|
########################################
|
|
### Tools & dependencies
|
|
|
|
go-mod-cache: go.sum
|
|
@echo "--> Download go modules to local cache"
|
|
@go mod download
|
|
PHONY: go-mod-cache
|
|
|
|
go.sum: go.mod
|
|
@echo "--> Ensuring dependencies have not been modified"
|
|
@go mod verify
|
|
|
|
clean:
|
|
rm -rf build/
|
|
|
|
########################################
|
|
### Linting
|
|
|
|
# Check url links in the repo are not broken.
|
|
# This tool checks local markdown links as well.
|
|
# Set to exclude riot links as they trigger false positives
|
|
link-check:
|
|
@go get -u github.com/raviqqe/liche@f57a5d1c5be4856454cb26de155a65a4fd856ee3
|
|
liche -r . --exclude "^http://127.*|^https://riot.im/app*|^http://kava-testnet*|^https://testnet-dex*|^https://kava3.data.kava.io*|^https://ipfs.io*|^https://apps.apple.com*|^https://kava.quicksync.io*"
|
|
|
|
|
|
lint:
|
|
golangci-lint run
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
|
|
go mod verify
|
|
.PHONY: lint
|
|
|
|
format:
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs gofmt -w -s
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs misspell -w
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/tendermint
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/cosmos/cosmos-sdk
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -name '*.pb.go' | xargs goimports -w -local github.com/kava-labs/kava
|
|
.PHONY: format
|
|
|
|
###############################################################################
|
|
### Localnet ###
|
|
###############################################################################
|
|
|
|
build-docker-local-kava:
|
|
@$(MAKE) -C networks/local
|
|
|
|
# Run a 4-node testnet locally
|
|
localnet-start: build-linux localnet-stop
|
|
@if ! [ -f build/node0/kvd/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/kvd:Z kava/kavanode testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
|
|
docker-compose up -d
|
|
|
|
localnet-stop:
|
|
docker-compose down
|
|
|
|
# Launch a new single validator chain
|
|
start:
|
|
./contrib/devnet/init-new-chain.sh
|
|
kava start
|
|
|
|
###############################################################################
|
|
### Protobuf ###
|
|
###############################################################################
|
|
|
|
protoVer=v0.3
|
|
protoImageName=tendermintdev/sdk-proto-gen:$(protoVer)
|
|
containerProtoGen=$(PROJECT_NAME)-proto-gen-$(protoVer)
|
|
containerProtoGenAny=$(PROJECT_NAME)-proto-gen-any-$(protoVer)
|
|
containerProtoGenSwagger=$(PROJECT_NAME)-proto-gen-swagger-$(protoVer)
|
|
containerProtoFmt=$(PROJECT_NAME)-proto-fmt-$(protoVer)
|
|
|
|
proto-all: proto-gen proto-format proto-lint proto-swagger-gen
|
|
|
|
proto-gen:
|
|
@echo "Generating Protobuf files"
|
|
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
|
|
sh ./scripts/protocgen.sh; fi
|
|
|
|
proto-swagger-gen:
|
|
@echo "Generating Protobuf Swagger"
|
|
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then docker start -a $(containerProtoGenSwagger); else docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
|
|
sh ./scripts/protoc-swagger-gen.sh; fi
|
|
|
|
proto-format:
|
|
@echo "Formatting Protobuf files"
|
|
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
|
|
find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -style=file -i {} \; ; fi
|
|
|
|
proto-lint:
|
|
@$(DOCKER_BUF) lint --error-format=json
|
|
|
|
proto-check-breaking:
|
|
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=master
|
|
|
|
GOOGLE_PROTO_URL = https://raw.githubusercontent.com/googleapis/googleapis/master/google/api
|
|
PROTOBUF_GOOGLE_URL = https://raw.githubusercontent.com/protocolbuffers/protobuf/master/src/google/protobuf
|
|
COSMOS_PROTO_URL = https://raw.githubusercontent.com/cosmos/cosmos-proto/master
|
|
|
|
GOOGLE_PROTO_TYPES = third_party/proto/google/api
|
|
PROTOBUF_GOOGLE_TYPES = third_party/proto/google/protobuf
|
|
COSMOS_PROTO_TYPES = third_party/proto/cosmos_proto
|
|
|
|
GOGO_PATH := $(shell go list -m -f '{{.Dir}}' github.com/gogo/protobuf)
|
|
TENDERMINT_PATH := $(shell go list -m -f '{{.Dir}}' github.com/tendermint/tendermint)
|
|
COSMOS_PROTO_PATH := $(shell go list -m -f '{{.Dir}}' github.com/cosmos/cosmos-proto)
|
|
COSMOS_SDK_PATH := $(shell go list -m -f '{{.Dir}}' github.com/cosmos/cosmos-sdk)
|
|
IBC_GO_PATH := $(shell go list -m -f '{{.Dir}}' github.com/cosmos/ibc-go/v3)
|
|
ETHERMINT_PATH := $(shell go list -m -f '{{.Dir}}' github.com/tharsis/ethermint)
|
|
|
|
proto-update-deps:
|
|
mkdir -p $(GOOGLE_PROTO_TYPES)
|
|
curl -sSL $(GOOGLE_PROTO_URL)/annotations.proto > $(GOOGLE_PROTO_TYPES)/annotations.proto
|
|
curl -sSL $(GOOGLE_PROTO_URL)/http.proto > $(GOOGLE_PROTO_TYPES)/http.proto
|
|
curl -sSL $(GOOGLE_PROTO_URL)/httpbody.proto > $(GOOGLE_PROTO_TYPES)/httpbody.proto
|
|
|
|
mkdir -p $(PROTOBUF_GOOGLE_TYPES)
|
|
curl -sSL $(PROTOBUF_GOOGLE_URL)/any.proto > $(PROTOBUF_GOOGLE_TYPES)/any.proto
|
|
|
|
mkdir -p client/docs
|
|
cp $(COSMOS_SDK_PATH)/client/docs/swagger-ui/swagger.yaml client/docs/cosmos-swagger.yml
|
|
cp $(IBC_GO_PATH)/docs/client/swagger-ui/swagger.yaml client/docs/ibc-go-swagger.yml
|
|
|
|
mkdir -p $(COSMOS_PROTO_TYPES)
|
|
cp $(COSMOS_PROTO_PATH)/cosmos.proto $(COSMOS_PROTO_TYPES)/cosmos.proto
|
|
|
|
rsync -r --chmod 644 --include "*.proto" --include='*/' --exclude='*' $(GOGO_PATH)/gogoproto third_party/proto
|
|
rsync -r --chmod 644 --include "*.proto" --include='*/' --exclude='*' $(TENDERMINT_PATH)/proto third_party
|
|
rsync -r --chmod 644 --include "*.proto" --include='*/' --exclude='*' $(COSMOS_SDK_PATH)/proto third_party
|
|
rsync -r --chmod 644 --include "*.proto" --include='*/' --exclude='*' $(IBC_GO_PATH)/proto third_party
|
|
rsync -r --chmod 644 --include "*.proto" --include='*/' --exclude='*' $(ETHERMINT_PATH)/proto third_party
|
|
cp -f $(IBC_GO_PATH)/third_party/proto/proofs.proto third_party/proto/proofs.proto
|
|
|
|
.PHONY: proto-all proto-gen proto-gen-any proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps
|
|
|
|
########################################
|
|
### Testing
|
|
|
|
# TODO tidy up cli tests to use same -Enable flag as simulations, or the other way round
|
|
# TODO -mod=readonly ?
|
|
# build dependency needed for cli tests
|
|
test-all: build
|
|
# basic app tests
|
|
@go test ./app -v
|
|
# basic simulation (seed "4" happens to not unbond all validators before reaching 100 blocks)
|
|
#@go test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h
|
|
# other sim tests
|
|
#@go test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h
|
|
#@go test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h
|
|
# AppStateDeterminism does not use Seed flag
|
|
#@go test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h
|
|
|
|
# run module tests and short simulations
|
|
test-basic: test
|
|
@go test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m
|
|
# other sim tests
|
|
@go test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m
|
|
@go test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m
|
|
@# AppStateDeterminism does not use Seed flag
|
|
@go test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m
|
|
|
|
test:
|
|
@go test $$(go list ./... | grep -v 'contrib')
|
|
|
|
# Run cli integration tests
|
|
# `-p 4` to use 4 cores, `-tags cli_test` to tell go not to ignore the cli package
|
|
# These tests use the `kvd` or `kvcli` binaries in the build dir, or in `$BUILDDIR` if that env var is set.
|
|
test-cli: build
|
|
@go test ./cli_test -tags cli_test -v -p 4
|
|
|
|
# Kick start lots of sims on an AWS cluster.
|
|
# This submits an AWS Batch job to run a lot of sims, each within a docker image. Results are uploaded to S3
|
|
start-remote-sims:
|
|
# build the image used for running sims in, and tag it
|
|
docker build -f simulations/Dockerfile -t kava/kava-sim:master .
|
|
# push that image to the hub
|
|
docker push kava/kava-sim:master
|
|
# submit an array job on AWS Batch, using 1000 seeds, spot instances
|
|
aws batch submit-job \
|
|
-—job-name "master-$(VERSION)" \
|
|
-—job-queue “simulation-1-queue-spot" \
|
|
-—array-properties size=1000 \
|
|
-—job-definition kava-sim-master \
|
|
-—container-override environment=[{SIM_NAME=master-$(VERSION)}]
|
|
|
|
.PHONY: all build-linux install clean build test test-cli test-all test-rest test-basic start-remote-sims
|