Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions turbo/jsonrpc/trace_filtering.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,21 @@ func (api *TraceAPIImpl) Transaction(ctx context.Context, txHash common.Hash, ga
}

var txIndex int
for idx := 0; idx < block.Transactions().Len() && !isBorStateSyncTxn; idx++ {
txn := block.Transactions()[idx]
if txn.Hash() == txHash {
txIndex = idx
break
}
}

if isBorStateSyncTxn {
txIndex = block.Transactions().Len()
} else {
var found bool
for idx := 0; idx < block.Transactions().Len(); idx++ {
txn := block.Transactions()[idx]
if txn.Hash() == txHash {
txIndex = idx
found = true
break
}
}
if !found {
return nil, fmt.Errorf("txn with hash %x belongs to currentely non-canonical block %d. only canonical blocks can be traced", txHash, block.NumberU64())
}
}

bn := hexutil.Uint64(blockNumber)
Expand Down