-
Notifications
You must be signed in to change notification settings - Fork 3.9k
op-wheel,op-service: create op-wheel, and extend op-service base functionality #4284
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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= |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.