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

[Feature] Support importing local and remote programs. #2881

Merged
merged 121 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
72cf2e7
Add "stub" token
evan-schott Oct 5, 2023
cf7baa0
Update AST to include FunctionStub and Stub
evan-schott Oct 6, 2023
292f890
error msgs
evan-schott Oct 6, 2023
14fc864
test expectations
evan-schott Oct 6, 2023
f906e7f
New tests
evan-schott Oct 12, 2023
ae6fda3
Update AST
evan-schott Oct 12, 2023
61f3d81
New errors
evan-schott Oct 12, 2023
393d9bc
Allow parsing of external types declared in stubs for function signat…
evan-schott Oct 12, 2023
878bbc8
Add stub structs & functions to ST
evan-schott Oct 12, 2023
5441c23
TC stubs
evan-schott Oct 12, 2023
b85c5b2
Make compatible w/ LU and CG passes
evan-schott Oct 12, 2023
bd2e3de
Allow imports & Variant::Function functions in stubs
evan-schott Oct 16, 2023
f1a19b2
rebase fix
evan-schott Nov 4, 2023
bbf1e01
clippy
evan-schott Nov 4, 2023
c809268
add new tests for new import structure, as well as deprecating hardco…
evan-schott Nov 30, 2023
fb56a4f
tests AST changes but bytecode remains the same
evan-schott Nov 30, 2023
0de4e81
revise errors to allow stubs more leeway in parsing
evan-schott Nov 30, 2023
400702e
add finalize_stub field to function_stub AST
evan-schott Nov 30, 2023
89bcb3d
remove stub tokens
evan-schott Nov 30, 2023
43fae97
allow `let a:token.aleo/super_valuable_token = token.aleo/mint_privat…
evan-schott Nov 30, 2023
5347570
deprecate `.leo` imports in parser
evan-schott Nov 30, 2023
d1d5abe
deprecate hardcoded stubs by changing parser
evan-schott Nov 30, 2023
004cc7c
typecheck that finalize_stub
evan-schott Nov 30, 2023
8796e8c
clippy
evan-schott Nov 30, 2023
2b6a358
codegen fix
evan-schott Nov 30, 2023
88b85f8
deprecate `.leo` imports in build system & codegen
evan-schott Nov 30, 2023
aee748b
New errors
evan-schott Oct 12, 2023
1fbc16c
Allow imports & Variant::Function functions in stubs
evan-schott Oct 16, 2023
aa37895
mess
evan-schott Oct 19, 2023
b5a9eed
From traits to from ProgramCore->AST
evan-schott Oct 20, 2023
5ed377e
Small TC fix to forbid record inputs to functions
evan-schott Oct 20, 2023
cc60421
Testing TC error
evan-schott Oct 20, 2023
562d6da
Convert programCore->AST vs string->string
evan-schott Oct 20, 2023
ce160d6
clippy
evan-schott Nov 4, 2023
4775364
proper `Cargo.toml` syntax
evan-schott Nov 30, 2023
6ab9415
Disassemble mappings too
evan-schott Nov 30, 2023
25af3dd
make errors consistent
evan-schott Nov 30, 2023
b3f8169
clippy
evan-schott Nov 30, 2023
11851d4
support arrays as inputs
evan-schott Nov 30, 2023
313a5e4
add finalize
evan-schott Nov 30, 2023
c94c2c3
mapping & nit fix
evan-schott Nov 30, 2023
1b9ac65
mess
evan-schott Oct 19, 2023
8b28c16
Add retriever module
evan-schott Nov 3, 2023
551eb1e
Examples
evan-schott Nov 3, 2023
1aac5ef
Retriever module
evan-schott Nov 3, 2023
26ff2b5
Change disassembler structure
evan-schott Nov 3, 2023
da1419c
Compiler::new() changes
evan-schott Nov 3, 2023
c7d3cf9
Test CLI build command
evan-schott Nov 3, 2023
650d47f
Integrate network retrieval to build system
evan-schott Nov 3, 2023
c44949c
Add new errors
evan-schott Nov 3, 2023
cd3ae36
Clippy fix
evan-schott Nov 3, 2023
3ff41db
Default trait for stubs
evan-schott Nov 3, 2023
184c2f5
Print imports in post order
evan-schott Nov 3, 2023
d5cbd8e
Modify compiler struct
evan-schott Nov 3, 2023
bb960bf
Merge dependencies stated in `program.json` w/ dependencies stated in…
evan-schott Nov 3, 2023
3695ac6
clippy
evan-schott Nov 3, 2023
a55e5e4
post rebase patches
evan-schott Nov 4, 2023
babac66
Working example in . Run test in and to see it in action
evan-schott Nov 4, 2023
931698f
Working example in `utils/tmp/nested`. Run test in `cli.rs` and `retr…
evan-schott Nov 4, 2023
3564389
add proper error checking
evan-schott Nov 8, 2023
ea0fce0
Merge pull request #2972 from AleoHQ/feat/stubs-disassembler
d0cd Dec 1, 2023
b7e6bca
versioning update
evan-schott Dec 2, 2023
51dd617
return stubs in post order from retrieval module
evan-schott Dec 2, 2023
4b3b198
reorganization of errors
evan-schott Dec 2, 2023
94b3290
remove leftover traces of previous import system
evan-schott Dec 2, 2023
20a4278
allow functions to have empty blocks
evan-schott Dec 2, 2023
db20544
merge `program.json` and `.leo` dependencies in `compiler.rs`
evan-schott Dec 2, 2023
565079c
Merge pull request #3374 from AleoHQ/feat/network-retriever
d0cd Dec 2, 2023
81b9001
#15513 Fix bug with parsing U32<N> from string into usize.
arosboro Dec 4, 2023
7aa476f
add tests
evan-schott Dec 5, 2023
0e78e23
fix bug that prevented stubs with no dependencies from being included
evan-schott Dec 5, 2023
16d9e1b
Merge pull request #15822 from AleoHQ/feat/network-retriever
evan-schott Dec 5, 2023
3991d23
Merge pull request #15519 from arosboro/network-retrieval-parse-array
evan-schott Dec 5, 2023
3de2d3f
fix retriever bug
evan-schott Dec 6, 2023
52141fe
fix tests
evan-schott Dec 6, 2023
b3b2102
add new errors
evan-schott Dec 6, 2023
8ea5e3a
fix stub shadowing issue & name mismatch issue
evan-schott Dec 6, 2023
51e3ad9
relax external struct shadowing
evan-schott Dec 6, 2023
54c6020
prevent external calls to .leo programs
evan-schott Dec 6, 2023
1a5a2bb
make retriever backwards compatbile w/ old program.json formatting
evan-schott Dec 6, 2023
9d7c753
consolidate E2E tests
evan-schott Dec 6, 2023
015cc05
new tests
evan-schott Dec 8, 2023
feaceff
allow specification of custom aleo registry
evan-schott Dec 8, 2023
e113def
passes retriever local, network + local&network retrieval unit tests
evan-schott Dec 8, 2023
0d3cff1
new tests
evan-schott Dec 11, 2023
f3d92d0
refactor structs & enums
evan-schott Dec 11, 2023
bc6a003
add local dep support
evan-schott Dec 11, 2023
5e3d244
working integration test
evan-schott Dec 11, 2023
7e0f225
refactor build.rs to support local imports
evan-schott Dec 11, 2023
c2d3c28
new deps
evan-schott Dec 11, 2023
b4dfead
clippy
evan-schott Dec 11, 2023
eb1b011
attempt to patch windows error
evan-schott Dec 11, 2023
3ef3cc3
check style
evan-schott Dec 11, 2023
1090c3e
style
evan-schott Dec 11, 2023
de8b2a2
make example compatible w/ stubs
evan-schott Dec 11, 2023
8afe272
fix a,b,c bug
evan-schott Dec 13, 2023
7954539
use explicit snarkvm commit to avoid bug
evan-schott Dec 16, 2023
6922569
run test
evan-schott Dec 16, 2023
349ba73
fmt
evan-schott Dec 16, 2023
10c06ff
add .env
evan-schott Dec 16, 2023
9d02cef
fix CI
evan-schott Dec 18, 2023
b56de76
leo clean all the tests
evan-schott Dec 18, 2023
55665fd
serial tests
evan-schott Dec 18, 2023
308cd15
fix manifest error
evan-schott Dec 18, 2023
b8370ff
testing framework
evan-schott Dec 18, 2023
1111971
fix non-existent directory error
evan-schott Dec 19, 2023
4a7e429
refactor tests
evan-schott Dec 19, 2023
d5237b6
Make error message more informative
d0cd Dec 25, 2023
033b99f
update retriever
evan-schott Jan 3, 2024
98ea5be
add CLI E2E tests using tempdirs
evan-schott Jan 3, 2024
31105a3
`leo add` CLI tool
evan-schott Jan 3, 2024
9aca0bf
small fix
evan-schott Jan 3, 2024
4370c0c
fix leo new
evan-schott Jan 3, 2024
9939a56
clippy
evan-schott Jan 3, 2024
44ae9e6
style
evan-schott Jan 3, 2024
902387d
Merge branch 'testnet3' into feat/stubs
evan-schott Jan 3, 2024
28dae76
CLI fix
evan-schott Jan 3, 2024
9c3a894
don't proactively remove tmp dir contents
evan-schott Jan 3, 2024
859ecde
clippy
evan-schott Jan 4, 2024
3b79e4f
put tmp clearing as TODO
evan-schott Jan 4, 2024
0bb52d3
Merge branch 'testnet3' into feat/stubs
d0cd Jan 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .circleci/lottery/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env
*.avm
*.prover
*.verifier
outputs/
19 changes: 19 additions & 0 deletions .circleci/lottery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# lottery.aleo

