Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use builtins iter to define os_order_iter #351

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
}
}
Loading