Skip to content

Commit

Permalink
Store transaction pos in batch poster (#219)
Browse files Browse the repository at this point in the history
* Move submit transaction pos from tx_streamer to batch poster
  • Loading branch information
Sneh1999 committed Sep 5, 2024
1 parent ef2c5cc commit 715491f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
11 changes: 11 additions & 0 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,17 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
)
break
}

// If the message is an Espresso message, store the pos in the database to be used later
// to submit the message to hotshot for finalization.
if arbos.IsEspressoMsg(msg.Message) {
err = b.streamer.SubmitEspressoTransactionPos(b.building.msgCount, b.streamer.db.NewBatch())
if err != nil {
log.Error("failed to submit espresso transaction pos", "pos", b.building.msgCount, "err", err)
break
}
}

err = b.addEspressoBlockMerkleProof(ctx, msg)
if err != nil {
return false, fmt.Errorf("error adding hotshot block merkle proof to justification: %w", err)
Expand Down
17 changes: 1 addition & 16 deletions arbnode/transaction_streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1023,16 +1023,6 @@ func (s *TransactionStreamer) WriteMessageFromSequencer(
}

s.broadcastMessages([]arbostypes.MessageWithMetadataAndBlockHash{msgWithBlockHash}, pos)
s.espressoTxnsStateInsertionMutex.Lock()
defer s.espressoTxnsStateInsertionMutex.Unlock()

if arbos.IsEspressoMsg(msgWithMeta.Message) {
err = s.SubmitEspressoTransactionPos(pos, s.db.NewBatch())
if err != nil {
return err
}
}

return nil
}

Expand Down Expand Up @@ -1454,12 +1444,7 @@ func (s *TransactionStreamer) submitEspressoTransactions(ctx context.Context, ig
return s.config().EspressoTxnsPollingInterval
}

espressoTx := espressoTypes.Transaction{
Payload: bytes[0],
Namespace: s.config().EspressoNamespace,
}

log.Info("submitting transaction to espresso using sovereign sequencer", "tx", espressoTx)
log.Info("submitting transaction to espresso using sovereign sequencer")

hash, err := s.espressoClient.SubmitTransaction(ctx, espressoTypes.Transaction{
Payload: bytes[0],
Expand Down

0 comments on commit 715491f

Please sign in to comment.