Skip to content

Remove ignores #1258

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions docs/execution_walkthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Given the following Cairo program:

```rust,ignore
```rust
// This is the cairo program. It just adds two numbers together and returns the
// result in an enum whose variant is selected using the result's parity.
enum Parity<T> {
Expand All @@ -22,7 +22,7 @@ fn run(lhs: u128, rhs: u128) -> Parity<u128> {

Let's see how it is executed. We start with the following Rust code:

```rust,ignore
```rust
let program = get_sierra_program(); // The result of the `cairo-compile` program.
let module = get_native_module(&program); // This compiles the Sierra program to
// MLIR (not covered here).
Expand All @@ -34,7 +34,7 @@ Given a compiled Cairo program in an MLIR module, once it is lowered to the LLVM
### Using the JIT executor
If we decide to use the JIT executor we just create the jit runner and we're done.

```rust,ignore
```rust
let program = get_sierra_program();
let module = get_native_module(&program);

Expand All @@ -47,7 +47,7 @@ let engine = JitNativeExecutor::from_native_module(module, OptLevel::Default);
### Using the AOT executor
Preparing the AOT executor is more complicated since we need to compile it into a shared library and load it from disk.

```rust,ignore
```rust
let program = get_sierra_program();
let module = get_native_module(&program);

Expand All @@ -61,7 +61,7 @@ You can use caches to keep the compiled programs in memory or disk and reuse the

Adding programs to the program cache involves steps not covered here, but once they're inserted you can get executors like this:

```rust,ignore
```rust
let engine = program_cache.get(key).expect("program not found");
```

Expand All @@ -74,7 +74,7 @@ In a future we may be able to implement compile-time trampolines for known progr

Now we need to find the function id:

```rust,ignore
```rust
let program = get_sierra_program();

// The utility function needs the symbol of the entry point, which is built as
Expand All @@ -88,7 +88,7 @@ let function_id = find_function_id(&program, "program::program::main(f0)");

The arguments must be placed in a list of `JitValue` instances. The builtins should be ignored since they are filled in automatically. The only builtins required are the `GasBuiltin` and `System` (aka. the syscall handler). They are only mandatory when required by the program itself.

```rust,ignore
```rust
let engine = get_execution_engine(); // This creates the execution engine (covered before).

let args = [
Expand All @@ -101,7 +101,7 @@ let args = [

Finally we can invoke the program like this:

```rust,ignore
```rust
let engine = get_execution_engine();

let function_id = find_function_id(&program, "program::program::main(f0)");
Expand All @@ -127,7 +127,7 @@ println!("Builtin stats: {:?}", execution_result.builtin_stats);

Running the code above should print the following:

```rust,ignore
```rust
Remaining gas: None
Return value: Enum {
tag: 0,
Expand Down Expand Up @@ -157,15 +157,15 @@ Builtin stats: BuiltinStats { bitwise: 1, ec_op: 0, range_check: 1, pedersen: 0,
### Contracts
Contracts always have the same interface, therefore they have an alternative to `invoke_dynamic` called `invoke_contract_dynamic`.

```rust,ignore
```rust
fn(Span<felt252>) -> PanicResult<Span<felt252>>;
```

This wrapper will attempt to deserialize the real contract arguments from the span of felts, invoke the contracts, and finally serialize and return the result. When this deserialization fails, the contract will panic with the mythical `Failed to deserialize param #N` error.

If the example program had the same interface as a contract (a span of felts) then it'd be invoked like this:

```rust,ignore
```rust
let engine = get_execution_engine();

let function_id = find_function_id(&program, "program::program::main(f0)");
Expand Down
6 changes: 3 additions & 3 deletions docs/gas_builtin_accounting.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ amount being withdrawn.
### Example
Let's illustrate this with a simple example using the following Cairo 1 code:

```rust,ignore
```rust
fn run_test() {
let mut i: u8 = 0;
let mut val = 0;
Expand Down Expand Up @@ -131,7 +131,7 @@ returned by the function. This is accomplished when
[parsing the return values](https://github.com/lambdaclass/cairo_native/blob/65face8194054b7ed396a34a60e7b1595197543a/src/executor.rs#L286)
from the function call:

```rust,ignore
```rust
...
for type_id in &function_signature.ret_types {
let type_info = registry.get_type(type_id).unwrap();
Expand Down Expand Up @@ -174,7 +174,7 @@ called from within the program.
### Example
Let us consider the following Cairo program which uses the `pedersen` builtin:

```rust,ignore
```rust
use core::integer::bitwise;
use core::pedersen::pedersen;

Expand Down
4 changes: 2 additions & 2 deletions docs/implementing_libfuncs.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Libfuncs are implemented under `src/libfuncs.rs` and

Using the `src/libfuncs/felt252.rs` libfuncs as a aid:

```rust,ignore
```rust
/// Select and call the correct libfunc builder function from the selector.
pub fn build<'ctx, 'this>(
context: &'ctx Context,
Expand Down Expand Up @@ -100,7 +100,7 @@ the `src/libfuncs.rs` match statement.
### Example libfunc implementation: u8_to_felt252
An example libfunc, converting a u8 to a felt252, extensively commented:

```rust,ignore
```rust
/// Generate MLIR operations for the `u8_to_felt252` libfunc.
pub fn build_to_felt252<'ctx, 'this>(
// The Context from MLIR, this is like the heart of the MLIR API, its required to create most stuff like types.
Expand Down
6 changes: 3 additions & 3 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ lowering to LLVM.
compiled sierra programs from an entrypoint. Programs and JIT states can be
cached in contexts where their execution will be done multiple times.

```rust,ignore
```rust
use starknet_types_core::felt::Felt;
use cairo_native::context::NativeContext;
use cairo_native::executor::JitNativeExecutor;
Expand Down Expand Up @@ -196,7 +196,7 @@ execute a program using the JIT.

Example code to run a program:

```rust,ignore
```rust
use starknet_types_core::felt::Felt;
use cairo_native::context::NativeContext;
use cairo_native::executor::NativeExecutor;
Expand Down Expand Up @@ -239,7 +239,7 @@ fn main() {

Example code to run a Starknet contract:

```rust,ignore
```rust
use starknet_types_core::felt::Felt;
use cairo_lang_compiler::CompilerConfig;
use cairo_lang_starknet::contract_class::compile_path;
Expand Down
2 changes: 1 addition & 1 deletion src/metadata/debug_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
//! ## Example
//!
//! ```rust,ignore
//! ```rust
//! # use cairo_lang_sierra::{
//! # extensions::{
//! # core::{CoreLibfunc, CoreType},
Expand Down
Loading