runtimeverification / runtimeverification/kontrol
Custom view shows another contract and uses the wrong PC in the kcfg viewer
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 122
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
Issue
When launching the kcfg-viewer, the custom view is not very useful because it rarely shows the correct executed part of the Solidity source.
There are two reasons of that:
- Only the testing contract is passed to the source map (1)
- Source maps are indexed by instruction index, but are fetched by PC (2)
(1)
When calling the exec_foundry_view_kcfg function
We get the name of the testing contract
And only this one is passed to the source mapping structure
Then if any external contract is called, we will not see the executed part in the source code
(2)
The instr_to_pc is correctly implemented but not used here
Here
We should probably rewrite it as:
_srcmap[instr_to_pc[i]] = (s, l, f, j, m)
Ideas
There is no way to know which contract is executed from the PC information only, because it may overlap (it starts at PC = 0 when executing a new contract).
Then when calling back _custom_view(), we may want to pass the contract name.
So a solution would be to allow writing the name of the contract that is currently executed in the K cell although not very desirable probably.
A better solution would be to write the bytecode of the contract that is currently executed in the node and we could fetch the contract, but if two contracts have the same bytecode then it may display the wrong one and may confuse the user.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Trace exec_foundry_view_kcfg in kevm-pyk/src/kevm_pyk/main.py and the source-map construction in kevm-pyk/src/kevm_pyk/solc_to_k.py, including instr_to_pc. Determine how _custom_view receives execution context, then define and test a way for the custom view to select the correct contract and source span for external calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, solidity
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100