Skip to content

Commit

Permalink
chore: terminate goroutine with err instead of crashing the entire pr…
Browse files Browse the repository at this point in the history
  • Loading branch information
gitferry authored Sep 1, 2023
1 parent 05e6752 commit 7dc8564
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions service/validator_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"github.com/babylonchain/btc-validator/valcfg"
)

const instanceTerminatingMsg = "terminating the instance due to critical error"

type state struct {
v *proto.StoreValidator
s *val.ValidatorStore
Expand Down Expand Up @@ -219,7 +221,8 @@ func (v *ValidatorInstance) submissionLoop() {
"err": err,
"btc_pk_hex": v.GetBtcPkHex(),
"block_height": nextBlock.Height,
}).Fatal("err when deciding if should send finality signature for the block")
}).Warnf(instanceTerminatingMsg)
return
}
if !should {
continue
Expand All @@ -234,7 +237,8 @@ func (v *ValidatorInstance) submissionLoop() {
"err": err,
"btc_pk_hex": v.GetBtcPkHex(),
"block_height": nextBlock.Height,
}).Fatal("failed to submit finality signature to Babylon")
}).Warnf(instanceTerminatingMsg)
return
}
if res != nil {
v.logger.WithFields(logrus.Fields{
Expand All @@ -251,15 +255,17 @@ func (v *ValidatorInstance) submissionLoop() {
v.logger.WithFields(logrus.Fields{
"err": err,
"babylon_pk_hex": v.GetBabylonPkHex(),
}).Fatal("failed to get the current Babylon block")
}).Warnf(instanceTerminatingMsg)
return
}
txRes, err := v.CommitPubRand(tipBlock)
if err != nil {
v.logger.WithFields(logrus.Fields{
"err": err,
"babylon_pk_hex": v.GetBabylonPkHex(),
"block_height": tipBlock,
}).Fatal("failed to commit public randomness")
}).Warnf(instanceTerminatingMsg)
return
}
if txRes != nil {
v.logger.WithFields(logrus.Fields{
Expand Down

0 comments on commit 7dc8564

Please sign in to comment.