Skip to content

Commit

Permalink
op-proposer: Enable default Admin RPC
Browse files Browse the repository at this point in the history
This allows the admin RPC to change the log level of the proposer
while it is running.
  • Loading branch information
trianglesphere committed Oct 12, 2023
1 parent 06c19a4 commit c444974
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions op-proposer/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Metrics struct {

opmetrics.RefMetrics
txmetrics.TxMetrics
opmetrics.RPCMetrics

info prometheus.GaugeVec
up prometheus.Gauge
Expand All @@ -60,6 +61,7 @@ func NewMetrics(procName string) *Metrics {

RefMetrics: opmetrics.MakeRefMetrics(ns, factory),
TxMetrics: txmetrics.MakeTxMetrics(ns, factory),
RPCMetrics: opmetrics.MakeRPCMetrics(ns, factory),

info: *factory.NewGaugeVec(prometheus.GaugeOpts{
Namespace: ns,
Expand Down
4 changes: 4 additions & 0 deletions op-proposer/proposer/l2_output_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ func Main(version string, cliCtx *cli.Context) error {

rpcCfg := cfg.RPCConfig
server := oprpc.NewServer(rpcCfg.ListenAddr, rpcCfg.ListenPort, version, oprpc.WithLogger(l))
if rpcCfg.EnableAdmin {
server.AddAPI(oprpc.ToGethAdminAPI(oprpc.NewCommonAdminAPI(&m.RPCMetrics, l)))
l.Info("Admin RPC enabled")
}
if err := server.Start(); err != nil {
return fmt.Errorf("error starting RPC server: %w", err)
}
Expand Down
8 changes: 8 additions & 0 deletions op-service/rpc/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ import (
oplog "github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/metrics"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
)

func ToGethAdminAPI(api *CommonAdminAPI) rpc.API {
return rpc.API{
Namespace: "admin",
Service: api,
}
}

type CommonAdminAPI struct {
M metrics.RPCMetricer
log log.Logger
Expand Down
2 changes: 2 additions & 0 deletions ops-bedrock/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ services:
ports:
- "6062:6060"
- "7302:7300"
- "6546:8545"
environment:
OP_PROPOSER_L1_ETH_RPC: http://l1:8545
OP_PROPOSER_ROLLUP_RPC: http://op-node:8545
Expand All @@ -105,6 +106,7 @@ services:
OP_PROPOSER_PPROF_ENABLED: "true"
OP_PROPOSER_METRICS_ENABLED: "true"
OP_PROPOSER_ALLOW_NON_FINALIZED: "true"
OP_PROPOSER_RPC_ENABLE_ADMIN: "true"

op-batcher:
depends_on:
Expand Down

0 comments on commit c444974

Please sign in to comment.