-
Notifications
You must be signed in to change notification settings - Fork 23
/
Makefile
179 lines (144 loc) · 5.8 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
################## update dependencies ####################
ETHEREUM_TARGET_VERSION := v1.10.14-0.20241105040223-5c7f1bb7073e
TENDERMINT_TARGET_VERSION := v0.3.1
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
update:
go work sync
@$(MAKE) update_all_mod
.PHONY: update
submodules:
git submodule update --init
git submodule update --remote
.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:
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.22-ubuntu . -f go-ubuntu-builder.Dockerfile; \
else \
echo "Docker image morph/go-ubuntu-builder already exists."; \
fi
.PHONY: go-ubuntu-builder
################## devnet 4 nodes ####################
devnet-up: submodules go-ubuntu-builder
python3 ops/devnet-morph/main.py --polyrepo-dir=.
.PHONY: devnet-up
devnet-up-debugccc:
python3 ops/devnet-morph/main.py --polyrepo-dir=. --debugccc
.PHONY: devnet-up-debugccc
devnet-down:
cd ops/docker && docker compose -f docker-compose-4nodes.yml down
.PHONY: devnet-down
devnet-clean-build: devnet-down
docker volume ls --filter name=docker-* --format='{{.Name}}' | xargs -r docker volume rm
rm -rf ops/l2-genesis/.devnet
rm -rf ops/docker/consensus/beacondata ops/docker/consensus/validatordata ops/docker/consensus/genesis.ssz
rm -rf ops/docker/execution/geth
.PHONY: devnet-clean-build
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-logs:
@(cd ops/docker && docker-compose logs -f)
.PHONY: devnet-logs
# 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