Skip to content

Commit 5726e87

Browse files
Merge pull request #540 from ProvableHQ/update/11-7-25
Leo v3.3.0
2 parents 6e149a4 + b2099f2 commit 5726e87

File tree

13 files changed

+3508
-2579
lines changed

13 files changed

+3508
-2579
lines changed

documentation/cli/00_overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ You can print the list of commands by running `leo --help`
4343
## Universal Flags
4444
These flags are available to use alongside all commands in the Leo CLI.
4545

46-
#### `-h`
4746
#### `--help`
47+
#### `-h`
4848
Prints available commands and flags.
4949

50-
#### `-V`
5150
#### `--version`
51+
#### `-V`
5252
Prints the currently installed version of Leo.
5353

5454
#### `-q`

documentation/cli/02_add.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ Do not use this feature unless you know what you are doing!
5252
Specifies that the imported program is a development dependency and should not be used in production
5353

5454

55-
56-
#### `-c`
5755
#### `--clear`
56+
#### `-c`
5857
Clears all previous dependencies.
5958

6059
:::warning

documentation/cli/06_deploy.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ Saves the transaction to the directory located at the `<SAVE>` path.
119119
#### `--skip <SUBSTRING_0> <SUBSTRING_1> ...`
120120
Skips deployment of any program that contains one of the given substrings, delimited by a space.
121121

122-
#### `-y`
123122
#### `--yes`
123+
#### `-y`
124124
The CLI will ask for manual confirmation on several steps throughout the deployment process. Setting this flag automatically agrees to all confirmations.
125125

126126
:::warning
@@ -135,9 +135,8 @@ Specifes the priority fee for the deployment transaction(s) delimited by `|` and
135135
:::
136136

137137

138-
#### `-f <FEE_RECORDS>`
139138
#### `--fee-records <FEE_RECORDS>`
140-
139+
#### `-f <FEE_RECORDS>`
141140
Specifes the record(s) to pay for fees privately, delimited by `|` and used in order. The fees must either be valid plaintext, ciphertext, or `default`. If not specified, then transaction fees will be public.
142141

143142

documentation/cli/08_execute.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ Broadcasts the transaction to the network upon successful execution. Without pa
116116
#### `--save <SAVE>`
117117
Saves the transaction to the directory located at the `<SAVE>` path.
118118

119-
#### `-y`
120119
#### `--yes`
120+
#### `-y`
121121
The CLI will ask for manual confirmation on several steps throughout the deployment process. Setting this flag automatically agrees to all confirmations.
122122

123123
:::warning
@@ -131,10 +131,8 @@ Specifes the priority fee for the deployment transaction(s) delimited by `|` and
131131
1 Credit == 1,000,000 Microcreditss
132132
:::
133133

134-
135-
#### `-f <FEE_RECORDS>`
136134
#### `--fee-records <FEE_RECORDS>`
137-
135+
#### `-f <FEE_RECORDS>`
138136
Specifes the record(s) to pay for fees privately, delimited by `|` and used in order. The fees must either be valid plaintext, ciphertext, or `default`. If not specified, then transaction fees will be public.
139137

140138

