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

Fixes #10

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ version = "0.1.0"
edition = "2021"

[dependencies]
cairo-lang-sierra = "2.8.0"
cairo-lang-sierra-ap-change = "2.8.0"
cairo-lang-sierra-gas = "2.8.0"
cairo-lang-utils = "2.8.0"
clap = { version = "4.5.16", features = ["derive"] }
cairo-lang-sierra = "2.8.2"
cairo-lang-sierra-ap-change = "2.8.2"
cairo-lang-sierra-gas = "2.8.2"
cairo-lang-utils = "2.8.2"
clap = { version = "4.5.17", features = ["derive"] }
k256 = "0.13.3"
keccak = "0.1.5"
num-bigint = "0.4.6"
num-traits = "0.2.19"
p256 = "0.13.2"
rand = "0.8.5"
sec1 = { version = "0.7.3", features = ["std"] }
serde = { version = "1.0.209", features = ["derive"] }
serde_json = "1.0.127"
serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
sha2 = { version = "0.10.8", features = ["compress"] }
smallvec = "1.13.2"
starknet-crypto = "0.7.1"
starknet-curve = "0.5.0"
starknet-types-core = "0.1.2"
starknet-crypto = "0.7.2"
starknet-curve = "0.5.1"
starknet-types-core = "0.1.5"
thiserror = "1.0.63"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

[dev-dependencies]
cairo-lang-compiler = "2.8.0"
cairo-lang-starknet = "2.8.0"
cairo-lang-compiler = "2.8.2"
cairo-lang-starknet = "2.8.2"

# On dev optimize dependencies a bit so it's not as slow.
[profile.dev.package."*"]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

UNAME := $(shell uname)

CAIRO_2_VERSION=2.8.0
SCARB_VERSION = 2.8.0
CAIRO_2_VERSION=2.8.2
SCARB_VERSION = 2.8.2

needs-cairo2:
ifeq ($(wildcard ./cairo2/.),)
Expand Down
35 changes: 28 additions & 7 deletions src/vm/const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,20 @@ pub fn eval_as_immediate(
[GenericArg::Value(value)] => Value::Felt(value.into()),
_ => unreachable!(),
},
CoreTypeConcrete::NonZero(info) => inner(registry, &info.ty, inner_data),
CoreTypeConcrete::NonZero(_) => match inner_data {
// Copied from the sierra to casm lowering
// NonZero is the same type as the inner type in native.
[GenericArg::Type(inner_ty)] => {
let inner_type = registry.get_type(inner_ty).unwrap();
let const_inner_type = match inner_type {
CoreTypeConcrete::Const(inner) => inner,
_ => unreachable!(),
};

inner(registry, &const_inner_type.inner_ty, &const_inner_type.inner_data)
}
_ => unreachable!(),
Comment on lines +59 to +70
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't it just recursively call inner?

},
CoreTypeConcrete::Sint8(_) => match inner_data {
[GenericArg::Value(value)] => Value::I8(value.try_into().unwrap()),
_ => unreachable!(),
Expand All @@ -70,6 +83,14 @@ pub fn eval_as_immediate(
},
CoreTypeConcrete::Uint128(_) => match inner_data {
[GenericArg::Value(value)] => Value::U128(value.try_into().unwrap()),
x => unreachable!("{:?}", x),
},
CoreTypeConcrete::Uint64(_) => match inner_data {
[GenericArg::Value(value)] => Value::U64(value.try_into().unwrap()),
x => unreachable!("{:?}", x),
},
CoreTypeConcrete::Uint16(_) => match inner_data {
[GenericArg::Value(value)] => Value::U16(value.try_into().unwrap()),
_ => unreachable!(),
},
CoreTypeConcrete::Struct(_) => {
Expand All @@ -80,14 +101,14 @@ pub fn eval_as_immediate(
GenericArg::Type(const_field_ty) => {
let field_type = registry.get_type(const_field_ty).unwrap();

match &field_type {
CoreTypeConcrete::Const(const_ty) => {
let field_value =
inner(registry, &const_ty.inner_ty, &const_ty.inner_data);
fields.push(field_value);
}
let const_field_type = match &field_type {
CoreTypeConcrete::Const(inner) => inner,
_ => unreachable!(),
};

let field_value =
inner(registry, &const_field_type.inner_ty, &const_field_type.inner_data);
fields.push(field_value);
Comment on lines +104 to +111
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between this and the previous code? Why is this better?

}
_ => unreachable!(),
}
Expand Down
2 changes: 2 additions & 0 deletions src/vm/uint252.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ pub fn eval_divmod(

let lhs = u256_to_biguint(lhs_lo, lhs_hi);



Comment on lines +91 to +92
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't pass a formatting check.

let [Value::U128(rhs_lo), Value::U128(rhs_hi)]: [Value; 2] = rhs.try_into().unwrap() else {
panic!()
};
Expand Down