Skip to content

Commit 10154c6

Browse files
authored
Stav/sync starkware dev (#2035)
# TITLE Cherry-pick all the commits from main Description of the pull request changes and motivation. ## Checklist - [ ] Linked to Github Issue - [ ] Unit tests added - [ ] Integration tests added. - [ ] This change requires new documentation. - [ ] Documentation has been added/updated. - [ ] CHANGELOG has been updated.
2 parents 3aed532 + 92e3188 commit 10154c6

File tree

10 files changed

+74
-29
lines changed

10 files changed

+74
-29
lines changed

.github/workflows/bench.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: benchmark
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ main, starkware-development ]
66

77
permissions:
88
# deployments permission to deploy GitHub pages website

.github/workflows/cairo_1_programs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Cairo 1 programs execution
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ main, starkware-development ]
66
pull_request:
77
branches: [ '**' ]
88

.github/workflows/hint_accountant.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Update missing hints tracking issue
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ main, starkware-development ]
66

77
env:
88
CARGO_TERM_COLOR: always

.github/workflows/hyper_threading_benchmarks.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ permissions:
88

99
on:
1010
pull_request:
11-
branches:
12-
- main
11+
branches: [ main, starkware-development ]
1312

1413
jobs:
1514
benchmark:

.github/workflows/iai_main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: iai Benchmark
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ main, starkware-development ]
66

77
jobs:
88
cache-iai-results:

.github/workflows/rust.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: QA
33
on:
44
merge_group:
55
push:
6-
branches: [ main ]
6+
branches: [ main, starkware-development ]
77
pull_request:
88
branches: [ '**' ]
99

@@ -42,13 +42,12 @@ jobs:
4242
strategy:
4343
matrix:
4444
# NOTE: we build cairo_bench_programs so clippy can check the benchmarks too
45-
program-target: [
46-
cairo_bench_programs,
47-
cairo_proof_programs,
48-
cairo_test_programs,
49-
cairo_1_test_contracts,
50-
cairo_2_test_contracts,
51-
]
45+
program-target:
46+
- cairo_bench_programs
47+
- cairo_proof_programs
48+
- cairo_test_programs
49+
- cairo_1_test_contracts
50+
- cairo_2_test_contracts
5251
name: Build Cairo programs
5352
runs-on: ubuntu-24.04
5453
steps:
@@ -162,7 +161,7 @@ jobs:
162161
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
163162

164163
lint:
165-
needs: build-programs
164+
needs: merge-caches
166165
name: Run Lints
167166
runs-on: ubuntu-24.04
168167
steps:

.github/workflows/test_install.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Test dependencies and cairo-vm install
33
on:
44
merge_group:
55
push:
6-
branches: [ main ]
6+
branches: [ main, starkware-development ]
77
pull_request:
88
branches: [ '**' ]
99

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
## Cairo-VM Changelog
22

