Skip to content

Commit c684037

Browse files
author
Stefan Effenberger
committed
fixed ordering
1 parent ce00cdb commit c684037

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

lib/bytecode_verification/parse_json.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ impl ProjectInfo {
326326
.unwrap()
327327
.to_string();
328328
if identifier.starts_with("t_struct") {
329-
let struct_slots: HashMap<U256, (u64, Option<String>)> = HashMap::from([(
329+
let struct_slots_vec: Vec<(U256, (u64, Option<String>))> = Vec::from([(
330330
U256::from_str("0x0").unwrap(), // this won't be used as we only have to add the types
331331
(
332332
type_name
@@ -345,7 +345,7 @@ impl ProjectInfo {
345345
sources,
346346
top_node,
347347
type_defs,
348-
&struct_slots,
348+
&struct_slots_vec,
349349
types,
350350
&mut storage,
351351
);
@@ -442,7 +442,7 @@ impl ProjectInfo {
442442
sources: &BTreeMap<PathBuf, SourceFile>,
443443
node: &EAstNode,
444444
type_defs: &Types,
445-
struct_slots: &HashMap<U256, (u64, Option<String>)>,
445+
struct_slots: &Vec<(U256, (u64, Option<String>))>,
446446
types: &mut HashMap<String, TypeDescription>,
447447
storage: &mut Vec<StateVariable>,
448448
) {
@@ -604,6 +604,11 @@ impl ProjectInfo {
604604
}
605605
}
606606
}
607+
608+
// Order struct_slots by key for deterministic results
609+
let mut struct_slots_vec: Vec<(U256, (u64, Option<String>))> = struct_slots.iter().map(|(k, v)| (*k, v.clone())).collect();
610+
struct_slots_vec.sort_by(|a, b| a.0.cmp(&b.0));
611+
607612
// parse the struct members + types
608613
for source in sources.values() {
609614
if let Some(ast) = source.ast.clone() {
@@ -612,7 +617,7 @@ impl ProjectInfo {
612617
sources,
613618
node,
614619
type_defs,
615-
&struct_slots,
620+
&struct_slots_vec,
616621
types,
617622
storage,
618623
);

0 commit comments

Comments
 (0)