Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

baseline: Improve code analysis API #941

Merged
merged 3 commits into from
Sep 12, 2024
Merged

baseline: Improve code analysis API #941

merged 3 commits into from
Sep 12, 2024

Conversation

chfast
Copy link
Member

@chfast chfast commented Jul 1, 2024

Passing the evmc_revision to the code analysis is too fine-grained for this public API. On Ethereum Mainnet EOF can be always enabled, but the options is left for other chain configurations.

@chfast chfast requested review from gumb0 and pdobacz July 1, 2024 09:52
Copy link

codecov bot commented Jul 1, 2024

Codecov Report

Attention: Patch coverage is 94.52055% with 4 lines in your changes missing coverage. Please review.

Project coverage is 93.89%. Comparing base (7a46e72) to head (6e2f5d9).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
test/bench/helpers.hpp 0.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #941   +/-   ##
=======================================
  Coverage   93.89%   93.89%           
=======================================
  Files         146      147    +1     
  Lines       15487    15507   +20     
=======================================
+ Hits        14541    14561   +20     
  Misses        946      946           
Flag Coverage Δ
eof_execution_spec_tests 17.49% <58.90%> (-0.01%) ⬇️
ethereum_tests 27.72% <39.72%> (-0.04%) ⬇️
ethereum_tests_silkpre 19.42% <27.53%> (-0.03%) ⬇️
execution_spec_tests 19.00% <30.13%> (-0.03%) ⬇️
unittests 89.00% <94.52%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
lib/evmone/advanced_analysis.hpp 96.00% <100.00%> (-0.16%) ⬇️
lib/evmone/advanced_execution.cpp 100.00% <100.00%> (ø)
lib/evmone/baseline.hpp 100.00% <100.00%> (ø)
lib/evmone/baseline_analysis.cpp 100.00% <100.00%> (ø)
lib/evmone/baseline_execution.cpp 100.00% <100.00%> (ø)
lib/evmone/execution_state.hpp 94.33% <100.00%> (-0.49%) ⬇️
lib/evmone/instructions.hpp 100.00% <100.00%> (ø)
lib/evmone/instructions_calls.cpp 99.52% <100.00%> (ø)
test/unittests/baseline_analysis_test.cpp 100.00% <100.00%> (ø)
test/unittests/execution_state_test.cpp 100.00% <100.00%> (ø)
... and 1 more

lib/evmone/baseline.hpp Outdated Show resolved Hide resolved
@chfast chfast marked this pull request as draft July 21, 2024 11:12
@chfast
Copy link
Member Author

chfast commented Jul 21, 2024

Converted to draft, because I have better idea...

@chfast chfast self-assigned this Sep 12, 2024
@chfast chfast marked this pull request as ready for review September 12, 2024 09:14
Copy link
Collaborator

@pdobacz pdobacz left a comment

Choose a reason for hiding this comment

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

LGTM, only minor nits

lib/evmone/baseline.hpp Outdated Show resolved Hide resolved
lib/evmone/instructions.hpp Outdated Show resolved Hide resolved
@chfast chfast changed the title baseline: Simplify code analysis API baseline: Improve code analysis API Sep 12, 2024
@chfast
Copy link
Member Author

chfast commented Sep 12, 2024

I changed the name for the "full unmodified code" to raw_code. Any better ideas?

  • raw_code
  • account_code
  • original_code
  • full_code
  • container_code

@pdobacz
Copy link
Collaborator

pdobacz commented Sep 12, 2024

I changed the name for the "full unmodified code" to raw_code. Any better ideas?

* `raw_code`

* `account_code`

* `original_code`

* `full_code`

* `container_code`

code_bytes or code_binary? All the _code versions imply it's code, while it is a something containing code. But raw_code was ok when I was reading through, I just needed a moment of hesitation and the presence of executable_code nearby. Maybe also just container or container_bytes/binary

@@ -335,19 +335,21 @@ evmc_result execute(evmc_vm* c_vm, const evmc_host_interface* host, evmc_host_co
{
auto vm = static_cast<VM*>(c_vm);
const bytes_view container{code, code_size};
const auto eof_enabled = rev >= EVMC_PRAGUE;
Copy link
Member

Choose a reason for hiding this comment

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

Can you use REV_EOF1 here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added as instr::REV_EOF1 but revision handling can be improved further. I wonder if we can make the revision opaque for EVMC.

For code analysis context only pass a `bool` value if EOF is enabled.
This was the only information the analysis extracted from the previously
used full EVM revision.
Expose more information from the `CodeAnalysis` class via new methods.
Make fields private and hide some implementation details.
Take the EOF data section contents from the `CodeAnalysis` object
instead of complicating the `ExecutionState`.
@chfast chfast merged commit 1004496 into master Sep 12, 2024
25 checks passed
@chfast chfast deleted the baseline/code_api branch September 12, 2024 15:12
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