Skip to content

[codex] evmrpc: guard hash trace lookups under timeout#3529

Open
codchen wants to merge 1 commit into
mainfrom
codex/debug-trace-hash-guard-timeout
Open

[codex] evmrpc: guard hash trace lookups under timeout#3529
codchen wants to merge 1 commit into
mainfrom
codex/debug-trace-hash-guard-timeout

Conversation

@codchen
Copy link
Copy Markdown
Collaborator

@codchen codchen commented Jun 1, 2026

What changed

  • Move debug_traceBlockByHash and hash-based debug_traceCall guard work behind prepareTraceContext, so the trace semaphore and timeout apply before hash lookup work begins.
  • Change the historical debug trace hash guard to read the Tendermint block height via blockByHashRespectingWatermarks instead of going through Backend.BlockByHash, which reconstructs the EVM block by number.
  • Add regression coverage for the lighter hash-height guard and for semaphore rejection happening before hash lookup.

Why

A review noted that hash-based historical trace guards were resolving the block height through Backend.BlockByHash -> Backend.BlockByNumber, doing expensive block reconstruction before the trace concurrency limit and trace timeout were in effect. The guard only needs the block height, so it can use the Tendermint block metadata directly.

Validation

  • go test ./evmrpc -run 'Test(IsHistoricalDebugTraceBlock|GuardHistoricalDebugTraceHeight|GuardHistoricalDebugTraceByHashUsesTendermintHeight|HashBasedTraceEndpointsAcquireSemaphoreBeforeHashLookup|PrepareTraceContextFailsFastWhenSemaphoreIsFull|PrepareTraceContextReleasesSemaphoreOnCleanup|AcquireTraceSemaphoreCanceledContextDoesNotConsumeSlot)$'
  • go test ./evmrpc -run 'TestTrace(Call|BlockByNumberLookbackLimit|BlockByNumberUnlimitedLookback)$'
  • go test ./evmrpc/tests -run 'TestTraceBlockByHash$'

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJun 2, 2026, 2:46 AM

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

❌ Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.28%. Comparing base (f8f1af1) to head (261e72f).

Files with missing lines Patch % Lines
evmrpc/tracers.go 25.00% 2 Missing and 4 partials ⚠️

❌ Your patch check has failed because the patch coverage (25.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3529      +/-   ##
==========================================
- Coverage   59.12%   58.28%   -0.85%     
==========================================
  Files        2213     2140      -73     
  Lines      182774   174405    -8369     
==========================================
- Hits       108072   101656    -6416     
+ Misses      64985    63714    -1271     
+ Partials     9717     9035     -682     
Flag Coverage Δ
sei-chain-pr 67.04% <25.00%> (?)
sei-db 70.41% <ø> (ø)
sei-db-state-db ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
evmrpc/tracers.go 69.34% <25.00%> (+0.97%) ⬆️

... and 74 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codchen codchen marked this pull request as ready for review June 2, 2026 02:45
@cursor
Copy link
Copy Markdown

cursor Bot commented Jun 2, 2026

PR Summary

Medium Risk
Changes ordering and data source for historical debug trace enforcement on hash-based RPC paths; mis-ordering or wrong height could allow expensive work or incorrect lookback errors, but scope is limited to debug trace endpoints with added tests.

Overview
Hash-based debug_traceBlockByHash and debug_traceCall now run prepareTraceContext (trace semaphore and timeout) before historical lookback checks, so overloaded nodes reject trace work without doing block resolution first.

The hash lookback guard no longer uses Backend.BlockByHash (which rebuilt the EVM block). It resolves height via blockByHashRespectingWatermarks and Tendermint block.Block.Height, which is enough to enforce maxBlockLookback.

Regression tests cover Tendermint-height guarding and semaphore rejection happening before any hash lookup.

Reviewed by Cursor Bugbot for commit 261e72f. Bugbot is set up for automated code reviews on this repo. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant