Skip to content

Commit

Permalink
EIP-1108: Reduce alt bn128 gas costs (#1108)
Browse files Browse the repository at this point in the history
* Add draft of elliptic-curve gas cost reduction EIP

* Add status and EIP dependencies

* Lowercase preamble per observed practice

* Tweak EIP title to reflect core cause for cost reduction

The EIP listed out the precompiles, but really this is about reducing all
alt_bn128-related gas costs.

* Reduce constant factor in line with original EIP issue

For some reason this got missed when turning into PR form.

* Fix footnote formatting

* Drop extraneous code fence

* GitHub username only for EIP author line

* Label alt_bn128 gas cost EIP as EIP 1108
  • Loading branch information
Shadowfiend authored and Arachnid committed Jun 4, 2018
1 parent f2a32e9 commit 75b1416
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions EIPS/eip-1108.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
eip: 1108
title: Reduce alt_bn128 precompile gas costs
author: Antonio Salazar Cardozo (@shadowfiend)
status: Draft
type: Standards Track
category: Core
created: 2018-05-21
requires: 196, 197
---

## Short Description

Recent changes to the underlying library used by the official Go reference
implementation led to significant performance gains for the `ECADD`, `ECMUL`,
and pairing check precompiled contracts on the `alt_bn128` elliptic curve, which
should be reflected in reduced gas costs.

## Motivation

Recently, the underlying library used by the [official Go reference
implementation](https://github.com/ethereum/go-ethereum) to implement the
`ECADD` (at address `0x06`), `ECMUL` (at address `0x07`), and pairing check (at
address `0x08`) precompiled contracts was shifted to [Cloudflare's bn256
library](https://github.com/cloudflare/bn256). Based on the [initial PR that
introduced this change](https://github.com/ethereum/go-ethereum/pull/16203),
and corroborated in [a later
note](https://github.com/ethereum/go-ethereum/pull/16301#issuecomment-372687543),
the computational cost of `ECADD`, `ECMUL`, and pairing checks (excepting the
constant) has dropped roughly an order of magnitude across the board.

## Specification

Following is a table with the current gas cost and new gas cost:

| Contract | Address | Current Gas Cost | Updated Gas Cost |
| ------------- | --------- | ----------------------------- | ------------------- |
| `ECADD` | `0x06` | 500<sup>[1]</sup> | 50 |
| `ECMUL` | `0x07` | 40 000<sup>[1]</sup> | 2 000 |
| Pairing check | `0x08` | 80 000k + 100 000<sup>[2]</sup>| 5 500k + 80 000 |

The gas costs for `ECADD` and `ECMUL` are updates to the costs listed in
EIP-196, while the gas costs for the pairing check are updates to the cost
listed in EIP-197.

[1]- Per [EIP-196](https://github.com/ethereum/EIPs/blob/984cf5de90bbf5fbe7e49be227b0c2f9567e661e/EIPS/eip-196.md#gas-costs).

[2]- Per [EIP-197](https://github.com/ethereum/EIPs/blob/df132cd37efb3986f9cd3ef4922b15a767d2c54a/EIPS/eip-197.md#specification).

0 comments on commit 75b1416

Please sign in to comment.