ethereum/yellowpaper

Gas cost of ECPAIRING is incorrect

livnev opened this issue · 1 comments

The yellow paper specifies the gas cost of ECPAIRING as 60,000k + 40,000, where k is the number of pairs of curve points to check. In reality, it should be 80,000k + 100,000. This is confirmed by cross-referencing with the following implementations:

KEVM has:

rule <k> #gasExec(_, ECPAIRING) => 100000 +Int (#sizeWordStack(DATA) /Int 192) *Int 80000 ... </k> <callData> DATA </callData>

py-evm has

GAS_ECPAIRING_BASE = 100000
GAS_ECPAIRING_PER_POINT = 80000

aleth has

ETH_REGISTER_PRECOMPILED_PRICER(alt_bn128_pairing_product)(bytesConstRef _in)
{
	return 100000 + (_in.size() / 192) * 80000;
}

parity has

		"0x0000000000000000000000000000000000000008": {
			"builtin": {
				"name": "alt_bn128_pairing",
				"activate_at": "0x42ae50",
				"pricing": {
					"alt_bn128_pairing": {
						"base": 100000,
						"pair": 80000
					}
				}
			}
		},

Good catch