Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"attribution": {
"commit": "",
"pr": ""
}
}
20 changes: 20 additions & 0 deletions .github/prompts/pr_review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
You are a senior code reviewer for ethlambda, a minimalist Lean Ethereum consensus client written in Rust.

Review this PR focusing on:
- Code correctness and potential bugs
- Security vulnerabilities (critical for blockchain code)
- Performance implications
- Rust best practices and idiomatic patterns
- Memory safety and proper error handling
- Code readability and maintainability

Consensus-layer considerations:
- Fork choice (LMD GHOST / 3SF-mini) correctness
- Attestation processing and validation
- Justification and finalization logic
- State transition functions (process_slots, process_block)
- XMSS signature verification and aggregation
- SSZ encoding/decoding correctness

Be concise and specific. Provide line references when suggesting changes.
If the code looks good, acknowledge it briefly.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Rust
uses: dtolnay/rust-toolchain@master
Expand All @@ -45,7 +45,7 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Download test fixtures
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/pr_review_chatgpt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: PR Review - ChatGPT

on:
pull_request:
types: [opened, synchronize, reopened]
pull_request_review_comment:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General Feedback

The PR adds a new environment variable MAX_PATCH_LENGTH: 100000. This addition is not related to the core functionalities typically reviewed for consensus clients such as EthLambda. As such, the feedback will focus on the correctness of the integration, potential implications, and overall impact on system performance.

Code Correctness and Potential Bugs

  1. MAX_PATCH_LENGTH: Consider checking how this variable is used within the codebase. Ensure it does not cause unexpected behavior due to assumptions about input sizes. Large values could potentially interfere with memory allocation or performance where this parameter is utilized.

Security Vulnerabilities

  • No direct code handling Ethereum's core functionalities (e.g., fork choice, state transition) is seen in this PR snippet. Ensure that any environment variable like MAX_PATCH_LENGTH doesn't expose the system to buffer overflow or similar vulnerabilities by focusing on well-defined limits and ensuring safe handling of environment variables.

Performance Implications

  • Increasing MAX_PATCH_LENGTH to 100000 may have performance implications depending on how it's used. If it leads to larger allocations or more processing, you may experience performance degradation. Profile or test this change to ensure it doesn't negatively affect critical paths.

Rust Best Practices and Idiomatic Patterns

  • The snippet reviewed doesn't reveal Rust-specific implementation details ... Ensure that any change interacts with the Rust code in an idiomatic way, using the borrow checker and taking advantage of Rust's ownership model.

Memory Safety and Error Handling

  • As this change concerns an environment variable's integration, ensure that all environment variable accesses are safely handled using functions like std::env::var and proper error handling with Result types.

Code Readability and Maintainability

  • The small snippet provided demonstrates good readability in YAML formatting. Ensure the entirety of the code base maintains high standards of readability and that this variable is documented accordingly, giving context to its purpose.

Final Considerations

Without the rest of the codebase, it's crucial to analyze further how this change interacts with process_slots, process_block, or other core functions. Testing high-load scenarios will help determine if MAX_PATCH_LENGTH impacts memory consumption or processing times.

In conclusion, while this change is isolated, ensuring it integrates smoothly with the broader system operationally and performance-wise is crucial.

types: [created]
issue_comment:
types: [created]

permissions:
contents: read
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
chatgpt-review:
name: ChatGPT Code Review
if: |
github.event_name == 'pull_request' ||
(github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@chatgpt')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@chatgpt'))
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Read review prompt
id: prompt
run: |
PROMPT=$(cat .github/prompts/pr_review.md)
echo "content<<EOF" >> $GITHUB_OUTPUT
echo "$PROMPT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: ChatGPT Code Review
uses: anc95/ChatGPT-CodeReview@6fdbaeafc6f9e0eaebb844f8cfafff67cb2947f0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Comments

Code Correctness & Potential Bugs

  • The transition from using openai/codex-action to anc95/ChatGPT-CodeReview should ensure that the correct environment variables and API configurations are maintained. Verify that OPENAI_API_KEY is properly scoped and won't hit request limits inadvertently due to any possible misconfiguration.

Security Vulnerabilities

  • Storing secrets such as OPENAI_API_KEY and GITHUB_TOKEN in GitHub Actions is a common practice, but it's crucial to ensure these secrets are not exposed or logged in the output. Always review the action logs for any accidental secret disclosure.

Performance Implications

  • Using the anc95/ChatGPT-CodeReview action appears simpler, but review the performance implications such as API response time especially with the increase in model complexity. Ensure that usage fits within any rate limits imposed by OpenAI.

Rust Best Practices & Idiomatic Patterns

  • This PR only modifies the GitHub Actions workflow without any Rust code change. Therefore, no Rust-specific idiomatic patterns were assessed.

