forked from 0xPolygonHermez/zkevm-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
191 lines (152 loc) · 6.78 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
DOCKERCOMPOSE := docker-compose -f docker-compose.yml
DOCKERCOMPOSEAPP := hez-core
DOCKERCOMPOSEDB := hez-postgres
DOCKERCOMPOSENETWORK := hez-network
DOCKERCOMPOSEPROVER := hez-prover
DOCKERCOMPOSEEXPLORER := hez-explorer
DOCKERCOMPOSEEXPLORERDB := hez-explorer-postgres
RUNDB := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEDB)
RUNCORE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEAPP)
RUNNETWORK := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSENETWORK)
RUNPROVER := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPROVER)
RUNEXPLORER := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEEXPLORER)
RUNEXPLORERDB := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEEXPLORERDB)
RUN := $(DOCKERCOMPOSE) up -d
STOPDB := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEDB) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEDB)
STOPCORE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEAPP) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEAPP)
STOPNETWORK := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSENETWORK) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSENETWORK)
STOPPROVER := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPROVER) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPROVER)
STOPEXPLORER := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEEXPLORER) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEEXPLORER)
STOPEXPLORERDB := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEEXPLORERDB) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEEXPLORERDB)
STOP := $(DOCKERCOMPOSE) down --remove-orphans
VERSION := $(shell git describe --tags --always)
COMMIT := $(shell git rev-parse --short HEAD)
DATE := $(shell date +%Y-%m-%dT%H:%M:%S%z)
LDFLAGS := -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
GOBASE := $(shell pwd)
GOBIN := $(GOBASE)/dist
GOENVVARS := GOBIN=$(GOBIN)
GOBINARY := hezcore
GOCMD := $(GOBASE)/cmd
LINT := $$(go env GOPATH)/bin/golangci-lint run --timeout=5m -E whitespace -E gosec -E gci -E misspell -E gomnd -E gofmt -E goimports -E revive
BUILD := $(GOENVVARS) go build $(LDFLAGS) -o $(GOBIN)/$(GOBINARY) $(GOCMD)
.PHONY: build
build: ## Builds the binary locally into ./dist
$(BUILD)
.PHONY: build-docker
build-docker: ## Builds a docker image with the core binary
docker build -t hezcore -f ./Dockerfile .
.PHONY: test
test: compile-scs ## Runs only short tests without checking race conditions
$(STOPDB)
$(RUNDB); sleep 5
trap '$(STOPDB)' EXIT; go test -short -p 1 ./...
.PHONY: test-full
test-full: build-docker compile-scs ## Runs all tests checking race conditions
$(STOPDB)
$(RUNDB); sleep 7
trap '$(STOPDB)' EXIT; MallocNanoZone=0 go test -race -p 1 -timeout 600s ./...
.PHONY: install-linter
install-linter: ## Installs the linter
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.45.2
.PHONY: lint
lint: ## Runs the linter
$(LINT)
.PHONY: validate
validate: lint build test-full ## Validates the whole integrity of the code base
.PHONY: run-db
run-db: ## Runs the node database
$(RUNDB)
.PHONY: stop-db
stop-db: ## Stops the node database
$(STOPDB)
.PHONY: run-core
run-core: ## Runs the core
$(RUNCORE)
.PHONY: stop-core
stop-core: ## Stops the core
$(STOPCORE)
.PHONY: run-network
run-network: ## Runs the l1 network
$(RUNNETWORK)
.PHONY: stop-network
stop-network: ## Stops the l1 network
$(STOPNETWORK)
.PHONY: run-prover
run-prover: ## Runs the zk prover
$(RUNPROVER)
.PHONY: stop-prover
stop-prover: ## Stops the zk prover
$(STOPPROVER)
.PHONY: run-explorer
run-explorer: ## Runs the explorer
$(RUNEXPLORER)
.PHONY: stop-explorer
stop-explorer: ## Stops the explorer
$(STOPEXPLORER)
.PHONY: run-explorer-db
run-explorer-db: ## Runs the explorer database
$(RUNEXPLORERDB)
.PHONY: stop-explorer-db
stop-explorer-db: ## Stops the explorer database
$(STOPEXPLORERDB)
.PHONY: run
run: compile-scs ## Runs all the services
$(RUNDB)
$(RUNEXPLORERDB)
$(RUNNETWORK)
sleep 5
$(RUNPROVER)
sleep 2
$(RUNCORE)
sleep 3
$(RUNEXPLORER)
.PHONY: init-network
init-network: ## Initializes the network
go run ./scripts/init_network/main.go .
.PHONY: deploy-sc
deploy-sc: ## deploys some examples of transactions and smart contracts
go run ./scripts/deploy_sc/main.go .
.PHONY: deploy-uniswap
deploy-uniswap: ## deploy the uniswap environment to the network
go run ./scripts/uniswap/main.go .
.PHONY: stop
stop: ## Stops all services
$(STOP)
.PHONY: restart
restart: stop run ## Executes `make stop` and `make run` commands
.PHONY: run-db-scripts
run-db-scripts: ## Executes scripts on the db after it has been initialized, potentially using info from the environment
./scripts/postgres/run.sh
.PHONY: install-git-hooks
install-git-hooks: ## Moves hook files to the .git/hooks directory
cp .github/hooks/* .git/hooks
.PHONY: generate-mocks
generate-mocks: ## Generates mocks for the tests, using mockery tool
mockery --name=etherman --dir=sequencer/strategy/txprofitabilitychecker --output=sequencer/strategy/txprofitabilitychecker --outpkg=txprofitabilitychecker_test --filename=etherman-mock_test.go
mockery --name=batchProcessor --dir=sequencer/strategy/txselector --output=sequencer/strategy/txselector --outpkg=txselector_test --filename=batchprocessor-mock_test.go
mockery --name=etherman --dir=sequencer --output=sequencer --outpkg=sequencer --structname=ethermanMock --filename=etherman-mock_test.go
mockery --name=Store --dir=state/tree --output=state/tree --outpkg=tree --structname=storeMock --filename=store-mock_test.go
.PHONY: generate-code-from-proto
generate-code-from-proto: ## Generates code from proto files
cd proto/src/proto/mt/v1 && protoc --proto_path=. --go_out=../../../../../state/tree/pb --go-grpc_out=../../../../../state/tree/pb --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative mt.proto
cd proto/src/proto/zkprover/v1 && protoc --proto_path=. --go_out=../../../../../proverclient/pb --go-grpc_out=../../../../../proverclient/pb --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative zk-prover.proto
cd proto/src/proto/zkprover/v1 && protoc --proto_path=. --go_out=../../../../../proverservice/pb --go-grpc_out=../../../../../proverservice/pb --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative zk-prover.proto
.PHONY: update-external-dependencies
update-external-dependencies: ## Updates external dependencies like images, test vectors or proto files
go run ./scripts/cmd/... updatedeps
.PHONY: run-benchmarks
run-benchmarks: run-db ## Runs benchmars
go test -bench=. ./state/tree
.PHONY: compile-scs
compile-scs: ## Compiles smart contracts, configuration in test/contracts/index.yaml
go run ./scripts/cmd... compilesc --input ./test/contracts
## Help display.
## Pulls comments from beside commands and prints a nicely formatted
## display with the commands and their usage information.
.DEFAULT_GOAL := help
.PHONY: help
help: ## Prints this help
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'