Skip to content
Merged
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
65ab4fa
Add sierra-emu as a debug utility
gabrielbosio Apr 11, 2025
baf9b00
Change working dir in sierra-emu job
gabrielbosio Apr 11, 2025
11696b3
Merge branch 'main' into add_debug_utils
gabrielbosio Apr 14, 2025
8caf292
Remove repeated lines in sierra-emu gitignore
gabrielbosio Apr 14, 2025
758c981
Exclude debug_utils from coverage job
gabrielbosio Apr 14, 2025
53343db
remove some todos from value and implement Coupon libfunc
FrancoGiachetta Apr 21, 2025
37494f2
start adding corelib test
FrancoGiachetta Apr 21, 2025
c7f6e0c
run tests from corelib
FrancoGiachetta Apr 22, 2025
de3a0bf
merge main
FrancoGiachetta Apr 22, 2025
a664894
remove unwanted file
FrancoGiachetta Apr 22, 2025
0464dfc
remove not related things
FrancoGiachetta Apr 22, 2025
30c6191
get return_value from trace
FrancoGiachetta Apr 23, 2025
40f0ed9
replace ids for debug info
FrancoGiachetta Apr 23, 2025
144a7ac
add common folder for integration tests
FrancoGiachetta Apr 23, 2025
60ac288
fix tests
FrancoGiachetta Apr 23, 2025
e18a55d
remove todo
FrancoGiachetta Apr 23, 2025
21b75aa
ignore test for now
FrancoGiachetta Apr 23, 2025
be29058
add enum in const::inner
FrancoGiachetta Apr 23, 2025
c5e5355
remove todos and fix some failures
FrancoGiachetta Apr 24, 2025
612b471
filter ignored tests
FrancoGiachetta Apr 24, 2025
3b34455
Update debug_utils/sierra-emu/tests/common/mod.rs
FrancoGiachetta Apr 24, 2025
d7642af
Merge branch 'test-corelib' of github.com:lambdaclass/cairo_native in…
FrancoGiachetta Apr 24, 2025
973a7db
run ignored test from the ci
FrancoGiachetta Apr 24, 2025
035ff56
better ignoring
FrancoGiachetta Apr 24, 2025
5fd9009
Merge branch 'test-corelib' into sierra-emu-add-some-libfs
FrancoGiachetta Apr 24, 2025
6acc0c2
ignore test
FrancoGiachetta Apr 24, 2025
1ab6479
fmt
FrancoGiachetta Apr 24, 2025
b325655
remove debug_name in enums
FrancoGiachetta Apr 24, 2025
fa74ff1
refactor
FrancoGiachetta Apr 24, 2025
8e8c03f
remove unused dependency
FrancoGiachetta Apr 24, 2025
5198de6
Merge branch 'test-corelib' into sierra-emu-add-some-libfs
FrancoGiachetta Apr 24, 2025
0b5f319
More expressive naming for the workflow
FrancoGiachetta Apr 24, 2025
6164b39
reviews
FrancoGiachetta Apr 25, 2025
ca359b2
Merge branch 'test-corelib' of github.com:lambdaclass/cairo_native in…
FrancoGiachetta Apr 25, 2025
1cd02e9
reviews
FrancoGiachetta Apr 25, 2025
f1b40d0
fmt
FrancoGiachetta Apr 25, 2025
48fb545
fmt ci
FrancoGiachetta Apr 25, 2025
7b9c99c
revert last commit
FrancoGiachetta Apr 25, 2025
986dafa
fmt
FrancoGiachetta Apr 25, 2025
f0e90c7
accidentally removed rayon usage
FrancoGiachetta Apr 25, 2025
51ff8ea
avoid map's short-circuiting
FrancoGiachetta Apr 25, 2025
6083538
catch panics the avoid loosing the test name
FrancoGiachetta Apr 25, 2025
47a346a
Merge branch 'main' into test-corelib
FrancoGiachetta Apr 25, 2025
4912309
log ignored tests
FrancoGiachetta Apr 25, 2025
eb3749b
clippy
FrancoGiachetta Apr 25, 2025
50a4dde
Add "(WIP)" to corelib's test job
FrancoGiachetta Apr 28, 2025
ef4fda9
Merge branch 'main' into sierra-emu-add-some-libfs
FrancoGiachetta Apr 28, 2025
ee6b5f7
print progress as the test runs
FrancoGiachetta Apr 28, 2025
3802add
print results as tests run
FrancoGiachetta Apr 28, 2025
1f3bf94
fmt
FrancoGiachetta Apr 28, 2025
d1ec743
format makefile
FrancoGiachetta Apr 29, 2025
3a626ce
Merge branch 'main' into test-corelib
FrancoGiachetta Apr 29, 2025
d38d14d
fix name test in ci
FrancoGiachetta Apr 29, 2025
48fd257
Merge branch 'test-corelib' of github.com:lambdaclass/cairo_native in…
FrancoGiachetta Apr 29, 2025
7a1fdfc
add dependencies removed in merge
FrancoGiachetta Apr 29, 2025
f89b02f
dependencies
FrancoGiachetta Apr 29, 2025
f278fcc
clippy
FrancoGiachetta Apr 29, 2025
d248128
remove unused import
FrancoGiachetta Apr 29, 2025
72761ce
better indent in makefile
FrancoGiachetta Apr 29, 2025
1e43ad3
uppercase tests summary comment for better sight
FrancoGiachetta Apr 29, 2025
d2c217b
Merge branch 'main' into test-corelib
FrancoGiachetta Apr 29, 2025
511ebc1
Merge branch 'test-corelib' into sierra-emu-add-some-libfs
FrancoGiachetta Apr 30, 2025
5040091
Merge branch 'sierra-emu-add-some-libfs' of github.com:lambdaclass/ca…
FrancoGiachetta Apr 30, 2025
83416f1
fix clippy
FrancoGiachetta Apr 30, 2025
6e02e1b
clippy
FrancoGiachetta Apr 30, 2025
fb4cea3
merge main
FrancoGiachetta Apr 30, 2025
0d2a760
remove unnecesary pubs
FrancoGiachetta Apr 30, 2025
a9c1b9e
Merge branch 'main' into sierra-emu-add-some-libfs
FrancoGiachetta Apr 30, 2025
d9d3828
better docs
FrancoGiachetta Apr 30, 2025
5879b7f
Merge branch 'sierra-emu-add-some-libfs' of github.com:lambdaclass/ca…
FrancoGiachetta Apr 30, 2025
b8de7be
better panic message in get_numberic_args_as_bigints()
FrancoGiachetta May 5, 2025
af371a8
Merge branch 'main' into sierra-emu-add-some-libfs
FrancoGiachetta May 5, 2025
38a25b8
reviews
FrancoGiachetta May 5, 2025
33e9fd4
Merge branch 'sierra-emu-add-some-libfs' of github.com:lambdaclass/ca…
FrancoGiachetta May 5, 2025
d797fed
Merge branch 'main' into sierra-emu-add-some-libfs
JulianGCalderon May 5, 2025
c148d29
remove unnecessary comment
FrancoGiachetta May 5, 2025
fc4e881
use slices in get_numeric_args_as_bigints
FrancoGiachetta May 5, 2025
fc2f8ac
Merge branch 'sierra-emu-add-some-libfs' of github.com:lambdaclass/ca…
FrancoGiachetta May 5, 2025
5c25448
fmt
FrancoGiachetta May 5, 2025
7f0393d
remove unnecesary to_vec
FrancoGiachetta May 5, 2025
82b8da3
fmt
FrancoGiachetta May 5, 2025
ea6a75b
use iter instead of into_iter
FrancoGiachetta May 5, 2025
d3c5b0a
reviews changes
FrancoGiachetta May 6, 2025
05c92eb
better error message
FrancoGiachetta May 6, 2025
033930c
Merge branch 'main' into sierra-emu-add-some-libfs
FrancoGiachetta May 7, 2025
9fac977
Merge branch 'main' into sierra-emu-add-some-libfs
FrancoGiachetta May 7, 2025
545bbe5
fix typo
FrancoGiachetta May 7, 2025
9bf4c2f
Merge branch 'sierra-emu-add-some-libfs' of github.com:lambdaclass/ca…
FrancoGiachetta May 7, 2025
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
1 change: 1 addition & 0 deletions debug_utils/sierra-emu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mod dump;
mod gas;
pub mod starknet;
mod test_utils;
mod utils;
mod value;
mod vm;

