Giter Site home page Giter Site logo

provablehq / sdk Goto Github PK

View Code? Open in Web Editor NEW
573.0 52.0 458.0 169.22 MB

A Software Development Kit (SDK) for Zero-Knowledge Transactions

Home Page: https://provable.tools

License: GNU General Public License v3.0

Rust 26.12% Shell 0.22% JavaScript 24.89% HTML 16.46% CSS 3.94% TypeScript 28.37%
aleo blockchain zero-knowledge zksnarks sdk

sdk's Introduction

Aleo SDK

Website

Zero Knowledge Web App SDK

The Aleo SDK provides tools for building zero knowledge applications. It consists of several TypeScript & JavaScript libraries which provide the following functionality:

  1. Aleo account management
  2. Web-based program execution and deployment
  3. Aleo credit transfers
  4. Management of program state and data
  5. Communication with the Aleo network

All of this functionality is demonstrated on Aleo.tools.

The Aleo SDK is divided into three Typescript/Javascript packages

1. Aleo SDK - Build Zero Knowledge Web Apps

Aleo SDK

The official Aleo SDK providing Javascript/Typescript tools for creating zero knowledge app.

⚡ Build your own app

Start here with the Aleo SDK Readme to get started building your first zero knowledge web app.

Source: sdk/sdk

2. Create-Aleo-App - Zero Knowledge Web App Examples

Create Aleo App

Create-aleo-app provides zero-knowledge web app examples in common web frameworks such as React. Developers looking to start with working examples should start here.

⚡ Build your own app

You can start with a template by running

npm create aleo-app@latest

3. Aleo-Wasm - Zero Knowledge Algorithms in JavaScript + WebAssembly

Create Aleo App Create Aleo App Aleo-Wasm

Aleo Wasm is a Rust crate which compiles Aleo code responsible for creating and executing zero knowledge programs into WebAssembly.

When compiled with wasm-pack JavaScript bindings are generated for the WebAssembly allowing Aleo zero knowledge programs to be used in the browser and NodeJS. This package is available on NPM (linked above). The Aleo WASM Readme provides instructions for compiling this crate and using it in web projects for those interested in building from source.

❗ Currently program execution is only available in web Browsers. However account, program and data management within NodeJS is functional.

Source: sdk/wasm

📚 Documentation

API Documentation, tutorials for the Aleo SDK, and documentation on how to build Leo and Aleo Instructions programs can be found on the Aleo Developer Docs page.

The SDK Readme provides concepts core to executing zero knowledge programs in the web and several detailed examples of how to use the SDK to build web apps using Aleo.

The Aleo Wasm Readme provides instructions for compiling the Aleo Wasm crate and using it in web projects. Those who want to build from source or create their own WebAssembly bindings should start here

❤️ Contributors

Thanks goes to these wonderful people (emoji key):

Mike Turner
Mike Turner

💻 🚧 💬 👀
Brent C
Brent C

💻 🚧 💬 👀
Collin Chin
Collin Chin

💻 🚧 💬 👀
Howard Wu
Howard Wu

💻 🤔 🔬 👀
Raymond Chu
Raymond Chu

💻 🤔 🔬 👀
d0cd
d0cd

💻 🤔 🔬 👀
Alessandro Coglio
Alessandro Coglio

📖 🔬 👀
a h
a h

💻 📖
Anthony DiPrinzio
Anthony DiPrinzio

💻
Ali Mousa
Ali Mousa

💻
Ivan Litteri
Ivan Litteri

💻
Nacho Avecilla
Nacho Avecilla

💻
ljedrz
ljedrz

💻
Facundo Olano
Facundo Olano

💻
Nicolas Continanza
Nicolas Continanza

💻
Mike
Mike

💻
Javier Rodríguez Chatruc
Javier Rodríguez Chatruc

💻
Pablo Deymonnaz
Pablo Deymonnaz

💻
Bob Niu
Bob Niu

💻
sptg
sptg

💻
Hamza Khchichine
Hamza Khchichine

💻
Kendrick
Kendrick

💻
Dependabot
Dependabot

💻
All Contributors
All Contributors

📖
Add your contributions

This project follows the all-contributors specification. Contributions of any kind welcome!

sdk's People

Contributors

acoglio avatar adiprinzio avatar amousa11 avatar calebcurry avatar collinc97 avatar d0cd avatar dependabot-preview[bot] avatar dependabot[bot] avatar facundoolano avatar fakefraud avatar fulltimemike avatar howardwu avatar iamalwaysuncomfortable avatar iavecilla avatar ilitteri avatar jrchatruc avatar kendrickdrews avatar ljedrz avatar maciejnadolski98 avatar moalobaidi avatar murrayee avatar nguyentuancanh avatar oguzutku1745 avatar onetrickwolf avatar pablodeymo avatar pauan avatar raheemlawal avatar raychu86 avatar samantatarun avatar spartucus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk's Issues

[Bug] I16 is_neq return type is not valid

I16 is_neq return type is not valid

We (@FuzzingLabs) found an error in is_neq while fuzzing.

cat main.aleo && aleo build
program function_with_xor_add.aleo;

function hello:
        is.neq 42i16 12i16 into r0;
        div.w r0 1i16 into r1;
        output r1 as i16.private;

⏳ Compiling 'function_with_xor_add.aleo'...

⚠️  Invalid operand types for the 'div.w' instruction

Your Environment

  • Aleo commit: b371a04
  • rustc 1.66.0-nightly (a37499ae6 2022-09-18)
  • Ubuntu 20.04

Why is this an error ?

Based on the documentation the following happens:

function hello:
        is.neq 42i16 12i16 into r0; // r0 = i16
        div.w r0 1i16 into r1; // div.w i16 i16 -> r1 = i16
        output r1 as i16.private;

Based on the documentation, at: https://developer.aleo.org/aleo/opcodes#divw, the div.w instruction, when called with 2 i16, should work.

When testing by replacing r0 by a random i16 in the instruction, the code compiles.

The problem seems then to be in is.neq. Still based on the documentation, at: https://developer.aleo.org/aleo/opcodes#isneq, the is.neq function, when called with 2 i16, should store the result in the destination as an i16:

First Second Destination
I16 I16 I16

So according to the documentation, our code should compile.

There may be either an error in the documentation or in the Aleo parser/compiler, as the code is valid as per the documentation

[Feature] Execute program command

🚀 Feature

Add an aleo execute command and equivalent WASM functionality to execute a program's function and broadcast the resulting transaction on-chain.

Motivation

Both Aleo developers and users need a way to execute their programs on-chain. For wallets and any other applications running on top of Aleo to work, they need a way to execute functions and publish them on the blockchain.

This is also necessary for the explorer to give users the ability to execute program functions.

Implementation

As opposed to the run feature, this will require accessing on-chain state (i.e. records). When a program receives a record as input, the execute command (or wasm function) will expect an on-chain record commitment, which it will fetch from a node, decrypt using the user's view key and then use for the execution.

