forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
op-wheel,op-service: create op-wheel, and extend op-service base func…
…tionality
- Loading branch information
1 parent
c129ec6
commit fe7509d
Showing
12 changed files
with
271 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ use ( | |
./op-batcher | ||
./op-bindings | ||
./op-chain-ops | ||
./op-wheel | ||
./op-e2e | ||
./op-exporter | ||
./op-node | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,49 @@ | ||
package op_service | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
func PrefixEnvVar(prefix, suffix string) string { | ||
return prefix + "_" + suffix | ||
} | ||
|
||
// CloseAction runs the function in the background, until it finishes or until it is closed by the user with an interrupt. | ||
func CloseAction(fn func(ctx context.Context, shutdown <-chan struct{}) error) error { | ||
stopped := make(chan error, 1) | ||
shutdown := make(chan struct{}, 1) | ||
|
||
ctx, cancel := context.WithCancel(context.Background()) | ||
go func() { | ||
stopped <- fn(ctx, shutdown) | ||
}() | ||
|
||
doneCh := make(chan os.Signal, 1) | ||
signal.Notify(doneCh, []os.Signal{ | ||
os.Interrupt, | ||
os.Kill, | ||
syscall.SIGTERM, | ||
syscall.SIGQUIT, | ||
}...) | ||
|
||
select { | ||
case <-doneCh: | ||
cancel() | ||
shutdown <- struct{}{} | ||
|
||
select { | ||
case err := <-stopped: | ||
return err | ||
case <-time.After(time.Second * 10): | ||
return errors.New("command action is unresponsive for more than 10 seconds... shutting down") | ||
} | ||
case err := <-stopped: | ||
cancel() | ||
return err | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM golang:1.18.0-alpine3.15 as builder | ||
|
||
RUN apk add --no-cache make gcc musl-dev linux-headers | ||
|
||
COPY ./op-wheel/docker.go.work /app/go.work | ||
COPY ./op-node /app/op-node | ||
COPY ./op-service /app/op-service | ||
COPY ./op-wheel /app/op-wheel | ||
|
||
WORKDIR /app/op-wheel | ||
|
||
RUN go build -o op-wheel ./cmd/main.go | ||
|
||
FROM alpine:3.15 | ||
|
||
COPY --from=builder /app/op-wheel/op-wheel /usr/local/bin | ||
|
||
CMD ["op-wheel"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/urfave/cli" | ||
|
||
"github.com/ethereum/go-ethereum/log" | ||
|
||
oplog "github.com/ethereum-optimism/optimism/op-service/log" | ||
wheel "github.com/ethereum-optimism/optimism/op-wheel" | ||
) | ||
|
||
var ( | ||
Version = "" | ||
GitCommit = "" | ||
GitDate = "" | ||
) | ||
|
||
func main() { | ||
app := cli.NewApp() | ||
app.Version = fmt.Sprintf("%s-%s-%s", Version, GitCommit, GitDate) | ||
app.Name = "op-wheel" | ||
app.Usage = "Optimism Wheel is a CLI tool for the execution engine" | ||
app.Description = "Optimism Wheel is a CLI tool to direct the engine one way or the other with DB cheats and Engine API routines." | ||
app.Flags = []cli.Flag{wheel.GlobalGethLogLvlFlag} | ||
app.Before = func(c *cli.Context) error { | ||
log.Root().SetHandler( | ||
log.LvlFilterHandler( | ||
oplog.Level(c.GlobalString(wheel.GlobalGethLogLvlFlag.Name)), | ||
log.StreamHandler(os.Stdout, log.TerminalFormat(true)), | ||
), | ||
) | ||
return nil | ||
} | ||
app.Action = cli.ActionFunc(func(c *cli.Context) error { | ||
return errors.New("see 'cheat' and 'engine' subcommands and --help") | ||
}) | ||
app.Writer = os.Stdout | ||
app.ErrWriter = os.Stderr | ||
app.Commands = []cli.Command{ | ||
//wheel.CheatCmd, | ||
//wheel.EngineCmd, | ||
} | ||
|
||
err := app.Run(os.Args) | ||
if err != nil { | ||
log.Crit("Application failed", "message", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package wheel | ||
|
||
import ( | ||
"github.com/urfave/cli" | ||
|
||
opservice "github.com/ethereum-optimism/optimism/op-service" | ||
) | ||
|
||
var ( | ||
GlobalGethLogLvlFlag = cli.StringFlag{ | ||
Name: "geth-log-level", | ||
Usage: "Set the global geth logging level", | ||
EnvVar: opservice.PrefixEnvVar("OP_WHEEL", "GETH_LOG_LEVEL"), | ||
Value: "error", | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
go 1.18 | ||
|
||
use ( | ||
./op-node | ||
./op-service | ||
./op-wheel | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module github.com/ethereum-optimism/optimism/op-wheel | ||
|
||
go 1.18 | ||
|
||
require ( | ||
github.com/ethereum-optimism/optimism/op-service v0.10.3 | ||
github.com/ethereum/go-ethereum v1.10.26 | ||
github.com/urfave/cli v1.22.10 | ||
) | ||
|
||
require ( | ||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect | ||
github.com/go-stack/stack v1.8.1 // indirect | ||
github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
golang.org/x/sys v0.3.0 // indirect | ||
golang.org/x/term v0.3.0 // indirect | ||
) | ||
|
||
replace github.com/ethereum/go-ethereum v1.10.26 => github.com/ethereum-optimism/op-geth v0.0.0-20221205191237-0678a130d790 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= | ||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= | ||
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= | ||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= | ||
github.com/ethereum-optimism/op-geth v0.0.0-20221205191237-0678a130d790 h1:QJL/gtfxGe11tApZIPCeKERQHrLZMAG0RwGV9eTgtvE= | ||
github.com/ethereum-optimism/op-geth v0.0.0-20221205191237-0678a130d790/go.mod h1:p0Yox74PhYlq1HvijrCBCD9A3cI7rXco7hT6KrQr+rY= | ||
github.com/ethereum-optimism/optimism/op-service v0.10.3 h1:gr+eVq6CzxMFqo0/9n6EoUkpumtYZEzO84gti6ekj/s= | ||
github.com/ethereum-optimism/optimism/op-service v0.10.3/go.mod h1:hCY0nAeGYp3YqB0NpLmOzUdXV/5t9EyukHMTJL3pIUQ= | ||
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= | ||
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= | ||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= | ||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= | ||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= | ||
github.com/urfave/cli v1.22.10 h1:p8Fspmz3iTctJstry1PYS3HVdllxnEzTEsgIgtxTrCk= | ||
github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= | ||
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= | ||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI= | ||
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |