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

Smart Contract Interpreter versionning #895

Merged
merged 7 commits into from
Mar 14, 2023

Conversation

bchamagne
Copy link
Member

@bchamagne bchamagne commented Feb 7, 2023

Description

Introduce smart contract versioning.
The user will be able to choose it's version by setting a @version attribute at the top of her/his code. No @version attributes is equivalent to 0.0.1.
Part of #894

There are 2 versions available:

  1. legacy / functional lang (= 0.0.1)
  2. imperative lang (= 1.0.0)

I move current language into a version0 folder.
The imperative lang is not implemented in this PR but I prepared the ground in a version1 interpreter.
Some files has been renamed to match their modules names.

TODO

  • Unplug the worker from version0 and plug it to the dispatcher (Archethic.Contracts.Interpreter) instead.
  • Unplug the contracts from version0 and plug it to the dispatcher instead.
  • Should I restrict versions to only those existing?

Examples

@version "1.0.0" 
condition ....
actions ...
@version "0.0.1"
condition ...
actions ...
condition ...
actions ...

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Unit tests ✔️
Legacy smart contract ✔️

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@bchamagne bchamagne marked this pull request as draft February 7, 2023 10:58
@bchamagne bchamagne marked this pull request as ready for review February 7, 2023 15:45
@samuelmanzanera samuelmanzanera linked an issue Feb 8, 2023 that may be closed by this pull request
4 tasks
@samuelmanzanera
Copy link
Member

samuelmanzanera commented Feb 22, 2023

Is this PR still relevant regarding #894 ?

@bchamagne
Copy link
Member Author

Is this PR still relevant regarding #894 ?

yes, this is step 1/2 (step 2 is #903).
This one prepared the ground to have 2 different interpreters

@samuelmanzanera
Copy link
Member

I wonder about the granularity of the versions.
The last digit might not be useful, as the bug fixes will be patched along the way, and the contract code might not be dependent on the bug fixes.
For the second one, I think the enhancements of the interpreter should be retrocompatible within a major version.
But the one is useful because it informs which major version of the interpreter is used and will simplify the writing of the smart contract code.

bchamagne and others added 5 commits March 9, 2023 09:17
…ation#903)

* Add modules for library and transaction statements
* Enable loops
* Improve testing
* Improve some error messages
* Enable ranges
* Handle map[field] syntax
* Allow code blocks in the condition interpreter
* Support several scopes
* Fix double execution of contract
@samuelmanzanera samuelmanzanera removed the request for review from netboz March 10, 2023 14:02
@bchamagne
Copy link
Member Author

@Neylix Neylix merged commit 9c935db into archethic-foundation:develop Mar 14, 2023
@samuelmanzanera samuelmanzanera added the feature New feature request label May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
Status: Done 🍻
Development

Successfully merging this pull request may close these issues.

Smart Contract Language: imperative over functional
3 participants