diff --git a/.github/workflows/coordinator.yml b/.github/workflows/coordinator.yml index 81ff42453..31001ffd8 100644 --- a/.github/workflows/coordinator.yml +++ b/.github/workflows/coordinator.yml @@ -32,7 +32,7 @@ jobs: uses: actions/checkout@v2 - name: Lint run: | - rm -rf $HOME/.cache/golangci-lint + rm -rf $HOME/.cache/golangci-lint make lint goimports-lint: runs-on: ubuntu-latest diff --git a/.github/workflows/roller.yml b/.github/workflows/roller.yml index 15604f17f..3b0b29c54 100644 --- a/.github/workflows/roller.yml +++ b/.github/workflows/roller.yml @@ -78,7 +78,7 @@ jobs: uses: actions/checkout@v2 - name: Install goimports run: go install golang.org/x/tools/cmd/goimports - - run: goimports -local scroll-tech/go-roller/ -w . + - run: goimports -local scroll-tech/roller/ -w . - run: go mod tidy # If there are any diffs from goimports or go mod tidy, fail. - name: Verify no changes from goimports and go mod tidy diff --git a/common/message/message.go b/common/message/message.go index 76a4d7d82..2afc32ed0 100644 --- a/common/message/message.go +++ b/common/message/message.go @@ -64,6 +64,9 @@ type Identity struct { Timestamp int64 `json:"timestamp"` // Roller public key PublicKey string `json:"publicKey"` + // Version is common.Version+ZK_VERSION. Use the following to check the latest ZK_VERSION version. + // curl -sL https://api.github.com/repos/scroll-tech/common-rs/commits | jq -r ".[0].sha" + Version string `json:"version"` } // Sign auth message diff --git a/coordinator/api.go b/coordinator/api.go index 0cd3249fe..711eb8fa8 100644 --- a/coordinator/api.go +++ b/coordinator/api.go @@ -10,6 +10,7 @@ import ( // RollerInfo records the roller name, pub key and active session info (id, start time). type RollerInfo struct { Name string `json:"name"` + Version string `json:"version"` PublicKey string `json:"public_key"` ActiveSession uint64 `json:"active_session,omitempty"` ActiveSessionStartTime time.Time `json:"active_session_start_time"` // latest proof start time. @@ -42,6 +43,7 @@ func (m *Manager) ListRollers() ([]*RollerInfo, error) { pk := roller.AuthMsg.Identity.PublicKey info := &RollerInfo{ Name: roller.AuthMsg.Identity.Name, + Version: roller.AuthMsg.Identity.Version, PublicKey: pk, } for id, sess := range m.sessions { diff --git a/coordinator/server.go b/coordinator/server.go index 71a989cfc..4b3831203 100644 --- a/coordinator/server.go +++ b/coordinator/server.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "net/http" - "scroll-tech/common/message" "sync" "sync/atomic" "time" @@ -14,6 +13,8 @@ import ( "github.com/scroll-tech/go-ethereum/common" "github.com/scroll-tech/go-ethereum/crypto" "github.com/scroll-tech/go-ethereum/log" + + "scroll-tech/common/message" ) const ( @@ -224,7 +225,7 @@ func (s *server) handshake(c *websocket.Conn) (*message.AuthMessage, error) { if !crypto.VerifySignature(common.FromHex(authMsg.Identity.PublicKey), hash, common.FromHex(authMsg.Signature)[:64]) { return nil, errors.New("signature verification failed") } - log.Info("signature verification successfully", "roller name", authMsg.Identity.Name) + log.Info("signature verification successfully", "roller name", authMsg.Identity.Name, "version", authMsg.Identity.Version) return authMsg, nil } diff --git a/coordinator/verifier/verifier_test.go b/coordinator/verifier/verifier_test.go index 0b4e9f2b8..5ed0c18af 100644 --- a/coordinator/verifier/verifier_test.go +++ b/coordinator/verifier/verifier_test.go @@ -3,11 +3,11 @@ package verifier_test import ( "testing" - "scroll-tech/common/message" - "github.com/scroll-tech/go-ethereum/common" "github.com/scroll-tech/go-ethereum/crypto" "github.com/stretchr/testify/assert" + + "scroll-tech/common/message" ) // skipped due to verifier upgrade @@ -52,6 +52,7 @@ func TestVerifier(t *testing.T) { Name: "scroll_roller", Timestamp: 1649663001, PublicKey: common.Bytes2Hex(pubkey), + Version: "some_version", } hash, err := msg.Hash() assert.NoError(t, err) diff --git a/roller/.gitignore b/roller/.gitignore index 5e04b336c..395b8a088 100644 --- a/roller/.gitignore +++ b/roller/.gitignore @@ -7,7 +7,7 @@ build/bin/ bbolt_db # ignore cgo in macOS -core/prover/lib/libprover.dylib +core/prover/lib/libprover.a core/prover/rust/target params/ diff --git a/roller/Makefile b/roller/Makefile index 9fc92842d..12d59f6e2 100644 --- a/roller/Makefile +++ b/roller/Makefile @@ -3,16 +3,18 @@ IMAGE_NAME=go-roller IMAGE_VERSION=latest +ZK_VERSION=$(shell grep -m 1 "common-rs" core/prover/rust/Cargo.lock | cut -d "\#" -f2 | cut -c-7) + libprover: cd core/prover/rust && cargo build --release && cp target/release/libprover.a ../lib/ roller: ## Build the Roller instance. cd core/prover/rust && cargo build --release && cp target/release/libprover.a ../lib/ - GOBIN=$(PWD)/build/bin go build -o $(PWD)/build/bin/roller ./cmd + GOBIN=$(PWD)/build/bin go build -ldflags "-X core.ZK_VERSION=${ZK_VERSION}" -o $(PWD)/build/bin/roller ./cmd gpu-roller: ## Build the GPU Roller instance. cd core/prover/rust && cargo build --release && cp target/release/libprover.a ../lib/ - GOBIN=$(PWD)/build/bin go build -tags gpu -o $(PWD)/build/bin/roller ./cmd + GOBIN=$(PWD)/build/bin go build -ldflags "-X core.ZK_VERSION=${ZK_VERSION}" -tags gpu -o $(PWD)/build/bin/roller ./cmd test-prover: go test -timeout 0 -v ./core/prover @@ -20,6 +22,9 @@ test-prover: test-gpu-prover: go test -tags gpu -timeout 0 -v ./core/prover +lastest-zk-version: + curl -sL https://api.github.com/repos/scroll-tech/common-rs/commits | jq -r ".[0].sha" + lint: ## Lint the files - used for CI GOBIN=$(PWD)/build/bin go run ../build/lint.go diff --git a/roller/cmd/main.go b/roller/cmd/main.go index 865fda120..d324af3d7 100644 --- a/roller/cmd/main.go +++ b/roller/cmd/main.go @@ -8,10 +8,9 @@ import ( "github.com/urfave/cli/v2" "scroll-tech/common/utils" - "scroll-tech/common/version" - "scroll-tech/go-roller/config" - "scroll-tech/go-roller/core" + "scroll-tech/roller/config" + "scroll-tech/roller/core" ) var ( @@ -43,7 +42,7 @@ func main() { app.Action = action app.Name = "Roller" app.Usage = "The Scroll L2 Roller" - app.Version = version.Version + app.Version = core.Version app.Flags = append(app.Flags, []cli.Flag{ &cfgFileFlag, &logFileFlag, @@ -76,7 +75,7 @@ func action(ctx *cli.Context) error { return err } defer r.Close() - log.Info("go-roller start successfully", "name", cfg.RollerName) + log.Info("roller start successfully", "name", cfg.RollerName) return r.Run() } diff --git a/roller/core/prover/prover.go b/roller/core/prover/prover.go index 4a61fa492..289a4fe69 100644 --- a/roller/core/prover/prover.go +++ b/roller/core/prover/prover.go @@ -16,7 +16,7 @@ import ( "scroll-tech/common/message" - "scroll-tech/go-roller/config" + "scroll-tech/roller/config" ) // Prover sends block-traces to rust-prover through socket and get back the zk-proof. diff --git a/roller/core/prover/prover_test.go b/roller/core/prover/prover_test.go index f4ab31e80..a12d3dbca 100644 --- a/roller/core/prover/prover_test.go +++ b/roller/core/prover/prover_test.go @@ -9,8 +9,8 @@ import ( "github.com/scroll-tech/go-ethereum/core/types" "github.com/stretchr/testify/assert" - "scroll-tech/go-roller/config" - "scroll-tech/go-roller/core/prover" + "scroll-tech/roller/config" + "scroll-tech/roller/core/prover" ) type RPCTrace struct { diff --git a/roller/core/prover/rust/Cargo.toml b/roller/core/prover/rust/Cargo.toml index d529d0261..3ff8ac7c7 100644 --- a/roller/core/prover/rust/Cargo.toml +++ b/roller/core/prover/rust/Cargo.toml @@ -8,8 +8,8 @@ edition = "2021" crate-type = ["staticlib", "cdylib"] [dependencies] -zkevm = { git = "https://github.com/scroll-tech/common-rs"} -types = { git = "https://github.com/scroll-tech/common-rs"} +zkevm = { git = "https://github.com/scroll-tech/common-rs" } +types = { git = "https://github.com/scroll-tech/common-rs" } log = "0.4" serde = "1.0" diff --git a/roller/core/roller.go b/roller/core/roller.go index 1f3103fb0..34d115cf4 100644 --- a/roller/core/roller.go +++ b/roller/core/roller.go @@ -18,11 +18,18 @@ import ( "github.com/scroll-tech/go-ethereum/crypto" "github.com/scroll-tech/go-ethereum/log" - message "scroll-tech/common/message" + "scroll-tech/common/message" + "scroll-tech/common/version" - "scroll-tech/go-roller/config" - "scroll-tech/go-roller/core/prover" - "scroll-tech/go-roller/store" + "scroll-tech/roller/config" + "scroll-tech/roller/core/prover" + "scroll-tech/roller/store" +) + +// ZK_VERSION is commit-id of prover/rust/cargo.lock/common-rs +var ( + ZK_VERSION string + Version = fmt.Sprintf("%s-%s", version.Version, ZK_VERSION) ) var ( @@ -102,6 +109,7 @@ func (r *Roller) Register() error { Name: r.cfg.RollerName, Timestamp: time.Now().UnixMilli(), PublicKey: common.Bytes2Hex(crypto.FromECDSAPub(&priv.PublicKey)), + Version: Version, }, Signature: "", } diff --git a/roller/go.mod b/roller/go.mod index 5a53148af..302cb4fdf 100644 --- a/roller/go.mod +++ b/roller/go.mod @@ -1,4 +1,4 @@ -module scroll-tech/go-roller +module scroll-tech/roller go 1.18 diff --git a/roller/mock/mock_test.go b/roller/mock/mock_test.go index 11e648641..00babbe77 100644 --- a/roller/mock/mock_test.go +++ b/roller/mock/mock_test.go @@ -17,8 +17,8 @@ import ( message "scroll-tech/common/message" - "scroll-tech/go-roller/config" - "scroll-tech/go-roller/core" + "scroll-tech/roller/config" + "scroll-tech/roller/core" ) var (