Skip to content

Commit

Permalink
simplify gas estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
olga24912 committed Nov 17, 2023
1 parent d9b039a commit b737d0b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions neps/nep-0488.md
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ Note: we take as input any points on the curve, not only from $G_1$
The algorithm has a linear complexity of the number of elements. The gas can be calculated by the next formula

```rust
let k = (input_bytes + item_size - 1)/item_size
let k = input_bytes / item_size
let gas_consumed = A + B * k
```

Expand Down Expand Up @@ -834,7 +834,7 @@ the ERROR_CODE is returned.
The algorithm has a linear complexity of the number of elements. The gas can be calculated by the next formula

```rust
let k = (input_bytes + item_size - 1)/item_size
let k = input_bytes / item_size
let gas_consumed = A + B * k
```

Expand Down Expand Up @@ -921,7 +921,7 @@ the ERROR_CODE is returned.
This function should be calculated by Pippenger’s algorithm[^25]. The Complexity of this algorithm is $O(\frac{k}{\log(k)})$. For gas calculation we will use the formula $\frac{k}{\max(\log_2(k), 1)}$ the same way as in the host function for `BN254`[^10].

```rust
let k = (input_bytes+item_size-1)/item_size;
let k = input_bytes / item_size;
let gas_consumed = A + B*k + C * if k > 1 {k / (k as f32).log2().floor()} else {k};
```

Expand Down Expand Up @@ -1026,7 +1026,7 @@ the output is 192 bytes — the one point $\in E'(F_{p^2})$ in decompressed form
This function should be calculated by Pippenger’s algorithm[^25]. The Complexity of this algorithm is $O(\frac{k}{\log(k)})$. For gas calculation we will use the formula $\frac{k}{\max(\log_2(k), 1)}$ the same way as in the host function for `BN254`[^10].

```rust
let k = (input_bytes+item_size-1)/item_size;
let k = input_bytes / item_size;
let gas_consumed = A + B*k + C * if k > 1 {k / (k as f32).log2().floor()} else {k};
```

Expand Down Expand Up @@ -1254,7 +1254,7 @@ For empty input it returns ERROR_CODE = 0.
The algorithm has a linear complexity of the number of elements. The gas can be calculated by the next formula

```rust
let k = (input_bytes + item_size - 1)/item_size
let k = input_bytes / item_size
let gas_consumed = A + B * k
```

Expand Down Expand Up @@ -1331,7 +1331,7 @@ the ERROR_CODE is returned.
***Gas Estimation:*** The algorithm has a linear complexity of the number of elements. The gas can be calculated by the next formula

```rust
let k = (input_bytes + item_size - 1)/item_size
let k = input_bytes / item_size
let gas_consumed = A + B * k
```

Expand Down

0 comments on commit b737d0b

Please sign in to comment.