Skip to content

Commit

Permalink
chore: use builtins iter to define os_order_iter
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Jul 4, 2024
1 parent dba37cb commit 56c0a93
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions crates/gateway/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,9 @@ pub trait IntoEnumIteratorExt {
fn iter() -> impl Iterator<Item = Builtin>;
}

// TODO(Arni): When the trait IntoEnumIteratorExt is removed, Make sure the order is maintained or
// address the different order.
impl IntoEnumIteratorExt for Builtin {
fn iter() -> impl Iterator<Item = Builtin> {
// The OS expects this order for the builtins.
vec![
let mut builtins_vector: Vec<Builtin> = vec![
Builtin::Pedersen,
Builtin::RangeCheck,
Builtin::Ecdsa,
Expand All @@ -198,7 +195,22 @@ impl IntoEnumIteratorExt for Builtin {
Builtin::Poseidon,
Builtin::SegmentArena,
Builtin::Keccak,
]
.into_iter()
];
builtins_vector.sort_by_key(builtin_order);
builtins_vector.into_iter()
}
}

// The OS expects this order for the builtins.
fn builtin_order(builtin: &Builtin) -> usize {
match builtin {
Builtin::Pedersen => 0,
Builtin::RangeCheck => 1,
Builtin::Ecdsa => 2,
Builtin::Bitwise => 3,
Builtin::EcOp => 4,
Builtin::Poseidon => 5,
Builtin::SegmentArena => 6,
Builtin::Keccak => 7,
}
}

0 comments on commit 56c0a93

Please sign in to comment.