Conversation
7765c0b to
d27046d
Compare
Codecov Report
@@ Coverage Diff @@
## eof-execution #366 +/- ##
==============================================
Coverage 99.57% 99.58%
==============================================
Files 37 37
Lines 4487 4551 +64
==============================================
+ Hits 4468 4532 +64
Misses 19 19
Flags with carried forward coverage won't be shown. Click here to find out more.
|
b166534 to
850d7b8
Compare
d27046d to
cac511b
Compare
1ccc8aa to
f82ac27
Compare
e07ffef to
de74fc2
Compare
3b42a85 to
2411d77
Compare
8127c9b to
6181dd1
Compare
a73f066 to
eb773aa
Compare
d387060 to
38461f6
Compare
a574ec8 to
6eb5cc5
Compare
1210ca1 to
e017bda
Compare
6826cc4 to
453c9ca
Compare
e017bda to
c09f8cc
Compare
| int8_t stack_height_change = 0; | ||
|
|
||
| /// Size of the immediate argument in bytes. | ||
| uint8_t immediate_size = 0; |
There was a problem hiding this comment.
Probably better to place it as the second field. The whole traits change should be submitted separately.
There was a problem hiding this comment.
Why the second? What about is_terminating?
Do you want a separate PR? (these fields are used only in this PR) I put it into a separate commit so far.
| return {{}, error}; | ||
| assert(code.size() > 0); // guaranteed by EOF headers validation | ||
|
|
||
| size_t i = 0; |
There was a problem hiding this comment.
Why isn't this an iterator instead?
There was a problem hiding this comment.
Because with an iterator loop end condition can be only it != code.end(), but loop can overrun end in case of truncated immediate.
| { | ||
| op = code[i]; | ||
| const auto& since = instr::traits[op].since; | ||
| if (!since.has_value() || *since > rev) |
There was a problem hiding this comment.
I think this doesn't cover the case when we want to remove an opcode (e.g.calldata) from EOF contracts?
There was a problem hiding this comment.
Yes, when that happens I guess we will need to add final revision to traits.
There was a problem hiding this comment.
Yes. This looks like a good solution if needed.
Validate that all used instructions are defined and code ends with a terminating instruction.
|
|
||
| namespace | ||
| { | ||
| inline EOFValidationError validate_eof(bytes_view cont, evmc_revision rev = EVMC_SHANGHAI) noexcept |
There was a problem hiding this comment.
| inline EOFValidationError validate_eof(bytes_view cont, evmc_revision rev = EVMC_SHANGHAI) noexcept | |
| inline EOFValidationError validate_eof(bytes_view container, evmc_revision rev = EVMC_SHANGHAI) noexcept |
| { | ||
| inline EOFValidationError validate_eof(bytes_view cont, evmc_revision rev = EVMC_SHANGHAI) noexcept | ||
| { | ||
| return ::validate_eof(rev, cont); |
There was a problem hiding this comment.
Does it call evmone::validate_eof()? I'm confused.
| } | ||
|
|
||
| inline EOFValidationError validate_eof( | ||
| std::string_view code_hex, evmc_revision rev = EVMC_SHANGHAI) noexcept |
There was a problem hiding this comment.
It seems this overload is used once and there is another use case as validate_eof(from_hex(...)). I'm rather for removing this overload. It sometimes become confusing when a unit tests multiple levels of wrappers. Using from_hex() or bytecode{} is fine or you can use bytecode as the type of the parameter.
There was a problem hiding this comment.
Changed it to a single helper with bytecode parameter, can be called with either hex string or bytes container.
There was a problem hiding this comment.
clang-tidy want it as const bytecode&. I think changing it like this should not be a problem.
| while (i < code.size()) | ||
| { | ||
| op = code[i]; | ||
| const auto& since = instr::traits[op].since; |
There was a problem hiding this comment.
I think it is fine for now, but instr::traits has sub-optimal layout for runtime use.
| { | ||
| op = code[i]; | ||
| const auto& since = instr::traits[op].since; | ||
| if (!since.has_value() || *since > rev) |
There was a problem hiding this comment.
Yes. This looks like a good solution if needed.
No description provided.