Skip to content

Commit

Permalink
Normalize a few log calls
Browse files Browse the repository at this point in the history
A handful of log calls were not using the package level custom logger
  • Loading branch information
joshuacolvin0 authored and hkalodner committed May 23, 2022
1 parent b7661ec commit 1c32e2e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
3 changes: 1 addition & 2 deletions packages/arb-rpc-node/batcher/batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"

"github.com/offchainlabs/arbitrum/packages/arb-evm/message"
"github.com/offchainlabs/arbitrum/packages/arb-rpc-node/snapshot"
Expand Down Expand Up @@ -203,7 +202,7 @@ func newBatcher(
server.Lock()
if server.pendingSentBatches.Len() > 0 {
if err := server.checkForNextBatch(ctx, receiptFetcher); err != nil {
log.Error().Err(err).Msg("error checking for submitted batch")
logger.Error().Err(err).Msg("error checking for submitted batch")
}
}
server.Unlock()
Expand Down
8 changes: 4 additions & 4 deletions packages/arb-rpc-node/batcher/sequencerBatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,16 +893,16 @@ func (b *SequencerBatcher) publishBatch(ctx context.Context, dontPublishBlockNum
doingReorg := b.consecutiveShouldReorgGaps >= 10

var msg string
var log *zerolog.Event
var partialLog *zerolog.Event
if doingReorg {
msg = "Exceeded max sequencer delay! Reorganizing to compensate..."
log = logger.Error()
partialLog = logger.Error()
} else {
msg = "Exceeded max sequencer delay! Waiting to see if this is consistent..."
log = logger.Warn()
partialLog = logger.Warn()
}

log.
partialLog.
Str("delayBlocks", delayBlocks.String()).
Str("delaySeconds", delaySeconds.String()).
Str("aheadBlocks", aheadBlocks.String()).
Expand Down
31 changes: 15 additions & 16 deletions packages/arb-rpc-node/cmd/arb-node/arb-node.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"github.com/pkg/errors"

"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog/pkgerrors"

"github.com/offchainlabs/arbitrum/packages/arb-node-core/cmdhelp"
Expand Down Expand Up @@ -219,7 +218,7 @@ func startup() error {
if config.PProfEnable {
go func() {
err := http.ListenAndServe("localhost:8081", pprofMux)
log.Error().Err(err).Msg("profiling server failed")
logger.Error().Err(err).Msg("profiling server failed")
}()
}

Expand All @@ -238,7 +237,7 @@ func startup() error {
}

if config.Node.Type() == configuration.ValidatorNodeType && config.Core.CheckpointMaxExecutionGas != 0 {
log.Warn().Msg("allowing for infinite core execution because running as validator")
logger.Warn().Msg("allowing for infinite core execution because running as validator")
config.Core.CheckpointMaxExecutionGas = 0
}

Expand Down Expand Up @@ -272,7 +271,7 @@ func startup() error {
go func() {
err := nodehealth.StartNodeHealthCheck(ctx, healthChan, metricsConfig.Registry)
if err != nil {
log.Error().Err(err).Msg("healthcheck server failed")
logger.Error().Err(err).Msg("healthcheck server failed")
}
}()
}
Expand Down Expand Up @@ -461,17 +460,17 @@ func startup() error {
go func() {
clnt, err := ethclient.DialContext(ctx, config.Node.Forwarder.Target)
if err != nil {
log.Warn().Err(err).Msg("failed to connect to forward target")
logger.Warn().Err(err).Msg("failed to connect to forward target")
clnt = nil
}
failCount := 0
for {
valid, err := checkBlockHash(ctx, clnt, db)
if err != nil {
log.Warn().Err(err).Msg("failed to lookup blockhash for consistency check")
logger.Warn().Err(err).Msg("failed to lookup blockhash for consistency check")
clnt, err = ethclient.DialContext(ctx, config.Node.Forwarder.Target)
if err != nil {
log.Warn().Err(err).Msg("failed to connect to forward target")
logger.Warn().Err(err).Msg("failed to connect to forward target")
clnt = nil
}
} else {
Expand All @@ -482,7 +481,7 @@ func startup() error {
}
}
if failCount >= failLimit {
log.Error().Msg("exiting due to repeated block hash mismatches")
logger.Error().Msg("exiting due to repeated block hash mismatches")
cancelFunc()
return
}
Expand Down Expand Up @@ -585,7 +584,7 @@ func startValidator(
chainState := ChainState{}
if config.Validator.ContractWalletAddress != "" {
if !ethcommon.IsHexAddress(config.Validator.ContractWalletAddress) {
log.Error().Str("address", config.Validator.ContractWalletAddress).Msg("invalid validator smart contract wallet")
logger.Error().Str("address", config.Validator.ContractWalletAddress).Msg("invalid validator smart contract wallet")
return nil, errors.New("invalid validator smart contract wallet address")
}
chainState.ValidatorWallet = config.Validator.ContractWalletAddress
Expand Down Expand Up @@ -620,7 +619,7 @@ func startValidator(
}
var validatorAddress *ethcommon.Address
if chainState.ValidatorWallet != "" {
log.Info().Str("address", chainState.ValidatorWallet).Msg("validator using smart contract wallet")
logger.Info().Str("address", chainState.ValidatorWallet).Msg("validator using smart contract wallet")
addr := ethcommon.HexToAddress(chainState.ValidatorWallet)
validatorAddress = &addr

Expand All @@ -636,9 +635,9 @@ func startValidator(
return nil, fmt.Errorf("validator smart contract wallet owner %v doesn't match validator wallet %v", owner, valAuth.From())
}
} else if config.Validator.OnlyCreateWalletContract {
log.Info().Msg("only creating validator smart contract and exiting")
logger.Info().Msg("only creating validator smart contract and exiting")
} else {
log.Info().Msg("validator smart contract wallet creation delayed until needed")
logger.Info().Msg("validator smart contract wallet creation delayed until needed")
}

onValidatorWalletCreated := func(addr ethcommon.Address) {}
Expand All @@ -647,19 +646,19 @@ func startValidator(
chainState.ValidatorWallet = addr.String()
newChainStateData, err := json.Marshal(chainState)
if err != nil {
log.Warn().Err(err).Msg("failed to marshal chain state")
logger.Warn().Err(err).Msg("failed to marshal chain state")
} else if err := ioutil.WriteFile(config.Validator.ContractWalletAddressFilename, newChainStateData, 0644); err != nil {
log.Warn().Err(err).Msg("failed to write chain state config")
logger.Warn().Err(err).Msg("failed to write chain state config")
}
log.
logger.
Info().
Str("address", chainState.ValidatorWallet).
Str("filename", config.Validator.ContractWalletAddressFilename).
Msg("created validator smart contract wallet")
}
} else {
onValidatorWalletCreated = func(addr ethcommon.Address) {
log.Error().Str("address", addr.String()).Msg("created wallet when --validator.wallet-address provided")
logger.Error().Str("address", addr.String()).Msg("created wallet when --validator.wallet-address provided")
}
}

Expand Down

0 comments on commit 1c32e2e

Please sign in to comment.