disable EIP-2537: Precompile for BLS12-381 curve operations

reason: not included in berlin hard fork

but we keep the code around, for future inclusion
This commit is contained in:
jangko 2021-05-16 19:44:24 +07:00
parent 3ccc4642f2
commit 76543da456
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
3 changed files with 61 additions and 47 deletions

View File

@ -19,15 +19,17 @@ type
# Istanbul
paBlake2bf
# Berlin
paBlsG1Add
paBlsG1Mul
paBlsG1MultiExp
paBlsG2Add
paBlsG2Mul
paBlsG2MultiExp
paBlsPairing
paBlsMapG1
paBlsMapG2
# EIP 2537: disabled
# reason: not included in berlin
# paBlsG1Add
# paBlsG1Mul
# paBlsG1MultiExp
# paBlsG2Add
# paBlsG2Mul
# paBlsG2MultiExp
# paBlsPairing
# paBlsMapG1
# paBlsMapG2
iterator activePrecompiles*(): EthAddress =
var res: EthAddress
@ -667,7 +669,9 @@ proc blsMapG2*(c: Computation) =
proc getMaxPrecompileAddr(fork: Fork): PrecompileAddresses =
if fork < FkByzantium: paIdentity
elif fork < FkIstanbul: paPairing
elif fork < FkBerlin: paBlake2bf
# EIP 2537: disabled
# reason: not included in berlin
# elif fork < FkBerlin: paBlake2bf
else: PrecompileAddresses.high
proc execPrecompiles*(computation: Computation, fork: Fork): bool {.inline.} =
@ -691,15 +695,17 @@ proc execPrecompiles*(computation: Computation, fork: Fork): bool {.inline.} =
of paEcMul: bn256ecMul(computation, fork)
of paPairing: bn256ecPairing(computation, fork)
of paBlake2bf: blake2bf(computation)
of paBlsG1Add: blsG1Add(computation)
of paBlsG1Mul: blsG1Mul(computation)
of paBlsG1MultiExp: blsG1MultiExp(computation)
of paBlsG2Add: blsG2Add(computation)
of paBlsG2Mul: blsG2Mul(computation)
of paBlsG2MultiExp: blsG2MultiExp(computation)
of paBlsPairing: blsPairing(computation)
of paBlsMapG1: blsMapG1(computation)
of paBlsMapG2: blsMapG2(computation)
# EIP 2537: disabled
# reason: not included in berlin
# of paBlsG1Add: blsG1Add(computation)
# of paBlsG1Mul: blsG1Mul(computation)
# of paBlsG1MultiExp: blsG1MultiExp(computation)
# of paBlsG2Add: blsG2Add(computation)
# of paBlsG2Mul: blsG2Mul(computation)
# of paBlsG2MultiExp: blsG2MultiExp(computation)
# of paBlsPairing: blsPairing(computation)
# of paBlsMapG1: blsMapG1(computation)
# of paBlsMapG2: blsMapG2(computation)
except OutOfGas as e:
# cannot use setError here, cyclic dependency
computation.error = Error(info: e.msg, burnsGas: true)

View File

@ -29,15 +29,17 @@ type
# Istanbul
paBlake2bf
# Berlin
paBlsG1Add
paBlsG1Mul
paBlsG1MultiExp
paBlsG2Add
paBlsG2Mul
paBlsG2MultiExp
paBlsPairing
paBlsMapG1
paBlsMapG2
# EIP-2537: disabled
# reason: not included in berlin
# paBlsG1Add
# paBlsG1Mul
# paBlsG1MultiExp
# paBlsG2Add
# paBlsG2Mul
# paBlsG2MultiExp
# paBlsPairing
# paBlsMapG1
# paBlsMapG2
iterator activePrecompiles*(): EthAddress =
var res: EthAddress
@ -677,7 +679,9 @@ proc blsMapG2*(c: Computation) =
proc getMaxPrecompileAddr(fork: Fork): PrecompileAddresses =
if fork < FkByzantium: paIdentity
elif fork < FkIstanbul: paPairing
elif fork < FkBerlin: paBlake2bf
# EIP 2537: disabled
# reason: not included in berlin
# elif fork < FkBerlin: paBlake2bf
else: PrecompileAddresses.high
proc execPrecompiles*(computation: Computation, fork: Fork): bool {.inline.} =
@ -701,15 +705,17 @@ proc execPrecompiles*(computation: Computation, fork: Fork): bool {.inline.} =
of paEcMul: bn256ecMul(computation, fork)
of paPairing: bn256ecPairing(computation, fork)
of paBlake2bf: blake2bf(computation)
of paBlsG1Add: blsG1Add(computation)
of paBlsG1Mul: blsG1Mul(computation)
of paBlsG1MultiExp: blsG1MultiExp(computation)
of paBlsG2Add: blsG2Add(computation)
of paBlsG2Mul: blsG2Mul(computation)
of paBlsG2MultiExp: blsG2MultiExp(computation)
of paBlsPairing: blsPairing(computation)
of paBlsMapG1: blsMapG1(computation)
of paBlsMapG2: blsMapG2(computation)
# EIP 2537: disabled
# reason: not included in berlin
# of paBlsG1Add: blsG1Add(computation)
# of paBlsG1Mul: blsG1Mul(computation)
# of paBlsG1MultiExp: blsG1MultiExp(computation)
# of paBlsG2Add: blsG2Add(computation)
# of paBlsG2Mul: blsG2Mul(computation)
# of paBlsG2MultiExp: blsG2MultiExp(computation)
# of paBlsPairing: blsPairing(computation)
# of paBlsMapG1: blsMapG1(computation)
# of paBlsMapG2: blsMapG2(computation)
except OutOfGas as e:
# cannot use setError here, cyclic dependency
computation.error = Error(info: e.msg, burnsGas: true)

View File

@ -65,15 +65,17 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
of "bn256mul" : data.doTest(fork, paEcMul)
of "ecpairing": data.doTest(fork, paPairing)
of "blake2f" : data.doTest(fork, paBlake2bf)
of "blsg1add" : data.doTest(fork, paBlsG1Add)
of "blsg1mul" : data.doTest(fork, paBlsG1Mul)
of "blsg1multiexp" : data.doTest(fork, paBlsG1MultiExp)
of "blsg2add" : data.doTest(fork, paBlsG2Add)
of "blsg2mul" : data.doTest(fork, paBlsG2Mul)
of "blsg2multiexp": data.doTest(fork, paBlsG2MultiExp)
of "blspairing": data.doTest(fork, paBlsPairing)
of "blsmapg1": data.doTest(fork, paBlsMapG1)
of "blsmapg2": data.doTest(fork, paBlsMapG2)
# EIP 2537: disabled
# reason: not included in berlin
#of "blsg1add" : data.doTest(fork, paBlsG1Add)
#of "blsg1mul" : data.doTest(fork, paBlsG1Mul)
#of "blsg1multiexp" : data.doTest(fork, paBlsG1MultiExp)
#of "blsg2add" : data.doTest(fork, paBlsG2Add)
#of "blsg2mul" : data.doTest(fork, paBlsG2Mul)
#of "blsg2multiexp": data.doTest(fork, paBlsG2MultiExp)
#of "blspairing": data.doTest(fork, paBlsPairing)
#of "blsmapg1": data.doTest(fork, paBlsMapG1)
#of "blsmapg2": data.doTest(fork, paBlsMapG2)
else:
echo "Unknown test vector '" & $label & "'"
testStatusIMPL = SKIPPED