Skip to content

Commit

Permalink
Merge branch 'SNOS_contract_support'
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed May 29, 2024
2 parents 80fbb3e + 6299ade commit 9692cba
Show file tree
Hide file tree
Showing 25 changed files with 3,155 additions and 231 deletions.
3 changes: 2 additions & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
scarb 2.6.3
scarb 2.6.3
starknet-foundry 0.24.0
61 changes: 37 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,57 @@ To set up the project environment and run the bootloader, follow these steps:

3. **Cairo1 Compilation**: Convert Cairo1 Scarb projects into the Sierra format by running `python compile.py`.

4. **Running the Bootloader**: Start the bootloader with `python run.py`, which will load and execute the compiled Cairo1 program within the Cairo0 environment.
4. **Running the Bootloader**: Start the bootloader with `python run.py`, which will load and execute the compiled Cairo1 contract within the Cairo0 environment.

---

This example showcases the exchange of data between a Cairo0 host provable environment and a Cairo1 program:
This example showcases merge of Cairo0 host provable environment and a Cairo1 developer frendly language:

```cairo
#[derive(Drop, Serde)]
struct Input {
a: u32,
b: u32,
c: u32,
#[starknet::interface]
pub trait IHelloBootloader<TContractState> {
fn main(ref self: TContractState, input: Array<felt252>) -> Array<felt252>;
}
struct Output {
a_2: u32,
b_2: u32,
c_2: u32,
}
#[starknet::contract]
mod HelloBootloader {
#[derive(Drop, Serde)]
struct Input {
a: u32,
b: u32,
c: u32,
}
#[derive(Drop, Serde)]
struct Output {
a_2: u32,
b_2: u32,
c_2: u32,
}
#[storage]
struct Storage {}
fn main(input: Array<felt252>) -> Output {
let mut input_span = input.span();
let input = Serde::<Input>::deserialize(ref input_span).unwrap();
#[abi(embed_v0)]
impl HelloBootloaderImpl of super::IHelloBootloader<ContractState> {
fn main(ref self: ContractState, input: Array<felt252>) -> Array<felt252> {
let mut input_span = input.span();
let input = Serde::<Input>::deserialize(ref input_span).unwrap();
let a_2 = input.a * input.a;
let b_2 = input.b * input.b;
let c_2 = input.c * input.c;
assert (a_2 + b_2 == c_2, 'invalid value');
let a_2 = input.a * input.a;
let b_2 = input.b * input.b;
let c_2 = input.c * input.c;
assert(a_2 + b_2 == c_2, 'invalid value');
Output {
a_2,
b_2,
c_2,
let mut output = array![];
Output { a_2, b_2, c_2, }.serialize(ref output);
output
}
}
}
```

The Cairo0 bootloader's execution can be verified using a STARK prover like [stone-prover](https://github.com/starkware-libs/stone-prover).
The Cairo0 bootloader's execution can be proven using a STARK prover like [stone-prover](https://github.com/starkware-libs/stone-prover).

## Work in Progress

Expand Down
Loading

0 comments on commit 9692cba

Please sign in to comment.