Skip to content

Commit d6692f5

Browse files
committed
chore: move build and common source files to root
1 parent 1ea0262 commit d6692f5

File tree

29 files changed

+1301
-1026
lines changed

29 files changed

+1301
-1026
lines changed

bridge/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Build bridge in a stock Go builder container
22
FROM scrolltech/go-builder:1.17 as builder
33

4-
ADD ./bridge /bridge
5-
ADD ./store /store
4+
COPY ./bridge /bridge
5+
COPY ./store /store
6+
COPY ./utils /utils
67

78
RUN cd /bridge/cmd/bridge/ && go build -v -p 4
89

bridge/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bridge: ## Builds the Bridge instance.
1515
GOBIN=$(PWD)/build/bin go install ./cmd/bridge
1616

1717
lint: ## Lint the files - used for CI
18-
GOBIN=$(PWD)/build/bin go run build/lint.go
18+
GOBIN=$(PWD)/build/bin go run ../build/lint.go
1919

2020
clean: ## Empty out the bin folder
2121
@rm -rf build/bin

bridge/cmd/bridge/db_client.go

Lines changed: 0 additions & 95 deletions
This file was deleted.

bridge/cmd/bridge/logger.go

Lines changed: 0 additions & 42 deletions
This file was deleted.

bridge/cmd/bridge/main.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
"scroll-tech/bridge/bridge/l1"
1313
"scroll-tech/bridge/bridge/l2"
14-
"scroll-tech/bridge/cmd/utils"
14+
"scroll-tech/utils"
1515
"scroll-tech/bridge/config"
1616
"scroll-tech/store"
1717
)
@@ -24,54 +24,54 @@ func main() {
2424
app.Name = "bridge"
2525
app.Usage = "The Scroll Bridge"
2626
app.Version = "v0.0.1"
27-
app.Flags = append(app.Flags, commonFlags...)
28-
app.Flags = append(app.Flags, apiFlags...)
29-
app.Flags = append(app.Flags, l1Flags...)
30-
app.Flags = append(app.Flags, l2Flags...)
31-
app.Flags = append(app.Flags, dbflags...)
27+
app.Flags = append(app.Flags, utils.CommonFlags...)
28+
app.Flags = append(app.Flags, utils.APIFlags...)
29+
app.Flags = append(app.Flags, utils.L1Flags...)
30+
app.Flags = append(app.Flags, utils.L2Flags...)
31+
app.Flags = append(app.Flags, utils.DBflags...)
3232

3333
app.Before = func(ctx *cli.Context) error {
34-
return setup(ctx)
34+
return utils.Setup(ctx)
3535
}
3636
app.Commands = []*cli.Command{
3737
{
3838
Name: "reset",
3939
Usage: "Clean and reset database.",
40-
Action: ResetDB,
40+
Action: utils.ResetDB,
4141
Flags: []cli.Flag{
42-
&configFileFlag,
42+
&utils.ConfigFileFlag,
4343
},
4444
},
4545
{
4646
Name: "status",
4747
Usage: "Check migration status.",
48-
Action: CheckDBStatus,
48+
Action: utils.CheckDBStatus,
4949
Flags: []cli.Flag{
50-
&configFileFlag,
50+
&utils.ConfigFileFlag,
5151
},
5252
},
5353
{
5454
Name: "version",
5555
Usage: "Display the current database version.",
56-
Action: DBVersion,
56+
Action: utils.DBVersion,
5757
Flags: []cli.Flag{
58-
&configFileFlag,
58+
&utils.ConfigFileFlag,
5959
},
6060
},
6161
{
6262
Name: "migrate",
6363
Usage: "Migrate the database to the latest version.",
64-
Action: MigrateDB,
64+
Action: utils.MigrateDB,
6565
Flags: []cli.Flag{
66-
&configFileFlag,
66+
&utils.ConfigFileFlag,
6767
},
6868
},
6969
{
7070
Name: "rollback",
7171
Usage: "Roll back the database to a previous <version>. Rolls back a single migration if no version specified.",
72-
Action: RollbackDB,
72+
Action: utils.RollbackDB,
7373
Flags: []cli.Flag{
74-
&configFileFlag,
74+
&utils.ConfigFileFlag,
7575
&cli.IntFlag{
7676
Name: "version",
7777
Usage: "Rollback to the specified version.",
@@ -89,23 +89,23 @@ func main() {
8989
}
9090

9191
func applyConfig(ctx *cli.Context, cfg *config.Config) {
92-
if ctx.IsSet(l1ChainIDFlag.Name) {
93-
cfg.L1Config.ChainID = ctx.Int64(l1ChainIDFlag.Name)
92+
if ctx.IsSet(utils.L1ChainIDFlag.Name) {
93+
cfg.L1Config.ChainID = ctx.Int64(utils.L1ChainIDFlag.Name)
9494
}
95-
if ctx.IsSet(l1UrlFlag.Name) {
96-
cfg.L1Config.Endpoint = ctx.String(l1UrlFlag.Name)
95+
if ctx.IsSet(utils.L1UrlFlag.Name) {
96+
cfg.L1Config.Endpoint = ctx.String(utils.L1UrlFlag.Name)
9797
}
98-
if ctx.IsSet(l2ChainIDFlag.Name) {
99-
cfg.L2Config.ChainID = ctx.Int64(l2ChainIDFlag.Name)
98+
if ctx.IsSet(utils.L2ChainIDFlag.Name) {
99+
cfg.L2Config.ChainID = ctx.Int64(utils.L2ChainIDFlag.Name)
100100
}
101-
if ctx.IsSet(l2UrlFlag.Name) {
102-
cfg.L2Config.Endpoint = ctx.String(l2UrlFlag.Name)
101+
if ctx.IsSet(utils.L2UrlFlag.Name) {
102+
cfg.L2Config.Endpoint = ctx.String(utils.L2UrlFlag.Name)
103103
}
104104
}
105105

106106
func action(ctx *cli.Context) error {
107107
// Load config file.
108-
cfgFile := ctx.String(configFileFlag.Name)
108+
cfgFile := ctx.String(utils.ConfigFileFlag.Name)
109109
cfg, err := config.NewConfig(cfgFile)
110110
if err != nil {
111111
log.Crit("failed to load config file", "config file", cfgFile, "error", err)
@@ -149,7 +149,7 @@ func action(ctx *cli.Context) error {
149149
}
150150

151151
// Register api and start rpc service.
152-
if ctx.Bool(httpEnabledFlag.Name) {
152+
if ctx.Bool(utils.HTTPEnabledFlag.Name) {
153153
srv := rpc.NewServer()
154154
apis := l2Backend.APIs()
155155
for _, api := range apis {
@@ -160,8 +160,8 @@ func action(ctx *cli.Context) error {
160160
handler, addr, err := utils.StartHTTPEndpoint(
161161
fmt.Sprintf(
162162
"%s:%d",
163-
ctx.String(httpListenAddrFlag.Name),
164-
ctx.Int(httpPortFlag.Name)),
163+
ctx.String(utils.HTTPListenAddrFlag.Name),
164+
ctx.Int(utils.HTTPPortFlag.Name)),
165165
rpc.DefaultHTTPTimeouts,
166166
srv)
167167
if err != nil {

bridge/go.mod

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ module scroll-tech/bridge
33
go 1.17
44

55
require (
6-
github.com/jmoiron/sqlx v1.3.5
7-
github.com/mattn/go-colorable v0.1.11
8-
github.com/mattn/go-isatty v0.0.14
96
github.com/scroll-tech/go-ethereum v1.10.14-0.20220920070544-3a7da33cd53d
107
github.com/stretchr/testify v1.7.2
118
github.com/urfave/cli/v2 v2.3.0
129
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
1310
scroll-tech/internal v1.0.0
1411
scroll-tech/store v1.0.0
12+
scroll-tech/utils v1.0.0
1513
)
1614

1715
replace (
1816
scroll-tech/coordinator v1.0.0 => ../coordinator
1917
scroll-tech/internal v1.0.0 => ../internal
2018
scroll-tech/store v1.0.0 => ../store
19+
scroll-tech/utils v1.0.0 => ../utils
2120
)
2221

2322
require (
@@ -54,7 +53,10 @@ require (
5453
github.com/influxdata/influxdb-client-go/v2 v2.4.0 // indirect
5554
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect
5655
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458 // indirect
56+
github.com/jmoiron/sqlx v1.3.5 // indirect
5757
github.com/lib/pq v1.10.6 // indirect
58+
github.com/mattn/go-colorable v0.1.11 // indirect
59+
github.com/mattn/go-isatty v0.0.14 // indirect
5860
github.com/mattn/go-runewidth v0.0.9 // indirect
5961
github.com/mitchellh/mapstructure v1.5.0 // indirect
6062
github.com/mitchellh/pointerstructure v1.2.0 // indirect

bridge/build/lint.go renamed to build/lint.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func goBin() string {
3030
func main() {
3131
log.SetFlags(log.Lshortfile)
3232

33-
if _, err := os.Stat(filepath.Join("build", "lint.go")); os.IsNotExist(err) {
33+
if _, err := os.Stat(filepath.Join("../build", "lint.go")); os.IsNotExist(err) {
3434
log.Fatal("should run build from root dir")
3535
}
3636

@@ -50,7 +50,7 @@ func lint() {
5050
log.Fatalf("could not list pkgs: %v\n%s", err, string(out))
5151
}
5252

53-
cmd = exec.Command(filepath.Join(goBin(), "golangci-lint"))
53+
cmd = exec.Command("golangci-lint")
5454
cmd.Args = append(cmd.Args, "run", "--config", ".golangci.yml")
5555

5656
if *v {

0 commit comments

Comments
 (0)