Skip to content

Commit ccfe64d

Browse files
kunxian-xiaroynalnaruto
authored andcommitted
fix: pairing cost formula (bluealloy#659)
* fix pairing cost formula bug * chore: fmt --------- Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>
1 parent 12c7f32 commit ccfe64d

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

crates/precompile/src/bn128.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ fn run_pair(
165165
pair_base_cost: u64,
166166
gas_limit: u64,
167167
) -> PrecompileResult {
168-
let gas_used =
169-
pair_per_point_cost * input.len() as u64 / PAIR_ELEMENT_LEN as u64 + pair_base_cost;
168+
let gas_used = (input.len() / PAIR_ELEMENT_LEN) as u64 * pair_per_point_cost + pair_base_cost;
170169
if gas_used > gas_limit {
171170
return Err(Error::OutOfGas);
172171
}

0 commit comments

Comments
 (0)