Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add debug logs to start process (#61) #62

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading