Skip to content

eof: Pass _eofVersion down to libevmasm/Assembly class #15356

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

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

rodiazet
Copy link
Contributor

No description provided.

Copy link

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

@rodiazet rodiazet changed the title Pass _eofVersion down to libevmasm/Assembly class eof: Pass _eofVersion down to libevmasm/Assembly class Aug 23, 2024
Copy link
Member

@ekpyron ekpyron left a comment

Choose a reason for hiding this comment

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

Looking at it again in isolation I do have a few more, but only minor comments - I've not yet seen why this would make that one test failing that CI complains about (I had assumed the CommonOptions::get().eofVersion() would also be empty for now?).

Comment on lines 1416 to 1424
std::shared_ptr<Compiler> compiler = std::make_shared<Compiler>(m_evmVersion, m_revertStrings, m_optimiserSettings);
std::shared_ptr<Compiler> compiler = std::make_shared<Compiler>(m_evmVersion, std::nullopt, m_revertStrings, m_optimiserSettings);
Copy link
Member

Choose a reason for hiding this comment

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

I actually didn't mean just passing std::nullopt here, but not adding the eof version option to Compiler (and CompilerContext) in the first place (and just have them pass std::nullopt to the Assemblys they need and such)
And an assert

solUnimplementedAssert(!m_eofVersion, "EOF is not supported for legacy code generation");

here also wouldn't hurt, together with the !m_viaIR assert below maybe.

@@ -99,7 +99,7 @@ class AbstractAssembly
/// Append the assembled size as a constant.
virtual void appendAssemblySize() = 0;
/// Creates a new sub-assembly, which can be referenced using dataSize and dataOffset.
virtual std::pair<std::shared_ptr<AbstractAssembly>, SubID> createSubAssembly(bool _creation, std::string _name = "") = 0;
virtual std::pair<std::shared_ptr<AbstractAssembly>, SubID> createSubAssembly(bool _creation, std::optional<uint8_t> _eofVersion, std::string _name = "") = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Also looking a bit closer here: should a sub-assembly get its own EOF version? I'd imagine that it'd always inherit the EOF version from the parent Assembly. (In the EthAssemblyAdapter implementation you can fetch it from the wrapped Assembly, in NoOutputAssembly, you'd need to store it.)

Or is the idea that technically there could be EOF version 1 containers containing EOF version 2 containers?

@@ -862,6 +864,8 @@ LinkerObject const& Assembly::assemble() const

LinkerObject& ret = m_assembledObject;

bool const eof = m_eofVersion.has_value();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bool const eof = m_eofVersion.has_value();
bool const eof = m_eofVersion.has_value();
solAssert(!eof || m_eofVersion == 1, "Invalid EOF version.");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@rodiazet
Copy link
Contributor Author

rodiazet commented Aug 26, 2024

Looking at it again in isolation I do have a few more, but only minor comments - I've not yet seen why this would make that one test failing that CI complains about (I had assumed the CommonOptions::get().eofVersion() would also be empty for now?).

Problem is in https://github.com/ipsilon/solidity/blob/eof-prep-1/test/libsolidity/Metadata.cpp#L228 test. It doesn't make sense for now. Even changing first evm version to prague() does not help because the codegen produce a code with PushTag which is not allowed for eof and is asserts in https://github.com/ipsilon/solidity/blob/eof-prep-1/libevmasm/Assembly.cpp#L965.

The test should be added later and adjusted to new EOF version. I can move it to proper commit (later PR) of the eof-cleaned branch. Let me know your opinion.

@ekpyron
Copy link
Member

ekpyron commented Aug 27, 2024

Looking at it again in isolation I do have a few more, but only minor comments - I've not yet seen why this would make that one test failing that CI complains about (I had assumed the CommonOptions::get().eofVersion() would also be empty for now?).

Problem is in https://github.com/ipsilon/solidity/blob/eof-prep-1/test/libsolidity/Metadata.cpp#L228 test. It doesn't make sense for now. Even changing first evm version to prague() does not help because the codegen produce a code with PushTag which is not allowed for eof and is asserts in https://github.com/ipsilon/solidity/blob/eof-prep-1/libevmasm/Assembly.cpp#L965.

The test should be added later and adjusted to new EOF version. I can move it to proper commit (later PR) of the eof-cleaned branch. Let me know your opinion.

Makes sense, yeah - we need clean CI to merge this, but we can just remove the test for now, merge this PR and bring the test back later, yes!

@rodiazet rodiazet requested a review from ekpyron August 28, 2024 13:13
@ekpyron ekpyron merged commit 9b33e00 into ethereum:develop Sep 3, 2024
72 checks passed
@axic axic deleted the eof-prep-1 branch September 3, 2024 09:41
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.

3 participants