diff --git a/internal/service/indexer/l2/report_error.go b/internal/service/indexer/l2/report_error.go index 410a825..ba992a8 100644 --- a/internal/service/indexer/l2/report_error.go +++ b/internal/service/indexer/l2/report_error.go @@ -12,6 +12,7 @@ import ( "net/http" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" ) type SlackMessageElement struct { @@ -31,7 +32,12 @@ type SlackMessageStructure struct { Blocks []SlackMessageBlock `json:"blocks"` } -func (s *server) ReportFailedTransactionToSlack(txErr error, txHash string, txFunc string, users []common.Address, amount []*big.Int) { +func (s *server) ReportFailedTransactionToSlack(txErr error, receipt *types.Receipt, txFunc string, users []common.Address, amount []*big.Int) { + txHash := "Unknown" + if receipt != nil { + txHash = receipt.TxHash.Hex() + } + log.Println("===================== Transaction Error =====================") log.Printf("%s transaction error! Please check information below:", txFunc) log.Printf("Transaction Hash: %s", txHash) @@ -49,6 +55,11 @@ func (s *server) ReportFailedTransactionToSlack(txErr error, txHash string, txFu s.sendNotificationMessage(txErr, txHash, txFunc) s.uploadUsersList(txHash, users, amount) + + // select {} purposely block the process as it is a critical error and meaningless to continue + // if panic() is called, the process will be restarted by the supervisor + // we do not want that as it will be stuck in the same state + select {} } func (s *server) sendNotificationMessage(txErr error, txHash string, txFunc string) { diff --git a/internal/service/indexer/l2/signer.go b/internal/service/indexer/l2/signer.go index cdd18ae..4c932f3 100644 --- a/internal/service/indexer/l2/signer.go +++ b/internal/service/indexer/l2/signer.go @@ -32,7 +32,8 @@ func (s *server) sendTransaction(ctx context.Context, input []byte) (*types.Rece // select {} purposely block the process as it is a critical error and meaningless to continue // if panic() is called, the process will be restarted by the supervisor // we do not want that as it will be stuck in the same state - select {} + // select {} // Move this process blocker after message report to notification system + return receipt, fmt.Errorf("received an invalid transaction receipt") } // return the receipt if the transaction is successful diff --git a/internal/service/indexer/l2/trigger_billing.go b/internal/service/indexer/l2/trigger_billing.go index 8c506cb..60bf61f 100644 --- a/internal/service/indexer/l2/trigger_billing.go +++ b/internal/service/indexer/l2/trigger_billing.go @@ -255,7 +255,7 @@ func (s *server) triggerBillingCollectTokens(ctx context.Context, epoch *big.Int receipt, err := s.sendTransaction(ctx, input) if err != nil { - s.ReportFailedTransactionToSlack(err, "", l2.MethodCollectTokens, users, amounts) + s.ReportFailedTransactionToSlack(err, receipt, l2.MethodCollectTokens, users, amounts) return fmt.Errorf("send transaction receipt: %w", err) } @@ -275,7 +275,7 @@ func (s *server) triggerBillingWithdrawTokens(ctx context.Context, users []commo receipt, err := s.sendTransaction(ctx, input) if err != nil { - s.ReportFailedTransactionToSlack(err, "", l2.MethodWithdrawTokens, users, amounts) + s.ReportFailedTransactionToSlack(err, receipt, l2.MethodWithdrawTokens, users, amounts) return fmt.Errorf("send transaction receipt: %w", err) } diff --git a/internal/service/indexer/l2/trigger_distribute_request_rewards.go b/internal/service/indexer/l2/trigger_distribute_request_rewards.go index 82f72e3..f60db0d 100644 --- a/internal/service/indexer/l2/trigger_distribute_request_rewards.go +++ b/internal/service/indexer/l2/trigger_distribute_request_rewards.go @@ -37,7 +37,7 @@ func (s *server) triggerDistributeRequestRewards(ctx context.Context, nodeAddres receipt, err := s.sendTransaction(ctx, input) if err != nil { - s.ReportFailedTransactionToSlack(err, "", l2.MethodDistributeRewards, nodeAddress, amounts) + s.ReportFailedTransactionToSlack(err, receipt, l2.MethodDistributeRewards, nodeAddress, amounts) return fmt.Errorf("send transaction receipt: %w", err) }