Skip to content

Commit bb0e2a5

Browse files
committed
Improve logging & tracking of dropped transactions
1 parent 28de80d commit bb0e2a5

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

services/requester/batch_tx_pool.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ func (t *BatchTxPool) Add(
184184
}
185185

186186
if err != nil {
187+
t.logger.Error().Err(err).Msgf(
188+
"failed to submit single Flow transaction for EOA: %s",
189+
from.Hex(),
190+
)
187191
return err
188192
}
189193

@@ -227,7 +231,7 @@ func (t *BatchTxPool) processPooledTransactions(ctx context.Context) {
227231
)
228232
if err != nil {
229233
t.logger.Error().Err(err).Msgf(
230-
"failed to submit Flow transaction from BatchTxPool for EOA: %s",
234+
"failed to submit batch Flow transaction for EOA: %s",
231235
address.Hex(),
232236
)
233237
continue
@@ -274,6 +278,9 @@ func (t *BatchTxPool) batchSubmitTransactionsForSameAddress(
274278
}
275279

276280
if err := t.client.SendTransaction(ctx, *flowTx); err != nil {
281+
// If there was any error while sending the transaction,
282+
// we record all transactions as dropped.
283+
t.collector.TransactionsDropped(len(hexEncodedTxs))
277284
return err
278285
}
279286

@@ -305,6 +312,9 @@ func (t *BatchTxPool) submitSingleTransaction(
305312
}
306313

307314
if err := t.client.SendTransaction(ctx, *flowTx); err != nil {
315+
// If there was any error while sending the transaction,
316+
// we record it as a dropped transaction.
317+
t.collector.TransactionsDropped(1)
308318
return err
309319
}
310320

services/requester/single_tx_pool.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ func (t *SingleTxPool) Add(
9595
) error {
9696
t.txPublisher.Publish(tx) // publish pending transaction event
9797

98+
from, err := models.DeriveTxSender(tx)
99+
if err != nil {
100+
return err
101+
}
102+
98103
txData, err := tx.MarshalBinary()
99104
if err != nil {
100105
return err
@@ -120,10 +125,21 @@ func (t *SingleTxPool) Add(
120125
// If there was any error during the transaction build
121126
// process, we record it as a dropped transaction.
122127
t.collector.TransactionsDropped(1)
128+
t.logger.Error().Err(err).Msgf(
129+
"failed to build Flow transaction for EOA: %s",
130+
from.Hex(),
131+
)
123132
return err
124133
}
125134

126135
if err := t.client.SendTransaction(ctx, *flowTx); err != nil {
136+
// If there was any error while sending the transaction,
137+
// we record it as a dropped transaction.
138+
t.collector.TransactionsDropped(1)
139+
t.logger.Error().Err(err).Msgf(
140+
"failed to submit Flow transaction for EOA: %s",
141+
from.Hex(),
142+
)
127143
return err
128144
}
129145

0 commit comments

Comments
 (0)