Skip to content
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

chore: add verify-script for checking validator migration proofs #218

Merged
merged 10 commits into from
Jan 8, 2025

Conversation

mbreithecker
Copy link
Member

@mbreithecker mbreithecker commented Dec 30, 2024

Summary by CodeRabbit

  • New Features

    • Added a new GitHub Actions workflow for verifying migration proofs
    • Introduced a verification script to validate transactions and validator proofs
  • Documentation

    • Updated README with clearer instructions for validator linking
    • Added guidance on checking GitHub action verification status
  • Chores

    • Removed example validator configuration files for Kaon and mainnet networks

Copy link

coderabbitai bot commented Dec 30, 2024

Walkthrough

This pull request introduces a comprehensive migration proof verification mechanism for blockchain validators. A new GitHub Actions workflow has been added to .github/workflows/all.yml that calls a migration workflow. The migration workflow runs a Python script verify.py to validate transactions and validator proofs across two networks: Kaon and Mainnet. The process involves checking transaction details, verifying consensus and protocol validators, and ensuring the correctness of migration-related transactions.

Changes

File Change Summary
.github/workflows/all.yml Added new job verify-migration-proofs to execute migration proof verification
.github/workflows/migration.yml New workflow to run migration proof verification script
app/upgrades/v2_0/validator-proofs/Readme.md Updated instructions for validator linking, added verification step
app/upgrades/v2_0/validator-proofs/kaon/example-validator.json Removed example validator configuration
app/upgrades/v2_0/validator-proofs/mainnet/example-validator.json Removed example validator configuration
app/upgrades/v2_0/validator-proofs/verify.py New script with functions to verify transactions and validator proofs

Sequence Diagram

sequenceDiagram
    participant GHA as GitHub Actions
    participant Script as verify.py
    participant API as Blockchain API
    
    GHA->>Script: Trigger verification
    Script->>Script: Load validator configs
    Script->>API: Verify Transaction 1
    API-->>Script: Return Transaction Details
    Script->>API: Verify Transaction 2
    API-->>Script: Return Transaction Details
    Script->>Script: Compile Verification Results
    Script-->>GHA: Return Verification Status
Loading

Possibly related PRs

Suggested reviewers

  • troykessler

Poem

🐰 Validators dance, proofs in hand,
GitHub Actions weave their command.
Transactions verified with care,
Migration's path, now crystal clear!
Code hops forward, no delay! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mbreithecker mbreithecker marked this pull request as ready for review January 8, 2025 09:35
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (6)
app/upgrades/v2_0/validator-proofs/verify.py (2)

10-10: Specify timeouts for HTTP requests

When making HTTP requests, it's good practice to specify a timeout to prevent the script from hanging indefinitely in case of network issues.

Apply this diff to set a timeout for the requests:

 def verify_tx(api_endpoint, tx_hash, expect_from_address, expect_to_address):
-    x = requests.get(api_endpoint + "/cosmos/tx/v1beta1/txs/" + tx_hash)
+    x = requests.get(api_endpoint + "/cosmos/tx/v1beta1/txs/" + tx_hash, timeout=10)

 def verify_proof(api_endpoint, entry):
-    x = requests.get(api_endpoint + "/cosmos/staking/v1beta1/validators/" + entry["consensus_address"])
+    x = requests.get(api_endpoint + "/cosmos/staking/v1beta1/validators/" + entry["consensus_address"], timeout=10)

-    x = requests.get(api_endpoint + "/kyve/query/v1beta1/staker/" + entry["protocol_address"])
+    x = requests.get(api_endpoint + "/kyve/query/v1beta1/staker/" + entry["protocol_address"], timeout=10)

Also applies to: 28-28, 32-32


52-55: Provide more informative error logging

When catching exceptions, consider logging more detailed information to assist with debugging. Currently, only the exception is printed. Including the stack trace can be helpful.

Apply this diff to improve error logging:

         except Exception as e:
             print("[{}]".format(name.title()), file, "❌")
-            print(e)
+            import traceback
+            traceback.print_exc()
             status["error"] += 1
.github/workflows/migration.yml (3)

17-17: Add a newline at the end of the file

The file is missing a newline character at the end, which can cause issues in some systems or tools that expect a terminating newline.

🧰 Tools
🪛 yamllint (1.35.1)

[error] 17-17: no new line character at the end of file

(new-line-at-end-of-file)


13-14: Pin dependency versions for reproducibility

To ensure consistent and reproducible builds, it's recommended to specify exact versions for dependencies.

Apply this diff to pin the dependency versions:

       - name: Install dependencies
-        run: pip3 install bech32 requests
+        run: pip3 install bech32==1.2.0 requests==2.31.0

Alternatively, consider using a requirements.txt file to manage dependencies.


7-11: Specify the Python version for consistency

To ensure the workflow runs with the expected Python version, consider adding a step to set up Python using actions/setup-python.

Apply this diff to specify the Python version:

     jobs:
       test:
           runs-on: ubuntu-latest
+          steps:
+            - name: Set up Python 3.8
+              uses: actions/setup-python@v4
+              with:
+                python-version: '3.8'
           steps:
             # Checkout the repository

This ensures that the script runs in a consistent Python environment across different runs.

app/upgrades/v2_0/validator-proofs/Readme.md (1)

21-24: Enhance security guidance for transactions.

Consider adding important security notes:

  1. Verify transaction amounts and addresses before sending
  2. Document recovery procedures for failed transactions
  3. Add a warning about potential scams/phishing attempts
🧰 Tools
🪛 Markdownlint (0.37.0)

24-24: null
Bare URL used

(MD034, no-bare-urls)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f60c1e and 264fb3f.

📒 Files selected for processing (6)
  • .github/workflows/all.yml (1 hunks)
  • .github/workflows/migration.yml (1 hunks)
  • app/upgrades/v2_0/validator-proofs/Readme.md (1 hunks)
  • app/upgrades/v2_0/validator-proofs/kaon/example-validator.json (0 hunks)
  • app/upgrades/v2_0/validator-proofs/mainnet/example-validator.json (0 hunks)
  • app/upgrades/v2_0/validator-proofs/verify.py (1 hunks)
💤 Files with no reviewable changes (2)
  • app/upgrades/v2_0/validator-proofs/mainnet/example-validator.json
  • app/upgrades/v2_0/validator-proofs/kaon/example-validator.json
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/migration.yml

[error] 17-17: no new line character at the end of file

(new-line-at-end-of-file)

🪛 Markdownlint (0.37.0)
app/upgrades/v2_0/validator-proofs/Readme.md

14-14: Column: 4
Hard tabs

(MD010, no-hard-tabs)


24-24: null
Bare URL used

(MD034, no-bare-urls)

🪛 Ruff (0.8.2)
app/upgrades/v2_0/validator-proofs/verify.py

47-47: Use a context manager for opening files

(SIM115)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test / test
  • GitHub Check: Summary
🔇 Additional comments (1)
.github/workflows/all.yml (1)

5-6: LGTM!

The new job verify-migration-proofs is correctly added and utilizes the migration.yml workflow appropriately.

@mbreithecker mbreithecker merged commit 5941397 into main Jan 8, 2025
5 checks passed
@mbreithecker mbreithecker deleted the mbreithecker/verify-script branch January 8, 2025 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants