Skip to content

evmasm test case #16012

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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

evmasm test case #16012

wants to merge 5 commits into from

Conversation

cameel
Copy link
Member

@cameel cameel commented Apr 19, 2025

Adds a new custom test case that accepts EVM assembly as input, which allows inspecting the results of assembly import and evmasm optimizer. It should replace the Boost-based optimizer tests from test/libevmasm/Optimiser.cpp as well as the command-line tests for assembly import.

The test case can take the assembly in JSON format as well as a simplified text format that can be easily post-processed into JSON ("plain assembly"). Plain assembly is currently very limited, but should still be enough to cover #15935. It allows using all opcodes as well as tags and jumps. It does not yet support subassemblies, data, metadata or the less common types of assembly items, but the format is designed to accommodate them and I'm going to add them in subsequent PRs.

@cameel cameel requested review from clonker and nikola-matic April 19, 2025 07:33
@cameel cameel self-assigned this Apr 19, 2025
Comment on lines +96 to +98
// TODO: Enable when assembly import for EOF is implemented.
if (CommonOptions::get().eofVersion().has_value())
m_shouldRun = false;
Copy link
Member Author

Choose a reason for hiding this comment

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

The test case can easily be extended support EOF, but we need to implement assembly import for EOF first.

@cameel cameel force-pushed the evmasm-test-case branch from 1fd7f7d to ce8ca0a Compare April 19, 2025 08:11
Comment on lines +70 to +74
if (!immediateArgument.starts_with("0x"))
BOOST_THROW_EXCEPTION(std::runtime_error(formatError("The immediate argument to PUSH must be a hex number prefixed with '0x'.")));

immediateArgument.remove_prefix("0x"s.size());
codeJSON.push_back({{"name", "PUSH"}, {"value", immediateArgument}});
Copy link
Member Author

Choose a reason for hiding this comment

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

It's quite annoying that the JSON format accepts only hex numbers here but without the 0x prefix. On the other hand for tag it accepts both both and the ones without 0x are actually decimal.

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