Skip to content

Commit

Permalink
add debug logs to start process (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradStaniec authored Oct 14, 2024
1 parent a3e5bf4 commit 00555f5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions staker/stakerapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ func (app *StakerApp) Start() error {
startErr = err
return
}

app.logger.Info("StakerApp started")
})

return startErr
Expand Down Expand Up @@ -518,6 +520,8 @@ func (app *StakerApp) mustSetTxSpentOnBtc(hash *chainhash.Hash) {
// for some reason they are behind staker
// TODO: Refactor this functions after adding unit tests to stakerapp
func (app *StakerApp) checkTransactionsStatus() error {
app.logger.Debug("Start checking transaction status to fix db state")

stakingParams, err := app.babylonClient.Params()

if err != nil {
Expand Down Expand Up @@ -596,6 +600,14 @@ func (app *StakerApp) checkTransactionsStatus() error {
return err
}

app.logger.WithFields(logrus.Fields{
"num_created": len(transactionCreated),
"num_sent_to_btc": len(transactionsSentToBtc),
"num_confirmed_on_btc": len(transactionConfirmedOnBtc),
"num_on_babylon": len(transactionsOnBabylon),
"num_verified": len(transactionsVerifiedOnBabylon),
}).Debug("Iteration over all database staking requests finished")

for _, txHash := range transactionCreated {
txHashCopy := txHash
tx, stakerAddress := app.mustGetTransactionAndStakerAddress(txHashCopy)
Expand Down Expand Up @@ -661,6 +673,10 @@ func (app *StakerApp) checkTransactionsStatus() error {
}
}

app.logger.WithFields(logrus.Fields{
"state": proto.TransactionState_TRANSACTION_CREATED.String(),
}).Debug("Partially fixed state of the database")

for _, txHash := range transactionsSentToBtc {
stakingTxHash := txHash
tx, _ := app.mustGetTransactionAndStakerAddress(stakingTxHash)
Expand All @@ -678,6 +694,10 @@ func (app *StakerApp) checkTransactionsStatus() error {
}
}

app.logger.WithFields(logrus.Fields{
"state": proto.TransactionState_SENT_TO_BTC.String(),
}).Debug("Partially fixed state of the database")

for _, txHash := range transactionConfirmedOnBtc {
stakingTxHash := txHash

Expand Down Expand Up @@ -750,6 +770,10 @@ func (app *StakerApp) checkTransactionsStatus() error {
}
}

app.logger.WithFields(logrus.Fields{
"state": proto.TransactionState_CONFIRMED_ON_BTC.String(),
}).Debug("Partially fixed state of the database")

for _, localInfo := range transactionsOnBabylon {
// we only can have one local states here
if localInfo.stakingTxState == proto.TransactionState_SENT_TO_BABYLON {
Expand Down Expand Up @@ -855,6 +879,12 @@ func (app *StakerApp) checkTransactionsStatus() error {
}
}

app.logger.WithFields(logrus.Fields{
"state_sent_to_babylon": proto.TransactionState_SENT_TO_BABYLON.String(),
"state_active": proto.TransactionState_DELEGATION_ACTIVE.String(),
"state_unbonding": proto.TransactionState_UNBONDING_CONFIRMED_ON_BTC.String(),
}).Debug("Partially fixed state of the database")

for _, txHash := range transactionsVerifiedOnBabylon {
txHashCopy := *txHash
storedTx, _ := app.mustGetTransactionAndStakerAddress(&txHashCopy)
Expand All @@ -866,6 +896,12 @@ func (app *StakerApp) checkTransactionsStatus() error {
)
}

app.logger.WithFields(logrus.Fields{
"state": proto.TransactionState_VERIFIED.String(),
}).Debug("Partially fixed state of the database")

app.logger.Debug("Finished checking transaction status to fix db state")

return nil
}

Expand Down

0 comments on commit 00555f5

Please sign in to comment.