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

Record Solidity/K mapping for input names #747

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

palinatolmach
Copy link
Collaborator

@palinatolmach palinatolmach commented Aug 6, 2024

Partially addresses #710.

As suggested by @ehildenb, this PR generates a new file out/kompiled/input-mapping.json that contains a mapping between a Solidity variable name and its K representation. The file is structured as follows:

    "lib%forge-std%src%interfaces%IERC20": {
        "allowance(address,address)": {
            "VV0_owner_114b9705": "owner",
            "VV1_spender_114b9705": "spender"
        },
        "approve(address,uint256)": {
            "VV0_spender_114b9705": "spender",
            "VV1_amount_114b9705": "amount"
        },
    },

This PR also changes the return value of arg_names from a list of processed input names to a dictionary storing a mapping between the processed (VV0_from_114b9705) and original (from) input names.

This mapping is then used to decode K variable names back to the original ones in the mode/counterexample, which depends on these two PRs in KEVM and pyk:

For our documentation CounterTest example, the model looks like this:

  Model:
    x = 12648430
    block.number = 0
    tx.origin = 10
    msg.sender = 10
    block.timestamp = 0
    inLuck = 1

It can also be useful when parsing precondition NatSpec comments (WIP), and for Simbolik. The newly generated file doesn't occupy too much additional storage: it takes 256 Kb on a relatively big client codebase, where contracts.k takes 2.6 Mb.

@palinatolmach palinatolmach self-assigned this Aug 6, 2024
@palinatolmach palinatolmach marked this pull request as draft August 29, 2024 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant