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

Space chars change compiled bytecode #73

Closed
davidyuk opened this issue Dec 17, 2022 · 3 comments · Fixed by #78
Closed

Space chars change compiled bytecode #73

davidyuk opened this issue Dec 17, 2022 · 3 comments · Fixed by #78

Comments

@davidyuk
Copy link
Member

I've noticed that if I add or remove space chars, the compiled bytecode insignificantly changes. From my perspective, these space chars don't change the contract semantics so the bytecode should be the same. Does it happen because the bytecode contains the hash of the source code? Can it be used somehow?

The current behavior looks odd because if I add space chars to an included file then the bytecode remains the same.

@dincho
Copy link
Member

dincho commented Dec 19, 2022

The commonly known as bytecode piece of data encoded as contract bytearray (cb_...) is actually a serialized contract object that indeed includes the source hash together with the actual bytecode and some other properties.

@hanssv
Copy link
Member

hanssv commented Mar 22, 2023

Yes, I think this is a documentation issue - the result of calling the compiler is a complete object that can go into the ContractCreateTx. It is a structured object containing among other things the actual contract byte code, but also the hash of the source code, the compiler version and whether or not the contract is payable...

@davidyuk
Copy link
Member Author

davidyuk commented Jul 3, 2023

Got it. But shouldn't included files be hashed as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants