Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ test-race: run-tests

test-evmd: ARGS=-timeout=15m
test-evmd:
@cd evmd && go test -count=1 -race -tags=test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(PACKAGES_EVMD)
@cd evmd && go test -count=1 -tags=test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(PACKAGES_EVMD)

test-unit-cover: ARGS=-timeout=15m -coverprofile=coverage.txt -covermode=atomic
test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT)
test-unit-cover: run-tests
@echo "🔍 Running evm (root) coverage..."
@go test -race -tags=test $(COMMON_COVER_ARGS) -coverpkg=$(COVERPKG_ALL) -coverprofile=coverage.txt ./...
@go test -tags=test $(COMMON_COVER_ARGS) -coverpkg=$(COVERPKG_ALL) -coverprofile=coverage.txt ./...
@echo "🔍 Running evmd coverage..."
@cd evmd && go test -race -tags=test $(COMMON_COVER_ARGS) -coverpkg=$(COVERPKG_ALL) -coverprofile=coverage_evmd.txt ./...
@cd evmd && go test -tags=test $(COMMON_COVER_ARGS) -coverpkg=$(COVERPKG_ALL) -coverprofile=coverage_evmd.txt ./...
@echo "🔀 Merging evmd coverage into root coverage..."
@tail -n +2 evmd/coverage_evmd.txt >> coverage.txt && rm evmd/coverage_evmd.txt
@echo "🧹 Filtering ignored files from coverage.txt..."
Expand All @@ -174,15 +174,15 @@ test: test-unit

test-all:
@echo "🔍 Running evm module tests..."
@go test -race -tags=test -mod=readonly -timeout=15m $(PACKAGES_NOSIMULATION)
@go test -tags=test -mod=readonly -timeout=15m $(PACKAGES_NOSIMULATION)
@echo "🔍 Running evmd module tests..."
@cd evmd && go test -race -tags=test -mod=readonly -timeout=15m $(PACKAGES_EVMD)
@cd evmd && go test -tags=test -mod=readonly -timeout=15m $(PACKAGES_EVMD)

run-tests:
ifneq (,$(shell which tparse 2>/dev/null))
go test -count=1 -race -tags=test -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse
go test -count=1 -tags=test -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse
else
go test -count=1 -race -tags=test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
go test -count=1 -tags=test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
endif

# Use the old Apple linker to workaround broken xcode - https://github.com/golang/go/issues/65169
Expand All @@ -191,11 +191,11 @@ ifeq ($(OS_FAMILY),Darwin)
endif

test-fuzz:
go test -race -tags=test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzMintCoins ./x/precisebank/keeper
go test -race -tags=test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzBurnCoins ./x/precisebank/keeper
go test -race -tags=test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzSendCoins ./x/precisebank/keeper
go test -race -tags=test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzGenesisStateValidate_NonZeroRemainder ./x/precisebank/types
go test -race -tags=test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzGenesisStateValidate_ZeroRemainder ./x/precisebank/types
go test -tags=test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzMintCoins ./x/precisebank/keeper
go test -tags=test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzBurnCoins ./x/precisebank/keeper
go test -tags=test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzSendCoins ./x/precisebank/keeper
go test -tags=test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzGenesisStateValidate_NonZeroRemainder ./x/precisebank/types
go test -tags=test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzGenesisStateValidate_ZeroRemainder ./x/precisebank/types

test-scripts:
@echo "Running scripts tests"
Expand All @@ -208,7 +208,7 @@ test-solidity:
.PHONY: run-tests test test-all $(TEST_TARGETS)

benchmark:
@go test -race -tags=test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION)
@go test -tags=test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION)

.PHONY: benchmark

Expand Down
1 change: 1 addition & 0 deletions evmd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts/node-data
15 changes: 15 additions & 0 deletions evmd/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.25-alpine AS builder

RUN apk add --no-cache curl build-base git bash file linux-headers eudev-dev

WORKDIR /src

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN LEDGER_ENABLED=false make build

FROM alpine:3.21
COPY --from=builder /src/build/evmd /bin/evmd
ENTRYPOINT ["evmd"]
159 changes: 159 additions & 0 deletions evmd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
APPNAME := evm
BUILDDIR ?= $(CURDIR)/build
DOCKER := $(shell which docker)

