cairo-vm is a Rust implementation of the Cairo VM. Cairo (CPU Algebraic Intermediate Representation) is a programming language for writing provable programs, where one party can prove to another that a certain computation was executed correctly without the need for this party to re-execute the same program.
Describe the bug
When running a Cairo program using the cairo1-run command, a panic occurs if the program defines a function that uses a Felt252Dict with Nullable<T> values, where T represents any type supported by Cairo.
To Reproduce
The issue can be reproduced with the following Cairo code snippet:
use core::nullable::{nullable_from_box, match_nullable, FromNullableResult};
fn main() {
// Create the dictionary
let mut d: Felt252Dict<Nullable<Span<felt252>>> = Default::default();
// Create the array to insert
let a = array![8, 9, 10];
// Insert it as a `Span`
d.insert(0, nullable_from_box(BoxTrait::new(a.span())));
}
What version/commit are you on?
Cairo VM version/commit: 1f98fef
Additional Context
This issue seems to be related to the handling of Nullable<T> types within Felt252Dict in the Cairo VM. However I tried to run the following cairo program, and it ran successfully:
fn main() {
let d = NullableTrait::new(1);
}
Any assistance in resolving this panic would be greatly appreciated. Thank you :)
Describe the bug When running a Cairo program using the cairo1-run command, a panic occurs if the program defines a function that uses a
Felt252Dict
withNullable<T>
values, whereT
represents any type supported by Cairo.To Reproduce The issue can be reproduced with the following Cairo code snippet:
The program is executed using the command:
This results in the following panic message:
What version/commit are you on? Cairo VM version/commit:
1f98fef
Additional Context This issue seems to be related to the handling of
Nullable<T>
types withinFelt252Dict
in the Cairo VM. However I tried to run the following cairo program, and it ran successfully:Any assistance in resolving this panic would be greatly appreciated. Thank you :)