Consensys / sol-dbg

Solidity source debugger built around EthereumJS
Apache License 2.0
22 stars 3 forks source link

We should try and match runtime code to compile artifacts without metadata hash as well #13

Closed cd1m0 closed 2 days ago

cd1m0 commented 1 year ago

Sometimes we get contracts without compiler metadata hash. In those cases we can still try to match the deployed bytecode to the artifact with the following algorithm:

  1. Select only artifacts with deployed bytecode length equal to the runtime bytecode length
  2. Of those pick the artifact that: 2.1 Matches the runtime bytecode in the most location 2.2 Has all 0-s in the mismatching locations

For constructor bytecodes, we can follow the same algorithm, except in step 1 we only pick bytecodes with lengths <= of the runtime bytecode.

cd1m0 commented 1 year ago

A twist in this is that we need the compiler version for each artifact even before we get to matching runtime bytecode to artifacts. We could try to infer this from the AST trees, with a basic walk if all else fails.

cd1m0 commented 2 days ago

Fixed.