-
Notifications
You must be signed in to change notification settings - Fork 21
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 v1 (mutable bindings/modules/for loop) #903
Smart Contract Interpreter v1 (mutable bindings/modules/for loop) #903
Conversation
very complex, |
Here's the code proposition to handle the faucet via a smart contract:
Works fine. FYI, here is the same contract with interpreter version 0
|
I will wait for feedback before working on documentation |
lib/archethic/contracts/interpreter/version1/condition_interpreter.ex
Outdated
Show resolved
Hide resolved
test/archethic/contracts/interpreter/version1/action_interpreter_test.exs
Outdated
Show resolved
Hide resolved
Except few comments, really great work 🚀 |
FYI, there's a way to replace
Since they are in a different context, here the 2 The issue with this is that the context is an |
No worry because the Process directory is by process as long as the execution of a contract is isolated into a single one, no risk of collision. |
lib/archethic/contracts/interpreter/version1/common_interpreter.ex
Outdated
Show resolved
Hide resolved
lib/archethic/contracts/interpreter/version1/library/common/list.ex
Outdated
Show resolved
Hide resolved
lib/archethic/contracts/interpreter/version1/library/common/chain.ex
Outdated
Show resolved
Hide resolved
lib/archethic/contracts/interpreter/version1/library/contract.ex
Outdated
Show resolved
Hide resolved
0e26584
to
3d059cc
Compare
end | ||
|
||
{new_node, acc} | ||
# new_node = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disabled Contract.get_calls()
from the condition
blocks for now, because it'd require a quorum and not a read from DB. (because the condition inherit
validator is not the worker).
…block in the conditionInterpreter
322a0a3
to
7a7a2a8
Compare
…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
* 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
Hello @bchamagne , @Neylix , @samuelmanzanera , Bravo for the work on the interpreted language ! Before i say anything , you can take into account i'm not familiar with writting language interpreter with elixir so take what is coming considering i'm a noobie here.
Here an exemple to illustrate my words.
Also the trigger could be a decorator of an action like this " Bonne journée :) |
Hey @Bantarus , thank you for your feedback, I appreciate. The language use an intermediary AST which is elixir's. This helped us tremendously because we did not have to create an entire interpreter. Therefore we are limitated by what is considered "valid elixir": we cannot change the I think the named What you propose is very similar to something I drafted a few months ago:
Anyway, it's too big of a breaking change for now. Maybe in a later version? |
Hello. Thanks for the contribution.
As mentioned @bchamagne, we are using Elixir to build the interpreted language, hence it's a subset of the Elixir language. But even without it, we designed the language to be as a domain specific language, close to a specification, while allowing developers to leverage a programmatic approach. In that direction, the language is then designed to be easy to read and understand for non-developers if needed.
The purpose of this language is not to be a generic programming language but a dedicated one for the Archethic's interpreter. |
Hello @samuelmanzanera , Thanks you for the detailed answer. Keep up the incredible work ! |
Description
I am creating this PR on top of branch #895 .
Here are the features of this new interpreter:
I reused as much of the previous interpreter as possible. You'll often see Version0 calls from within Version1.
This PR is so big, the diff will not help you. To review, just open the /archethic/contracts/interpreter folder and read everything from there (you can skip Version0 folder, it is the previous interpreter)
Fixes #894
TODO
Type of change
How Has This Been Tested?
Many unit tests were added.
Tested manually with the transactionBuilder
Checklist: