Skip to content

Commit

Permalink
Fix trace pending txns
Browse files Browse the repository at this point in the history
  • Loading branch information
wojciechos committed Jan 15, 2025
1 parent efe2165 commit ac0a2be
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions rpc/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ func (h *Handler) traceTransaction(ctx context.Context, hash *felt.Felt) (*vm.Tr
httpHeader.Set(ExecutionStepsHeader, "0")

if err != nil {
if pendingB := h.syncReader.PendingBlock(); pendingB != nil {
txIndex := slices.IndexFunc(pendingB.Transactions, func(tx core.Transaction) bool {
return tx.Hash().Equal(hash)
})
if txIndex != -1 {
traceResults, header, traceBlockErr := h.traceBlockTransactions(ctx, pendingB)
if traceBlockErr != nil {
return nil, header, traceBlockErr
}
return traceResults[txIndex].TraceRoot, header, nil
}
}
return nil, httpHeader, ErrTxnHashNotFound
}

Expand Down

0 comments on commit ac0a2be

Please sign in to comment.