Improvements to PHI instruction handling#38
Conversation
…rivate Add a sanity check for CALLPRIVATE argument count match
Signed-off-by: degrigis <degrigis@ucsb.edu>
…olic options for PartialConcreteStorage Signed-off-by: degrigis <degrigis@ucsb.edu>
Signed-off-by: degrigis <degrigis@ucsb.edu>
This reverts commit 65e3a87.
Update inspect plugin to support OP_BEFORE and OP_AFTER
Add hook plugin
writen to write n bytes
blacklist exploration technique
use bytes.fromhex to load contract bytecode
add support for TLOAD/TSTORE
…_safemath auto patch safemath
|
Hey there! Thanks a lot for the contribution, we'll take a look at the PR and get back to you :) |
bugfix: YicesTermBVZeroExtend not suppported in symbols_referenced_at
|
Hey @syang-ng , really appreciate this contrib but we are currently not 100% sure if we want to merge the While we are disscussing what is the best way to go here, do you mind rebasing that branch Thanks a lot! |
|
Can you maybe clarify your use case for requiring phi as an instruction? Ultimately I never found a justification for the change; I didn't observe any situation where it helps our analyses over the current solution (even if the current solution is a bit odd). Can you comment on that? |
|
I agree that the current handling of I like the idea of treating |
|
I agree it would be great to have this merged into the |
ece7dda to
3a44049
Compare
|
Sure! I updated it as you suggested, @degrigis. Thanks everyone for reviewing -- let me know if there are any issues. |
|
@robmcl4 you have a second to fix the conflicts and merge this? :) |
Motivation
The current implementation of
phi_as_instructiontracks the last written register and assigns this register to the variable determined by the PHI instruction. This can cause an issue when there are multiple PHI instructions with overlapping sources — all variables may come from the same register. For example, ifvf1b0arg1uses the most recently written register, it could be assigned to0xc110xf1b0_0x0,0xc110xf1b0_0x2, and0xc110xf1b0_0x3. This could lead to false negatives in the analysis, as these variables are supposed to have different values.Solution
First, I merged the changes from the
mainbranch intophi_as_instruction(but I still use the oldparse_blocksingreed/TAC/TAC_parser.py, as the new parsing logic will trigger an error).Then, in this pull request, I implemented a simple solution to prevent the repeated usage of the same registers by counting their usage and avoiding reuse within the same block.
Specifically, I've added the following code (in

greed/TAC/gigahorse_ops.py) to track the number of times a block has been entered in the trace:and then avoid repeated usage of the same registers:

Summary: The handling of PHI instructions is a significant challenge. This pull request provides a temporary solution for specific issues I encountered in the smart contracts I tested. A more robust and complete solution may require continued effort :)