Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshvanahalli committed Jan 27, 2025
1 parent 80358d7 commit db513f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 8 additions & 3 deletions execution/gethexec/express_lane_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,18 @@ func (es *expressLaneService) sequenceExpressLaneSubmission(
}
roundInfo, _ := es.roundInfo.Get(msg.Round)

prev, exists := roundInfo.msgAndResultBySequenceNumber[msg.SequenceNumber]

// Check if the submission nonce is too low.
if msg.SequenceNumber < roundInfo.sequence {
if exists && bytes.Equal(prev.msg.Signature, msg.Signature) {
return nil
}
return timeboost.ErrSequenceNumberTooLow
}

// Check if a duplicate submission exists already, and reject if so.
if prev, exists := roundInfo.msgAndResultBySequenceNumber[msg.SequenceNumber]; exists {
if exists {
if bytes.Equal(prev.msg.Signature, msg.Signature) {
return nil
}
Expand All @@ -342,7 +347,8 @@ func (es *expressLaneService) sequenceExpressLaneSubmission(
// Log an informational warning if the message's sequence number is in the future.
if msg.SequenceNumber > roundInfo.sequence {
if seqConfig.Timeboost.MaxQueuedTxCount != 0 &&
len(roundInfo.msgAndResultBySequenceNumber) >= seqConfig.Timeboost.MaxQueuedTxCount {
// Pending msgs count=(total msgs present in the map)-(number of processed messages=roundInfo.Sequence)
len(roundInfo.msgAndResultBySequenceNumber)-int(roundInfo.sequence) >= seqConfig.Timeboost.MaxQueuedTxCount {
return fmt.Errorf("reached limit for queuing of future sequence number transactions, please try again with the correct sequence number. Limit: %d, Current sequence number: %d", seqConfig.Timeboost.MaxQueuedTxCount, roundInfo.sequence)
}
log.Info("Received express lane submission with future sequence number", "SequenceNumber", msg.SequenceNumber)
Expand All @@ -360,7 +366,6 @@ func (es *expressLaneService) sequenceExpressLaneSubmission(
if !exists {
break
}
delete(roundInfo.msgAndResultBySequenceNumber, nextMsgAndResult.msg.SequenceNumber)
// Queued txs cannot use this message's context as it would lead to context canceled error once the result for this message is available and returned
// Hence using context.Background() allows unblocking of queued up txs even if current tx's context has errored out
var queueCtx context.Context
Expand Down
7 changes: 1 addition & 6 deletions execution/gethexec/express_lane_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,19 +386,14 @@ func Test_expressLaneService_sequenceExpressLaneSubmission_outOfOrder(t *testing
require.Equal(t, 2, len(stubPublisher.publishedTxOrder))
els.roundInfoMutex.Lock()
roundInfo, _ := els.roundInfo.Get(0)
require.Equal(t, 3, len(roundInfo.msgAndResultBySequenceNumber)) // Processed txs are deleted
require.Equal(t, 5, len(roundInfo.msgAndResultBySequenceNumber))
els.roundInfoMutex.Unlock()

wg.Add(2) // 4 & 5 should be able to get in after 3 so we add a delta of 2
err := els.sequenceExpressLaneSubmission(ctx, buildValidSubmissionWithSeqAndTx(t, 0, 3, emptyTx))
require.NoError(t, err)
wg.Wait()
require.Equal(t, 5, len(stubPublisher.publishedTxOrder))

els.roundInfoMutex.Lock()
roundInfo, _ = els.roundInfo.Get(0)
require.Equal(t, 1, len(roundInfo.msgAndResultBySequenceNumber)) // Tx with seq num 10 should still be present
els.roundInfoMutex.Unlock()
}

func Test_expressLaneService_sequenceExpressLaneSubmission_erroredTx(t *testing.T) {
Expand Down

0 comments on commit db513f0

Please sign in to comment.