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 instruction names #252

Merged
merged 3 commits into from
Jun 25, 2018
Merged

EVM instruction names #252

merged 3 commits into from
Jun 25, 2018

Conversation

chfast
Copy link
Collaborator

@chfast chfast commented Jun 11, 2018

No description provided.

@chfast chfast requested review from jwasinger and jakelang June 11, 2018 13:36
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";
Copy link
Member

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.

Copy link
Collaborator Author

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)];
Copy link
Member

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

@axic
Copy link
Member

axic commented Jun 11, 2018

Build and tests are failing.

@jakelang
Copy link
Member

jakelang commented Jun 12, 2018

@axic this is probably failing because it needs to be rebased for the create gas changes in #250
edit: nvm
edit: not nvm
edit: rebased

@axic
Copy link
Member

axic commented Jun 12, 2018

This will need to be changed after ethereum/evmc#34 is merged. I think this one here is pending till then.

@jakelang
Copy link
Member

jakelang commented Jun 12, 2018

@chfast I think that the tests are failing build because cpp-ethereum has an outdated evmc submodule pointing to a commit without the evmc::evmc alias.
Or the CI is pointing to a cpp-ethereum commit where the above has not been fixed.

@chfast chfast force-pushed the evm-instructions branch from 61ba7bc to 897985c Compare June 16, 2018 19:05
@chfast
Copy link
Collaborator Author

chfast commented Jun 16, 2018

Updated cpp-ethereum, ewasm-tests is fine now.
Is failure of linux-clang-shared-release expected?

@chfast
Copy link
Collaborator Author

chfast commented Jun 18, 2018

The failure in linux-clang-shared-release happens in all other PRs. Please review!

@axic
Copy link
Member

axic commented Jun 19, 2018

@chfast is this now updated to the final evmc version for instruction names?

@axic
Copy link
Member

axic commented Jun 19, 2018

The failure in linux-clang-shared-release happens in all other PRs. Please review!

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);
Copy link
Member

Choose a reason for hiding this comment

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

OMG, that looks hideous

Copy link
Collaborator Author

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

Copy link
Member

Choose a reason for hiding this comment

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

Any better option?

Copy link
Collaborator Author

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*).

Copy link
Collaborator Author

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*.

Copy link
Member

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?

Copy link
Collaborator Author

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.

@hugo-dc
Copy link
Member

hugo-dc commented Jun 19, 2018

@axic it is not passing one of the newer test cases, I'll take a look

@chfast
Copy link
Collaborator Author

chfast commented Jun 20, 2018

Can I merge it now?

@hugo-dc
Copy link
Member

hugo-dc commented Jun 20, 2018

One of the new test case is failing createNonzero, I think we should remove it by now and investigate why it is not passing. cc @lrettig

@lrettig
Copy link
Member

lrettig commented Jun 20, 2018

@hugo-dc just ran createNonzero against this hera branch and it's passing for me. Can someone kick off these tests again? They were last run four days ago.

@chfast
Copy link
Collaborator Author

chfast commented Jun 20, 2018

Green!

@axic axic merged commit bcf1f51 into master Jun 25, 2018
@axic axic deleted the evm-instructions branch June 25, 2018 15:22
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.

5 participants