Skip to content

Commit 2dd6c9d

Browse files
gabrielbosioFrancoGiachettaJulianGCalderonenitratVolodymyrBg
committed
Sync with main (#2116)
* Remove duplicated `get_val` (#2065) * avoid installing gmp if it is already installed * revert part of the last commit * changelog * remove unwanted file * CI: Make cache keys depend on Cairo version (#2056) * Add Makefile and requirements.txt to cache key * Don't fetch cairo stwo exclusive programs * Remove empty file * Restrict caching Cairo programs Revert how the Rust workflow uses the Cairo program paths to calculate the cache keys. This change would imply the branch only adds Makefile and requirements.txt to the cache key computation. --------- Co-authored-by: gabrielbosio <[email protected]> Co-authored-by: Gabriel Bosio <[email protected]> * dev: make Memory::get `pub` (#2039) * dev: make Memory::get `pub` * edit changelog * dev: expose get_maybe_relocatable instead * add comment on borrowed variant * add tests * feat(breaking): add support for hint accessible scopes (#2042) * feat: add support for hint accessible scopes update changelog * Update vm/src/hint_processor/hint_processor_definition.rs Co-authored-by: Julian Gonzalez Calderon <[email protected]> --------- Co-authored-by: Julian Gonzalez Calderon <[email protected]> * feat: add support for alias identifiers destination in program serde (#2071) * feat: add support for aliases destination in program serde * add changelog --------- Co-authored-by: Julián González Calderón <[email protected]> * fix: Add boundary tests for SecpSplitOutOfRange in secp_utils (#2062) * fix: Add boundary tests for SecpSplitOutOfRange in secp_utils * Update secp_utils.rs * Update CHANGELOG.md * Update secp_utils.rs * remove optimizations * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * empty commit to fix CI --------- Co-authored-by: Julian Gonzalez Calderon <[email protected]> * docs: add --run_from_cairo_pie documentation for Cairo 0 and Cairo 1 (#2077) * docs: add --run_from_cairo_pie flag usage documentation for Cairo 0 * docs: add --run_from_cairo_pie flag usage documentation for Cairo 1 * Update README.md Co-authored-by: Julian Gonzalez Calderon <[email protected]> * Update README.md * Update README.md * Update README.md Co-authored-by: Julian Gonzalez Calderon <[email protected]> * Update README.md Co-authored-by: Gabriel Bosio <[email protected]> * Update README.md Co-authored-by: Julian Gonzalez Calderon <[email protected]> --------- Co-authored-by: Julian Gonzalez Calderon <[email protected]> Co-authored-by: Gabriel Bosio <[email protected]> * Fix WRITE_DIVMOD_SEGMENT hint (#2078) * Minor fixes - use CAIRO_PRIME * Add error handling * Update CHANGELOG.md * Bump cairo-lang to 0.13.5 (#1959) * Update cairo-lang versin * Update changelog * Add new hints * Specify prime in new hints * Only apply mod floor if prime is not CAIRO_PRIME * Properly implement pack for a different prime * Fix pack in compute_doubling_slope * Add negative_points.cairo test * Add try_get_point_from_x for negative points * Add double_x test for negative points * Allow to many arguments * Add codecov to cairo-0-secp-hints feature * Prepare for Release v3.0.0-rc.1 (#2092) * Update version * Update lock * Update toolchain * Update changelog * Fix clippy * Update toolchain in CI * fix: correct cache keys for no-std test coverage in CI (#2093) * Update rust.yml * Update rust.yml * Update rust toolchain to 1.87.0 (#2100) * update rust toolchain to 1.87.0 * remove uneeded file * update rust in workflows * update changelog * clippy * clippy * remove unneeded clippy allow * fix Changelog link (#2104) * Improve memory_segments coverage (#2110) * Add tests for .gen_arg() and .write_arg() * Add test for .is_valid_memory_value() * Assert contents of memory segments --------- Co-authored-by: Franco Giachetta <[email protected]> Co-authored-by: Julian Gonzalez Calderon <[email protected]> Co-authored-by: Mathieu <[email protected]> Co-authored-by: VolodymyrBg <[email protected]> Co-authored-by: GarmashAlex <[email protected]> Co-authored-by: crStiv <[email protected]> Co-authored-by: DiegoC <[email protected]>
1 parent c394503 commit 2dd6c9d

File tree

10 files changed

+240
-21
lines changed

10 files changed

+240
-21
lines changed

.github/workflows/rust.yml

Lines changed: 112 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,29 @@ jobs:
566566
path: lcov-test#4-.info
567567
key: codecov-cache-test#4--${{ github.sha }}
568568
fail-on-cache-miss: true
569-
- name: Fetch results for tests without stdlib
569+
- name: Fetch results for tests without stdlib (part. 1)
570570
uses: actions/cache/restore@v3
571571
with:
572-
path: lcov-test-no_std-.info
573-
key: codecov-cache-test-no_std--${{ github.sha }}
572+
path: lcov-test-no_std#1-.info
573+
key: codecov-cache-test-no_std#1--${{ github.sha }}
574+
fail-on-cache-miss: true
575+
- name: Fetch results for tests without stdlib (part. 2)
576+
uses: actions/cache/restore@v3
577+
with:
578+
path: lcov-test-no_std#2-.info
579+
key: codecov-cache-test-no_std#2--${{ github.sha }}
580+
fail-on-cache-miss: true
581+
- name: Fetch results for tests without stdlib (part. 3)
582+
uses: actions/cache/restore@v3
583+
with:
584+
path: lcov-test-no_std#3-.info
585+
key: codecov-cache-test-no_std#3--${{ github.sha }}
586+
fail-on-cache-miss: true
587+
- name: Fetch results for tests without stdlib (part. 4)
588+
uses: actions/cache/restore@v3
589+
with:
590+
path: lcov-test-no_std#4-.info
591+
key: codecov-cache-test-no_std#4--${{ github.sha }}
574592
fail-on-cache-miss: true
575593
- name: Fetch results for tests with stdlib (w/extensive_hints; part. 1)
576594
uses: actions/cache/restore@v3
@@ -596,11 +614,29 @@ jobs:
596614
path: lcov-test#4-extensive_hints.info
597615
key: codecov-cache-test#4-extensive_hints-${{ github.sha }}
598616
fail-on-cache-miss: true
599-
- name: Fetch results for tests without stdlib (w/extensive_hints)
617+
- name: Fetch results for tests without stdlib (w/extensive_hints; part. 1)
618+
uses: actions/cache/restore@v3
619+
with:
620+
path: lcov-test-no_std#1-extensive_hints.info
621+
key: codecov-cache-test-no_std#1-extensive_hints-${{ github.sha }}
622+
fail-on-cache-miss: true
623+
- name: Fetch results for tests without stdlib (w/extensive_hints; part. 2)
624+
uses: actions/cache/restore@v3
625+
with:
626+
path: lcov-test-no_std#2-extensive_hints.info
627+
key: codecov-cache-test-no_std#2-extensive_hints-${{ github.sha }}
628+
fail-on-cache-miss: true
629+
- name: Fetch results for tests without stdlib (w/extensive_hints; part. 3)
630+
uses: actions/cache/restore@v3
631+
with:
632+
path: lcov-test-no_std#3-extensive_hints.info
633+
key: codecov-cache-test-no_std#3-extensive_hints-${{ github.sha }}
634+
fail-on-cache-miss: true
635+
- name: Fetch results for tests without stdlib (w/extensive_hints; part. 4)
600636
uses: actions/cache/restore@v3
601637
with:
602-
path: lcov-no_std-extensive_hints.info
603-
key: codecov-cache-test-no_std-extensive_hints-${{ github.sha }}
638+
path: lcov-test-no_std#4-extensive_hints.info
639+
key: codecov-cache-test-no_std#4-extensive_hints-${{ github.sha }}
604640
fail-on-cache-miss: true
605641

606642
- name: Fetch results for tests with stdlib (w/mod_builtin; part. 1)
@@ -627,11 +663,78 @@ jobs:
627663
path: lcov-test#4-mod_builtin.info
628664
key: codecov-cache-test#4-mod_builtin-${{ github.sha }}
629665
fail-on-cache-miss: true
630-
- name: Fetch results for tests without stdlib (w/mod_builtin)
666+
- name: Fetch results for tests without stdlib (w/mod_builtin; part. 1)
667+
uses: actions/cache/restore@v3
668+
with:
669+
path: lcov-test-no_std#1-mod_builtin.info
670+
key: codecov-cache-test-no_std#1-mod_builtin-${{ github.sha }}
671+
fail-on-cache-miss: true
672+
- name: Fetch results for tests without stdlib (w/mod_builtin; part. 2)
673+
uses: actions/cache/restore@v3
674+
with:
675+
path: lcov-test-no_std#2-mod_builtin.info
676+
key: codecov-cache-test-no_std#2-mod_builtin-${{ github.sha }}
677+
fail-on-cache-miss: true
678+
- name: Fetch results for tests without stdlib (w/mod_builtin; part. 3)
679+
uses: actions/cache/restore@v3
680+
with:
681+
path: lcov-test-no_std#3-mod_builtin.info
682+
key: codecov-cache-test-no_std#3-mod_builtin-${{ github.sha }}
683+
fail-on-cache-miss: true
684+
- name: Fetch results for tests without stdlib (w/mod_builtin; part. 4)
685+
uses: actions/cache/restore@v3
686+
with:
687+
path: lcov-test-no_std#4-mod_builtin.info
688+
key: codecov-cache-test-no_std#4-mod_builtin-${{ github.sha }}
689+
fail-on-cache-miss: true
690+
691+
- name: Fetch results for tests with stdlib (w/cairo-0-secp-hints; part. 1)
692+
uses: actions/cache/restore@v3
693+
with:
694+
path: lcov-test#1-cairo-0-secp-hints.info
695+
key: codecov-cache-test#1-cairo-0-secp-hints-${{ github.sha }}
696+
fail-on-cache-miss: true
697+
- name: Fetch results for tests with stdlib (w/cairo-0-secp-hints; part. 2)
698+
uses: actions/cache/restore@v3
699+
with:
700+
path: lcov-test#2-cairo-0-secp-hints.info
701+
key: codecov-cache-test#2-cairo-0-secp-hints-${{ github.sha }}
702+
fail-on-cache-miss: true
703+
- name: Fetch results for tests with stdlib (w/cairo-0-secp-hints; part. 3)
704+
uses: actions/cache/restore@v3
705+
with:
706+
path: lcov-test#3-cairo-0-secp-hints.info
707+
key: codecov-cache-test#3-cairo-0-secp-hints-${{ github.sha }}
708+
fail-on-cache-miss: true
709+
- name: Fetch results for tests with stdlib (w/cairo-0-secp-hints; part. 4)
710+
uses: actions/cache/restore@v3
711+
with:
712+
path: lcov-test#4-cairo-0-secp-hints.info
713+
key: codecov-cache-test#4-cairo-0-secp-hints-${{ github.sha }}
714+
fail-on-cache-miss: true
715+
- name: Fetch results for tests without stdlib (w/cairo-0-secp-hints; part. 1)
716+
uses: actions/cache/restore@v3
717+
with:
718+
path: lcov-test-no_std#1-cairo-0-secp-hints.info
719+
key: codecov-cache-test-no_std#1-cairo-0-secp-hints-${{ github.sha }}
720+
fail-on-cache-miss: true
721+
- name: Fetch results for tests without stdlib (w/cairo-0-secp-hints; part. 2)
722+
uses: actions/cache/restore@v3
723+
with:
724+
path: lcov-test-no_std#2-cairo-0-secp-hints.info
725+
key: codecov-cache-test-no_std#2-cairo-0-secp-hints-${{ github.sha }}
726+
fail-on-cache-miss: true
727+
- name: Fetch results for tests without stdlib (w/cairo-0-secp-hints; part. 3)
728+
uses: actions/cache/restore@v3
729+
with:
730+
path: lcov-test-no_std#3-cairo-0-secp-hints.info
731+
key: codecov-cache-test-no_std#3-cairo-0-secp-hints-${{ github.sha }}
732+
fail-on-cache-miss: true
733+
- name: Fetch results for tests without stdlib (w/cairo-0-secp-hints; part. 4)
631734
uses: actions/cache/restore@v3
632735
with:
633-
path: lcov-no_std-mod_builtin.info
634-
key: codecov-cache-test-no_std-mod_builtin-${{ github.sha }}
736+
path: lcov-test-no_std#4-cairo-0-secp-hints.info
737+
key: codecov-cache-test-no_std#4-cairo-0-secp-hints-${{ github.sha }}
635738
fail-on-cache-miss: true
636739

637740
- name: Fetch results for tests with stdlib (w/cairo-0-secp-hints; part. 1)

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@
3434

3535
* refactor: remove duplicated get_val function [#2065](https://github.com/lambdaclass/cairo-vm/pull/2065)
3636

37+
* chore: update Rust required version to 1.87.0 [#2100](https://github.com/lambdaclass/cairo-vm/pull/2100)
38+
39+
#### [3.0.0-rc.1] - 2025-05-08
40+
41+
* chore: bump pip `cairo-lang` 0.13.5 [#1959](https://github.com/lambdaclass/cairo-vm/pull/1959)
42+
43+
* fix: Use Cairo prime instead of SECP_P in WRITE_DIVMOD_SEGMENT hint [#2078](https://github.com/lambdaclass/cairo-vm/pull/2078)
44+
45+
* feat: add support for alias identifiers destination in program serde [#2071](https://github.com/lambdaclass/cairo-vm/pull/2071)
46+
47+
* feat(BREAKING): add support for accessible scopes in hint processor [#2042](https://github.com/lambdaclass/cairo-vm/pull/2042)
48+
49+
* dev: add Memory::get_maybe_relocatable [#2039](https://github.com/lambdaclass/cairo-vm/pull/2039)
50+
51+
* refactor: remove duplicated get_val function [#2065](https://github.com/lambdaclass/cairo-vm/pull/2065)
52+
3753
* fix: Always use a normal segment in first SegmentArena segment [#1845](https://github.com/lambdaclass/cairo-vm/pull/1845)
3854

3955
* chore: update cairo-lang dependencies to 2.12.0-dev.0 #[2040](https://github.com/lambdaclass/cairo-vm/pull/2040)

Cargo.lock

Lines changed: 14 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hint_accountant/src/main.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,34 @@ fn run() {
5151
}
5252
let mut vm = VirtualMachine::new(false, false);
5353
let mut hint_executor = BuiltinHintProcessor::new_empty();
54-
let (ap_tracking_data, reference_ids, references, mut exec_scopes, constants) = (
54+
let (
55+
ap_tracking_data,
56+
reference_ids,
57+
references,
58+
mut exec_scopes,
59+
constants,
60+
accessible_scopes,
61+
) = (
5562
ApTracking::default(),
5663
HashMap::new(),
5764
Vec::new(),
5865
ExecutionScopes::new(),
5966
HashMap::new(),
67+
Vec::new(),
6068
);
6169
let missing_hints: HashSet<_> = whitelists
6270
.into_iter()
6371
.flatten()
6472
.map(|ahe| ahe.hint_lines.join("\n"))
6573
.filter(|h| {
6674
let hint_data = hint_executor
67-
.compile_hint(h, &ap_tracking_data, &reference_ids, &references)
75+
.compile_hint(
76+
h,
77+
&ap_tracking_data,
78+
&reference_ids,
79+
&references,
80+
&accessible_scopes,
81+
)
6882
.expect("this implementation is infallible");
6983
matches!(
7084
hint_executor.execute_hint(&mut vm, &mut exec_scopes, &hint_data, &constants,),

vm/src/hint_processor/builtin_hint_processor/builtin_hint_processor_definition.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ pub struct HintProcessorData {
132132
pub code: String,
133133
pub ap_tracking: ApTracking,
134134
pub ids_data: HashMap<String, HintReference>,
135+
pub accessible_scopes: Vec<String>,
135136
}
136137

137138
impl HintProcessorData {
@@ -140,6 +141,7 @@ impl HintProcessorData {
140141
code,
141142
ap_tracking: ApTracking::default(),
142143
ids_data,
144+
accessible_scopes: vec![],
143145
}
144146
}
145147
}

vm/src/hint_processor/cairo_1_hint_processor/hint_processor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,8 @@ impl HintProcessorLogic for Cairo1HintProcessor {
12631263
_reference_ids: &HashMap<String, usize>,
12641264
//List of all references (key corresponds to element of the previous dictionary)
12651265
_references: &[HintReference],
1266+
// List of accessible scopes in the hint
1267+
_accessible_scopes: &[String],
12661268
) -> Result<Box<dyn Any>, VirtualMachineError> {
12671269
let data = hint_code.parse().ok().and_then(|x: usize| self.hints.get(&x).cloned())
12681270
.ok_or_else(|| VirtualMachineError::CompileHintFail(

vm/src/hint_processor/hint_processor_definition.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ pub trait HintProcessorLogic {
4343
reference_ids: &HashMap<String, usize>,
4444
//List of all references (key corresponds to element of the previous dictionary)
4545
references: &[HintReference],
46+
// List of accessible scopes in the hint
47+
accessible_scopes: &[String],
4648
) -> Result<Box<dyn Any>, VirtualMachineError> {
4749
Ok(any_box!(HintProcessorData {
4850
code: hint_code.to_string(),
4951
ap_tracking: ap_tracking_data.clone(),
5052
ids_data: get_ids_data(reference_ids, references)?,
53+
accessible_scopes: accessible_scopes.to_vec(),
5154
}))
5255
}
5356

vm/src/tests/run_deprecated_contract_class_simplified.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,17 @@ pub fn vm_load_program(
296296
let hint_ap_tracking_data = ApTracking::default();
297297
let reference_ids = HashMap::default();
298298
let references = vec![];
299+
let accessible_scopes = vec![
300+
String::from("__main__"),
301+
String::from("__main__.get_number"),
302+
];
299303
// Compile the hint
300304
let compiled_hint = hint_processor.compile_hint(
301305
hint_code,
302306
&hint_ap_tracking_data,
303307
&reference_ids,
304308
&references,
309+
&accessible_scopes,
305310
)?;
306311
// Create the hint extension
307312
// As the hint from the compiled constract has offset 0, the hint pc will be equal to the loaded contract's program base:

vm/src/vm/runners/cairo_runner.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ impl CairoRunner {
657657
&hint.flow_tracking_data.ap_tracking,
658658
&hint.flow_tracking_data.reference_ids,
659659
references,
660+
&hint.accessible_scopes,
660661
)
661662
.map_err(|_| VirtualMachineError::CompileHintFail(hint.code.clone().into()))
662663
})

0 commit comments

Comments
 (0)