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

EVM instructions table #33

Merged
merged 9 commits into from
Jun 11, 2018
Merged

EVM instructions table #33

merged 9 commits into from
Jun 11, 2018

Conversation

chfast
Copy link
Member

@chfast chfast commented Jun 7, 2018

No description provided.

@chfast chfast force-pushed the evm-instructions branch 2 times, most recently from 57d8f7a to 762cdb9 Compare June 8, 2018 10:11
@chfast chfast requested review from axic and gumb0 June 8, 2018 10:32

/** @} */

static struct evmc_instruction_metrics constantinople_metrics[256] = {
Copy link
Member

Choose a reason for hiding this comment

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

This file is 1600 lines, maybe put revisions in separate files? It would be also easier to diff them

Copy link
Member Author

Choose a reason for hiding this comment

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

After thinking about this for 2 day, I'd like to keep it as it is. I hope this is single time job and it should depend on testing, not manual review (some parts already tested, I can add test cases for all HFs).

  1. To add a new EVM revision you will have to copy the recent one and apply changes. This should not be very complicated. In case it was in separate files, you will also have to alter the CMake config.

  2. Having all this in 2 files make it easier to copy to other projects, even translate to other languages.

  3. Having the tables in separate files require to make the symbol default visibility.

* from all EVM revisions. Use evmc_get_instruction_metrics_table() to know if an instruction
* is present in the given EVM revision.
*
* @return The pointer to the array of 256 instruction names.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a note that it contains some NULLs besides names?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added.

@chfast chfast merged commit 37cc64f into master Jun 11, 2018
@chfast chfast deleted the evm-instructions branch June 11, 2018 13:28
*
* @return The pointer to the array of 256 instruction names.
*/
const char* const* evmc_get_instruction_name_table();
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this also have revision parameter?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it has names for all opcodes, i.e. from the latest revision. I think it's good enough for debugging.

Copy link
Member

Choose a reason for hiding this comment

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

Would a good middle ground be a helper which based on the revision generates a table relevant to that revision? It would do that every time, so the callee would need to ensure it stores the result.

Copy link
Member Author

Choose a reason for hiding this comment

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

No. I will just add the revision here as well if there is the use case for it.

Copy link
Member

Choose a reason for hiding this comment

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

I do like the idea of having this static const table too.

*
* This table is EVM revision independent and contains the superset of the names of the instructions
* from all EVM revisions. Use evmc_get_instruction_metrics_table() to know if an instruction
* is present in the given EVM revision.
Copy link
Member

Choose a reason for hiding this comment

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

I thought this was the reason for the decision, but it seems a bit convoluted.

@chfast
Copy link
Member Author

chfast commented Jun 11, 2018

Because of the name clash on Windows, I have to rename the enum items.

Which one to use?

  • EVMC_OP_ADDMOD
  • EVM_ADDMOD
  • OP_ADDMOD

@axic
Copy link
Member

axic commented Jun 11, 2018

Basically it can clash with macros, correct?

@chfast
Copy link
Member Author

chfast commented Jun 11, 2018

Is the "opcode" a more precise name to "instruction"? Everybody seems to be using "instruction" name in Ethereum.

@chfast
Copy link
Member Author

chfast commented Jun 11, 2018

Basically it can clash with macros, correct?

It clashes with BYTE typedef somewhere in Windows headers.

@axic
Copy link
Member

axic commented Jun 11, 2018

I think the "instruction" term stands for the abstract instruction, while "opcode" term stands for the encoding of it as bytes. Since EVM is rather simple, there's not much going on in terms of encoding :)

@axic
Copy link
Member

axic commented Jun 11, 2018

Based on that I think opcode would be the more relevant term here, since you assign the encoded value to it.

@chfast chfast mentioned this pull request Jun 11, 2018
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

Successfully merging this pull request may close these issues.

3 participants