Skip to content

Commit

Permalink
Fix delayed message readLastAcc logging
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower committed Sep 13, 2024
1 parent f8bbc38 commit ff4802e
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions arbnode/inbox_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,26 @@ func (r *InboxReader) CaughtUp() chan struct{} {
return r.caughtUpChan
}

type lazyHashLogging struct {
f func() common.Hash
}

func (l lazyHashLogging) String() string {
return l.f().String()
}

func (l lazyHashLogging) TerminalString() string {
return l.f().TerminalString()
}

func (l lazyHashLogging) MarshalText() ([]byte, error) {
return l.f().MarshalText()
}

func (l lazyHashLogging) Format(s fmt.State, c rune) {
l.f().Format(s, c)
}

func (r *InboxReader) run(ctx context.Context, hadError bool) error {
readMode := r.config().ReadMode
from, err := r.getNextBlockToRead(ctx)
Expand Down Expand Up @@ -508,9 +528,9 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error {
}
log.Trace(
"Found sequencer batches",
"firstSequenceNumber", firstBatch.SequenceNumber,
"newBatchesCount", len(sequencerBatches),
"duplicateBatches", duplicateBatches,
"firstSequenceNumber", firstBatch.SequenceNumber,
"reorgingSequencer", reorgingSequencer,
"readBeforeAcc", firstBatch.BeforeInboxAcc,
"haveBeforeAcc", havePrevAcc,
Expand Down Expand Up @@ -546,12 +566,15 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error {
}
log.Trace(
"Found delayed messages",
"count", len(delayedMessages),
"firstSequenceNumber", beforeCount,
"count", len(delayedMessages),
"reorgingDelayed", reorgingDelayed,
"readBeforeAcc", beforeAcc,
"haveBeforeAcc", havePrevAcc,
"readLastAcc", delayedMessages[len(delayedMessages)-1].AfterInboxAcc,
"readLastAcc", lazyHashLogging{func() common.Hash {
// Only compute this if we need to log it, as it's expensive
return delayedMessages[len(delayedMessages)-1].AfterInboxAcc()
}},
)
} else if missingDelayed && to.Cmp(currentHeight) >= 0 {
log.Trace("Didn't find expected delayed messages", "from", from, "to", to, "currentHeight", currentHeight)
Expand Down

0 comments on commit ff4802e

Please sign in to comment.