base icon indicating copy to clipboard operation
base copied to clipboard

feat(rpc): add deep tracing for eth_call and sendRawTransaction

Open meyer9 opened this issue 5 months ago • 4 comments

Summary

  • add Base-owned tracing spans for eth_call and eth_sendRawTransaction
  • break eth_call into nested orchestration spans so state load and execution are visible in traces
  • split raw tx handling into decode and submission phases
  • include the one-pager summary doc for team review

Validation

  • just check::format
  • just zepter
  • just test-affected-ci meyer9/otel-tracing-engine-parenting
  • local affected tests are not fully green yet; this draft PR is intended to let GitHub CI verify the remaining split fallout

meyer9 avatar Jun 15 '26 17:06 meyer9


"Good findings. On the span level concern (#1):

debug_span! for the inner sub spans is the right call. The concrete production benefit: default RUST_LOG configs typically filter out DEBUG spans, so the 11 inner spans become zero-cost (the enabled! check short circuits before any metadata allocation). Operators can then opt into the full breakdown per-target:

RUST_LOG=rpc::eth::call=debug,rpc::eth::send_raw_transaction=debug

This gives the detailed trace exactly when needed without paying the cost on every call. The outer eth_call at INFO is sufficient for normal ops it signals rate and latency without the per-step overhead.

On finding #3 (cancellation error): EthApiError::InternalEthError masks the root cause. A separate Canceled variant (or wrapping the existing error with context) would make traces and error responses actionable.


Sertug17 avatar Jun 15 '26 17:06 Sertug17

One more thing I noticed that the bot didn't flag:

The caller_gas_allowance cap on line ~201 is only applied when !request_has_gas_limit i.e., only when the caller didn't supply an explicit gas limit. If a request comes in with gas: 1_000_000_000 (huge value), it gets capped to global_gas_cap but the per-caller balance allowance is never checked. The upstream default EthCall::call applies the caller allowance regardless of whether a gas limit was supplied.

Consequence: when a caller supplies a high gas limit that exceeds their balance based allowance, instead of getting a clear early error the call proceeds to execution and would fail inside the EVM with a more opaque error. Not a correctness issue per se (the EVM will still reject it), but the error path is worse and the behavior diverges from upstream.

Sertug17 avatar Jun 18 '26 18:06 Sertug17

Review Summary — feat(rpc): add deep tracing for eth_call and sendRawTransaction

Critical

Double semaphore permit in traced_eth_call (call.rs:98,108): acquire_owned_blocking_io() acquires a permit, then spawn_blocking_io_fut acquires another from the same semaphore. This halves effective concurrency and risks deadlock under load. The upstream default EthCall::call does not manually acquire before spawning — verify and remove the redundant acquisition.

Important

  • All inner spans are info_span! (call.rs, transaction.rs): ~12 info_span!s per eth_call allocate metadata on every invocation regardless of OTel configuration. The rest of the execution crate uses debug_span! for similar instrumentation. Inner sub-spans should be debug_span!; keep only the outermost eth_call / send_raw_transaction at info level.

  • Dead nonce conditional (call.rs:157,178): request.nonce is unconditionally set to None at line 157, then the if request.as_ref().nonce.is_none() check at line 178 always evaluates true. Either remove the if to clarify intent or stop clearing the nonce if callers should be able to supply one.

  • Generic error on cancellation (call.rs:220): EthApiError::InternalEthError is indistinguishable from actual internal errors. Cancellation should use a specific variant or emit a span event so operators can differentiate cancelled requests in traces.

Minor

  • pub #[doc(hidden)] on traced_eth_call (call.rs:82): Only called from the EthCall::call impl in this file. Since project conventions require pub on all functions, consider removing #[doc(hidden)] and adding a proper doc comment instead, or keeping it private since it's an inherent method (not trait impl) and arguably an implementation detail.

Notes

  • The docs/otel-tracing-one-pager.md is a helpful context document for reviewers.
  • The new alloy-evm dependency is used for apply_block_overrides / apply_state_overrides and is appropriate.
  • The CancelOnDrop guard pattern is correctly structured for cancellation propagation.

github-actions[bot] avatar Jun 22 '26 18:06 github-actions[bot]

✅ base-std fork tests: all 616 passed

base/base is fully in sync with the base-std spec.

Dependency Ref Commit
base-std main 4658f1b7
base-anvil 0092692587d8d064dd2c6923ce26a682c58f3694 00926925

github-actions[bot] avatar Jun 22 '26 18:06 github-actions[bot]