8000 Versioning of protocol contracts · Issue #1135 · autonity/autonity · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Versioning of protocol contracts #1135

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

Open
lorenzo-dev1 opened this issue Jan 24, 2025 · 6 comments
Open

Versioning of protocol contracts #1135

lorenzo-dev1 opened this issue Jan 24, 2025 · 6 comments
Labels
triage Needs prioritisation and/or scheduling type:feature New feature

Comments

@lorenzo-dev1
Copy link
Contributor

Each protocol contract should have a version, so that we can track upgrades at chain runtime.

The tricky thing is how to manage the increment of the version number on upgrade. Some possibilities are:

  • The version number gets automatically increased by the upgraded contract in the constructor
  • the UpgradeManager contract manages all versioning by itself
  • we do 2-step process:
    1. contract gets upgraded
    2. Operator calls a incrementVersion function on the upgraded contract
@lorenzo-dev1 lorenzo-dev1 added triage Needs prioritisation and/or scheduling type:feature New feature labels Jan 24, 2025
@aiman
Copy link
Contributor
aiman commented Jan 24, 2025

Individual protocol contract versioning is highly desirable from the side of downstream tools and interfaces, which are developed against a specific ABI of a protocol contract. If the contract ABI changes for a protocol contract, or the even if the behaviour changes without a change to the ABI, it can break downstream tools and interfaces that provide strong compatibility guarantees for their users. Examples of downstream tools and interfaces would be Autonity CLI and Autonity Python SDK.

In addition to individual protocol contract versions, it would be desirable to be able to check compatibility against the entire protocol in a single check, rather than have to enumerate all contracts, and then check their version one by one.

Conceptually, if a single protocol contract changes, it changes the Autonity Protocol as a whole. So would it make sense for the "version" of the Autonity Protocol as a whole should increase at the same time as the upgraded protocol contract?

In this way, if we are connecting to an RPC node, we can check if the version of all protocol contracts on the chain is what we expect, and if not, then we can raise an error that the chain has an unexpected/unsupported Autonity Protocol version.

@aiman
Copy link
Contributor
aiman commented Jan 24, 2025 8000

Note that autonity.py is checking that the value of web3_clientVersion (e.g. Autonity/v1.0.2-alpha/linux-amd64/go1.21.13) matched what is expected, but this is not enough to ensure protocol compatibility in the case of protocol contract upgrade. So it would be good if we can do a similar check for the protocol as a whole, or would it make sense to reflect the Autonity Protocol version in this version string?

@cmjc
Copy link
Contributor
cmjc commented Jan 24, 2025

Conceptually, if a single protocol contract changes, it changes the Autonity Protocol as a whole. So would it make sense for the "version" of the Autonity Protocol as a whole should increase at the same time as the upgraded protocol contract?

Agree.

@yazzaoui
Copy link
Collaborator

Yes, that makes sense. Ideally, the upgrade manager contract would handle versioning and expose a global protocol contracts version. However, I’d argue that some upgrades are entirely transparent to users and are implemented solely for internal improvements.

Would it make sense to adopt a simple double-digit versioning scheme like "X.Y," where X represents a compatibility-breaking change and Y signifies a minor update?

To support this, we could update the upgrade method in the upgrade manager contract to include an additional flag indicating whether the update is minor.

@aiman
Copy link
Contributor
aiman commented Jan 27, 2025

Would it make sense to adopt a simple double-digit versioning scheme like "X.Y," where X represents a compatibility-breaking change and Y signifies a minor update?

It would make sense to use a versioning scheme that distinguishes between a breaking upgrade and a fully backward-compatible upgrade.

However I am wondering, instead of a custom versioning scheme, if it's better to just adopt the well-known three-digit semantic versioning scheme, as it's only one more digit, instead of a custom version scheme.

@Jason-Zhangxin-Chen
Copy link
Contributor
Jason-Zhangxin-Chen commented Mar 5, 2025

Without changing the upgrade manager, we can just manage a const version field out from the state of the contract, thus that the version is compiled into the binary, once the contract is upgraded, the version will be accessible by calling a pure function. In this way, we just need to upgrade the contract that we officially released, there is no state management are required since the version is in the bytes code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Needs prioritisation and/or scheduling type:feature New feature
Projects
None yet
Development

No branches or pull requests

5 participants
0