mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-04-23 03:00:50 -04:00
address comments
This commit is contained in:
@@ -17,14 +17,10 @@ type CoordinatorClient struct {
|
||||
|
||||
// NewCoordinatorClient constructs a new CoordinatorClient.
|
||||
func NewCoordinatorClient(cfg *config.CoordinatorConfig) (*CoordinatorClient, error) {
|
||||
if cfg.BaseURL == "" {
|
||||
return nil, fmt.Errorf("base URL is not specified")
|
||||
}
|
||||
|
||||
client := resty.New().
|
||||
SetTimeout(time.Duration(cfg.Timeout) * time.Second).
|
||||
SetTimeout(time.Duration(cfg.ConnectionTimeoutSec) * time.Second).
|
||||
SetRetryCount(cfg.RetryCount).
|
||||
SetRetryWaitTime(time.Duration(cfg.RetryWaitTime) * time.Second).
|
||||
SetRetryWaitTime(time.Duration(cfg.RetryWaitTimeSec) * time.Second).
|
||||
SetBaseURL(cfg.BaseURL)
|
||||
|
||||
return &CoordinatorClient{
|
||||
|
||||
@@ -29,13 +29,9 @@ type GetTaskRequest struct {
|
||||
|
||||
// GetTaskResponse defines the response structure for GetTask API
|
||||
type GetTaskResponse struct {
|
||||
ErrCode int `json:"errcode,omitempty"`
|
||||
ErrMsg string `json:"errmsg,omitempty"`
|
||||
Data *struct {
|
||||
TaskID string `json:"task_id"`
|
||||
TaskType message.ProofType `json:"task_type"`
|
||||
ProofData string `json:"proof_data"`
|
||||
} `json:"data,omitempty"`
|
||||
ErrCode int `json:"errcode,omitempty"`
|
||||
ErrMsg string `json:"errmsg,omitempty"`
|
||||
Data message.TaskMsg `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
// SubmitProofRequest defines the request structure for the SubmitProof API.
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/scroll-tech/go-ethereum/rpc"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
proverConfig "scroll-tech/prover/config"
|
||||
@@ -84,18 +85,20 @@ func (r *ProverApp) MockConfig(store bool, wsURL string) error {
|
||||
}
|
||||
cfg.ProverName = fmt.Sprintf("%s_%d", r.name, r.index)
|
||||
cfg.KeystorePath = fmt.Sprintf("/tmp/%d_%s.json", r.base.Timestamp, cfg.ProverName)
|
||||
cfg.TraceEndpoint = r.base.L2gethImg.Endpoint()
|
||||
cfg.L2GethConfig.Endpoint = r.base.L2gethImg.Endpoint()
|
||||
cfg.L2GethConfig.Confirmations = rpc.SafeBlockNumber
|
||||
// Reuse l1geth's keystore file
|
||||
cfg.KeystorePassword = "scrolltest"
|
||||
cfg.DBPath = r.bboltDB
|
||||
cfg.Coordinator.BaseURL = wsURL
|
||||
cfg.Coordinator.RetryCount = 3
|
||||
cfg.Coordinator.RetryWaitTime = 10
|
||||
// Create keystore file.
|
||||
_, err = utils.LoadOrCreateKey(cfg.KeystorePath, cfg.KeystorePassword)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cfg.CoordinatorConfig.BaseURL = wsURL
|
||||
cfg.CoordinatorConfig.RetryCount = 10
|
||||
cfg.CoordinatorConfig.RetryWaitTimeSec = 10
|
||||
cfg.CoordinatorConfig.ConnectionTimeoutSec = 30
|
||||
r.Config = cfg
|
||||
|
||||
if !store {
|
||||
|
||||
@@ -6,11 +6,14 @@
|
||||
"core": {
|
||||
"params_path": "params"
|
||||
},
|
||||
"coordinator": {
|
||||
"coordinator_config": {
|
||||
"base_url": "https://coordinator/v1",
|
||||
"timeout": 30,
|
||||
"retry_count": 10,
|
||||
"retry_wait_time": 10
|
||||
"retry_wait_time_sec": 10,
|
||||
"connection_timeout_sec": 30
|
||||
},
|
||||
"confirmations": "0x1"
|
||||
"l2geth_config": {
|
||||
"endpoint": "/var/lib/jenkins/workspace/SequencerPipeline/MyPrivateNetwork/geth.ipc",
|
||||
"confirmations": "0x1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -14,14 +13,13 @@ import (
|
||||
|
||||
// Config loads prover configuration items.
|
||||
type Config struct {
|
||||
ProverName string `json:"prover_name"`
|
||||
KeystorePath string `json:"keystore_path"`
|
||||
KeystorePassword string `json:"keystore_password"`
|
||||
TraceEndpoint string `json:"trace_endpoint"`
|
||||
Core *ProverCoreConfig `json:"core"`
|
||||
DBPath string `json:"db_path"`
|
||||
Coordinator *CoordinatorConfig `json:"coordinator"`
|
||||
Confirmations rpc.BlockNumber `json:"confirmations"`
|
||||
ProverName string `json:"prover_name"`
|
||||
KeystorePath string `json:"keystore_path"`
|
||||
KeystorePassword string `json:"keystore_password"`
|
||||
Core *ProverCoreConfig `json:"core"`
|
||||
DBPath string `json:"db_path"`
|
||||
CoordinatorConfig *CoordinatorConfig `json:"coordinator_config"`
|
||||
L2GethConfig *L2GethConfig `json:"l2geth_config"`
|
||||
}
|
||||
|
||||
// ProverCoreConfig load zk prover config.
|
||||
@@ -33,10 +31,16 @@ type ProverCoreConfig struct {
|
||||
|
||||
// CoordinatorConfig represents the configuration for the Coordinator client.
|
||||
type CoordinatorConfig struct {
|
||||
Timeout int `json:"timeout"`
|
||||
BaseURL string `json:"base_url"`
|
||||
RetryCount int `json:"retry_count"`
|
||||
RetryWaitTime int `json:"retry_wait_time"`
|
||||
BaseURL string `json:"base_url"`
|
||||
RetryCount int `json:"retry_count"`
|
||||
RetryWaitTimeSec int `json:"retry_wait_time_sec"`
|
||||
ConnectionTimeoutSec int `json:"connection_timeout_sec"`
|
||||
}
|
||||
|
||||
// L2GethConfig represents the configuration for the l2geth client.
|
||||
type L2GethConfig struct {
|
||||
Endpoint string `json:"endpoint"`
|
||||
Confirmations rpc.BlockNumber `json:"confirmations"`
|
||||
}
|
||||
|
||||
// NewConfig returns a new instance of Config.
|
||||
@@ -56,8 +60,5 @@ func NewConfig(file string) (*Config, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if cfg.Coordinator == nil || cfg.Coordinator.BaseURL == "" {
|
||||
return nil, errors.New("missing coordinator config or base_url in configuration")
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func NewProver(ctx context.Context, cfg *config.Config) (*Prover, error) {
|
||||
}
|
||||
|
||||
// Collect geth node.
|
||||
traceClient, err := ethclient.DialContext(ctx, cfg.TraceEndpoint)
|
||||
traceClient, err := ethclient.DialContext(ctx, cfg.L2GethConfig.Endpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func NewProver(ctx context.Context, cfg *config.Config) (*Prover, error) {
|
||||
}
|
||||
log.Info("init prover_core successfully!")
|
||||
|
||||
coordinatorClient, err := client.NewCoordinatorClient(cfg.Coordinator)
|
||||
coordinatorClient, err := client.NewCoordinatorClient(cfg.CoordinatorConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -196,34 +196,12 @@ func (r *Prover) fetchTaskFromServer() (*store.ProvingTask, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.Data == nil {
|
||||
return nil, fmt.Errorf("no tasks available")
|
||||
}
|
||||
|
||||
// convert the response task to a ProvingTask
|
||||
provingTask := &store.ProvingTask{
|
||||
Task: &message.TaskMsg{
|
||||
ID: resp.Data.TaskID,
|
||||
Type: resp.Data.TaskType,
|
||||
},
|
||||
Task: &resp.Data,
|
||||
Times: 0,
|
||||
}
|
||||
|
||||
switch resp.Data.TaskType {
|
||||
case message.ProofTypeChunk:
|
||||
err := json.Unmarshal([]byte(resp.Data.ProofData), &provingTask.Task.ChunkTaskDetail)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case message.ProofTypeBatch:
|
||||
err := json.Unmarshal([]byte(resp.Data.ProofData), &provingTask.Task.BatchTaskDetail)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown proof type: %d", resp.Data.TaskType)
|
||||
}
|
||||
|
||||
return provingTask, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user