-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
base: develop
Are you sure you want to change the base?
eof: Syntax tests update #15661
Conversation
rodiazet
commented
Dec 19, 2024
- 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.
This comment was marked as resolved.
There was a problem hiding this 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better option is done
There was a problem hiding this comment.
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.
test/libsolidity/syntaxTests/functionCalls/calloptions_on_delegatecall.sol
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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 tocomparison_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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
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
inexternal_functions_with_variable_number_of_stack_slots.sol
andtypes_with_unspecified_encoding_internal_functions.sol
. - Please also rename
eof/gas_value_without_call.sol
toeof/call_options_without_call.sol
(it no longer usesgas
).- It also does not need
bytecodeFormat: >=EOFv1
. Should work for legacy too.
- It also does not need
- Looking at
gas_with_call_nonpayable.sol
again now, I was wrong,gas
actually is relevant there. We could replace it withvalue
, but I see that such a test already exists and passes for EOF as well. So we can actually just dropeof/
gas_with_call_nonpayable.sol` without much loss.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 sayingRelative jump too far
.
I think that's due to missing optimization. Currently this code generates a ton of mstore
s 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.
test/libsolidity/syntaxTests/inlineAssembly/assignment_from_library.sol
Outdated
Show resolved
Hide resolved
9c41121
to
5969f81
Compare
5969f81
to
9072b2e
Compare
} | ||
} | ||
// ==== | ||
// bytecodeFormat: legacy |
There was a problem hiding this comment.
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.
// EVMVersion: >=byzantium | ||
// bytecodeFormat: >=EOFv1 |
There was a problem hiding this comment.
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.
// EVMVersion: >=london | ||
// bytecodeFormat: >=EOFv1 |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extstaticcall
is missing here.