documentation/cli/14_update.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ leo update --name v3.0.0
3030
```
3131

3232
### Flags:
33-
#### `-l`
3433
#### `--list`
34+
#### `-l`
3535
Lists all available versions of Leo.
3636

37-
#### `-n`
3837
#### `--name`
38+
#### `-n`
3939
An optional release name if you wish to install a specific version of Leo. By default, the command will look for the latest release.
4040

documentation/cli/15_upgrade.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ Broadcasts the transaction to the network upon successful execution. Without pa
5252
#### `--save <SAVE>`
5353
Saves the transaction to the directory located at the `<SAVE>` path.
5454

55-
#### `-y`
5655
#### `--yes`
56+
#### `-y`
5757
The CLI will ask for manual confirmation on several steps throughout the deployment process. Setting this flag automatically agrees to all confirmations.
5858

5959
:::warning
@@ -67,10 +67,8 @@ Specifes the priority fee for the deployment transaction(s) delimited by `|` and
6767
1 Credit == 1,000,000 Microcreditss
6868
:::
6969

70-
71-
#### `-f <FEE_RECORDS>`
7270
#### `--fee-records <FEE_RECORDS>`
73-
71+
#### `-f <FEE_RECORDS>`
7472
Specifes the record(s) to pay for fees privately, delimited by `|` and used in order. The fees must either be valid plaintext, ciphertext, or `default`. If not specified, then transaction fees will be public.
7573

7674

documentation/cli/16_synthesize.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
id: cli_synthesize
3+
title: ""
4+
sidebar_label: Synthesize
5+
toc_min_heading_level: 2
6+
toc_max_heading_level: 2
7+
---
8+
[general tags]: # (cli, synthesize, proving, verifying, keys, circuit)
9+
10+
# `leo synthesize`
11+
12+
This command is used to generate proving and verifying keys for all transitions in a local or remote Leo program, along with circuit metadata.
13+
14+
```bash
15+
leo synthesize <PROGRAM_NAME> --save <SAVE_DIRECTORY>
16+
```
17+
18+
Each output of this command includes:
19+
- Number of public inputs
20+
- Number of variables
21+
- Number of constraints
22+
- Non-zero entries in matrices
23+
- Circuit ID
24+
- Proving and verifying keys saved to disk
25+
26+
This enables better understanding of program size and key management.
27+
28+
### Flags:
29+
30+
#### `--network <NETWORK>`
31+
Specifies the network to deploy to. Overrides any `NETWORK` environment variable set manually or in a `.env` file. Valid network names are `testnet`, `mainnet`, and `canary`.
32+
33+
#### `--endpoint <ENDPOINT>`
34+
The endpoint to deploy to. Overrides any `ENDPOINT` environment variable set manually or in a `.env` file.
35+
36+
#### `--local`
37+
#### `-l`
38+
Specifies that the keys should be generated for the local Leo project in the current working directory.
39+
40+
#### `--skip <SKIP>`
41+
#### `-s <SKIP>`
42+
Specifies to skip the key generation for any function names that contain the provided substrings
43+
44+
45+
#### `--save <SAVE_DIRECTORY>`
46+
The directory to save the key files to. If the provided path does not exist, it will be created in your current working directory.

documentation/language/02_structure.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,27 @@ program hello.aleo { }
125125
### Mappings
126126

127127
A mapping is declared as `mapping {name}: {key-type} => {value-type}`.
128-
Mappings contain key-value pairs.
129-
Mappings are stored on chain.
128+
Mappings contain key-value pairs and stored on chain.
130129

131-
```leo showLineNumbers
130+
```leo
132131
// On-chain storage of an `account` mapping,
133132
// with `address` as the type of keys,
134133
// and `u64` as the type of values.
135134
mapping account: address => u64;
136135
```
137136

137+
### Storage
138+
A storage variable is declared as `storage {name}: {type}`. Storage variables contain singleton values. They are declared at program scope and are stored on chain, similar to mappings.
139+
```leo
140+
// On-chain storage of an `counter` storage variable of type u32,
141+
storage counter: u32;
142+
```
143+
A storage vector is declared as `storage {name}: [{type}]`. Storage vectors contain dynamic lists of values of a given type. They are declared at program scope and are stored on chain, similar to mappings.
144+
```leo
145+
// On-chain storage of an `accounts` storage vector of type address,
146+
storage accounts: [address];
147+
```
148+
138149
### Struct
139150

140151
A struct data type is declared as `struct {name} {}`.

documentation/language/03_data_types.md

Lines changed: 58 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,6 @@ sidebar_label: Data Types
55
---
66
[general tags]: # (boolean, integer, field, group, scalar, address, signature, array, tuple, struct)
77