# don't override user values
ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif

help: ## List Commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: help

check-all: ## Convenience to make sure everything is all good
# @$(MAKE) proto-all # Uncomment if we add custom modules
@$(MAKE) build
@$(MAKE) test-unit
@$(MAKE) lint
@$(MAKE) e2e-contracts
@$(MAKE) test-e2e

.PHONY: all

################################################################################
## Build ##
################################################################################

# forces Go to use its pure Go implementation of the DNS resolver
build_tags = netgo
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

whitespace :=
empty = $(whitespace) $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(empty),$(comma),$(build_tags))

# process linker flags

# TODO: Figure out if '-s -w' is still needed
# flags '-s -w' resolves an issue with xcode 16 and signing of go binaries
# ref: https://github.com/golang/go/issues/63997
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(APPNAME) \
-X github.com/cosmos/cosmos-sdk/version.AppName=$(APPNAME) \
-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)" \
-s -w

ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags_comma_sep)" -ldflags '$(ldflags)' -trimpath

clean: ## Clean build artifacts
rm -rf $(BUILDDIR)/ artifacts/

build: go.sum ## Build chain binary
@echo "Building chain binary"
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/evmd ./cmd/evmd



.PHONY: build clean

################################################################################
## Test ##
################################################################################

test-unit: ## Run unit tests
@echo Running unit tests...
@go test -mod=readonly -v -timeout 30m ./...

test-race: ## Run unit tests with race condition reporting
@echo Running unit tests with race condition reporting...
@go test -mod=readonly -v -race -timeout 30m ./...

test-e2e: ## Run e2e tests
@echo Running e2e tests...
@cd e2e && go test -parallel 8 -mod=readonly -v -count=1 -timeout 30m .

.PHONY: test-unit test-race

################################################################################
## Install ##
################################################################################

install: ## Install dependencies
@echo "--> ensure dependencies have not been modified"
@go mod verify
@echo "--> installing $(APPNAME)d"
@go install $(BUILD_FLAGS) -mod=readonly ./cmd/$(APPNAME)d

.PHONY: install

################################################################################
## Protobuf ##
################################################################################

protoVer=0.17.1
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

proto-all: proto-format proto-lint proto-gen ## Generate Protobuf files

proto-gen: ## Generate Protobuf files
@echo "Generating Protobuf files"
@$(protoImage) sh ./scripts/protocgen.sh
@go mod tidy

proto-format: ## Format Protobuf files
@echo "Formatting Protobuf files"
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;

proto-lint: ## Lint Protobuf files
@$(protoImage) buf lint --error-format=json

.PHONY: proto-all proto-gen proto-format proto-lint

################################################################################
## Linting ##
################################################################################

golangci_lint_cmd=golangci-lint

lint: ## Run linter
@echo "--> Running linter"
@$(golangci_lint_cmd) run ./... --timeout 15m -c .golangci.yml
@cd e2e && $(golangci_lint_cmd) run ./... --timeout 15m -c ../.golangci.yml

lint-fix: ## Run linter and fix issues
@echo "--> Running linter and fixing issues"
@$(golangci_lint_cmd) run ./... --fix --timeout 15m -c .golangci.yml
@cd e2e && $(golangci_lint_cmd) run ./... --fix --timeout 15m -c ../.golangci.yml

.PHONY: lint lint-fix

################################################################################
## E2E Contract Artifacts ##
################################################################################

SOLC_IMAGE ?= ethereum/solc:0.8.28
E2E_CONTRACTS_DIR ?= e2e/contracts

e2e-contracts: ## Regenerate e2e embedded contract artifacts (ABI/BIN)
@echo "--> Regenerating e2e contract artifacts with $(SOLC_IMAGE)"
@docker run --rm -v $(CURDIR)/$(E2E_CONTRACTS_DIR):/contracts $(SOLC_IMAGE) --abi --bin -o /contracts --overwrite /contracts/Counter.sol /contracts/Reverter.sol

.PHONY: e2e-contracts
Loading