Expand Down
55 changes: 55 additions & 0 deletions debug_utils/sierra-emu/src/utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
use cairo_lang_sierra::{
extensions::core::{CoreLibfunc, CoreType, CoreTypeConcrete},
program_registry::ProgramRegistry,
};
use num_bigint::BigInt;
use num_traits::ToPrimitive;

use crate::Value;

/// Receives a vector of values, filters any which is non numeric and returns a `Vec<BigInt>`
/// Useful when a binary operation takes generic values (like with bounded ints).
pub fn get_numberic_args_as_bigints(args: &[Value]) -> Vec<BigInt> {
args.iter()
.map(|v| match v {
Value::BoundedInt { value, .. } => value.to_owned(),
Value::I8(value) => BigInt::from(*value),
Value::I16(value) => BigInt::from(*value),
Value::I32(value) => BigInt::from(*value),
Value::I64(value) => BigInt::from(*value),
Value::I128(value) => BigInt::from(*value),
Value::U8(value) => BigInt::from(*value),
Value::U16(value) => BigInt::from(*value),
Value::U32(value) => BigInt::from(*value),
Value::U64(value) => BigInt::from(*value),
Value::U128(value) => BigInt::from(*value),
Value::Felt(value) => value.to_bigint(),
Value::Bytes31(value) => value.to_bigint(),
value => panic!("argument should be an integer: {:?}", value),
})
.collect()
}

