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
Open
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
20 changes: 20 additions & 0 deletions common/version/prover_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (

// CheckScrollProverVersion check the "scroll-prover" version, if it's different from the local one, return false
func CheckScrollProverVersion(proverVersion string) bool {
if strings.HasPrefix(proverVersion, "sdk") {
return CheckProverSDKVersion(proverVersion)
}

// note the version is in fact in the format of "tag-commit-scroll_prover-halo2",
// so split-by-'-' length should be 4
remote := strings.Split(proverVersion, "-")
Expand All @@ -23,8 +27,18 @@ func CheckScrollProverVersion(proverVersion string) bool {
return remote[2] == local[2]
}

// CheckProverSDKVersion check prover sdk version, it simply returns true for now,
// and more checks will be added as we evolve.
func CheckProverSDKVersion(proverVersion string) bool {
return true
}

// CheckScrollRepoVersion checks if the proverVersion is at least the minimum required version.
func CheckScrollRepoVersion(proverVersion, minVersion string) bool {
if strings.HasPrefix(proverVersion, "sdk") {
return CheckProverSDKWithMinVersion(proverVersion, minVersion)
}
Comment on lines +38 to +40
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)
}


c, err := semver.NewConstraint(">= " + minVersion + "-0")
if err != nil {
log.Error("failed to initialize constraint", "minVersion", minVersion, "error", err)
Expand All @@ -39,3 +53,9 @@ func CheckScrollRepoVersion(proverVersion, minVersion string) bool {

return c.Check(v)
}

// 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
}
Comment on lines +57 to +61
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.

2 changes: 1 addition & 1 deletion common/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"runtime/debug"
)

var tag = "v4.4.70"
var tag = "v4.4.71"

var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
Expand Down