Skip to content

Commit

Permalink
chore: fix log errors
Browse files Browse the repository at this point in the history
  • Loading branch information
krish-nr committed Apr 17, 2024
1 parent a5ec200 commit 28a0772
Show file tree
Hide file tree
Showing 64 changed files with 93 additions and 129 deletions.
2 changes: 1 addition & 1 deletion op-node/client/polling.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/rpc"

"github.com/ethereum-optimism/optimism/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/logutil/log"
)

var ErrSubscriberClosed = errors.New("subscriber closed")
Expand Down
3 changes: 1 addition & 2 deletions op-node/client/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/prometheus/client_golang/prometheus"

"github.com/ethereum-optimism/optimism/logutil/log"

"github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-service/backoff"

"github.com/ethereum/go-ethereum/rpc"
Expand Down
2 changes: 1 addition & 1 deletion op-node/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"strconv"
"syscall"

"github.com/ethereum-optimism/optimism/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-node/cmd/doc"
"github.com/ethereum-optimism/optimism/op-node/logutil/log"

"github.com/urfave/cli"

Expand Down
3 changes: 1 addition & 2 deletions op-node/eth/heads.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"

"github.com/ethereum-optimism/optimism/logutil/log"

"github.com/ethereum-optimism/optimism/op-node/logutil/log"
opservice "github.com/ethereum-optimism/optimism/op-service"
)

Expand Down
2 changes: 1 addition & 1 deletion op-node/heartbeat/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"net/http"
"time"

"github.com/ethereum-optimism/optimism/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/logutil/log"
)

// SendInterval determines the delay between requests. This must be larger than the MinHeartbeatInterval in the server.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions op-node/node/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"

"github.com/ethereum-optimism/optimism/logutil/log"

"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/version"
)
Expand Down
3 changes: 1 addition & 2 deletions op-node/node/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import (
"fmt"

"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/sources"

"github.com/ethereum-optimism/optimism/logutil/log"

gn "github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc"
)
Expand Down
15 changes: 7 additions & 8 deletions op-node/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/event"

"github.com/ethereum-optimism/optimism/logutil/log"

"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/eth"
log2 "github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/ethereum-optimism/optimism/op-node/p2p"
"github.com/ethereum-optimism/optimism/op-node/rollup/driver"
"github.com/ethereum-optimism/optimism/op-node/sources"
)

