feat(coordinator): add prover rest api (#716)

Co-authored-by: colinlyguo <colinlyguo@scroll.io>
This commit is contained in:
georgehao
2023-08-04 20:48:17 +08:00
committed by GitHub
parent d11de12637
commit fcf34edbfb
64 changed files with 2366 additions and 15500 deletions

View File

@@ -51,7 +51,9 @@ func action(ctx *cli.Context) error {
r.Start()
defer r.Stop()
log.Info("prover start successfully", "name", cfg.ProverName, "publickey", r.PublicKey(), "version", version.Version)
log.Info("prover start successfully",
"name", cfg.ProverName, "type", cfg.Core.ProofType,
"publickey", r.PublicKey(), "version", version.Version)
// Catch CTRL-C to ensure a graceful shutdown.
interrupt := make(chan os.Signal, 1)

View File

@@ -8,6 +8,7 @@ import (
"testing"
"time"
"github.com/google/uuid"
"github.com/scroll-tech/go-ethereum/rpc"
"golang.org/x/sync/errgroup"
@@ -15,6 +16,7 @@ import (
"scroll-tech/common/cmd"
"scroll-tech/common/docker"
"scroll-tech/common/types/message"
"scroll-tech/common/utils"
)
@@ -44,18 +46,20 @@ type ProverApp struct {
}
// NewProverApp return a new proverApp manager.
func NewProverApp(base *docker.App, file string, wsURL string) *ProverApp {
proverFile := fmt.Sprintf("/tmp/%d_prover-config.json", base.Timestamp)
func NewProverApp(base *docker.App, file string, httpURL string, proofType message.ProofType) *ProverApp {
uuid := uuid.New().String()
proverFile := fmt.Sprintf("/tmp/%s_%d_prover-config.json", uuid, base.Timestamp)
proverApp := &ProverApp{
base: base,
originFile: file,
proverFile: proverFile,
bboltDB: fmt.Sprintf("/tmp/%d_bbolt_db", base.Timestamp),
bboltDB: fmt.Sprintf("/tmp/%s_%d_bbolt_db", uuid, base.Timestamp),
index: getIndex(),
name: string(utils.ProverApp),
args: []string{"--log.debug", "--config", proverFile},
}
if err := proverApp.MockConfig(true, wsURL); err != nil {
if err := proverApp.MockConfig(true, httpURL, proofType); err != nil {
panic(err)
}
return proverApp
@@ -78,7 +82,7 @@ func (r *ProverApp) Free() {
}
// MockConfig creates a new prover config.
func (r *ProverApp) MockConfig(store bool, wsURL string) error {
func (r *ProverApp) MockConfig(store bool, httpURL string, proofType message.ProofType) error {
cfg, err := proverConfig.NewConfig(r.originFile)
if err != nil {
return err
@@ -86,7 +90,7 @@ 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.L2Geth.Endpoint = r.base.L2gethImg.Endpoint()
cfg.L2Geth.Confirmations = rpc.SafeBlockNumber
cfg.L2Geth.Confirmations = rpc.LatestBlockNumber
// Reuse l1geth's keystore file
cfg.KeystorePassword = "scrolltest"
cfg.DBPath = r.bboltDB
@@ -95,10 +99,11 @@ func (r *ProverApp) MockConfig(store bool, wsURL string) error {
if err != nil {
return err
}
cfg.Coordinator.BaseURL = wsURL
cfg.Coordinator.BaseURL = httpURL
cfg.Coordinator.RetryCount = 10
cfg.Coordinator.RetryWaitTimeSec = 10
cfg.Coordinator.ConnectionTimeoutSec = 30
cfg.Core.ProofType = proofType
r.Config = cfg
if !store {
@@ -128,18 +133,6 @@ func (r ProverApps) RunApps(t *testing.T, args ...string) {
_ = eg.Wait()
}
// MockConfigs creates all the proverApps' configs.
func (r ProverApps) MockConfigs(store bool, wsURL string) error {
var eg errgroup.Group
for _, prover := range r {
prover := prover
eg.Go(func() error {
return prover.MockConfig(store, wsURL)
})
}
return eg.Wait()
}
// Free releases proverApps.
func (r ProverApps) Free() {
var wg sync.WaitGroup