-
Notifications
You must be signed in to change notification settings - Fork 626
[Feat] Support "proxy" arch between coordinator and prover #1701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
5dbb5c5
1f2b857
9796d16
412ad56
3adb2e0
5c6c225
76ecdf0
0d238d7
7b3a65b
4f878d9
624a7a2
321dd43
64ef0f4
5a07a16
5614ec3
322766f
4725d8a
c72ee5d
e6be62f
9df6429
78dbe6c
a04b64d
2721503
50f3e1a
256c90a
92ca7a6
c7b83a0
057e220
b7f23c6
1d9fa41
884b050
fa5b113
c79ad57
6ee026f
4365aaf
8a15836
404c664
c992157
d9a29cd
b1c3a4e
8f8a537
5d41788
7572bf8
b6e3345
17e6c5b
ac0396d
4b79e63
6696aac
4df1dd8
20fde41
e755165
c22d9ec
51b1e79
e9470ff
cf9e368
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Download Go dependencies | ||
| FROM scrolltech/go-rust-builder:go-1.22.12-rust-nightly-2025-02-14 as base | ||
| WORKDIR /src | ||
| COPY go.work* ./ | ||
| COPY ./rollup/go.* ./rollup/ | ||
| COPY ./common/go.* ./common/ | ||
| COPY ./coordinator/go.* ./coordinator/ | ||
| COPY ./database/go.* ./database/ | ||
| COPY ./tests/integration-test/go.* ./tests/integration-test/ | ||
| COPY ./bridge-history-api/go.* ./bridge-history-api/ | ||
| RUN go mod download -x | ||
|
|
||
|
|
||
| # Build coordinator proxy | ||
| FROM base as builder | ||
| COPY . . | ||
| RUN cd ./coordinator && CGO_LDFLAGS="-Wl,--no-as-needed -ldl" make coordinator_proxy && mv ./build/bin/coordinator_proxy /bin/coordinator_proxy | ||
|
|
||
| # Pull coordinator proxy into a second stage deploy ubuntu container | ||
| FROM ubuntu:20.04 | ||
| ENV CGO_LDFLAGS="-Wl,--no-as-needed -ldl" | ||
| RUN apt update && apt install vim netcat-openbsd net-tools curl jq -y | ||
| COPY --from=builder /bin/coordinator_proxy /bin/ | ||
| RUN /bin/coordinator_proxy --version | ||
| WORKDIR /app | ||
| ENTRYPOINT ["/bin/coordinator_proxy"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| assets/ | ||
| contracts/ | ||
| docs/ | ||
| l2geth/ | ||
| rpc-gateway/ | ||
| *target/* | ||
|
|
||
| permissionless-batches/conf/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ require ( | |
| github.com/gin-gonic/gin v1.9.1 | ||
| github.com/mattn/go-colorable v0.1.13 | ||
| github.com/mattn/go-isatty v0.0.20 | ||
| github.com/mitchellh/mapstructure v1.5.0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify mapstructure v1.5.0 is current and has no security advisories. The dependency is being added as a direct dependency (moved from indirect) to support the new 🌐 Web query: 💡 Result: Latest release: go-viper/mapstructure v2.4.0 (release 15 Jul 2025). [1] Security advisories: yes — multiple advisories (e.g., CVE-2025-52893 / GHSA-fv92-fjc5-jj9h) list mapstructure v1.5.0 as affected (sensitive data insertion into logs); upgrade to a fixed version (v2.3.0+ or v2.4.0) is recommended. [2][3] Sources:
Upgrade mapstructure to v2.4.0 to resolve security vulnerability CVE-2025-52893. Version 1.5.0 is affected by security advisory CVE-2025-52893 / GHSA-fv92-fjc5-jj9h (sensitive data insertion into logs); upgrade to v2.3.0+ or v2.4.0 is required. The latest version is v2.4.0 (released July 15, 2025). 🤖 Prompt for AI Agents |
||
| github.com/modern-go/reflect2 v1.0.2 | ||
| github.com/orcaman/concurrent-map v1.0.0 | ||
| github.com/prometheus/client_golang v1.19.0 | ||
|
|
@@ -147,7 +148,6 @@ require ( | |
| github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect | ||
| github.com/miekg/pkcs11 v1.1.1 // indirect | ||
| github.com/mitchellh/copystructure v1.2.0 // indirect | ||
| github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
| github.com/mitchellh/pointerstructure v1.2.0 // indirect | ||
| github.com/mitchellh/reflectwalk v1.0.2 // indirect | ||
| github.com/mmcloughlin/addchain v0.4.0 // indirect | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,122 @@ | ||||||
| package app | ||||||
|
|
||||||
| import ( | ||||||
| "context" | ||||||
| "errors" | ||||||
| "fmt" | ||||||
| "net/http" | ||||||
| "os" | ||||||
| "os/signal" | ||||||
| "time" | ||||||
|
|
||||||
| "github.com/gin-gonic/gin" | ||||||
| "github.com/prometheus/client_golang/prometheus" | ||||||
| "github.com/scroll-tech/go-ethereum/log" | ||||||
| "github.com/urfave/cli/v2" | ||||||
| "gorm.io/gorm" | ||||||
|
|
||||||
| "scroll-tech/common/database" | ||||||
| "scroll-tech/common/observability" | ||||||
| "scroll-tech/common/utils" | ||||||
| "scroll-tech/common/version" | ||||||
|
|
||||||
| "scroll-tech/coordinator/internal/config" | ||||||
| "scroll-tech/coordinator/internal/controller/proxy" | ||||||
| "scroll-tech/coordinator/internal/route" | ||||||
| ) | ||||||
|
|
||||||
| var app *cli.App | ||||||
|
|
||||||
| func init() { | ||||||
| // Set up coordinator app info. | ||||||
| app = cli.NewApp() | ||||||
| app.Action = action | ||||||
| app.Name = "coordinator proxy" | ||||||
| app.Usage = "Proxy for multiple Scroll L2 Coordinators" | ||||||
| app.Version = version.Version | ||||||
| app.Flags = append(app.Flags, utils.CommonFlags...) | ||||||
| app.Flags = append(app.Flags, apiFlags...) | ||||||
| app.Before = func(ctx *cli.Context) error { | ||||||
| return utils.LogSetup(ctx) | ||||||
| } | ||||||
| // Register `coordinator-test` app for integration-test. | ||||||
| utils.RegisterSimulation(app, utils.CoordinatorAPIApp) | ||||||
| } | ||||||
|
|
||||||
| func action(ctx *cli.Context) error { | ||||||
| cfgFile := ctx.String(utils.ConfigFileFlag.Name) | ||||||
| cfg, err := config.NewProxyConfig(cfgFile) | ||||||
| if err != nil { | ||||||
| log.Crit("failed to load config file", "config file", cfgFile, "error", err) | ||||||
| } | ||||||
|
|
||||||
| var db *gorm.DB | ||||||
| if dbCfg := cfg.ProxyManager.DB; dbCfg != nil { | ||||||
| log.Info("Apply persistent storage", "via", cfg.ProxyManager.DB.DSN) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stop logging the raw DB DSN. Including - log.Info("Apply persistent storage", "via", cfg.ProxyManager.DB.DSN)
+ log.Info("Apply persistent storage")📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| db, err = database.InitDB(cfg.ProxyManager.DB) | ||||||
| if err != nil { | ||||||
| log.Crit("failed to init db connection", "err", err) | ||||||
| } | ||||||
| defer func() { | ||||||
| if err = database.CloseDB(db); err != nil { | ||||||
| log.Error("can not close db connection", "error", err) | ||||||
| } | ||||||
| }() | ||||||
| observability.Server(ctx, db) | ||||||
| } | ||||||
| registry := prometheus.DefaultRegisterer | ||||||
|
|
||||||
| apiSrv := server(ctx, cfg, db, registry) | ||||||
|
|
||||||
| log.Info( | ||||||
| "Start coordinator api successfully.", | ||||||
| "version", version.Version, | ||||||
| ) | ||||||
|
|
||||||
| // Catch CTRL-C to ensure a graceful shutdown. | ||||||
| interrupt := make(chan os.Signal, 1) | ||||||
| signal.Notify(interrupt, os.Interrupt) | ||||||
|
|
||||||
| // Wait until the interrupt signal is received from an OS signal. | ||||||
| <-interrupt | ||||||
| log.Info("start shutdown coordinator proxy server ...") | ||||||
|
|
||||||
| closeCtx, cancelExit := context.WithTimeout(context.Background(), 5*time.Second) | ||||||
| defer cancelExit() | ||||||
| if err = apiSrv.Shutdown(closeCtx); err != nil { | ||||||
| log.Warn("shutdown coordinator proxy server failure", "error", err) | ||||||
| return nil | ||||||
| } | ||||||
|
|
||||||
| <-closeCtx.Done() | ||||||
| log.Info("coordinator proxy server exiting success") | ||||||
| return nil | ||||||
| } | ||||||
|
|
||||||
| func server(ctx *cli.Context, cfg *config.ProxyConfig, db *gorm.DB, reg prometheus.Registerer) *http.Server { | ||||||
| router := gin.New() | ||||||
| proxy.InitController(cfg, db, reg) | ||||||
| route.ProxyRoute(router, cfg, reg) | ||||||
| port := ctx.String(httpPortFlag.Name) | ||||||
| srv := &http.Server{ | ||||||
| Addr: fmt.Sprintf(":%s", port), | ||||||
| Handler: router, | ||||||
| ReadHeaderTimeout: time.Minute, | ||||||
| } | ||||||
|
|
||||||
| go func() { | ||||||
| if runServerErr := srv.ListenAndServe(); runServerErr != nil && !errors.Is(runServerErr, http.ErrServerClosed) { | ||||||
| log.Crit("run coordinator proxy http server failure", "error", runServerErr) | ||||||
| } | ||||||
| }() | ||||||
| return srv | ||||||
| } | ||||||
|
|
||||||
| // Run coordinator. | ||||||
| func Run() { | ||||||
| // RunApp the coordinator. | ||||||
| if err := app.Run(os.Args); err != nil { | ||||||
| _, _ = fmt.Fprintln(os.Stderr, err) | ||||||
| os.Exit(1) | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package app | ||
|
|
||
| import "github.com/urfave/cli/v2" | ||
|
|
||
| var ( | ||
| apiFlags = []cli.Flag{ | ||
| // http flags | ||
| &httpEnabledFlag, | ||
| &httpListenAddrFlag, | ||
| &httpPortFlag, | ||
| } | ||
| // httpEnabledFlag enable rpc server. | ||
| httpEnabledFlag = cli.BoolFlag{ | ||
| Name: "http", | ||
| Usage: "Enable the HTTP-RPC server", | ||
| Value: false, | ||
| } | ||
| // httpListenAddrFlag set the http address. | ||
| httpListenAddrFlag = cli.StringFlag{ | ||
| Name: "http.addr", | ||
| Usage: "HTTP-RPC server listening interface", | ||
| Value: "localhost", | ||
| } | ||
| // httpPortFlag set http.port. | ||
| httpPortFlag = cli.IntFlag{ | ||
| Name: "http.port", | ||
| Usage: "HTTP-RPC server listening port", | ||
| Value: 8590, | ||
| } | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package main | ||
|
|
||
| import "scroll-tech/coordinator/cmd/proxy/app" | ||
|
|
||
| func main() { | ||
| app.Run() | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| { | ||
| "proxy_manager": { | ||
| "proxy_cli": { | ||
| "proxy_name": "proxy_name", | ||
| "secret": "client private key" | ||
| }, | ||
| "auth": { | ||
| "secret": "proxy secret key", | ||
| "challenge_expire_duration_sec": 3600, | ||
| "login_expire_duration_sec": 3600 | ||
| }, | ||
| "verifier": { | ||
| "min_prover_version": "v4.4.45", | ||
| "verifiers": [] | ||
| }, | ||
| "db": { | ||
| "driver_name": "postgres", | ||
| "dsn": "postgres://localhost/scroll?sslmode=disable", | ||
| "maxOpenNum": 200, | ||
| "maxIdleNum": 20 | ||
| } | ||
| }, | ||
| "coordinators": { | ||
| "sepolia": { | ||
| "base_url": "http://localhost:8555", | ||
| "retry_count": 10, | ||
| "retry_wait_time_sec": 10, | ||
| "connection_timeout_sec": 30 | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrade Docker GitHub actions to Node20-compatible releases.
docker/setup-qemu-action@v2,docker/setup-buildx-action@v2,docker/login-action@v2, anddocker/build-push-action@v3all run on the removed Node16 runtime, so this job will fail on GitHub-hosted runners after Node16 was retired on November 12, 2024. Bump them to the Node20-ready releases (@v3for the first three and@v5for build-push) before merging. (github.blog)📝 Committable suggestion
🧰 Tools
🪛 actionlint (1.7.8)
370-370: the runner of "docker/setup-qemu-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
372-372: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
374-374: the runner of "docker/login-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
393-393: the runner of "docker/build-push-action@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🤖 Prompt for AI Agents