Skip to content

feat(devnet2): modexp assume minimal base/mod length of 32 #2613

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

Merged
merged 1 commit into from
Jun 10, 2025
Merged
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
10 changes: 5 additions & 5 deletions crates/precompile/src/modexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ pub fn berlin_gas_calc(base_len: u64, exp_len: u64, mod_len: u64, exp_highp: &U2
/// 3. Increase cost when base or modulus is larger than 32 bytes
pub fn osaka_gas_calc(base_len: u64, exp_len: u64, mod_len: u64, exp_highp: &U256) -> u64 {
gas_calc::<500, 16, 3, _>(base_len, exp_len, mod_len, exp_highp, |max_len| -> U256 {
let words = U256::from(max_len.div_ceil(8));
let words_square = words * words;
if max_len > 32 {
return words_square * U256::from(2);
if max_len <= 32 {
return U256::from(16); // multiplication_complexity = 16
}
words_square

let words = U256::from(max_len.div_ceil(8));
words * words * U256::from(2) // multiplication_complexity = 2 * words**2
})
}

Expand Down