Skip to content

Commit

Permalink
log block height vs currheight
Browse files Browse the repository at this point in the history
  • Loading branch information
Farber98 committed Nov 28, 2024
1 parent 0a86de7 commit 1e29551
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pkg/solana/txm/pendingtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down
9 changes: 7 additions & 2 deletions pkg/solana/txm/txm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1e29551

Please sign in to comment.