Following the trailofbits/manticore#909 discussion:
We need to improve
|
def _remove_metadata(self): |
|
""" |
|
Init bytecode contains metadata that needs to be removed |
|
see http://solidity.readthedocs.io/en/v0.4.24/metadata.html#encoding-of-the-metadata-hash-in-the-bytecode |
|
""" |
|
self._init_bytecodes = { |
|
key: re.sub(r"a165627a7a72305820.{64}0029", r"", bytecode) |
|
for (key, bytecode) in self._init_bytecodes.items() |
|
} |
|
|
|
self._runtime_bytecodes = { |
|
key: re.sub(r"a165627a7a72305820.{64}0029", r"", bytecode) |
|
for (key, bytecode) in self._runtime_bytecodes.items() |
|
} |
|
|
To handle newer versions of the metadata encoding, including:
0xa2
0x65 'b' 'z' 'z' 'r' '1' 0x58 0x20 <32 bytes swarm hash>
0x64 's' 'o' 'l' 'c' 0x43 <3 byte version encoding>
0x00 0x32
0xa2
0x64 'i' 'p' 'f' 's' 0x58 0x22 <34 bytes IPFS hash>
0x64 's' 'o' 'l' 'c' 0x43 <3 byte version encoding>
0x00 0x32
We could also handle the parsing of the metatadata, like doing the key-values extraction.
Additionally, we should add a public function allowing external tools to access these functionalities. This would be useful for, at least, Manticore and evm-cfg-builder.
Following the trailofbits/manticore#909 discussion:
We need to improve
crytic-compile/crytic_compile/crytic_compile.py
Lines 942 to 956 in 35370b6
To handle newer versions of the metadata encoding, including:
0.5.150.6.1We could also handle the parsing of the metatadata, like doing the key-values extraction.
Additionally, we should add a public function allowing external tools to access these functionalities. This would be useful for, at least, Manticore and evm-cfg-builder.