Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
gitferry committed Dec 18, 2024
1 parent 757156e commit 9c904b3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 25 deletions.
4 changes: 1 addition & 3 deletions eotsmanager/service/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ func (s *Server) RunUntilShutdown() error {
return fmt.Errorf("failed to listen on %s: %w", listenAddr, err)
}
defer func() {
if err := lis.Close(); err != nil {
s.logger.Error(fmt.Sprintf("Failed to close network listener: %v", err))
}
_ = lis.Close()
}()

grpcServer := grpc.NewServer()
Expand Down
10 changes: 4 additions & 6 deletions finality-provider/service/event_loops.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,12 @@ func (app *FinalityProviderApp) metricsUpdateLoop() {
defer updateTicker.Stop()

for {
if app.fpIns != nil {
app.metrics.UpdateFpMetrics(app.fpIns.GetStoreFinalityProvider())
}
select {
case <-updateTicker.C:
fps, err := app.fps.GetAllStoredFinalityProviders()
if err != nil {
app.logger.Error("failed to get finality-providers from the store", zap.Error(err))
continue
}
app.metrics.UpdateFpMetrics(fps)
continue
case <-app.quit:
app.logger.Info("exiting metrics update loop")
return
Expand Down
5 changes: 5 additions & 0 deletions finality-provider/service/fp_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ func (fp *FinalityProviderInstance) finalitySigSubmissionLoop() {
continue
}

if len(processedBlocks) == 0 {
continue
}

res, err := fp.retrySubmitSigsUntilFinalized(processedBlocks)
if err != nil {
fp.metrics.IncrementFpTotalFailedVotes(fp.GetBtcPkHex())
Expand Down Expand Up @@ -457,6 +461,7 @@ func (fp *FinalityProviderInstance) retrySubmitSigsUntilFinalized(targetBlocks [
select {
case <-time.After(fp.cfg.SubmissionRetryInterval):
// Continue to next retry iteration
continue
case <-fp.quit:
fp.logger.Debug("the finality-provider instance is closing", zap.String("pk", fp.GetBtcPkHex()))
return nil, ErrFinalityProviderShutDown
Expand Down
4 changes: 1 addition & 3 deletions finality-provider/service/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ func (s *Server) RunUntilShutdown() error {
return fmt.Errorf("failed to listen on %s: %w", listenAddr, err)
}
defer func() {
if err := lis.Close(); err != nil {
s.logger.Error(fmt.Sprintf("Failed to close network listener: %v", err))
}
_ = lis.Close()
}()

grpcServer := grpc.NewServer()
Expand Down
4 changes: 0 additions & 4 deletions itest/test_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,6 @@ func StartManagerWithFinalityProvider(t *testing.T, n int) (*TestManager, []*ser
}

func (tm *TestManager) Stop(t *testing.T) {
for _, fp := range tm.Fps {
err := fp.Stop()
require.NoError(t, err)
}
err := tm.manager.ClearResources()
require.NoError(t, err)
err = os.RemoveAll(tm.baseDir)
Expand Down
16 changes: 7 additions & 9 deletions metrics/fp_collectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,19 +269,17 @@ func (fm *FpMetrics) RecordFpRandomnessTime(fpBtcPkHex string) {
fm.previousRandomnessByFp[fpBtcPkHex] = &now
}

func (fm *FpMetrics) UpdateFpMetrics(fps []*store.StoredFinalityProvider) {
func (fm *FpMetrics) UpdateFpMetrics(fp *store.StoredFinalityProvider) {
fm.mu.Lock()
defer fm.mu.Unlock()

for _, fp := range fps {
fm.RecordFpStatus(fp.GetBIP340BTCPK().MarshalHex(), fp.Status)
fm.RecordFpStatus(fp.GetBIP340BTCPK().MarshalHex(), fp.Status)

if lastVoteTime, ok := fm.previousVoteByFp[fp.GetBIP340BTCPK().MarshalHex()]; ok {
fm.RecordFpSecondsSinceLastVote(fp.GetBIP340BTCPK().MarshalHex(), time.Since(*lastVoteTime).Seconds())
}
if lastVoteTime, ok := fm.previousVoteByFp[fp.GetBIP340BTCPK().MarshalHex()]; ok {
fm.RecordFpSecondsSinceLastVote(fp.GetBIP340BTCPK().MarshalHex(), time.Since(*lastVoteTime).Seconds())
}

if lastRandomnessTime, ok := fm.previousRandomnessByFp[fp.GetBIP340BTCPK().MarshalHex()]; ok {
fm.RecordFpSecondsSinceLastRandomness(fp.GetBIP340BTCPK().MarshalHex(), time.Since(*lastRandomnessTime).Seconds())
}
if lastRandomnessTime, ok := fm.previousRandomnessByFp[fp.GetBIP340BTCPK().MarshalHex()]; ok {
fm.RecordFpSecondsSinceLastRandomness(fp.GetBIP340BTCPK().MarshalHex(), time.Since(*lastRandomnessTime).Seconds())
}
}

0 comments on commit 9c904b3

Please sign in to comment.