-
Notifications
You must be signed in to change notification settings - Fork 791
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
What does the VM do to code before putContractCode is called #289
Comments
I may have answered my own question. Looks like I need the 'runtime bytecode' section instead of the 'bytecode' section. Would still love to hear what the differences are conceptually id anyone has any insight. |
The other thing I had to do to get this to work was to uncomment the following line from the stageManager.putAccount function. Not sure why it was commented out. self.trie.put(addressHex, account.serialize(), cb) |
For reference for everyone who wants to dig into this: the line mentioned above is still commented out, have no first-sight context though. |
Another update: line in |
@skilesare Just as an explanation here: the original I think this issue can be closed? @holgerd77 |
Will close here as suggested by @jochem-brouwer, thanks for this detailed explanation. |
I used an example I found(#128) to deploy code using vm.runTX
The code is super simple. Solidity:
}
Remix outputs this as the code:
I added a console.log to the saveCode method of the runCall function to output exactly what was being written to the chain:
It outputs the following code:
0x606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063257c8c89146044575b600080fd5b3415604e57600080fd5b6054606a565b6040518082815260200191505060405180910390f35b60006301e133809050905600a165627a7a723058202e0505c5235858e9b30b642de84fb21c102bdd86b3f7dfbdda1a1f80fb90fd900029
It looks like 23 bytes "3415600e57600080fd5b60a28061001c6000396000f3006060604052" are taken out of the code when it is written to the tree.
The reason I need this I'm trying to sideload some code and storage into the evm without having to run the transactions.
I tried directly loading the original code with
When I do this and then run the code the return ends up being the original code!
If I switch out to the code with the missing 23 bytes it works like a champ. What am I missing about these 23 bytes? Are they the opcode that saves the code to the blockchain? If so, how do I remove them when I'm trying to move code from remix? Will they always be the same so I can just find replace?
What am I missing?
The text was updated successfully, but these errors were encountered: