mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-10 14:38:18 -05:00
Co-authored-by: colinlyguo <colinlyguo@users.noreply.github.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
83 lines
2.3 KiB
Go
83 lines
2.3 KiB
Go
package version
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime/debug"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
var tag = "v4.2.8"
|
|
|
|
var commit = func() string {
|
|
if info, ok := debug.ReadBuildInfo(); ok {
|
|
for _, setting := range info.Settings {
|
|
if setting.Key == "vcs.revision" {
|
|
value := setting.Value
|
|
if len(value) >= 7 {
|
|
return value[:7]
|
|
}
|
|
return value
|
|
}
|
|
}
|
|
}
|
|
// Set default value for integration test.
|
|
return "000000"
|
|
}()
|
|
|
|
// ZkVersion is commit-id of common/libzkp/impl/cargo.lock/scroll-prover and halo2, contacted by a "-"
|
|
// The default `000000-000000` is set for integration test, and will be overwritten by coordinator's & prover's actual compilations (see their Makefiles).
|
|
var ZkVersion = "000000-000000"
|
|
|
|
// Version denote the version of scroll protocol, including the l2geth, relayer, coordinator, prover, contracts and etc.
|
|
var Version = fmt.Sprintf("%s-%s-%s", tag, commit, ZkVersion)
|
|
|
|
// CheckScrollProverVersion check the "scroll-prover" version, if it's different from the local one, return false
|
|
func CheckScrollProverVersion(proverVersion string) bool {
|
|
// note the 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, "-")
|
|
if len(remote) != 4 {
|
|
return false
|
|
}
|
|
local := strings.Split(Version, "-")
|
|
if len(local) != 4 {
|
|
return false
|
|
}
|
|
// compare the `scroll_prover` version
|
|
return remote[2] == local[2]
|
|
}
|
|
|
|
// CheckScrollProverVersionTag check the "scroll-prover" version's tag, if it's too old, return false
|
|
func CheckScrollProverVersionTag(proverVersion string) bool {
|
|
// note the 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, "-")
|
|
if len(remote) != 4 {
|
|
return false
|
|
}
|
|
remoteTagNums := strings.Split(strings.TrimPrefix(remote[0], "v"), ".")
|
|
if len(remoteTagNums) != 3 {
|
|
return false
|
|
}
|
|
remoteTagMajor, err := strconv.Atoi(remoteTagNums[0])
|
|
if err != nil {
|
|
return false
|
|
}
|
|
remoteTagMinor, err := strconv.Atoi(remoteTagNums[1])
|
|
if err != nil {
|
|
return false
|
|
}
|
|
remoteTagPatch, err := strconv.Atoi(remoteTagNums[2])
|
|
if err != nil {
|
|
return false
|
|
}
|
|
if remoteTagMajor < 4 {
|
|
return false
|
|
}
|
|
if remoteTagMinor == 1 && remoteTagPatch < 98 {
|
|
return false
|
|
}
|
|
return true
|
|
}
|