8-
## Type Inference
9-
As of v2.7.0, Leo supports type inference. The Leo compiler is able to infer the types of declared variables and expressions as long as the type can be **unambiguously determined** from the surrounding context.
10-
11-
If the compiler cannot infer the type, you must provide an explicit type annotation.
12-
13-
Here are some examples:
14-
```leo
15-
let a: u8 = 2u8; // explicit type - allowed
16-
let b = 2u8; // type inference - allowed
17-
let c : u8 = 2; // type inference - allowed
18-
19-
let d = 2; // ambiguous type - not allowed
20-
```
21-
22-
Type inference also applies to members within a struct:
23-
```leo
24-
struct Foo {
25-
x: u8
26-
}
27-
28-
let f = Foo {
29-
x: 5, // inferred to be a `u8`
30-
};
31-
```
32-
338

349
## Types
3510

@@ -61,20 +36,19 @@ let n: u64 = 1_000_000u64;
6136
Higher bit length integers generate more constraints in the circuit, which can slow down computation time.
6237
:::
6338

64-
#### A Note on Leo Integers
65-
39+
:::info
6640
Leo does not assume a default integer type. Every integer must either have an **explicit type annotation** or a type that can be **inferred by the compiler**.
6741

6842
```leo
6943
let a: u8 = 2u8; // explicit type
7044
let b: u16 = a as u16; // type casting
7145
```
46+
:::
7247

7348
### Field Elements
7449

7550
Leo supports the `field` type for elements of the base field of the elliptic curve.
76-
These are unsigned integers less than the modulus of the base field. The following are the
77-
smallest and largest field elements.
51+
These are unsigned integers less than the modulus of the base field. The following are the smallest and largest field elements.
7852

7953
```leo
8054
let a: field = 0field;
@@ -260,3 +234,58 @@ struct Matrix::[N: u32, M: u32] {
260234
let m = Matrix::[2, 2] { data: [0, 1, 2, 3] };
261235
```
262236
Note that generic structs cannot currently be imported outside a program, but can be declared and used in submodules. Acceptable types for const generic parameters include integer types, `bool`, `scalar`, `group`, `field`, and `address`.
237+
238+
## Option Types
239+
As of v3.3.0, Leo supports first-class option types using the `T?` syntax, where `T` is any of the types previously mentioned, excluding `address`, `signature`, and `tuple`. A value of type `T?` can be initialized into two states: either a value of type `T`, or `none`:
240+
```leo
241+
let w: u8? = 42u8;
242+
let x: u8? = none;
243+
```
244+
A value of type `T?` can be converted to type `T` by calling the `.unwrap()` method on the value. Note that if the value being unwrapped is `none`, then the program will fail to execute. To unwrap the value with a fallback for this case, call the `.unwrap_or()` method:
245+
```leo
246+
let y = w.unwrap(); // Returns 42u8
247+
let z = x.unwrap_or(99u8); // Returns 99u8
248+
```
249+
Option types can also be stored in arrays and structs:
250+
```leo
251+
// Struct of options
252+
struct Point {
253+
x: u32?,
254+
y: u32?
255+
}
256+
257+
// Array of options
258+
let arr: [u16?; 2] = [1u16, none];
259+
let first_val = arr[0].unwrap(); // Returns 1u16
260+
let second_val = arr[1].unwrap_or(0u16); // Returns 0u16
261+
262+
// Structs have option variant as well
263+
let p: Point? = none;
264+
let p_val = p.unwrap_or(Point { x: 0u32, y: none }); // Returns default
265+
```
266+
267+
## Type Inference
268+
As of v2.7.0, Leo supports type inference. The Leo compiler is able to infer the types of declared variables and expressions as long as the type can be **unambiguously determined** from the surrounding context.
269+
270+
If the compiler cannot infer the type, you must provide an explicit type annotation.
271+
272+
Here are some examples:
273+
```leo
274+
let a: u8 = 2u8; // explicit type - allowed
275+
let b = 2u8; // type inference - allowed
276+
let c : u8 = 2; // type inference - allowed
277+
278+
let d = 2; // ambiguous type - not allowed
279+
```
280+
281+
Type inference also applies to members within a struct:
282+
```leo
283+
struct Foo {
284+
x: u8
285+
}
286+
287+
let f = Foo {
288+
x: 5, // inferred to be a `u8`
289+
};
290+
```
291+

0 commit comments

Comments
 (0)