Neo: Script header for multiple virtual machines

Created on 5 Jul 2019  路  12Comments  路  Source: neo-project/neo

I think that we could add a preffix in all scripts for identify the virtual machine to be used (0x00=neovm).
Now we could have only neo-vm, but in the future we could add WebAssembly or other if we thought that it could be usefull, one extra byte could helps a lot of in the future.

discussion

Most helpful comment

Or we can add a complicated header. Including fields such as Magic, Version, Compiler, etc.

All 12 comments

Just an opinion: I think that neovm is an inherent and fundamental part of Neo protocol... regarding webassembly, we could "easily" compile it for neovm in the future. We already did some studies on this, we really think its possible, with some small limits (like floats), although it wont be our direction this year... focus on finishing other things first.

I don't want to add webassembly support yet, only the header for allow it in the future without troubles

I think that use this is a good idea. Today we only run NVM code, but in the future we can have other scripts. This will be a developer decision

~Adding header is good. We can add a 4-bytes header.~

Or we can add a complicated header. Including fields such as Magic, Version, Compiler, etc.

Maybe we can add this header inside the manifest.

I think a complete header in the manifest is better 馃憤

I'm totally in favor of:

Or we can add a complicated header. Including fields such as Magic, Version, Compiler, etc. @erikzhang

First bytes of nvm could indicate the Magic and Version (nvm2 and nvm3), perhaps the compiled language devpack (C#/Python/etc) and some more specific devpack versioning.
We could do that in, perhaps, 4 bytes.
1 byte magic
1 byte version
2 bytes language + compiler/devpack version (1 nibble gives 16 languages, + 2k versions)

It may not be enough for languages and devpacks, so in this case, 8 bytes would be better.
1 byte magic
1 byte version
2 bytes language (ASCII char 'py', 'c#', or 'cs', 'js', etc)
4 bytes compiler + devpack identification (a lot).

We need 4 or 8 bytes for magic.

Perfect. I saw now on the PR, it's good int32("NEF3") magic.

Version will be 0x03 or 0x01 ? int32?

I noticed a Version object on PR (with 4x int32).
Which version is this? Neo (core) version? NeoVM version? Perhaps both?
But since every Neo (core) release carries a specific NeoVM version, it's fine to just use Neo (core) version I guess.

Or is it Compiler + Devpack version? hahaha too many versions... perhaps it's compiler related this, right? It would be good to have some minimal protocol version here, to differentiate between Neo2 and Neo3, and perhaps other affiliated Neo protocols.

@igormcoelho I think we need the compiler version too.
- We need core because of the syscalls versioning;
- We need vm because it is how the script is run;
- We need the compiler because it generated the opcodes used by the vm

What if we have 4 bytes for each?

EDIT:
Erik is right. I think that we just need the manifest version. Everything else is added there. What do you guys think?

Was this page helpful?
0 / 5 - 0 ratings