From 0d43942dd1ea2e1f0b4c483fa3fa44c3f42b6c34 Mon Sep 17 00:00:00 2001 From: "Mario J. Rugiero" Date: Wed, 11 Jan 2023 08:16:43 -0300 Subject: [PATCH 1/7] Add description and some metadata for crates.io --- Cargo.toml | 10 ++++++---- src/main.rs | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c22f1426b3..e7c9204030 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,12 @@ [workspace] -members = [".", "felt"] +members = [".", "felt", "./deps/parse-hyperlinks"] [package] -name = "cairo-rs" +name = "cairo-vm" version = "0.1.0" edition = "2021" +license = "MIT" +description = "Blazing fast Cairo interpreter" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -37,8 +39,8 @@ generic-array = "0.14.6" # There is a proposal for extending nom::delimited to use this function: # https://github.com/Geal/nom/issues/1253 keccak = "0.1.2" -parse-hyperlinks = { path = "./deps/parse-hyperlinks" } -felt = { path = "./felt" } +parse-hyperlinks = { path = "./deps/parse-hyperlinks", version = "0.23.4" } +felt = { path = "./felt", version = "0.1.0" } [dev-dependencies] iai = "0.1" diff --git a/src/main.rs b/src/main.rs index c56dcc20a0..9ac3bda555 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,9 @@ #![deny(warnings)] -use cairo_rs::cairo_run; -use cairo_rs::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor; -use cairo_rs::vm::errors::cairo_run_errors::CairoRunError; -use cairo_rs::vm::errors::runner_errors::RunnerError; -use cairo_rs::vm::errors::trace_errors::TraceError; +use cairo_vm::cairo_run; +use cairo_vm::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor; +use cairo_vm::vm::errors::cairo_run_errors::CairoRunError; +use cairo_vm::vm::errors::runner_errors::RunnerError; +use cairo_vm::vm::errors::trace_errors::TraceError; use clap::{Parser, ValueHint}; use std::path::PathBuf; From 9e24b9c6381d6ed3cebb1663b1fb5a072a713898 Mon Sep 17 00:00:00 2001 From: "Mario J. Rugiero" Date: Wed, 11 Jan 2023 08:28:07 -0300 Subject: [PATCH 2/7] Description and license for Felt --- felt/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/felt/Cargo.toml b/felt/Cargo.toml index 6219284db6..668d8db889 100644 --- a/felt/Cargo.toml +++ b/felt/Cargo.toml @@ -2,6 +2,8 @@ name = "felt" version = "0.1.0" edition = "2021" +license = "MIT" +description = "Field elements representation for the Cairo VM" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From c6b6858cf492cf2827a4e4b990b5d4df46fb0cfa Mon Sep 17 00:00:00 2001 From: "Mario J. Rugiero" Date: Wed, 11 Jan 2023 08:33:05 -0300 Subject: [PATCH 3/7] Rename Felt crate --- felt/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/felt/Cargo.toml b/felt/Cargo.toml index 668d8db889..bf16f0c713 100644 --- a/felt/Cargo.toml +++ b/felt/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "felt" +name = "cairo-felt" version = "0.1.0" edition = "2021" license = "MIT" From cfd56ad0eb18e1607492f80372d8734795d90b43 Mon Sep 17 00:00:00 2001 From: "Mario J. Rugiero" Date: Wed, 11 Jan 2023 08:35:03 -0300 Subject: [PATCH 4/7] Pin deps --- felt/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/felt/Cargo.toml b/felt/Cargo.toml index bf16f0c713..3c30cf4b59 100644 --- a/felt/Cargo.toml +++ b/felt/Cargo.toml @@ -8,10 +8,10 @@ description = "Field elements representation for the Cairo VM" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -num-integer = "*" +num-integer = "0.1.45" num-bigint = { version = "0.4", features = ["serde"] } -num-traits = "*" -lazy_static = "*" +num-traits = "0.2.15" +lazy_static = "1.4.0" serde = { version = "1.0", features = ["derive"] } [dev-dependencies] From c4feec496bd4bfa9e15e2f61bb0cf841284ff33d Mon Sep 17 00:00:00 2001 From: "Mario J. Rugiero" Date: Wed, 11 Jan 2023 08:37:45 -0300 Subject: [PATCH 5/7] Fixes to Cargo.toml --- Cargo.lock | 28 ++++++++++++++-------------- Cargo.toml | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e1f72e3d7..30be52c996 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -163,13 +163,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] -name = "cairo-rs" +name = "cairo-felt" +version = "0.1.0" +dependencies = [ + "lazy_static", + "num-bigint", + "num-integer", + "num-traits", + "proptest", + "serde", +] + +[[package]] +name = "cairo-vm" version = "0.1.0" dependencies = [ "bincode", + "cairo-felt", "clap 3.2.15", "criterion", - "felt", "generic-array", "hex", "iai", @@ -468,18 +480,6 @@ dependencies = [ "instant", ] -[[package]] -name = "felt" -version = "0.1.0" -dependencies = [ - "lazy_static", - "num-bigint", - "num-integer", - "num-traits", - "proptest", - "serde", -] - [[package]] name = "fnv" version = "1.0.7" diff --git a/Cargo.toml b/Cargo.toml index e7c9204030..984641c935 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,14 +33,14 @@ nom = "7" sha2 = {version="0.10.2", features=["compress"]} thiserror = "1.0.32" generic-array = "0.14.6" +keccak = "0.1.2" # This crate has only one function `take_until_unbalanced` that is # very useful for our parsing purposes: # https://stackoverflow.com/questions/70630556/parse-allowing-nested-parentheses-in-nom # There is a proposal for extending nom::delimited to use this function: # https://github.com/Geal/nom/issues/1253 -keccak = "0.1.2" parse-hyperlinks = { path = "./deps/parse-hyperlinks", version = "0.23.4" } -felt = { path = "./felt", version = "0.1.0" } +felt = { package = "cairo-felt", path = "./felt", version = "0.1.0" } [dev-dependencies] iai = "0.1" From 1dbed69830a2b15c10af3882ef98722a2971a089 Mon Sep 17 00:00:00 2001 From: "Mario J. Rugiero" Date: Wed, 11 Jan 2023 09:00:06 -0300 Subject: [PATCH 6/7] Fix references to cairo_rs --- bench/criterion_benchmark.rs | 2 +- bench/iai_benchmark.rs | 2 +- custom_hint_example/src/main.rs | 14 +++++++------- .../builtin_hint_processor/README.md | 4 ++-- tests/bitwise_test.rs | 2 +- tests/cairo_run_test.rs | 4 ++-- tests/pedersen_test.rs | 2 +- tests/struct_test.rs | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bench/criterion_benchmark.rs b/bench/criterion_benchmark.rs index da324f8891..64188bf3a7 100644 --- a/bench/criterion_benchmark.rs +++ b/bench/criterion_benchmark.rs @@ -1,6 +1,6 @@ use std::path::Path; -use cairo_rs::{ +use cairo_vm::{ cairo_run, hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor, }; diff --git a/bench/iai_benchmark.rs b/bench/iai_benchmark.rs index 12c39af70b..970738faed 100644 --- a/bench/iai_benchmark.rs +++ b/bench/iai_benchmark.rs @@ -1,6 +1,6 @@ use std::path::Path; -use cairo_rs::{ +use cairo_vm::{ cairo_run::cairo_run, hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor, vm::errors::cairo_run_errors::CairoRunError, vm::runners::cairo_runner::CairoRunner, diff --git a/custom_hint_example/src/main.rs b/custom_hint_example/src/main.rs index 8b102d263e..7486752864 100644 --- a/custom_hint_example/src/main.rs +++ b/custom_hint_example/src/main.rs @@ -1,12 +1,12 @@ -use cairo_rs::cairo_run::cairo_run; -use cairo_rs::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::{ +use cairo_vm::cairo_run::cairo_run; +use cairo_vm::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::{ BuiltinHintProcessor, HintFunc, }; -use cairo_rs::hint_processor::builtin_hint_processor::hint_utils::get_integer_from_var_name; -use cairo_rs::hint_processor::hint_processor_definition::HintReference; -use cairo_rs::types::exec_scope::ExecutionScopes; -use cairo_rs::serde::deserialize_program::ApTracking; -use cairo_rs::vm::{errors::hint_errors::HintError, vm_core::VirtualMachine}; +use cairo_vm::hint_processor::builtin_hint_processor::hint_utils::get_integer_from_var_name; +use cairo_vm::hint_processor::hint_processor_definition::HintReference; +use cairo_vm::types::exec_scope::ExecutionScopes; +use cairo_vm::serde::deserialize_program::ApTracking; +use cairo_vm::vm::{errors::hint_errors::HintError, vm_core::VirtualMachine}; use num_bigint::BigInt; use std::collections::HashMap; use std::path::Path; diff --git a/docs/hint_processor/builtin_hint_processor/README.md b/docs/hint_processor/builtin_hint_processor/README.md index f358b888b5..4794db11d1 100644 --- a/docs/hint_processor/builtin_hint_processor/README.md +++ b/docs/hint_processor/builtin_hint_processor/README.md @@ -60,7 +60,7 @@ let hint = HintFunc(Box::new(print_a_hint)); #### Step 3: Instantiate the BuiltinHintProcessor and add your custom hint implementation Import the BuiltinHintProcessor from cairo-rs, instantiate it using the `new_empty()` method and the add your custom hint implementation using the method `add_hint` ```rust -use cairo_rs::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor +use cairo_vm::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor let mut hint_processor = BuiltinHintProcessor::new_empty(); hint_processor.add_hint(String::from("print(ids.a)"), hint); @@ -71,7 +71,7 @@ You can also create a dictionary of HintFunc and use the method `new()` to creat Import the function cairo_run from cairo-rs, and run your compiled program ```rust -use cairo_rs::cairo_run::cairo_run; +use cairo_vm::cairo_run::cairo_run; cairo_run( Path::new("custom_hint.json"), "main", diff --git a/tests/bitwise_test.rs b/tests/bitwise_test.rs index 8251d01676..adba4f6597 100644 --- a/tests/bitwise_test.rs +++ b/tests/bitwise_test.rs @@ -1,4 +1,4 @@ -use cairo_rs::{ +use cairo_vm::{ hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor, types::program::Program, vm::{ diff --git a/tests/cairo_run_test.rs b/tests/cairo_run_test.rs index 66e7abb311..126c40eb41 100644 --- a/tests/cairo_run_test.rs +++ b/tests/cairo_run_test.rs @@ -1,5 +1,5 @@ -use cairo_rs::cairo_run; -use cairo_rs::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor; +use cairo_vm::cairo_run; +use cairo_vm::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor; use std::path::Path; #[test] diff --git a/tests/pedersen_test.rs b/tests/pedersen_test.rs index 7e52fc4837..4836a1f263 100644 --- a/tests/pedersen_test.rs +++ b/tests/pedersen_test.rs @@ -1,6 +1,6 @@ use std::path::Path; -use cairo_rs::{ +use cairo_vm::{ hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor, types::program::Program, vm::trace::trace_entry::RelocatedTraceEntry, diff --git a/tests/struct_test.rs b/tests/struct_test.rs index 94356916b1..1915ed3734 100644 --- a/tests/struct_test.rs +++ b/tests/struct_test.rs @@ -1,10 +1,10 @@ -use cairo_rs::{ +use cairo_vm::{ hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor, vm::vm_core::VirtualMachine, }; use std::path::Path; -use cairo_rs::{ +use cairo_vm::{ types::program::Program, vm::{runners::cairo_runner::CairoRunner, trace::trace_entry::RelocatedTraceEntry}, }; From 7d1fa851a16177829898472f958b85feb4786662 Mon Sep 17 00:00:00 2001 From: "Mario J. Rugiero" Date: Wed, 11 Jan 2023 09:07:13 -0300 Subject: [PATCH 7/7] Bump crate version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 984641c935..0180336b0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = [".", "felt", "./deps/parse-hyperlinks"] [package] name = "cairo-vm" -version = "0.1.0" +version = "0.1.1" edition = "2021" license = "MIT" description = "Blazing fast Cairo interpreter"