forked from Ethernal-Tech/blade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
183 lines (154 loc) · 7.62 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
.PHONY: download-submodules
download-submodules: check-git
git submodule init
git submodule update
.PHONY: check-git
check-git:
@which git > /dev/null || (echo "git is not installed. Please install and try again."; exit 1)
.PHONY: check-go
check-go:
@which go > /dev/null || (echo "Go is not installed.. Please install and try again."; exit 1)
.PHONY: check-protoc
check-protoc:
@which protoc > /dev/null || (echo "protoc is not installed. Please install and try again."; exit 1)
.PHONY: check-lint
check-lint:
@which golangci-lint > /dev/null || (echo "golangci-lint is not installed. Please install and try again."; exit 1)
.PHONY: check-npm
check-npm:
@which npm > /dev/null || (echo "npm is not installed. Please install and try again."; exit 1)
.PHONY: bindata
bindata: check-go
go-bindata -pkg chain -o ./chain/chain_bindata.go ./chain/chains
.PHONY: protoc
protoc: check-protoc
protoc --go_out=. --go-grpc_out=. -I . -I=./validate --validate_out="lang=go:." \
./server/proto/*.proto \
./network/proto/*.proto \
./txpool/proto/*.proto \
./consensus/polybft/**/*.proto
.PHONY: build
build: check-go check-git
$(eval COMMIT_HASH = $(shell git rev-parse HEAD))
$(eval VERSION = $(shell git describe --tags --abbrev=0 ${COMMIT_HASH}))
$(eval BRANCH = $(shell git rev-parse --abbrev-ref HEAD | tr -d '\040\011\012\015\n'))
$(eval TIME = $(shell date))
go build -o blade -ldflags="\
-X 'github.com/0xPolygon/polygon-edge/versioning.Version=$(VERSION)' \
-X 'github.com/0xPolygon/polygon-edge/versioning.Commit=$(COMMIT_HASH)'\
-X 'github.com/0xPolygon/polygon-edge/versioning.Branch=$(BRANCH)'\
-X 'github.com/0xPolygon/polygon-edge/versioning.BuildTime=$(TIME)'" \
main.go
.PHONY: lint
lint: check-lint
golangci-lint run --timeout 10m --config .golangci.yml --whole-files
.PHONY: generate-bsd-licenses
generate-bsd-licenses: check-git
./generate_dependency_licenses.sh BSD-3-Clause,BSD-2-Clause > ./licenses/bsd_licenses.json
.PHONY: unit-test
unit-test: check-go
go test -race -shuffle=on -coverprofile coverage.out -timeout 20m `go list ./... | grep -v e2e`
.PHONY: benchmark-test
benchmark-test: check-go
go test -bench=. -run=^$ `go list ./... | grep -v /e2e`
.PHONY: fuzz-test
fuzz-test: check-go
./scripts/fuzzAll
.PHONY: test-e2e-legacy
test-e2e-legacy: check-go
go build -race -o artifacts/blade .
env EDGE_BINARY=${PWD}/artifacts/blade go test -v -timeout=30m ./e2e/...
.PHONY: test-e2e-polybft
test-e2e-polybft: check-go
@TESTS=`go test -list . ./e2e-polybft/e2e/... | grep '^Test' | grep -v ApexBridge | paste -sd '|' - | tr -d '\n'`; \
go build -o artifacts/blade .; \
env EDGE_BINARY=${PWD}/artifacts/blade E2E_TESTS=true E2E_LOGS=true \
go test -v -timeout=5h ./e2e-polybft/e2e/... -run "$${TESTS}"
.PHONY: test-e2e-apex-bridge
test-e2e-apex-bridge: check-go
go build -o artifacts/blade .
env EDGE_BINARY=${PWD}/artifacts/blade E2E_TESTS=true E2E_LOGS=true \
go test -v -timeout=7h ./e2e-polybft/e2e/... -run "ApexBridge"
.PHONY: fund-testnet-e2e-apex-bridge
fund-testnet-e2e-apex-bridge: check-go
go build -o artifacts/blade .
env EDGE_BINARY=${PWD}/artifacts/blade E2E_TESTS=true E2E_LOGS=true \
go test -v -timeout=1h ./e2e-polybft/e2e/... -run "Test_E2E_TestnetFund"
.PHONY: defund-testnet-e2e-apex-bridge
defund-testnet-e2e-apex-bridge: check-go
go build -o artifacts/blade .
env EDGE_BINARY=${PWD}/artifacts/blade E2E_TESTS=true E2E_LOGS=true \
go test -v -timeout=1h ./e2e-polybft/e2e/... -run "Test_E2E_TestnetDefund"
.PHONY: testnet-e2e-apex-bridge-print-balances
testnet-e2e-apex-bridge-print-balances: check-go
go build -o artifacts/blade .
env EDGE_BINARY=${PWD}/artifacts/blade E2E_TESTS=true E2E_LOGS=true \
go test -v -timeout=1h ./e2e-polybft/e2e/... -run "Test_E2E_TestnetPrintBalances"
.PHONY: test-testnet-e2e-apex-bridge
test-testnet-e2e-apex-bridge: check-go
go build -o artifacts/blade .
env EDGE_BINARY=${PWD}/artifacts/blade E2E_TESTS=true E2E_LOGS=true \
go test -v -timeout=7h ./e2e-polybft/e2e/... -run "ApexTestnetBridge"
.PHONY: full-test-testnet-e2e-apex-bridge
full-test-testnet-e2e-apex-bridge: check-go
go build -o artifacts/blade .
env EDGE_BINARY=${PWD}/artifacts/blade E2E_TESTS=true E2E_LOGS=true \
go test -v -timeout=1h ./e2e-polybft/e2e/... -run "Test_E2E_TestnetFund" && \
env EDGE_BINARY=${PWD}/artifacts/blade E2E_TESTS=true E2E_LOGS=true \
go test -v -timeout=7h ./e2e-polybft/e2e/... -run "ApexTestnetBridge"; true
env EDGE_BINARY=${PWD}/artifacts/blade E2E_TESTS=true E2E_LOGS=true \
go test -v -timeout=1h ./e2e-polybft/e2e/... -run "Test_E2E_TestnetDefund"
.PHONY: test-property-polybft
test-property-polybft: check-go
go build -o artifacts/blade .
env EDGE_BINARY=${PWD}/artifacts/blade E2E_TESTS=true E2E_LOGS=true go test -v -timeout=30m ./e2e-polybft/property/... \
-rapid.checks=10
.PHONY: compile-blade-contracts
compile-blade-contracts: check-npm
cd blade-contracts && npm install && npm run compile
$(MAKE) generate-smart-contract-bindings
.PHONY: generate-smart-contract-bindings
generate-smart-contract-bindings: check-go
go run ./consensus/polybft/contractsapi/artifacts-gen/main.go
go run ./consensus/polybft/contractsapi/bindings-gen/main.go
.PHONY: run-docker
run-docker:
./scripts/cluster polybft --docker
.PHONY: stop-docker
stop-docker:
./scripts/cluster polybft --docker stop
.PHONY: destroy-docker
destroy-docker:
./scripts/cluster polybft --docker destroy
.PHONY: update-apex-contracts
update-apex-contracts:
git submodule update --remote --init apex-bridge-smartcontracts && \
cd apex-bridge-smartcontracts/ && npm i && npx hardhat compile && cd .. && \
go run consensus/polybft/contractsapi/apex-artifacts-gen/main.go && \
go run consensus/polybft/contractsapi/bindings-gen/main.go
.PHONY: help
help:
@echo "Available targets:"
@printf " %-35s - %s\n" "download-submodules" "Initialize and update Git submodules"
@printf " %-35s - %s\n" "bindata" "Generate Go binary data for chain"
@printf " %-35s - %s\n" "protoc" "Compile Protocol Buffers files"
@printf " %-35s - %s\n" "build" "Build the project"
@printf " %-35s - %s\n" "lint" "Run linters on the codebase"
@printf " %-35s - %s\n" "generate-bsd-licenses" "Generate BSD licenses"
@printf " %-35s - %s\n" "unit-test" "Run unit tests"
@printf " %-35s - %s\n" "fuzz-test" "Run fuzz tests"
@printf " %-35s - %s\n" "test-e2e-legacy" "Run end-to-end Legacy tests"
@printf " %-35s - %s\n" "test-e2e-polybft" "Run end-to-end tests for PolyBFT"
@printf " %-35s - %s\n" "test-property-polybft" "Run property tests for PolyBFT"
@printf " %-35s - %s\n" "compile-blade-contracts" "Compile blade contracts"
@printf " %-35s - %s\n" "generate-smart-contract-bindings" "Generate smart contract bindings"
@printf " %-35s - %s\n" "test-e2e-apex-bridge" "Run end-to-end tests for Apex Bridge"
@printf " %-35s - %s\n" "fund-testnet-e2e-apex-bridge" "Fund wallets for end-to-end tests for Apex Bridge Testnet"
@printf " %-35s - %s\n" "defund-testnet-e2e-apex-bridge" "Defund wallets for end-to-end tests for Apex Bridge Testnet"
@printf " %-35s - %s\n" "testnet-e2e-apex-bridge-print-balances" "Print balances of wallets for end-to-end tests for Apex Bridge Testnet"
@printf " %-35s - %s\n" "test-testnet-e2e-apex-bridge" "Run end-to-end tests for Apex Bridge Testnet"
@printf " %-35s - %s\n" "full-test-testnet-e2e-apex-bridge" "Run fund wallets, end-to-end tests and defund wallets for Apex Bridge Testnet"
@printf " %-35s - %s\n" "update-apex-contracts" "Update Apex Bridge smart contracts and bindings"
@printf " %-35s - %s\n" "run-docker" "Run Docker cluster for PolyBFT"
@printf " %-35s - %s\n" "stop-docker" "Stop Docker cluster for PolyBFT"
@printf " %-35s - %s\n" "destroy-docker" "Destroy Docker cluster for PolyBFT"