Skip to content

Commit

Permalink
BTreeMap for preserving order
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Aug 29, 2024
1 parent 156217b commit 883b31b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
5 changes: 2 additions & 3 deletions proof_parser/src/builtins.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::HashMap;

use std::collections::BTreeMap;
use crate::json_parser::MemorySegmentAddress;

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -55,7 +54,7 @@ impl Builtin {
]
}
pub fn sort_segments(
memory_segments: HashMap<String, MemorySegmentAddress>,
memory_segments: BTreeMap<String, MemorySegmentAddress>,
) -> Vec<MemorySegmentAddress> {
let mut segments = memory_segments
.into_iter()
Expand Down
6 changes: 3 additions & 3 deletions proof_parser/src/json_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
};
use num_bigint::BigUint;
use serde::Deserialize;
use std::{collections::HashMap, convert::TryFrom};
use std::{collections::BTreeMap, convert::TryFrom};

#[derive(Deserialize, Debug, Clone, PartialEq)]
pub struct ProofJSON {
Expand Down Expand Up @@ -52,9 +52,9 @@ pub struct PublicMemoryElement {

#[derive(Deserialize, Debug, Clone, PartialEq)]
pub struct PublicInput {
dynamic_params: Option<HashMap<String, u32>>,
dynamic_params: Option<BTreeMap<String, u32>>,
layout: Layout,
memory_segments: HashMap<String, MemorySegmentAddress>,
memory_segments: BTreeMap<String, MemorySegmentAddress>,
n_steps: u32,
public_memory: Vec<PublicMemoryElement>,
rc_min: u32,
Expand Down
4 changes: 2 additions & 2 deletions proof_parser/src/layout.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use serde::Deserialize;
use std::{collections::HashMap, fmt::Display};
use std::{collections::BTreeMap, fmt::Display};

// For now only the recursive and starknet layouts is supported
#[derive(Debug, Clone, PartialEq, Deserialize)]
Expand Down Expand Up @@ -30,7 +30,7 @@ impl Layout {
}
pub fn get_dynamics_or_consts(
&self,
dynamic_params: &Option<HashMap<String, u32>>,
dynamic_params: &Option<BTreeMap<String, u32>>,
) -> Option<LayoutConstants> {
let consts = self.get_consts();

Expand Down
1 change: 1 addition & 0 deletions proof_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ mod tests {
let input = include_str!("../../examples/proofs/dynamic/cairo0_example_proof.json");
let proof_json = serde_json::from_str::<ProofJSON>(input).unwrap();
let stark_proof = StarkProof::try_from(proof_json).unwrap();
println!("{:?}", stark_proof.public_input);
let _: StarkProofFromVerifier = stark_proof.into();
}

Expand Down
4 changes: 2 additions & 2 deletions proof_parser/src/stark_proof.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use num_bigint::BigUint;
use std::collections::HashMap;
use std::collections::BTreeMap;

#[derive(Debug, Clone, PartialEq)]
pub struct StarkProof {
Expand Down Expand Up @@ -140,7 +140,7 @@ pub struct CairoPublicInput {
pub range_check_min: u32,
pub range_check_max: u32,
pub layout: BigUint,
pub dynamic_params: HashMap<String, u32>,
pub dynamic_params: BTreeMap<String, u32>,
pub n_segments: usize,
pub segments: Vec<SegmentInfo>,
pub padding_addr: u32,
Expand Down

0 comments on commit 883b31b

Please sign in to comment.