mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-10 06:28:04 -05:00
feat: add version info in roller handshake (#60)
Co-authored-by: Steven Gu <steven.gu@crypto.com> Co-authored-by: HAOYUatHZ <haoyu@protonmail.com>
This commit is contained in:
2
.github/workflows/coordinator.yml
vendored
2
.github/workflows/coordinator.yml
vendored
@@ -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
|
||||
|
||||
2
.github/workflows/roller.yml
vendored
2
.github/workflows/roller.yml
vendored
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
2
roller/.gitignore
vendored
2
roller/.gitignore
vendored
@@ -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/
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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: "",
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module scroll-tech/go-roller
|
||||
module scroll-tech/roller
|
||||
|
||||
go 1.18
|
||||
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user