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

eof: Syntax tests update #15661

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

Conversation

rodiazet
Copy link
Contributor

  • Compile syntax test via IR by default when EOF enabled.
  • Disable syntax tests which won't work with EOF when compiling to flag EOF enabled.

This comment was marked as resolved.

Copy link
Member

@cameel cameel left a comment

Choose a reason for hiding this comment

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

I think that in some cases here just disabling the test on EOF is not the right solution. Some of them should have EOF version, some can be adjusted to work on both. I even found some that shouldn't need to be disabled because they seem work on both already.

There are also cases which indicate that we're missing some codegen asserts (and analysis checks). And even one case which is a result of a previously undiscovered unimplemented part of the IR codegen.

Copy link
Member

Choose a reason for hiding this comment

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

This one (and nested_calldata_storage2.sol) should still be tested via IR, just with different expectations (no error). Please add a copy with compileViaYul: true and that will pass on EOF just fine.

Or, even better, add them as semantic tests, since if they pass, we should also make sure they produce correct results.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Better option is done

Copy link
Member

Choose a reason for hiding this comment

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

I see that the original syntax tests are still there. I'd replace bytecodeFormat: legacy in them with compileViaYul: false.

Also, please fix indents in the new semantic tests.

Copy link
Member

Choose a reason for hiding this comment

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

We should have an EOF version of this, without gas.

Same for viewPureChecker/gas_value_without_call.sol and viewPureChecker/gas_with_call_nonpayable.sol.

Copy link
Member

Choose a reason for hiding this comment

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

And these should be rewritten to use value instead:

  • comparison_operator_for_external_functions_with_extra_gas_slots.sol (rename to comparison_operator_for_external_functions_with_call_options.sol)
  • external_functions_with_variable_number_of_stack_slots.sol
  • types_with_unspecified_encoding_internal_functions.sol

The use of gas there seems incidental. Any other call option would work just as well.

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

Copy link
Member

Choose a reason for hiding this comment

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

  • You still have bytecodeFormat: legacy in external_functions_with_variable_number_of_stack_slots.sol and types_with_unspecified_encoding_internal_functions.sol.
  • Please also rename eof/gas_value_without_call.sol to eof/call_options_without_call.sol (it no longer uses gas).
    • It also does not need bytecodeFormat: >=EOFv1. Should work for legacy too.
  • Looking at gas_with_call_nonpayable.sol again now, I was wrong, gas actually is relevant there. We could replace it with value, but I see that such a test already exists and passes for EOF as well. So we can actually just drop eof/gas_with_call_nonpayable.sol` without much loss.

test/libsolidity/syntaxTests/immutable/no_assignments.sol Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

This one will still work if you replace codesize() with something else, e.g. calldataload(0). It's meant to test that hex literals are usable with switch and the use of codesize() is incidental.

Same for string_literal_switch_case.sol.

Copy link
Member

Choose a reason for hiding this comment

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

You still have bytecodeFormat: legacy in string_literal_switch_case.sol.

Copy link
Member

Choose a reason for hiding this comment

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

This one should have an EOF version. EOF is still subject to the size limit and that should be tested.

Copy link
Member

Choose a reason for hiding this comment

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

viewPureChecker/assembly.sol, viewPureChecker/builtin_functions.sol and all the viewPureChecker/inline_assembly_instructions_*.sol tests should have EOF versions, with legacy instructions removed (EOF equivalents used where possible) and some new EOF instructions added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regarding bytecode_too_large.sol we have different problem. Compiler throws an exception saying Relative jump too far. At this stage we don't know what is the size of the runtime bytecode yet. So I think we should add a test which verifies that proper exception is thrown in this case.

Copy link
Contributor Author

@rodiazet rodiazet Jan 8, 2025

Choose a reason for hiding this comment

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

After fixing this there is one important question. Which of the new EOF builtin function should be available in assembly? There are eofcreate, auxdataloadn and returncontract. IMO non of them should but please confirm. If so additional change is required to disallow this.

Copy link
Member

Choose a reason for hiding this comment

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

eofcreate() definitely should be available. It's a replacement for create()/create2() and both are available on legacy (actually, I see that they're missing from those tests for some reason; could you add them?).

With returncontract(), while it's potentially less useful, I still don't see much reason to disallow it. You can put assembly in a constructor now and use return() there and that would be the equivalent now.

As for auxdataladn(), here the case for disallowing it would be the strongest, because currently you can't use loadimmutable() in inline assembly. But it could also be used to read some other things stored in data section, so it's broader than that. I also don't see much harm in allowing it.

I'll add a point to the main EOF issue to discuss those and make a decision, but for now I'd say let's assume they'll be allowed and add them to these tests.

Copy link
Member

@cameel cameel Jan 22, 2025

Choose a reason for hiding this comment

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

Ah, I see that create2() is in one of the cases targeting specific EVM versions (>= constantinople). There are more instructions like this. For EOF they should all be added to the main tests since we don't have to worry about older EVM versions.

Copy link
Member

Choose a reason for hiding this comment

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

Regarding bytecode_too_large.sol we have different problem. Compiler throws an exception saying Relative jump too far.

I think that's due to missing optimization. Currently this code generates a ton of mstores on EOF while on legacy you get much smaller code and a data object, which would prevent this.

Let's add the test with the jump error in expectations and just add a TODO saying that they should change to the proper error once we have all optimizations in place.

@rodiazet rodiazet force-pushed the eof-syntax-tests-update branch from 5969f81 to 9072b2e Compare January 9, 2025 11:41
}
}
// ====
// bytecodeFormat: legacy
Copy link
Member

@cameel cameel Jan 22, 2025

Choose a reason for hiding this comment

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

This test should now run on EOF as well.

Comment on lines +9 to +10
// EVMVersion: >=byzantium
// bytecodeFormat: >=EOFv1
Copy link
Member

Choose a reason for hiding this comment

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

You can merge this case with inline_assembly_instructions_disallowed_pure.sol, because EOF is not available on byzantium anyway so the restriction is unnecessary.

Comment on lines +20 to +21
// EVMVersion: >=london
// bytecodeFormat: >=EOFv1
Copy link
Member

@cameel cameel Jan 22, 2025

Choose a reason for hiding this comment

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

I see that this and some other newly added cases in viewPureChecker/eof/*.sol have EVM version restriction. It's unnecessary.

pop(caller())
pop(callvalue())
pop(extcall(0, 1, 2, 3))
pop(extdelegatecall(0, 1, 2))
Copy link
Member

@cameel cameel Jan 22, 2025

Choose a reason for hiding this comment

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

extstaticcall is missing here.

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.

2 participants