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

Add support for cut cheat code #163

Closed
wants to merge 2 commits into from
Closed

Add support for cut cheat code #163

wants to merge 2 commits into from

Conversation

anvacaru
Copy link
Contributor

@anvacaru anvacaru commented Nov 8, 2023

Fixes: #23

Added a new cut cheat code that takes a program counter and will create a new KCFG node whenever that program counter is executed.

  • When the cut is executed in a proof/test, the program counter argument is added to a set in the cell.
  • The #pc [ OP ] rule is overwritten to identify when a program count in the cell is executed.
  • Added an empty foundry.cut rule and marked it as a cut-point rule to create the new node in the kcfg.

TODO:

  • add test
  • update expected output
  • extract cut cheat code in the cheat code library after this PR is merged

@anvacaru anvacaru added the enhancement New feature or request label Nov 8, 2023
@lucasmt
Copy link
Contributor

lucasmt commented Nov 9, 2023

I tried the cut cheatcode at the example from PR #162, but it didn't seem to be working. I used kontrol section-edge to look closer at what's going on, and I found that it was just skipping from #next to #execute without going through #pc (which is what should trigger the #cut instruction):

┃  │  (1 step)
┃  ├─ 122
┃  │   k: #next [ PUSH ( 2 ) ] ~> #execute ~> CONTINUATION:K
┃  │   pc: 4690
┃  │   callDepth: 0
┃  │   statusCode: STATUSCODE:StatusCode
┃  │
┃  │  (1 step)
┃  ├─ 123
┃  │   k: #execute ~> CONTINUATION:K
┃  │   pc: 4693
┃  │   callDepth: 0
┃  │   statusCode: STATUSCODE:StatusCode

I think this is because of the optimizations in the optimizations.md file. Not sure what's the best way to get around this.

@lucasmt
Copy link
Contributor

lucasmt commented Nov 9, 2023

Additionally, I think the cheatcode also won't work if the PC is arrived at from a JUMP instruction. Although this might not be as big of a problem since one can just use the PC immediately following the JUMPDEST.

@anvacaru
Copy link
Contributor Author

Closing this for now.

@anvacaru anvacaru closed this Nov 28, 2023
@anvacaru anvacaru deleted the anvacaru/cutPC branch November 28, 2023 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Usability improvements to foundry-merge-node
2 participants