forked from succinctlabs/op-succinct
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathjustfile
More file actions
540 lines (434 loc) · 17.4 KB
/
justfile
File metadata and controls
540 lines (434 loc) · 17.4 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
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
default:
@just --list
# Runs the op-succinct program for a single block.
run-single l2_block_num use-cache="false" prove="false":
#!/usr/bin/env bash
CACHE_FLAG=""
if [ "{{use-cache}}" = "true" ]; then
CACHE_FLAG="--use-cache"
fi
PROVE_FLAG=""
if [ "{{prove}}" = "true" ]; then
PROVE_FLAG="--prove"
fi
cargo run --bin single --release -- --l2-block {{l2_block_num}} $CACHE_FLAG $PROVE_FLAG
# Runs the op-succinct program for multiple blocks.
run-multi start end use-cache="false" prove="false":
#!/usr/bin/env bash
CACHE_FLAG=""
if [ "{{use-cache}}" = "true" ]; then
CACHE_FLAG="--use-cache"
fi
PROVE_FLAG=""
if [ "{{prove}}" = "true" ]; then
PROVE_FLAG="--prove"
fi
cargo run --bin multi --release -- --start {{start}} --end {{end}} $CACHE_FLAG $PROVE_FLAG
# Runs the cost estimator for a given block range.
# If no range is provided, runs for the last 5 finalized blocks.
cost-estimator *args='':
#!/usr/bin/env bash
if [ -z "{{args}}" ]; then
cargo run --bin cost-estimator --release
else
cargo run --bin cost-estimator --release -- {{args}}
fi
# Output the data required for the ZKVM execution.
echo "$L1_HEAD $L2_OUTPUT_ROOT $L2_CLAIM $L2_BLOCK_NUMBER $L2_CHAIN_ID"
upgrade-l2oo l1_rpc admin_pk etherscan_api_key="":
#!/usr/bin/env bash
VERIFY=""
ETHERSCAN_API_KEY="{{etherscan_api_key}}"
if [ $ETHERSCAN_API_KEY != "" ]; then
VERIFY="--verify --verifier etherscan --etherscan-api-key $ETHERSCAN_API_KEY"
fi
L1_RPC="{{l1_rpc}}"
ADMIN_PK="{{admin_pk}}"
cd contracts && forge script script/validity/OPSuccinctUpgrader.s.sol:OPSuccinctUpgrader --rpc-url $L1_RPC --private-key $ADMIN_PK $VERIFY --broadcast --slow
# Fetch config for deployment
fetch-fdg-config env_file=".env" *features='':
#!/usr/bin/env bash
set -euo pipefail
echo "Fetching Fault Dispute Game configuration..."
if [ -z "{{features}}" ]; then
RUST_LOG=info cargo run --bin fetch-fault-dispute-game-config --release -- --env-file {{env_file}}
else
echo "Fetching fault dispute game config with features: {{features}}"
RUST_LOG=info cargo run --bin fetch-fault-dispute-game-config --release --features {{features}} -- --env-file {{env_file}}
fi
# Deploy OPSuccinct FDG contracts
deploy-fdg-contracts env_file=".env" *features='':
#!/usr/bin/env bash
set -euo pipefail
# First fetch FDG config using the env file
just fetch-fdg-config {{env_file}} {{features}}
# Run deployment of contracts
just _deploy-fdg-contracts {{env_file}}
# Deploy contracts without fetching config
_deploy-fdg-contracts env_file=".env" custom_config_file="":
#!/usr/bin/env bash
set -euo pipefail
# Load environment variables from project root
source {{env_file}}
# Load environment variables from contracts directory if it exists
if [ -f "contracts/.env" ]; then
source contracts/.env
fi
# Check if required environment variables are set
if [ -z "${RPC_URL:-}" ] && [ -z "${L1_RPC:-}" ]; then
echo "Error: Neither RPC_URL nor L1_RPC environment variable is set"
exit 1
fi
if [ -z "${PRIVATE_KEY:-}" ]; then
echo "Error: PRIVATE_KEY environment variable is not set"
exit 1
fi
# Use RPC_URL if set, otherwise fall back to L1_RPC
RPC_URL_TO_USE="${RPC_URL:-$L1_RPC}"
echo "Using RPC URL: $RPC_URL_TO_USE"
echo "Deploying FDG contracts..."
# Change to contracts directory
cd contracts
# Use custom config file
CUSTOM_CONFIG="{{custom_config_file}}"
if [ -n "$CUSTOM_CONFIG" ]; then
echo "Using custom config file: $CUSTOM_CONFIG..."
cp $CUSTOM_CONFIG opsuccinctfdgconfig.json
fi
# Install dependencies only if not already present
# (avoids git lock conflicts in parallel test runs)
if [ ! -d "lib/forge-std" ]; then
echo "Installing forge dependencies..."
forge install
else
echo "Forge dependencies already installed, skipping..."
fi
# Build contracts
echo "Building contracts..."
forge build
# Setup verification flags
VERIFY=""
if [ -n "${ETHERSCAN_API_KEY:-}" ]; then
VERIFY="--verify --verifier etherscan --etherscan-api-key $ETHERSCAN_API_KEY --retries 10 --delay 5"
echo "Verification enabled with Etherscan"
fi
# Run deployment script
echo "Running deployment script..."
forge script script/fp/DeployOPSuccinctFDG.s.sol \
--broadcast \
--no-storage-caching \
--slow \
--rpc-url "$RPC_URL_TO_USE" \
--private-key "$PRIVATE_KEY" \
$VERIFY
echo "FDG contract deployment complete!"
# Deploy mock verifier
deploy-mock-verifier env_file=".env":
#!/usr/bin/env bash
set -a
source {{env_file}}
set +a
if [ -z "$L1_RPC" ]; then
echo "L1_RPC not set in {{env_file}}"
exit 1
fi
if [ -z "$PRIVATE_KEY" ]; then
echo "PRIVATE_KEY not set in {{env_file}}"
exit 1
fi
cd contracts
VERIFY=""
if [ -n "${ETHERSCAN_API_KEY:-}" ]; then
VERIFY="--verify --verifier etherscan --etherscan-api-key $ETHERSCAN_API_KEY"
fi
forge script script/validity/DeployMockVerifier.s.sol:DeployMockVerifier \
--rpc-url $L1_RPC \
--private-key $PRIVATE_KEY \
--broadcast \
$VERIFY
# Upgrade the game implementation contract (for hardfork/upgrade)
# This script deploys a new OPSuccinctFaultDisputeGame implementation and sets it in the factory.
# Required env vars: FACTORY_ADDRESS, GAME_TYPE, VERIFIER_ADDRESS, ANCHOR_STATE_REGISTRY, ACCESS_MANAGER,
# AGGREGATION_VKEY, RANGE_VKEY_COMMITMENT, ROLLUP_CONFIG_HASH,
# MAX_CHALLENGE_DURATION, MAX_PROVE_DURATION, CHALLENGER_BOND_WEI
upgrade-game-impl env_file=".env":
#!/usr/bin/env bash
set -aeo pipefail
source {{env_file}}
if [ -z "$L1_RPC" ]; then
echo "L1_RPC not set in {{env_file}}"
exit 1
fi
if [ -z "$PRIVATE_KEY" ]; then
echo "PRIVATE_KEY not set in {{env_file}}"
exit 1
fi
cd contracts
echo "Upgrading game implementation..."
forge script script/fp/UpgradeOPSuccinctFDG.s.sol \
--rpc-url "$L1_RPC" \
--private-key "$PRIVATE_KEY" \
--broadcast \
--slow
echo "Game implementation upgrade complete!"
# Deploy the OPSuccinct L2 Output Oracle
deploy-oracle env_file=".env" *features='':
#!/usr/bin/env bash
set -euo pipefail
# First fetch rollup config using the env file
if [ -z "{{features}}" ]; then
RUST_LOG=info cargo run --bin fetch-l2oo-config --release -- --env-file {{env_file}}
else
echo "Fetching rollup config with features: {{features}}"
RUST_LOG=info cargo run --bin fetch-l2oo-config --release --features {{features}} -- --env-file {{env_file}}
fi
# Load environment variables
source {{env_file}}
# cd into contracts directory
cd contracts
VERIFY=""
if [ -n "${ETHERSCAN_API_KEY:-}" ]; then
VERIFY="--verify --verifier etherscan --etherscan-api-key $ETHERSCAN_API_KEY"
fi
ENV_VARS=""
if [ -n "${ADMIN_PK:-}" ]; then ENV_VARS="$ENV_VARS ADMIN_PK=$ADMIN_PK"; fi
if [ -n "${DEPLOY_PK:-}" ]; then ENV_VARS="$ENV_VARS DEPLOY_PK=$DEPLOY_PK"; fi
# Run the forge deployment script
$ENV_VARS forge script script/validity/OPSuccinctDeployer.s.sol:OPSuccinctDeployer \
--rpc-url $L1_RPC \
--private-key $PRIVATE_KEY \
--broadcast \
$VERIFY
# Upgrade the OPSuccinct L2 Output Oracle
upgrade-oracle env_file=".env" *features='':
#!/usr/bin/env bash
set -euo pipefail
# First fetch rollup config using the env file
if [ -z "{{features}}" ]; then
RUST_LOG=info cargo run --bin fetch-l2oo-config --release -- --env-file {{env_file}}
else
echo "Fetching rollup config with features: {{features}}"
RUST_LOG=info cargo run --bin fetch-l2oo-config --release --features {{features}} -- --env-file {{env_file}}
fi
# Load environment variables
source {{env_file}}
# cd into contracts directory
cd contracts
# forge install
forge install
# Run the forge upgrade script
ENV_VARS="L2OO_ADDRESS=$L2OO_ADDRESS"
if [ -n "${EXECUTE_UPGRADE_CALL:-}" ]; then ENV_VARS="$ENV_VARS EXECUTE_UPGRADE_CALL=$EXECUTE_UPGRADE_CALL"; fi
if [ -n "${ADMIN_PK:-}" ]; then ENV_VARS="$ENV_VARS ADMIN_PK=$ADMIN_PK"; fi
if [ -n "${DEPLOY_PK:-}" ]; then ENV_VARS="$ENV_VARS DEPLOY_PK=$DEPLOY_PK"; fi
VERIFY_FLAGS=""
if [ -n "${ETHERSCAN_API_KEY:-}" ]; then
VERIFY_FLAGS="--verify --verifier etherscan --etherscan-api-key $ETHERSCAN_API_KEY"
fi
if [ "${EXECUTE_UPGRADE_CALL:-true}" = "false" ]; then
env $ENV_VARS forge script script/validity/OPSuccinctUpgrader.s.sol:OPSuccinctUpgrader \
--rpc-url $L1_RPC \
--private-key $PRIVATE_KEY
else
env $ENV_VARS forge script script/validity/OPSuccinctUpgrader.s.sol:OPSuccinctUpgrader \
--rpc-url $L1_RPC \
--private-key $PRIVATE_KEY \
$VERIFY_FLAGS \
--broadcast
fi
deploy-dispute-game-factory env_file=".env":
#!/usr/bin/env bash
set -euo pipefail
# Load environment variables
source {{env_file}}
# Check if required environment variables are set.
if [ -z "${L2OO_ADDRESS:-}" ]; then
echo "Error: L2OO_ADDRESS environment variable is not set"
exit 1
fi
if [ -z "${PROPOSER_ADDRESSES:-}" ]; then
echo "Error: PROPOSER_ADDRESSES environment variable is not set"
exit 1
fi
# cd into contracts directory
cd contracts
# forge install
forge install
VERIFY=""
if [ -n "$ETHERSCAN_API_KEY" ]; then
VERIFY="--verify --verifier etherscan --etherscan-api-key $ETHERSCAN_API_KEY"
fi
# Run the forge deployment script
env L2OO_ADDRESS=$L2OO_ADDRESS \
PROPOSER_ADDRESSES=$PROPOSER_ADDRESSES \
forge script script/validity/OPSuccinctDGFDeployer.s.sol:OPSuccinctDFGDeployer \
--rpc-url $L1_RPC \
--private-key $PRIVATE_KEY \
--broadcast \
$VERIFY
# Upgrade the OPSuccinct Fault Dispute Game implementation.
upgrade-fault-dispute-game env_file="fault-proof/.env.upgrade":
#!/usr/bin/env bash
set -aeuo pipefail
# Load environment variables
source {{env_file}}
# cd into contracts directory.
cd contracts
# Install dependencies.
forge install
# Run the forge upgrade script.
if [ "${DRY_RUN}" = "false" ]; then
if [ -z "${PRIVATE_KEY:-}" ]; then
echo "Error: PRIVATE_KEY environment variable is required when DRY_RUN=false"
exit 1
fi
forge script script/fp/UpgradeOPSuccinctFDG.s.sol:UpgradeOPSuccinctFDG \
--rpc-url $L1_RPC \
--private-key $PRIVATE_KEY \
--etherscan-api-key $ETHERSCAN_API_KEY \
--broadcast
else
forge script script/fp/UpgradeOPSuccinctFDG.s.sol:UpgradeOPSuccinctFDG \
--sig "getUpgradeCalldata()"
fi
# Add a new OpSuccinctConfig to the L2 Output Oracle
add-config config_name env_file=".env" *features='':
#!/usr/bin/env bash
set -euo pipefail
# First fetch rollup config using the env file
if [ -z "{{features}}" ]; then
RUST_LOG=info cargo run --bin fetch-l2oo-config --release -- --env-file {{env_file}}
else
echo "Fetching rollup config with features: {{features}}"
RUST_LOG=info cargo run --bin fetch-l2oo-config --release --features {{features}} -- --env-file {{env_file}}
fi
# Load environment variables
source {{env_file}}
# cd into contracts directory
cd contracts
# forge install
forge install
# Run the forge script to add config
env L2OO_ADDRESS="$L2OO_ADDRESS" \
${EXECUTE_UPGRADE_CALL:+EXECUTE_UPGRADE_CALL="$EXECUTE_UPGRADE_CALL"} \
${ADMIN_PK:+ADMIN_PK="$ADMIN_PK"} \
${DEPLOY_PK:+DEPLOY_PK="$DEPLOY_PK"} \
forge script script/validity/OPSuccinctParameterUpdater.s.sol:OPSuccinctParameterUpdater \
--sig "addConfig(string)" "{{config_name}}" \
--rpc-url $L1_RPC \
--private-key $PRIVATE_KEY \
--broadcast
# Remove an OpSuccinctConfig from the L2 Output Oracle
remove-config config_name env_file=".env":
#!/usr/bin/env bash
set -euo pipefail
# Load environment variables
source {{env_file}}
# cd into contracts directory
cd contracts
# forge install
forge install
# Run the forge script to remove config
env L2OO_ADDRESS="$L2OO_ADDRESS" \
${EXECUTE_UPGRADE_CALL:+EXECUTE_UPGRADE_CALL="$EXECUTE_UPGRADE_CALL"} \
${ADMIN_PK:+ADMIN_PK="$ADMIN_PK"} \
${DEPLOY_PK:+DEPLOY_PK="$DEPLOY_PK"} \
forge script script/validity/OPSuccinctParameterUpdater.s.sol:OPSuccinctParameterUpdater \
--sig "removeConfig(string)" "{{config_name}}" \
--rpc-url $L1_RPC \
--private-key $PRIVATE_KEY \
--broadcast
# Generate verification key hashes for all DA variants.
vkeys:
#!/usr/bin/env bash
set -e
echo "Generating verification key hashes..."
echo ""
# Ethereum DA
ETH_OUTPUT=$(RUST_LOG=error cargo run --release --bin config 2>&1)
ETH_RANGE=$(echo "$ETH_OUTPUT" | grep "Range Verification Key Hash" | awk '{print $NF}')
AGG_KEY=$(echo "$ETH_OUTPUT" | grep "Aggregation Verification Key Hash" | awk '{print $NF}')
# Celestia DA
CEL_OUTPUT=$(RUST_LOG=error cargo run --release --bin config --features celestia 2>&1)
CEL_RANGE=$(echo "$CEL_OUTPUT" | grep "Range Verification Key Hash" | awk '{print $NF}')
# EigenDA
EIGEN_OUTPUT=$(RUST_LOG=error cargo run --release --bin config --features eigenda 2>&1)
EIGEN_RANGE=$(echo "$EIGEN_OUTPUT" | grep "Range Verification Key Hash" | awk '{print $NF}')
echo "## Verification Key Hashes"
echo ""
echo "| Program | Verification Key Hash |"
echo "|--------|------------------------|"
echo "| Ethereum DA Range Verification Key | **$ETH_RANGE** |"
echo "| Celestia DA Range Verification Key | **$CEL_RANGE** |"
echo "| EigenDA Range Verification Key | **$EIGEN_RANGE** |"
echo "| Aggregation Verification Key | **$AGG_KEY** |"
# Build all ELF files.
build-elfs: build-range-elfs build-agg-elf
# Build ELF files for range programs.
build-range-elfs:
#!/usr/bin/env bash
cd programs/range/ethereum
~/.sp1/bin/cargo-prove prove build --elf-name range-elf-bump --docker --tag v5.2.4 --output-directory ../../../elf
~/.sp1/bin/cargo-prove prove build --elf-name range-elf-embedded --docker --tag v5.2.4 --output-directory ../../../elf --features embedded
cd ../eigenda
~/.sp1/bin/cargo-prove prove build --elf-name eigenda-range-elf-embedded --docker --tag v5.2.4 --output-directory ../../../elf --features embedded
# Build ELF file for aggregation program.
build-agg-elf:
#!/usr/bin/env bash
cd programs/aggregation
~/.sp1/bin/cargo-prove prove build --elf-name aggregation-elf --docker --tag v5.2.4 --output-directory ../../elf
# Run all unit tests except for the specified ones.
audit-forkdiff:
#!/usr/bin/env bash
set -euo pipefail
outpath=audits/audit-forkdiff.html
docker run --rm \
--mount src=$(pwd),target=/host-pwd,type=bind \
--platform linux/amd64 \
protolambda/forkdiff:latest \
-repo /host-pwd/ -fork /host-pwd/audits/audit-forkdiff.yaml -out /host-pwd/$outpath
echo "Audit forkdiff written to $outpath"
# Run all unit and integration tests except for the specified ones.
tests:
cargo t --release \
-- \
--skip test_cycle_count_diff \
--skip test_post_to_github \
--skip execute_batch \
# Run fault-proof integration tests
# target: test file (integration, sync, etc.)
# da: DA feature (ethereum, eigenda, celestia). DA-agnostic tests like sync work with any.
fp-integration-tests target="integration" da="ethereum":
cd fault-proof && cargo t --test {{target}} --release --features integration,{{da}} -- --test-threads=1 --nocapture
# Run DA-specific host utility tests
# da: ethereum, eigenda, celestia
da-integration-tests da="ethereum":
#!/usr/bin/env bash
set -euo pipefail
# EigenDA tests require SRS file - create symlink if needed
if [ "{{da}}" = "eigenda" ] && [ ! -e "utils/eigenda/host/resources" ]; then
if [ ! -d "resources" ]; then
echo "Error: resources/ directory not found. Run from workspace root."
exit 1
fi
ln -sf ../../../resources utils/eigenda/host/resources
echo "Created symlink: utils/eigenda/host/resources -> resources/"
fi
cargo t -p op-succinct-{{da}}-host-utils --features integration --release -- --test-threads=1 --nocapture
forge-build *ARGS:
#!/usr/bin/env bash
set -euo pipefail
cd contracts
forge build {{ARGS}}
# Forge build compiles only the src/ graph; the scripts/ graph is compiled by `forge script`.
# On the first invocation, `forge script` may compile a small set of dependencies.
# To avoid paying this cost in every CI test, we pre‑warm the script cache once here.
#
# Notes:
# - A single `forge script <any script> --skip-simulation` is sufficient to compile the script
# dependency graph into the cache.
forge script "script/validity/DeployMockVerifier.s.sol" \
--skip "/**/test/**" \
--sig "idonotexist()" \
--skip-simulation \
2>/dev/null || true