mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-22 22:44:47 +03:00
[RFC] Minor edits (just form, no change of substance).
This commit is contained in:
parent
8d26cc5676
commit
b37de11116
@ -11,27 +11,27 @@ IMPLEMENTED
|
||||
## Summary
|
||||
|
||||
This proposal aims to improve the import management system in Leo programs to
|
||||
make program environment more reproducible, predictable and compatible. To achieve
|
||||
that we suggest few changes to Leo CLI and Manifest:
|
||||
make the program environment more reproducible, predictable and compatible. To achieve
|
||||
that we suggest a few changes to the Leo CLI and Manifest:
|
||||
|
||||
- add a "dependencies" section to Leo Manifest and add a command to pull those dependencies;
|
||||
- add a "dependencies" section to the Leo Manifest and add a command to pull those dependencies;
|
||||
- allow custom names for imports to manually resolve name conflicts;
|
||||
- add "curve" and "proving system" sections to the Manifest;
|
||||
- add "include" and "exclude" parameters for "proving system" and "curve";
|
||||
- add a lock file which would store imported dependencies and their relations;
|
||||
- add a lock file to store imported dependencies and their relations;
|
||||
|
||||
## Motivation
|
||||
|
||||
The current design of imports does not provide any guarantees on what's stored
|
||||
in program imports and published with the program to Aleo Package Manager.
|
||||
When a dependency is "added," it is stored inside imports folder, and it is possible
|
||||
When a dependency is "added," it is stored inside the imports folder, and it is possible
|
||||
to manually edit and/or add packages in this folder.
|
||||
|
||||
Also, imports are stored under the package name which makes it impossible to import
|
||||
Also, imports are stored under the package name, which makes it impossible to import
|
||||
two different packages with the same name.
|
||||
|
||||
Another important detail in the scope of this proposal is that in future Leo
|
||||
programs will have the ability to be run with different proving systems
|
||||
Another important detail in the scope of this proposal is that, in the future, Leo
|
||||
programs will have the ability to run with different proving systems
|
||||
and curves, possibly creating incompatibility between programs written
|
||||
for different proving systems or curves. To make a foundation for these features,
|
||||
imports need to be managed with include/exclude lists for allowed (compatible)
|
||||
@ -41,12 +41,12 @@ proving systems and curves.
|
||||
|
||||
### Leo Manifest - target section
|
||||
|
||||
To lay the foundation for the future of the Leo ecosystem and start integrating
|
||||
information about programs compatibility we suggest adding two new fields to
|
||||
To lay the foundation for the future of the Leo ecosystem and to start integrating
|
||||
information about programs compatibility, we suggest adding two new fields to
|
||||
the new `[target]` section of the Leo Manifest: `proving_system` and `curve`.
|
||||
|
||||
Currently, the Leo compiler only supports `Groth16` for the proving system and `Bls12_377`
|
||||
for the curve, they are meant to be default values in Leo Manifest.
|
||||
for the curve, which are meant to be default values in Leo Manifest.
|
||||
|
||||
```toml
|
||||
[project]
|
||||
@ -60,7 +60,7 @@ curve = "Bls12_377"
|
||||
proving_system = "Groth16"
|
||||
```
|
||||
|
||||
These fields are meant to be used to determine whether imported program is
|
||||
These fields are meant to be used to determine whether the imported program is
|
||||
compatible to the original when support for different curves and proving systems
|
||||
is added.
|
||||
|
||||
@ -81,9 +81,9 @@ version = "1.0"
|
||||
|
||||
#### Parameters description
|
||||
|
||||
`name` field sets the name of the dependency in Leo code. That way we allow
|
||||
The `name` field sets the name of the dependency in Leo code. That way we allow
|
||||
developer to resolve collisions in import names manually. So, for example,
|
||||
if a developer is adding `howard/silly-sudoku` package to his program, he
|
||||
if a developer is adding the `howard/silly-sudoku` package to his program, he
|
||||
might define its in-code name as `sudoku` and import it with that name:
|
||||
|
||||
```ts
|
||||
@ -96,7 +96,7 @@ command, so these fields are already understood by the Leo developers.
|
||||
|
||||
### Leo CLI
|
||||
|
||||
To support updated Manifest new command should be added to Leo CLI.
|
||||
To support updating the Manifest, a new command should be added to Leo CLI.
|
||||
|
||||
```bash
|
||||
# pull imports
|
||||
@ -105,16 +105,16 @@ leo fetch
|
||||
|
||||
### Imports Restructurization
|
||||
|
||||
One of the goals of proposed changes is to allow importing packages with the
|
||||
One of the goals of the proposed changes is to allow importing packages with the
|
||||
same name but different authors. This has to be solved not only on the
|
||||
language level but also on the level of storing program imports.
|
||||
|
||||
We suggest using set of all 3 possible program identifiers for import
|
||||
We suggest using the set of all 3 possible program identifiers for the import
|
||||
folder name: `author-package@version`. Later it can be extended to
|
||||
include hash for version, but having the inital set already solves name
|
||||
include a hash for the version, but having the inital set already solves name
|
||||
collisions.
|
||||
|
||||
So, updated imports would look like:
|
||||
So, the updated imports would look like:
|
||||
|
||||
```
|
||||
leo-program
|
||||
@ -131,8 +131,8 @@ leo-program
|
||||
└── main.leo
|
||||
```
|
||||
|
||||
This change would also affect the way imports are being processed on the ASG
|
||||
level, and we'd need to add an imports map as an argument to the Leo compiler.
|
||||
This change also affects the way imports are being processed on the ASG
|
||||
level, and we need to add an imports map as an argument to the Leo compiler.
|
||||
The Leo Manifest's dependencies sections needs to be parsed and passed as
|
||||
a hashmap to the compiler:
|
||||
|
||||
@ -143,12 +143,12 @@ second-program => author2-program2@1.0.4
|
||||
|
||||
### Leo.lock
|
||||
|
||||
For imports map to be generated and read by the Leo binary and then by the Leo compiler,
|
||||
a lock file needs to be created. Lock file should be generated by the `leo fetch` command,
|
||||
For the imports map to be generated and read by the Leo binary and then by the Leo compiler,
|
||||
a lock file needs to be created. The lock file should be generated by the `leo fetch` command,
|
||||
which will pull the dependencies, process their manifests, and put the required information
|
||||
to the file in the root directory of the program called `Leo.lock`.
|
||||
|
||||
Suggested structure of this file is similar to the Cargo.lock file:
|
||||
The suggested structure of this file is similar to the Cargo.lock file:
|
||||
|
||||
```
|
||||
[[package]]
|
||||
@ -176,7 +176,7 @@ field `dependencies`.
|
||||
The format described here allows the Leo binary to form an imports map which can be
|
||||
passed to the compiler.
|
||||
|
||||
It is important to note that Leo.lock file is created only when a package has dependencies.
|
||||
It is important to note that the Leo.lock file is created only when a package has dependencies.
|
||||
For programs with no dependencies, a lock file is not required and not created.
|
||||
|
||||
### Recursive Dependencies
|
||||
@ -196,17 +196,17 @@ This change might require the update of already published programs on Aleo PM du
|
||||
Leo Manifest change. However it is possible to implement it in a backward-compatible
|
||||
way.
|
||||
|
||||
It also introduces the danger of having recursive dependencies, this problem is addressed in the Design section above.
|
||||
It also introduces the danger of having recursive dependencies, but this problem is addressed in the Design section above.
|
||||
|
||||
## Effect on Ecosystem
|
||||
|
||||
Proposed improvement provides safety inside Leo programs and should not affect
|
||||
ecosystem except for the tools which use Leo directly (such as Aleo Studio).
|
||||
The proposed improvement provides safety inside Leo programs and should not affect
|
||||
the ecosystem except for the tools which use Leo directly (such as Aleo Studio).
|
||||
|
||||
It is possible that some of the proposed features will open new features on Aleo PM.
|
||||
|
||||
## Alternatives
|
||||
|
||||
Another approach to the stated cases is to keep everything as we have now but change
|
||||
the way programs are imported and stored and make names unique. Also, current
|
||||
the way programs are imported and stored and make names unique. Also, the current
|
||||
implementation provides some guarantees on import stablitity and consistency.
|
||||
|
Loading…
Reference in New Issue
Block a user