-
Notifications
You must be signed in to change notification settings - Fork 13
Description
With this PR, we can now use the foundry-merge-nodes command to merge two nodes in different branches into a single node that subsumes both. This lets us merge branches back after a split, for example after an if statement or a loop, continuing the execution as a single branch, which has the potential of greatly improving the scalability of the tool in code with many loops or if statements.
However, this command has a few limitations in terms of usability:
- The corresponding nodes in each branch (same PC) need to be present in the KCFG in order to be merged. This is not necessarily easy to ensure.
- Because it requires manual intervention, the result of the verification becomes harder to reproduce.
We should think about ways to address these limitations to make this functionality easier to use. For example, suppose there was a cheatcode kevm.mergePoint() that denotes the point where we want to merge branches:
if (condition) {
// if branch
} else {
// else branch
}
kevm.mergePoint();
If we could implement this cheatcode such that the point where it's called is always added as a node to the KCFG, this would take care of (1). Going one step further, if we had an option to automatically merge such nodes if they have the same PC, this would take care of (2) (but this heuristic might not always work, for example if the merge point itself is inside a loop or a function that is called multiple times). But I don't know if something like that could actually be implemented, because it is a cheatcode that would not be handled solely from inside kevm, instead needing to somehow communicate with pyk.
I'd like to hear people's thoughts on this and brainstorm possible options.