Skip to content

fix(blockscout): always trace CREATE transactions#2293

Merged
carneiro-cw merged 3 commits intomainfrom
dont_skip_create
Sep 4, 2025
Merged

fix(blockscout): always trace CREATE transactions#2293
carneiro-cw merged 3 commits intomainfrom
dont_skip_create

Conversation

@carneiro-cw
Copy link
Contributor

@carneiro-cw carneiro-cw commented Sep 4, 2025

User description

When the internal transaction indexer is enabled in Blockscout it relies on that to index bytecodes. So while it is useful to only trace failed transactions as to not put too much strain on stratus, we need to trace successful transactions that create contracts.


PR Type

Bug fix, Enhancement


Description

  • Always trace CREATE transactions for Blockscout compatibility

  • Modify condition to check for deployed contract address

  • Ensure correct bytecode indexing for internal transaction indexer

  • Maintain performance by tracing only necessary transactions


Diagram Walkthrough

flowchart LR
  TX["Transaction"] --> CHECK{"Is CREATE?"}
  CHECK -->|Yes| TRACE["Always Trace"]
  CHECK -->|No| CONDITION{"Trace Unsuccessful Only?"}
  CONDITION -->|Yes| RESULT{"Successful?"}
  RESULT -->|No| TRACE
  RESULT -->|Yes| SKIP["Skip Tracing"]
  CONDITION -->|No| TRACE
Loading

File Walkthrough

Relevant files
Enhancement
evm.rs
Refine transaction tracing logic for CREATE transactions 

src/eth/executor/evm.rs

  • Added condition to check for deployed contract address
  • Modified tracing logic to always trace CREATE transactions
  • Ensures compatibility with Blockscout's internal transaction indexer
  • Maintains performance optimization for non-CREATE transactions
+2/-1     

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Logic Verification

Verify that the condition for tracing CREATE transactions is correctly implemented. Ensure that the check for deployed_contract_address().is_none() accurately identifies CREATE transactions.

if tx.deployed_contract_address().is_none() && trace_unsuccessful_only && matches!(tx.result(), ExecutionResult::Success) {

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Ensure CREATE transactions are traced

The condition for skipping tracing is too restrictive. It should allow tracing for
CREATE transactions even when they're successful. Consider inverting the logic to
make the intention clearer and ensure CREATE transactions are always traced.

src/eth/executor/evm.rs [223-226]

-// CREATE transactions need to be traced for blockscout to work correctly
-if tx.deployed_contract_address().is_none() && trace_unsuccessful_only && matches!(tx.result(), ExecutionResult::Success) {
+// Always trace CREATE transactions, and unsuccessful transactions when trace_unsuccessful_only is true
+if !tx.deployed_contract_address().is_some() && !(trace_unsuccessful_only && matches!(tx.result(), ExecutionResult::Success)) {
     return Ok(default_trace(tracer_type, tx));
 }
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a critical issue in the tracing logic for CREATE transactions. The proposed change ensures that CREATE transactions are always traced, which is essential for compatibility with blockscout, as mentioned in the comment.

High

@codecov
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.76%. Comparing base (69debfe) to head (c953c42).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2293       +/-   ##
===========================================
+ Coverage   45.23%   84.76%   +39.52%     
===========================================
  Files         129      129               
  Lines        9227    10575     +1348     
===========================================
+ Hits         4174     8964     +4790     
+ Misses       5053     1611     -3442     
Flag Coverage Δ
contracts-rocks- 45.05% <0.00%> (-0.19%) ⬇️
e2e-admin-password 22.43% <0.00%> (?)
e2e-clock-stratus 25.24% <0.00%> (?)
e2e-genesis 26.77% <0.00%> (?)
e2e-importer-offline 59.35% <0.00%> (?)
e2e-rpc-downloader 54.42% <0.00%> (?)
e2e-stratus 56.43% <100.00%> (?)
leader-follower- 62.50% <0.00%> (?)
rust-tests 30.67% <0.00%> (?)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@carneiro-cw carneiro-cw merged commit 18cd0c5 into main Sep 4, 2025
41 checks passed
@carneiro-cw carneiro-cw deleted the dont_skip_create branch September 4, 2025 18:13
@cloudwalk cloudwalk deleted a comment from stratus-benchmark bot Sep 4, 2025
@stratus-benchmark
Copy link

Final benchmark:
Run ID: bench-c1e0bc12

Git Info:

Leader Stats:
RPS Stats: Max: 3227.00, Min: 1531.00, Avg: 2328.09, StdDev: 129.18
TPS Stats: Max: 2593.00, Min: 894.00, Avg: 2322.75, StdDev: 136.08

Follower Stats:
Imported Blocks/s: Max: 12.00, Min: 4.00, Avg: 9.47, StdDev: 1.46
Imported Transactions/s: Max: 27427.00, Min: 6743.00, Avg: 21913.97, StdDev: 3806.92

Plots:

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.

3 participants

Comments