Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: NEP-488 incorrect behavior #12928

Open
mrLSD opened this issue Feb 13, 2025 · 0 comments
Open

Bug: NEP-488 incorrect behavior #12928

mrLSD opened this issue Feb 13, 2025 · 0 comments
Labels
community Issues created by community investigation required

Comments

@mrLSD
Copy link

mrLSD commented Feb 13, 2025

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Issues created by community investigation required
Projects
None yet
Development

No branches or pull requests

1 participant