From 992016602eebca7ebc1bab3cab10d55c0202cb65 Mon Sep 17 00:00:00 2001 From: KonradStaniec Date: Mon, 14 Oct 2024 18:05:05 +0200 Subject: [PATCH] add debug logs to start process (#61) --- staker/stakerapp.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/staker/stakerapp.go b/staker/stakerapp.go index bffaaca..23f8cea 100644 --- a/staker/stakerapp.go +++ b/staker/stakerapp.go @@ -314,6 +314,8 @@ func (app *StakerApp) Start() error { startErr = err return } + + app.logger.Info("StakerApp started") }) return startErr @@ -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 { @@ -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) @@ -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) @@ -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 @@ -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 { @@ -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) @@ -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 }