Skip to content

Commit

Permalink
Trying to fix issues regarding --code-a/--code-b inputs
Browse files Browse the repository at this point in the history
Better documentation, better error printing

Related to #581
  • Loading branch information
msooseth committed Oct 10, 2024
1 parent 7a96106 commit da57548
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions doc/src/equivalence-checking-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,19 @@ consume the same amount of gas and have widely different EVM bytecodes. Yet for
an outside observer, they behave the same. Notice that hevm didn't simply fuzz
the contract and within a given out of time it didn't find a counterexample.
Instead, it _proved_ the two equivalent from an outside observer perspective.

## Dealing with Already Compiled Contracts

If the contracts have already been compiled into a hex string, you can paste
them into files `a.txt` and `b.txt` and compare them via:

```shell
$ hevm equivalence --code-a "$(<a.txt)" --code-b "$(<b.txt)"
```

You can also copy-paste the contents of the hex strings directly into the
command line, although this can become cumbersome:

```shell
$ hevm equivalence --code-a "6080604052348015600e575f80fd5b50600436106026575f3560e01c8063881fc77c14602a575b5f80fd5b60306032565b005b5f600190506002811460455760446048565b5b50565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffdfea26469706673582212208c57ae04774d9ebae7d1d11f9d5e730075068bc7988d4c83c6fed85b7f062e7b64736f6c634300081a0033" --code-b "6080604052348015600e575f80fd5b50600436106030575f3560e01c806385c2fc7114603457806386ae330914603c575b5f80fd5b603a6044565b005b60426055565b005b60025f541460535760526066565b5b565b60035f541460645760636066565b5b565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffdfea2646970667358221220bd2f8a1ba281308f845e212d2b5eceab85e029909fa2409cdca7ede039bae26564736f6c634300081a0033"
```
2 changes: 1 addition & 1 deletion src/EVM/Format.hs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ hexByteString :: String -> ByteString -> ByteString
hexByteString msg bs =
case BS16.decodeBase16Untyped bs of
Right x -> x
_ -> internalError $ "invalid hex bytestring for " ++ msg
_ -> internalError $ "invalid hex bytestring for '" ++ msg ++ "'. Bytestring provided: '" ++ show bs ++ "'"

hexText :: Text -> ByteString
hexText t =
Expand Down

0 comments on commit da57548

Please sign in to comment.