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

feat(coordinator): add version check for sdk provers #1551

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

0xmountaintop
Copy link
Member

@0xmountaintop 0xmountaintop commented Oct 24, 2024

Purpose or design rationale of this PR

Currently the sdk-provers are hard to get the "repo" commit hash and hard to follow the version check we are using in coordinator now: see https://github.com/scroll-tech/scroll-proving-sdk/blob/haoyu/sindri_tokio/src/utils.rs#L5-L9, we have to hardcode a version to bypass the version check for now.

This PR add a dedicated version check mechanism for sdk-prover. And it simply returns true for now.

PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • build: Changes that affect the build system or external dependencies (example scopes: yarn, eslint, typescript)
  • ci: Changes to our CI configuration files and scripts (example scopes: vercel, github, cypress)
  • docs: Documentation-only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that doesn't fix a bug, or add a feature, or improves performance
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • test: Adding missing tests or correcting existing tests

Deployment tag versioning

Has tag in common/version.go been updated or have you added bump-version label to this PR?

  • No, this PR doesn't involve a new deployment, git tag, docker image tag
  • Yes

Breaking change label

Does this PR have the breaking-change label?

  • No, this PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • New Features

    • Introduced new functions for enhanced SDK version handling in the prover.
    • Added specific checks for SDK versions in existing version validation logic.
  • Bug Fixes

    • Updated versioning information to reflect the new version number (v4.4.71).

These changes improve the application's capability to manage SDK versions while ensuring existing functionalities remain intact.

Copy link

coderabbitai bot commented Oct 24, 2024

Walkthrough

The changes introduce new functionality for handling SDK versions in the common/version/prover_version.go file by adding two methods: CheckProverSDKVersion and CheckProverSDKWithMinVersion. Both methods currently return true for any input, with future enhancements planned. The CheckScrollProverVersion and CheckScrollRepoVersion methods are updated to utilize these new functions when the proverVersion string starts with "sdk". Additionally, the version number in common/version/version.go is incremented from "v4.4.70" to "v4.4.71".

Changes

File Path Change Summary
common/version/prover_version.go Added methods: CheckProverSDKVersion and CheckProverSDKWithMinVersion, both returning true. Updated CheckScrollProverVersion and CheckScrollRepoVersion to call new methods for SDK versions.
common/version/version.go Updated variable tag from "v4.4.70" to "v4.4.71" to reflect the new version number.

Poem

In the burrow, changes bloom,
New SDK checks dispel the gloom.
Version tags now rise anew,
Hop along, the code's in view!
With each tweak, we grow and play,
A brighter path, hip-hip-hooray! 🐇✨


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 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.

@0xmountaintop 0xmountaintop added the bump-version Bump the version tag for deployment label Oct 24, 2024
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: 2

🧹 Outside diff range and nitpick comments (1)
common/version/prover_version.go (1)

30-34: Add tracking and detailed documentation for future SDK version checks.

The current implementation is a placeholder that accepts all SDK versions. To ensure this doesn't remain as technical debt:

  1. Document the expected format of SDK versions
  2. Add a TODO with specific checks that will be implemented
  3. Create a tracking issue for the implementation

Would you like me to help create a GitHub issue to track the implementation of SDK version validation?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between bc8f9db and 71b3fc8.

📒 Files selected for processing (2)
  • common/version/prover_version.go (3 hunks)
  • common/version/version.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • common/version/version.go
🔇 Additional comments (1)
common/version/prover_version.go (1)

12-14: Verify the implications of accepting all SDK versions.

While the implementation is clean, accepting all SDK versions without validation could potentially lead to compatibility issues. Consider adding validation logic or logging when SDK versions are encountered to track usage patterns.

Consider adding structured logging to track SDK version usage:

 if strings.HasPrefix(proverVersion, "sdk") {
+    log.Info("Processing SDK prover version", "version", proverVersion)
     return CheckProverSDKVersion(proverVersion)
 }

Comment on lines +38 to +40
if strings.HasPrefix(proverVersion, "sdk") {
return CheckProverSDKWithMinVersion(proverVersion, minVersion)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add validation for minVersion format in SDK version checks.

The current implementation skips semver validation for SDK versions. Consider:

  1. Validating the minVersion format even for SDK versions
  2. Documenting the expected format for SDK version constraints
 if strings.HasPrefix(proverVersion, "sdk") {
+    if !strings.HasPrefix(minVersion, "sdk") {
+        log.Error("incompatible version formats", "proverVersion", proverVersion, "minVersion", minVersion)
+        return false
+    }
     return CheckProverSDKWithMinVersion(proverVersion, minVersion)
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if strings.HasPrefix(proverVersion, "sdk") {
return CheckProverSDKWithMinVersion(proverVersion, minVersion)
}
if strings.HasPrefix(proverVersion, "sdk") {
if !strings.HasPrefix(minVersion, "sdk") {
log.Error("incompatible version formats", "proverVersion", proverVersion, "minVersion", minVersion)
return false
}
return CheckProverSDKWithMinVersion(proverVersion, minVersion)
}

Comment on lines +57 to +61
// CheckProverSDKWithMinVersion check prover sdk version is at least the minimum required version, it simply returns true for now,
// and more checks will be added as we evolve.
func CheckProverSDKWithMinVersion(proverVersion string, minVersion string) bool {
return true
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Implement basic version comparison for SDK versions.

The current implementation accepts any version combination, which could lead to compatibility issues. Consider implementing basic version comparison:

  1. Validate input parameters
  2. Parse and compare SDK version numbers

Here's a suggested implementation:

 func CheckProverSDKWithMinVersion(proverVersion string, minVersion string) bool {
-    return true
+    if !strings.HasPrefix(proverVersion, "sdk") || !strings.HasPrefix(minVersion, "sdk") {
+        log.Error("invalid SDK version format", "proverVersion", proverVersion, "minVersion", minVersion)
+        return false
+    }
+    
+    // Extract version numbers (assuming format sdk-x.y.z)
+    proverParts := strings.Split(proverVersion, "-")
+    minParts := strings.Split(minVersion, "-")
+    if len(proverParts) != 2 || len(minParts) != 2 {
+        log.Error("invalid SDK version format", "proverVersion", proverVersion, "minVersion", minVersion)
+        return false
+    }
+    
+    proverSemver, err1 := semver.NewVersion(proverParts[1])
+    minSemver, err2 := semver.NewVersion(minParts[1])
+    if err1 != nil || err2 != nil {
+        log.Error("invalid semver in SDK version", "error1", err1, "error2", err2)
+        return false
+    }
+    
+    return proverSemver.Compare(minSemver) >= 0
 }

Committable suggestion was skipped due to low confidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump-version Bump the version tag for deployment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant