-
Notifications
You must be signed in to change notification settings - Fork 72
Emerald prover #822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Emerald prover #822
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
71d478f
emerald verify
chengwenxi b68a2b8
feat: Alt fee tx (#823)
anylots 0d35bb5
update revm
chengwenxi 6be1998
Merge branch 'main' into emerald-prover
anylots 6472d85
update elf & program key
anylots f86cedd
fix for cr
anylots 34108d3
prover
anylots f724254
prover
anylots 3911ba1
shadow execute
anylots 7c28595
shadow execute
anylots 805a14d
Merge branch 'main' into emerald-prover
anylots 037dae9
Merge branch 'main' into emerald-prover
chengwenxi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Script to fetch block traces and verify them with Rust prover | ||
| # Usage: ./verify.sh <start_block> <end_block> [rpc_url] | ||
| # Example: ./verify.sh 10 20 http://localhost:8545 | ||
|
|
||
| set -e | ||
|
|
||
| # Check if required commands exist | ||
| command -v cast >/dev/null 2>&1 || { echo "Error: 'cast' command not found. Please install foundry."; exit 1; } | ||
| command -v jq >/dev/null 2>&1 || { echo "Error: 'jq' command not found. Please install jq."; exit 1; } | ||
|
|
||
| # Parse arguments | ||
| if [ $# -lt 2 ]; then | ||
| echo "Usage: $0 <start_block> <end_block> [rpc_url]" | ||
| echo "Example: $0 10 20 http://localhost:8545" | ||
| exit 1 | ||
| fi | ||
|
|
||
| START_BLOCK=$1 | ||
| END_BLOCK=$2 | ||
| RPC_URL=${3:-"http://localhost:8545"} | ||
|
|
||
| # Validate block numbers | ||
| if ! [[ "$START_BLOCK" =~ ^[0-9]+$ ]] || ! [[ "$END_BLOCK" =~ ^[0-9]+$ ]]; then | ||
| echo "Error: Block numbers must be integers" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$START_BLOCK" -gt "$END_BLOCK" ]; then | ||
| echo "Error: Start block must be less than or equal to end block" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Create output directory if it doesn't exist | ||
| OUTPUT_DIR="./generated" | ||
| mkdir -p "$OUTPUT_DIR" | ||
|
|
||
| OUTPUT_FILE="$OUTPUT_DIR/block_traces_${START_BLOCK}_${END_BLOCK}.json" | ||
| TEMP_FILE="$OUTPUT_DIR/temp_traces.json" | ||
|
|
||
| echo "Fetching block traces from block $START_BLOCK to $END_BLOCK..." | ||
| echo "RPC URL: $RPC_URL" | ||
| echo "Output file: $OUTPUT_FILE" | ||
| echo "" | ||
|
|
||
| # Initialize the JSON array | ||
| echo "[" > "$TEMP_FILE" | ||
|
|
||
| FIRST=true | ||
| SUCCESS_COUNT=0 | ||
| FAIL_COUNT=0 | ||
|
|
||
| # Iterate through blocks | ||
| for ((block=$START_BLOCK; block<=$END_BLOCK; block++)); do | ||
| # Convert block number to hex | ||
| BLOCK_HEX=$(printf "0x%x" $block) | ||
|
|
||
| echo -n "Fetching block $block (${BLOCK_HEX})... " | ||
|
|
||
| # Fetch the block trace | ||
| TRACE=$(cast rpc morph_getBlockTraceByNumberOrHash "$BLOCK_HEX" --rpc-url "$RPC_URL" 2>/dev/null) | ||
|
|
||
| if [ $? -eq 0 ] && [ -n "$TRACE" ] && [ "$TRACE" != "null" ]; then | ||
| # Add comma separator if not first element | ||
| if [ "$FIRST" = false ]; then | ||
| echo "," >> "$TEMP_FILE" | ||
| fi | ||
| FIRST=false | ||
|
|
||
| # Wrap the trace in an array and append to file | ||
| echo " [" >> "$TEMP_FILE" | ||
| echo " $TRACE" >> "$TEMP_FILE" | ||
| echo -n " ]" >> "$TEMP_FILE" | ||
|
|
||
| echo "✓ Success" | ||
| SUCCESS_COUNT=$((SUCCESS_COUNT + 1)) | ||
| else | ||
| echo "✗ Failed (empty or null response)" | ||
| FAIL_COUNT=$((FAIL_COUNT + 1)) | ||
| fi | ||
| done | ||
|
|
||
| # Close the JSON array | ||
| echo "" >> "$TEMP_FILE" | ||
| echo "]" >> "$TEMP_FILE" | ||
|
|
||
| # Validate and format JSON | ||
| echo "" | ||
| echo "Validating and formatting JSON..." | ||
| if jq empty "$TEMP_FILE" 2>/dev/null; then | ||
| jq '.' "$TEMP_FILE" > "$OUTPUT_FILE" | ||
| rm "$TEMP_FILE" | ||
| echo "✓ JSON is valid and formatted" | ||
| else | ||
| echo "✗ Error: Invalid JSON generated" | ||
| echo "Temp file saved at: $TEMP_FILE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "Summary:" | ||
| echo " Total blocks: $((END_BLOCK - START_BLOCK + 1))" | ||
| echo " Successfully fetched: $SUCCESS_COUNT" | ||
| echo " Failed: $FAIL_COUNT" | ||
| echo " Output file (absolute): $(cd "$(dirname "$OUTPUT_FILE")" && pwd)/$(basename "$OUTPUT_FILE")" | ||
| echo "" | ||
|
|
||
| # If all blocks failed, exit | ||
| if [ "$SUCCESS_COUNT" -eq 0 ]; then | ||
| echo "Error: No blocks were successfully fetched" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Run Rust verification | ||
| echo "================================================" | ||
| echo "Running Rust verification..." | ||
| echo "================================================" | ||
| echo "" | ||
|
|
||
| cd "$(dirname "$0")/.." | ||
|
|
||
| # Update OUTPUT_FILE path to be relative to prover directory | ||
| OUTPUT_FILE_FOR_RUST="./testdata/$OUTPUT_FILE" | ||
|
|
||
| RUST_LOG=info TRUSTED_SETUP_4844=./configs/4844_trusted_setup.txt cargo run --release -- --block-path "$OUTPUT_FILE_FOR_RUST" | ||
|
|
||
| RUST_EXIT_CODE=$? | ||
|
|
||
| echo "" | ||
| echo "================================================" | ||
| if [ $RUST_EXIT_CODE -eq 0 ]; then | ||
| echo "✓ Verification completed successfully!" | ||
| else | ||
| echo "✗ Verification failed with exit code $RUST_EXIT_CODE" | ||
| fi | ||
| echo "================================================" | ||
|
|
||
| exit $RUST_EXIT_CODE | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
cat -n prover/testdata/verify.sh | head -150Repository: morph-l2/morph
Length of output: 5002
🏁 Script executed:
Repository: morph-l2/morph
Length of output: 120
🏁 Script executed:
Repository: morph-l2/morph
Length of output: 103
🏁 Script executed:
Repository: morph-l2/morph
Length of output: 1486
🌐 Web query:
cast rpc foundry exit code behavior error handling💡 Result:
Short answer
What to do if you need reliable exit codes
Sources
🏁 Script executed:
Repository: morph-l2/morph
Length of output: 177
🏁 Script executed:
Repository: morph-l2/morph
Length of output: 136
set -ecauses script to abort on first RPC failure instead of continuing with error trackingWhen
cast rpcfails and returns a non-zero exit code, the assignmentTRACE=$(cast rpc ...)on line 63 triggers theset -eexit immediately, terminating the loop before theif [ $? -eq 0 ]check on line 65 is reached. This prevents the FAIL_COUNT logic from executing and stops processing of remaining blocks.Wrap the assignment in an
ifstatement to suppressset -efor that command and allow the loop to continue:Also applies to: 56-81
🤖 Prompt for AI Agents