Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
Use a log helper that will log only after a certain of time or retries
and utilize the emphemeral error handler in batch poster
  • Loading branch information
ImJeremyHe committed Nov 27, 2024
1 parent d683e16 commit bf4e0c8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
9 changes: 6 additions & 3 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,8 @@ func AccessList(opts *AccessListOpts) types.AccessList {
return l
}

var EspressoVerificationError = errors.New("waiting for espresso verification")

// Adds a block merkle proof to an Espresso justification, providing a proof that a set of transactions
// hashes to some light client state root.
func (b *BatchPoster) checkEspressoValidation(
Expand Down Expand Up @@ -587,8 +589,6 @@ func (b *BatchPoster) checkEspressoValidation(
return nil
}

log.Warn("this message has not been finalized on L1 or validated")

if b.streamer.UseEscapeHatch {
skip, err := b.streamer.getSkipVerificationPos()
if err != nil {
Expand All @@ -612,7 +612,7 @@ func (b *BatchPoster) checkEspressoValidation(
return nil
}

return fmt.Errorf("waiting for espresso finalization, pos: %d", b.building.msgCount)
return EspressoVerificationError
}

func (b *BatchPoster) submitEspressoTransactionPos(pos arbutil.MessageIndex) error {
Expand Down Expand Up @@ -1815,12 +1815,14 @@ func (b *BatchPoster) Start(ctxIn context.Context) {
storageRaceEphemeralErrorHandler := util.NewEphemeralErrorHandler(5*time.Minute, storage.ErrStorageRace.Error(), time.Minute)
normalGasEstimationFailedEphemeralErrorHandler := util.NewEphemeralErrorHandler(5*time.Minute, ErrNormalGasEstimationFailed.Error(), time.Minute)
accumulatorNotFoundEphemeralErrorHandler := util.NewEphemeralErrorHandler(5*time.Minute, AccumulatorNotFoundErr.Error(), time.Minute)
espressoEphemeralErrorHandler := util.NewEphemeralErrorHandler(80*time.Minute, EspressoVerificationError.Error(), time.Hour)
resetAllEphemeralErrs := func() {
commonEphemeralErrorHandler.Reset()
exceedMaxMempoolSizeEphemeralErrorHandler.Reset()
storageRaceEphemeralErrorHandler.Reset()
normalGasEstimationFailedEphemeralErrorHandler.Reset()
accumulatorNotFoundEphemeralErrorHandler.Reset()
espressoEphemeralErrorHandler.Reset()
}
b.CallIteratively(func(ctx context.Context) time.Duration {
var err error
Expand Down Expand Up @@ -1875,6 +1877,7 @@ func (b *BatchPoster) Start(ctxIn context.Context) {
// Likely the inbox tracker just isn't caught up.
// Let's see if this error disappears naturally.
logLevel = commonEphemeralErrorHandler.LogLevel(err, logLevel)
logLevel = espressoEphemeralErrorHandler.LogLevel(err, logLevel)
// If the error matches one of these, it's only logged at debug for the first minute,
// then at warn for the next 4 minutes, then at error. If the error isn't one of these,
// it'll be logged at warn for the first minute, then at error.
Expand Down
18 changes: 18 additions & 0 deletions arbnode/log_cleaner.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package arbnode

import (
"time"

log_helper "github.com/EspressoSystems/espresso-sequencer-go/log-helper"
)

const FETCH_MERKLE_ROOT = "espresso-fetch-merkle-root"
const ESPRESSO_VERIFICATION = "espresso-verification"

var logger = log_helper.NewLogger()

func init() {
// An error log will occur if more than an hour has passed since the first attempt
logger.AddLogAfterDurationStrategy(FETCH_MERKLE_ROOT, "0", time.Hour)
logger.AddLogAfterDurationStrategy(ESPRESSO_VERIFICATION, "0", time.Hour)
}
5 changes: 4 additions & 1 deletion arbnode/transaction_streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"fmt"
"math/big"
"reflect"
"strconv"
"sync"
"sync/atomic"
"testing"
Expand Down Expand Up @@ -1327,7 +1328,9 @@ func (s *TransactionStreamer) pollSubmittedTransactionForFinality(ctx context.Co
// Verify the merkle tree proof
snapshot, err := s.lightClientReader.FetchMerkleRoot(height, nil)
if err != nil {
log.Warn("could not get the merkle root", "height", height, "err", err)
logger.Attempt(FETCH_MERKLE_ROOT, strconv.FormatUint(height, 10), func() {
log.Warn("could not get the merkle root", "height", height, "err", err)
})
return false
}

Expand Down

0 comments on commit bf4e0c8

Please sign in to comment.