## Run Guide

To run this program, run:
```bash
leo run play

or

./run.sh
```

## Execute Guide

To execute this program, run:
```bash
leo execute play
```
26 changes: 26 additions & 0 deletions .circleci/lottery/build/main.aleo
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
program lottery.aleo;

record Ticket:
owner as address.private;


mapping num_winners:
key as u8.public;
value as u8.public;

function play:
cast self.caller into r0 as Ticket.record;
async play into r1;
output r0 as Ticket.record;
output r1 as lottery.aleo/play.future;

finalize play:
lte block.height 1000u32 into r0;
assert.eq r0 true;
rand.chacha into r1 as boolean;
assert.eq r1 true;
get.or_use num_winners[0u8] 0u8 into r2;
lt r2 5u8 into r3;
assert.eq r3 true;
add r2 1u8 into r4;
set r4 into num_winners[0u8];
6 changes: 6 additions & 0 deletions .circleci/lottery/build/program.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"program": "lottery.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}
2 changes: 2 additions & 0 deletions .circleci/lottery/inputs/lottery.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// The program input for lottery/src/main.leo
[play]
1 change: 1 addition & 0 deletions .circleci/lottery/leo.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package = []
6 changes: 6 additions & 0 deletions .circleci/lottery/program.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"program": "lottery.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}
10 changes: 10 additions & 0 deletions .circleci/lottery/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# First check that Leo is installed.
if ! command -v leo &> /dev/null
then
echo "leo is not installed."
exit
fi