type OpNode struct {
log log.Logger
log log2.Logger
appVersion string
metrics *metrics.Metrics

Expand All @@ -49,7 +48,7 @@ type OpNode struct {
// The OpNode handles incoming gossip
var _ p2p.GossipIn = (*OpNode)(nil)

func New(ctx context.Context, cfg *Config, log log.Logger, snapshotLog log.Logger, appVersion string, m *metrics.Metrics) (*OpNode, error) {
func New(ctx context.Context, cfg *Config, log log2.Logger, snapshotLog log2.Logger, appVersion string, m *metrics.Metrics) (*OpNode, error) {
if err := cfg.Check(); err != nil {
return nil, err
}
Expand All @@ -74,7 +73,7 @@ func New(ctx context.Context, cfg *Config, log log.Logger, snapshotLog log.Logge
return n, nil
}

func (n *OpNode) init(ctx context.Context, cfg *Config, snapshotLog log.Logger) error {
func (n *OpNode) init(ctx context.Context, cfg *Config, snapshotLog log2.Logger) error {
if err := n.initTracer(ctx, cfg); err != nil {
return err
}
Expand Down Expand Up @@ -180,7 +179,7 @@ func (n *OpNode) initRuntimeConfig(ctx context.Context, cfg *Config) error {
return errors.New("failed to load runtime configuration repeatedly")
}

func (n *OpNode) initL2(ctx context.Context, cfg *Config, snapshotLog log.Logger) error {
func (n *OpNode) initL2(ctx context.Context, cfg *Config, snapshotLog log2.Logger) error {
rpcClient, err := cfg.L2.Setup(ctx, n.log)
if err != nil {
return fmt.Errorf("failed to setup L2 execution-engine RPC client: %w", err)
Expand All @@ -202,7 +201,7 @@ func (n *OpNode) initL2(ctx context.Context, cfg *Config, snapshotLog log.Logger
// If the L2 sync config is present, use it to create a sync client
if cfg.L2Sync != nil {
if err := cfg.L2Sync.Check(); err != nil {
log.Info("L2 sync config is not present, skipping L2 sync client setup", "err", err)
log2.Info("L2 sync config is not present, skipping L2 sync client setup", "err", err)
} else {
rpcSyncClient, err := cfg.L2Sync.Setup(ctx, n.log)
if err != nil {
Expand Down Expand Up @@ -252,7 +251,7 @@ func (n *OpNode) initMetricsServer(ctx context.Context, cfg *Config) error {
n.log.Info("starting metrics server", "addr", cfg.Metrics.ListenAddr, "port", cfg.Metrics.ListenPort)
go func() {
if err := n.metrics.Serve(ctx, cfg.Metrics.ListenAddr, cfg.Metrics.ListenPort); err != nil {
log.Crit("error starting metrics server", "err", err)
log2.Crit("error starting metrics server", "err", err)
}
}()
return nil
Expand Down
3 changes: 1 addition & 2 deletions op-node/node/runtime_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import (

"github.com/ethereum/go-ethereum/common"

"github.com/ethereum-optimism/optimism/logutil/log"

"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/p2p"
"github.com/ethereum-optimism/optimism/op-node/rollup"
)
Expand Down
3 changes: 1 addition & 2 deletions op-node/node/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import (
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc"

"github.com/ethereum-optimism/optimism/logutil/log"

ophttp "github.com/ethereum-optimism/optimism/op-node/http"
"github.com/ethereum-optimism/optimism/op-node/logutil/log"

"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/ethereum-optimism/optimism/op-node/p2p"
Expand Down
3 changes: 1 addition & 2 deletions op-node/p2p/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import (
"github.com/libp2p/go-libp2p/p2p/net/conngater"
cmgr "github.com/libp2p/go-libp2p/p2p/net/connmgr"

userlog "github.com/ethereum-optimism/optimism/logutil/log"

userlog "github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/rollup"
)

Expand Down
3 changes: 1 addition & 2 deletions op-node/p2p/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ import (
"github.com/ethereum/go-ethereum/p2p/enr"
"github.com/ethereum/go-ethereum/rlp"

"github.com/ethereum-optimism/optimism/logutil/log"

"github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/chaincfg/chainhash"

"github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/rollup"
)

Expand Down
3 changes: 1 addition & 2 deletions op-node/p2p/gossip.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"

"github.com/ethereum-optimism/optimism/logutil/log"

"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/rollup"
)

Expand Down
2 changes: 1 addition & 1 deletion op-node/p2p/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
ma "github.com/multiformats/go-multiaddr"
madns "github.com/multiformats/go-multiaddr-dns"

"github.com/ethereum-optimism/optimism/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/logutil/log"
)

type ExtraHostFeatures interface {
Expand Down
3 changes: 1 addition & 2 deletions op-node/p2p/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ import (
p2pmetrics "github.com/libp2p/go-libp2p/core/metrics"
ma "github.com/multiformats/go-multiaddr"

"github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/metrics"

"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/enode"

"github.com/ethereum-optimism/optimism/logutil/log"

"github.com/ethereum-optimism/optimism/op-node/rollup"
)

Expand Down
3 changes: 1 addition & 2 deletions op-node/p2p/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"github.com/libp2p/go-libp2p/core/network"
ma "github.com/multiformats/go-multiaddr"

"github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/metrics"

"github.com/ethereum-optimism/optimism/logutil/log"
)

type NotificationsMetricer interface {
Expand Down
3 changes: 2 additions & 1 deletion op-node/p2p/peer_gater.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package p2p

import (
log "github.com/ethereum-optimism/optimism/logutil/log"
peer "github.com/libp2p/go-libp2p/core/peer"
slices "golang.org/x/exp/slices"

"github.com/ethereum-optimism/optimism/op-node/logutil/log"
)

// ConnectionFactor is the factor by which we multiply the connection score.
Expand Down
2 changes: 1 addition & 1 deletion op-node/p2p/peer_scorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
pubsub "github.com/libp2p/go-libp2p-pubsub"
peer "github.com/libp2p/go-libp2p/core/peer"

log "github.com/ethereum-optimism/optimism/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/logutil/log"
)

type scorer struct {
Expand Down
4 changes: 2 additions & 2 deletions op-node/p2p/peer_scores.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package p2p

import (
log "github.com/ethereum-optimism/optimism/logutil/log"

pubsub "github.com/libp2p/go-libp2p-pubsub"
host "github.com/libp2p/go-libp2p/core/host"

"github.com/ethereum-optimism/optimism/op-node/logutil/log"
)

// ConfigurePeerScoring configures the peer scoring parameters for the pubsub
Expand Down
7 changes: 3 additions & 4 deletions op-node/p2p/prepared.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import (
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/enr"

userlog "github.com/ethereum-optimism/optimism/logutil/log"

"github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/rollup"
)

Expand Down Expand Up @@ -42,12 +41,12 @@ func (p *Prepared) Check() error {
}

// Host creates a libp2p host service. Returns nil, nil if p2p is disabled.
func (p *Prepared) Host(log userlog.Logger, reporter metrics.Reporter) (host.Host, error) {
func (p *Prepared) Host(log log.Logger, reporter metrics.Reporter) (host.Host, error) {
return p.HostP2P, nil
}

// Discovery creates a disc-v5 service. Returns nil, nil, nil if discovery is disabled.
func (p *Prepared) Discovery(log userlog.Logger, rollupCfg *rollup.Config, tcpPort uint16) (*enode.LocalNode, *discover.UDPv5, error) {
func (p *Prepared) Discovery(log log.Logger, rollupCfg *rollup.Config, tcpPort uint16) (*enode.LocalNode, *discover.UDPv5, error) {
if p.LocalNode != nil {
dat := OpStackENRData{
chainID: rollupCfg.L2ChainID.Uint64(),
Expand Down
3 changes: 1 addition & 2 deletions op-node/p2p/rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import (
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/enode"

"github.com/ethereum-optimism/optimism/logutil/log"

"github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/metrics"
)

Expand Down
3 changes: 1 addition & 2 deletions op-node/rollup/derive/attributes_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"io"
"time"

"github.com/ethereum-optimism/optimism/logutil/log"

"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/rollup"
)

Expand Down
3 changes: 1 addition & 2 deletions op-node/rollup/derive/batch_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"fmt"
"io"

"github.com/ethereum-optimism/optimism/logutil/log"

"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/rollup"
)

Expand Down
3 changes: 1 addition & 2 deletions op-node/rollup/derive/batches.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package derive
import (
"github.com/ethereum/go-ethereum/core/types"

"github.com/ethereum-optimism/optimism/logutil/log"

"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/rollup"
)

Expand Down
15 changes: 7 additions & 8 deletions op-node/rollup/derive/calldata_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"

"github.com/ethereum-optimism/optimism/logutil/log"

"github.com/ethereum-optimism/optimism/op-node/eth"
log2 "github.com/ethereum-optimism/optimism/op-node/logutil/log"
"github.com/ethereum-optimism/optimism/op-node/rollup"
)

Expand All @@ -28,12 +27,12 @@ type L1TransactionFetcher interface {
// batch submitter transactions.
// This is not a stage in the pipeline, but a wrapper for another stage in the pipeline
type DataSourceFactory struct {
log log.Logger
log log2.Logger
cfg *rollup.Config
fetcher L1TransactionFetcher
}

func NewDataSourceFactory(log log.Logger, cfg *rollup.Config, fetcher L1TransactionFetcher) *DataSourceFactory {
func NewDataSourceFactory(log log2.Logger, cfg *rollup.Config, fetcher L1TransactionFetcher) *DataSourceFactory {
return &DataSourceFactory{log: log, cfg: cfg, fetcher: fetcher}
}

Expand All @@ -53,14 +52,14 @@ type DataSource struct {
id eth.BlockID
cfg *rollup.Config // TODO: `DataFromEVMTransactions` should probably not take the full config
fetcher L1TransactionFetcher
log log.Logger
log log2.Logger

batcherAddr common.Address
}

// NewDataSource creates a new calldata source. It suppresses errors in fetching the L1 block if they occur.
// If there is an error, it will attempt to fetch the result on the next call to `Next`.
func NewDataSource(ctx context.Context, log log.Logger, cfg *rollup.Config, fetcher L1TransactionFetcher, block eth.BlockID, batcherAddr common.Address) DataIter {
func NewDataSource(ctx context.Context, log log2.Logger, cfg *rollup.Config, fetcher L1TransactionFetcher, block eth.BlockID, batcherAddr common.Address) DataIter {
_, txs, err := fetcher.InfoAndTxsByHash(ctx, block.Hash)
if err != nil {
return &DataSource{
Expand All @@ -86,7 +85,7 @@ func (ds *DataSource) Next(ctx context.Context) (eth.Data, error) {
if !ds.open {
if _, txs, err := ds.fetcher.InfoAndTxsByHash(ctx, ds.id.Hash); err == nil {
ds.open = true
ds.data = DataFromEVMTransactions(ds.cfg, ds.batcherAddr, txs, log.New("origin", ds.id))
ds.data = DataFromEVMTransactions(ds.cfg, ds.batcherAddr, txs, log2.New("origin", ds.id))
} else if errors.Is(err, ethereum.NotFound) {
return nil, NewResetError(fmt.Errorf("failed to open calldata source: %w", err))
} else {
Expand All @@ -105,7 +104,7 @@ func (ds *DataSource) Next(ctx context.Context) (eth.Data, error) {
// DataFromEVMTransactions filters all of the transactions and returns the calldata from transactions
// that are sent to the batch inbox address from the batch sender address.
// This will return an empty array if no valid transactions are found.
func DataFromEVMTransactions(config *rollup.Config, batcherAddr common.Address, txs types.Transactions, log log.Logger) []eth.Data {
func DataFromEVMTransactions(config *rollup.Config, batcherAddr common.Address, txs types.Transactions, log log2.Logger) []eth.Data {
var out []eth.Data
l1Signer := config.L1Signer()
for j, tx := range txs {
Expand Down
Loading

0 comments on commit 28a0772

Please sign in to comment.