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

Versioning in contracts #121

Open
axic opened this issue Jul 31, 2018 · 12 comments
Open

Versioning in contracts #121

axic opened this issue Jul 31, 2018 · 12 comments

Comments

@axic
Copy link
Member

axic commented Jul 31, 2018

As we are making changes to the API it would make sense thinking about how to version imports in contracts.

Immediately an option comes to mind where either the namespace or the function name is version, for example following GCC's <symbol>@<version> scheme.

If we version functions does it mean that multiple versions of the functions are accepted in a contract? I would say that is a bad idea.

If we version the namespace does it mean that multiple versions of the namespaces are accepted in a contract? Again, I think we shouldn't do that.

I would propose one of the following two options:

  1. Version the namespace (as ethereum@3 - the current revision), but disallow multiple versions.
  2. Have a custom section with the version in it.

Option 2) means that the Sentinel contract would need to verify the contract based on the value in the custom section.

@axic axic added this to Proposed in Revision 5 Aug 16, 2018
@chfast chfast self-assigned this Aug 16, 2018
@jakelang
Copy link
Member

I think that simply versioning the "ethereum" import interface would make the best sense.
Furthermore, a contract should only be able to use one version of the interface.

If we have a custom section indicating the version, then Sentinel must still validate that the imports are correct (as has been mentioned already). A contract can specify an erroneous version number in the custom section and import from a different version. If Sentinel correctly catches this, it should either reject contract deployment or amend the version number (assuming all the imports are from one version). However, this is unnecessarily complicated.

It would make much more sense for Sentinel to just verify that all contract imports are from one version, implicitly assigning a contract its version number by that of the interface it imports.
In Hera, we can then simply support multiple versions of the interface by using multiple namespaces (naming scheme TBD), and throw an exception if a certain version is unsupported.
We can also choose to either rely on Sentinel catching multi-version imports at deployment time, or additionally detect this and throw an exception at runtime.

@jakelang
Copy link
Member

@axic we need another decisions call or something, otherwise these things will stay on the back burner forever.

@lrettig
Copy link
Member

lrettig commented Sep 24, 2018

What happens if a contract that implements e.g. v4 calls into one implementing e.g. v3? This should be fine, right? I do think there's a more interesting question here for package managers--what happens if you try to import a contract that implements an earlier version?

@jakelang
Copy link
Member

@lrettig good question.
I think it would make sense to just prohibit this altogether (checked at runtime) because allowing cross-revision calls means that the VM has to implement each revision of the EEI, and also opens up crazy vulnerability surface if we eventually have contracts that can access deprecated or unsafe host functions by calling a contract on an older revision.
We could also go more draconian and just automatically fail all calls to contracts with an older revision tag than the latest, making them effectively "dead" contracts.
Note that this solution is messy as hell and only belongs on the testnet.

@lrettig
Copy link
Member

lrettig commented Sep 25, 2018

Like you said, we need another decision call to discuss this stuff :)

@axic axic unassigned chfast Nov 27, 2018
@axic
Copy link
Member Author

axic commented Nov 27, 2018

I think for now we should just go for: have a version number in the namespace. A contract can import a single version of the namespace, i.e. all imports must share the same version number.

Reasoning: a custom section would make this unnecessarily complicated and we're trying to use custom sections for other purposes already.

This probably will get very complicated with linking. Lets discuss it when we get there.

@jakelang
Copy link
Member

@axic I think versioning in the namespace should be ok.
This does really complicate linking semantics, however. A custom section can have multiple subsections, though, which allows us to separate the deployer data and the EEI namespace. And it is simpler, IMO, for a VM to just use the correct version of the EEI upon reading the custom section.

@axic
Copy link
Member Author

axic commented Nov 27, 2018

My other uses for custom sections are not that much ewasm specific and would feel weird to have one very complicated ewasm-specific custom section with all these different features smacked into it.

@lrettig
Copy link
Member

lrettig commented Jan 17, 2019

@axic
Copy link
Member Author

axic commented Jan 17, 2019

This is a different kind of versioning thread. The relevant one for that is ethereum/EIPs#154

@lrettig
Copy link
Member

lrettig commented Jan 17, 2019

Also #17 and #153. Thanks.

@axic
Copy link
Member Author

axic commented Jun 12, 2019

  1. Have a custom section with the version in it.

This proposal could be extended to be a platform metadata section giving opportunity for storing more details.

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

No branches or pull requests

4 participants