Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gitferry committed Dec 3, 2024
1 parent cbb27e7 commit 599d2e9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
35 changes: 0 additions & 35 deletions finality-provider/service/app.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package service

import (
"errors"
"fmt"
"strings"
"sync"
Expand Down Expand Up @@ -569,40 +568,6 @@ func (app *FinalityProviderApp) removeFinalityProviderInstance() error {
return nil
}

func (app *FinalityProviderApp) monitorCriticalErr() {
defer app.wg.Done()

var criticalErr *CriticalError

for {
select {
case criticalErr = <-app.criticalErrChan:
fpi, err := app.GetFinalityProviderInstance()
if err != nil {
app.logger.Debug("the finality-provider instance is already shutdown",
zap.String("pk", criticalErr.fpBtcPk.MarshalHex()))
continue
}
if errors.Is(criticalErr.err, ErrFinalityProviderSlashed) {
app.setFinalityProviderSlashed(fpi)
app.logger.Debug("the finality-provider has been slashed",
zap.String("pk", criticalErr.fpBtcPk.MarshalHex()))
continue
}
if errors.Is(criticalErr.err, ErrFinalityProviderJailed) {
app.setFinalityProviderJailed(fpi)
app.logger.Debug("the finality-provider has been jailed",
zap.String("pk", criticalErr.fpBtcPk.MarshalHex()))
continue
}
app.logger.Fatal(instanceTerminatingMsg,
zap.String("pk", criticalErr.fpBtcPk.MarshalHex()), zap.Error(criticalErr.err))
case <-app.quit:
return
}
}
}

func (app *FinalityProviderApp) setFinalityProviderSlashed(fpi *FinalityProviderInstance) {
fpi.MustSetStatus(proto.FinalityProviderStatus_SLASHED)
if err := app.removeFinalityProviderInstance(); err != nil {
Expand Down
35 changes: 35 additions & 0 deletions finality-provider/service/event_loops.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package service

import (
"errors"
"time"

"go.uber.org/zap"
Expand Down Expand Up @@ -147,6 +148,40 @@ func (app *FinalityProviderApp) monitorStatusUpdate() {
}
}

func (app *FinalityProviderApp) monitorCriticalErr() {
defer app.wg.Done()

var criticalErr *CriticalError

for {
select {
case criticalErr = <-app.criticalErrChan:
fpi, err := app.GetFinalityProviderInstance()
if err != nil {
app.logger.Debug("the finality-provider instance is already shutdown",
zap.String("pk", criticalErr.fpBtcPk.MarshalHex()))
continue
}
if errors.Is(criticalErr.err, ErrFinalityProviderSlashed) {
app.setFinalityProviderSlashed(fpi)
app.logger.Debug("the finality-provider has been slashed",
zap.String("pk", criticalErr.fpBtcPk.MarshalHex()))
continue
}
if errors.Is(criticalErr.err, ErrFinalityProviderJailed) {
app.setFinalityProviderJailed(fpi)
app.logger.Debug("the finality-provider has been jailed",
zap.String("pk", criticalErr.fpBtcPk.MarshalHex()))
continue
}
app.logger.Fatal(instanceTerminatingMsg,
zap.String("pk", criticalErr.fpBtcPk.MarshalHex()), zap.Error(criticalErr.err))
case <-app.quit:
return
}
}
}

func (app *FinalityProviderApp) registrationLoop() {
defer app.wg.Done()
for {
Expand Down
4 changes: 2 additions & 2 deletions finality-provider/service/fp_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ func (fp *FinalityProviderInstance) Start() error {

fp.poller = poller
fp.quit = make(chan struct{})
fp.wg.Add(1)

fp.wg.Add(2)
go fp.finalitySigSubmissionLoop()
fp.wg.Add(1)
go fp.randomnessCommitmentLoop()

return nil
Expand Down
2 changes: 1 addition & 1 deletion itest/test_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import (
)

var (
eventuallyWaitTimeOut = 1 * time.Minute
eventuallyWaitTimeOut = 5 * time.Minute
eventuallyPollTime = 500 * time.Millisecond
btcNetworkParams = &chaincfg.SimNetParams

Expand Down

0 comments on commit 599d2e9

Please sign in to comment.