Skip to content

Commit

Permalink
feat(op-plasma-eigenda): Metrics server - cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
epociask committed May 16, 2024
1 parent 820f78d commit 38814d9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
15 changes: 3 additions & 12 deletions cmd/daserver/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"net/http"

"github.com/Layr-Labs/op-plasma-eigenda/metrics"
"github.com/urfave/cli/v2"
Expand All @@ -16,22 +15,14 @@ import (
"github.com/ethereum-optimism/optimism/op-service/opio"
)

type App struct {
DAServer *http.Server
MetricsSvr *http.Server
}

func StartDAServer(cliCtx *cli.Context) error {
println("CHECKING")
if err := CheckRequired(cliCtx); err != nil {
return err
}
println("Reading CLI CFG")
cfg := ReadCLIConfig(cliCtx)
if err := cfg.Check(); err != nil {
return err
}
println("HERERERER")
m := metrics.NewMetrics("default")

log := oplog.NewLogger(oplog.AppOut(cliCtx), oplog.ReadCLIConfig(cliCtx)).New("role", "eigenda_plasma_server")
Expand Down Expand Up @@ -88,16 +79,16 @@ func StartDAServer(cliCtx *cli.Context) error {

if cfg.MetricsCfg.Enabled {
log.Debug("starting metrics server", "addr", cfg.MetricsCfg.ListenAddr, "port", cfg.MetricsCfg.ListenPort)
metricsSrv, err := m.StartServer(cfg.MetricsCfg.ListenAddr, cfg.MetricsCfg.ListenPort)
svr, err := m.StartServer(cfg.MetricsCfg.ListenAddr, cfg.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 {
if err := svr.Stop(context.Background()); err != nil {
log.Error("failed to stop metrics server", "err", err)
}
}()
log.Info("started metrics server", "addr", metricsSrv.Addr())
log.Info("started metrics server", "addr", svr.Addr())
m.RecordUp()
}

Expand Down
4 changes: 2 additions & 2 deletions daserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ type DAServer struct {
log log.Logger
endpoint string
store PlasmaStore
m *metrics.Metrics
m metrics.Metricer
tls *rpc.ServerTLSConfig
httpServer *http.Server
listener net.Listener
}

func NewDAServer(host string, port int, store PlasmaStore, log log.Logger, m *metrics.Metrics) *DAServer {
func NewDAServer(host string, port int, store PlasmaStore, log log.Logger, m metrics.Metricer) *DAServer {
endpoint := net.JoinHostPort(host, strconv.Itoa(port))
return &DAServer{
m: m,
Expand Down
3 changes: 2 additions & 1 deletion test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/Layr-Labs/eigenda/encoding/kzg"
plasma "github.com/Layr-Labs/op-plasma-eigenda"
"github.com/Layr-Labs/op-plasma-eigenda/eigenda"
"github.com/Layr-Labs/op-plasma-eigenda/metrics"
"github.com/Layr-Labs/op-plasma-eigenda/store"
"github.com/Layr-Labs/op-plasma-eigenda/verify"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
Expand Down Expand Up @@ -73,7 +74,7 @@ func createTestSuite(t *testing.T) (TestSuite, func()) {
panic(err)
}

server := plasma.NewDAServer(testSvrHost, testSvrPort, daStore, log)
server := plasma.NewDAServer(testSvrHost, testSvrPort, daStore, log, metrics.NoopMetrics)

go func() {
t.Log("Starting test plasma server on separate routine...")
Expand Down
3 changes: 3 additions & 0 deletions verify/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ func (v *Verifier) Verify(cert eigenda.Cert, blob []byte) error {
if err != nil {
return err
}

// blob to field elements
inputFr, err := rs.ToFrArray(blob)
if err != nil {
return err
}

// encode using FFT to evaluations
polyEvals, _, err := encoder.ExtendPolyEval(inputFr)
if err != nil {
return err
Expand Down

0 comments on commit 38814d9

Please sign in to comment.