Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ethereum-optimism/bailiff
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.1-rc.17
Choose a base ref
...
head repository: ethereum-optimism/bailiff
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 5 commits
  • 9 files changed
  • 1 contributor

Commits on Oct 23, 2024

  1. Add metrics

    mslipper committed Oct 23, 2024
    Copy the full SHA
    d62fdc3 View commit details
  2. sync the whitelist

    mslipper committed Oct 23, 2024
    Copy the full SHA
    09f93ea View commit details
  3. fix build error

    mslipper committed Oct 23, 2024
    Copy the full SHA
    7503c36 View commit details

Commits on Nov 19, 2024

  1. Copy the full SHA
    b57f931 View commit details

Commits on Jan 8, 2025

  1. Add queue (#1)

    mslipper authored Jan 8, 2025
    Copy the full SHA
    d0c628f View commit details
Showing with 534 additions and 21 deletions.
  1. +31 −5 cmd/bailiff/main.go
  2. +43 −0 go.mod
  3. +235 −1 go.sum
  4. +3 −2 internal/pkg/bailiff/handler.go
  5. +60 −0 internal/pkg/bailiff/metrics.go
  6. +103 −4 internal/pkg/bailiff/repush.go
  7. +43 −0 internal/pkg/bailiff/repush_test.go
  8. +3 −0 internal/pkg/bailiff/server.go
  9. +13 −9 internal/pkg/bailiff/whitelist.go
36 changes: 31 additions & 5 deletions cmd/bailiff/main.go
Original file line number Diff line number Diff line change
@@ -7,12 +7,14 @@ import (
"fmt"
"net/http"
"os"
"time"

opservice "github.com/ethereum-optimism/optimism/op-service"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
"github.com/ethereum-optimism/optimism/op-service/ctxinterrupt"
"github.com/ethereum-optimism/optimism/op-service/httputil"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
"github.com/google/go-github/v66/github"
"github.com/urfave/cli/v2"
)
@@ -61,12 +63,12 @@ var (
}
)

var GlobalFlags = append([]cli.Flag{
var GlobalFlags = []cli.Flag{
ConfigPathFlag,
WebhookSecretFlag,
GithubTokenFlag,
PrivateKeyFileFlag,
}, oplog.CLIFlags(EnvVarPrefix)...)
}

func main() {
app := cli.NewApp()
@@ -107,8 +109,10 @@ func main() {

gh := github.NewClient(http.DefaultClient).WithAuthToken(envCfg.GitHubToken)
wl := bailiff.NewTeamWhitelist(cfg.Org, cfg.AdminTeams, gh)

repusher := bailiff.NewShellRepusher(l.New("module", "shell-repusher"), workdir, envCfg.PrivateKeyFile)
eh := bailiff.NewEventHandler(gh, wl, cfg, workdir, l, repusher)
asyncRepusher := bailiff.NewAsyncRepusher(l.New("module", "async-repusher"), repusher)
eh := bailiff.NewEventHandler(gh, wl, cfg, workdir, l, asyncRepusher)
srv := bailiff.NewServer(l, envCfg.WebhookSecret, eh)

repoURL := fmt.Sprintf("git@github.com:%s/%s.git", cfg.Org, cfg.Repo)
@@ -118,22 +122,44 @@ func main() {

ctx, cancel := context.WithCancel(cliCtx.Context)
defer cancel()

go wl.SyncPeriodically(ctx, l, time.Minute)

metricsCfg := opmetrics.ReadCLIConfig(cliCtx)
if metricsCfg.Enabled {
metricsSrv, err := opmetrics.StartServer(bailiff.MetricsRegistry, metricsCfg.ListenAddr, metricsCfg.ListenPort)
if err != nil {
return fmt.Errorf("failed to start metrics server: %w", err)
}
defer func() {
if err := metricsSrv.Stop(context.Background()); err != nil {
l.Error("failed to stop metrics server", "err", err)
}
}()

l.Info("metrics server is running", "addr", metricsCfg.ListenAddr)
}

httpSrv, err := httputil.StartHTTPServer(cfg.ListenAddr, srv)
if err != nil {
return fmt.Errorf("failed to start HTTP server: %w", err)
}

defer func() {
if err := httpSrv.Stop(ctx); err != nil {
if err := httpSrv.Stop(context.Background()); err != nil {
l.Error("failed to stop DA server", "err", err)
}
}()

l.Info("bailiff is running", "addr", cfg.ListenAddr)

return ctxinterrupt.Wait(ctx)
}
if err := app.Run(os.Args); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Application failed: %v\n", err)
}
}

func init() {
GlobalFlags = append(GlobalFlags, oplog.CLIFlags(EnvVarPrefix)...)
GlobalFlags = append(GlobalFlags, opmetrics.CLIFlags(EnvVarPrefix)...)
}
43 changes: 43 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -9,31 +9,74 @@ require (
github.com/google/go-github/v66 v66.0.0
github.com/gorilla/mux v1.8.0
github.com/migueleliasweb/go-github-mock v1.0.1
github.com/prometheus/client_golang v1.20.5
github.com/stretchr/testify v1.9.0
github.com/urfave/cli/v2 v2.27.4
)

require (
github.com/DataDog/zstd v1.5.6-0.20230824185856-869dae002e5e // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v1.1.2 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/go-github/v64 v64.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/holiman/uint256 v1.3.1 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/supranational/blst v0.3.13 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.6.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
Loading