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

Rename invalid to verbatim #1

Closed
axic opened this issue Jun 10, 2022 · 2 comments
Closed

Rename invalid to verbatim #1

axic opened this issue Jun 10, 2022 · 2 comments

Comments

@axic
Copy link

axic commented Jun 10, 2022

(invalid #xaabbccff) - sequence of bytes that represent a sequence of arbitrary invalid instructions

This may be confused with the invalid instruction. Solidity/Yul has a verbatim instruction, which may be a good naming in this case as well, i.e (verbatim #5c0001) to encode RJUMP 1 (EIP-4200.

Btw, does the literal has any length limitation?

@dvush
Copy link
Owner

dvush commented Jun 11, 2022

Hi, thanks for the comment.

  1. In the current form, invalid works as a verbatim, and it does not have any length limitation - its just any blob of bytes.
  2. I often refer to any instruction that is not defined as invalid, but you are right - special 'invalid' opcode may be different because users will always be sure that it is 'invalid' unlike generic 'verbatim' sequence that can become valid after update.
  3. When I thought about naming it invalid, I was thinking about an experience that I had when I tried symbolical execution of code. I decided to lump all instruction after 'undefined' one but before valid jumpdest into one blob because it makes reading asm easier and bytecode inside this blob is unreachable. Also, even valid jumpdest can be lumped together with 'invalid' blob if it immediately followed by it - because jump to that location will fail anyway. ecfg panics on certain contracts quilt/etk#99 (comment)

Currently, 'invalid' does not have checks described above (i.e. we can write (invalid #x00) and it's the same as stop, but maybe it makes sense to be implemented: asm may check if invalid blocks inside are indeed unexecutable.

But now that I think about it – checking that (invalid ..) is indeed unexecutable while writing code may hurt someone because some compact data (i.e. jump table) can have executable parts (like accidental jumpdest stop) but on the other hand I can imagine someone using 'invalid' to have extra protection against suddenly making data executable.

In the spirit of lisp the good solution would be to give user (for this particular project it's probably just me) helper function that can check if some verbatim code is indeed executable data.

Anyway, you have a good point, I'll think about it!

@dvush
Copy link
Owner

dvush commented Aug 11, 2022

renamed, why not

@dvush dvush closed this as completed Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants