Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
2bc6e85c
Commit
2bc6e85c
authored
Jul 18, 2023
by
Felipe Andrade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
semgrep
parent
94ca47ec
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
13 deletions
+14
-13
example.config.toml
op-ufm/example.config.toml
+2
-2
config.go
op-ufm/pkg/config/config.go
+4
-4
eth.go
op-ufm/pkg/metrics/clients/eth.go
+3
-0
healthz_server.go
op-ufm/pkg/service/healthz_server.go
+1
-3
service.go
op-ufm/pkg/service/service.go
+4
-4
No files found.
op-ufm/example.config.toml
View file @
2bc6e85c
...
...
@@ -16,7 +16,7 @@ enabled = true
# Host for the healthz endpoint to listen on
host
=
"0.0.0.0"
# Port for the above.
port
=
8080
port
=
"8080"
[metrics]
# Whether or not to enable Prometheus metrics
...
...
@@ -24,7 +24,7 @@ enabled = true
# Host for the Prometheus metrics endpoint to listen on.
host
=
"0.0.0.0"
# Port for the above.
port
=
9761
port
=
"9761"
[wallets.default]
# OP Stack Chain ID
...
...
op-ufm/pkg/config/config.go
View file @
2bc6e85c
...
...
@@ -29,13 +29,13 @@ type MetricsConfig struct {
Enabled
bool
`toml:"enabled"`
Debug
bool
`toml:"debug"`
Host
string
`toml:"host"`
Port
int
`toml:"port"`
Port
string
`toml:"port"`
}
type
HealthzConfig
struct
{
Enabled
bool
`toml:"enabled"`
Host
string
`toml:"host"`
Port
int
`toml:"port"`
Port
string
`toml:"port"`
}
type
WalletConfig
struct
{
...
...
@@ -80,12 +80,12 @@ func New(file string) (*Config, error) {
func
(
c
*
Config
)
Validate
()
error
{
if
c
.
Metrics
.
Enabled
{
if
c
.
Metrics
.
Host
==
""
||
c
.
Metrics
.
Port
==
0
{
if
c
.
Metrics
.
Host
==
""
||
c
.
Metrics
.
Port
==
""
{
return
errors
.
New
(
"metrics is enabled but host or port are missing"
)
}
}
if
c
.
Healthz
.
Enabled
{
if
c
.
Healthz
.
Host
==
""
||
c
.
Healthz
.
Port
==
0
{
if
c
.
Healthz
.
Host
==
""
||
c
.
Healthz
.
Port
==
""
{
return
errors
.
New
(
"healthz is enabled but host or port are missing"
)
}
}
...
...
op-ufm/pkg/metrics/clients/eth.go
View file @
2bc6e85c
...
...
@@ -5,6 +5,7 @@ import (
"time"
"github.com/ethereum-optimism/optimism/op-ufm/pkg/metrics"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -32,7 +33,9 @@ func Dial(providerName string, url string) (*InstrumentedEthClient, error) {
func
(
i
*
InstrumentedEthClient
)
TransactionByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Transaction
,
bool
,
error
)
{
start
:=
time
.
Now
()
log
.
Debug
(
">> TransactionByHash"
,
"hash"
,
hash
,
"provider"
,
i
.
providerName
)
tx
,
isPending
,
err
:=
i
.
c
.
TransactionByHash
(
ctx
,
hash
)
log
.
Debug
(
"<< TransactionByHash"
,
"tx"
,
tx
,
"isPending"
,
isPending
,
"err"
,
err
,
"hash"
,
hash
,
"provider"
,
i
.
providerName
)
if
err
!=
nil
{
if
!
i
.
ignorableErrors
(
err
)
{
metrics
.
RecordError
(
i
.
providerName
,
"ethclient.TransactionByHash"
)
...
...
op-ufm/pkg/service/healthz_server.go
View file @
2bc6e85c
...
...
@@ -2,7 +2,6 @@ package service
import
(
"context"
"fmt"
"net/http"
"github.com/gorilla/mux"
...
...
@@ -14,10 +13,9 @@ type HealthzServer struct {
server
*
http
.
Server
}
func
(
h
*
HealthzServer
)
Start
(
ctx
context
.
Context
,
host
string
,
port
int
)
error
{
func
(
h
*
HealthzServer
)
Start
(
ctx
context
.
Context
,
addr
string
)
error
{
hdlr
:=
mux
.
NewRouter
()
hdlr
.
HandleFunc
(
"/healthz"
,
h
.
Handle
)
.
Methods
(
"GET"
)
addr
:=
fmt
.
Sprintf
(
"%s:%d"
,
host
,
port
)
c
:=
cors
.
New
(
cors
.
Options
{
AllowedOrigins
:
[]
string
{
"*"
},
})
...
...
op-ufm/pkg/service/service.go
View file @
2bc6e85c
...
...
@@ -2,7 +2,7 @@ package service
import
(
"context"
"
fm
t"
"
ne
t"
"github.com/ethereum-optimism/optimism/op-ufm/pkg/config"
"github.com/ethereum-optimism/optimism/op-ufm/pkg/metrics"
...
...
@@ -31,10 +31,10 @@ func New(cfg *config.Config) *Service {
func
(
s
*
Service
)
Start
(
ctx
context
.
Context
)
{
log
.
Info
(
"service starting"
)
if
s
.
Config
.
Healthz
.
Enabled
{
addr
:=
fmt
.
Sprintf
(
"%s:%d"
,
s
.
Config
.
Healthz
.
Host
,
s
.
Config
.
Healthz
.
Port
)
addr
:=
net
.
JoinHostPort
(
s
.
Config
.
Healthz
.
Host
,
s
.
Config
.
Healthz
.
Port
)
log
.
Info
(
"starting healthz server"
,
"addr"
,
addr
)
go
func
()
{
if
err
:=
s
.
Healthz
.
Start
(
ctx
,
s
.
Config
.
Healthz
.
Host
,
s
.
Config
.
Healthz
.
Port
);
err
!=
nil
{
if
err
:=
s
.
Healthz
.
Start
(
ctx
,
addr
);
err
!=
nil
{
log
.
Error
(
"error starting healthz server"
,
"err"
,
err
)
}
}()
...
...
@@ -42,7 +42,7 @@ func (s *Service) Start(ctx context.Context) {
metrics
.
Debug
=
s
.
Config
.
Metrics
.
Debug
if
s
.
Config
.
Metrics
.
Enabled
{
addr
:=
fmt
.
Sprintf
(
"%s:%d"
,
s
.
Config
.
Metrics
.
Host
,
s
.
Config
.
Metrics
.
Port
)
addr
:=
net
.
JoinHostPort
(
s
.
Config
.
Metrics
.
Host
,
s
.
Config
.
Metrics
.
Port
)
log
.
Info
(
"starting metrics server"
,
"addr"
,
addr
)
go
func
()
{
if
err
:=
s
.
Metrics
.
Start
(
ctx
,
addr
);
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment