Skip to content

rpc: fix otterscan API stability and correctness issues#19679

Merged
lupin012 merged 4 commits intomainfrom
lupin012/fix_ots_api
Mar 9, 2026
Merged

rpc: fix otterscan API stability and correctness issues#19679
lupin012 merged 4 commits intomainfrom
lupin012/fix_ots_api

Conversation

@lupin012
Copy link
Copy Markdown
Contributor

@lupin012 lupin012 commented Mar 6, 2026

This PR contains the following fixes

  • Replace panic(err) with proper error handling in GetContractCreator and GetTransactionBySenderAndNonce
  • Fix uint256 zero check using IsZero() instead of Uint64() != 0 in OperationsTracer
  • Add missing defer it.Close() to prevent iterator resource leak
  • Fix nil dereference in GetContractCreator: add tracer.Found() check before accessing tracer.Tx.Hash() to prevent panic when contract creator is not found
  • Fix genericTracer returning nil error silently when header or txn is not found; now returns explicit error to prevent callers from proceeding with uninitialized tracer state
  • Remove dead code: prunedBlock was computed but never used in GetBlockTransactions (present since PR Upstream all Otterscan patches to devel #5945)
  • Fix OOB panic in GetBlockTransactions: add bounds check on receipts slice before slicing with page offsets
  • Fix gas price truncation in delegateBlockFees: replace Uint64() intermediate with ToBig() to preserve full uint256 precision
  • Fix SELFDESTRUCT handler in TransactionTracer: guard against empty Results slice to prevent index out of range panic
  • Fix OnTxEnd call inconsistency: use tracer.Hooks.OnTxEnd consistently instead of mixing promoted field access with explicit field access

lupin012 and others added 4 commits March 6, 2026 09:45
- Replace panic(err) with proper error handling in GetContractCreator and GetTransactionBySenderAndNonce
- Fix uint256 zero check using IsZero() instead of Uint64() != 0 in OperationsTracer
- Add missing defer it.Close() to prevent iterator resource leak

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix nil dereference in GetContractCreator: add tracer.Found() check
  before accessing tracer.Tx.Hash() to prevent panic when the contract
  creator is not found by the tracer
- Fix genericTracer returning nil error silently when header or txn is
  not found; now returns an explicit error to prevent callers from
  proceeding with uninitialized tracer state
- Remove dead code: prunedBlock was computed but never assigned to the
  response in GetBlockTransactions (present since PR #5945)
- Fix OOB panic in GetBlockTransactions: add bounds check on receipts
  slice before slicing with page offsets derived from transaction count
- Fix gas price truncation in delegateBlockFees: replace Uint64()
  intermediate with ToBig() to preserve full uint256 precision
- Fix SELFDESTRUCT handler in TransactionTracer: guard against empty
  Results slice to prevent index out of range panic
- Fix OnTxEnd call inconsistency: use tracer.Hooks.OnTxEnd consistently
  instead of mixing promoted field access with explicit field access

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lupin012 lupin012 marked this pull request as ready for review March 8, 2026 13:19
@lupin012 lupin012 requested a review from canepat as a code owner March 8, 2026 13:19
@lupin012 lupin012 merged commit 91a0551 into main Mar 9, 2026
32 of 38 checks passed
@lupin012 lupin012 deleted the lupin012/fix_ots_api branch March 9, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants