-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
354 lines (293 loc) · 12.5 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# detect operating system
ifeq ($(OS),Windows_NT)
CURRENT_OS := Windows
else
CURRENT_OS := $(shell uname -s)
endif
#GOBIN
GOBIN = $(shell pwd)/build/bin
GO ?= latest
# variables
DEBUGAPI=OFF # disable DEBUGAPI by default
PACKAGES = $(shell go list ./... | grep -Ev 'vendor|importer')
COMMIT_HASH := $(shell git rev-parse --short HEAD)
GIT_BRANCH :=$(shell git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //")
BUILD_FLAGS = -tags netgo -ldflags "-X github.com/orientwalt/htdf/version.GitCommit=${COMMIT_HASH} -X main.GitCommit=${COMMIT_HASH} -X main.DEBUGAPI=${DEBUGAPI} -X main.GitBranch=${GIT_BRANCH}"
HTDFSERVICE_DAEMON_BINARY = hsd
HTDFSERVICE_CLI_BINARY = hscli
# tool checking
DEP_CHK := $(shell command -v dep 2> /dev/null)
GOLINT_CHK := $(shell command -v golint 2> /dev/null)
GOMETALINTER_CHK := $(shell command -v gometalinter.v2 2> /dev/null)
UNCONVERT_CHK := $(shell command -v unconvert 2> /dev/null)
INEFFASSIGN_CHK := $(shell command -v ineffassign 2> /dev/null)
MISSPELL_CHK := $(shell command -v misspell 2> /dev/null)
ERRCHECK_CHK := $(shell command -v errcheck 2> /dev/null)
UNPARAM_CHK := $(shell command -v unparam 2> /dev/null)
all: tools deps build
tools:
ifndef DEP_CHK
@echo "Installing dep"
go get -u -v github.com/golang/dep/cmd/dep
else
@echo "Dep is already installed..."
endif
deps:
@echo "--> Generating vendor directory via dep ensure"
@rm -rf .vendor-new
@dep ensure -v -vendor-only
update:
@echo "--> Running dep ensure"
@rm -rf .vendor-new
@dep ensure -v -update
buildquick:
echo BUILD_FLAGS=$(BUILD_FLAGS)
@go build $(BUILD_FLAGS) -o ./build/bin/hsd ./cmd/hsd
@go build $(BUILD_FLAGS) -o ./build/bin/hscli ./cmd/hscli
@go build $(BUILD_FLAGS) -o ./build/bin/hsutils ./cmd/hsutil
@go build $(BUILD_FLAGS) -o ./build/bin/hsinfo ./cmd/hsinfo
build: unittest buildquick
build-batchsend:
@build/env.sh go run build/ci.go install ./cmd/hsbatchsend
install: buildquick
@if [ -d build/bin ]; then cp build/bin/* $(GOPATH)/bin; fi
@$(MAKE) -sC . clean
# build-:
# ifeq ($(CURRENT_OS),Windows)
# @echo building all....
# @go build $(BUILD_FLAGS) -o ./build/bin/hsd.exe ./cmd/hsd
# @go build $(BUILD_FLAGS) -o ./build/bin/hscli.exe ./cmd/hscli
# @go build $(BUILD_FLAGS) -o ./build/bin/hsutils.exe ./cmd/hsutil
# @go build $(BUILD_FLAGS) -o ./build/bin/hscli.exe ./cmd/hsinfo
# else
# @echo building all....
# @go build $(BUILD_FLAGS) -o ./build/bin/hsd ./cmd/hsd
# @go build $(BUILD_FLAGS) -o ./build/bin/hscli ./cmd/hscli
# @go build $(BUILD_FLAGS) -o ./build/bin/hsutils ./cmd/hsutil
# @go build $(BUILD_FLAGS) -o ./build/bin/hsinfo ./cmd/hsinfo
# endif
# install-:
# @echo installing all ....
# @go install ./cmd/hsd
# @go install ./cmd/hscli
# @go install ./cmd/hsutil
# test part
test:
@go test -v --vet=off $(PACKAGES)
@echo $(PACKAGES)
unittest:
@go test -v ./evm/...
@go test -v ./types/...
@go test -v ./store/...
@go test -v ./utils/...
@go test -v ./x/mint/...
@go test -v ./x/bank/...
@go test -v ./x/core/...
@go test -v ./accounts/...
@go test -v ./app/...
@go test -v ./client/...
@go test -v ./init/...
@go test -v ./crypto/...
@go test -v ./server/...
@go test -v ./tools/...
@go test -v ./x/auth/...
@go test -v ./x/crisis/...
@go test -v ./x/distribution/...
@go test -v ./x/gov/...
@go test -v ./x/guardian/...
@go test -v ./x/ibc/...
@go test -v ./x/params/...
@go test -v ./x/slashing/...
@go test -v ./x/staking/...
CHAIN_ID = testchain
GENESIS_ACCOUNT_PASSWORD = 12345678
GENESIS_ACCOUNT_BALANCE = 3000000000000000satoshi
MINIMUM_GAS_PRICES = 100satoshi
new: install clear hsinit accs conf vals
new.pure: clear hsinit accs conf vals
hsinit:
@hsd init yjy --chain-id $(CHAIN_ID)
accs:
@echo create new accounts....;\
$(eval ACC1=$(shell hscli accounts new $(GENESIS_ACCOUNT_PASSWORD)))\
$(eval ACC2=$(shell hscli accounts new $(GENESIS_ACCOUNT_PASSWORD)))\
hsd add-genesis-account $(ACC1) $(GENESIS_ACCOUNT_BALANCE)
@hsd add-genesis-account $(ACC2) $(GENESIS_ACCOUNT_BALANCE)
conf:
@echo setting config....
@hscli config chain-id $(CHAIN_ID)
@hscli config output json
@hscli config indent true
@hscli config trust-node true
vals:
@echo setting validators....
@hsd gentx $(ACC1)
@hsd collect-gentxs
start: start.daemon start.rest
start.daemon:
@echo starting daemon....
@nohup hsd start >> ${HOME}/.hsd/app.log 2>&1 &
start.rest:
@echo starting rest server...
@nohup hscli rest-server --chain-id=${CHAIN_ID} --trust-node=true --laddr=tcp://0.0.0.0:1317 >> ${HOME}/.hsd/restServer.log 2>&1 &
stop:
@pkill hsd
@pkill hscli
# clean part
clean:
@find build -name bin | xargs rm -rf
clear: clean
@rm -rf ~/.hs*
# git part
down:
@git pull
up: clean
@git add .
@read -p "Enter a Comment: " comment;\
git commit -m "$$comment";\
git push origin master
# misc
conv:
@find -iregex '.*\.\(go\)'| xargs sed -i "s/x\/htdfservice/x\/core/g"
DOCKER_VALIDATOR_IMAGE = falcon0125/hsdnode
DOCKER_CLIENT_IMAGE = falcon0125/hsclinode
VALIDATOR_COUNT = 4
TESTNODE_NAME = client
TESTNETDIR = build/testnet
LIVENETDIR = build/livenet
##############################################################################################################################
# Run a 4-validator testnet locally
##############################################################################################################################
# docker-compose part[multi-node part, also test mode]
# Local validator nodes using docker and docker-compose
hsnode: clean build# hstop
$(MAKE) -C networks/local
init-testnet:
@if ! [ -d ${TESTNETDIR} ]; then mkdir -p ${TESTNETDIR}; fi
@if [ -d build/bin ]; then cp build/bin/* ${TESTNETDIR}; fi
echotest:
@echo $(CURDIR)/${TESTNETDIR}
hsinit-v4:
@if ! [ -f ${TESTNETDIR}/node0/.hsd/config/genesis.json ]; then\
docker run --rm -v $(CURDIR)/build/testnet:/root:Z ${DOCKER_VALIDATOR_IMAGE} testnet \
--chain-id ${CHAIN_ID} \
--v ${VALIDATOR_COUNT} \
-o . \
--starting-ip-address 192.168.10.2 \
--minimum-gas-prices ${MINIMUM_GAS_PRICES}; fi
hsinit-test:
@hsd testnet --chain-id ${CHAIN_ID} \
--v ${VALIDATOR_COUNT} \
-o ${TESTNETDIR} \
--starting-ip-address 192.168.10.2 \
--minimum-gas-prices ${MINIMUM_GAS_PRICES}
hsinit-o1:
@mkdir -p ${TESTNETDIR}/node4/.hsd ${TESTNETDIR}/node4/.hscli
@hsd init node4 --home ${TESTNETDIR}/node4/.hsd
@cp ${TESTNETDIR}/node0/.hsd/config/genesis.json ${TESTNETDIR}/node4/.hsd/config
@cp ${TESTNETDIR}/node0/.hsd/config/hsd.toml ${TESTNETDIR}/node4/.hsd/config
@cp ${TESTNETDIR}/node0/.hsd/config/config.toml ${TESTNETDIR}/node4/.hsd/config
@sed -i s/node0/node4/g ${TESTNETDIR}/node4/.hsd/config/config.toml
@cp -rf ${TESTNETDIR}/node0/.hscli/* ${TESTNETDIR}/node4/.hscli
hsinit-o2:
@mkdir -p ${TESTNETDIR}/node5/.hsd ${TESTNETDIR}/node5/.hscli
@hsd init node5 --home ${TESTNETDIR}/node5/.hsd
@cp ${TESTNETDIR}/node0/.hsd/config/genesis.json ${TESTNETDIR}/node5/.hsd/config
@cp ${TESTNETDIR}/node0/.hsd/config/hsd.toml ${TESTNETDIR}/node5/.hsd/config
@cp ${TESTNETDIR}/node0/.hsd/config/config.toml ${TESTNETDIR}/node5/.hsd/config
@sed -i s/node0/node5/g ${TESTNETDIR}/node5/.hsd/config/config.toml
@cp -rf ${TESTNETDIR}/node1/.hscli/* ${TESTNETDIR}/node5/.hscli
hstart: build hsinit-test hsinit-o1 hsinit-o2 init-testnet
@docker-compose up -d
hsattach:
@docker attach hsclinode1
# Stop testnet
hstop:
docker-compose down
hscheck:
@docker logs -f hsdnode0
hsclean:
@docker rmi ${DOCKER_VALIDATOR_IMAGE} ${DOCKER_CLIENT_IMAGE}
##############################################################################################################################
# ethernet part
##############################################################################################################################
clean-t:
@find build -name testnet |xargs rm -rf
addrs:
@if [ -f ipaddrs.conf ]; then rm ipaddrs.conf ;fi
# modify conf files
@read -p "Enter node0 IP addr: " ipaddr;\
echo $${ipaddr} >> ipaddrs.conf
@read -p "Enter node1 IP addr: " ipaddr;\
echo $${ipaddr} >> ipaddrs.conf
@read -p "Enter node2 IP addr: " ipaddr;\
echo $${ipaddr} >> ipaddrs.conf
@read -p "Enter node3 IP addr: " ipaddr;\
echo $${ipaddr} >> ipaddrs.conf
killall:
@sshpass -p miss16980 ssh root@$$(cat networks/remote/ipaddrs.conf | sed -n '1p') pkill -9 hsd
@sshpass -p miss16980 ssh root@$$(cat networks/remote/ipaddrs.conf | sed -n '2p') pkill -9 hsd
@sshpass -p miss16980 ssh root@$$(cat networks/remote/ipaddrs.conf | sed -n '3p') pkill -9 hsd
@sshpass -p miss16980 ssh root@$$(cat networks/remote/ipaddrs.conf | sed -n '4p') pkill -9 hsd
startall:
@sshpass -p miss16980 ssh root@$$(cat networks/remote/ipaddrs.conf | sed -n '1p') nohup hsd start & > /dev/null
@sshpass -p miss16980 ssh root@$$(cat networks/remote/ipaddrs.conf | sed -n '2p') nohup hsd start & > /dev/null
@sshpass -p miss16980 ssh root@$$(cat networks/remote/ipaddrs.conf | sed -n '3p') nohup hsd start & > /dev/null
@sshpass -p miss16980 ssh root@$$(cat networks/remote/ipaddrs.conf | sed -n '4p') nohup hsd start & > /dev/null
cleanall:
@sshpass -p miss16980 ssh root@$$(cat networks/remote/ipaddrs.conf | sed -n '1p') rm -rf /root/.hsd /root/.hscli
@sshpass -p miss16980 ssh root@$$(cat networks/remote/ipaddrs.conf | sed -n '2p') rm -rf /root/.hsd /root/.hscli
@sshpass -p miss16980 ssh root@$$(cat networks/remote/ipaddrs.conf | sed -n '3p') rm -rf /root/.hsd /root/.hscli
@sshpass -p miss16980 ssh root@$$(cat networks/remote/ipaddrs.conf | sed -n '4p') rm -rf /root/.hsd /root/.hscli
copyall:
# upload files
### 1st server
@sshpass -p miss16980 scp -r ${TESTNETDIR}/node0/.hsd root@$$(cat networks/remote/ipaddrs.conf | sed -n '1p'):/root
@sshpass -p miss16980 scp -r ${TESTNETDIR}/node0/.hscli root@$$(cat networks/remote/ipaddrs.conf | sed -n '1p'):/root
@sshpass -p miss16980 scp -r build/bin/hsd root@$$(cat networks/remote/ipaddrs.conf | sed -n '1p'):/usr/local/bin
### 2nd server
@sshpass -p miss16980 scp -r ${TESTNETDIR}/node1/.hsd root@$$(cat networks/remote/ipaddrs.conf | sed -n '2p'):/root
@sshpass -p miss16980 scp -r ${TESTNETDIR}/node1/.hscli root@$$(cat networks/remote/ipaddrs.conf | sed -n '2p'):/root
@sshpass -p miss16980 scp -r build/bin/hsd root@$$(cat networks/remote/ipaddrs.conf | sed -n '2p'):/usr/local/bin
### 3rd server
@sshpass -p miss16980 scp -r ${TESTNETDIR}/node2/.hsd root@$$(cat networks/remote/ipaddrs.conf | sed -n '3p'):/root
@sshpass -p miss16980 scp -r build/testnet/node2/.hscli root@$$(cat networks/remote/ipaddrs.conf | sed -n '3p'):/root
@sshpass -p miss16980 scp -r build/bin/hsd root@$$(cat networks/remote/ipaddrs.conf | sed -n '3p'):/usr/local/bin
### 4th server
@sshpass -p miss16980 scp -r ${TESTNETDIR}/node3/.hsd root@$$(cat networks/remote/ipaddrs.conf | sed -n '4p'):/root
@sshpass -p miss16980 scp -r ${TESTNETDIR}/node3/.hscli root@$$(cat networks/remote/ipaddrs.conf | sed -n '4p'):/root
@sshpass -p miss16980 scp -r build/bin/hsd root@$$(cat networks/remote/ipaddrs.conf | sed -n '4p'):/usr/local/bin
resetall: #clean-4 install-
@if ! [ -d ${TESTNETDIR} ]; then mkdir -p ${TESTNETDIR}; fi
@hsd testnet --chain-id mainchain \
--v 4 \
-o ${TESTNETDIR} \
--validator-ip-addresses $(CURDIR)/networks/remote/ipaddrs.conf \
--minimum-gas-prices ${MINIMUM_GAS_PRICES}
clean-testnet:
@rm -rf $(CURDIR)/build/testnet
testnet: clean-testnet install resetall #copyall startall # killall cleanall
chketh:
@sshpass -p miss16980 ssh [email protected]
##############################################################################################################################
# ethernet distribution part
##############################################################################################################################
clean-livenet:
@rm -rf $(CURDIR)/build/livenet
distall: #clean-4 install-
@if ! [ -d ${LIVENETDIR} ]; then mkdir -p ${LIVENETDIR}; fi
@hsd livenet --chain-id livenet \
--v $$(wc $(CURDIR)/networks/remote/ipaddrs.conf | awk '{print$$1F}') \
-o ${LIVENETDIR} \
--validator-ip-addresses $(CURDIR)/networks/remote/ipaddrs.conf \
--minimum-gas-prices ${MINIMUM_GAS_PRICES}
livenet: clean-livenet install distall
##############################################################################################################################
# load test part
##############################################################################################################################
loadtest:
@locust -f $(CURDIR)/tests/locustfile.py --host=http://127.0.0.1:1317
.PHONY: build install build- install- \
test clean clean-t \
testnet livenet \
stop