Closed xermicus closed 1 month ago
I don't really know what it means that the length is encoded into bytecode hash. Like how to you tell for example REMIX what the "bytecode hash" is? Is it part of the json output on stdout? If yes it would still need some changes to REMIX. If it is just prepended to the bytecode itself REMIX can continue to just pass it through.
Stemming from an internal discussion: Prefixing the length seems to be the most straight forward thing to do. The length just has to (implicitly) become part of the bytecode. Which keeps the code just an opaque stream of bytes. Mitigating the risk of mis-calculated bytecode hashes.
That would also need some changes in pallet_revive to strip the length from the bytecode if we make it part of the bytecode itself.
We ultimately decided to have it as metadata in the container.
We need to define a way to encode the length of the bytecode. Unlike with EVM, we need to know the offset of the constructor arguments for contract deployments.
A possible solution would be to just pre-pend the bytecode length to the bytecode itself. A wrinkle I can see with this is that makes it easy to mis-calculate the bytecode hash. On ZKSync the length is encoded into the bytecode hash.