33
#### Upcoming Changes
4+
* Refactor: Replaced HashMap with BTreeMap to guarantee deterministic ordering of the data [#2023] (https://github.com/lambdaclass/cairo-vm/pull/2023)
5+
6+
* fix: Updated the logic for collecting builtin segment data for prover input info, removing dependency on the existence of stop pointers. [#2022](https://github.com/lambdaclass/cairo-vm/pull/2022)
7+
8+
* fix: Keep None values in memory segments for the prover input info [#2021](https://github.com/lambdaclass/cairo-vm/pull/2021)
49

510
* refactor: Clap attribute macros from #[clap(...)] to #[arg(...)] and #[command(...)] in v4.x [#2003] (https://github.com/lambdaclass/cairo-vm/pull/2003)
611

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ Enhancement suggestions are tracked as [GitHub issues](https://github.com/lambda
110110
- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux.
111111
- **Explain why this enhancement would be useful** to most cairo-vm users. You may also want to point out the other projects that solved it better and which could serve as inspiration.
112112

113+
### Pushing commits to Pull Requests
114+
115+
This repository enforces commit signing on all branches. See [this page](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) for more details on how to sign a commit and how to manage signing keys in Github.
113116

114117
<!-- TODO
115118
### Your First Code Contribution

vm/src/vm/runners/cairo_runner.rs

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{
44
math_utils::safe_div_usize,
55
stdlib::{
66
any::Any,
7-
collections::{HashMap, HashSet},
7+
collections::{BTreeMap, HashMap, HashSet},
88
ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign},
99
prelude::*,
1010
},
@@ -1502,7 +1502,7 @@ impl CairoRunner {
15021502
.memory
15031503
.data
15041504
.iter()
1505-
.map(|segment| segment.iter().filter_map(|cell| cell.get_value()).collect())
1505+
.map(|segment| segment.iter().map(|cell| cell.get_value()).collect())
15061506
.collect();
15071507

15081508
let public_memory_offsets = self
@@ -1516,10 +1516,21 @@ impl CairoRunner {
15161516
})
15171517
.collect();
15181518

1519-
let builtins_segments = self
1520-
.get_builtin_segment_info_for_pie()?
1521-
.into_iter()
1522-
.map(|(name, info)| (info.index as usize, name))
1519+
let builtins_segments: BTreeMap<usize, BuiltinName> = self
1520+
.vm
1521+
.builtin_runners
1522+
.iter()
1523+
.filter(|builtin| {
1524+
// Those segments are not treated as builtins by the prover.
1525+
!matches!(
1526+
builtin,
1527+
BuiltinRunner::SegmentArena(_) | BuiltinRunner::Output(_)
1528+
)
1529+
})
1530+
.map(|builtin| {
1531+
let (index, _) = builtin.get_memory_segment_addresses();
1532+
(index, builtin.name())
1533+
})
15231534
.collect();
15241535

15251536
Ok(ProverInputInfo {
@@ -1540,12 +1551,12 @@ impl CairoRunner {
15401551
pub struct ProverInputInfo {
15411552
/// A vector of trace entries, i.e. pc, ap, fp, where pc is relocatable.
15421553
pub relocatable_trace: Vec<TraceEntry>,
1543-
/// A vector of segments, where each segment is a vector of maybe relocatable values.
1544-
pub relocatable_memory: Vec<Vec<MaybeRelocatable>>,
1554+
/// A vector of segments, where each segment is a vector of maybe relocatable values or holes (`None`).
1555+
pub relocatable_memory: Vec<Vec<Option<MaybeRelocatable>>>,
15451556
/// A map from segment index to a vector of offsets within the segment, representing the public memory addresses.
1546-
pub public_memory_offsets: HashMap<usize, Vec<usize>>,
1557+
pub public_memory_offsets: BTreeMap<usize, Vec<usize>>,
15471558
/// A map from the builtin segment index into its name.
1548-
pub builtins_segments: HashMap<usize, BuiltinName>,
1559+
pub builtins_segments: BTreeMap<usize, BuiltinName>,
15491560
}
15501561

15511562
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -5581,12 +5592,40 @@ mod tests {
55815592
offset: 0,
55825593
});
55835594
assert_eq!(prover_info.relocatable_trace, expected_trace);
5584-
assert_eq!(prover_info.relocatable_memory[0][3], expected_in_memory_0_3);
5585-
assert_eq!(prover_info.relocatable_memory[1][0], expected_in_memory_1_0);
5595+
assert_eq!(
5596+
prover_info.relocatable_memory[0][3],
5597+
Some(expected_in_memory_0_3)
5598+
);
5599+
assert_eq!(
5600+
prover_info.relocatable_memory[1][0],
5601+
Some(expected_in_memory_1_0)
5602+
);
55865603
assert!(prover_info.public_memory_offsets.is_empty());
55875604
assert_eq!(
55885605
prover_info.builtins_segments,
5589-
HashMap::from([(2, BuiltinName::ecdsa)])
5606+
BTreeMap::from([(2, BuiltinName::ecdsa)])
55905607
);
55915608
}
5609+
5610+
#[test]
5611+
fn test_output_not_builtin_segment() {
5612+
let program_content =
5613+
include_bytes!("../../../../cairo_programs/proof_programs/split_felt.json");
5614+
let runner = crate::cairo_run::cairo_run(
5615+
program_content,
5616+
&CairoRunConfig {
5617+
trace_enabled: true,
5618+
layout: LayoutName::all_cairo,
5619+
..Default::default()
5620+
},
5621+
&mut BuiltinHintProcessor::new_empty(),
5622+
)
5623+
.unwrap();
5624+
let prover_info = runner.get_prover_input_info().unwrap();
5625+
5626+
assert!(!prover_info
5627+
.builtins_segments
5628+
.values()
5629+
.any(|v| *v == BuiltinName::output));
5630+
}
55925631
}

0 commit comments

Comments
 (0)