-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Apply new EVM opcode updates #2602
base: next
Are you sure you want to change the base?
Conversation
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.
Looks good to me. Please add some test cases though in tests/details/evm.yaml
. (They are desperately needed in general.)
49a1352
to
0a7e356
Compare
@Rot127 Thanks. I've added simple test cases. PTAL. |
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.
Not all instructions which push and pop are covered yet I think.
E.g. EVMDisassembler.c::289
should also include PUSH0
?
Also, I think instructions like ChainID
also push onto the stack (feel free to correct me if I am wrong, never used EVM).
Sorry, you are the first contributor for a while looking at the EVM code. Now I see all the missing cases (and as you see, nothing was tested before). It would be nice if you could add a test case for each new instruction. So we get step by step to a better module.
PUSH0 is to replace PUSH 0x00 for space efficiency and has no payload.
I just followed the old test style. I'll add test cases for all introduced new opcodes.
Yes. Handled in |
Another question: For minor EVM forks (e.g., TRON added some opcodes, no conflicts, in 0xd0 to 0xdf range), what's the recommended implementation strategy in Capstone? |
Feature flags (or modes) is the way to go. They are defined in
Thank you! It doesn't even need to be all opcodes ( The old test coverage was barely there (for details at least). And only done for bug fixes. So we have to catch up quite a lot unfortunately. With all archs, not just EVM. |
0a7e356
to
bb63a03
Compare
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.
Test cases added.
Thanks, this is helpful. I'll implement the alternative architecture support in a separate PR. |
|
Error likely happens because the first value in the instruction enum @kabeor Please review this as well. It is basically done. |
Please correct me if I misunderstood:
|
In essence, yes. This is correct. But I just recognized that the enum of EVM instructions are probably bound to their definition in the RFCs. So changing I think alternatively, we could add a method to the Python bindings which checks the Something along the line: (in class CsInsn:
def is_invalid_insn(self) -> bool:
arch = self._cs.arch
if arch == CS_ARCH_EVM:
return self.id() == EVM_INS_INVALID
else:
# Probably better to write it out for all architectures though.
return self.id() == 0 Then replace all checks of if |
Agreed. The python side approach is better. |
Exceptions are gone! One case is still left:
And the group seems incorrect?
|
Please rebase onto the latest |
891f675
to
ef0dda7
Compare
@Rot127 Now all checks have passed. PTAL |
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.
Excellent! Thanks a lot, also for the repairs :)
I can't merge without the permission from @kabeor. But he said he will find time reviewing and merging all the PRs before Lunar New Year holidays.
@kabeor could you please take a look? |
Your checklist for this pull request
I've documented or updated the documentation of every API function and struct this PR changes.
I've added tests that prove my fix is effective or that my feature works (if possible)
No API change
If it's required to add test cased to new opcodes, I'm glad to do so.
Detailed description
Test plan
...
Closing issues
...