Memory Safety & Proper Error Handling

  • Ensure that there is appropriate error handling and logging around API calls, especially during network failure or unexpected responses from the API.

Code Readability & Maintainability

  • The PR improves maintainability by simplifying the actions, however, please add comments to describe the high-level steps of the new workflow for easier understanding to other maintainers.

Consensus-layer Considerations

  • Since this PR only affects GitHub Actions, consensus-layer considerations such as fork choice correctness and attestation processing do not apply here. However, make sure changes do not disrupt any existing release workflows critical for these components.

Overall, this PR introduces a cleaner and potentially more effective way to handle code reviews via automated workflows. Please ensure all preconditions (e.g., the existence of files and correct secrets configuration) are thoroughly checked and validated prior to merging.

OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
MODEL: gpt-4o
LANGUAGE: English
MAX_PATCH_LENGTH: 100000
max_tokens: 4096
PROMPT: ${{ steps.prompt.outputs.content }}
49 changes: 49 additions & 0 deletions .github/workflows/pr_review_claude.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: PR Review - Claude

on:
pull_request:
types: [opened, synchronize, reopened]
pull_request_review_comment:
types: [created]
issue_comment:
types: [created]

permissions:
contents: read
pull-requests: write
issues: write
id-token: write

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
claude-review:
name: Claude Code Review
if: |
github.event_name == 'pull_request' ||
(github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude'))
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Read review prompt
id: prompt
run: |
PROMPT=$(cat .github/prompts/pr_review.md)
echo "content<<EOF" >> $GITHUB_OUTPUT
echo "$PROMPT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Claude Code Review
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
claude_args: |
--max-turns 5
--model claude-sonnet-4-20250514
trigger_phrase: "@claude"
prompt: ${{ steps.prompt.outputs.content }}
113 changes: 113 additions & 0 deletions .github/workflows/pr_review_kimi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: PR Review - Kimi

on:
pull_request:
types: [opened, synchronize, reopened]
pull_request_review_comment:
types: [created]
issue_comment:
types: [created]

permissions:
contents: read
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
kimi-review:
name: Kimi Code Review
if: |
github.event_name == 'pull_request' ||
(github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@kimi')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@kimi'))
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Read review prompt
id: prompt
run: |
PROMPT=$(cat .github/prompts/pr_review.md)
echo "content<<EOF" >> $GITHUB_OUTPUT
echo "$PROMPT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Get PR diff
id: diff
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr diff ${{ github.event.pull_request.number }} > pr_diff.txt
# Truncate if too large (Kimi has context limits)
head -c 100000 pr_diff.txt > pr_diff_truncated.txt

- name: Kimi Code Review
id: kimi_review
env:
KIMI_API_KEY: ${{ secrets.KIMI_API_KEY }}
PR_TITLE: ${{ github.event.pull_request.title }}
REVIEW_PROMPT: ${{ steps.prompt.outputs.content }}
run: |
if [ -z "$KIMI_API_KEY" ]; then
echo "Error: KIMI_API_KEY secret is not set" > kimi_review.txt
exit 0
fi

DIFF_CONTENT=$(cat pr_diff_truncated.txt)

# Build the request body
REQUEST_BODY=$(jq -n \
--arg diff "$DIFF_CONTENT" \
--arg title "$PR_TITLE" \
--arg prompt "$REVIEW_PROMPT" \
'{
"model": "moonshot-v1-128k",
"messages": [
{
"role": "system",
"content": $prompt
},
{
"role": "user",
"content": ("PR Title: " + $title + "\n\nDiff:\n" + $diff)
}
],
"temperature": 0.3,
"max_tokens": 4096
}')

# Try the API call
HTTP_RESPONSE=$(curl -s -w "\n%{http_code}" https://api.moonshot.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $KIMI_API_KEY" \
-d "$REQUEST_BODY")

HTTP_CODE=$(echo "$HTTP_RESPONSE" | tail -n1)
RESPONSE=$(echo "$HTTP_RESPONSE" | sed '$d')

if [ "$HTTP_CODE" != "200" ]; then
echo "API Error (HTTP $HTTP_CODE): $RESPONSE" > kimi_review.txt
else
# Check for API errors in response
ERROR=$(echo "$RESPONSE" | jq -r '.error.message // empty')
if [ -n "$ERROR" ]; then
echo "API Error: $ERROR" > kimi_review.txt
else
REVIEW=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // "Error: Unexpected API response"')
echo "$REVIEW" > kimi_review.txt
fi
fi

- name: Post review comment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "<details><summary><h2>Kimi AI Code Review</h2></summary>" > body.md
cat kimi_review.txt >> body.md
echo -e "\n---\n*Automated review by Kimi (Moonshot AI)*\n</details>" >> body.md

gh pr comment ${{ github.event.pull_request.number }} --body-file body.md
Loading
Loading