Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions arbnode/delayed.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,11 @@ func (b *DelayedBridge) logsToDeliveredMessages(ctx context.Context, logs []type
},
ParentChainBlockNumber: parsedLog.Raw.BlockNumber,
}
err := msg.Message.FillInBatchGasFieldsWithParentBlock(batchFetcher, msg.ParentChainBlockNumber)
if err != nil {
return nil, err
if batchFetcher != nil {
err := msg.Message.FillInBatchGasFieldsWithParentBlock(batchFetcher, msg.ParentChainBlockNumber)
if err != nil {
return nil, err
}
}
messages = append(messages, msg)
}
Expand Down
11 changes: 5 additions & 6 deletions arbnode/inbox_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,15 @@ func (t *InboxTracker) legacyGetDelayedMessageAndAccumulator(ctx context.Context
}
var acc common.Hash
copy(acc[:], data[:32])
msg, err := arbostypes.ParseIncomingL1Message(bytes.NewReader(data[32:]), nil)
batchFetcher := func(batchNum uint64) ([]byte, error) {
data, _, err := t.txStreamer.inboxReader.GetSequencerMessageBytes(ctx, batchNum)
return data, err
}
msg, err := arbostypes.ParseIncomingL1Message(bytes.NewReader(data[32:]), batchFetcher)
if err != nil {
return nil, common.Hash{}, err
}

err = msg.FillInBatchGasFields(func(batchNum uint64) ([]byte, error) {
data, _, err := t.txStreamer.inboxReader.GetSequencerMessageBytes(ctx, batchNum)
return data, err
})

return msg, acc, err
}

Expand Down
11 changes: 8 additions & 3 deletions arbnode/transaction_streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,11 @@ func (s *TransactionStreamer) addMessagesAndReorg(batch ethdb.Batch, msgIdxOfFir
continue
}
msgBlockNum := new(big.Int).SetUint64(oldMessage.Message.Header.BlockNumber)
delayedInBlock, err := s.delayedBridge.LookupMessagesInRange(s.GetContext(), msgBlockNum, msgBlockNum, nil)
batchFetcher := func(batchNum uint64, parentChainBlockNumber uint64) ([]byte, error) {
data, _, err := s.inboxReader.GetSequencerMessageBytesForParentBlock(s.GetContext(), batchNum, parentChainBlockNumber)
return data, err
}
delayedInBlock, err := s.delayedBridge.LookupMessagesInRange(s.GetContext(), msgBlockNum, msgBlockNum, batchFetcher)
if err != nil {
log.Error("reorg-resequence: failed to serialize old delayed message from database", "err", err)
continue
Expand Down Expand Up @@ -516,7 +520,7 @@ func (s *TransactionStreamer) GetMessage(msgIdx arbutil.MessageIndex) (*arbostyp
}

if s.inboxReader != nil {
err = message.Message.FillInBatchGasFields(func(batchNum uint64) ([]byte, error) {
batchFetcher := func(batchNum uint64) ([]byte, error) {
ctx, err := s.GetContextSafe()
if err != nil {
return nil, err
Expand All @@ -533,7 +537,8 @@ func (s *TransactionStreamer) GetMessage(msgIdx arbutil.MessageIndex) (*arbostyp
}

return data, err
})
}
err = message.Message.FillInBatchGasFields(batchFetcher)
if err != nil {
return nil, err
}
Expand Down
13 changes: 10 additions & 3 deletions arbos/arbostypes/incomingmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,20 @@ func LegacyCostForStats(stats *BatchDataStats) uint64 {
}

func (msg *L1IncomingMessage) FillInBatchGasFields(batchFetcher FallibleBatchFetcher) error {
return msg.FillInBatchGasFieldsWithParentBlock(FromFallibleBatchFetcher(batchFetcher), msg.Header.BlockNumber)
var fetcher FallibleBatchFetcherWithParentBlock
if batchFetcher != nil {
fetcher = FromFallibleBatchFetcher(batchFetcher)
}
return msg.FillInBatchGasFieldsWithParentBlock(fetcher, msg.Header.BlockNumber)
}

func (msg *L1IncomingMessage) FillInBatchGasFieldsWithParentBlock(batchFetcher FallibleBatchFetcherWithParentBlock, parentChainBlockNumber uint64) error {
if batchFetcher == nil || msg.Header.Kind != L1MessageType_BatchPostingReport {
if msg.Header.Kind != L1MessageType_BatchPostingReport {
return nil
}
if batchFetcher == nil {
return fmt.Errorf("batch fetcher is nil, cannot fill in batch gas fields for batch posting report (parentChainBlockNumber %d)", parentChainBlockNumber)
}
if msg.BatchDataStats != nil && msg.LegacyBatchGasCost != nil {
return nil
}
Expand All @@ -220,7 +227,7 @@ func (msg *L1IncomingMessage) FillInBatchGasFieldsWithParentBlock(batchFetcher F
// missing BatchDataStats and fail there, since it does know the arbos
// version. In practice, any node that supports arbos50 populates both
// fields together, so this fallback path should not be reached.
log.Warn("Failed reading batch data for filling message - leaving BatchDataStats empty")
log.Warn("Failed reading batch data for filling message - leaving BatchDataStats empty", "batchNum", batchNum, "err", err)
return nil
} else {
gotHash := crypto.Keccak256Hash(batchData)
Expand Down
Loading
Loading