cairo-vm-go icon indicating copy to clipboard operation
cairo-vm-go copied to clipboard

Felt values in hints representing array length

Open cicr99 opened this issue 9 months ago • 4 comments

There are cases such as this hint:

%{
        n -= 1
        ids.continue_copying = 1 if n > 0 else 0
%}

where the value of n is supposed to be a felt, as you can see in its definition here:

%{ vm_enter_scope({'n': ids.len}) %}

where len is of type felt.

However, in practice, the actual value of n cannot be a value of 252 bits since that wouldn't be feasible to compute, as this is representing the length of an array. n should fit in int64. If we do the conversion from the moment we define the variable then all operations regarding n would be a lot easier and more efficient, as the way we can handle felts is using Element from this library.

Task: Look for all the places in the code of hints where this can be optimized and do so. Notice you'll also need to modify all the code related to operations with these variables

cicr99 avatar May 03 '24 08:05 cicr99