-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
218 lines (177 loc) Β· 8.61 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
COMMIT := $(shell git log -1 --format='%H')
GO_VERSION := $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1,2)
# VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
VERSION := v1.5.0
BUILD_TIME := 202407040800.00 # format [[CC]YY]MMDDhhmm[.ss]
TEAM_ALLOCATION := 165000000000000
ifeq ($(ENV),kaon)
$(info π Using Kaon environment...)
DENOM := tkyve
TEAM_TGE := 2023-02-07T14:00:00
TEAM_FOUNDATION_ADDRESS := kyve1vut528et85755xsncjwl6dx8xakuv26hxgyv0n
TEAM_BCP_ADDRESS := kyve1vut528et85755xsncjwl6dx8xakuv26hxgyv0n
else ifeq ($(ENV),mainnet)
$(info π Using mainnet environment...)
DENOM := ukyve
TEAM_TGE := 2023-03-14T14:03:14
TEAM_FOUNDATION_ADDRESS := kyve1xjpl57p7f49y5gueu7rlfytaw9ramcn5zhjy2g
TEAM_BCP_ADDRESS := kyve1fnh4kghr25tppskap50zk5j385pt65tyyjaraa
endif
ldflags := $(LDFLAGS)
ldflags += -X github.com/cosmos/cosmos-sdk/version.Name=kyve \
-X github.com/cosmos/cosmos-sdk/version.AppName=kyved \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/KYVENetwork/chain/x/global/types.Denom=$(DENOM) \
-X github.com/KYVENetwork/chain/x/team/types.TEAM_FOUNDATION_STRING=$(TEAM_FOUNDATION_ADDRESS) \
-X github.com/KYVENetwork/chain/x/team/types.TEAM_BCP_STRING=$(TEAM_BCP_ADDRESS) \
-X github.com/KYVENetwork/chain/x/team/types.TEAM_ALLOCATION_STRING=$(TEAM_ALLOCATION) \
-X github.com/KYVENetwork/chain/x/team/types.TGE_STRING=$(TEAM_TGE)
ldflags := $(strip $(ldflags))
BUILD_FLAGS := -ldflags '$(ldflags)' -tags 'ledger' -trimpath -buildvcs=false
.PHONY: proto-setup proto-format proto-lint proto-gen \
format lint vet test build release dev interchaintest
all: ensure_environment ensure_version proto-all format lint test interchaintest build
###############################################################################
### Build ###
###############################################################################
build: ensure_environment ensure_version
@echo "π€ Building kyved..."
@go build $(BUILD_FLAGS) -o "$(PWD)/build/" ./cmd/kyved
@echo "β
Completed build!"
install: ensure_environment ensure_version
@echo "π€ Installing kyved..."
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/kyved
@echo "β
Completed installation!"
release: ensure_environment ensure_version
@echo "π€ Creating kyved releases (using timestamp $(BUILD_TIME))..."
@rm -rf release
@mkdir -p release
@for b in darwin:amd64 darwin:arm64 linux:amd64 linux:arm64; do \
os=$$(echo $$b | cut -d':' -f1); \
arch=$$(echo $$b | cut -d':' -f2); \
echo "β‘οΈ "$$os" "$$arch""; \
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build $(BUILD_FLAGS) -o release/kyved_$(ENV)_"$$os"_"$$arch" ./cmd/kyved; \
touch -a -m -t $(BUILD_TIME) release/kyved_$(ENV)_"$$os"_"$$arch"; \
sha256sum release/kyved_$(ENV)_"$$os"_"$$arch" >> release/release_$(ENV)_checksum; \
mv release/kyved_$(ENV)_"$$os"_"$$arch" release/kyved; \
tar -C release -cf release/kyved_$(ENV)_"$$os"_"$$arch".tar kyved; \
mv release/kyved release/kyved_$(ENV)_"$$os"_"$$arch"; \
touch -a -m -t $(BUILD_TIME) release/kyved_$(ENV)_"$$os"_"$$arch".tar; \
gzip release/kyved_$(ENV)_"$$os"_"$$arch".tar; \
sha256sum release/kyved_$(ENV)_"$$os"_"$$arch".tar.gz >> release/release_$(ENV)_checksum; \
done
@echo "β
Completed release creation!"
###############################################################################
### Docker Build ###
###############################################################################
# Build a release image
docker-image:
@DOCKER_BUILDKIT=1 docker build -t kyve-network/kyve:${VERSION} .
@echo "β
Completed docker image build!"
# Build a release nonroot image
docker-image-nonroot:
@DOCKER_BUILDKIT=1 docker build \
--build-arg IMG_TAG="nonroot" \
-t kyve-network/kyve:${VERSION}-nonroot .
@echo "β
Completed docker image build! (nonroot)"
# Build a release debug image
docker-image-debug:
@DOCKER_BUILDKIT=1 docker build \
--build-arg IMG_TAG="debug" \
-t kyve-network/kyve:${VERSION}-debug .
@echo "β
Completed docker image build! (debug)"
# Build a release debug-nonroot image
docker-image-debug-nonroot:
@DOCKER_BUILDKIT=1 docker build \
--build-arg IMG_TAG="debug-nonroot" \
-t kyve-network/kyve:${VERSION}-debug-nonroot .
@echo "β
Completed docker image build! (debug-nonroot)"
###############################################################################
### Checks ###
###############################################################################
ensure_environment:
ifndef ENV
$(error β Please specify a build environment..)
endif
ensure_version:
ifneq ($(GO_VERSION),1.22)
$(error β Please run Go v1.22.x..)
endif
###############################################################################
### Development ###
###############################################################################
dev:
@ignite chain serve --reset-once --skip-proto --verbose
dev-continue:
@ignite chain serve --skip-proto --verbose
###############################################################################
### Formatting & Linting ###
###############################################################################
gofumpt_cmd=mvdan.cc/gofumpt
golangci_lint_cmd=github.com/golangci/golangci-lint/cmd/golangci-lint
format:
@echo "π€ Running formatter..."
@go run $(gofumpt_cmd) -l -w .
@echo "β
Completed formatting!"
lint:
@echo "π€ Running linter..."
@go run $(golangci_lint_cmd) run --skip-dirs scripts --timeout=10m
@echo "β
Completed linting!"
###############################################################################
### Protobuf ###
###############################################################################
BUF_VERSION=1.20.0
proto-all: proto-format proto-lint proto-gen
proto-format:
@echo "π€ Running protobuf formatter..."
@docker run --rm --volume "$(PWD)":/workspace --workdir /workspace \
bufbuild/buf:$(BUF_VERSION) format --diff --write
@echo "β
Completed protobuf formatting!"
proto-gen:
@echo "π€ Generating code from protobuf..."
@docker run --rm \
--volume "$(PWD)":/workspace `# Mount this repo as workspace` \
--volume "$$(go list -m -f '{{.Dir}}' github.com/cosmos/cosmos-sdk)":/cosmos-sdk:ro `# Mount cosmos-sdk from installed go modules` \
--volume "$$(go list -m -f '{{.Dir}}' github.com/cosmos/ibc-go/v8)":/ibc:ro `# Mount ibc-go from installed go modules` \
--workdir /workspace \
kyve-proto sh ./proto/generate.sh
@echo "β
Completed code generation!"
proto-lint:
@echo "π€ Running protobuf linter..."
@docker run --rm --volume "$(PWD)":/workspace --workdir /workspace \
bufbuild/buf:$(BUF_VERSION) lint
@echo "β
Completed protobuf linting!"
proto-setup:
@echo "π€ Setting up protobuf environment..."
@docker build --rm --tag kyve-proto:latest --file proto/Dockerfile \
--build-arg USER_ID=$$(id -u) --build-arg USER_GID=$$(id -g) .
@echo "β
Setup protobuf environment!"
###############################################################################
### Tests & Simulation ###
###############################################################################
ensure_heighliner:
@which heighliner > /dev/null || (echo "β Heighliner not found. Please install it by running 'make heighliner-setup'." && exit 1)
@docker inspect kaon:local > /dev/null || (echo "β Kaon image not found. Please build it by running 'make heighliner'." && exit 1)
@docker inspect kyve:local > /dev/null || (echo "β Kyve image not found. Please build it by running 'make heighliner'." && exit 1)
heighliner:
@echo "π€ Building Kaon image..."
@heighliner build --chain kaon --local 1> /dev/null
@echo "β
Completed build!"
@echo "π€ Building Kyve image..."
@heighliner build --chain kyve --local 1> /dev/null
@echo "β
Completed build!"
heighliner-setup:
@echo "π€ Installing Heighliner..."
@git clone https://github.com/strangelove-ventures/heighliner.git /tmp/heighliner
@cd /tmp/heighliner && go install && cd ..
@rm -rf heighliner
@echo "β
Completed installation!"
test:
@echo "π€ Running tests..."
@go test -cover -mod=readonly ./x/...
@echo "β
Completed tests!"
interchaintest: ensure_heighliner
@echo "π€ Running interchain tests..."
@go test -mod=readonly ./interchaintest/...
@echo "β
Completed interchain tests!"