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

Use invalid opcode as part of the eWASM magic #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

axic
Copy link
Member

@axic axic commented Aug 14, 2016

Following the discussion: #20 (comment)

@axic
Copy link
Member Author

axic commented Oct 8, 2016

@chriseth since you mentioned the requirement for this, can you please explain why we should have it?

@chriseth
Copy link

chriseth commented Nov 7, 2016

The idea is that multiple versions of evm bytecode can be introduced with limited backwards-compatibility breaks. We can at least be rather sure that no useful existing contract can have the same bytecode (prefix) as an ewasm contract.

@wanderer
Copy link
Member

wanderer commented Nov 7, 2016

We can at least be rather sure that no useful existing contract can have the same bytecode (prefix) as an ewasm contract.

Currently all wasm binaries a prefixed with 0x00, which is stop. Wouldn't that eliminate all useful contracts?

@chriseth
Copy link

chriseth commented Nov 7, 2016

This aims for a general standard to select the proper VM for a given bytecode, without having to add metadata to an account. Since we do not have a VM identifier for EVM1, anything is valid EVM1. In order to avoid cases where an existing contract written for EVM1 is mistaken for eWASM bytecode which would change its semantics, I would propose to take a first byte that cannot be the start of a contract that is in use, and I think 0xef is more likely to fulfil that purpose than 0x00.

@wanderer
Copy link
Member

wanderer commented Nov 7, 2016

right, so if we go that route we probably should drop the wasm magic number 0x00, 0x61, 0x73, 0x6d and replace it with just a single 0xfe

@chriseth
Copy link

chriseth commented Nov 8, 2016

No, I still think that a kind of version number of VM identifier should follow the 0xfe because that allows for upgrading the VM much more easily.

@wanderer
Copy link
Member

wanderer commented Nov 8, 2016

0x00, 0x61, 0x73, 0x6d ("0asm") is wasm identifier, it is followed the version number (0x01). So if we replaced the identifier then we would still have the version number to go off of for future upgrades

@axic
Copy link
Member Author

axic commented Jun 29, 2018

I would argue this is not needed, because wasm cannot be introduced without the client knowing about it, and if it does, it can easily detect the "wasm magic" as a pattern.

@lrettig
Copy link
Member

lrettig commented Jun 29, 2018

In theory it would be nice for a client to be able to implement some, but not all, VMs and to be able to detect which VM a particular piece of contract bytecode targets, so that it can choose to execute that contract or not -- this wouldn't make sense for main chain but it could make sense for a private network, or maybe for a hypothetical world where different shards run different VMs. It would be nice to maintain optionality.

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

Successfully merging this pull request may close these issues.

4 participants