runtimeverification / runtimeverification/evm-semantics
Implement vm.record cheat code
Nobody has claimed this yet.
- Dominant language
- KCL
- Stars
- 591
- Forks
- 156
- Avg merge
- 2h 19m
- Merged PRs (30d)
- 1
Description
When testing an ercx test with the kevm foundry integration, the proof ended because it reached an unimplemented cheat code vm.record. The documentation for record can be found here.
As a suggestion, you can try this implementation:
- extending the configuration in
foundry.mdto add these cells:
<recordAccess>
<recordActive> false </recordActive>
<records>
<record multiplicity="*" type="Map">
<recordKey> 0 </recordKey>
<reads> .List </reads>
<writes> .List </writes>
</record>
</records>
</recordAccess>
- add a
#call_foundryrule that intercepts the call of the cheat code
rule [foundry.call.record]:
<k> #call_foundry SELECTOR _ => #enableRecord ... </k>
requires SELECTOR ==Int selector ( "record()" )
Here, #enableRecord will start recording the storage operations.
rule <k> #enableRecord => . ... </k>
<recordAccess>
<recordActive> _ => true </recordActive>
...
</recordAccess>
- overwrite rules for
SLOADandSSTOREto write in the records cells whilerecordActiveistrue.
rule [foundry.recordSLOAD]:
<k> SLOAD INDEX => #recordRead INDEX ~> #pauseRecord ~> SLOAD INDEX ~> #resumeRecord ... </k>
<recordAccess> <recordActive> true </recordActive> ... </recordAccess>
[priority(39)]
rule [foundry.recordSSTORE]:
<k> SSTORE INDEX NEW => #recordRead INDEX ~> #recordWrite INDEX ~> #pauseRecord ~> SSTORE INDEX NEW ~> #resumeRecord ... </k>
<recordAccess> <recordActive> true </recordActive> ... </recordAccess>
[priority(39)]
Here, #pauseRecord and #unpauseRecord could be used to allow the original SLOAD/SSTORE rules from evm.md to be executed by disabling/reenabling the recording.
rule <k> #resumeRecord => . ... </k>
<recordAccess> <recordActive> _ => true </recordActive> ... </recordAccess>
rule <k> #pauseRecord => . ... </k>
<recordAccess> <recordActive> _ => false </recordActive> ... </recordAccess>
And #recordRead and #recordWrite can record the operations.
rule <k> #recordRead V => . </k>
<id> KEY </id>
<recordAccess>
<record>
<recordKey> KEY </recordKey>
<reads> R => R ListItem(#buf(32, V)) </reads>
...
</record>
...
</recordAccess>
rule <k> #recordRead V => . </k>
<id> KEY </id>
<recordAccess>
<records>
( .Bag
=> <record>
<recordKey> KEY </recordKey>
<reads> ListItem(#buf(32, V)) </reads>
...
</record>
)
</records>
...
</recordAccess> [owise]
rule <k> #recordWrite V => . </k>
<id> KEY </id>
<recordAccess>
<record>
<recordKey> KEY </recordKey>
<writes> R => R ListItem(#buf(32, V)) </writes>
...
</record>
...
</recordAccess>
This cheat code goes hand in hand with vm.accesses, so probably this needs to be implemented as well.
Contributor guide
No contributing guide indexed for this repository
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
Start with foundry.md and the existing EVM rules in evm.md, then compare the linked Foundry documentation for vm.record and vm.accesses. Implement the record state, cheat-code interception, and SLOAD/SSTORE recording described in the issue; done means the ercx Foundry integration no longer stops at vm.record and the related access data is captured.
Written by the indexing model from the issue text.
Assessment
- Domain
- blockchain
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100