-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathMakefile
More file actions
246 lines (204 loc) · 8.06 KB
/
Makefile
File metadata and controls
246 lines (204 loc) · 8.06 KB
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
################## update dependencies ####################
ETHEREUM_SUBMODULE_COMMIT_OR_TAG := morph-v2.2.3
ETHEREUM_TARGET_VERSION := morph-v2.2.3
TENDERMINT_TARGET_VERSION := v0.3.7
ETHEREUM_MODULE_NAME := github.com/morph-l2/go-ethereum
TENDERMINT_MODULE_NAME := github.com/morph-l2/tendermint
.PHONY: update_mod
update_mod:
@echo "Updating go.mod in $(MODULE)..."
@if grep -q '$(ETHEREUM_MODULE_NAME)' $(MODULE)/go.mod; then \
sed -i '' -e "s|$(ETHEREUM_MODULE_NAME) v[0-9][^[:space:]]*|$(ETHEREUM_MODULE_NAME) $(ETHEREUM_TARGET_VERSION)|" $(MODULE)/go.mod; \
fi
@if grep -q '$(TENDERMINT_MODULE_NAME)' $(MODULE)/go.mod; then \
sed -i '' -e "s|$(TENDERMINT_MODULE_NAME) v[0-9][^[:space:]]*|$(TENDERMINT_MODULE_NAME) $(TENDERMINT_TARGET_VERSION)|" $(MODULE)/go.mod; \
fi
@cd $(MODULE) && go mod tidy
@echo "go.mod in $(MODULE) updated and cleaned."
.PHONY: update_all_mod
update_all_mod:
@$(MAKE) update_mod MODULE=bindings
@$(MAKE) update_mod MODULE=contracts
@$(MAKE) update_mod MODULE=node
@$(MAKE) update_mod MODULE=ops/l2-genesis
@$(MAKE) update_mod MODULE=ops/tools
@$(MAKE) update_mod MODULE=oracle
@$(MAKE) update_mod MODULE=tx-submitter
@$(MAKE) update_mod MODULE=token-price-oracle
update:
go work sync
@$(MAKE) update_all_mod
.PHONY: update
submodules:
git submodule update --init
@if [ -d "go-ethereum" ]; then \
echo "Updating go-ethereum submodule to tag $(ETHEREUM_SUBMODULE_COMMIT_OR_TAG)..."; \
cd go-ethereum && \
git fetch --tags && \
git checkout $(ETHEREUM_SUBMODULE_COMMIT_OR_TAG) && \
cd ..; \
fi
.PHONY: submodules
################## bindings ####################
bindings:
make -C bindings all
.PHONY: bindings
################## lint code ####################
lint: lint-sol lint-go
.PHONY: lint
lint-sol:
make -C contracts lint-sol
.PHONY: lint-sol
lint-go:
go work sync
make -C bindings lint
make -C contracts lint-go
make -C node lint
make -C ops/l2-genesis lint
make -C ops/tools lint
## make -C oracle lint
make -C tx-submitter lint
.PHONY: lint-go
################## format code ####################
fmt: fmt-sol fmt-go
.PHONY: fmt
# npm install --global --save-dev prettier-plugin-solidity
fmt-sol:
find ./contracts/ -name '*.sol' -type f -not -path "**/node_modules*" | xargs misspell -w
cd $(PWD)/contracts/ && yarn prettier --write --plugin=prettier-plugin-solidity './contracts/**/*.sol'
.PHONY: fmt-sol
# go get -u github.com/client9/misspell/cmd/misspell
fmt-go:
go work sync
cd $(PWD)/bindings/ && go mod tidy
cd $(PWD)/contracts/ && go mod tidy
cd $(PWD)/node/ && go mod tidy
cd $(PWD)/ops/l2-genesis/ && go mod tidy
cd $(PWD)/ops/tools/ && go mod tidy
cd $(PWD)/oracle/ && go mod tidy
cd $(PWD)/tx-submitter/ && go mod tidy
find . -name '*.go' -type f -not -path "./go-ethereum*" -not -name '*.pb.go' | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./go-ethereum*" -not -name '*.pb.go' | xargs misspell -w
find . -name '*.go' -type f -not -path "./go-ethereum*" -not -name '*.pb.go' | xargs goimports -w -local $(PWD)/
.PHONY: fmt-go
################## docker build ####################
docker-build:
cd ops/docker && docker compose build
.PHONY: docker-build
go-rust-builder:
@if [ -z "$(shell docker images -q morph/go-rust-builder 2> /dev/null)" ]; then \
echo "Docker image morph/go-rust-builder does not exist. Building..."; \
cd ops/docker/intermediate && docker build -t morph/go-rust-builder:go-1.22-rust-nightly-2023-12-03 . -f go-rust-builder.Dockerfile; \
else \
echo "Docker image morph/go-rust-builder already exists."; \
fi
.PHONY: go-rust-builder
go-rust-alpine-builder:
@if [ -z "$(shell docker images -q morph/go-rust-alpine-builder 2> /dev/null)" ]; then \
echo "Docker image morph/go-rust-alpine-builder does not exist. Building..."; \
cd ops/docker/intermediate && docker build -t morph/go-rust-alpine-builder:go-1.22-rust-nightly-2023-12-03 . -f go-rust-alpine-builder.Dockerfile; \
else \
echo "Docker image morph/go-rust-alpine-builder already exists."; \
fi
.PHONY: go-rust-alpine-builder
go-ubuntu-builder:
@if [ -z "$(shell docker images -q morph/go-ubuntu-builder 2> /dev/null)" ]; then \
echo "Docker image morph/go-ubuntu-builder does not exist. Building..."; \
cd ops/docker/intermediate && docker build -t morph/go-ubuntu-builder:go-1.24-ubuntu . -f go-ubuntu-builder.Dockerfile; \
else \
echo "Docker image morph/go-ubuntu-builder already exists."; \
fi
.PHONY: go-ubuntu-builder
################## devnet 4 nodes ####################
EXECUTION_CLIENT ?= geth
MORPH_RETH_BUILD_FROM_SOURCE ?= false
ifeq ($(MORPH_RETH_BUILD_FROM_SOURCE),true)
MORPH_RETH_IMAGE ?= morph-reth:latest
MORPH_RETH_ENTRYPOINT ?= /app/morph-reth
else
MORPH_RETH_IMAGE ?= ghcr.io/morph-l2/morph-reth:latest
MORPH_RETH_ENTRYPOINT ?= /usr/local/bin/morph-reth
endif
MORPH_RETH_DIR ?= ../morph-reth
MORPH_RETH_BUILD_PROFILE ?= release
MORPH_RETH_RUSTFLAGS ?=
MORPH_RETH_DOCKER_TARGET ?= builder
export MORPH_RETH_IMAGE
export MORPH_RETH_DIR
export MORPH_RETH_BUILD_PROFILE
export MORPH_RETH_RUSTFLAGS
export MORPH_RETH_DOCKER_TARGET
export MORPH_RETH_ENTRYPOINT
DEVNET_COMPOSE_FILES := -f docker-compose-4nodes.yml
ifeq ($(EXECUTION_CLIENT),geth)
DEVNET_EXECUTION_DEPS := submodules
else ifeq ($(EXECUTION_CLIENT),reth)
DEVNET_COMPOSE_FILES += -f docker-compose-reth.yml
ifeq ($(MORPH_RETH_BUILD_FROM_SOURCE),true)
DEVNET_EXECUTION_DEPS := reth
else
DEVNET_EXECUTION_DEPS := reth-image
endif
else
$(error unsupported EXECUTION_CLIENT "$(EXECUTION_CLIENT)", expected "geth" or "reth")
endif
devnet-up: $(DEVNET_EXECUTION_DEPS) go-ubuntu-builder
python3 ops/devnet-morph/main.py --polyrepo-dir=. --execution-client=$(EXECUTION_CLIENT)
.PHONY: devnet-up
devnet-up-reth:
$(MAKE) devnet-up EXECUTION_CLIENT=reth
.PHONY: devnet-up-reth
devnet-up-debugccc: $(DEVNET_EXECUTION_DEPS) go-ubuntu-builder
python3 ops/devnet-morph/main.py --polyrepo-dir=. --execution-client=$(EXECUTION_CLIENT) --debugccc
.PHONY: devnet-up-debugccc
devnet-down:
cd ops/docker && docker compose $(DEVNET_COMPOSE_FILES) down
.PHONY: devnet-down
devnet-clean-build: devnet-l1-clean
cd ops/docker && docker compose $(DEVNET_COMPOSE_FILES) down --volumes --remove-orphans
docker volume ls --filter name=docker_ --format='{{.Name}}' | xargs docker volume rm 2>/dev/null || true
rm -rf ops/l2-genesis/.devnet
rm -rf ops/docker/.devnet
rm -rf ops/docker/consensus/beacondata ops/docker/consensus/validatordata ops/docker/consensus/genesis.ssz
rm -rf ops/docker/execution/geth
rm -rf ops/docker/execution/reth
.PHONY: devnet-clean-build
devnet-clean-build-reth:
$(MAKE) devnet-clean-build EXECUTION_CLIENT=reth
.PHONY: devnet-clean-build-reth
devnet-clean: devnet-clean-build
docker image ls '*morph*' --format='{{.Repository}}' | xargs -r docker rmi
docker image ls '*sentry-*' --format='{{.Repository}}' | xargs -r docker rmi
.PHONY: devnet-clean
devnet-l1:
python3 ops/devnet-morph/main.py --polyrepo-dir=. --only-l1
devnet-l1-clean:
@cd ops/docker && ./layer1/scripts/clean.sh
.PHONY: devnet-l1-clean
devnet-logs:
@(cd ops/docker && docker compose $(DEVNET_COMPOSE_FILES) logs -f)
.PHONY: devnet-logs
reth-image:
docker pull "$(MORPH_RETH_IMAGE)"
.PHONY: reth-image
reth:
@test -d "$(MORPH_RETH_DIR)" || (echo "morph-reth directory not found: $(MORPH_RETH_DIR)" && exit 1)
docker build -t "$(MORPH_RETH_IMAGE)" --target "$(MORPH_RETH_DOCKER_TARGET)" --build-arg BUILD_PROFILE="$(MORPH_RETH_BUILD_PROFILE)" --build-arg RUSTFLAGS="$(MORPH_RETH_RUSTFLAGS)" "$(MORPH_RETH_DIR)"
.PHONY: reth
# tx-submitter
SUBMITTERS := $(shell grep -o 'tx-submitter-[0-9]*[^:]' ops/docker/docker-compose-4nodes.yml | sort | uniq)
rebuild-all-tx-submitter:
@for submitter in $(SUBMITTERS); do \
docker compose -f ./ops/docker/docker-compose-4nodes.yml up -d --build $$submitter --no-deps; \
done
stop-all-tx-submitter:
@for submitter in $(SUBMITTERS); do \
docker compose -f ./ops/docker-compose-4nodes.yml stop $$submitter; \
done
start-all-tx-submitter:
@for submitter in $(SUBMITTERS); do \
docker compose -f ./ops/docker-compose-4nodes.yml start $$submitter; \
done
# build geth
geth: submodules
cd go-ethereum && env GO111MODULE=on GOWORK=off go run build/ci.go install ./cmd/geth