Releases: lambdaclass/cairo-vm
v0.5.2
What's Changed
-
BREAKING: Compute
ExecutionResources.n_steps
without requiring trace #1222CairoRunner::get_execution_resources
return'sn_steps
field value is now set tovm.current_step
instead of0
if bothoriginal_steps
andtrace
are set toNone
-
Add
RunResources::get_n_steps
method #1225 -
refactor: simplify
mem_eq
-
fix: pin Cairo compiler version #1220
-
perf: make
inner_rc_bound
a constant, improving performance of the range-check builtin -
fix: substraction of
MaybeRelocatable
always behaves as signed #1218
v0.5.1
What's Changed
-
fix: fix overflow for
QUAD_BIT
andDI_BIT
hints #1209
Fixes #1205 -
fix: fix hints
UINT256_UNSIGNED_DIV_REM
&&UINT256_EXPANDED_UNSIGNED_DIV_REM
#1203 -
bugfix: fix deserialization of scientific notation with fractional values #1202
-
feat: implement
mem_eq
function to test for equality of two ranges in memory #1198 -
perf: use
mem_eq
inset_add
#1198 -
feat: wrap big variants of
HintError
,VirtualMachineError
,RunnerError
,MemoryError
,MathError
,InsufficientAllocatedCellsError
inBox
#1193- BREAKING: all tuple variants of
HintError
with a singleFelt252
or multiple elements now receive a singleBox
- BREAKING: all tuple variants of
-
Add
Program::builtins_len method
#1194 -
fix: Handle the deserialization of serde_json::Number with scientific notation (e.g.: Number(1e27)) in felt_from_number function #1188
-
feat: Add RunResources Struct #1175
- BREAKING: Modify
CairoRunner::run_until_pc
arity. Addrun_resources: &mut Option<RunResources>
input - BREAKING: Modify
CairoRunner::run_from_entrypoint
arity. Addrun_resources: &mut Option<RunResources>
input
- BREAKING: Modify
-
fix: Fix 'as_int' conversion usage in hints
ASSERT_250_BIT
&SIGNED_DIV_REM
#1191 -
bugfix: Use cairo constants in
ASSERT_250_BIT
hint #1187 -
bugfix: Fix
EC_DOUBLE_ASSIGN_NEW_X_V2
hint not takingSECP_P
value from the current execution scope #1186 -
fix: Fix hint
BIGINT_PACK_DIV_MOD
#1189 -
fix: Fix possible subtraction overflow in
QUAD_BIT
&DI_BIT
hints #1185- These hints now return an error when ids.m equals zero
-
fix: felt_from_number not properly returning parse errors #1012
-
fix: Fix felt sqrt and Signed impl #1150
- BREAKING: Fix
Felt252
methodsabs
,signum
,is_positive
,is_negative
andsqrt
- BREAKING: Remove function
math_utils::sqrt
(Now moved toFelt252::sqrt
)
- BREAKING: Fix
-
feat: Add method
CairoRunner::initialize_function_runner_cairo_1
#1151-
Add method
pub fn initialize_function_runner_cairo_1( &mut self, vm: &mut VirtualMachine, program_builtins: &[BuiltinName], ) -> Result<(), RunnerError>
toCairoRunner
-
BREAKING: Move field
builtins
fromSharedProgramData
toProgram
-
BREAKING: Remove argument
add_segment_arena_builtin
fromCairoRunner::initialize_function_runner
, it is now always false -
BREAKING: Add
segment_arena
enum variant toBuiltinName
-
-
Fix implementation of
InitSquashData
andShouldSkipSquashLoop
-
Add more hints to
Cairo1HintProcessor
#1171
#1143Cairo1HintProcessor
can now run the following hints:- Felt252DictEntryInit
- Felt252DictEntryUpdate
- GetCurrentAccessDelta
- InitSquashData
- AllocConstantSize
- GetCurrentAccessIndex
- ShouldContinueSquashLoop
- FieldSqrt
- Uint512DivMod
-
Add some small considerations regarding Cairo 1 programs #1144:
- Ignore Casm and Sierra files
- Add special flag to compile Cairo 1 programs
-
Make the VM able to run
CasmContractClass
files undercairo-1-hints
feature #1098- Implement
TryFrom<CasmContractClass> for Program
- Add
Cairo1HintProcessor
- Implement
v0.4.0
What's Changed
-
perf: insert elements from the tail in
load_data
so reallocation happens only once #1117 -
Add
CairoRunner::get_program method
#1123 -
Use to_signed_felt as function for felt252 as BigInt within [-P/2, P/2] range and use to_bigint as function for representation as BigInt. #1100
-
Implement hint on field_arithmetic lib #1090
BuiltinHintProcessor
now supports the following hints:%{ def split(num: int, num_bits_shift: int, length: int): a = [] for _ in range(length): a.append( num & ((1 << num_bits_shift) - 1) ) num = num >> num_bits_shift return tuple(a) def pack(z, num_bits_shift: int) -> int: limbs = (z.d0, z.d1, z.d2) return sum(limb << (num_bits_shift * i) for i, limb in enumerate(limbs)) a = pack(ids.a, num_bits_shift = 128) b = pack(ids.b, num_bits_shift = 128) p = pack(ids.p, num_bits_shift = 128) res = (a - b) % p res_split = split(res, num_bits_shift=128, length=3) ids.res.d0 = res_split[0] ids.res.d1 = res_split[1] ids.res.d2 = res_split[2] %}
-
Add missing hint on cairo_secp lib #1089:
BuiltinHintProcessor
now supports the following hint:from starkware.cairo.common.cairo_secp.secp_utils import pack slope = pack(ids.slope, PRIME) x0 = pack(ids.point0.x, PRIME) x1 = pack(ids.point1.x, PRIME) y0 = pack(ids.point0.y, PRIME) value = new_x = (pow(slope, 2, SECP_P) - x0 - x1) % SECP_P
-
Add missing hint on vrf.json whitelist #1055:
BuiltinHintProcessor
now supports the following hint:%{ PRIME = 2**255 - 19 II = pow(2, (PRIME - 1) // 4, PRIME) xx = ids.xx.low + (ids.xx.high<<128) x = pow(xx, (PRIME + 3) // 8, PRIME) if (x * x - xx) % PRIME != 0: x = (x * II) % PRIME if x % 2 != 0: x = PRIME - x ids.x.low = x & ((1<<128)-1) ids.x.high = x >> 128 %}
-
Implement hint variant for finalize_blake2s#1072
BuiltinHintProcessor
now supports the following hint:%{ # Add dummy pairs of input and output. from starkware.cairo.common.cairo_blake2s.blake2s_utils import IV, blake2s_compress _n_packed_instances = int(ids.N_PACKED_INSTANCES) assert 0 <= _n_packed_instances < 20 _blake2s_input_chunk_size_felts = int(ids.BLAKE2S_INPUT_CHUNK_SIZE_FELTS) assert 0 <= _blake2s_input_chunk_size_felts < 100 message = [0] * _blake2s_input_chunk_size_felts modified_iv = [IV[0] ^ 0x01010020] + IV[1:] output = blake2s_compress( message=message, h=modified_iv, t0=0, t1=0, f0=0xffffffff, f1=0, ) padding = (message + modified_iv + [0, 0xffffffff] + output) * (_n_packed_instances - 1) segments.write_arg(ids.blake2s_ptr_end, padding) %} ```
-
Implement fast_ec_add hint variant #1087
BuiltinHintProcessor
now supports the following hint:
```python
%{
from starkware.cairo.common.cairo_secp.secp_utils import SECP_P, pack
slope = pack(ids.slope, PRIME)
x0 = pack(ids.pt0.x, PRIME)
x1 = pack(ids.pt1.x, PRIME)
y0 = pack(ids.pt0.y, PRIME)
value = new_x = (pow(slope, 2, SECP_P) - x0 - x1) % SECP_P
%}
```
-
feat(hints): Add alternative string for hint IS_ZERO_PACK_EXTERNAL_SECP #1082
BuiltinHintProcessor
now supports the following hint:%{ from starkware.cairo.common.cairo_secp.secp_utils import pack x = pack(ids.x, PRIME) % SECP_P %}
-
Add alternative hint code for ec_double hint #1083
BuiltinHintProcessor
now supports the following hint:%{ from starkware.cairo.common.cairo_secp.secp_utils import SECP_P, pack slope = pack(ids.slope, PRIME) x = pack(ids.pt.x, PRIME) y = pack(ids.pt.y, PRIME) value = new_x = (pow(slope, 2, SECP_P) - 2 * x) % SECP_P %}
-
fix(security)!: avoid DoS on malicious insertion to memory #1099
- A program could crash the library by attempting to insert a value at an address with a big offset; fixed by trying to reserve to check for allocation failure
- A program could crash the program by exploiting an integer overflow when attempting to insert a value at an address with offset
usize::MAX
BREAKING: added a new error variant
MemoryError::VecCapacityExceeded
-
perf: specialize addition for
u64
andFelt252
#932- Avoids the creation of a new
Felt252
instance for additions with a very restricted valid range - This impacts specially the addition of
Relocatable
withFelt252
values inupdate_pc
, which take a significant amount of time in some benchmarks
- Avoids the creation of a new
-
fix(starknet-crypto): bump version to
0.5.0
#1088 -
feat(hints): Add alternative string for hint IS_ZERO_PACK #1081
BuiltinHintProcessor
now supports the following hint:%{ from starkware.cairo.common.cairo_secp.secp_utils import SECP_P, pack x = pack(ids.x, PRIME) % SECP_P %}
-
Add missing hints
NewHint#55
,NewHint#56
, andNewHint#57
#1077BuiltinHintProcessor
now supports the following hints:from starkware.cairo.common.cairo_secp.secp_utils import pack SECP_P=2**255-19 x = pack(ids.x, PRIME) % SECP_P
from starkware.cairo.common.cairo_secp.secp_utils import pack SECP_P=2**255-19 value = pack(ids.x, PRIME) % SECP_P
SECP_P=2**255-19 from starkware.python.math_utils import div_mod value = x_inv = div_mod(1, x, SECP_P)
-
Implement hint for
starkware.cairo.common.cairo_keccak.keccak._copy_inputs
as described by whiteliststarknet/security/whitelists/cairo_keccak.json
#1058BuiltinHintProcessor
now supports the following hint:%{ ids.full_word = int(ids.n_bytes >= 8) %}
-
perf: cache decoded instructions #944
- Creates a new cache field in
VirtualMachine
that stores theInstruction
instances as they get decoded from memory, significantly reducing decoding overhead, with gains up to 9% in runtime according to benchmarks in the performance server
- Creates a new cache field in
-
Add alternative hint code for nondet_bigint3 hint #1071
BuiltinHintProcessor
now supports the following hint:%{ from starkware.cairo.common.cairo_secp.secp_utils import split segments.write_arg(ids.res.address_, split(value)) %}
-
Add missing hint on vrf.json lib #1052:
BuiltinHintProcessor
now supports the following hint:%{ from starkware.cairo.common.cairo_secp.secp_utils import pack SECP_P = 2**255-19 slope = pack(ids.slope, PRIME) x0 = pack(ids.point0.x, PRIME) x1 = pack(ids.point1.x, PRIME) y0 = pack(ids.point0.y, PRIME) value = new_x = (pow(slope, 2, SECP_P) - x0 - x1) % SECP_P %}
-
Implement hint for cairo_sha256_arbitrary_input_length whitelist #1091
BuiltinHintProcessor
now supports the following hint:%{ from starkware.cairo.common.cairo_sha256.sha256_utils import ( compute_message_schedule, sha2_compress_function) _sha256_input_chunk_size_felts = int(ids.SHA256_INPUT_CHUNK_SIZE_FELTS) assert 0 <= _sha256_input_chunk_size_felts < 100 _sha256_state_size_felts = int(ids.SHA256_STATE_SIZE_FELTS) assert 0 <= _sha256_state_size_felts < 100 w = compute_message_schedule(memory.get_range( ids.sha256_start, _sha256_input_chunk_size_felts)) new_state = sha2_compress_function(memory.get_range(ids.state, _sha256_state_size_felts), w) segments.write_arg(ids.output, new_state) %}
-
Add missing hint on vrf.json lib #1053:
BuiltinHintProcessor
now supports the following hint:%{ from starkware.cairo.common.cairo_secp.secp_utils import SECP_P, pack SECP_P = 2**255-19 slope = pack(ids.slope, PRIME) ...