As an example, if there's a hello function with one record as input, and the CLI user has a record on chain with commitment 3892363209129015695237595996230595282638607490815872341685075479616088416491field, they would run (on the CLI)

aleo execute hello 3892363209129015695237595996230595282638607490815872341685075479616088416491field

[Feature] WASM ViewKey.decrypt should handle bare ciphertexts

🚀 Feature

The decrypt function on the ViewKey within the wasm should handle decrypting ciphertexts and not just records.
https://github.com/AleoHQ/aleo/blob/testnet3/wasm/src/account/view_key.rs#L46

Motivation

The motivation is to be able to decrypt specific inputs.

Implementation

The implementation is straightforward and self contained. The only question is should another function be introduced or should a singular function be able to handle both records and bare ciphertexts?

[Feature] Improve Command Line Transfer Speed

🚀 Feature

Improve command line transfer speed

The command line transfer needs to scan the whole block every time. Is it possible to cache the block data to improve the speed of the second transfer?

Implementation

Cache the block data

[Proposal] Remove local node development code and run snarkOS internally

💥 Proposal

Currently, aleo node start runs a local development node whose code is entirely contained in this repo. This is a problem because it duplicates the code contained in snarkOS. If changes need to be made to the REST API, both this repo and snarkOS need to be changed, which is unnecessary and makes the two nodes become de-synced, as people forget to update one or the other.

Instead, the local node spun up by aleo node start should use the snarkOS development mode internally.

This issue depends on this other issue, which proposes adding a flag to start snarkOS in for local development mode.

[Feature] Faucet command to receive funds on development environments

🚀 Feature

Add a faucet command to the CLI that gives users some funds on development environments.

Motivation

To test functionality on their apps on development environments (see this issue for a proposal on development nodes), users need to have funds available for the transactions they submit on their applications.

Implementation

This could be done by adding an endpoint to development nodes and then have the faucet call it. The endpoint would send a small amount of money from the development node's account to the caller.

[Proposal] Deploy command refactor

💥 Proposal

The aleo deploy command currently delegates most of its behaviour to snarkVM, including broadcasting the transaction to the blockchain. This is not ideal, as the VM should only be concerned with the crafting of the transaction (i.e. the execution/proof generation), but not the broadcasting aspect; instead, it should return the Deployment, which the CLI then converts into a transaction and broadcasts.

This also allow us to remove the custom deploy node endpoint, which currently just (almost) duplicates the broadcast logic.

Dependabot can't resolve your Rust dependency files

Dependabot can't resolve your Rust dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

error: failed to parse lock file at: /home/dependabot/dependabot-updater/dependabot_tmp_dir/Cargo.lock

Caused by:
  package `bytes` is specified twice in the lockfile

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

[Feature] Improve Syntax Error logs

🚀 Improve Syntax Error logs

Aleo should provide better error logging for syntax errors. Nowadays it only logs that the compiler could not parse the .aleo file at a certain line (which is not always the line where the error is located) if something is wrong.

It would be awesome if the syntax error were more clearly logged as Leo does.

Are you willing to open a pull request? (See CONTRIBUTING)

String Integer undefined error[Bug]

String integer keeps dropping nonce while execution on the node

Aleo run update '{
owner: aleo16qlhfdrhxv2m2r6cuvl5grrw0mvruc6kcufmgasn7e7csxfj4y9s8dz3pu.private,
gates: 0u64.private,
message: "hello world"private,
_nonce: 20945652754310690266192540395567222880172191888445476630754123022400300672595group.public
}'

[Leo Playground] menu items not consistently blue

🐛 Bug Report

I'm using staging https://stage-pg.leo-lang.org
in Safari version 15.0 on macOS 10.15.7 Catalina.

The Playground menu strings turn blue on mouse-over.
The menu items mainly do not turn blue on mouse-over, but
exactly two of them do for me: Share -> Direct Link to the GIST
and Share -> Permalink to the Playground.
I suggest making the rest of the menu items turn blue.

[Docs] Version option not working

📚 Documentation

The README of this repo says that aleo accepts a version option, but it doesn't appear to work:

...$ aleo -V
error: Found argument '-V' which wasn't expected, or isn't valid in this context

	If you tried to supply `-V` as a value rather than a flag, use `-- -V`

USAGE:
    aleo [OPTIONS] <SUBCOMMAND>

For more information try --help
...$ aleo --version
error: Found argument '--version' which wasn't expected, or isn't valid in this context

	Did you mean '--verbosity'?

	If you tried to supply `--version` as a value rather than a flag, use `-- --version`

USAGE:
    aleo --verbosity <VERBOSITY>

For more information try --help

[Proposal] Aleo Javascript SDK

💥 Proposal

Motivation

A great deal of operational functionality for building and and using zero knowledge programs built in the 🦁Leo language is exposed via Aleo's SnarkVM Rust libraries. A subset of this functionality is used to power the Aleo CLI command line tool. It would be optimal to expand the accessibility of this functionality to web developers by creating a Javascript API so that they can integrate zero knowledge proving functionality into their web applications. This is further motivated by the fact that both Rust and Javascript are well suited for WebAssembly (Further referred to as "Wasm") compilation targets which allows Javascript to directly consume functionality written in Rust.

Goals

Create a Modest Initial Set of Functionality
The first natural step would be to have a Javascript SDK contain most the functionality present with the Aleo CLI. As the CLI is a standalone software, the API within Javascript API may not be a 1-1 correspondence and instead provide a more fine grained API to provide developers the flexibility in design of their applications. Further extensions of the SDK would likely include an API for managing proving and verification of statements generated by Aleo applications.

Create Accessible Javascript Packages & Deployment Tools
The SDK should be published on popular package registries like Npm & Yarn. It should also optimally include easy-to-use deployment tools such as docker containers to allow easy integration into live web applications. The details of Wasm compilation can be documented in detail for those who want to customize it, but largely it should be abstracted away as an implementation detail.

Expose further SnarkVM functionality to Wasm
Wasm interaction with most languages has a lot of caveats. Any code must be explicitly tested within a Wasm context before exposing it to a public API. Useful functionality within SnarkVM worth testing in the Wasm context should be identified and tested.

Concrete Steps

  • Expose account management functions such as create and import via javascript
  • Expose create, build, clean and run functionality for Leo programs via javascript
  • #451
  • Expose testing functionality for interacting with a local development node via javascript
  • Expose functionality for proof verification via javascript
  • Build integration tests for Wasm functionality written in rust & its corresponding javascript representations (this should be done concurrently with any implementation of features)
  • Publish an Aleo-js package to Npm & Yarn
  • Create deployment scripts & docker containers for deploying the javascript API into web contexts
  • Create autogenerated docs and appropriate usage documentation within the NPM ecosystem & developer.aleo.org

