Skip to content

Commit

Permalink
fix: seq-sender latestVirtualTime (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniRamirezM authored Jan 23, 2025
1 parent 7f89e6c commit 57b4b15
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions sequencesender/ethtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,13 @@ func (s *SequenceSender) syncEthTxResults(ctx context.Context) (uint64, error) {
}

// syncAllEthTxResults syncs all tx results from L1
func (s *SequenceSender) syncAllEthTxResults(ctx context.Context) error {
func (s *SequenceSender) syncAllEthTxResults(ctx context.Context) (time.Time, error) {
latestVirtualTime := time.Now().Local().Add(-s.cfg.LastBatchVirtualizationTimeMaxWaitPeriod.Duration)
// Get all results
results, err := s.ethTxManager.ResultsByStatus(ctx, nil)
if err != nil {
log.Warnf("error getting results for all tx: %v", err)
return err
return latestVirtualTime, err
}

// Check and update tx status
Expand All @@ -227,7 +228,7 @@ func (s *SequenceSender) syncAllEthTxResults(ctx context.Context) error {
}
txSequence = s.ethTransactions[result.ID]
}

latestVirtualTime = txSequence.SentL1Timestamp
s.updateEthTxResult(txSequence, result)
}
s.mutexEthTx.Unlock()
Expand All @@ -239,7 +240,7 @@ func (s *SequenceSender) syncAllEthTxResults(ctx context.Context) error {
}

log.Infof("%d tx results synchronized", numResults)
return nil
return latestVirtualTime, nil
}

// copyTxData copies tx data in the internal structure
Expand Down
2 changes: 1 addition & 1 deletion sequencesender/ethtx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ func Test_syncAllEthTxResults(t *testing.T) {
logger: log.GetDefaultLogger(),
}

err = ss.syncAllEthTxResults(context.Background())
_, err = ss.syncAllEthTxResults(context.Background())
if tt.expectErr != nil {
require.Equal(t, tt.expectErr, err)
} else {
Expand Down
2 changes: 1 addition & 1 deletion sequencesender/sequencesender.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (s *SequenceSender) Start(ctx context.Context) {
}

// Sync all monitored sent L1 tx
err = s.syncAllEthTxResults(ctx)
s.latestVirtualTime, err = s.syncAllEthTxResults(ctx)
if err != nil {
s.logger.Fatalf("failed to sync monitored tx results, error: %v", err)
}
Expand Down

0 comments on commit 57b4b15

Please sign in to comment.