runtimeverification / runtimeverification/kontrol

Errors due to placeholders for unlinked libraries in bytecode

Open
#591 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

engagement enhancement
Dominant language
Python
Stars
122
Forks
16
PR merge metrics
No merged PRs in 30d

Description

When a Solidity library has functions declared external or public (rather than only internal functions), it must be linked by providing the compiler with the address where the library is deployed (see Library Linking in the Solidity documentation). Until it is linked, the bytecode of a contract using the library will contain placeholders of the form __$53aea86b7d70b31448b230b20ae141a537$__ instead of the library address. Trying to execute this bytecode using KEVM leads to two issues:

  1. The definedness constraint added by foundry-prove (here) evaluates to #Bottom, causing the entire initial configuration to simplify to #Bottom. I believe this happens because #parseByteStack is not defined when the string includes non-numerical characters.
  2. foundry-show can fail because it tries to read a numerical byte and gets something that contains a special character instead, like __ or $5 (see runtimeverification/evm-semantics#1895).

To avoid these issues, which are non-trivial for a user to debug, it would be better if we could detect when the bytecode contains placeholders for unlinked libraries and give the user an informative error message.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the definedness constraint in kevm-pyk/src/kevm_pyk/foundry.py around line 863 and inspect how foundry-prove processes bytecode containing Solidity library placeholders. Also trace the foundry-show failure described in runtimeverification/evm-semantics#1895. Done means unlinked-library placeholders are detected and users receive an informative error instead of the current failures.

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
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.