pub fn get_value_from_integer(
registry: &ProgramRegistry<CoreType, CoreLibfunc>,
ty: &CoreTypeConcrete,
value: BigInt,
) -> Value {
match ty {
CoreTypeConcrete::NonZero(info) => {
let ty = registry.get_type(&info.ty).unwrap();
get_value_from_integer(registry, ty, value)
}
CoreTypeConcrete::Sint8(_) => Value::I8(value.to_i8().unwrap()),
CoreTypeConcrete::Sint16(_) => Value::I16(value.to_i16().unwrap()),
CoreTypeConcrete::Sint32(_) => Value::I32(value.to_i32().unwrap()),
CoreTypeConcrete::Sint64(_) => Value::I64(value.to_i64().unwrap()),
CoreTypeConcrete::Sint128(_) => Value::I128(value.to_i128().unwrap()),
CoreTypeConcrete::Uint8(_) => Value::U8(value.to_u8().unwrap()),
CoreTypeConcrete::Uint16(_) => Value::U16(value.to_u16().unwrap()),
CoreTypeConcrete::Uint32(_) => Value::U32(value.to_u32().unwrap()),
CoreTypeConcrete::Uint64(_) => Value::U64(value.to_u64().unwrap()),
CoreTypeConcrete::Uint128(_) => Value::U128(value.to_u128().unwrap()),
_ => panic!("cannot get integer value for a non-integer type"),
}
}
33 changes: 5 additions & 28 deletions debug_utils/sierra-emu/src/vm/bounded_int.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::EvalAction;
use crate::Value;
use crate::{utils::get_numberic_args_as_bigints, Value};
use cairo_lang_sierra::{
extensions::{
bounded_int::{
Expand All @@ -15,29 +15,6 @@ use cairo_lang_sierra::{
use num_bigint::BigInt;
use smallvec::smallvec;

// All binary operations have generic arguments, this function takes their values
// and builds bigints out of them (since Bigints are used to represent bounded ints' values)
fn get_numberic_args_as_bigints(args: Vec<Value>) -> Vec<BigInt> {
args.into_iter()
// remove builtins, if any
.filter(|v| !matches!(v, Value::Unit))
.map(|v| match v {
Value::BoundedInt { value, .. } => value,
Value::I8(value) => BigInt::from(value),
Value::I16(value) => BigInt::from(value),
Value::I32(value) => BigInt::from(value),
Value::I64(value) => BigInt::from(value),
Value::I128(value) => BigInt::from(value),
Value::U8(value) => BigInt::from(value),
Value::U16(value) => BigInt::from(value),
Value::U32(value) => BigInt::from(value),
Value::U64(value) => BigInt::from(value),
Value::U128(value) => BigInt::from(value),
_ => panic!("Not a numeric value"),
})
.collect()
}

pub fn eval(
registry: &ProgramRegistry<CoreType, CoreLibfunc>,
selector: &BoundedIntConcreteLibfunc,
Expand All @@ -62,7 +39,7 @@ pub fn eval_add(
info: &SignatureOnlyConcreteLibfunc,
args: Vec<Value>,
) -> EvalAction {
let [lhs, rhs]: [BigInt; 2] = get_numberic_args_as_bigints(args).try_into().unwrap();
let [lhs, rhs]: [BigInt; 2] = get_numberic_args_as_bigints(&args).try_into().unwrap();

let range = match registry
.get_type(&info.signature.branch_signatures[0].vars[0].ty)
Expand Down Expand Up @@ -91,7 +68,7 @@ pub fn eval_sub(
info: &SignatureOnlyConcreteLibfunc,
args: Vec<Value>,
) -> EvalAction {
let [lhs, rhs]: [BigInt; 2] = get_numberic_args_as_bigints(args).try_into().unwrap();
let [lhs, rhs]: [BigInt; 2] = get_numberic_args_as_bigints(&args).try_into().unwrap();

let range = match registry
.get_type(&info.signature.branch_signatures[0].vars[0].ty)
Expand Down Expand Up @@ -120,7 +97,7 @@ pub fn eval_mul(
info: &SignatureOnlyConcreteLibfunc,
args: Vec<Value>,
) -> EvalAction {
let [lhs, rhs]: [BigInt; 2] = get_numberic_args_as_bigints(args).try_into().unwrap();
let [lhs, rhs]: [BigInt; 2] = get_numberic_args_as_bigints(&args).try_into().unwrap();

let range = match registry
.get_type(&info.signature.branch_signatures[0].vars[0].ty)
Expand Down Expand Up @@ -149,7 +126,7 @@ pub fn eval_div_rem(
info: &BoundedIntDivRemConcreteLibfunc,
args: Vec<Value>,
) -> EvalAction {
let [lhs, rhs]: [BigInt; 2] = get_numberic_args_as_bigints(args).try_into().unwrap();
let [lhs, rhs]: [BigInt; 2] = get_numberic_args_as_bigints(&args).try_into().unwrap();

let quo = &lhs / &rhs;
let rem = lhs % rhs;
Expand Down
77 changes: 17 additions & 60 deletions debug_utils/sierra-emu/src/vm/cast.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use super::EvalAction;
use crate::Value;
use crate::{
utils::{get_numberic_args_as_bigints, get_value_from_integer},
Value,
};
use cairo_lang_sierra::{
extensions::{
casts::{CastConcreteLibfunc, DowncastConcreteLibfunc},
core::{CoreLibfunc, CoreType, CoreTypeConcrete},
core::{CoreLibfunc, CoreType},
lib_func::SignatureOnlyConcreteLibfunc,
ConcreteType,
ConcreteLibfunc,
},
program_registry::ProgramRegistry,
};
use num_bigint::BigInt;
use smallvec::smallvec;

pub fn eval(
Expand All @@ -23,85 +25,40 @@ pub fn eval(
}
}

pub fn eval_downcast(
fn eval_downcast(
registry: &ProgramRegistry<CoreType, CoreLibfunc>,
info: &DowncastConcreteLibfunc,
args: Vec<Value>,
) -> EvalAction {
let [range_check @ Value::Unit, value]: [Value; 2] = args.try_into().unwrap() else {
let range_check @ Value::Unit: Value = args[0].clone() else {
panic!()
};
let [value] = get_numberic_args_as_bigints(&args[1..]).try_into().unwrap();

let value = match value {
Value::BoundedInt { value, .. } => value,
Value::U128(value) => BigInt::from(value),
Value::U64(value) => BigInt::from(value),
Value::U32(value) => BigInt::from(value),
Value::U16(value) => BigInt::from(value),
Value::U8(value) => BigInt::from(value),
_ => todo!(),
};

let int_ty = registry.get_type(&info.to_ty).unwrap();
let range = info.to_range.lower.clone()..info.to_range.upper.clone();
if range.contains(&value) {
EvalAction::NormalBranch(
0,
smallvec![
range_check,
match registry.get_type(&info.to_ty).unwrap() {
CoreTypeConcrete::Sint8(_) => Value::I8(value.try_into().unwrap()),
CoreTypeConcrete::Sint128(_) => Value::I128(value.try_into().unwrap()),
CoreTypeConcrete::Uint8(_) => Value::U8(value.try_into().unwrap()),
CoreTypeConcrete::Uint16(_) => Value::U16(value.try_into().unwrap()),
CoreTypeConcrete::Uint32(_) => Value::U32(value.try_into().unwrap()),
CoreTypeConcrete::Uint64(_) => Value::U64(value.try_into().unwrap()),
CoreTypeConcrete::Uint128(_) => Value::U128(value.try_into().unwrap()),
CoreTypeConcrete::BoundedInt(_) => Value::BoundedInt { range, value },
x => todo!("{:?}", x.info()),
}
],
smallvec![range_check, get_value_from_integer(registry, int_ty, value)],
)
} else {
EvalAction::NormalBranch(1, smallvec![range_check])
}
}

pub fn eval_upcast(
fn eval_upcast(
registry: &ProgramRegistry<CoreType, CoreLibfunc>,
info: &SignatureOnlyConcreteLibfunc,
args: Vec<Value>,
) -> EvalAction {
let [value] = args.try_into().unwrap();

let value = match value {
Value::BoundedInt { value, .. } => value,
Value::U128(value) => BigInt::from(value),
Value::U64(value) => BigInt::from(value),
Value::U32(value) => BigInt::from(value),
Value::U16(value) => BigInt::from(value),
Value::U8(value) => BigInt::from(value),
_ => todo!(),
};
let [value] = get_numberic_args_as_bigints(&args).try_into().unwrap();
let int_ty = registry
.get_type(&info.branch_signatures()[0].vars[0].ty)
.unwrap();

EvalAction::NormalBranch(
0,
smallvec![match registry
.get_type(&info.signature.branch_signatures[0].vars[0].ty)
.unwrap()
{
CoreTypeConcrete::Sint8(_) => Value::I8(value.try_into().unwrap()),
CoreTypeConcrete::Sint32(_) => Value::I32(value.try_into().unwrap()),
CoreTypeConcrete::Sint128(_) => Value::I128(value.try_into().unwrap()),
CoreTypeConcrete::Uint8(_) => Value::U8(value.try_into().unwrap()),
CoreTypeConcrete::Uint16(_) => Value::U16(value.try_into().unwrap()),
CoreTypeConcrete::Uint32(_) => Value::U32(value.try_into().unwrap()),
CoreTypeConcrete::Uint64(_) => Value::U64(value.try_into().unwrap()),
CoreTypeConcrete::Uint128(_) => Value::U128(value.try_into().unwrap()),
CoreTypeConcrete::Felt252(_) => Value::Felt(value.into()),
CoreTypeConcrete::Sint16(_) => todo!("Sint16"),
CoreTypeConcrete::Sint64(_) => todo!("Sint64"),
CoreTypeConcrete::BoundedInt(_) => todo!("BoundedInt"),
_ => todo!(),
}],
smallvec![get_value_from_integer(registry, int_ty, value)],
)
}
61 changes: 49 additions & 12 deletions debug_utils/sierra-emu/src/vm/const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ use cairo_lang_sierra::{
ConstAsBoxConcreteLibfunc, ConstAsImmediateConcreteLibfunc, ConstConcreteLibfunc,
},
core::{CoreLibfunc, CoreType, CoreTypeConcrete},
starknet::StarknetTypeConcrete,
},
ids::ConcreteTypeId,
program::GenericArg,
program_registry::ProgramRegistry,
};
use num_traits::ToPrimitive;
use smallvec::smallvec;

pub fn eval(
Expand All @@ -24,7 +26,7 @@ pub fn eval(
}
}

pub fn eval_as_immediate(
fn eval_as_immediate(
registry: &ProgramRegistry<CoreType, CoreLibfunc>,
info: &ConstAsImmediateConcreteLibfunc,
args: Vec<Value>,
Expand All @@ -41,7 +43,7 @@ pub fn eval_as_immediate(
)
}

pub fn eval_as_box(
fn eval_as_box(
registry: &ProgramRegistry<CoreType, CoreLibfunc>,
info: &ConstAsBoxConcreteLibfunc,
args: Vec<Value>,
Expand Down Expand Up @@ -89,52 +91,56 @@ fn inner(
},
_ => unreachable!(),
},
CoreTypeConcrete::Bytes31(_) => match inner_data {
[GenericArg::Value(value)] => Value::Bytes31(value.into()),
_ => unreachable!(),
},
CoreTypeConcrete::Sint128(_) => match inner_data {
[GenericArg::Value(value)] => Value::I128(value.try_into().unwrap()),
[GenericArg::Value(value)] => Value::I128(value.to_i128().unwrap()),
_ => unreachable!(),
},
CoreTypeConcrete::Sint64(_) => match inner_data {
[GenericArg::Value(value)] => Value::U64(value.try_into().unwrap()),
[GenericArg::Value(value)] => Value::I64(value.to_i64().unwrap()),
_ => unreachable!(),
},
CoreTypeConcrete::Sint32(_) => match inner_data {
[GenericArg::Value(value)] => Value::I32(value.try_into().unwrap()),
[GenericArg::Value(value)] => Value::I32(value.to_i32().unwrap()),
_ => unreachable!(),
},
CoreTypeConcrete::Sint16(_) => match inner_data {
[GenericArg::Value(value)] => Value::I16(value.try_into().unwrap()),
[GenericArg::Value(value)] => Value::I16(value.to_i16().unwrap()),
_ => unreachable!(),
},
CoreTypeConcrete::Sint8(_) => match inner_data {
[GenericArg::Value(value)] => Value::I8(value.try_into().unwrap()),
[GenericArg::Value(value)] => Value::I8(value.to_i8().unwrap()),
_ => unreachable!(),
},
CoreTypeConcrete::Uint128(_) => match inner_data {
[GenericArg::Value(value)] => Value::U128(value.try_into().unwrap()),
[GenericArg::Value(value)] => Value::U128(value.to_u128().unwrap()),
[GenericArg::Type(type_id)] => match registry.get_type(type_id).unwrap() {
CoreTypeConcrete::Const(info) => inner(registry, &info.inner_ty, &info.inner_data),
_ => unreachable!(),
},
_ => unreachable!(),
},
CoreTypeConcrete::Uint64(_) => match inner_data {
[GenericArg::Value(value)] => Value::U64(value.try_into().unwrap()),
[GenericArg::Value(value)] => Value::U64(value.to_u64().unwrap()),
_ => unreachable!(),
},
CoreTypeConcrete::Uint32(_) => match inner_data {
[GenericArg::Value(value)] => Value::U32(value.try_into().unwrap()),
[GenericArg::Value(value)] => Value::U32(value.to_u32().unwrap()),
[GenericArg::Type(type_id)] => match registry.get_type(type_id).unwrap() {
CoreTypeConcrete::Const(info) => inner(registry, &info.inner_ty, &info.inner_data),
_ => unreachable!(),
},
_ => unreachable!(),
},
CoreTypeConcrete::Uint16(_) => match inner_data {
[GenericArg::Value(value)] => Value::U16(value.try_into().unwrap()),
[GenericArg::Value(value)] => Value::U16(value.to_u16().unwrap()),
_ => unreachable!(),
},
CoreTypeConcrete::Uint8(_) => match inner_data {
[GenericArg::Value(value)] => Value::U8(value.try_into().unwrap()),
[GenericArg::Value(value)] => Value::U8(value.to_u8().unwrap()),
_ => unreachable!(),
},
CoreTypeConcrete::Struct(_) => {
Expand All @@ -160,6 +166,37 @@ fn inner(

Value::Struct(fields)
}
CoreTypeConcrete::Enum(_) => match inner_data {
[GenericArg::Value(value_idx), GenericArg::Type(payload_ty)] => {
let payload_type = registry.get_type(payload_ty).unwrap();
let const_payload_type = match payload_type {
CoreTypeConcrete::Const(inner) => inner,
_ => {
panic!("matched an unexpected CoreTypeConcrete that is not a Const")
}
};
let payload = inner(registry, payload_ty, &const_payload_type.inner_data);
let index: usize = value_idx.to_usize().unwrap();

Value::Enum {
self_ty: type_id.clone(),
index,
payload: Box::new(payload),
}
}
_ => panic!("const data mismatch"),
},
CoreTypeConcrete::Const(info) => inner(registry, &info.inner_ty, &info.inner_data),
CoreTypeConcrete::Starknet(selector) => match selector {
StarknetTypeConcrete::ClassHash(_)
| StarknetTypeConcrete::ContractAddress(_)
| StarknetTypeConcrete::StorageAddress(_)
| StarknetTypeConcrete::StorageBaseAddress(_) => match inner_data {
[GenericArg::Value(value)] => Value::Felt(value.into()),
_ => unreachable!(),
},
_ => todo!(""),
},
_ => todo!("{}", type_id),
}
}
Loading