[Proposal] Move REST API from snarkVM to snarkOS

💥 Proposal

SnarkVM should only handle program compilation and execution and snarkOS handle node related functionalities. The REST API should be defined in a single place to reduce duplication, make it easier to test and extend without having to touch several repositories.

[Feature] Add record decrypt functionality on WASM package

🚀 Feature

Add a record decrypt function on the wasm sub-project

Motivation

Web applications should be capable of decrypting records via ViewKey on the client using the wasm pkg.

(Outline your motivation here)

Implementation

It should be possible to expose the SnarkVm decrypt functionality via #[wasm_bingen] on the wasm sub-project

suggested firm:

record = decrypt_record(viewkey, cyperth_text)

Are you willing to open a pull request? (See CONTRIBUTING)

[Bug] counterintuitive syntax when handling negative numbers

We (@FuzzingLabs) found something that may be counterintuitive in the Leo syntax/grammar.

Our fuzzer generated some test cases looking like this:

program foo.aleo {
	transition fuzz() -> i64 {
		let r0: i64 = -1i64.abs();
		return r0;
	}
}


By looking at this, we thought it would return 1, as it is the absolute of -1.

Contrary to our expectations, it returned -1.

We first thought it was an error in the parsing or in the abs() function, but this pattern repeated on multiple operations.

We found that compared to the Aleo code we thought would be produced:

program foo.aleo;
​
​
function fuzz:
    abs -1i64 into r0;
    output r0 as i64.private;


It produced this one

program foo.aleo;
​
​
function fuzz:
    abs 1i64 into r0;
    neg r0 into r1;
    output r1 as i64.private;


So the compiler sees this code like this:

program foo.aleo {
	transition fuzz() -> i64 {
		let r0: i64 = -(1i64.abs());
		return r0;
	}
}


When we initially interpreted that more like this:

program foo.aleo {
	transition fuzz() -> i64 {
		let r0: i64 = (-1i64).abs();
		return r0;
	}
}


Based on some private discussions with the developer team, we found that it was the intended behavior, as specified in the abnf grammar, and is the default behavior of a lot of parsers.

So on the line let r0: i64 = -1i64.abs();, the parser understand something like that let r0: i64 = -(1i64.abs());.

Users may have to be careful when using negative numbers to call a function to avoid unwanted behavior

We open this issue to keep track of this behavior and to provide additional examples for unit testing.

[Bug] Unable to cast more than 8 elements into an interface

🐛 Bug Report

I'm trying to cast a set of fields into an interface that represents an array of 784 elements. As far as I could test, this is not possible for anything greater than 8 elements.

Steps to Reproduce

For the sake of clarity and legibility, 9 elements will be used instead of 784.

Code snippet to reproduce

The following example works as expected when executing the circuit as: aleo run hello_world 1field 2field 3field 4field 5field 6field 7field 8field

interface array8:
  a0 as field;
  a1 as field;
  a2 as field;
  a3 as field;
  a4 as field;
  a5 as field;
  a6 as field;
  a7 as field;
  
function hello_world:
  input r0 as field.public;
  input r1 as field.public;
  input r2 as field.public;
  input r3 as field.public;
  input r4 as field.public;
  input r5 as field.public;
  input r6 as field.public;
  input r7 as field.public;
  
  cast r0 r1 r2 r3 r4 r5 r6 r7 into r8 as array8;

  output r8 as array8.public;

Output:

$ aleo run hello_world 1field 2field 3field 4field 5field 6field 7field 8field

⏳ Compiling 'tests.aleo'...

 • Called universal setup: 11326 ms
 • Called setup: 11306 ms

🚀 Executing 'tests.aleo/hello_world'...

 • Called prover: 1415 ms

➡️  Output

 • {
  a0: 1field,
  a1: 2field,
  a2: 3field,
  a3: 4field,
  a4: 5field,
  a5: 6field,
  a6: 7field,
  a7: 8field
}

✅ Executed 'tests.aleo/hello_world' 

The following example results in an error, when trying to do the same as before with one more element:

interface array9:
  a0 as field;
  a1 as field;
  a2 as field;
  a3 as field;
  a4 as field;
  a5 as field;
  a6 as field;
  a7 as field;
  a8 as field;
  
function hello_world:
  input r0 as field.public;
  input r1 as field.public;
  input r2 as field.public;
  input r3 as field.public;
  input r4 as field.public;
  input r5 as field.public;
  input r6 as field.public;
  input r7 as field.public;
  input r8 as field.public;
  
  cast r0 r1 r2 r3 r4 r5 r6 r7 r8 into r9 as array9;

  output r9 as array9.public;

Stack trace & error message

$ aleo run hello_world 1field 2field 3field 4field 5field 6field 7field 8field 9field

⚠️  Failed to parse string. Remaining invalid string is: "function hello_world:
  input r0 as field.public;
  input r1 as field.public;
  input r2 as field.public;
  input r3 as field.public;
  input r4 as field.public;
  input r5 as field.public;
  input r6 as field.public;
  input r7 as field.public;
  input r8 as field.public;
  
  cast r0 r1 r2 r3 r4 r5 r6 r7 r8 into r9 as array9;

  output r9 as array9.public;

Expected Behavior

The expected output would have been an array9 interface such as the following:

➡️  Output

 • {
  a0: 1field,
  a1: 2field,
  a2: 3field,
  a3: 4field,
  a4: 5field,
  a5: 6field,
  a6: 7field,
  a7: 8field,
  a8: 9field,
}

Your Environment

  • Aleo Version: 0.2.0
  • Rust Version: 1.62.0
  • Computer OS: macOS Monterey 12.4

[Bug] minor issue when build

🐛 Bug Report

rust/environment/src/environment.rs:17:5

|
17 | use aleo_account::Address;
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

warning: unused imports: CRH, CommitmentScheme, SignatureScheme
--> rust/environment/src/environment.rs:20:14
|
20 | traits::{CommitmentScheme, CRH},
| ^^^^^^^^^^^^^^^^ ^^^
21 | SignatureScheme,
| ^^^^^^^^^^^^^^^

warning: unused import: std::hash::Hash
--> rust/environment/src/environment.rs:33:5
|
33 | use std::hash::Hash;
| ^^^^^^^^^^^^^^^

warning: 3 warnings emitted

Compiling aleo-record v0.2.0 (~/aleo/aleo/rust/record)
warning: glob import doesn't reexport anything because no candidate is public enough
--> rust/record/src/helpers/mod.rs:18:9
|
18 | pub use decode::*;
| ^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

warning: glob import doesn't reexport anything because no candidate is public enough
--> rust/record/src/helpers/mod.rs:21:9
|
21 | pub use decrypt::*;
| ^^^^^^^^^^

warning: glob import doesn't reexport anything because no candidate is public enough
--> rust/record/src/helpers/mod.rs:24:9
|
24 | pub use encode::*;
| ^^^^^^^^^

