From dd9f6be7604b9e367871fcd2f9e2e3cd2604bc7d Mon Sep 17 00:00:00 2001 From: Antonio Salazar Cardozo Date: Mon, 21 May 2018 10:09:58 -0400 Subject: [PATCH 1/9] Add draft of elliptic-curve gas cost reduction EIP --- EIPS/eip-ec-gas-cost-reduction.md | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 EIPS/eip-ec-gas-cost-reduction.md diff --git a/EIPS/eip-ec-gas-cost-reduction.md b/EIPS/eip-ec-gas-cost-reduction.md new file mode 100644 index 0000000000000..f73ab3ead308c --- /dev/null +++ b/EIPS/eip-ec-gas-cost-reduction.md @@ -0,0 +1,47 @@ +--- +``` +EIP: +Title: Reduce ECADD, ECMUL, pairing check gas costs +Author: Antonio Salazar Cardozo (@shadowfiend) +Type: Standards Track +Category: Core +Created: 2018-05-21 +``` +--- + +## 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[1] | 50 | +| `ECMUL` | `0x07` | 40 000[1] | 2 000 | +| Pairing check | `0x08` | 80 000k + 100 000[2]| 5 500k + 100 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). From 21e3f0634229b95b436b7cc296ff6d6db01cd4b9 Mon Sep 17 00:00:00 2001 From: Antonio Salazar Cardozo Date: Mon, 21 May 2018 10:11:11 -0400 Subject: [PATCH 2/9] Add status and EIP dependencies --- EIPS/eip-ec-gas-cost-reduction.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/EIPS/eip-ec-gas-cost-reduction.md b/EIPS/eip-ec-gas-cost-reduction.md index f73ab3ead308c..3a818b6fe8952 100644 --- a/EIPS/eip-ec-gas-cost-reduction.md +++ b/EIPS/eip-ec-gas-cost-reduction.md @@ -3,9 +3,11 @@ EIP: Title: Reduce ECADD, ECMUL, pairing check gas costs Author: Antonio Salazar Cardozo (@shadowfiend) +Status: Draft Type: Standards Track Category: Core Created: 2018-05-21 +requires: 196, 197 ``` --- From d1aafab01f9fe0503c7713c6cc899a72cea476f1 Mon Sep 17 00:00:00 2001 From: Antonio Salazar Cardozo Date: Mon, 21 May 2018 10:11:46 -0400 Subject: [PATCH 3/9] Lowercase preamble per observed practice --- EIPS/eip-ec-gas-cost-reduction.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/EIPS/eip-ec-gas-cost-reduction.md b/EIPS/eip-ec-gas-cost-reduction.md index 3a818b6fe8952..9e641b6717b98 100644 --- a/EIPS/eip-ec-gas-cost-reduction.md +++ b/EIPS/eip-ec-gas-cost-reduction.md @@ -1,12 +1,12 @@ --- ``` -EIP: -Title: Reduce ECADD, ECMUL, pairing check gas costs -Author: Antonio Salazar Cardozo (@shadowfiend) -Status: Draft -Type: Standards Track -Category: Core -Created: 2018-05-21 +eip: +title: Reduce ECADD, ECMUL, pairing check gas costs +author: Antonio Salazar Cardozo (@shadowfiend) +status: Draft +type: Standards Track +category: Core +created: 2018-05-21 requires: 196, 197 ``` --- From d8eaa3e1eee4c3cc1aef18bca924b97912b2e328 Mon Sep 17 00:00:00 2001 From: Antonio Salazar Cardozo Date: Mon, 21 May 2018 10:15:27 -0400 Subject: [PATCH 4/9] 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. --- ...-gas-cost-reduction.md => eip-reduce-alt_bn128-gas-costs.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename EIPS/{eip-ec-gas-cost-reduction.md => eip-reduce-alt_bn128-gas-costs.md} (97%) diff --git a/EIPS/eip-ec-gas-cost-reduction.md b/EIPS/eip-reduce-alt_bn128-gas-costs.md similarity index 97% rename from EIPS/eip-ec-gas-cost-reduction.md rename to EIPS/eip-reduce-alt_bn128-gas-costs.md index 9e641b6717b98..a7c8330ec4cc0 100644 --- a/EIPS/eip-ec-gas-cost-reduction.md +++ b/EIPS/eip-reduce-alt_bn128-gas-costs.md @@ -1,7 +1,7 @@ --- ``` eip: -title: Reduce ECADD, ECMUL, pairing check gas costs +title: Reduce alt_bn128 precompile gas costs author: Antonio Salazar Cardozo (@shadowfiend) status: Draft type: Standards Track From 1311b36bd5dc80f031f7dc0d1d2706a9ba8386b8 Mon Sep 17 00:00:00 2001 From: Antonio Salazar Cardozo Date: Tue, 22 May 2018 09:09:11 -0400 Subject: [PATCH 5/9] Reduce constant factor in line with original EIP issue For some reason this got missed when turning into PR form. --- EIPS/eip-reduce-alt_bn128-gas-costs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-reduce-alt_bn128-gas-costs.md b/EIPS/eip-reduce-alt_bn128-gas-costs.md index a7c8330ec4cc0..87a25e3a2bd44 100644 --- a/EIPS/eip-reduce-alt_bn128-gas-costs.md +++ b/EIPS/eip-reduce-alt_bn128-gas-costs.md @@ -39,7 +39,7 @@ Following is a table with the current gas cost and new gas cost: | ------------- | --------- | ----------------------------- | ------------------- | | `ECADD` | `0x06` | 500[1] | 50 | | `ECMUL` | `0x07` | 40 000[1] | 2 000 | -| Pairing check | `0x08` | 80 000k + 100 000[2]| 5 500k + 100 000 | +| Pairing check | `0x08` | 80 000k + 100 000[2]| 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 From 9fd2cd1508ca1ed59a9ddce6070b785cb2f4b9d6 Mon Sep 17 00:00:00 2001 From: Antonio Salazar Cardozo Date: Tue, 22 May 2018 09:10:26 -0400 Subject: [PATCH 6/9] Fix footnote formatting --- EIPS/eip-reduce-alt_bn128-gas-costs.md | 1 + 1 file changed, 1 insertion(+) diff --git a/EIPS/eip-reduce-alt_bn128-gas-costs.md b/EIPS/eip-reduce-alt_bn128-gas-costs.md index 87a25e3a2bd44..063f2e12e422d 100644 --- a/EIPS/eip-reduce-alt_bn128-gas-costs.md +++ b/EIPS/eip-reduce-alt_bn128-gas-costs.md @@ -46,4 +46,5 @@ 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). From 4ef1d409035b4b422c72be180dd9e83b5da4fd68 Mon Sep 17 00:00:00 2001 From: Antonio Salazar Cardozo Date: Wed, 23 May 2018 08:51:04 -0400 Subject: [PATCH 7/9] Drop extraneous code fence --- EIPS/eip-reduce-alt_bn128-gas-costs.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/EIPS/eip-reduce-alt_bn128-gas-costs.md b/EIPS/eip-reduce-alt_bn128-gas-costs.md index 063f2e12e422d..50f176ed2bbc2 100644 --- a/EIPS/eip-reduce-alt_bn128-gas-costs.md +++ b/EIPS/eip-reduce-alt_bn128-gas-costs.md @@ -1,5 +1,4 @@ --- -``` eip: title: Reduce alt_bn128 precompile gas costs author: Antonio Salazar Cardozo (@shadowfiend) @@ -8,7 +7,6 @@ type: Standards Track category: Core created: 2018-05-21 requires: 196, 197 -``` --- ## Short Description From 1a97a7be5a80b769b976555f3674f0d16523a5c0 Mon Sep 17 00:00:00 2001 From: Antonio Salazar Cardozo Date: Wed, 23 May 2018 08:51:19 -0400 Subject: [PATCH 8/9] GitHub username only for EIP author line --- EIPS/eip-reduce-alt_bn128-gas-costs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-reduce-alt_bn128-gas-costs.md b/EIPS/eip-reduce-alt_bn128-gas-costs.md index 50f176ed2bbc2..56b5e5de01e93 100644 --- a/EIPS/eip-reduce-alt_bn128-gas-costs.md +++ b/EIPS/eip-reduce-alt_bn128-gas-costs.md @@ -1,7 +1,7 @@ --- eip: title: Reduce alt_bn128 precompile gas costs -author: Antonio Salazar Cardozo (@shadowfiend) +author: Antonio Salazar Cardozo (@shadowfiend) status: Draft type: Standards Track category: Core From 40e45abcc85e002e507cd8f64d24e6121b70963d Mon Sep 17 00:00:00 2001 From: Antonio Salazar Cardozo Date: Wed, 23 May 2018 08:52:08 -0400 Subject: [PATCH 9/9] Label alt_bn128 gas cost EIP as EIP 1108 --- EIPS/{eip-reduce-alt_bn128-gas-costs.md => eip-1108.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename EIPS/{eip-reduce-alt_bn128-gas-costs.md => eip-1108.md} (98%) diff --git a/EIPS/eip-reduce-alt_bn128-gas-costs.md b/EIPS/eip-1108.md similarity index 98% rename from EIPS/eip-reduce-alt_bn128-gas-costs.md rename to EIPS/eip-1108.md index 56b5e5de01e93..c034c4da8a0d1 100644 --- a/EIPS/eip-reduce-alt_bn128-gas-costs.md +++ b/EIPS/eip-1108.md @@ -1,5 +1,5 @@ --- -eip: +eip: 1108 title: Reduce alt_bn128 precompile gas costs author: Antonio Salazar Cardozo (@shadowfiend) status: Draft