Repository navigation
Improve metadata handling #59
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
Following the trailofbits/manticore#909 discussion:
We need to improve
crytic-compile/crytic_compile/crytic_compile.py
Lines 942 to 956 in 35370b6
| 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Activity
0xalpharush commentedon Oct 27, 2022
Fwiw in solc 0.8.18, there will be an option to remove the metadata with "appendCBOR": false https://docs.soliditylang.org/en/develop/using-the-compiler.html#input-description