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 c300fd6 commit b29e5bb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
29 changes: 16 additions & 13 deletions execution/gethexec/express_lane_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,13 @@ func (es *expressLaneService) Start(ctxIn context.Context) {
})
}

func (es *expressLaneService) StopAndWait() {
es.StopWaiter.StopAndWait()
if es.redisCoordinator != nil {
es.redisCoordinator.StopAndWait()
}
}

func (es *expressLaneService) currentRoundHasController() bool {
controller, ok := es.roundControl.Load(es.roundTimingInfo.RoundNumber())
if !ok {
Expand Down Expand Up @@ -472,25 +479,21 @@ func (es *expressLaneService) syncFromRedis() {
return
}

es.roundInfoMutex.Lock()
currentRound := es.roundTimingInfo.RoundNumber()

// If expressLaneRoundInfo for current round doesn't exist yet, we'll add it to the cache
if !es.roundInfo.Contains(currentRound) {
es.roundInfo.Add(currentRound, &expressLaneRoundInfo{
0,
make(map[uint64]*msgAndResult),
})
}
roundInfo, _ := es.roundInfo.Get(currentRound)

redisSeqCount, err := es.redisCoordinator.GetSequenceCount(currentRound)
if err != nil {
log.Error("error fetching current round's global sequence count from redis", "err", err)
} else if redisSeqCount > roundInfo.sequence {
roundInfo.sequence = redisSeqCount
}

es.roundInfoMutex.Lock()
roundInfo, exists := es.roundInfo.Get(currentRound)
if !exists {
// If expressLaneRoundInfo for current round doesn't exist yet, we'll add it to the cache
roundInfo = &expressLaneRoundInfo{0, make(map[uint64]*msgAndResult)}
}
if redisSeqCount > roundInfo.sequence {
roundInfo.sequence = redisSeqCount
}
es.roundInfo.Add(currentRound, roundInfo)
es.roundInfoMutex.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion timeboost/redis_coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (rc *RedisCoordinator) GetAcceptedTxs(round, startSeqNum uint64) []*Express
for _, key := range keys {
seq, err := strconv.Atoi(strings.TrimPrefix(key, prefix))
if err != nil {
log.Error("")
log.Error("Error getting sequence number from the redis key of accepted timeboost Tx", "key", key, "error", err)
continue
}
// #nosec G115
Expand Down
6 changes: 6 additions & 0 deletions timeboost/redis_coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ func TestRedisSeqCoordinatorAtomic(t *testing.T) {
t.Fatalf("error setting round number and sequence count: %v", err)
}
checkSeqCountInRedis(3)
round = 1
err = redisCoordinator.UpdateSequenceCount(round, 4) // shouldn't succeed as the sequence count is a lower value
if err != nil {
t.Fatalf("error setting round number and sequence count: %v", err)
}
checkSeqCountInRedis(4)

// Test adding and retrieval of expressLane messages
var addedMsgs []*ExpressLaneSubmission
Expand Down

0 comments on commit b29e5bb

Please sign in to comment.