Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve metadata handling #59

Open
montyly opened this issue Jan 24, 2020 · 1 comment
Open

Improve metadata handling #59

montyly opened this issue Jan 24, 2020 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@montyly
Copy link
Member

montyly commented Jan 24, 2020

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.

@montyly montyly added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jan 24, 2020
@0xalpharush
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants