vyperlang / vyper

Pythonic Smart Contract Language for the EVM
https://vyperlang.org
Other
4.87k stars 800 forks source link

VIP: Add semver (semantic versioning) in pragma checking #1993

Open arjunaskykok opened 4 years ago

arjunaskykok commented 4 years ago

Simple Summary

Currently we can add pragma in Vyper file, for example:

# @version 0.1.0b13

It means Vyper compiler version 0.2.0 will fail to compile this Vyper file. But this is too primitive. We need to add semver capability. It needs to support >=, ^, <, ==, for example:

# @version ==0.1.0b13

This pragma line means only Vyper compiler version 0.1.0b13 can compile this Vyper file successfully.

Motivation

Solidity pragma supports semver capability.

Specification

Semver specification is here: https://docs.npmjs.com/misc/semver

Backwards Compatibility

It's safe.

Dependencies

References

https://github.com/python-semver/python-semver https://vyper.readthedocs.io/en/latest/structure-of-a-contract.html https://solidity.readthedocs.io/en/v0.6.8/layout-of-source-files.html

Copyright

Copyright and related rights waived via CC0

arjunaskykok commented 4 years ago

Is it okay to use third party package (python-semver) to implement this feature?

fubuloubu commented 4 years ago

Yeah, I think the semver package has no external dependencies, so it's safe to use

fubuloubu commented 4 years ago

Use this package for npm semver compatibility: https://github.com/rbarrois/python-semanticversion

fubuloubu commented 4 years ago

Note: Move to contract-level natspec

fubuloubu commented 4 years ago

Note: Mostly fixed in https://github.com/vyperlang/vyper/pull/1995

Still need to discuss move to contract-level natpsec for easier parsing and sharing