From 1e2955111e69d7d6d8f54d0255da6209d9c246ca Mon Sep 17 00:00:00 2001 From: Farber98 Date: Thu, 28 Nov 2024 15:13:11 -0300 Subject: [PATCH] log block height vs currheight --- pkg/solana/txm/pendingtx.go | 8 ++++---- pkg/solana/txm/txm.go | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/solana/txm/pendingtx.go b/pkg/solana/txm/pendingtx.go index 44895fd40..8123133ec 100644 --- a/pkg/solana/txm/pendingtx.go +++ b/pkg/solana/txm/pendingtx.go @@ -30,7 +30,7 @@ type PendingTxContext interface { ListAll() []solana.Signature // ListAllExpiredBroadcastedTxs returns all the txes that are in broadcasted state and have expired for given slot height compared against their lastValidBlockHeight. // Passing maxUint64 as currHeight will return all broadcasted txes. - ListAllExpiredBroadcastedTxs(currHeight uint64) []pendingTx + ListAllExpiredBroadcastedTxs(currHeight uint64) ([]pendingTx, int, int) // Expired returns whether or not confirmation timeout amount of time has passed since creation Expired(sig solana.Signature, confirmationTimeout time.Duration) bool // OnProcessed marks transactions as Processed @@ -223,7 +223,7 @@ func (c *pendingTxContext) ListAll() []solana.Signature { // ListAllExpiredBroadcastedTxs returns all the txes that are in broadcasted state and have expired for given slot height compared against their lastValidBlockHeight. // Passing maxUint64 as currHeight will return all broadcasted txes. -func (c *pendingTxContext) ListAllExpiredBroadcastedTxs(currHeight uint64) []pendingTx { +func (c *pendingTxContext) ListAllExpiredBroadcastedTxs(currHeight uint64) ([]pendingTx, int, int) { c.lock.RLock() defer c.lock.RUnlock() broadcastedTxes := make([]pendingTx, 0, len(c.broadcastedProcessedTxs)) // worst case, all of them @@ -232,7 +232,7 @@ func (c *pendingTxContext) ListAllExpiredBroadcastedTxs(currHeight uint64) []pen broadcastedTxes = append(broadcastedTxes, tx) } } - return broadcastedTxes + return broadcastedTxes, len(broadcastedTxes), len(c.broadcastedProcessedTxs) } // Expired returns if the timeout for trying to confirm a signature has been reached @@ -623,7 +623,7 @@ func (c *pendingTxContextWithProm) ListAll() []solana.Signature { return sigs } -func (c *pendingTxContextWithProm) ListAllExpiredBroadcastedTxs(currHeight uint64) []pendingTx { +func (c *pendingTxContextWithProm) ListAllExpiredBroadcastedTxs(currHeight uint64) ([]pendingTx, int, int) { return c.pendingTx.ListAllExpiredBroadcastedTxs(currHeight) } diff --git a/pkg/solana/txm/txm.go b/pkg/solana/txm/txm.go index 3ba39f2f5..95cc10139 100644 --- a/pkg/solana/txm/txm.go +++ b/pkg/solana/txm/txm.go @@ -576,8 +576,13 @@ func (txm *Txm) rebroadcastExpiredTxs(ctx context.Context, client client.ReaderW return } // Rebroadcast all expired txes - for _, tx := range txm.txs.ListAllExpiredBroadcastedTxs(currHeight) { - txm.lggr.Debugw("transaction expired, rebroadcasting", "id", tx.id, "signature", tx.signatures) + rebroadcastTxs, rebroadcastCount, allCount := txm.txs.ListAllExpiredBroadcastedTxs(currHeight) + txm.lggr.Debugw("rebroadcasting expired transactions", "rebroadcastCount", rebroadcastCount, "allCount", allCount) + for _, tx := range rebroadcastTxs { + if tx.lastValidBlockHeight > currHeight { + continue + } + txm.lggr.Debugw("transaction expired, rebroadcasting", "id", tx.id, "signature", tx.signatures, "currHeight", currHeight, "lastValidBlockHeight", tx.lastValidBlockHeight) if len(tx.signatures) == 0 { // prevent panic, shouldn't happen. txm.lggr.Errorw("no signatures found for expired transaction", "id", tx.id) continue