forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 9
/
justfile
255 lines (189 loc) · 8.72 KB
/
justfile
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
247
248
249
250
251
252
253
254
255
########################################################
# INSTALL #
########################################################
# Installs dependencies.
install:
forge install
# Shows the status of the git submodules.
dep-status:
git submodule status
########################################################
# BUILD #
########################################################
# Checks that the correct version of Foundry is installed.
check-foundry:
cd ../../ && ./ops/scripts/check-foundry.sh
# Checks that semgrep is installed.
check-semgrep:
cd ../../ && just check-semgrep
# Checks that the correct versions of Foundry and semgrep are installed.
check-dependencies:
just check-foundry && just check-semgrep
# Core forge build command
forge-build:
forge build
# Builds the contracts.
build: check-dependencies lint-fix-no-fail forge-build interfaces-check-no-build
# Builds the go-ffi tool for contract tests.
build-go-ffi-default:
cd ./scripts/go-ffi && go build
# Builds the go-ffi tool for MIPS64 contract tests.
build-go-ffi-cannon64:
cd ./scripts/go-ffi && go build -tags=cannon64 -o ./go-ffi-cannon64
build-go-ffi: build-go-ffi-default build-go-ffi-cannon64
# Cleans build artifacts and deployments.
clean:
rm -rf ./artifacts ./forge-artifacts ./cache ./scripts/go-ffi/go-ffi ./deployments/hardhat/*
########################################################
# TEST #
########################################################
# Runs standard contract tests.
test: build-go-ffi
forge test
# Runs standard contract tests with rerun flag.
test-rerun: build-go-ffi
forge test --rerun -vvv
# Run Kontrol tests and build all dependencies.
test-kontrol: build-go-ffi build kontrol-summary-full test-kontrol-no-build
# Run Kontrol tests without dependencies.
test-kontrol-no-build:
./test/kontrol/scripts/run-kontrol.sh script
# Runs contract coverage.
coverage: build-go-ffi
forge coverage || (bash -c "forge coverage 2>&1 | grep -q 'Stack too deep' && echo -e '\\033[1;33mWARNING\\033[0m: Coverage failed with stack too deep, so overriding and exiting successfully' && exit 0 || exit 1")
# Runs contract coverage with lcov.
coverage-lcov: build-go-ffi
forge coverage --report lcov || (bash -c "forge coverage --report lcov 2>&1 | grep -q 'Stack too deep' && echo -e '\\033[1;33mWARNING\\033[0m: Coverage failed with stack too deep, so overriding and exiting successfully' && exit 0 || exit 1")
########################################################
# DEPLOY #
########################################################
# Generates the L2 genesis state.
genesis:
forge script scripts/L2Genesis.s.sol:L2Genesis --sig 'runWithStateDump()'
# Deploys the contracts.
deploy:
./scripts/deploy/deploy.sh
########################################################
# SNAPSHOTS #
########################################################
# Generates a gas snapshot without building.
gas-snapshot-no-build:
forge snapshot --match-contract GasBenchMark --snap snapshots/.gas-snapshot
# Generates a gas snapshot.
gas-snapshot: build-go-ffi gas-snapshot-no-build
# Generates default Kontrol summary.
kontrol-summary:
./test/kontrol/scripts/make-summary-deployment.sh
# Generates fault proofs Kontrol summary.
kontrol-summary-fp:
KONTROL_FP_DEPLOYMENT=true ./test/kontrol/scripts/make-summary-deployment.sh
# Generates all Kontrol summaries (default and FP).
kontrol-summary-full: kontrol-summary kontrol-summary-fp
# Generates ABI snapshots for contracts.
snapshots-abi-storage:
go run ./scripts/autogen/generate-snapshots .
# Updates the snapshots/semver-lock.json file.
semver-lock:
go run scripts/autogen/generate-semver-lock/main.go
# Generates core snapshots without building contracts. Currently just an alias for
# snapshots-abi-storage because we no longer run Kontrol snapshots here. Run
# kontrol-summary-full to build the Kontrol summaries if necessary.
snapshots-no-build: snapshots-abi-storage
# Builds contracts and then generates core snapshots.
snapshots: build snapshots-no-build
########################################################
# CHECKS #
########################################################
# Checks that the gas snapshot is up to date without building.
gas-snapshot-check-no-build:
forge snapshot --match-contract GasBenchMark --snap snapshots/.gas-snapshot --check
# Checks that the gas snapshot is up to date.
gas-snapshot-check: build-go-ffi gas-snapshot-check-no-build
# Checks if the snapshots are up to date without building.
snapshots-check-no-build:
./scripts/checks/check-snapshots.sh --no-build
# Checks if the snapshots are up to date.
snapshots-check:
./scripts/checks/check-snapshots.sh
# Checks interface correctness without building.
interfaces-check-no-build:
go run ./scripts/checks/interfaces
# Checks that all interfaces are appropriately named and accurately reflect the corresponding
# contract that they're meant to represent. We run "clean" before building because leftover
# artifacts can cause the script to detect issues incorrectly.2
interfaces-check: clean build interfaces-check-no-build
# Checks that the size of the contracts is within the limit.
size-check:
forge build --sizes --skip "/**/test/**" --skip "/**/scripts/**"
# Checks that any contracts with a modified semver lock also have a modified semver version.
# Does not build contracts.
semver-diff-check-no-build:
./scripts/checks/check-semver-diff.sh
# Checks that any contracts with a modified semver lock also have a modified semver version.
semver-diff-check: build semver-diff-check-no-build
# Checks that the semgrep tests are valid.
semgrep-test-validity-check:
forge fmt ../../.semgrep/tests/sol-rules.t.sol --check
# Checks that forge test names are correctly formatted. Does not build contracts.
lint-forge-tests-check-no-build:
go run ./scripts/checks/test-names
# Checks that forge test names are correctly formatted.
lint-forge-tests-check: build lint-forge-tests-check-no-build
# Checks that contracts are properly linted.
lint-check:
forge fmt --check
# Checks for unused imports in Solidity contracts. Does not build contracts.
unused-imports-check-no-build:
go run ./scripts/checks/unused-imports
# Checks for unused imports in Solidity contracts.
unused-imports-check: build unused-imports-check-no-build
# Checks that the deploy configs are valid.
validate-deploy-configs:
./scripts/checks/check-deploy-configs.sh
# Checks that spacer variables are correctly inserted without building.
validate-spacers-no-build:
go run ./scripts/checks/spacers
# Checks that spacer variables are correctly inserted.
validate-spacers: build validate-spacers-no-build
# Checks that the Kontrol summary dummy files have not been modified.
# If you have changed the summary files deliberately, update the hashes in the script.
# Use `openssl dgst -sha256` to generate the hash for a file.
check-kontrol-summaries-unchanged:
./scripts/checks/check-kontrol-summaries-unchanged.sh
# Runs semgrep on the contracts.
semgrep:
cd ../../ && semgrep scan --config .semgrep/rules/ ./packages/contracts-bedrock
# Runs semgrep tests.
semgrep-test:
cd ../../ && semgrep scan --test --config .semgrep/rules/ .semgrep/tests/
# TODO: Also run lint-forge-tests-check but we need to fix the test names first.
# Runs all checks.
check:
@just gas-snapshot-check-no-build \
semgrep-test-validity-check \
unused-imports-check-no-build \
snapshots-check-no-build \
lint-check \
semver-diff-check-no-build \
validate-deploy-configs \
validate-spacers-no-build \
interfaces-check-no-build \
lint-forge-tests-check-no-build
########################################################
# DEV TOOLS #
########################################################
# Cleans, builds, lints, and runs all checks.
pre-pr: clean pre-pr-no-build
# Builds, lints, and runs all checks. Sometimes a bad cache causes issues, in which case the above
# `pre-pr` is preferred. But in most cases this will be sufficient and much faster then a full build.
pre-pr-no-build: build-go-ffi build lint gas-snapshot-no-build snapshots-no-build semver-lock check
# Fixes linting errors.
lint-fix:
forge fmt
# Fixes linting errors but doesn't fail if there are syntax errors. Useful for build command
# because the output of forge fmt can sometimes be difficult to understand but if there's a syntax
# error the build will fail anyway and provide more context about what's wrong.
lint-fix-no-fail:
forge fmt || true
# Fixes linting errors and checks that the code is correctly formatted.
lint: lint-fix lint-check