-
Notifications
You must be signed in to change notification settings - Fork 289
/
Makefile
229 lines (186 loc) · 9.97 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
TOP:=$(realpath ..)
export CGO_CFLAGS:=-I$(TOP)/bls/include -I$(TOP)/mcl/include -I/opt/homebrew/opt/openssl@1.1/include
export CGO_LDFLAGS:=-L$(TOP)/bls/lib -L/opt/homebrew/opt/openssl@1.1/lib
export LD_LIBRARY_PATH:=$(TOP)/bls/lib:$(TOP)/mcl/lib:/opt/homebrew/opt/openssl@1.1/lib:/opt/homebrew/opt/gmp/lib/:/opt/homebrew/opt/openssl@1.1/lib
export LIBRARY_PATH:=$(LD_LIBRARY_PATH)
export DYLD_FALLBACK_LIBRARY_PATH:=$(LD_LIBRARY_PATH)
export GO111MODULE:=on
PKGNAME=harmony
VERSION?=$(shell git tag -l --sort=-v:refname | head -n 1 | tr -d v)
RELEASE?=$(shell git describe --long | cut -f2 -d-)
RPMBUILD=$(HOME)/rpmbuild
DEBBUILD=$(HOME)/debbuild
SHELL := bash
.PHONY: all help libs exe race trace-pointer debug debug-ext debug-kill test test-go test-api test-api-attach linux_static deb_init deb_build deb debpub_dev debpub_prod rpm_init rpm_build rpm rpmpub_dev rpmpub_prod clean distclean docker
all: libs
bash ./scripts/go_executable_build.sh -S
help:
@echo "all - build the harmony binary & bootnode along with the MCL & BLS libs (if necessary)"
@echo "libs - build only the MCL & BLS libs (if necessary) "
@echo "exe - build the harmony binary & bootnode"
@echo "race - build the harmony binary & bootnode with race condition checks"
@echo "trace-pointer - build the harmony binary & bootnode with pointer analysis"
@echo "debug - start a localnet with 2 shards (s0 rpc endpoint = localhost:9700; s1 rpc endpoint = localhost:9800)"
@echo "debug-kill - force kill the localnet"
@echo "debug-ext - start a localnet with 2 shards and external (s0 rpc endpoint = localhost:9598; s1 rpc endpoint = localhost:9596)"
@echo "clean - remove node files & logs created by localnet"
@echo "distclean - remove node files & logs created by localnet, and all libs"
@echo "test - run the entire test suite (go test & Node API test)"
@echo "test-go - run the go test (with go lint, fmt, imports, mod, and generate checks)"
@echo "test-rpc - run the rpc tests"
@echo "test-rpc-attach - attach onto the rpc testing docker container for inspection"
@echo "test-rosetta - run the rosetta tests"
@echo "test-rosetta-attach - attach onto the rosetta testing docker container for inspection"
@echo "linux_static - static build the harmony binary & bootnode along with the MCL & BLS libs (for linux)"
@echo "linux_static_quick - static build the harmony binary & bootnode more quickly without recompiling dependencies (for linux)"
@echo "rpm_init - prepare the RPM build environment by creating directories, copying files, and generating the spec file and source tarball"
@echo "rpm_build - build an RPM package for x86_64 architecture using the spec file (<RPMBUILD>/SPECS/harmony.spec)"
@echo "rpm - build a harmony RPM pacakge"
@echo "rpmpub_dev - publish harmony RPM package to development repo"
@echo "rpmpub_prod - publish harmony RPM package to production repo"
@echo "deb_init - initialize a Debian package for Harmony, setting up necessary files and configurations in the package structure."
@echo "deb_build - build a Debian package from the <HOME>/debbuild directory"
@echo "deb - build a harmony Debian pacakge"
@echo "debpub_dev - publish harmony Debian package to development repo"
@echo "debpub_prod - publish harmony Debian package to production repo"
@echo "go-vet - run Go vet to examine Go source code in the current project for potential issues"
@echo "go-test - run all Go tests with vet checks and the race detector enabled"
@echo "docker - build a Docker image for Harmony using the project root directory's Dockerfile, pulling the latest base image"
@echo "travis_go_checker - run the Travis Go checker script to validate Go code in the project"
@echo "travis_rpc_checker - run the Travis RPC checker script, defaulting the test branch to 'master' unless overridden by TEST_REPO_BRANCH"
@echo "travis_rosetta_checker - run the Travis Rosetta checker script, defaulting the test branch to 'master' unless overridden by TEST_REPO_BRANCH"
@echo "debug_external - cleans up environment, rebuilds the binary, and deploys with external nodes"
@echo "build_localnet_validator - imports validator keys, funds validator accounts, waits for the epoch, and creates external validators on a local network"
@echo "debug-start-log - start a docker compose Promtail->Loki->Grafana stack against localnet logs, needs docker compose and started localnet"
@echo "debug-stop-log - stops a docker compose Promtail->Loki->Grafana stack"
@echo "debug-restart-log - restart a docker compose Promtail->Loki->Grafana stack"
libs:
make -C $(TOP)/mcl -j8
make -C $(TOP)/bls BLS_SWAP_G=1 -j8
exe:
bash ./scripts/go_executable_build.sh -S
race:
bash ./scripts/go_executable_build.sh -r
trace-pointer:
bash ./scripts/go_executable_build.sh -t
debug:
rm -rf .dht-127.0.0.1*
# uncomment the following lines to enable debug logging for libp2p, it produces a lot of logs, so disabled by default
#export GOLOG_LOG_LEVEL=debug
#export GOLOG_OUTPUT=stdout
# add VERBOSE=true before bash or run `export VERBOSE=true` on the shell level for have max logging
# add LEGACY_SYNC=true before bash or run `export LEGACY_SYNC=true` on the shell level to switch to the legacy sync
bash ./test/debug.sh
debug-kill:
bash ./test/kill_node.sh
debug-ext:
# update localnet block per epoch to ensure a stable localnet
sed -i 's/localnetBlocksPerEpoch\s*=\s*[0-9]*/localnetBlocksPerEpoch = 64/' internal/configs/sharding/localnet.go
sed -i 's/localnetBlocksPerEpochV2\s*=\s*[0-9]*/localnetBlocksPerEpochV2 = 64/' internal/configs/sharding/localnet.go
# add VERBOSE=true before bash or run `export VERBOSE=true` on the shell level for have max logging
# add LEGACY_SYNC=true before bash or run `export LEGACY_SYNC=true` on the shell level to switch to the legacy sync
bash ./test/debug-external.sh &
echo sleep 10s before creating the external validator
sleep 10
bash ./test/build-localnet-validator.sh
clean:
rm -rf ./tmp_log*
rm -rf ./.dht*
rm -rf ./db-*
rm -rf ./latest
rm -f ./*.rlp
rm -rf ~/rpmbuild
rm -f coverage.txt
distclean: clean
make -C $(TOP)/mcl clean
make -C $(TOP)/bls clean
go-get:
source ./scripts/setup_bls_build_flags.sh
go get -v ./...
test:
bash ./test/all.sh
test-go:
bash ./test/go.sh
test-rpc:
bash ./test/rpc.sh run
test-rpc-attach:
bash ./test/rpc.sh attach
test-rosetta:
bash ./test/rosetta.sh run
test-rosetta-attach:
bash ./test/rosetta.sh attach
linux_static:
make -C $(TOP)/mcl -j8
make -C $(TOP)/bls minimised_static BLS_SWAP_G=1 -j8
bash ./scripts/go_executable_build.sh -s
linux_static_quick:
bash ./scripts/go_executable_build.sh -s
deb_init:
rm -rf $(DEBBUILD)
mkdir -p $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/{etc/systemd/system,usr/sbin,etc/sysctl.d,etc/harmony}
cp -f bin/harmony $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/usr/sbin/
bin/harmony dumpconfig $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/etc/harmony/harmony.conf
cp -f scripts/package/rclone.conf $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/etc/harmony/
cp -f scripts/package/harmony.service $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/etc/systemd/system/
cp -f scripts/package/harmony-setup.sh $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/usr/sbin/
cp -f scripts/package/harmony-rclone.sh $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/usr/sbin/
cp -f scripts/package/harmony-sysctl.conf $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/etc/sysctl.d/99-harmony.conf
cp -r scripts/package/deb/DEBIAN $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)
VER=$(VERSION)-$(RELEASE) scripts/package/templater.sh scripts/package/deb/DEBIAN/control > $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/DEBIAN/control
deb_build:
(cd $(DEBBUILD); dpkg-deb --build $(PKGNAME)-$(VERSION)-$(RELEASE)/)
deb: deb_init deb_build
debpub_dev: deb
cp scripts/package/deb/dev.aptly.conf ~/.aptly.conf
./scripts/package/publish-repo.sh -p dev -n deb -s $(DEBBUILD)
debpub_prod: deb
cp scripts/package/deb/prod.aptly.conf ~/.aptly.conf
./scripts/package/publish-repo.sh -p prod -n deb -s $(DEBBUILD)
rpm_init:
rm -rf $(RPMBUILD)
mkdir -p $(RPMBUILD)/{SOURCES,SPECS,BUILD,RPMS,BUILDROOT,SRPMS}
mkdir -p $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION)
cp -f bin/harmony $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION)
bin/harmony dumpconfig $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION)/harmony.conf
cp -f scripts/package/harmony.service $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION)
cp -f scripts/package/harmony-setup.sh $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION)
cp -f scripts/package/harmony-rclone.sh $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION)
cp -f scripts/package/rclone.conf $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION)
cp -f scripts/package/harmony-sysctl.conf $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION)
VER=$(VERSION) REL=$(RELEASE) scripts/package/templater.sh scripts/package/rpm/harmony.spec > $(RPMBUILD)/SPECS/harmony.spec
(cd $(RPMBUILD)/SOURCES; tar cvf $(PKGNAME)-$(VERSION).tar $(PKGNAME)-$(VERSION))
rpm_build:
rpmbuild --target x86_64 -bb $(RPMBUILD)/SPECS/harmony.spec
rpm: rpm_init rpm_build
rpm --addsign $(RPMBUILD)/RPMS/x86_64/$(PKGNAME)-$(VERSION)-$(RELEASE).x86_64.rpm
rpmpub_dev: rpm
./scripts/package/publish-repo.sh -p dev -n rpm -s $(RPMBUILD)
rpmpub_prod: rpm
./scripts/package/publish-repo.sh -p prod -n rpm -s $(RPMBUILD)
go-vet:
go vet ./...
go-test:
go test -vet=all -race ./...
docker:
docker build --pull -t harmonyone/$(PKGNAME):latest -f scripts/docker/Dockerfile .
travis_go_checker:
bash ./scripts/travis_go_checker.sh
travis_rpc_checker:
# value from command line will override this value, use point test to non-default
TEST_REPO_BRANCH='master'
bash ./scripts/travis_rpc_checker.sh
travis_rosetta_checker:
# value from command line will override this value, use point test to non-default
TEST_REPO_BRANCH='master'
bash ./scripts/travis_rosetta_checker.sh
debug_external: clean
bash test/debug-external.sh
build_localnet_validator:
bash test/build-localnet-validator.sh
protofiles:
bash ./scripts/gogenerate.sh
debug-start-log:
bash ./test/logs_aggregator/start_log_aggregator.sh
debug-stop-log:
bash ./test/logs_aggregator/stop_log_aggregator.sh
debug-restart-log: debug-stop-log debug-start-log