Commit dd604bd9 authored by dhanu's avatar dhanu

cleanup-logging-service-utils add admin_setLogLevel

parent 4e8c6222
......@@ -127,6 +127,10 @@ func (s *l2VerifierBackend) SequencerActive(ctx context.Context) (bool, error) {
return false, nil
}
func (s *l2VerifierBackend) SetLogLevel(ctx context.Context, lvl string) error {
return nil
}
func (s *L2Verifier) L2Finalized() eth.L2BlockRef {
return s.derivation.Finalized()
}
......
......@@ -28,6 +28,7 @@ type driverClient interface {
StartSequencer(ctx context.Context, blockHash common.Hash) error
StopSequencer(context.Context) (common.Hash, error)
SequencerActive(context.Context) (bool, error)
SetLogLevel(ctx context.Context, lvl string) error
}
type rpcMetrics interface {
......@@ -71,6 +72,12 @@ func (n *adminAPI) SequencerActive(ctx context.Context) (bool, error) {
return n.dr.SequencerActive(ctx)
}
func (n *adminAPI) SetLogLevel(ctx context.Context, lvl string) error {
recordDur := n.m.RecordRPCServerRequest("admin_setLogLevel")
defer recordDur()
return n.dr.SetLogLevel(ctx, lvl)
}
type nodeAPI struct {
config *rollup.Config
client l2EthClient
......
......@@ -224,3 +224,7 @@ func (c *mockDriverClient) StopSequencer(ctx context.Context) (common.Hash, erro
func (c *mockDriverClient) SequencerActive(ctx context.Context) (bool, error) {
return c.Mock.MethodCalled("SequencerActive").Get(0).(bool), nil
}
func (c *mockDriverClient) SetLogLevel(ctx context.Context, lvl string) error {
return c.Mock.MethodCalled("SetLogLevel").Get(0).(error)
}
......@@ -52,6 +52,9 @@ type Driver struct {
// true when the sequencer is active, false when it is not.
sequencerActive chan chan bool
// Upon receiving a channel in this channel, set the log level.
seLogLevel chan stringAndErrorChannel
// sequencerNotifs is notified when the sequencer is started or stopped
sequencerNotifs SequencerStateListener
......@@ -388,6 +391,16 @@ func (s *Driver) eventLoop() {
}
case respCh := <-s.sequencerActive:
respCh <- !s.driverConfig.SequencerStopped
case respCh := <-s.seLogLevel:
lvlStr := respCh.str
h := s.log.GetHandler()
lvl, err := log.LvlFromString(lvlStr)
if err != nil {
respCh.err <- err
continue
}
h = log.LvlFilterHandler(lvl, h)
s.log.SetHandler(h)
case <-s.done:
return
}
......@@ -469,6 +482,22 @@ func (s *Driver) SequencerActive(ctx context.Context) (bool, error) {
}
}
func (s *Driver) SetLogLevel(ctx context.Context, lvl string) error {
sCh := stringAndErrorChannel{
str: lvl,
err: make(chan error, 1),
}
select {
case <-ctx.Done():
return ctx.Err()
case s.seLogLevel <- sCh:
select {
case <-ctx.Done():
return ctx.Err()
}
}
}
// syncStatus returns the current sync status, and should only be called synchronously with
// the driver event loop to avoid retrieval of an inconsistent status.
func (s *Driver) syncStatus() *eth.SyncStatus {
......@@ -546,6 +575,11 @@ type hashAndErrorChannel struct {
err chan error
}
type stringAndErrorChannel struct {
str string
err chan error
}
// checkForGapInUnsafeQueue checks if there is a gap in the unsafe queue and attempts to retrieve the missing payloads from an alt-sync method.
// WARNING: This is only an outgoing signal, the blocks are not guaranteed to be retrieved.
// Results are received through OnUnsafeL2Payload.
......
......@@ -5,7 +5,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/rollup"
......@@ -60,6 +59,6 @@ func (r *RollupClient) SequencerActive(ctx context.Context) (bool, error) {
return result, err
}
func (r *RollupClient) SetLogLevel(ctx context.Context, lvl log.Lvl) error {
func (r *RollupClient) SetLogLevel(ctx context.Context, lvl string) error {
return r.rpc.CallContext(ctx, nil, "admin_setLogLevel", lvl)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment