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

Self modifying code? #129

Closed
fulldecent opened this issue Feb 12, 2018 · 5 comments
Closed

Self modifying code? #129

fulldecent opened this issue Feb 12, 2018 · 5 comments

Comments

@fulldecent
Copy link
Contributor

Issues.md states:

Currently in EVM, the *CODECOPY opcodes allow regarding program pieces as data, meaning that a translation back must always be maintained, because in theory a program can modify itself while executing.

The machine state (including memory) is defined in "9.4.1. Machine State" and the execution environment (including program code) is "9.3. Execution Environment."

CODECOPY is defined in the OPCODES table and brings code from the latter to the former.

How are you seeing that a program can modify itself?

@ehildenb
Copy link
Member

programs can't modify themselves, but the point still remains that a translation back to bytecode representation must be maintained for EVM execution (which makes reasoning about EVM code more difficult).

@fulldecent
Copy link
Contributor Author

Understood, thank you.

Perhaps that line and the following can be improved. Such can be the scope of this issue.

While self-modifying code is nice and powerful in principle, we are not aware of any programming languages for the blockchain that encourage or even allow that.

@fulldecent
Copy link
Contributor Author

Also, yes, difficult to reason.

FYI, here's is a (limited) Solidity decompiler I am writing. It runs on the blockchain.

ethereum/EIPs#165 (comment)

Thought you might get a laugh out of that.

@dwightguth
Copy link
Collaborator

Another point of view to consider is that while a contract cannot modify itself, it can construct an arbitrary fragment of code, CREATE it as a new contract, and then DELEGATECALL the contract it created to effectively execute arbitrary code. So I'm honestly not sure it's correct to claim that evm doesn't support self modifying code.

@fulldecent
Copy link
Contributor Author

Fair enough, can execute arbitrary code. I suggested a slightly different wording here.

Fun stuff to look at for sure!

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

No branches or pull requests

3 participants