warning: glob import doesn't reexport anything because no candidate is public enough
--> rust/record/src/helpers/mod.rs:27:9
|
27 | pub use encrypt::*;
| ^^^^^^^^^^

warning: variable does not need to be mutable
--> rust/record/src/record_builder.rs:141:9
|
141 | mut self,
| ----^^^^
| |
| help: remove this mut
|
= note: #[warn(unused_mut)] on by default

warning: field is never read: elements
--> rust/record/src/encoded.rs:23:5
|
23 | elements: Vec,
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default

warning: field is never read: final_sign_high
--> rust/record/src/encoded.rs:24:5
|
24 | final_sign_high: bool,
| ^^^^^^^^^^^^^^^^^^^^^

warning: struct is never constructed: Decode
--> rust/record/src/helpers/decode.rs:36:19
|
36 | pub(crate) struct Decode;
| ^^^^^^

warning: associated function is never used: decode
--> rust/record/src/helpers/decode.rs:39:19
|
39 | pub(crate) fn decode<E: Environment>(
| ^^^^^^

warning: 9 warnings emitted

Compiling aleo v0.2.0 (~/aleo/aleo)
Finished release [optimized] target(s) in 2m 11s
-->

(Write your description here)

Steps to Reproduce

Code snippet to reproduce

# Add code here

Stack trace & error message

// Paste the output here

Expected Behavior

(Write what you expected to happen here)

Your Environment

  • aleo v0.2.0
  • rustc 1.53.0
  • ubuntu 20

[Proposal] Cache function keys in browser storage

💥 Proposal - Cache function keys in browser storage

Function keys are public keys needed to execute and verify execution of programs. Currently if they are downloaded from the web or synthesized offline on aleo.tools, these keys remain for the duration of the web session but are erased from memory as soon as the component using it unmounts. These keys should be stored in the browser’s local storage so that when a user re-visits aleo.tools. The keys are available for usage without having to re-download them or re-synthesize them.

The caveats to this however are the following:

  • Network Reset: the network needs to go through a reset, these keys become invalid and need to be refreshed. A mechanism needs to be devised to detect changes in program keys for auto-refresh.
  • Key for offchain programs: If the key is synthesized locally before a program is deployed to the network, these keys may not represent the program on chain at a future time. So perhaps keys synthesized locally for a program not yet deployed on chain should either not be stored or should have an explicit option to clear the local key cache.

[Proposal] Create web workers in an top-level component in aleo.tools so they can be shared

💥 Proposal - Create web workers in an top-level component in aleo.tools so they can be shared

Webworkers are currently started on each react component which does Program Execution (currently the Execute, Deploy, Transfer, Split, and Join components)

This has the following disadvantages

  • A wasteful amount of web workers are started & stopped on each page
  • Resources aren’t shared between the components which mean keys synthesized or downloaded can’t be shared between the workers
  • It creates a situation where a heavy load on browser’s host memory can be generated

Optimally the web workers should be moved up to a parent component and be shared between the react components which perform program execution

Leo Playground default programs not working [Bug]

🐛 Bug Report

I tried to run Token and Simple Token programs and both returned that error. I didn't make any change to the code.

Steps to Reproduce

Go to Leo Playground, select examples, Token. Click Run -> Main and wait for the error

Code snippet to reproduce

program token.aleo {
    // On-chain storage of an `account` map, with `address` as the key,
    // and `u64` as the value.
    mapping account: address => u64;

    record token {
        // The token owner.
        owner: address,
        // The Aleo balance (in gates).
        gates: u64,
        // The token amount.
        amount: u64,
    }

    /* Mint */

    // The function `mint_public` issues the specified token amount for the token receiver publicly on the network.
    transition mint_public(public receiver: address, public amount: u64) {
        // Mint the tokens publicly by invoking the computation on-chain.
        return then finalize(receiver, amount);
    }

    finalize mint_public(public receiver: address, public amount: u64) {
        // Increments `account[receiver]` by `amount`.
        // If `account[receiver]` does not exist, it will be created.
        // If `account[receiver] + amount` overflows, `mint_public` is reverted.
        increment(account, receiver, amount);
    }

    // The function `mint_private` initializes a new record with the specified amount of tokens for the receiver.
    transition mint_private(receiver: address, amount: u64) -> token {
        return token {
            owner: receiver,
            gates: 0u64,
            amount: amount,
        };
    }

    /* Transfer */
    transition transfer_public(public receiver: address, public amount: u64) {
        // Transfer the tokens publicly, by invoking the computation on-chain.
        return then finalize(self.caller, receiver, amount);
    }

    finalize transfer_public(public sender: address, public receiver: address, public amount: u64) {
        // Decrements `account[sender]` by `amount`.
        // If `account[sender]` does not exist, it will be created.
        // If `account[sender] - amount` underflows, `transfer_public` is reverted.
        decrement(account, sender, amount);
        // Increments `account[receiver]` by `amount`.
        // If `account[receiver]` does not exist, it will be created.
        // If `account[receiver] + amount` overflows, `transfer_public` is reverted.
        increment(account, receiver, amount);
    }

    // The function `transfer_private` sends the specified token amount to the token receiver from the specified token record.
    transition transfer_private(sender: token, receiver: address, amount: u64) -> (token, token) {
        // Checks the given token record has sufficient balance.
        // This `sub` operation is safe, and the proof will fail if an overflow occurs.
        // `difference` holds the change amount to be returned to sender.
        let difference: u64 = sender.amount - amount;

        // Produce a token record with the change amount for the sender.
        let remaining: token = token {
            owner: sender.owner,
            gates: sender.gates,
            amount: difference,
        };

        // Produce a token record for the specified receiver.
        let transferred: token = token {
            owner: receiver,
            gates: 0u64,
            amount: amount,
        };

        // Output the sender's change record and the receiver's record.
        return (remaining, transferred);
    }

    // The function `transfer_private_to_public` turns a specified token amount from a token record into public tokens for the specified receiver.
    // This function preserves privacy for the sender's record, however it publicly reveals the token receiver and the token amount.
    transition transfer_private_to_public(sender: token, public receiver: address, public amount: u64) -> token {
        // Checks the given token record has a sufficient token amount.
        // This `sub` operation is safe, and the proof will fail if an underflow occurs.
        // `difference` holds the change amount for the caller.
        let difference: u64 = sender.amount - amount;

        // Produces a token record with the change amount for the caller.
        let remaining: token = token {
            owner: sender.owner,
            gates: sender.gates,
            amount: difference,
        };

        // Output the sender's change record.
        // Increment the token amount publicly for the token receiver.
        return remaining then finalize(receiver, amount);
    }

    finalize transfer_private_to_public(public receiver: address, public amount: u64) {
        // Increments `account[receiver]` by `amount`.
        // If `account[receiver]` does not exist, it will be created.
        // If `account[receiver] + amount` overflows, `transfer_private_to_public` is reverted.
        increment(account, receiver, amount);
    }

    // The function `transfer_public_to_private` turns a specified token amount from `account` into a token record for the specified receiver.
    // This function preserves privacy for the receiver's record, however it publicly reveals the caller and the specified token amount.
    transition transfer_public_to_private(public receiver: address, public amount: u64) -> token {
        // Produces a token record for the token receiver.
        let transferred: token = token {
            owner: receiver,
            gates: 0u64,
            amount: amount,
        };

        // Output the receiver's record.
        // Decrement the token amount of the caller publicly.
        return transferred then finalize(self.caller, amount);
    }

    finalize transfer_public_to_private(public sender: address, public amount: u64) {
        // Decrements `account[sender]` by `amount`.
        // If `account[sender]` does not exist, it will be created.
        // If `account[sender] - amount` underflows, `transfer_public_to_private` is reverted.
        decrement(account, sender, amount);
    }

}

Stack trace & error message

 Leo Compiled 'main.leo' into Aleo instructions
⏳ Compiling 'token.aleo'...

 • Loaded universal setup (in 17 ms)
 • Built 'mint_public' (in 2216 ms)
 • Built 'mint_private' (in 4426 ms)
 • Built 'transfer_public' (in 2398 ms)
 • Built 'transfer_private' (in 7839 ms)
 • Built 'transfer_private_to_public' (in 6888 ms)
 • Built 'transfer_public_to_private' (in 4101 ms)

       Leo ✅ Built 'token.aleo' (in "/usr/playground-projects/adorable_succinct_breezy_beauty/build")

Error [ECLI0377010]: Failed to execute the `aleo run` command.
SnarkVM Error: Function 'main' does not exist.

Expected Behavior

(Write what you expected to happen here)

Your Environment

  • Leo Playground's
  • Leo Playground's
  • Windows 10

Self.Anything is parsed as an address

🐛 Bug Report

Self.anything will be parsed as an address. Self.caller parses correctly, however; self.a or self.b will parse as addresses.

Steps to Reproduce

Code snippet to reproduce

program bug.aleo;

record bug:
    owner as address.private;
    gates as u64.private;
    a as address.private;
    b as address.private;
    not_an_aleo_opcode as address.private;

function example:
    cast self.caller 0u64 self.a self.b self.not_an_aleo_opcode into r0 as bug.record;

    output r0 as bug.record;

Stack trace & error message

➡️  Output

 • {
  owner: aleo1pas6kcc8nwqawwqu9fhz99anqkk9ccd9q0fk3nc3wzsr0utt7cxq5klu4k.private,
  gates: 0u64.private,
  a: aleo1c0k9657psh8qzr2usfw6u7a7yu6mwe6wh2ypup4t2ugpx784wsrqp53rdl.private,
  b: aleo1wk535qg0h9tarqeu40zkmpr0qv5mhdfa5lue6qcdcwtwgqm2pq9q2ezssx.private,
  not_an_aleo_opcode: aleo13h4g6epkv8a6z48waewdr9jp5gf4xmnuamhwy3a8n936t73j8vrq9uaz39.private,
  _nonce: 5582012585678402213691137563223232720299537956048903574854357996637224826608group.public
}

Expected Behavior

Only implemented attributes of self in aleo should parse (like self.caller and self.parent in the future), and should otherwise throw an error. Note, each of the addresses parsed (self.a, self.b, self.not_an_aleo_opcode) are deterministic -- repeated runs on different machines will yield the same address, so the self.[trait_name] is likely being hashed here in snarkVM. I'm including this in case it helps with pinpointing the bug's location.

Your Environment

  • Aleo Version 901453f
  • rustup 1.25.1
  • MacOS

[Proposal] Create-Aleo-App

🔮 Proposal - Create-Aleo-App

Privacy preservation through zero Knowledge computing is an ideal that Aleo aspires to enable, but the concept in reality is often difficult to grasp. The create-aleo-app strives to present an example of how to bring zero knowledge computing to every-day web applications.

Description

The create-aleo-app provides a template for creating zero knowledge apps via Aleo cryptography.

Users who use create-aleo-app will be able to receive templates to build the following

  • Create and manage Aleo accounts
  • Simple wallet using Aleo
  • Simple zero knowledge applications

Concrete Tasks

Implementation

  • Create-Aleo-App should be published to NPM and be able to be run via NPX

[Bug] Unable to Deploy Program with Imports to Local Aleo Node

🐛 Bug Report

Aleo programs with multiple files (one main.aleo file, one imported helper.aleo file) cannot deploy because the initialization in SnarkVM expects the imported program to be deployed already.

Steps to Reproduce

Run aleo node start in a program with at least one imported aleo file.

Code snippet to reproduce

main.aleo file

import importtest.aleo;

// The 'main.aleo' program.
program token.main;

function hello:
    // Dummy input
    input r0 as address.public;
    // Dummy input
    input r1 as u64.public;

importtest.aleo file

program importtest.aleo;

function hello:
    // Dummy input
    input r0 as address.public;
    // Dummy input
    input r1 as u64.public;

Stack trace & error message

📦 Deploying 'token.aleo' to the local development node...

⚠️  Cannot add program 'main.aleo' because its import 'importtest.aleo' must be added first

Expected Behavior

Programs with local imported files should deploy successfully. Local imports should be deployed to the local Aleo Node before the main program.

Your Environment

  • Aleo Version: built from source code
  • Rust Version: rustc 1.65.0-nightly
  • Computer OS: macOS Monetery Version 12.5

[Security] Workflow ci.yml is using vulnerable action actions/checkout

The workflow ci.yml is referencing action actions/checkout using references v1. However this reference is missing the commit a6747255bd19d7a757dbdda8c654a9f84db19839 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

[Bug] Assertion failed `left == right` in ShrOperation

Assertion failed left == right

We (@FuzzingLabs) found an assertion fail panics while fuzzing in Circuit::enforce().

This error can be triggered directly with the aleo build on the latest release version of the project

aleo build

⏳ Compiling 'foo.aleo'...

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `1`: Constant constraint failed: (0 * 1) =?= 1', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/snarkvm-circuit-environment-0.9.14/src/circuit.rs:156:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Your Environment

  • Aleo version: v0.3.6
  • rustc 1.66.0-nightly (a37499ae6 2022-09-18)
  • Ubuntu 20.04

Expected Behavior

The program should either gracefully exit or use the function halt() that is used in others cases when there's an error.
The preferred behavior would be to gracefully exit.

Backtrace

⏳ Compiling 'foo.aleo'...

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `1`: Constant constraint failed: (0 * 1) =?= 1', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/snarkvm-circuit-environment-0.9.14/src/circuit.rs:156:29
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a37499ae66ec5fc52a93d71493b78fb141c32f6b/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/a37499ae66ec5fc52a93d71493b78fb141c32f6b/library/core/src/panicking.rs:142:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
   4: std::thread::local::LocalKey<T>::with
   5: <snarkvm_synthesizer::program::instruction::operation::ShrOperation<N> as snarkvm_synthesizer::program::instruction::operation::Operation<N,snarkvm_console_program::data::literal::Literal<N>,snarkvm_console_program::data_types::literal_type::LiteralType,2_usize>>::execute
   6: snarkvm_synthesizer::program::instruction::operation::literals::Literals<N,O,_>::execute
   7: snarkvm_synthesizer::process::stack::execute::<impl snarkvm_synthesizer::process::stack::Stack<N>>::execute_function
   8: snarkvm::package::build::<impl snarkvm::package::Package<N>>::build
   9: aleo::commands::build::Build::parse
  10: aleo::commands::Command::parse
  11: aleo::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Crash File (main.aleo)

program foo.aleo;

function fuzz:
  input r0 as i16.public;
	rem.w r0 r0 into r1;
	shr r1 32u8 into r2;

[Bug]

🐛 Bug Report

Code snippet to reproduce

Stack trace & error message error: failed to compile aleo v0.3.1 (C:\Users\Giga\aleo), intermediate artifacts can be found at C:\Users\Giga\aleo\target

Your Environment

[Bug] ECLI0377010 (Transition view key (console) is not set in the registers.)

🐛 Bug Report

I wrote a program, https://github.com/arosboro/aleo_bitwise_stack, and some transitions generate errors, while the program still manages to compile correctly.

Steps to Reproduce

Compile the program in the description, and run leo run main 6u32 leo run push 14u32 "{...}"

struct BufferSeries256Bit:
    b00 as u32;
    b01 as u32;
    b02 as u32;
    b03 as u32;
    b04 as u32;
    b05 as u32;
    b06 as u32;
    b07 as u32;

record Stack:
    owner as address.private;
    gates as u64.private;
    capacity as u32.private;
    top as u32.private;
    member_size as u32.private;
    s00 as BufferSeries256Bit.private;
    s01 as BufferSeries256Bit.private;
    s02 as BufferSeries256Bit.private;
    s03 as BufferSeries256Bit.private;

function push:
    input r0 as u32.private;
    input r1 as Stack.record;
    call get_series_and_buffer_indexes r1.top r1.member_size into r2 r3;
    call get_buffer_series r2 r1 into r4;
    call get_buffer_at_index r3 r4 into r5;
    pow 2u32 r1.member_size into r6;
    sub r6 1u32 into r7;
    lt r1.top r1.capacity into r8;
    assert.eq r8 true;
    lte r0 r7 into r9;
    assert.eq r9 true;
    div 4294967295u32 2u32 into r10;
    lte r7 r10 into r11;
    assert.eq r11 true;
    add r1.top 1u32 into r12;
    shl r5 r1.member_size into r13;
    or r13 r0 into r14;
    call set_buffer_at_index r3 r4 r14 into r15;
    call set_buffer_series r2 r1 r12 r15 into r16;
    output r16 as Stack.record;

Stack trace & error message

leo run push 14u32 "{
  owner: aleo1g7lprd8dkrt76jnyrgnw4mw0cpe2u4ckkajs96wqu8xyggze6v8qlegxp3.private,
  gates: 0u64.private,
  capacity: 170u32.private,
  top: 0u32.private,
  member_size: 6u32.private,
  s00: {
    b00: 0u32.private,
    b01: 0u32.private,
    b02: 0u32.private,
    b03: 0u32.private,
    b04: 0u32.private,
    b05: 0u32.private,
    b06: 0u32.private,
    b07: 0u32.private
  },
  s01: {
    b00: 0u32.private,
    b01: 0u32.private,
    b02: 0u32.private,
    b03: 0u32.private,
    b04: 0u32.private,
    b05: 0u32.private,
    b06: 0u32.private,
    b07: 0u32.private
  },
  s02: {
    b00: 0u32.private,
    b01: 0u32.private,
    b02: 0u32.private,
    b03: 0u32.private,
    b04: 0u32.private,
    b05: 0u32.private,
    b06: 0u32.private,
    b07: 0u32.private
  },
  s03: {
    b00: 0u32.private,
    b01: 0u32.private,
    b02: 0u32.private,
    b03: 0u32.private,
    b04: 0u32.private,
    b05: 0u32.private,
    b06: 0u32.private,
    b07: 0u32.private
  },
  _nonce: 614214494271648495598934275926054716009684844222154912820977896450124583491group.public
}"
       Leo Compiled 'main.leo' into Aleo instructions
       Leo ✅ Built 'aleo_bitwise_stack.aleo' (in "/Users/arosboro/git/aleo_bitwise_stack/build")

