Skip to content

Commit

Permalink
fix: pairing cost formula (#659)
Browse files Browse the repository at this point in the history
* fix pairing cost formula bug

* chore: fmt

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>
  • Loading branch information
kunxian-xia and roynalnaruto authored Aug 29, 2023
1 parent c14f8a9 commit 0fa4504
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions crates/precompile/src/bn128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ fn run_pair(
pair_base_cost: u64,
gas_limit: u64,
) -> PrecompileResult {
let gas_used =
pair_per_point_cost * input.len() as u64 / PAIR_ELEMENT_LEN as u64 + pair_base_cost;
let gas_used = (input.len() / PAIR_ELEMENT_LEN) as u64 * pair_per_point_cost + pair_base_cost;
if gas_used > gas_limit {
return Err(Error::OutOfGas);
}
Expand Down

0 comments on commit 0fa4504

Please sign in to comment.