# Run the lottery example
leo run play || exit
30 changes: 30 additions & 0 deletions .circleci/lottery/src/main.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// The 'lottery' program.
program lottery.aleo {

mapping num_winners: u8 => u8;

record Ticket {
owner: address,
}

transition play() -> Ticket {
let ticket: Ticket = Ticket {
owner: self.caller,
};
return ticket then finalize();
}

finalize play() {
// Check that the lottery has not expired.
assert(block.height <= 1000u32);

// Randomly select whether or not the ticket is a winner.
assert(ChaCha::rand_bool());

// Check that the maximum number of winners have not been reached.
let winners: u8 = num_winners.get_or_use(0u8, 0u8);
assert(winners < 5u8);
num_winners.set(0u8, winners + 1u8);

}
}
5 changes: 5 additions & 0 deletions .circleci/tictactoe/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env
*.avm
*.prover
*.verifier
outputs/
82 changes: 82 additions & 0 deletions .circleci/tictactoe/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!-- # ⭕ Tic-Tac-Toe -->

[//]: # (<img alt="workshop/tictactoe" width="1412" src="../.resources/tictactoe.png">)

A standard game of Tic-Tac-Toe in Leo.

⭕ ❕ ⭕ ❕ ❌

➖ ➕ ➖ ➕ ➖

⭕ ❕ ⁣❌ ❕ ⭕

➖ ➕ ➖ ➕ ➖

❌ ❕ ❌ ❕ ⭕

## Representing State
Leo allows users to define composite data types with the `struct` keyword.
The game board is represented by a struct called `Board`, which contains three `Row`s.
An alternative representation would be to use an array, however, these are not yet supported in Leo.

## Language Features
- `struct` declarations
- conditional statements
- early termination. Leo allows users to return from a function early using the `return` keyword.

## Running the Program

Leo provides users with a command line interface for compiling and running Leo programs.
Users may either specify input values via the command line or provide an input file in `inputs/`.

### Providing inputs via the command line.
1. Run
```bash
leo run <function_name> <input_1> <input_2> ...
```
See `./run.sh` for an example.


### Using an input file.
1. Modify `inputs/tictactoe.in` with the desired inputs.
2. Run
```bash
leo run <function_name>
```

## Executing the Program
```bash
leo execute <function_name> <input_1> <input_2> ...
```

## Playing the Game

### 1. Create a new game board
```bash
leo run new
```
| | | |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 0 | 0 |
| 0 | 0 | 0 |

### 2. Player 1 makes a move
```bash
leo run make_move 1u8 1u8 1u8 "{ r1: { c1: 0u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }"
```
| | | |
|---|---|---|
| 1 | 0 | 0 |
| 0 | 0 | 0 |
| 0 | 0 | 0 |

### 3. Player 2 makes a move
```bash
leo run make_move 2u8 2u8 2u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }"
```
| | | |
|---|---|---|
| 1 | 0 | 0 |
| 0 | 2 | 0 |
| 0 | 0 | 0 |
Loading
Loading