🚀 Executing 'aleo_bitwise_stack.aleo/push'...

 • Executing 'aleo_bitwise_stack.aleo/push'...
Error [ECLI0377010]: Failed to execute the `aleo run` command.
SnarkVM Error: Failed to evaluate instruction (cast r1.owner r1.gates r1.capacity r2 r1.member_size r3 r1.s01 r1.s02 r1.s03 into r5 as Stack.record;): Transition view key (console) is not set in the registers.
arosboro@Andrews

Expected Behavior

The program runs as expected.

Your Environment

  • v0.3.2
  • rustc 1.66.0 (69f9c33d7 2022-12-12)
  • MacOS Monterey 12.6.1

[Security] Workflow release.yml is using vulnerable action actions/checkout

The workflow release.yml is referencing action actions/checkout using references v1. However this reference is missing the commit a6747255bd19d7a757dbdda8c654a9f84db19839 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

[Proposal] Testnet2 Record Epic

💥 Proposal

Requirements to add testnet2 record support to aleo sdk.

Tracking issue checklist:

  • implement datatypes
    • record
    • record ciphertext
  • implement wasm_bindgen methods
    • record
    • record ciphertext
  • implement CLI support
    • record
    • record ciphertext
  • call JS methods in website frontend
    • record
    • record ciphertext

