Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: seq-sender latestVirtualTime #270

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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
Loading