-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
453 lines (396 loc) · 19.1 KB
/
Copy pathMakefile
File metadata and controls
453 lines (396 loc) · 19.1 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
ifneq (,$(wildcard .env))
include .env
export
endif
ANVIL_PRIVATE_KEY ?= 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
ANVIL_DEPLOYER ?= $(shell cast wallet address --private-key $(ANVIL_PRIVATE_KEY) 2>/dev/null)
ANVIL_RPC_URL ?= http://127.0.0.1:8545
ANVIL_CHAIN_ID ?= 31337
FORGE_DEFAULT = FOUNDRY_PROFILE=default forge
FORGE_CI = FOUNDRY_PROFILE=ci forge
FORGE_COVERAGE = FOUNDRY_PROFILE=coverage forge
FORGE_PROD = FOUNDRY_PROFILE=prod forge
FORGE_GAS = FOUNDRY_PROFILE=gas forge
FORGE_SCRIPT_DEFAULT = $(FORGE_DEFAULT) script --ffi
FORGE_SCRIPT_PROD = $(FORGE_PROD) script --ffi
FORGE_SCRIPT_OPTS = --broadcast --slow
.PHONY: all setup build build-prod sizes clean \
test test-ci test-vv test-vvv test-match test-contract \
cover cover-lcov gas snapshot snapshot-check \
fmt fmt-check lint docs \
seed-createx deploy-anvil deploy-sepolia deploy \
upgrade-all upgrade-single \
register-tokens register-price-feed register-vault-module set-adapters \
register-avs register-network setup-symbiotic \
register-operator register-operator-to-network set-allocation-delay \
generate-register-params \
deploy-vaults create-committee add-operator set-vaults-to-committee \
deposit-stake delegate-stake \
distribute-rewards complete-distribute-rewards \
execute-slashing \
compute-addresses keystore-new keystore-address \
slither mythril help
# ============================================================
all: clean build test
setup:
@echo "Setting up project..."
@printf '#!/bin/sh\nset -e\nmake fmt-check\nmake lint\nmake test\n' > .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
@echo "Setup complete"
# ============================================================
# Build & Clean
# ============================================================
build:
@echo "Building contracts with default profile..."
@$(FORGE_DEFAULT) build
build-prod:
@echo "Building contracts with production profile..."
@$(FORGE_PROD) build
sizes:
@echo "Reporting contract bytecode sizes..."
@$(FORGE_PROD) build --sizes
clean:
@echo "Cleaning build artifacts..."
@$(FORGE_DEFAULT) clean
@rm -rf broadcast/*/31337 cache out .gas-snapshot lcov.info coverage anvil.log
# ============================================================
# Tests
# ============================================================
test:
@echo "Running all tests..."
@$(FORGE_DEFAULT) test -vvv --fail-fast
test-ci:
@echo "Running all tests with CI profile..."
@$(FORGE_CI) test -vvv --fail-fast
test-vv:
@echo "Running all tests with -vv verbosity..."
@$(FORGE_DEFAULT) test -vv
test-vvv:
@echo "Running all tests with -vvv verbosity..."
@$(FORGE_DEFAULT) test -vvv
test-match:
@echo "Running tests matching '$(MATCH)'..."
@$(FORGE_DEFAULT) test --match-test $(MATCH) -vvv --fail-fast
test-contract:
@echo "Running tests for contract '$(CONTRACT)'..."
@$(FORGE_DEFAULT) test --match-contract $(CONTRACT) -vvv --fail-fast
# ============================================================
# Coverage
# ============================================================
cover:
@echo "Generating coverage summary..."
@$(FORGE_COVERAGE) coverage --ir-minimum --report summary
cover-lcov:
@echo "Generating lcov coverage report..."
@$(FORGE_COVERAGE) coverage --ir-minimum --report lcov
@echo "Coverage report generated at ./lcov.info"
@if command -v genhtml >/dev/null 2>&1; then \
echo "Generating HTML coverage report..."; \
genhtml lcov.info --output-directory coverage --branch-coverage --function-coverage; \
echo "HTML coverage report generated in ./coverage/"; \
open coverage/index.html 2>/dev/null || echo "Open ./coverage/index.html in your browser"; \
else \
echo "Warning: genhtml not found. HTML report not generated."; \
fi
# ============================================================
# Gas
# ============================================================
gas:
@echo "Generating gas report..."
@$(FORGE_GAS) test --gas-report
snapshot:
@echo "Generating gas snapshot..."
@$(FORGE_PROD) snapshot
snapshot-check:
@echo "Checking gas snapshot..."
@$(FORGE_PROD) snapshot --check
# ============================================================
# Code Quality
# ============================================================
fmt:
@echo "Formatting code..."
@$(FORGE_DEFAULT) fmt
fmt-check:
@echo "Checking code format..."
@$(FORGE_DEFAULT) fmt --check
lint:
@echo "Linting code..."
@$(FORGE_DEFAULT) lint
docs:
@echo "Generating documentation..."
@$(FORGE_DEFAULT) doc
# ============================================================
# Local — Anvil
# ============================================================
seed-createx:
@echo "Seeding CreateX on Anvil..."
@cast rpc anvil_setCode 0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed "0x$$(cat src/script/createx-bytecode.txt)" \
--rpc-url $(ANVIL_RPC_URL) > /dev/null
deploy-anvil: clean seed-createx
@echo "Deploying contracts to Anvil..."
@DEPLOYER_ADDRESS=$(ANVIL_DEPLOYER) $(FORGE_SCRIPT_DEFAULT) src/script/Deploy.s.sol:Deploy \
--rpc-url $(ANVIL_RPC_URL) \
--private-key $(ANVIL_PRIVATE_KEY) \
--chain $(ANVIL_CHAIN_ID) \
$(FORGE_SCRIPT_OPTS)
# ============================================================
# Deployment
# ============================================================
deploy:
@echo "Deploying contracts to target chain..."
@$(FORGE_SCRIPT_PROD) src/script/Deploy.s.sol:Deploy \
--rpc-url $(RPC_URL) \
--keystore $(KEYSTORE) \
--sender $(DEPLOYER_ADDRESS) \
--chain $(CHAIN_ID) \
$(FORGE_SCRIPT_OPTS) \
--verify \
--etherscan-api-key $(ETHERSCAN_API_KEY)
deploy-sepolia:
@echo "Deploying contracts to Sepolia..."
@$(FORGE_SCRIPT_PROD) src/script/DeploySepolia.s.sol:DeploySepolia \
--rpc-url $(RPC_URL) \
--keystore $(KEYSTORE) \
--sender $(DEPLOYER_ADDRESS) \
--chain sepolia \
$(FORGE_SCRIPT_OPTS)
# ============================================================
# Upgrades
# ============================================================
upgrade-all:
@echo "Upgrading all core contracts..."
@$(FORGE_SCRIPT_PROD) src/script/UpgradeAllContracts.s.sol:UpgradeAllContracts \
--rpc-url $(RPC_URL) \
--keystore $(KEYSTORE) \
--sender $(DEPLOYER_ADDRESS) \
$(FORGE_SCRIPT_OPTS) \
--verify \
--etherscan-api-key $(ETHERSCAN_API_KEY)
upgrade-single:
@echo "Upgrading single contract..."
@$(FORGE_SCRIPT_PROD) src/script/UpgradeSingleContract.s.sol:UpgradeSingleContract \
--rpc-url $(RPC_URL) \
--keystore $(KEYSTORE) \
--sender $(DEPLOYER_ADDRESS) \
$(FORGE_SCRIPT_OPTS) \
--verify \
--etherscan-api-key $(ETHERSCAN_API_KEY)
# ============================================================
# Protocol Setup
# ============================================================
register-tokens:
@echo "Registering acceptable ERC-20 tokens in SSPRouter..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/RegisterAcceptableTokens.s.sol:RegisterAcceptableTokens \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
register-price-feed:
@echo "Registering Chainlink price feed..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/RegisterPriceFeed.s.sol:RegisterPriceFeed \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
register-vault-module:
@echo "Registering vault/module in SSPRouter..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/RegisterVaultModule.s.sol:RegisterVaultModule \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
set-adapters:
@echo "Setting adapter addresses on SSPRouter..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/SetAdapters.s.sol:SetAdapters \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
register-avs:
@echo "Registering AVS metadata URI in EigenAdapter..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/RegisterAVS.s.sol:RegisterAVS \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
register-network:
@echo "Registering network in Symbiotic NetworkRegistry..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/RegisterNetwork.s.sol:RegisterNetwork \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
setup-symbiotic:
@echo "Running full Symbiotic protocol setup..."
@$(FORGE_SCRIPT_DEFAULT) src/script/SetupSymbiotic.s.sol:SetupSymbiotic \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
# ============================================================
# Operator Registration
# ============================================================
register-operator:
@echo "Registering operator in Symbiotic and EigenLayer..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/RegisterOperatorInProtocols.s.sol:RegisterOperatorInProtocols \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
register-operator-to-network:
@echo "Opting operator into Symbiotic network..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/RegisterOperatorToNetwork.s.sol:RegisterOperatorToNetwork \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
set-allocation-delay:
@echo "Setting EigenLayer allocation delay for operator..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/SetAllocationDelay.s.sol:SetAllocationDelay \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
generate-register-params:
@echo "Generating operator registration params (dry-run)..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/GenerateRegisterOperatorParams.s.sol:GenerateRegisterOperatorParams \
--rpc-url $(RPC_URL) -vvvv
# ============================================================
# Vault & Committee Setup
# ============================================================
deploy-vaults:
@echo "Deploying and registering Symbiotic + EigenLayer vaults..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/DeployAndRegisterVaults.s.sol:DeployAndRegisterVaults \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
create-committee:
@echo "Creating committee and adding vaults..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/CreateCommitteeAndAddVaults.s.sol:CreateCommitteeAndAddVaults \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
add-operator:
@echo "Adding operator to committee..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/AddOperatorToCommittee.s.sol:AddOperatorToCommittee \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
set-vaults-to-committee:
@echo "Updating vault assignments for committee..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/SetVaultsToCommittee.s.sol:SetVaultsToCommittee \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
# ============================================================
# Stake Management
# ============================================================
deposit-stake:
@echo "Depositing collateral into vaults..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/DepositStakeInVaults.s.sol:DepositStakeInVaults \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
delegate-stake:
@echo "Delegating stake to operator in EigenLayer..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/DelegateStakeToOperator.s.sol:DelegateStakeToOperator \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
# ============================================================
# Rewards
# ============================================================
distribute-rewards:
@echo "Distributing rewards..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/DistributeRewards.s.sol:DistributeRewards \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
complete-distribute-rewards:
@echo "Completing pending reward distribution..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/CompleteDistributeRewards.s.sol:CompleteDistributeRewards \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
# ============================================================
# Slashing
# ============================================================
execute-slashing:
@echo "Executing slashing..."
@$(FORGE_SCRIPT_DEFAULT) src/script/testing/ExecuteSlashing.s.sol:ExecuteSlashing \
--rpc-url $(RPC_URL) --keystore $(KEYSTORE) --sender $(DEPLOYER_ADDRESS) $(FORGE_SCRIPT_OPTS)
# ============================================================
# Utilities
# ============================================================
compute-addresses:
@echo "Computing deterministic CREATE2 addresses via CreateX..."
@$(FORGE_SCRIPT_DEFAULT) src/script/ComputeAddresses.s.sol:ComputeAddresses \
--rpc-url $(RPC_URL) -vvvv
keystore-new:
@echo "Creating new encrypted keystore at $(KEYSTORE)..."
@cast wallet new $(dir $(KEYSTORE)) $(notdir $(KEYSTORE))
keystore-address:
@echo "Deployer address from keystore:"
@cast wallet address --keystore $(KEYSTORE)
# ============================================================
# Static Analysis
# ============================================================
slither:
@echo "Running Slither static analysis..."
@slither . --config-file slither.config.json --checklist --fail-pedantic
mythril:
@echo "Running Mythril security analysis..."
@for contract in \
src/contracts/StakeManager.sol \
src/contracts/RewardsManager.sol \
src/contracts/SlashingManager.sol \
src/contracts/SSPRouter.sol \
src/contracts/OraclePriceFeed.sol \
src/contracts/Adapters/BaseAdapter.sol \
src/contracts/Adapters/SymbioticAdapter.sol \
src/contracts/Adapters/EigenAdapter.sol; do \
echo "Analyzing $$contract..."; \
myth analyze $$contract \
--solv 0.8.28 \
--solc-args "--via-ir --evm-version cancun" \
--solc-remappings "$(shell paste -sd' ' remappings.txt)" \
--max-depth 22 \
--execution-timeout 300 \
--create-timeout 60 \
-t 3 \
--strategy dfs || true; \
done
# ============================================================
# Help
# ============================================================
help:
@echo "Catalysis Core Contracts - Available commands:"
@echo ""
@echo "Setup:"
@echo " make setup - Install git pre-commit hooks"
@echo ""
@echo "Building:"
@echo " make all - Clean, build and test"
@echo " make build - Build contracts with default profile"
@echo " make build-prod - Build contracts with production profile (optimized)"
@echo " make sizes - Report contract bytecode sizes (EIP-170 check)"
@echo " make clean - Remove build artifacts"
@echo ""
@echo "Testing:"
@echo " make test - Run all tests (default profile, -vvv)"
@echo " make test-ci - Run all tests with CI profile"
@echo " make test-vv - Run all tests with -vv verbosity"
@echo " make test-vvv - Run all tests with -vvv verbosity"
@echo " make test-match MATCH=<pattern> - Run tests matching a name pattern"
@echo " make test-contract CONTRACT=<name> - Run tests for a specific contract"
@echo " make cover - Generate coverage summary (console)"
@echo " make cover-lcov - Generate lcov report + HTML (requires genhtml)"
@echo " make gas - Generate gas report"
@echo " make snapshot - Generate gas snapshots"
@echo " make snapshot-check - Check gas snapshots haven't regressed"
@echo ""
@echo "Code Quality:"
@echo " make fmt - Format Solidity files"
@echo " make fmt-check - Check formatting (CI mode)"
@echo " make lint - Lint (deny warnings)"
@echo " make docs - Generate NatSpec documentation"
@echo " make slither - Run Slither static analysis"
@echo " make mythril - Run Mythril security analysis"
@echo ""
@echo "Deployment:"
@echo " make deploy-anvil - Deploy to local Anvil node"
@echo " make deploy-sepolia - Deploy to Sepolia"
@echo " make deploy - Deploy to target chain (RPC_URL + CHAIN_ID)"
@echo ""
@echo "Upgrades:"
@echo " make upgrade-all - Upgrade all core contracts"
@echo " make upgrade-single - Upgrade a single contract"
@echo ""
@echo "Protocol Setup:"
@echo " make register-tokens - Register acceptable ERC-20 tokens in SSPRouter"
@echo " make register-price-feed - Register a Chainlink price feed"
@echo " make register-vault-module - Register a vault/module in SSPRouter"
@echo " make set-adapters - Set adapter addresses on SSPRouter"
@echo " make register-avs - Register AVS metadata URI in EigenAdapter"
@echo " make register-network - Register network in Symbiotic NetworkRegistry"
@echo " make setup-symbiotic - Run full Symbiotic protocol setup"
@echo ""
@echo "Operator Registration:"
@echo " make register-operator - Register operator in Symbiotic + EigenLayer"
@echo " make register-operator-to-network - Opt operator into Symbiotic network"
@echo " make set-allocation-delay - Set EigenLayer allocation delay"
@echo " make generate-register-params - Generate operator registration calldata (dry-run)"
@echo ""
@echo "Vault & Committee:"
@echo " make deploy-vaults - Deploy and register Symbiotic + EigenLayer vaults"
@echo " make create-committee - Create committee and add vaults"
@echo " make add-operator - Add operator to committee"
@echo " make set-vaults-to-committee - Update vault assignments for a committee"
@echo " make deposit-stake - Deposit collateral into vaults"
@echo " make delegate-stake - Delegate stake to operator in EigenLayer"
@echo ""
@echo "Rewards & Slashing:"
@echo " make distribute-rewards - Trigger reward distribution"
@echo " make complete-distribute-rewards - Complete pending reward distribution"
@echo " make execute-slashing - Execute a slash"
@echo ""
@echo "Utilities:"
@echo " make compute-addresses - Compute deterministic CREATE2 addresses"
@echo " make keystore-new KEYSTORE=<path> - Create a new encrypted keystore"
@echo " make keystore-address KEYSTORE=<path> - Print deployer address from keystore"
@echo ""
@echo " make help - Show this help message"