[Bug] thread 'main' panicked at 'Integer power failed on 2u32 and 32u32

🐛 Bug Report

When working with a u32 type and using the operation max_u32: u32 = 2u32 ** 32u32 - 1u32, there is an overflow error and it is impossible to allocate the maximum sized u32 value using this method.

Code snippet to reproduce

input r0 as u32.private // 32u32
pow 2u32 r0 into r1

Stack trace & error message

arosboro@Andrews-iMac aleo_bitwise_stack % export RUST_BACKTRACE=1;leo run push 14u32 "{
  owner: aleo1g7lprd8dkrt76jnyrgnw4mw0cpe2u4ckkajs96wqu8xyggze6v8qlegxp3.private,
  gates: 0u64.private,
  capacity: 32u32.private,
  top: 0u32.private,
  member_size: 32u32.private,
  s00: {
    b00: 0u32.private,
    b01: 0u32.private,
    b02: 0u32.private,
    b03: 0u32.private,
    b04: 0u32.private,
    b05: 0u32.private,
    b06: 0u32.private,
    b07: 0u32.private
  },
  s01: {
    b00: 0u32.private,
    b01: 0u32.private,
    b02: 0u32.private,
    b03: 0u32.private,
    b04: 0u32.private,
    b05: 0u32.private,
    b06: 0u32.private,
    b07: 0u32.private
  },
  s02: {
    b00: 0u32.private,
    b01: 0u32.private,
    b02: 0u32.private,
    b03: 0u32.private,
    b04: 0u32.private,
    b05: 0u32.private,
    b06: 0u32.private,
    b07: 0u32.private
  },
  s03: {
    b00: 0u32.private,
    b01: 0u32.private,
    b02: 0u32.private,
    b03: 0u32.private,
    b04: 0u32.private,
    b05: 0u32.private,
    b06: 0u32.private,
    b07: 0u32.private
  },
  _nonce: 1187103184385585538941608731894191400304769658683763343800607324013088691420group.public
}"
       Leo Compiled 'main.leo' into Aleo instructions
       Leo ✅ Built 'aleo_bitwise_stack.aleo' (in "/Users/arosboro/git/aleo_bitwise_stack/build")

🚀 Executing 'aleo_bitwise_stack.aleo/push'...

 • Executing 'aleo_bitwise_stack.aleo/push'...
thread 'main' panicked at 'Integer power failed on: 2u32 and 32u32', /Users/arosboro/.cargo/registry/src/github.com-1ecc6299db9ec823/snarkvm-console-network-environment-0.9.11/src/environment.rs:62:9
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_display
   3: snarkvm_synthesizer::program::instruction::operation::literals::Literals<N,O,_>::evaluate
   4: snarkvm_synthesizer::process::stack::execute::<impl snarkvm_synthesizer::process::stack::Stack<N>>::execute_function
   5: snarkvm_synthesizer::process::execute::<impl snarkvm_synthesizer::process::Process<N>>::execute
   6: snarkvm::package::run::<impl snarkvm::package::Package<N>>::run
   7: aleo::commands::run::Run::parse
   8: <leo::commands::run::Run as leo::commands::Command>::apply
   9: leo::commands::Command::try_execute
  10: leo::run_with_args
  11: scoped_tls::ScopedKey<T>::set
  12: leo::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Expected Behavior

operation truncates to u32::MAX or the error is made more clear.

Your Environment

  • 0.3.2
  • rustc 1.66.0 (69f9c33d7 2022-12-12)
  • macOS Monterey Version 12.6.1

[Proposal] accept capitalised `Project Names`

💥 Proposal

Seeing this error:

  • image

is a bit confusing, the suggestion is to either accept capitalised Project Names or indicate that capitals are not allowed, I know in a regex world [a-z] means just lower cases etc, but the text is a bit unclear ..

[Bug] o

🐛 Bug Report

(Write your description here)

Steps to Reproduce

Code snippet to reproduce

# Add code here

Stack trace & error message

// Paste the output here

Expected Behavior

(Write what you expected to happen here)

Your Environment

[Leo Playground] OUTPUTS buttons not working for me

🐛 Bug Report

I'm using staging https://stage-pg.leo-lang.org
in Safari version 15.0 on macOS 10.15.7 Catalina.

The OUTPUTS window in the upper right has some buttons,
but they don't show me the output.

When I click on Verifying Key, Proof, or main.output,
nothing happens.

When I click on Proving Key, a new tab opens, then a little warning box from
Safari asks if I want to allow downloads on https://stage-pg.leo-lang.org
and then both of those go away before I can do anything.

One possible solution:

I suggest adding another button under OUTPUTS for STDOUT/STDERR
(maybe arranging in two columns to take less vertical space)
and then when the user clicks one of the outputs buttons, just display it in the pane below.
That way I would be able to see main.output right in the Playground.

[Security] Workflow release.yml is using vulnerable action actions/checkout

The workflow release.yml is referencing action actions/checkout using references v1. However this reference is missing the commit a6747255bd19d7a757dbdda8c654a9f84db19839 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

Expose functionality for creating simple value transfer transactions via javascript

Exposing basic transaction functionality for exchanging Aleo credits is a key need for people to be able to participate in the network. It's thus desired to create a reference SDK and wallet implementation to demonstrate canonical ways of transferring value.

This can be achieved in the following few steps

  • Develop a program similar to credits.leo that transfers credits (likely in units of gates) to 1 or more recipients
  • Create a rust API in the SDK encapsulating the steps for transfer with the aformentioned leo program "powering" it
  • Create a javascript & typescript front end through this via wasm (or another rpc method)
  • Consume this functionality in a reference wallet implementation

[Bug] Cast a Record with a gates values different than 0

🐛 Bug Report

You cannot cast a Record with a gates values different than 0u64.

Steps to Reproduce

Try to build this program:

(Aleo CLI built with f3cad52)

 aleo build

Code snippet to reproduce

// The 'foo.aleo' program.
program foo.aleo;

record foo:
    owner as address.private;
    gates as u64.private;

function mint_foo:
    // user address
    input r0 as address.private;
    // cast address and the initial balance: Zero 
    cast r0 100u64 into r1 as foo.record;
    // output wallet created
    output r1 as foo.record;

Stack trace & error message

⏳ Compiling 'foo.aleo'...

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `1`: Constant constraint failed: (0 * 1) =?= 1', /[...]/.cargo/git/checkouts/snarkvm-f1160780ffe17de8/bb3324d/circuit/environment/src/circuit.rs:160:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected Behavior

⏳ Compiling 'foo.aleo'...

 • Loaded universal setup (in 1422 ms)
 • Built 'create_foo' (in 6103 ms)

✅ Built 'foo.aleo' (in "[...]")

[Feature] Add JSON output format option to `aleo run` command

🚀 Feature

Add JSON output format option to aleo run command.

aleo run --json <FUNCTION> [INPUTS]

Motivation

A JSON output option would be very appreciated for developers to integrate their projects with the Aleo CLI in a more pleasant way.

Implementation

  • Add --json option to the aleo run command with clap.
  • Ignore any output (universal setup, building, ...) when this option is passed by:
  • Implement a JSON parser for aleo types and return the output inside a JSON object.

For example this output:


➜  foo aleo run hello 1u32 1u32
 • Loaded universal setup (in 1489 ms)
🚀 Executing 'foo.aleo/hello'...

 • Executing 'foo.aleo/hello'...
 • Executed 'hello' (in 1076 ms)

➡️  Output

 • 1u32
 • aleo188ux4wh47xutmmn78s55tknxutt8dj5p4qhgq83y0znxz8x7qqgqaextru
 • {
  owner: aleo1x5nz5u4j50w482t5xtqc3jdwly9s8saaxlgjz0wvmuzmxv2l5q9qmypx09.private,
  gates: 0u64.private,
  _nonce: 2293253577170800572742339369209137467208538700597121244293392265726446806023group.public
}

✅ Executed 'foo.aleo/hello' (in "[...]/foo")

It should be outputted as the following:

{
  "outputs": [
    1,
    "aleo188ux4wh47xutmmn78s55tknxutt8dj5p4qhgq83y0znxz8x7qqgqaextru",
    {
      "owner": "aleo1x5nz5u4j50w482t5xtqc3jdwly9s8saaxlgjz0wvmuzmxv2l5q9qmypx09",
      "gates": 0
    }
  ]
}

[FEATURE] Generate docs sub project

🚀 Feature

Generate a subproject for documentation purposes.

Motivation

To have a subproject for handling the docs from now on

Implementation

  • run npm init inside docs folder
  • install jsdoc and all the packages needed inside there
  • before docs generation, build wasp-pack inside a docs/pkg folder. This folder should be ignored by github.
  • generate docs inside docs running npm run build
  • make prettier and eslint to ignored this folder
  • use docs/readme.md as the docs main page
  • check that the github pages works correctly

[Bug] Records with Strings cannot later be used as inputs

🐛 Bug Report

String can be set in records but then this causes records to break. They cannot even be input to another function if the record contains a string. I would expect records to work with strings just as they work with other types.

Steps to Reproduce

Code snippet to reproduce

program messenger.aleo;

record message:
    owner as address.private;
    gates as u64.private;
    message as string.private;

function create:
    cast self.caller 0u64 "hello world" into r0 as message.record;

    output r0 as message.record;

function update:
    input r0 as message.record;
  1. Run aleo run create
    Outputs:
{
  owner: aleo16qlhlqy6xv2m2r6cuvl5grrw0mvruc6kcufmgasn7e7csxfj4y9s8dz3pu.private,
  gates: 0u64.private,
  message: "hello world".private,
  _nonce: 2097303754310690266192540395567222880172191888445476630754123022400300672595group.public
}
  1. Run
aleo run update  '{
  owner: aleo16qlhlqy6xv2m2r6cuvl5grrw0mvruc6kcufmgasn7e7csxfj4y9s8dz3pu.private,
  gates: 0u64.private,
  message: "hello world".private,
  _nonce: 2097303754310690266192540395567222880172191888445476630754123022400300672595group.public
}' 

Stack trace & error message

🚀 Executing 'messenger.aleo/update'...

 • Executing 'messenger.aleo/update'...
⚠️  marlin: AHPError(InstanceDoesNotMatchIndex)

Expected Behavior

I expect no error.

If we can set a string in a record, we should be able to create a new record with an updated string.

Your Environment

rustc 1.65.0-nightly
leo-lang 1.5.3 running on Darwin 21.5.0

[Bug] `cargo install --path .` currently failing with error

🐛 Bug Report

testnet3 HEAD does not compile due to a change in the function signature of package.run called from cli/commands/run.rs:59:13.

Steps to Reproduce

git clone [email protected]:AleoHQ/aleo.git
cd aleo
cargo install --path .

Code snippet to reproduce

let (response, _transition, _inclusion) = package.run::<Aleo, _>(
    self.endpoint,
    package.manifest_file().development_private_key(),
    self.function,
    rng,
)?;

Stack trace & error message

   Compiling snarkvm v0.9.11
error[E0308]: mismatched types
  --> cli/commands/run.rs:59:13
   |
59 |           let (response, _transition, _inclusion) = package.run::<Aleo, _>(
   |  _____________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^___-
   | |             |
   | |             expected a tuple with 4 elements, found one with 3 elements
60 | |             self.endpoint,
61 | |             package.manifest_file().development_private_key(),
62 | |             self.function,
63 | |             &self.inputs,
64 | |             rng,
65 | |         )?;
   | |__________- this expression has type `(snarkvm::prelude::Response<Testnet3>, Execution<Testnet3>, Inclusion<Testnet3>, Vec<CallMetrics<Testnet3>>)`
   |
   = note: expected tuple `(snarkvm::prelude::Response<Testnet3>, Execution<Testnet3>, Inclusion<Testnet3>, Vec<CallMetrics<Testnet3>>)`
              found tuple `(_, _, _)`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `aleo` due to previous error
error: failed to compile `aleo v0.3.1 (/Users/arosboro/AleoSDK/aleo)`, intermediate artifacts can be found at `/Users/arosboro/AleoSDK/aleo/target`

Expected Behavior

arosboro@Andrews-iMac aleo % cargo install --path .
  Installing aleo v0.3.1 (/Users/arosboro/AleoSDK/aleo)
    Updating crates.io index
   Compiling aleo v0.3.1 (/Users/arosboro/AleoSDK/aleo)
    Finished release [optimized] target(s) in 4m 45s
   Replacing /Users/arosboro/.cargo/bin/aleo
    Replaced package `aleo v0.3.1 (/Users/arosboro/AleoSDK/aleo)` with `aleo v0.3.1 (/Users/arosboro/AleoSDK/aleo)` (executable `aleo`)

Aleo SDK compiles and installs from HEAD

Your Environment

  • HEAD
  • rustc 1.65.0 (897e37553 2022-11-02)
  • macOS Monterey 12.6.1

[Bug] Transfer Function doesn't Work

🐛 Bug Report

Created a transfer endpoint on a forked repo -> https://github.com/Entropy1729/aleo/pull/4/files

It seems that are some bugs related to the create_transfer function on the ledger.rs of the client.

  1. The function tries to consume the record with the lowest amount of gates. This generates that when the amount to be transferred is greater than the number of gates of the record, the transfer cannot be carried out. 

This error was resolved by changing min_by to max_by, on the records lookup. 

  1. When a transfer is made, it seems that it consumes a record that is also trying to consume the transfer used to generate transactions, which blocks the generation of blocks.

Steps to Reproduce

Run

curl -X POST http://0.0.0.0:4180/testnet3/transfer -H 'Content-Type: application/json' -d '{"to": "NewAddress", "amount":700000000}'

Stack trace & error message

`Serial number '4089065859010301472916859160003200087111650892897426850644464939793352274911field' already exists in the ledger

🛡️ Produced block 4 (ab16ljf59r3d8t25y6wzqs40z3tm34s8dm3xxt8cjazq53p59v2xcqqpk4qun)

{
"previous_state_root": "3364010905788773857973743228842458740809350980788858797789209934619623548296field",
"transactions_root": "8249325785024399288466739230704435237326997204634167570625238085849968763798field",
"metadata": {
"network": 3,
"round": 4,
"height": 4,
"coinbase_target": 18446744073709551615,
"proof_target": 18446744073709551615,
"timestamp": 1660855184
}
}`

Expected Behavior

It should carry out the transfer and continue the generation of blocks.

Your Environment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.