-
Notifications
You must be signed in to change notification settings - Fork 50
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 instruction names #252
Conversation
src/eei.cpp
Outdated
string opName = (it != evmInstructionNames.end()) ? it->second : "UNKNOWN"; | ||
const char* opName = evmc_get_instruction_name_table()[static_cast<uint8_t>(opcode)]; | ||
if (opName == nullptr) | ||
opName = "UNDEFINED"; |
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.
Is undefined
used by the tracing format? The code above used unknown
previously.
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'm not sure tests depends on this, but the "undefined" name comes from https://github.com/ethereum/evmc/blob/master/include/evmc/evmc.h#L229.
src/eei.cpp
Outdated
@@ -177,8 +178,9 @@ inline int64_t maxCallGas(int64_t gas) { | |||
heraAssert(sp <= (1024 * stackItemSize), "EVM stack pointer out of bounds."); | |||
heraAssert(opcode >= 0x00 && opcode <= 0xff, "Invalid EVM instruction."); | |||
|
|||
auto it = evmInstructionNames.find(static_cast<uint8_t>(opcode)); | |||
string opName = (it != evmInstructionNames.end()) ? it->second : "UNKNOWN"; | |||
const char* opName = evmc_get_instruction_name_table()[static_cast<uint8_t>(opcode)]; |
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'd like to have a check that this only gets byzantium
opcodes since that is what evm2wasm "supports". The only way to do that with the current API is to build a local array while calling get_instruction_metrics
every time. See my comments here: ethereum/evmc#33
Build and tests are failing. |
f1e6293
to
61ba7bc
Compare
This will need to be changed after ethereum/evmc#34 is merged. I think this one here is pending till then. |
@chfast I think that the tests are failing build because cpp-ethereum has an outdated evmc submodule pointing to a commit without the |
Updated cpp-ethereum, ewasm-tests is fine now. |
The failure in |
@chfast is this now updated to the final evmc version for instruction names? |
I think someone broke the test suite again and left in debugging statements. cc @hugo-dc @lrettig @jwasinger ? |
@@ -177,8 +178,10 @@ inline int64_t maxCallGas(int64_t gas) { | |||
heraAssert(sp <= (1024 * stackItemSize), "EVM stack pointer out of bounds."); | |||
heraAssert(opcode >= 0x00 && opcode <= 0xff, "Invalid EVM instruction."); | |||
|
|||
auto it = evmInstructionNames.find(static_cast<uint8_t>(opcode)); | |||
string opName = (it != evmInstructionNames.end()) ? it->second : "UNKNOWN"; | |||
const char* const* const opNamesTable = evmc_get_instruction_names_table(EVMC_BYZANTIUM); |
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.
OMG, that looks hideous
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.
True. If you want I can change it to const char* const*
:D
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.
Any better option?
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.
No, because you cannot return an array in C. It must be a const pointer to an item (which is const char*
).
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.
Here you can just use auto
or auto*
.
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.
Does that ensure constness though?
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.
Yes. The best would be const auto
.
@axic it is not passing one of the newer test cases, I'll take a look |
Can I merge it now? |
One of the new test case is failing |
@hugo-dc just ran |
Green! |
No description provided.