Description
Contact Details
No response
Which network are you using?
mainnet
What happened?
Description
After implantation for Aurora Enigne EIP-2537: aurora-is-near/aurora-engine#990
tests based on blst
crate, we decided to use NEAR host functions, that related to:
https://github.com/near/nearcore/blob/master/runtime/near-vm-runner/src/logic/bls12381.rs
As we're using execution-spec-tests for testing EVM, we have successfully passed all tests with our own implementation, as it's represented in the PR mentioned. But near-host functions that were integrated to aurora-engine-sdk
failed for execution-spec-tests
.
After research and investigations, with extending and runnging tests with: https://github.com/near/nearcore/blob/master/runtime/near-vm-runner/src/logic/tests/bls12381.rs for execution-spec-tests
we discovered several issues.
Incorrect input and output data for EIP-2537
We discovered, that input and output data for EIP-2537 should be unpadded for input
data, and padded for output
data using NEP-488 functions. According to NEP-488 we can use that function directly for EIP-2537, and it's misleading, as it's not true. As explained, the data should be prepared to pass as parameters. We managed it for Aurora Engine. But it's also about additional NEAR gas consumption.
Bug for BLS12-381 g1_add
We discovered running execution-spec-tests
that points with coordinate 0<..<=2
produce incorrect results. We aligned only to execution-spec-tests
tests. And it's possible same bug for other coordinates.
Input examples:
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaa9
Gas exceeded issue BLS12-381 g1_mul
We have got host error GasExceeded
for input: > 17000
Gas exceeded issue BLS12-381 g2_mul
We have got host error GasExceeded
for input: > 14500
Memory violation for BLS12-381 pairing
We have got host error MemoryAccessViolation
for test case execution-spec-tests
with input: 384000
Relevant log output
no logs there