Reduce alt_bn128 precompile gas costs
Antonio Salazar Cardozo (@shadowfiend)
Recent changes to the underlying library used by the official Go reference
implementation led to significant performance gains for the
and pairing check precompiled contracts on the
alt_bn128 elliptic curve.
What is more, the performance boost for those operations can be also observed for Parity client.
Faster operations on Ethereum clients should be reflected in reduced gas costs.
Recently, the underlying library used by the official Go reference
implementation to implement the
ECADD (at address
ECMUL (at address
0x07), and pairing check (at
0x08) precompiled contracts was shifted to Cloudflare's bn256
library. Based on the initial PR that
introduced this change,
and corroborated in a later
the computational cost of
ECMUL, and pairing checks (excepting the
constant) has dropped roughly an order of magnitude across the board.
Following is a table with the current gas cost and new gas cost:
|Contract||Address||Current Gas Cost||Updated Gas Cost|
||40 000||6 000|
||80 000 * k + 100 000||28 300 * k + 35 450|
The gas costs for
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. Updated gas costs have been adjusted to the less performant
client which is Parity, according to benchmarks.
- Per EIP-196.
- Per EIP-197.
- Parity benchmarks.