Skip to content

evm: Read the account also for a 0-byte EXTCODECOPY - #1753

Merged
chfast merged 1 commit into
masterfrom
evm/extcodecopy-zero-size
Oct 12, 2026
Merged

chfast merged 1 commit into
masterfrom
evm/extcodecopy-zero-size

Conversation

@chfast

@chfast chfast commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

EXTCODECOPY skipped Host::copy_code() when copying 0 bytes, unlike
execution-specs which reads the account regardless of the size. Call it
always. For a 0-byte copy pass a null buffer, as for empty LOG data,
because the memory offset may then be out of bounds; the hosts accept
it.

@codspeed

codspeed Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 16.67%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 898 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_extcodecopy_warm[fork_Osaka-blockchain_test-copy_size_0-benchmark-gas-value_1M] 7.2 ms 8.6 ms -16.67%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing evm/extcodecopy-zero-size (a89c91f) with master (39425f3)

Open in CodSpeed

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.07%. Comparing base (39425f3) to head (a89c91f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1753   +/-   ##
=======================================
  Coverage   98.06%   98.07%           
=======================================
  Files         183      183           
  Lines       16940    16944    +4     
  Branches     3873     3876    +3     
=======================================
+ Hits        16613    16617    +4     
  Misses        245      245           
  Partials       82       82           
Flag Coverage Δ
eest-develop-gmp 25.86% <61.53%> (-0.01%) ⬇️
eest-legacy 17.05% <53.84%> (+<0.01%) ⬆️
eest-libsecp256k1 28.05% <61.53%> (-0.01%) ⬇️
eest-stable 83.88% <100.00%> (+<0.01%) ⬆️
evmone-unittests 94.24% <100.00%> (+<0.01%) ⬆️

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

Components Coverage Δ
core 96.25% <100.00%> (+<0.01%) ⬆️
tooling 94.29% <ø> (ø)
tests 99.81% <100.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
lib/evmone/instructions.hpp 99.53% <100.00%> (+<0.01%) ⬆️
test/unittests/evm_eip2929_test.cpp 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

EXTCODECOPY skipped Host::copy_code() when copying 0 bytes, unlike
execution-specs which reads the account regardless of the size. Call it
always. For a 0-byte copy pass a null buffer, as for empty LOG data,
because the memory offset may then be out of bounds; the hosts accept
it.
@chfast
chfast force-pushed the evm/extcodecopy-zero-size branch from a4db3c3 to a89c91f Compare October 8, 2026 10:43
@chfast
chfast requested a balanced review from Copilot October 12, 2026 08:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the specified behavior and safely avoids dereferencing invalid memory for zero-length copies.

0 open findings

What changed in this PR

Ensures zero-byte EXTCODECOPY still reads the target account while safely handling out-of-bounds memory offsets.

Changes:

  • Always invokes Host::copy_code(), using a null buffer for zero-byte copies.
  • Updates EIP-2929 account-access expectations.
File Description
lib/​evmone/​instructions.hpp Corrects zero-byte EXTCODECOPY behavior.
test/​unittests/​evm_eip2929_test.cpp Verifies the additional account reads.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chfast
chfast merged commit c2d54b0 into master Oct 12, 2026
30 of 31 checks passed
@chfast
chfast deleted the evm/extcodecopy-zero-size branch October 12, 2026 08:38
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