Cairo VM maintains two parallel branches:
- 2.x.y branch: Stable API, minimal breaking changes
- 3.x (main): New features with breaking API changes
Both branches support Stwo prover opcodes (Blake2s, QM31) since v2.0.0.
-
feat: add
test_helpersmodule (error_utils,test_utils) withassert_mr_eq,load_cairo_program!macro andexpect_*error checkers, behindtest_utilsfeature flag #2381 -
feat(makefile,ci): add
cairo_test_suite_programsMakefile target and CI integration to compile Cairo test suite programs before running tests #2380 -
Add Stwo cairo runner API #2351
-
feat: make max traceback entries configurable #2370
-
feat: create and use VirtualMachineConfig #2369
-
feat: consolidate CairoRunner ctors #2368
-
feat: create and use CairoRunConfig as ctor arg for CairoRunner ctors #2367
-
feat: move runner_mode to be a field in StwoCairoRunConfig #2366
-
refactor: rename CairoRunConfig to Cairo0RunConfig #2365
-
feat: add disable_trace_padding field to Cairo1RunConfig #2364
-
feat: refactor CairoRunner ctors to accept CairoLayout directly #2363
-
feat: implement CairoLayout::new from layout name and dynamic params #2362
-
Add Stwo cairo runner API #2351
-
Add union merge strategy for CHANGELOG.md #2345
-
fix: Fix off-by-one comparisons in
split_int,assert_250_bit, andsqrthints #2348
-
adding codecov app.# added by sobhe.
-
feat: Add
CairoFunctionRunnerfor running Cairo entrypoints by name or PC, and broadenCairoArg/MaybeRelocatableconversions to support primitive signed/unsigned integers and big integers #2352 -
chore: Add
CairoFunctionRunnerfor running Cairo entrypoints by name or PC, and broadenCairoArg/MaybeRelocatableconversions to support primitive signed/unsigned integers and big integers #2352 -
chore: Add unit tests for
CairoFunctionRunner,CairoArgconversions/macros, andMaybeRelocatableconversion macro coverage #2354 -
chore: Add function-runner methods to
CairoRunner(new_for_testing,run_default_cairo0,get_builtin_base,run_from_entrypoint) under thetest_utilsfeature #2359
-
fix: Change extended_resource_counter entry from u32 to usize #2349
-
chore: Update fuzz_json with missing hint constants and improve fuzzer docs #2341
-
chore: Remove
diff_fuzzerandpy_export#2340 -
fix: Validate
log_diluted_units_per_stepin dynamic layout params #2342 -
Remove no_std support #2326
-
Remove WASM support #2328
-
docs: Add onboarding doc for new developers #2325
-
chore: Remove
cairo_compiled_programs_fuzzer#2339 -
refactor: deduplicate memory segment selection in Memory helpers #2331
-
feat:
Add_ecop_to_all_cairo_stwo_and_add_stwo_no_ecop_layout#2333all_cairo_stwonow includesec_op.- Added new
stwo_no_ecoplayout preserving the previousall_cairo_stwobehavior.
-
fix: replace
streaming::tagwithcomplete::tagin deserialize_utils #2332 -
Use starknet-types-core's QM31 instead of hand-rolled implementation #2203
-
fix: Handle n=0 in
mod_builtin_fill_memory#1935 -
fix: correct off-by-one error in Cairo PIE address validation #2329
-
feat: Make
write_encodedAPI public again #2306 -
refactor: deduplicate memcpy/memset scope initialization in builtin hint processor #2313
-
fix: correct offsets_ptr values in mod builtin security check #2318
-
fix: Allow WASM32 compilation with std feature enabled #2315
-
chore(vm): unify Uint256 usage across u256 hints and split quotient via Uint512 #2237
-
feat: Add Blake counter in vm #2322
-
fix: assign validation rules in place to preserve segment-index alignment #2268
-
chore: Remove old compare-benchmarks Makefile command #2307
-
chore: Update iai-callgrind from 0.3.1 to 0.14.0 #2311
-
refactor: simplify relocated instruction locations lookup #2293
-
feat: Add public
ORDERED_BUILTIN_LISTconstant #2298 -
chore(breaking): Remove bincode crate #2294
-
refactor: Make HintReference dereference count explicit in
get_maybe_relocatable_from_reference#2296 -
chore: Add logs to
cairo_run_program_with_initial_scope#2319
Summary: Introduces stateful VM hooks via the StepHooks trait, enabling debuggers and instrumentation tools.
Breaking Changes
- feat(breaking): Introduce
StepHookstrait which allows hooks to be stateful #2295- New
StepHookstrait thatHooksimplements - Allows hooks to be stateful (needed for cairo-debugger)
- Migration: If implementing custom hooks, implement the
StepHookstrait
- New
Features
Bug Fixes
-
fix: Make cairo1-run to conditionally relocate memory and trace #2241
- Honor
relocate_memandtrace_enabledflags in cairo1-run
- Honor
-
fix: Fix compute_ids_high_low hint constant path #2285
-
fix: also mark PC as accessed in run_instruction #2106
-
fix: rename y_cube_int to y_square_int in get_point_from_x #2271
-
fix: correct duplicate tuple index in InvalidTrackingGroup error message #2276
Patch release with bug fixes backported to 3.0.x. See [3.1.0] for the consolidated changes.
Summary: Major release consolidating all changes from v3.0.0-rc.1 through v3.0.0-rc.5. Introduces accessible scopes for hints, deterministic iteration, and various API improvements.
Breaking Changes
-
feat(BREAKING): add support for accessible scopes in hint processor #2042
accessible_scopesfield added toHintProcessorData
-
breaking: Store constants in Hint Data #2191
- Constants now stored in hint data for correct resolution in nested programs
-
dev(BREAKING): Make blake2s API internal #2265
-
feat: Make QM31 functions internal #2181
-
feat: Use BTreeMap in PIE additional data #2162
- Ensures deterministic PIE ordering
-
[BREAKING] Compute missing builtin cells only in proof mode #2088
- Fill holes only in proof mode
Features
-
feat: Add support for WASM with Cairo 1 #2216
-
feat: Add
--fill-holesCLI flag instead of relying on--proof-mode#2165 -
feat: Added support for large files in PIE #2136
-
feat: Enable using secure run in proof mode #2113
-
feat: Add perpetual and dex with bitwise layouts #2067
-
feat: Fill holes in builtins segments to save computation in the prover #2036
-
feat: add support for alias identifiers destination in program serde #2071
-
feat: add get_current_step getter #2034
-
feat: implement VirtualMachine::is_accessed #2033
-
dev: make
VirtualMachine::get_traceback_entriespub #2126
Bug Fixes
-
bugfix: Fix temp segment chain bug #2195
-
fix: save x1 variable to execution scope in fast_ec_add_assign_new_x #2266
-
fix: use div_mod_unsigned and remove unwrap_or_default in inv_mod_p_uint256 and uint384_div #2262
-
fix: error mapping for fee_provision in excess_balance hint #2236
-
fix: ArcTooBig parameter order in assert_le_felt #2234
-
Fix bug affecting cairo1 programs with input and System builtin #2207
-
fix: Use Cairo prime instead of SECP_P in WRITE_DIVMOD_SEGMENT hint #2078
-
fix: Fix zero offset output base assumption #2068
-
fix: Always use a normal segment in first SegmentArena segment #1845
Internal/Chores
-
chore: Bump Rust toolchain to 1.89 #2245
-
chore: update Rust required version to 1.87.0 #2100
-
chore: Migrate from
pyenvtouv#1995 -
Refactor: Remove unused error variants #1760
-
Refactor: Replaced HashMap with BTreeMap to guarantee deterministic ordering of the data #2023
See RC versions below for individual change details.
-
fix: save x1 variable to execution scope in fast_ec_add_assign_new_x #2266
-
fix: use div_mod_unsigned and remove unwrap_or_default in inv_mod_p_uint256 and uint384_div #2262
-
Refactor: Remove unused error variants #1760
-
opt(breaking): Avoid cloning constants when compiling hints #2208
-
dev(BREAKING): Make blake2s API internal #2265
-
bugfix: Fix temp segment chain bug #2195
-
fix: error mapping for fee_provision in excess_balance hint #2236
-
fix: ArcTooBig parameter order in assert_le_felt. #2234
-
chore: Bump Rust toolchain to 1.89 #2245
-
chore: Remove dead SegmentInfo struct from cairo_runner.rs #2235
-
fix: Remove unused dependency getrandom for cairo1-run, and serde_json for wasm-demo-cairo1 #2238
-
chore: Unify deps makefile target #2211
-
Fix bug affecting cairo1 programs with input and System builtin #2207
-
chore: Pin generic-array version to 0.14.7 or lower. #2227
-
feat: Add support for WASM with Cairo 1 #2216
-
fix: Added
cairo_1_test_contractsandcairo_2_test_contractsas dependencies fortest-extensive_hintstarget #2201 -
breaking: Store constants in Hint Data #2191
- chore: Bump types-rs to 0.2.0 #2183
-
feat: Make QM31 functions internal #2181
-
feat: Add
--fill-holesCLI flag instead of relying on--proof-mode#2165 -
feat: Use BTreeMap in PIE additional data #2162
-
feat: Remove prover input info struct and add getters instead #2149
-
feat: Added support for large files in PIE #2136
-
feat: Disable relocate trace with flag #2133
-
feat: Enable using secure run in proof mode #2113
-
[BREAKING] Compute missing builtin cells only in proof mode #2088
-
test: Add test for filling holes in builtin segments #2087
-
fix: Removed memory comparison test with Python VM in proof mode, since the new hole-filling logic causes divergence.#2086
-
refactor: Use BTreeMap for deterministic order of PIE keys #2085
-
fix: Fix zero offset output base assumption #2068
-
feat: Add perpetual and dex with bitwise layouts #2067
-
feat: Fill holes in builtins segments to save computation in the prover #2036
-
feat: Added hints felt unpacking for blake #2032
-
dev: make
VirtualMachine::get_traceback_entriespub #2126 -
chore: Pin types-rs version to the one set in lockfile #2140
-
chore: Migrate from
pyenvtouv#1995 -
chore: remove unused dependencies #2111
-
chore: update Rust required version to 1.87.0 #2100
-
chore: bump pip
cairo-lang0.13.5 #1959 -
fix: Use Cairo prime instead of SECP_P in WRITE_DIVMOD_SEGMENT hint #2078
-
feat: add support for alias identifiers destination in program serde #2071
-
feat(BREAKING): add support for accessible scopes in hint processor #2042
-
dev: add Memory::get_maybe_relocatable #2039
-
refactor: remove duplicated get_val function #2065
-
fix: Always use a normal segment in first SegmentArena segment #1845
-
chore: update cairo-lang dependencies to 2.12.0-dev.0 #2040
-
feat: add get_current_step getter #2034
-
feat: implement VirtualMachine::is_accessed #2033
-
Refactor: Replaced HashMap with BTreeMap to guarantee deterministic ordering of the data [#2023] (#2023)
-
fix: Updated the logic for collecting builtin segment data for prover input info, removing dependency on the existence of stop pointers. #2022
-
fix: Keep None values in memory segments for the prover input info #2021
-
refactor: Clap attribute macros from #[clap(...)] to #[arg(...)] and #[command(...)] in v4.x [#2003] (#2003)
-
fix: Fix
WriteReturnFperror due to a bad loading of initial gas #2015 -
refactor: Replaces security anyhow errors with enum variants #1946
-
fix:
mod_builtin_fill_memorycould be stuck in an infinite loop #1975 -
feat: replace
thiserror-no-stdwiththiserror 2#1919 -
feat: Add
ProverInfoand extract the relevant information for it from the runner #2001
Summary: Fixes constant resolution for nested Cairo program execution.
Breaking Changes
- breaking: Store constants in Hint Data #2191
HintProcessorLogic::execute_hint- RemovedconstantsparameterHintProcessorLogic::compile_hint- AddedconstantsparameterCairoRunner::step_hint- No longer receives program constants- Why: When executing inner Cairo programs, hints now use the correct program's constants instead of the top-level program's constants
-
feat: Limited padding of builtin segments to >=16 #1981
-
fix: Enforce
disable_trace_paddingused only inproof_mode#1984 -
feat: adding option to simulate builtins #1956
-
feat: adding
all_cairo_stwolayout to vm #1957 -
chore: update Rust required version to 1.85.0 #1990
-
chore: Update fastecdsa python package #1993
-
fix: Update wasm-bindgen to version 0.2.100 and unpin its version requirement #1988
- fix: Check overflow in cairo pie address calculation #1945
-
fix: Fix Cairo Pie limiting the number of segments to 2^16 #1960
- Implement
merge_extra_segments
- Implement
-
feat: implement an opcode that computes QM31 arithmetics (add, sub, mul, div) in the VM #1938
-
feat: add functions that compute packed reduced qm31 arithmetics to
math_utils#1944 -
feat: implement
Blake2sLastBlockopcode in VM #1932 -
feat: implement
Blake2sopcode in VM #1927 -
feat: remove
NonZeroReservedBitsfromVirtualMachineError#1948 -
feat: set
encoded_instructionto be u128 for opcode_extensions to come #1940 -
feat: add
get_u32_rangetoimpl VirtualMachineaddget_u32andget_u32_rangetoimpl Memory#1936 -
feat: add the field
opcode_extensionto the structure ofInstruction#1933 -
fix(BREAKING): Fix no trace padding flow in proof mode #1909
-
refactor: Limit ret opcode decodeing to Cairo0's standards. #1925
-
feat: define HashMap of hint groups along with hint strings #1943
- feat: implement
kzgdata availability hints #1887
- chore: update cairo-lang dependencies to 2.10.0-rc.0 #1901
-
feat: Add support for subtractions containing references as right hand side operands #1898
-
fix: Change wildcard getrandom dependency.
-
Update starknet-crypto to 0.7.3, removing the old FieldElement completly in favour of the new Felt (that is Copy).
-
chore: update the cairo-vm version used in the readme
-
chore: update cairo-lang dependencies to 2.9.2
-
fix: replace
div_remwithdiv_mod_floorinverify_zerohints #1881 -
feat: Implement
SECP relatedhints #1829 -
chore: bump pip
cairo-lang0.13.3 #1884 -
fix: #1862:
- Use MaybeRelocatable for relocation table
-
chore: bump pip
cairo-lang0.13.3 #1884 -
chore: #1880:
- Refactor vm crate to make it possible to use hint extension feature for nested programs with hints.
-
feat: add
EvalCircuitandTestLessThanOrEqualAddresshints #1843 -
fix: #1873
- Fix broken num-prime
is_primecall
- Fix broken num-prime
-
fix: #1868:
- Adds logic to include the 3 new builtins in
builtin_segmentswhen serializing the output cairo pie's metadata.
- Adds logic to include the 3 new builtins in
-
fix: #1855:
- Adds logic to skip pedersen additional data comparison when checking pie compatibility.
-
serde: add
sizefield toIdentifier[#1861]#1861
-
fix: #1864:
- Runner: include data from constants segment to the bytecode when assembling program
-
chore: bump
cairo-lang-dependencies to 2.9.0-dev.0 #1858 -
chore: update Rust required version to 1.81.0 #1857
-
fix: #1851:
- Fix unsorted signature and mod builtin outputs in air_private_input.
-
- Add support for dynamic layout
- CLI change(BREAKING): The flag
cairo_layout_params_filemust be specified when using dynamic layout. - Signature change(BREAKING): Both
CairoRunner::newandCairoRunner::new_v2now receive anOption<CairoLayoutParams>, used only with dynamic layout.
-
fix: #1841:
- Fix modulo builtin to comply with prover constraints
-
chore: bump pip
cairo-lang0.13.2 #1827 -
chore: bump
cairo-lang-dependencies to 2.8.0 #1833- chore: update Rust required version to 1.80.0
-
fix: Added the following VM fixes: #1820
- Fix zero segment location.
- Fix has_zero_segment naming.
- Fix prover input.
- Fix version reading when no version is supplied.
-
chore: bump
cairo-lang-dependencies to 2.7.1 #1823
-
fix(BREAKING): #1818:
- Fix
MemorySegmentManager::add_zero_segmentfunction when resizing a segment - Signature change(BREAKING):
MemorySegmentManager::get_memory_holesnow receivesbuiltin_segment_indexes: HashSet<usize>
- Fix
-
fix(BREAKING): Replace
CairoRunnermethodinitialize_all_builtinswithinitialize_program_builtins. Now it only initializes program builtins instead of all of them
-
chore: bump
cairo-lang-dependencies to 2.7.0 #1813 -
fix(BREAKING): Don't assume output builtin is first when counting memory holes
- Logic change: Memory hole counting no longer asumes that the output builtin ocuppies the first builtin segment if present
- Signature change:
MemorySegmentManagermethodget_memory_holesnow receives the index of the output builtin (as anOption<usize>) instead of the boolean argumenthas_output_builtin#1811
-
fix: ambiguous keccak module name use on external contexts #1809
- chore: bump
cairo-lang-dependencies to 2.7.0-rc.3 #1807- chore: update Rust required version to 1.76.0
- fix: Fixed deserialization of negative numbers in scientific notation #1804
-
chore: bump
cairo-lang-dependencies to 2.6.4 #1799- fix: revert breaking change on public input serialization
-
fix: Remove validation of CairoPie memory values #1783
-
fix: Handle
GasBuiltinin cairo1-run crate #1789- Load
initial_gasinto vm instead of creating it via instructions. - Fix bug affecting programs with input arguments and gas builtin.
- Load
-
fix: Change (de)serialization of CairoPie's
OutputBuiltinAdditionalData'sPublicMemoryPageto vectors of length 2. #1781 -
fix: Fixed deserialization issue when signature additional data is empty, and the name of the builtin range_check96 #1785
-
refactor + bugfix: Improve arg handling for cairo1-run #1782
- Now uses ascii whitespace as separator, preventing errors when using newlines in args file
- No longer gets stuck on improperly-formatted arrays
- Returns an informative clap error upon invalid felt strings instead of unwrapping
-
fix: Ignore memory order when comparing instances of
CairoPieMemory#1780 -
feat: Add
EXCESS_BALANCEhint #1777 -
feat(BREAKING): Use a cheatcode to relocate all dicts + Make temporary segment usage configurable #1776
- Add the flags
segment_arena_validation&use_temporary_segmentsto theCairo1HintProcessor&DictManagerExecScoperespectively. These flags will determine if real segments or temporary segments will be used when creating dictionaries. DictManagerExecScope::finalize_segmentno longer performs relocation and is ignored ifuse_temporary_segmentsis set to false.- Add method
DictManagerExecScope::relocate_all_dictionariesthat adds relocation rules for all tracked dictionaries, relocating them one next to the other in a new segment. - Add cheatcode
RelocateAllDictionariesto theCairo1HintProcessor, which calls the aforementioned method. - Add casm instruction to call the aforementioned cheatcode in
create_entry_codeif eitherproof_modeorappend_return_valuesare set to true, and segment arena is present.
- Add the flags
-
Bump
starknet-types-coreversion + Use the lib's pedersen hash #1734 -
refactor: Add boolean method Cairo1RunConfig::copy_to_output + Update Doc #1778
-
feat: Filter implicit arguments from return value in cairo1-run crate #1775
-
feat(BREAKING): Serialize inputs into output segment in cairo1-run crate:
-
Checks that only
Array<Felt252>can be received by the program main function when running with with either--proof_modeor--append_return_values. -
Copies the input value to the output segment right after the output in the format
[array_len, arr[0], arr[1],.., arr[n]].* feat: specify initial value for `exec_scopes` in `cairo_run_program` [1772](https://github.com/starkware-libs/cairo-vm/pull/1772)
-
-
fix: make MemorySegmentManager.finalize() public #1771
-
feat: load Cairo PIE from bytes #1773
-
feat(BREAKING): Serialize
Array<Felt252>return value into output segment in cairo1-run crate:- Checks that only
PanicResult<Array<Felt252>>orArray<Felt252>can be returned by the program when running with either--proof_modeor--append_return_values. - Serializes return values into the output segment under the previous conditions following the format:
PanicResult<Array<Felt252>>->[panic_flag, array_len, arr[0], arr[1],.., arr[n]]<Array<Felt252>->[array_len, arr[0], arr[1],.., arr[n]]
- Checks that only
-
feat: Handle
BoundedIntvariant inserialize_output,cairo1-runcrate #1768 -
fix: make
OutputBuiltinStatepublic #1769 -
feat: Load arguments into VM instead of creating them via instructions in cairo1-run #1759
-
bugfix: Fix handling of return values wrapped in
PanicResultin cairo1-run crate #1763 -
refactor(BREAKING): Move the VM back to the CairoRunner #1743
CairoRunnerhas a new public fieldvm: VirtualMachineCairoRunnerno longer derivesDebugCairoRunnermethodsnew_v2&newtake an extra boolean argumenttrace_enabled.- Functions
cairo_run,cairo_run_program&cairo_run_fuzzed_programfromvmcrate andcairo_run_programfromcairo1-runcrate now return onlyCairoRunnerinstead of(CairoRunner, VirtualMachine) CairoRunnermethods no longer take a reference toVirtualMachine. Methods that took an immutable reference to self and a mutable reference to the VM now take a mutable reference to self. Affected methods:initializeinitialize_builtinsinitialize_all_builtinsinitialize_segmentsinitialize_stateinitialize_function_entrypointinitialize_stateinitialize_main_entrypointinitialize_vmrun_until_pcrun_for_stepsrun_until_stepsrun_until_power_of_2get_perm_range_check_limitscheck_range_check_usageget_memory_holescheck_diluted_check_usageend_runrelocate_tracerelocate_memoryrelocateget_builtin_segments_infoget_builtin_segments_info_for_pieget_execution_resourcesfinalize_segmentsrun_from_entrypointcheck_used_cellscheck_memory_usageinitialize_function_runner_cairo_1initialize_function_runnerread_return_valuesget_builtins_final_stackget_cairo_pieget_air_public_inputget_air_private_inputget_memory_segment_addresses
- Functions & methods taking a reference to
CairoRunner&VirtualMachinenow only take a reference toCairoRunner:start_tracerVmException::from_vm_errorget_error_attr_valueget_tracebackverify_secure_runner
- [hooks feature]
BeforeFirstStepHookFuncdyn Fn no longer takes a mutable reference toCairoRunner, along withVirtualMachine::execute_before_first_step.
-
fix: add support for arrays shorter than 2 as arguments for cairo1-run #1737
-
bugfix: Fix BuiltinRunner::final_stack for SegmentArena#1747
-
feat: unify
arbitrary,hooks,printandskip_next_instruction_hintfeatures as a singletest_utilsfeature #1755- BREAKING: removed the above features
-
bugfix: cairo1-run CLI: Set finalize_builtins to true when using --air_public_input flag #1744
-
feat: Add hint
U256InvModNtoCairo1HintProcessor#1744 -
perf: use a more compact representation for
MemoryCell#1672- BREAKING:
Memory::get_valuewill now always returnCow::Ownedvariants, code that relied onCow::Borrowedmay break
- BREAKING:
-
cairo1-runCLI: Allow loading arguments from file#1739 -
BREAKING: Remove unused
CairoRunnerfieldoriginal_steps#1742 -
feat: Add
--run_from_cairo_pietocairo-vm-cli+ workflow #1730 -
Serialize directly into writer in
CairoPie::write_zip_file#1736 -
feat: Add support for cairo1 run with segements arena validation.
- Refactored the runner CASM code generation to user a more high level builder.
- Added segment merging of the dictionary segments.
- Added validation of the generated segment arena in cairo1 run.
-
refactor: Add
lib.rsto cairo1-run#1714 -
feat: Implement
CairoPie::read_zip_file#1729 -
feat: Bump to 2.6.3 + Remove gas checks#1709
- Bump cairo_lang crates & corelib to v2.6.3
- Disable gas checks when compiling to sierra & casm
- Add
Known bugs & issuessegment to README, poining out issues derived from the removal of gas checks and cairo v2.6.3
-
feat: Implement running from
CairoPie#1720- Add function
cairo_run_pie - Add
CairoPiemethodsrun_validity_checks&check_pie_compatibility - Add
Programmethodfrom_stripped_program
- Add function
-
bugfix: Don't assume outer deref when fetching integer values from references#1732
-
feat: Implement
extend_additional_dataforBuiltinRunner#1726 -
BREAKING: Set dynamic params as null by default on air public input #1716
PublicInputfieldlayout_paramsrenamed todynamic_params& type changed from&'a CairoLayoutto().
-
feat:
cairo1-runaccepts Sierra programs #1719 -
refactor(BREAKING): Use
BuiltinNameenum instead of string representation #1722BuiltinNamemoved fromcrate::serde::deserialize_programmodule tocrate::types::builtin_name.- Implement
BuiltinNamemethodsto_str,to_str_with_suffix,from_str&from_str_with_suffix.
- Implement
- Remove
BuiltinNamemethodname. - All builtin-related error variants now store
BuiltinNameinstead of&'static strorString. - Remove constants:
OUTPUT_BUILTIN_NAME,HASH_BUILTIN_NAME,RANGE_CHECK_BUILTIN_NAME,RANGE_CHECK_96_BUILTIN_NAME,SIGNATURE_BUILTIN_NAME,BITWISE_BUILTIN_NAME,EC_OP_BUILTIN_NAME,KECCAK_BUILTIN_NAME,POSEIDON_BUILTIN_NAME,SEGMENT_ARENA_BUILTIN_NAME,ADD_MOD_BUILTIN_NAME&MUL_MOD_BUILTIN_NAME. - Remove
BuiltinRunner&ModBuiltinRunnermethodidentifier - Structs containing string representation of builtin names now use
BuiltinNameinstead:AirPrivateInput(pub HashMap<&'static str, Vec<PrivateInput>>)->AirPrivateInput(pub HashMap<BuiltinName, Vec<PrivateInput>>).CairoPieMetadatafieldadditional_data:HashMap<String, BuiltinAdditionalData>,->CairoPieAdditionalDatawithCairoPieAdditionalData(pub HashMap<BuiltinName, BuiltinAdditionalData>)CairoPieMetadatafieldbuiltin_segments:HashMap<String, SegmentInfo>->HashMap<BuiltinName, SegmentInfo>.ExecutiobResourcesfieldbuiltin_instance_counter:HashMap<String, usize>->HashMap<BuiltinName, usize>
- Methods returning string representation of builtin names now use
BuiltinNameinstead:BuiltinRunner,ModBuiltinRunner&RangeCheckBuiltinRunnermethodname:&'static str->BuiltinName.CairoRunnermethodget_builtin_segment_info_for_pie:Result<HashMap<String, cairo_pie::SegmentInfo>, RunnerError>->Result<HashMap<BuiltinName, cairo_pie::SegmentInfo>, RunnerError>
Notes: Serialization of vm outputs that now contain
BuiltinName&Displayimplementation ofBuiltinNamehave not been affected by this PR -
feat: Add
recursive_with_poseidonlayout#1724 -
refactor(BREAKING): Use an enum to represent layout name#1715
- Add enum
LayoutNameto represent cairo layout names. CairoRunConfig,Cairo1RunConfig&CairoRunnerfieldlayouttype changed fromStringtoLayoutName.CairoLayoutfieldnametype changed fromStringtoLayoutName.
- Add enum
-
fix(BREAKING): Remove unsafe impl of
Add<usize> for &'a Relocatable#1718 -
fix(BREAKING): Handle triple dereference references#1708
- Replace
ValueAddressboolean fielddereferencewith boolean fieldsouter_dereference&inner_dereference - Replace
HintReferenceboolean fielddereferencewith boolean fieldsouter_dereference&inner_dereference - Reference parsing now handles the case of dereferences inside the cast. Aka references of type
cast([A + B], type)such ascast([[fp + 2] + 2], felt).
- Replace
-
Bump
starknet-types-coreversion + Use the lib's pedersen hash #1692 -
refactor: Remove unused code & use constants whenever possible for builtin instance definitions#1707
-
feat: missing EC hints for Starknet OS 0.13.1 #1706
-
fix(BREAKING): Use program builtins in
initialize_main_entrypoint&read_return_values#1703initialize_main_entrypointnow iterates over the program builtins when building the stack & inserts 0 for any missing builtinread_return_valuesnow only computes the final stack of the builtins in the program- BREAKING:
read_return_valuesnow takes a boolean argumentallow_missing_builtins - Added method
BuiltinRunner::identifierto get theBuiltinNameof each builtin - BREAKING:
OutputBuiltinRunner::get_public_memorynow takes a reference toMemorySegmentManager - BREAKING: method
VirtualMachine::get_memory_segment_addressesmoved toCairoRunner::get_memory_segment_addresses
-
feat(BREAKING): Add range_check96 builtin#1698
- Add the new
range_check96builtin to theall_cairolayout. RangeCheckBuiltinRunnerchanges:- Remove field
n_parts, replacing it with const genericN_PARTS. - Remome
n_partsargument form methodnew. - Remove field
_bound, replacing it with public methodbound. - Add public methods
name&n_parts.
- Remove field
- Add the new
-
feat(BREAKING): Add mod builtin #1673
Main Changes:
- Add the new
ModBuiltinRunner, implementing the builtinsadd_mod&mul_mod - Adds
add_mod&mul_modto theall_cairo&dynamiclayouts under themod_builtinfeature flag. This will be added to the main code in a future update. - Add method
VirtualMachine::fill_memoryin order to perform the new builtin's main logic from within hints - Add hints to run arithmetic circuits using
add_modand/ormul_modbuiltins
Other Changes:
- BREAKING: BuiltinRunner method signature change from
air_private_input(&self, memory: &Memory) -> Vec<PrivateInput>topub fn air_private_input(&self, segments: &MemorySegmentManager) -> Vec<PrivateInput> - Add
MayleRelocatable::sub_usize - Implement
Add<u32> for Relocatable - Add
Memory::get_usize - BREAKING: Clean up unused/duplicated code from builtins module:
- Remove unused method
get_memory_segment_addressesfrom all builtin runners & the enum - Remove empty implementations of
deduce_memory_cell&add_validation_rulesfrom all builtin runners - Remove duplicated implementation of
final_stackfrom all builtin runners except output and move it to the enum implementation
- Remove unused method
- Add the new
-
bugfix(BREAKING): Handle off2 immediate case in
get_integer_from_reference#1701get_integer_from_reference&get_integer_from_var_nameoutput changed fromResult<Cow<'a, Felt252>, HintError>toResult<Felt252, HintError>
-
feat: Reorganized builtins to be in the top of stack at the end of a run (Cairo1).
-
BREAKING: Remove
CairoRunner::add_additional_hash_builtin&VirtualMachine::disable_trace#1658 -
feat: output builtin add_attribute method #1691
-
feat: add a method to retrieve the output builtin from the VM #1690
-
feat: Add zero segment #1668
-
feat: Bump cairo_lang to 0.13.1 in testing env #1687
-
feat(BREAKING): Use return type info from sierra when serializing return values in cairo1-run crate #1665
- Removed public function
serialize_output. - Add field
serialize_outputtoCairo1RunConfig. - Function
cairo_run_programnow returns an extraOption<String>value with the serialized output ifserialize_outputis enabled in the config. - Output serialization improved as it now uses the sierra program data to identify return value's types.
- Removed public function
-
feat: Create hyper_threading crate to benchmark the
cairo-vmin a hyper-threaded environment #1679 -
feat: add a
--traceroption which hosts a web server that shows the line by line execution of cairo code along with memory registers #1265 -
feat: Fix error handling in
initialize_state#1657 -
feat: Make air public inputs deserializable #1657
-
feat: Show only layout builtins in air private input #1651
-
feat: Sort builtin segment info upon serialization for Cairo PIE #1654
-
feat: Fix output serialization for cairo 1 #1645
- Reverts changes added by #1630
- Extends the serialization of Arrays added by the
print_outputflag to Spans and Dictionaries - Now dereferences references upon serialization
-
feat: Add flag to append return values to output segment when not running in proof_mode #1646
- Adds the flag
append_return_valuesto both the CLI andCairo1RunConfigstruct. - Enabling flag will add the output builtin and the necessary instructions to append the return values to the output builtin's memory segment.
- Adds the flag
-
feat: Compute program hash chain #1647
-
feat: Add cairo1-run output pretty-printing for felts, arrays/spans and dicts #1630
-
feat: output builtin features for bootloader support #1580
-
Bump
starknet-types-coredependency version to 0.0.9 #1628 -
feat: Implement
DisplayforMemorySegmentManager#1606 -
fix: make Felt252DictEntryUpdate work with MaybeRelocatable instead of only Felt #1624.
-
chore: bump
cairo-lang-dependencies to 2.5.4 #1629 -
chore: bump
cairo-lang-dependencies to 2.5.3 #1596 -
refactor: Refactor
cairo1-runcrate #1601- Add function
cairo_run_program& structCairo1RunConfigincairo1-run::cairo_runmodule. - Function
serialize_output& structsFuncArgandErrorin cratecairo1-runare now public.
- Add function
-
feat(BREAKING): Add
allow_missing_builtinsflag #1600This new flag will skip the check that all builtins used by the program need to be present in the selected layout if enabled. It will also be enabled by default when running in proof_mode.
- Add
allow_missing_builtinsflag tocairo-vm-clicrate - Add
allow_missing_builtinsfield toCairoRunConfigstruct - Add
allow_missing_builtinsboolean argument toCairoRunnermethodsinitialize&initialize_builtins
- Add
-
feat: Append return values to the output segment when running cairo1-run in proof_mode #1597
- Add instructions to the proof_mode header to copy return values to the output segment before initiating the infinite loop
- Output builtin is now always included when running cairo 1 programs in proof_mode
-
feat: deserialize AIR private input #1589
-
feat(BREAKING): Remove unecessary conversion functions between
Felt&BigUint/BigInt#1562- Remove the following functions:
- felt_from_biguint
- felt_from_bigint
- felt_to_biguint
- felt_to_bigint
- Remove the following functions:
-
perf: optimize instruction cache allocations by using
VirtualMachine::load_data#1441 -
feat: Add
print_outputflag tocairo-1crate [#1575] (#1575) -
bugfixes(BREAKING): Fix memory hole count inconsistencies #[1585] (#1585)
- Output builtin memory segment is no longer skipped when counting memory holes
- Temporary memory cells now keep their accessed status when relocated
- BREAKING: Signature change:
get_memory_holes(&self, builtin_count: usize) -> Result<usize, MemoryError>->get_memory_holes(&self, builtin_count: usize, has_output_builtin: bool) -> Result<usize, MemoryError>
-
feat: Add
cairo_pie_outputflag tocairo1-run[#1581] (#1581) -
feat: Add
cairo_pie_outputflag tocairo_vm_cli[#1578] (#1578)- Fix serialization of CairoPie to be fully compatible with the python version
- Add
CairoPie::write_zip_file - Move handling of required and exclusive arguments in
cairo-vm-clito struct definition using clap derives
-
feat: Add doc + default impl for ResourceTracker trait [#1576] (#1576)
-
feat: Add
air_private_inputflag tocairo1-run[#1559] (#1559) -
feat: Add
argsflag tocairo1-run[#1551] (#1551) -
feat: Add
air_public_inputflag tocairo1-run[#1539] (#1539) -
feat: Implement air_private_input #1552
-
feat: Add
proof_modeflag tocairo1-run[#1537] (#1537)- The cairo1-run crate no longer compiles and executes in proof_mode by default
- Add flag
proof_modeto cairo1-run crate. Activating this flag will enable proof_mode compilation and execution
-
dev: bump cairo 1 compiler dep to 2.4 #1530
-
feat: Use
ProjectivePointfrom types-rs in ec_op builtin impl #1532 -
feat(BREAKING): Replace
cairo-feltcrate withstarknet-types-core(0.0.5) #1408 -
feat(BREAKING): Add Cairo 1 proof mode compilation and execution [#1517] (#1517)
- In the cairo1-run crate, now the Cairo 1 Programs are compiled and executed in proof-mode
- BREAKING: Remove
CairoRunner.proof_mode: boolfield and replace it withCairoRunner.runner_mode: RunnerMode
-
perf: Add
extensive_hintsfeature to prevent performance regression for the common use-case [#1503] (#1503)- Gates changes added by #1491 under the feature flag
extensive_hints
- Gates changes added by #1491 under the feature flag
-
chore: remove cancel-duplicates workflow #1497
-
feat: Handle
pcs outside of program segment inVmException[#1501] (#1501)VmExceptionnow shows the full pc value instead of just the offset (VmException.pcfield type changed toRelocatable)VmException.tracebacknow shows the full pc value for each entry instead of hardcoding its index to 0.- Disable debug information for errors produced when
pcis outside of the program segment (segment_index != 0).VmExceptionfieldsinst_location&error_attr_valuewill beNonein such case.
-
feat: Allow running instructions from pcs outside the program segement #1493
-
BREAKING: Partially Revert
Optimize trace relocation #906#1492- Remove methods
VirtualMachine::get_relocated_trace&VirtualMachine::relocate_trace. - Add
relocated_tracefield &relocate_tracemethod toCairoRunner. - Swap
TraceEntryforRelocatedTraceEntrytype inwrite_encoded_trace&PublicInput::newsignatures. - Now takes into account the program counter's segment index when building the execution trace instead of assuming it to be 0.
- Remove methods
-
feat: Add HintProcessor::execute_hint_extensive + refactor hint_ranges #1491
-
Add trait method
HintProcessorLogic::execute_hint_extensive:- This method has a similar behaviour to
HintProcessorLogic::execute_hintbut it also returns aHintExtension(type alias forHashMap<Relocatable, Vec<Box<dyn Any>>>) that can be used to extend the current map of hints used by the VM. This behaviour achieves what thevm_load_dataprimitive does for cairo-lang, and is needed to implement os hints. - This method is now used by the VM to execute hints instead of
execute_hint, but it's default implementation callsexecute_hint, so current implementors of theHintProcessortrait won't notice any change.
- This method has a similar behaviour to
-
Signature changes:
pub fn step_hint(&mut self, hint_executor: &mut dyn HintProcessor, exec_scopes: &mut ExecutionScopes, hint_datas: &mut Vec<Box<dyn Any>>, constants: &HashMap<String, Felt252>) -> Result<(), VirtualMachineError>->pub fn step_hint(&mut self, hint_processor: &mut dyn HintProcessor, exec_scopes: &mut ExecutionScopes, hint_datas: &mut Vec<Box<dyn Any>>, hint_ranges: &mut HashMap<Relocatable, HintRange>, constants: &HashMap<String, Felt252>) -> Result<(), VirtualMachineError>pub fn step(&mut self, hint_executor: &mut dyn HintProcessor, exec_scopes: &mut ExecutionScopes, hint_data: &[Box<dyn Any>], constants: &HashMap<String, Felt252>) -> Result<(), VirtualMachineError>->pub fn step(&mut self, hint_processor: &mut dyn HintProcessor, exec_scopes: &mut ExecutionScopes, hint_datas: &mut Vec<Box<dyn Any>>, hint_ranges: &mut HashMap<Relocatable, HintRange>, constants: &HashMap<String, Felt252>) -> Result<(), VirtualMachineError>
-
-
feat: add debugging capabilities behind
printfeature flag. #1476 -
feat: add
cairo_run_programfunction that takes aProgramas an arg. #1496
-
feat: Make PublicInput fields public #1474
-
chore: bump starknet-crypto to v0.6.1 #1469
-
feat: Implement the Serialize and Deserialize methods for the Program struct #1458
-
feat: Use only program builtins when running cairo 1 programs #1457
-
feat: Use latest cairo-vm version in cairo1-run crate #1455
-
feat: Implement a CLI to run cairo 1 programs #1370
-
fix: Fix string code of
BLAKE2S_ADD_UINT256hint #1454
-
fix: Default to empty attributes vector when the field is missing from the program JSON #1450
-
fix: Change serialization of CairoPieMemory to match Python's binary format #1447
-
fix: Remove Deserialize derive from CairoPie and fix Serialize implementation to match Python's #1444
-
fix: ec_recover hints no longer panic when divisor is 0 #1433
-
feat: Implement the Serialize and Deserialize traits for the CairoPie struct #1438
-
fix: Using UINT256_HINT no longer panics when b is greater than 2^256 #1430
-
feat: Added a differential fuzzer for programs with whitelisted hints #1358
-
fix(breaking): Change return type of
get_execution_resourcestoRunnerError#1398 -
Don't build wasm-demo in
buildtarget + add ci job to run the wasm demo #1393- Adds default-members to workspace
- Crate
examples/wasm-demois no longer built duringmake build make checkno longer compiles the cairo file used in the wasm-demo- Removes Makefile targets
examples/wasm-demo/src/array_sum.json&example_program wasm-demonow uses the compiled cairo file incairo_programsdirectory instead of its own copy
-
feat: Add
Program::new_for_proof#1396
-
Add REDUCE_V2 hint #1420:
- Implement REDUCE_V2 hint
- Rename hint REDUCE -> REDUCE_V1
-
BREAKING: Add
disable_trace_paddingtoCairoRunConfig#1233 -
feat: Implement
CairoRunner.get_cairo_pie#1375 -
fix: Compare air_public_inputs against python vm + Fix how public memory is built #391
BugFixes:
CairoRunner.finalize_segmentsnow builds the output builtin's public memory (if applicable).MemorySegmentManager.get_public_memory_addresseslogic fixed.MemorySegmentManager.finalizeno longer skips segments when their public memory is None
Minor changes:
VirtualMachine.get_public_memory_addressesnow strips the "_builtin" suffix from builtin namesMemorySegmentAddresses.stop_addressrenamed tostop_ptr
Overall these changes make the the air public input file (obtained through the --air_public_input flag) equivalent to the ones outputted by the cairo-lang version
-
fix: Fix
SPLIT_FELThint #1387 -
refactor: combine
Program.hintsandProgram.hints_rangesinto custom collection #1366 -
fix: Fix div_mod #1383
- Fixes
div_modfunction so that it behaves like the cairo-lang version - Various functions in the
math_utilscrate can now return aMathError:div_mod,ec_add,line_slope,ec_double,ec_double_slope. - Fixes
UINT256_MUL_INV_MOD_Phint so that it behaves like the python code.
- Fixes
-
fix: Handle error in hint
UINT256_MUL_DIV_MODwhen divides by zero #1367 -
Add HintError::SyscallError and VmErrors::HINT_ERROR_STR constant #1357
-
feat: make arbitrary feature also enable a
proptest::arbitrary::Arbitraryimplementation forFelt252#1355 -
fix: correctly display invalid signature error message #1361
-
fix:
Programcomparison depending onhints_rangesordering #1351 -
feat: implement the
--air_public_inputflag to the runner for outputting public inputs into a file #1268 -
fix: CLI errors bad formatting and handling
-
perf: replace insertion with bit-setting in validated addresses #1208
-
fix: return error when a parsed hint's PC is invalid #1340
-
chore(deps): bump cairo-lang dependencies to v2.1.0-rc2 #1345
-
chore(examples): remove wee_alloc dependency from wasm-demo example and ensure-no_std dummy crate #1337
-
docs: improved crate documentation #1334
-
chore!: made
deserialize_utilsmodule private #1334 BREAKING:deserialize_utilsis no longer exported- functions
maybe_add_padding,parse_value, andtake_until_unbalancedare no longer exported ReferenceParseErroris no more
-
perf: changed
ok_orusage forok_or_elsein expensive cases #1332 -
feat: updated the old WASM example and moved it to
examples/wasm-demo#1315 -
feat(fuzzing): add
arbitraryfeature to enable arbitrary derive inProgramandCairoRunConfig#1306 #1330 -
perf: remove pointless iterator from rc limits tracking #1316
-
feat(felt): add
from_bytes_leandfrom_bytes_nemethods toFelt252#1326 -
perf: change
Program::shared_program_data::hintsfromHashMap<usize, Vec<Box<dyn Any>>>toVec<Box<dyn Any>>and refer to them as ranges stored in aVec<_>indexed by PC with run time reductions of up to 12% #931 BREAKING:get_hint_dictionary(&self, &[HintReference], &mut dyn HintProcessor) -> Result<HashMap<usize, Vec<Box<dyn Any>>, VirtualMachineError>->get_hint_data(self, &[HintReference], &mut dyn HintProcessor) -> Result<Vec<Box<dyn Any>, VirtualMachineError>- Hook methods receive
&[Box<dyn Any>]rather than&HashMap<usize, Vec<Box<dyn Any>>>
YANKED
YANKED
-
chore: update dependencies, particularly lamdaworks 0.1.2 -> 0.1.3 #1323
-
fix: fix
UINT256_MUL_DIV_MODhint #1320 -
feat: add dependency installation script
install.sh#1298 -
fix: specify resolver version 2 in the virtual workspace's manifest #1311
-
feat: add
lambdaworks-feltfeature tocairo-vm-cli#1308 -
chore: update dependencies, particularly clap 3.2 -> 4.3 #1309
- this removes dependency on atty, that's no longer mantained
-
chore: remove unused dependencies #1307
- rand_core
- serde_bytes
- rusty-hook (dev-dependency)
-
chore: bump
cairo-lang-starknetandcairo-lang-casmdependencies to 2.0.0 #1313
-
chore: change mentions of cairo-rs-py to cairo-vm-py #1296
-
rename github repo from https://github.com/lambdaclass/cairo-rs to https://github.com/starkware-libs/cairo-vm #1289
-
fix(security): avoid OOM crashes when programs jump to very high invalid addresses #1285
-
fix: add
to_bytes_beto the felt whenlambdaworks-feltfeature is active #1290 -
chore: mark
modpowandto_signed_bytes_leas deprecated #1290 -
fix: bump lambdaworks-math to latest version, that fixes no-std support #1293
-
build: remove dependency to
thiserror(usethiserror-no-std/stdinstead) -
chore: use LambdaWorks' implementation of bit operations for
Felt252#1291 -
update
cairo-lang-starknetandcairo-lang-casmdependencies to v2.0.0-rc6 #1299
-
feat: Add feature
lambdaworks-felttofelt&cairo-vmcrates #1281Changes under this feature:
Felt252now uses LambdaWorks'FieldElementinternally- BREAKING: some methods of
Felt252were removed, namely:modpowandto_signed_bytes_le
-
BREAKING: Integrate
RunResourceslogic intoHintProcessortrait #1274- Rename trait
HintProcessortoHintProcessorLogic - Add trait
ResourceTracker - Trait
HintProcessoris nowHintProcessor: HintProcessorLogic + ResourceTracker BuiltinHintProcessor::new&Cairo1HintProcessor::newnow receive the argumetrun_resources: RunResourcesHintProcessorLogic::execute_hintno longer receivesrun_resources: &mut RunResources- Remove argument
run_resources: &mut RunResourcesfromCairoRunner::run_until_pc&CairoRunner::run_from_entrypoint
- Rename trait
-
build: remove unused implicit features from cairo-vm #1266
-
fix: updated the
custom_hint_exampleand added it to the workspace #1258 -
Add path to cairo-vm README.md #1276
-
fix: change error returned when subtracting two
MaybeRelocatables to better reflect the cause #1271 -
fix: CLI error message when using --help #1270
-
fix:
dibithint no longer fails when called with anmof zero #1247 -
fix(security): avoid denial of service on malicious input exploiting the scientific notation parser #1239
-
BREAKING: Change
RunResourcesusage:-
Modify field type
RunResources.n_steps: Option<usize>, -
Public Api Changes:
- CairoRunner::run_until_pc: Now receive a
&mut RunResourcesinstead of an&mut Option<RunResources> - CairoRunner::run_from_entrypoint: Now receive a
&mut RunResourcesinstead of an&mut Option<RunResources> - VirtualMachine::Step: Add
&mut RunResourcesas input - Trait HintProcessor::execute_hint: Add
&mut RunResourcesas an input
- CairoRunner::run_until_pc: Now receive a
-
-
perf: accumulate
minandmaxinstruction offsets during run to speed up range check #1080 BREAKING:Cairo_runner::get_perm_range_check_limitsno longer returns an error when called without trace enabled, as it no longer depends on it -
perf: process reference list on
Programcreation only #1214 Also keep them in aVec<_>instead of aHashMap<_, _>since it will be continuous anyway. BREAKING:HintProcessor::compile_hintnow receies a&[HintReference]rather than&HashMap<usize, HintReference>- Public
CairoRunner::get_reference_listhas been removed
-
BREAKING: Add no_std compatibility to cairo-vm (cairo-1-hints feature still not supported)
-
Move the vm to its own directory and crate, different from the workspace #1215
-
Add an
ensure_no_stdcrate that the CI will use to check that new changes don't revertno_stdsupport #1215 #1232 -
replace the use of
num-prime::is_primeby a custom implementation, therefore restoringno_stdcompatibility #1238
-
-
BREAKING: Compute
ExecutionResources.n_stepswithout requiring trace #1222CairoRunner::get_execution_resourcesreturn'sn_stepsfield value is now set tovm.current_stepinstead of0if bothoriginal_stepsandtraceare set toNone
-
Add
RunResources::get_n_stepsmethod #1225 -
refactor: simplify
mem_eq -
fix: pin Cairo compiler version #1220
-
perf: make
inner_rc_bounda constant, improving performance of the range-check builtin -
fix: substraction of
MaybeRelocatablealways behaves as signed #1218
-
fix: fix overflow for
QUAD_BITandDI_BIThints #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_eqfunction to test for equality of two ranges in memory #1198 -
perf: use
mem_eqinset_add#1198 -
feat: wrap big variants of
HintError,VirtualMachineError,RunnerError,MemoryError,MathError,InsufficientAllocatedCellsErrorinBox#1193- BREAKING: all tuple variants of
HintErrorwith a singleFelt252or 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_pcarity. Addrun_resources: &mut Option<RunResources>input - BREAKING: Modify
CairoRunner::run_from_entrypointarity. 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_BIThint #1187 -
bugfix: Fix
EC_DOUBLE_ASSIGN_NEW_X_V2hint not takingSECP_Pvalue from the current execution scope #1186 -
fix: Fix hint
BIGINT_PACK_DIV_MOD#1189 -
fix: Fix possible subtraction overflow in
QUAD_BIT&DI_BIThints #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
Felt252methodsabs,signum,is_positive,is_negativeandsqrt - 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
builtinsfromSharedProgramDatatoProgram -
BREAKING: Remove argument
add_segment_arena_builtinfromCairoRunner::initialize_function_runner, it is now always false -
BREAKING: Add
segment_arenaenum variant toBuiltinName
-
-
Fix implementation of
InitSquashDataandShouldSkipSquashLoop -
Add more hints to
Cairo1HintProcessor#1171 #1143Cairo1HintProcessorcan 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
CasmContractClassfiles undercairo-1-hintsfeature #1098- Implement
TryFrom<CasmContractClass> for Program - Add
Cairo1HintProcessor
- Implement
YANKED
-
perf: insert elements from the tail in
load_dataso 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
BuiltinHintProcessornow 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:
BuiltinHintProcessornow 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:
BuiltinHintProcessornow 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
BuiltinHintProcessornow 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
BuiltinHintProcessornow 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
BuiltinHintProcessornow 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
u64andFelt252#932- Avoids the creation of a new
Felt252instance for additions with a very restricted valid range - This impacts specially the addition of
RelocatablewithFelt252values 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
BuiltinHintProcessornow 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#1077BuiltinHintProcessornow 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_inputsas described by whiteliststarknet/security/whitelists/cairo_keccak.json#1058BuiltinHintProcessornow supports the following hint:%{ ids.full_word = int(ids.n_bytes >= 8) %}
-
perf: cache decoded instructions #944
- Creates a new cache field in
VirtualMachinethat stores theInstructioninstances 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
BuiltinHintProcessornow 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:
BuiltinHintProcessornow 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
BuiltinHintProcessornow 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:
BuiltinHintProcessornow 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) x = pack(ids.point.x, PRIME) y = pack(ids.point.y, PRIME) value = new_x = (pow(slope, 2, SECP_P) - 2 * x) % SECP_P %}
-
Implement hint on 0.6.0.json whitelist #1044:
BuiltinHintProcessornow supports the following hints:%{ ids.a_lsb = ids.a & 1 ids.b_lsb = ids.b & 1 %}
-
Implement hint for
starkware.cairo.common.cairo_keccak.keccak._block_permutationas described by whiteliststarknet/security/whitelists/cairo_keccak.json#1046BuiltinHintProcessornow supports the following hint:%{ from starkware.cairo.common.cairo_keccak.keccak_utils import keccak_func _keccak_state_size_felts = int(ids.KECCAK_STATE_SIZE_FELTS) assert 0 <= _keccak_state_size_felts < 100 output_values = keccak_func(memory.get_range( ids.keccak_ptr_start, _keccak_state_size_felts)) segments.write_arg(ids.output, output_values) %}
-
Implement hint on cairo_blake2s whitelist #1040
BuiltinHintProcessornow supports the following hint:%{ from starkware.cairo.common.cairo_blake2s.blake2s_utils import IV, blake2s_compress _blake2s_input_chunk_size_felts = int(ids.BLAKE2S_INPUT_CHUNK_SIZE_FELTS) assert 0 <= _blake2s_input_chunk_size_felts < 100 new_state = blake2s_compress( message=memory.get_range(ids.blake2s_start, _blake2s_input_chunk_size_felts), h=[IV[0] ^ 0x01010020] + IV[1:], t0=ids.n_bytes, t1=0, f0=0xffffffff, f1=0, ) segments.write_arg(ids.output, new_state) %}
-
Implement hint on cairo_blake2s whitelist #1039
BuiltinHintProcessornow 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 = (modified_iv + message + [0, 0xffffffff] + output) * (_n_packed_instances - 1) segments.write_arg(ids.blake2s_ptr_end, padding) %}
-
Add
Program::iter_identifiers(&self) -> Iterator<Item = (&str, &Identifier)>to get an iterator over the program's identifiers #1079 -
Implement hint on
assert_le_feltfor versions 0.6.0 and 0.8.2 #1047:BuiltinHintProcessornow supports the following hints:%{ from starkware.cairo.common.math_utils import assert_integer assert_integer(ids.a) assert_integer(ids.b) assert (ids.a % PRIME) <= (ids.b % PRIME), \ f'a = {ids.a % PRIME} is not less than or equal to b = {ids.b % PRIME}.' %}
%{ from starkware.cairo.common.math_utils import assert_integer assert_integer(ids.a) assert_integer(ids.b) a = ids.a % PRIME b = ids.b % PRIME assert a <= b, f'a = {a} is not less than or equal to b = {b}.' ids.small_inputs = int( a < range_check_builtin.bound and (b - a) < range_check_builtin.bound) %}
-
Add missing hints on whitelist #1073:
BuiltinHintProcessornow supports the following hints:ids.is_250 = 1 if ids.addr < 2**250 else 0
# Verify the assumptions on the relationship between 2**250, ADDR_BOUND and PRIME. ADDR_BOUND = ids.ADDR_BOUND % PRIME assert (2**250 < ADDR_BOUND <= 2**251) and (2 * 2**250 < PRIME) and ( ADDR_BOUND * 2 > PRIME), \ 'normalize_address() cannot be used with the current constants.' ids.is_small = 1 if ids.addr < ADDR_BOUND else 0
-
Implement hint on ec_recover.json whitelist #1038:
BuiltinHintProcessornow supports the following hint:%{ value = k = product // m %}
-
Implement hint on ec_recover.json whitelist #1037:
BuiltinHintProcessornow supports the following hint:%{ from starkware.cairo.common.cairo_secp.secp_utils import pack from starkware.python.math_utils import div_mod, safe_div a = pack(ids.a, PRIME) b = pack(ids.b, PRIME) product = a * b m = pack(ids.m, PRIME) value = res = product % m %}
-
Implement hint for
starkware.cairo.common.cairo_keccak.keccak.finalize_keccakas described by whiteliststarknet/security/whitelists/cairo_keccak.json#1041BuiltinHintProcessornow supports the following hint:%{ # Add dummy pairs of input and output. _keccak_state_size_felts = int(ids.KECCAK_STATE_SIZE_FELTS) _block_size = int(ids.BLOCK_SIZE) assert 0 <= _keccak_state_size_felts < 100 assert 0 <= _block_size < 1000 inp = [0] * _keccak_state_size_felts padding = (inp + keccak_func(inp)) * _block_size segments.write_arg(ids.keccak_ptr_end, padding) %}
-
Implement hint on ec_recover.json whitelist #1036:
BuiltinHintProcessornow supports the following hint:%{ from starkware.cairo.common.cairo_secp.secp_utils import pack from starkware.python.math_utils import div_mod, safe_div a = pack(ids.a, PRIME) b = pack(ids.b, PRIME) value = res = a - b %}
-
Add missing hint on vrf.json lib #1054:
BuiltinHintProcessornow supports the following hint:from starkware.cairo.common.cairo_secp.secp_utils import pack SECP_P = 2**255-19 y = pack(ids.point.y, PRIME) % SECP_P # The modulo operation in python always returns a nonnegative number. value = (-y) % SECP_P
-
Implement hint on ec_recover.json whitelist #1032:
BuiltinHintProcessornow supports the following hint:%{ from starkware.cairo.common.cairo_secp.secp_utils import pack from starkware.python.math_utils import div_mod, safe_div N = pack(ids.n, PRIME) x = pack(ids.x, PRIME) % N s = pack(ids.s, PRIME) % N, value = res = div_mod(x, s, N) %}
-
Implement hints on field_arithmetic lib (Part 2) #1004
BuiltinHintProcessornow supports the following hint:%{ from starkware.python.math_utils import div_mod 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) # For python3.8 and above the modular inverse can be computed as follows: # b_inverse_mod_p = pow(b, -1, p) # Instead we use the python3.7-friendly function div_mod from starkware.python.math_utils b_inverse_mod_p = div_mod(1, b, p) b_inverse_mod_p_split = split(b_inverse_mod_p, num_bits_shift=128, length=3) ids.b_inverse_mod_p.d0 = b_inverse_mod_p_split[0] ids.b_inverse_mod_p.d1 = b_inverse_mod_p_split[1] ids.b_inverse_mod_p.d2 = b_inverse_mod_p_split[2] %}
-
Optimizations for hash builtin #1029:
- Track the verified addresses by offset in a
Vec<bool>rather than storing the address in aVec<Relocatable>
- Track the verified addresses by offset in a
-
Add missing hint on vrf.json whitelist #1056:
BuiltinHintProcessornow supports the following hint:%{ from starkware.python.math_utils import ec_double_slope from starkware.cairo.common.cairo_secp.secp_utils import pack SECP_P = 2**255-19 # Compute the slope. x = pack(ids.point.x, PRIME) y = pack(ids.point.y, PRIME) value = slope = ec_double_slope(point=(x, y), alpha=42204101795669822316448953119945047945709099015225996174933988943478124189485, p=SECP_P) %}
-
Add missing hint on vrf.json whitelist #1035:
BuiltinHintProcessornow supports the following hint:%{ from starkware.python.math_utils import line_slope from starkware.cairo.common.cairo_secp.secp_utils import pack SECP_P = 2**255-19 # Compute the slope. x0 = pack(ids.point0.x, PRIME) y0 = pack(ids.point0.y, PRIME) x1 = pack(ids.point1.x, PRIME) y1 = pack(ids.point1.y, PRIME) value = slope = line_slope(point1=(x0, y0), point2=(x1, y1), p=SECP_P) %}
-
Add missing hint on vrf.json whitelist #1035:
BuiltinHintProcessornow supports the following hint:%{ from starkware.cairo.common.cairo_secp.secp_utils import pack SECP_P = 2**255-19 to_assert = pack(ids.val, PRIME) q, r = divmod(pack(ids.val, PRIME), SECP_P) assert r == 0, f"verify_zero: Invalid input {ids.val.d0, ids.val.d1, ids.val.d2}." ids.q = q % PRIME %}
-
Add missing hint on vrf.json whitelist #1000:
BuiltinHintProcessornow supports the following hint:def pack_512(u, num_bits_shift: int) -> int: limbs = (u.d0, u.d1, u.d2, u.d3) return sum(limb << (num_bits_shift * i) for i, limb in enumerate(limbs)) x = pack_512(ids.x, num_bits_shift = 128) p = ids.p.low + (ids.p.high << 128) x_inverse_mod_p = pow(x,-1, p) x_inverse_mod_p_split = (x_inverse_mod_p & ((1 << 128) - 1), x_inverse_mod_p >> 128) ids.x_inverse_mod_p.low = x_inverse_mod_p_split[0] ids.x_inverse_mod_p.high = x_inverse_mod_p_split[1]
-
BREAKING CHANGE: Fix
CairoRunner::get_memory_holes#1027:- Skip builtin segements when counting memory holes
- Check amount of memory holes for all tests in cairo_run_test
- Remove duplicated tests in cairo_run_test
- BREAKING CHANGE:
MemorySegmentManager.get_memory_holesnow also receives the amount of builtins in the vm. Signature is nowpub fn get_memory_holes(&self, builtin_count: usize) -> Result<usize, MemoryError>
-
Add missing hints on cairo_secp lib #1026:
BuiltinHintProcessornow supports the following hints:from starkware.cairo.common.cairo_secp.secp256r1_utils import SECP256R1_ALPHA as ALPHA
and:
from starkware.cairo.common.cairo_secp.secp256r1_utils import SECP256R1_N as N
-
Add missing hint on vrf.json lib #1043:
BuiltinHintProcessornow supports the following hint:from starkware.python.math_utils import div_mod def split(a: int): return (a & ((1 << 128) - 1), a >> 128) def pack(z, num_bits_shift: int) -> int: limbs = (z.low, z.high) return sum(limb << (num_bits_shift * i) for i, limb in enumerate(limbs)) a = pack(ids.a, 128) b = pack(ids.b, 128) p = pack(ids.p, 128) # For python3.8 and above the modular inverse can be computed as follows: # b_inverse_mod_p = pow(b, -1, p) # Instead we use the python3.7-friendly function div_mod from starkware.python.math_utils b_inverse_mod_p = div_mod(1, b, p) b_inverse_mod_p_split = split(b_inverse_mod_p) ids.b_inverse_mod_p.low = b_inverse_mod_p_split[0] ids.b_inverse_mod_p.high = b_inverse_mod_p_split[1]
-
Add missing hints
NewHint#35andNewHint#36#975BuiltinHintProcessornow supports the following hint:from starkware.cairo.common.cairo_secp.secp_utils import pack from starkware.cairo.common.math_utils import as_int from starkware.python.math_utils import div_mod, safe_div p = pack(ids.P, PRIME) x = pack(ids.x, PRIME) + as_int(ids.x.d3, PRIME) * ids.BASE ** 3 + as_int(ids.x.d4, PRIME) * ids.BASE ** 4 y = pack(ids.y, PRIME) value = res = div_mod(x, y, p)
k = safe_div(res * y - x, p) value = k if k > 0 else 0 - k ids.flag = 1 if k > 0 else 0
-
Add missing hint on cairo_secp lib #1057:
BuiltinHintProcessornow supports the following hint:from starkware.cairo.common.cairo_secp.secp_utils import pack from starkware.python.math_utils import ec_double_slope # Compute the slope. x = pack(ids.point.x, PRIME) y = pack(ids.point.y, PRIME) value = slope = ec_double_slope(point=(x, y), alpha=ALPHA, p=SECP_P)
-
Add missing hint on uint256_improvements lib #1025:
BuiltinHintProcessornow supports the following hint:from starkware.python.math_utils import isqrt n = (ids.n.high << 128) + ids.n.low root = isqrt(n) assert 0 <= root < 2 ** 128 ids.root = root
-
Add missing hint on vrf.json lib #1045:
BuiltinHintProcessornow supports the following hint:from starkware.python.math_utils import is_quad_residue, sqrt def split(a: int): return (a & ((1 << 128) - 1), a >> 128) def pack(z) -> int: return z.low + (z.high << 128) generator = pack(ids.generator) x = pack(ids.x) p = pack(ids.p) success_x = is_quad_residue(x, p) root_x = sqrt(x, p) if success_x else None success_gx = is_quad_residue(generator*x, p) root_gx = sqrt(generator*x, p) if success_gx else None # Check that one is 0 and the other is 1 if x != 0: assert success_x + success_gx == 1 # `None` means that no root was found, but we need to transform these into a felt no matter what if root_x == None: root_x = 0 if root_gx == None: root_gx = 0 ids.success_x = int(success_x) ids.success_gx = int(success_gx) split_root_x = split(root_x) # print('split root x', split_root_x) split_root_gx = split(root_gx) ids.sqrt_x.low = split_root_x[0] ids.sqrt_x.high = split_root_x[1] ids.sqrt_gx.low = split_root_gx[0] ids.sqrt_gx.high = split_root_gx[1]
-
Add missing hint on uint256_improvements lib #1024:
BuiltinHintProcessornow supports the following hint:res = ids.a + ids.b ids.carry = 1 if res >= ids.SHIFT else 0
-
BREAKING CHANGE: move
Program::identifierstoSharedProgramData::identifiers#1023- Optimizes
CairoRunner::new, needed for sequencers and other workflows reusing the samePrograminstance acrossCairoRunners - Breaking change: make all fields in
ProgramandSharedProgramDatapub(crate), since we break by moving the field let's make it the last break for this struct - Add
Program::get_identifier(&self, id: &str) -> &Identifierto get a single identifier by name
- Optimizes
-
Implement hints on field_arithmetic lib#985
BuiltinHintProcessornow supports the following hint:%{ from starkware.python.math_utils import is_quad_residue, sqrt def split(num: int, num_bits_shift: int = 128, length: int = 3): 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 = 128) -> int: limbs = (z.d0, z.d1, z.d2) return sum(limb << (num_bits_shift * i) for i, limb in enumerate(limbs)) generator = pack(ids.generator) x = pack(ids.x) p = pack(ids.p) success_x = is_quad_residue(x, p) root_x = sqrt(x, p) if success_x else None success_gx = is_quad_residue(generator*x, p) root_gx = sqrt(generator*x, p) if success_gx else None # Check that one is 0 and the other is 1 if x != 0: assert success_x + success_gx ==1 # `None` means that no root was found, but we need to transform these into a felt no matter what if root_x == None: root_x = 0 if root_gx == None: root_gx = 0 ids.success_x = int(success_x) ids.success_gx = int(success_gx) split_root_x = split(root_x) split_root_gx = split(root_gx) ids.sqrt_x.d0 = split_root_x[0] ids.sqrt_x.d1 = split_root_x[1] ids.sqrt_x.d2 = split_root_x[2] ids.sqrt_gx.d0 = split_root_gx[0] ids.sqrt_gx.d1 = split_root_gx[1] ids.sqrt_gx.d2 = split_root_gx[2] %}
-
Add missing hint on vrf.json lib #1050:
BuiltinHintProcessornow supports the following hint:sum_low = ids.a.low + ids.b.low ids.carry_low = 1 if sum_low >= ids.SHIFT else 0
-
Add missing hint on uint256_improvements lib #1016:
BuiltinHintProcessornow supports the following hint:def split(num: int, num_bits_shift: int = 128, length: int = 2): 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 = 128) -> int: limbs = (z.low, z.high) return sum(limb << (num_bits_shift * i) for i, limb in enumerate(limbs)) a = pack(ids.a) b = pack(ids.b) res = (a - b)%2**256 res_split = split(res) ids.res.low = res_split[0] ids.res.high = res_split[1]
-
Implement hint on vrf.json lib #1049
BuiltinHintProcessornow supports the following hint: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)) def pack_extended(z, num_bits_shift: int) -> int: limbs = (z.d0, z.d1, z.d2, z.d3, z.d4, z.d5) return sum(limb << (num_bits_shift * i) for i, limb in enumerate(limbs)) a = pack_extended(ids.a, num_bits_shift = 128) div = pack(ids.div, num_bits_shift = 128) quotient, remainder = divmod(a, div) quotient_split = split(quotient, num_bits_shift=128, length=6) ids.quotient.d0 = quotient_split[0] ids.quotient.d1 = quotient_split[1] ids.quotient.d2 = quotient_split[2] ids.quotient.d3 = quotient_split[3] ids.quotient.d4 = quotient_split[4] ids.quotient.d5 = quotient_split[5] remainder_split = split(remainder, num_bits_shift=128, length=3) ids.remainder.d0 = remainder_split[0] ids.remainder.d1 = remainder_split[1] ids.remainder.d2 = remainder_split[2]
Note: this hint is similar to the one in #983, but with some trailing whitespace removed
-
Add missing hint on vrf.json whitelist #1030:
BuiltinHintProcessornow supports the following hint: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.low, z.high) return sum(limb << (num_bits_shift * i) for i, limb in enumerate(limbs)) def pack_extended(z, num_bits_shift: int) -> int: limbs = (z.d0, z.d1, z.d2, z.d3) return sum(limb << (num_bits_shift * i) for i, limb in enumerate(limbs)) x = pack_extended(ids.x, num_bits_shift = 128) div = pack(ids.div, num_bits_shift = 128) quotient, remainder = divmod(x, div) quotient_split = split(quotient, num_bits_shift=128, length=4) ids.quotient.d0 = quotient_split[0] ids.quotient.d1 = quotient_split[1] ids.quotient.d2 = quotient_split[2] ids.quotient.d3 = quotient_split[3] remainder_split = split(remainder, num_bits_shift=128, length=2) ids.remainder.low = remainder_split[0] ids.remainder.high = remainder_split[1]
-
Add method
Program::data_len(&self) -> usizeto get the number of data cells in a given program #1022 -
Add missing hint on uint256_improvements lib #1013:
BuiltinHintProcessornow supports the following hint:a = (ids.a.high << 128) + ids.a.low div = (ids.div.b23 << 128) + ids.div.b01 quotient, remainder = divmod(a, div) ids.quotient.low = quotient & ((1 << 128) - 1) ids.quotient.high = quotient >> 128 ids.remainder.low = remainder & ((1 << 128) - 1) ids.remainder.high = remainder >> 128
-
Add missing hint on cairo_secp lib #1010:
BuiltinHintProcessornow supports the following hint:memory[ap] = int(x == 0)
-
Implement hint on
get_felt_bitlength#993BuiltinHintProcessornow supports the following hint:x = ids.x ids.bit_length = x.bit_length()
Used by the
Garagalibrary functionget_felt_bitlength -
Add missing hint on cairo_secp lib #1009:
BuiltinHintProcessornow supports the following hint:ids.dibit = ((ids.scalar_u >> ids.m) & 1) + 2 * ((ids.scalar_v >> ids.m) & 1)
-
Add getters to read properties of a
Program#1017:prime(&self) -> &str: get the prime associated to data in hex representationiter_data(&self) -> Iterator<Item = &MaybeRelocatable>: get an iterator over all elements in the program dataiter_builtins(&self) -> Iterator<Item = &BuiltinName>: get an iterator over the names of required builtins
-
Add missing hint on cairo_secp lib #1008:
BuiltinHintProcessornow supports the following hint:ids.len_hi = max(ids.scalar_u.d2.bit_length(), ids.scalar_v.d2.bit_length())-1
-
Update
starknet-cryptoto version0.4.3#1011- The new version carries an 85% reduction in execution time for ECDSA signature verification
-
BREAKING CHANGE: refactor
Programto optimizeProgram::clone#999- Breaking change: many fields that were (unnecessarily) public become hidden by the refactor.
-
BREAKING CHANGE: Add _builtin suffix to builtin names e.g.: output -> output_builtin #1005
-
Implement hint on uint384_extension lib #983
BuiltinHintProcessornow supports the following hint: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)) def pack_extended(z, num_bits_shift: int) -> int: limbs = (z.d0, z.d1, z.d2, z.d3, z.d4, z.d5) return sum(limb << (num_bits_shift * i) for i, limb in enumerate(limbs)) a = pack_extended(ids.a, num_bits_shift = 128) div = pack(ids.div, num_bits_shift = 128) quotient, remainder = divmod(a, div) quotient_split = split(quotient, num_bits_shift=128, length=6) ids.quotient.d0 = quotient_split[0] ids.quotient.d1 = quotient_split[1] ids.quotient.d2 = quotient_split[2] ids.quotient.d3 = quotient_split[3] ids.quotient.d4 = quotient_split[4] ids.quotient.d5 = quotient_split[5] remainder_split = split(remainder, num_bits_shift=128, length=3) ids.remainder.d0 = remainder_split[0] ids.remainder.d1 = remainder_split[1] ids.remainder.d2 = remainder_split[2]
-
BREAKING CHANGE: optimization for instruction decoding #942:
- Avoids copying immediate arguments to the
Instructionstructure, as they get inferred from the offset anyway - Breaking: removal of the field
Instruction::imm
- Avoids copying immediate arguments to the
-
Add missing
\ncharacter in traceback string #997- BugFix: Add missing
\ncharacter after traceback lines when the filename is missing ("Unknown Location")
- BugFix: Add missing
-
0.11 Support
- Add missing hints #1014:
BuiltinHintProcessornow supports the following hints:and:from starkware.cairo.common.cairo_secp.secp256r1_utils import SECP256R1_P as SECP_P
from starkware.cairo.common.cairo_secp.secp_utils import pack from starkware.python.math_utils import line_slope # Compute the slope. x0 = pack(ids.point0.x, PRIME) y0 = pack(ids.point0.y, PRIME) x1 = pack(ids.point1.x, PRIME) y1 = pack(ids.point1.y, PRIME) value = slope = line_slope(point1=(x0, y0), point2=(x1, y1), p=SECP_P)
- Add missing hints on cairo_secp lib #991:
BuiltinHintProcessornow supports the following hints:and:from starkware.cairo.common.cairo_secp.secp_utils import pack from starkware.python.math_utils import div_mod, safe_div N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 x = pack(ids.x, PRIME) % N s = pack(ids.s, PRIME) % N value = res = div_mod(x, s, N)
value = k = safe_div(res * s - x, N)
- Layouts update #874
- Keccak builtin updated #873, #883
- Changes to
ec_op#876 - Poseidon builtin #875
- Renamed Felt to Felt252 #899
- Added SegmentArenaBuiltinRunner #913
- Added
program_segment_sizeargument toverify_secure_runner&run_from_entrypoint#928 - Added dynamic layout #879
get_segment_sizewas exposed #934
- Add missing hints #1014:
-
Add missing hint on cairo_secp lib #1006:
BuiltinHintProcessornow supports the following hint:ids.quad_bit = ( 8 * ((ids.scalar_v >> ids.m) & 1) + 4 * ((ids.scalar_u >> ids.m) & 1) + 2 * ((ids.scalar_v >> (ids.m - 1)) & 1) + ((ids.scalar_u >> (ids.m - 1)) & 1) )
-
Add missing hint on cairo_secp lib #1003:
BuiltinHintProcessornow supports the following hint:from starkware.cairo.common.cairo_secp.secp_utils import pack x = pack(ids.x, PRIME) % SECP_P
-
Add missing hint on cairo_secp lib #996:
BuiltinHintProcessornow supports the following hint:from starkware.python.math_utils import div_mod value = x_inv = div_mod(1, x, SECP_P)
-
Add missing hints on cairo_secp lib #994:
BuiltinHintProcessornow supports the following hints:from starkware.cairo.common.cairo_secp.secp_utils import pack from starkware.python.math_utils import div_mod, safe_div a = pack(ids.a, PRIME) b = pack(ids.b, PRIME) value = res = div_mod(a, b, N)
value = k_plus_one = safe_div(res * b - a, N) + 1
-
Add missing hint on cairo_secp lib #992:
BuiltinHintProcessornow supports the following hint:from starkware.cairo.common.cairo_secp.secp_utils import pack q, r = divmod(pack(ids.val, PRIME), SECP_P) assert r == 0, f"verify_zero: Invalid input {ids.val.d0, ids.val.d1, ids.val.d2}." ids.q = q % PRIME
-
Add missing hint on cairo_secp lib #990:
BuiltinHintProcessornow supports the following hint:from starkware.cairo.common.cairo_secp.secp_utils import pack slope = pack(ids.slope, PRIME) x = pack(ids.point.x, PRIME) y = pack(ids.point.y, PRIME) value = new_x = (pow(slope, 2, SECP_P) - 2 * x) % SECP_P
-
Add missing hint on cairo_secp lib #989:
BuiltinHintProcessornow supports the following hint:from starkware.cairo.common.cairo_secp.secp_utils import SECP_P q, r = divmod(pack(ids.val, PRIME), SECP_P) assert r == 0, f"verify_zero: Invalid input {ids.val.d0, ids.val.d1, ids.val.d2}." ids.q = q % PRIME
-
Add missing hint on cairo_secp lib #986:
BuiltinHintProcessornow supports the following hint:from starkware.cairo.common.cairo_secp.secp_utils import SECP_P, pack from starkware.python.math_utils import div_mod # Compute the slope. x = pack(ids.pt.x, PRIME) y = pack(ids.pt.y, PRIME) value = slope = div_mod(3 * x ** 2, 2 * y, SECP_P)
-
Add missing hint on cairo_secp lib #984:
BuiltinHintProcessornow supports the following hint:from starkware.cairo.common.cairo_secp.secp_utils import SECP_P, pack from starkware.python.math_utils import div_mod # Compute the slope. x0 = pack(ids.pt0.x, PRIME) y0 = pack(ids.pt0.y, PRIME) x1 = pack(ids.pt1.x, PRIME) y1 = pack(ids.pt1.y, PRIME) value = slope = div_mod(y0 - y1, x0 - x1, SECP_P)
-
Implement hints on uint384 lib (Part 2) #971
BuiltinHintProcessornow supports the following hint:memory[ap] = 1 if 0 <= (ids.a.d2 % PRIME) < 2 ** 127 else 0
-
Add alternative hint code for hint on _block_permutation used by 0.10.3 whitelist #958
BuiltinHintProcessornow supports the following hint:from starkware.cairo.common.keccak_utils.keccak_utils import keccak_func _keccak_state_size_felts = int(ids.KECCAK_STATE_SIZE_FELTS) assert 0 <= _keccak_state_size_felts < 100 output_values = keccak_func(memory.get_range( ids.keccak_ptr - _keccak_state_size_felts, _keccak_state_size_felts)) segments.write_arg(ids.keccak_ptr, output_values)
-
Make hints code
src/hint_processor/builtin_hint_processor/hint_code.rspublic #988 -
Implement hints on uint384 lib (Part 1) #960
BuiltinHintProcessornow 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) div = pack(ids.div, num_bits_shift = 128) quotient, remainder = divmod(a, div) quotient_split = split(quotient, num_bits_shift=128, length=3) assert len(quotient_split) == 3 ids.quotient.d0 = quotient_split[0] ids.quotient.d1 = quotient_split[1] ids.quotient.d2 = quotient_split[2] remainder_split = split(remainder, num_bits_shift=128, length=3) ids.remainder.d0 = remainder_split[0] ids.remainder.d1 = remainder_split[1] ids.remainder.d2 = remainder_split[2]
ids.low = ids.a & ((1<<128) - 1) ids.high = ids.a >> 128
sum_d0 = ids.a.d0 + ids.b.d0 ids.carry_d0 = 1 if sum_d0 >= ids.SHIFT else 0 sum_d1 = ids.a.d1 + ids.b.d1 + ids.carry_d0 ids.carry_d1 = 1 if sum_d1 >= ids.SHIFT else 0 sum_d2 = ids.a.d2 + ids.b.d2 + ids.carry_d1 ids.carry_d2 = 1 if sum_d2 >= ids.SHIFT else 0
from starkware.python.math_utils import isqrt 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) root = isqrt(a) assert 0 <= root < 2 ** 192 root_split = split(root, num_bits_shift=128, length=3) ids.root.d0 = root_split[0] ids.root.d1 = root_split[1] ids.root.d2 = root_split[2]
-
Re-export the
cairo-feltcrate ascairo_vm::felt#981- Removes the need of explicitly importing
cairo-feltin downstream projects and helps ensure there is no version mismatch caused by that
- Removes the need of explicitly importing
-
Implement hint on
uint256_mul_div_mod#957BuiltinHintProcessornow supports the following hint:a = (ids.a.high << 128) + ids.a.low b = (ids.b.high << 128) + ids.b.low div = (ids.div.high << 128) + ids.div.low quotient, remainder = divmod(a * b, div) ids.quotient_low.low = quotient & ((1 << 128) - 1) ids.quotient_low.high = (quotient >> 128) & ((1 << 128) - 1) ids.quotient_high.low = (quotient >> 256) & ((1 << 128) - 1) ids.quotient_high.high = quotient >> 384 ids.remainder.low = remainder & ((1 << 128) - 1) ids.remainder.high = remainder >> 128"
Used by the common library function
uint256_mul_div_mod
-
Derive Deserialize for ExecutionResources #922
-
Remove builtin names from VirtualMachine.builtin_runners #921
-
Implemented hints on common/ec.cairo #888
-
Changed
Memory.insertargument types #902 -
feat: implemented
Deserializeon Program by changing builtins field type to enum #896 -
Effective size computation from the VM exposed #887
-
MathErroradded for math operation #855 -
Check for overflows in relocatable operations #859
-
Use
Relocatableinstead of&MaybeRelocatableinload_dataandget_range#860 #867 -
Memory-related errors moved to
MemoryError#854- Removed unused error variants
- Moved memory-related error variants to
MemoryError - Changed memory getters to return
MemoryErrorinstead ofVirtualMachineError - Changed all memory-related errors in hint from
HintError::Internal(VmError::...toHintError::Memory(MemoryError::...
-
feat: Builder pattern for
VirtualMachine#820 -
Simplified
Memory::getreturn type toOption#852 -
Improved idenitifier variable error handling #851
-
CairoRunner::write_outputnow prints missing and relocatable values #853 -
VirtualMachineError::FailedToComputeOperandserror message expanded #848 -
Builtin names made public #849
-
secure_runflag moved toCairoRunConfigstruct #832 -
vm_coreerror types revised and iimplementedAddAssignforRelocatable#837 -
to_bigintandto_biguintdeprecated #757 -
Memorymoved intoMemorySegmentManager#830- To reduce the complexity of the VM's memory and enforce proper usage (as the memory and its segment manager are now a "unified" entity)
- Removed
memoryfield fromVirtualMachine - Added
memoryfield toMemorySegmentManager - Removed
Memoryargument from methods whereMemorySegmentManageris also an argument - Added test macro
segments(an extension of thememorymacro)
-
Displaytrait added to Memory struct #812 -
feat: Extensible VirtualMachineError and removed PartialEq trait #783
VirtualMachineError::Other(anyhow::Error)was added to allow to returning custom errors when usingcairo-vm- The
PartialEqtrait was removed from theVirtualMachineErrorenum
-
VM hooks added as a conditional feature #761
- Cairo-vm based testing tools such as cairo-foundry or those built by FuzzingLabs need access to the state of the VM at specific points during the execution.
- This PR adds the possibility for users of the cairo-vm lib to execute their custom additional code during the program execution.
- The Rust "feature" mechanism was used in order to guarantee that this ability is only available when the lib user needs it, and is not compiled when it's not required.
- Three hooks were created:
- before the first step
- before each step
- after each step
-
ExecutionResource operations: add and substract #774, multiplication #908 , and
AddAssign#914 -
Move
MemoryintoMemorySegmentManager#830- Structural changes:
- Remove
memory: Memoryfield fromVirtualMachine - Add
memory: Memoryfield toMemorySegmentManager
- Remove
- As a result of this, multiple public methods' signatures changed:
BuiltinRunner(and its inner enum types):initialize_segments(&mut self, segments: &mut MemorySegmentManager, memory: &mut Memory)->initialize_segments(&mut self, segments: &mut MemorySegmentManager)final_stack(&mut self, segments: &MemorySegmentManager, memory: &Memory, stack_pointer: Relocatable) -> Result<Relocatable, RunnerError>->final_stack(&mut self, segments: &MemorySegmentManager, stack_pointer: Relocatable) -> Result<Relocatable, RunnerError>
MemorySegmentManageradd(&mut self, memory: &mut Memory) -> Relocatable->add(&mut self) -> Relocatableadd_temporary_segment(&mut self, memory: &mut Memory) -> Relocatable->add_temporary_segment(&mut self) -> Relocatableload_data(&mut self, memory: &mut Memory, ptr: &MaybeRelocatable, data: &Vec<MaybeRelocatable>) -> Result<MaybeRelocatable, MemoryError>->load_data(&mut self, ptr: &MaybeRelocatable, data: &Vec<MaybeRelocatable>) -> Result<MaybeRelocatable, MemoryError>compute_effective_sizes(&mut self, memory: &Memory) -> &Vec<usize>->compute_effective_sizes(&mut self) -> &Vec<usize>gen_arg(&mut self, arg: &dyn Any, memory: &mut Memory) -> Result<MaybeRelocatable, VirtualMachineError>->gen_arg(&mut self, arg: &dyn Any) -> Result<MaybeRelocatable, VirtualMachineError>gen_cairo_arg(&mut self, arg: &CairoArg, memory: &mut Memory) -> Result<MaybeRelocatable, VirtualMachineError>->gen_cairo_arg(&mut self, arg: &CairoArg) -> Result<MaybeRelocatable, VirtualMachineError>write_arg(&mut self, memory: &mut Memory, ptr: &Relocatable, arg: &dyn Any) -> Result<MaybeRelocatable, MemoryError>->write_arg(&mut self, ptr: &Relocatable, arg: &dyn Any) -> Result<MaybeRelocatable, MemoryError>
- Structural changes:
-
Refactor
Memory::relocate memory#784- Bugfixes:
Memory::relocate_memorynow moves data in the temporary memory relocated by a relocation rule to the real memory
- Aditional Notes:
- When relocating temporary memory produces clashes with pre-existing values in the real memory, an InconsistentMemory error is returned instead of keeping the last inserted value. This differs from the original implementation.
- Bugfixes:
-
Restrict addresses to Relocatable + fix some error variants used in signature.rs #792
- Public Api Changes:
- Change
ValidationRuleinner type toBox<dyn Fn(&Memory, &Relocatable) -> Result<Vec<Relocatable>, MemoryError>>. - Change
validated_addressesfield ofMemorytoHashSet<Relocatable>. - Change
validate_memory_cell(&mut self, address: &MaybeRelocatable) -> Result<(), MemoryError>tovalidate_memory_cell(&mut self, addr: &Relocatable) -> Result<(), MemoryError>.
- Change
- Public Api Changes:
-
Add
VmExceptiontoCairoRunner::run_from_entrypoint#775- Public Api Changes:
- Change error return type of
CairoRunner::run_from_entrypointtoCairoRunError. - Convert
VirtualMachineErrors outputed during the vm run toVmExceptioninCairoRunner::run_from_entrypoint. - Make
VmExceptionfields public
- Change error return type of
- Public Api Changes:
-
Fix
BuiltinRunner::final_stackand remove quick fix #778- Public Api changes:
- Various changes to public
BuiltinRunnermethod's signatures:final_stack(&self, vm: &VirtualMachine, pointer: Relocatable) -> Result<(Relocatable, usize), RunnerError>tofinal_stack(&mut self, segments: &MemorySegmentManager, memory: &Memory, pointer: Relocatable) -> Result<Relocatable,RunnerError>.get_used_cells(&self, vm: &VirtualMachine) -> Result<usize, MemoryError>toget_used_cells(&self, segments: &MemorySegmentManager) -> Result<usize, MemoryError>.get_used_instances(&self, vm: &VirtualMachine) -> Result<usize, MemoryError>toget_used_instances(&self, segments: &MemorySegmentManager) -> Result<usize, MemoryError>.
- Various changes to public
- Bugfixes:
BuiltinRunner::final_stacknow updates the builtin's stop_ptr instead of returning it. This replaces the bugfix on PR #768.
- Public Api changes:
-
Add secure_run flag + integrate verify_secure_runner into cairo-run #771
- Public Api changes:
- Add command_line argument
secure_run - Add argument
secure_run: Option<bool>tocairo_run verify_secure_runneris now called insidecairo-runwhensecure_runis set to true or when it not set and the run is not onproof_mode
- Add command_line argument
- Bugfixes:
EcOpBuiltinRunner::deduce_memory_cellnow checks that both points are on the curve instead of only the first oneEcOpBuiltinRunner::deduce_memory_cellnow returns the values of the point coordinates instead of the indices when aPointNotOnCurveerror is returned
- Public Api changes:
-
Refactor
Refactor verify_secure_runner#768- Public Api changes:
- Remove builtin name from the return value of
BuiltinRunner::get_memory_segment_addresses - Simplify the return value of
CairoRunner::get_builtin_segments_infotoVec<(usize, usize)> - CairoRunner::read_return_values now receives a mutable reference to VirtualMachine
- Remove builtin name from the return value of
- Bugfixes:
- CairoRunner::read_return_values now updates the
stop_ptrof each builtin after callingBuiltinRunner::final_stack
- CairoRunner::read_return_values now updates the
- Public Api changes:
-
Use CairoArg enum instead of Any in CairoRunner::run_from_entrypoint #686
- Public Api changes:
- Remove
ResultfromMaybeRelocatable::mod_floor, it now returns aMaybeRelocatable - Add struct
CairoArg - Change
argargument ofCairoRunner::run_from_entrypointfromVec<&dyn Any>to&[&CairoArg] - Remove argument
typed_argsfromCairoRunner::run_from_entrypoint - Remove no longer used method
gen_typed_argfromVirtualMachine&MemorySegmentManager - Add methods
MemorySegmentManager::gen_cairo_arg&MemorySegmentManager::write_simple_argsas typed counterparts toMemorySegmentManager::gen_arg&MemorySegmentManager::write_arg
- Remove
- Public Api changes:
-
Add input file contents to traceback #666
- Public Api changes:
VirtualMachineErrorenum variants containingMaybeRelocatableand/orRelocatablevalues now use theDisplayformat instead ofDebugin theirDisplayimplementationget_tracebacknow adds the source code line to each traceback entry
- Public Api changes:
-
Use hint location instead of instruction location when building VmExceptions from hint failure #673
- Public Api changes:
hintsfield added toInstructionLocationProgram.instruction_locationstype changed fromOption<HashMap<usize, Location>>toOption<HashMap<usize, InstructionLocation>>VirtualMachineErrors produced byHintProcessor::execute_hint()will be wrapped in aVirtualMachineError::Hinterror containing their hint_indexget_location()now receives an an optional usize valuehint_index, used to obtain hint locations
- Public Api changes:
-
Default implementation of compile_hint #680
- Internal changes:
- Make the
compile_hintimplementation which was in theBuiltinHintProcessorthe default implementation in the trait.
- Make the
- Internal changes:
-
Add new error type
HintError#676- Public Api changes:
HintProcessor::execute_hint()now returns aHintErrorinstead of aVirtualMachineError- Helper functions on
hint_processor_utils.rsnow return aHintError
- Public Api changes:
-
Change the Dictionary used in dict hints to store MaybeRelocatable instead of BigInt #687
- Public Api changes:
DictManager, its dictionaries, and all dict module hints implemented in rust now useMaybeRelocatablefor keys and values instead ofBigInt- Add helper functions that allow extracting ids variables as
MaybeRelocatable:get_maybe_relocatable_from_var_name&get_maybe_relocatable_from_reference - Change inner value type of dict-related
HintErrorvariants toMaybeRelocatable
- Public Api changes:
-
Implement
substitute_error_message_attribute_references[#689] (https://github.com/starkware-libs/cairo-vm/pull/689)- Public Api changes:
- Remove
error_message_attributesfield fromVirtualMachine, andVirtualMachine::new - Add
flow_tracking_datafield toAttribute get_error_attr_valuenow replaces the references in the error message with the corresponding cairo values.- Remove duplicated handling of error attribute messages leading to duplicated into in the final error display.
- Remove
- Public Api changes:
-
Fix multiplicative inverse bug #697 #698. The VM was using integer division rather than prime field inverse when deducing
op0orop1for the multiplication opcode
- Add traceback to VmException #657
- Public API changes:
tracebackfield added toVmExceptionstructpub fn from_vm_error(runner: &CairoRunner, error: VirtualMachineError, pc: usize) -> Selfis nowpub fn from_vm_error(runner: &CairoRunner, vm: &VirtualMachine, error: VirtualMachineError) -> Selfpub fn get_location(pc: &usize, runner: &CairoRunner) -> Option<Location>is nowpub fn get_location(pc: usize, runner: &CairoRunner) -> Option<Location>pub fn decode_instruction(encoded_instr: i64, mut imm: Option<BigInt>) -> Result<instruction::Instruction, VirtualMachineError>is nowpub fn decode_instruction(encoded_instr: i64, mut imm: Option<&BigInt>) -> Result<instruction::Instruction, VirtualMachineError>VmExceptionfields' string format now mirrors their cairo-lang counterparts.
- Public API changes: