Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

feat: support bn256_pairing precompiled contract by Godwoken syscall #88

Merged
merged 20 commits into from
Nov 7, 2022

Conversation

Flouse
Copy link
Collaborator

@Flouse Flouse commented Sep 22, 2021

Previously, bn256_pairing precompiled contract was not supported due to too high cycle cost.

This PR implements bn256_pairing precompiled contract by introducing new Godwoken syscall:

sys_bn_pairing

Dependencies

Tests

test code:
https://github.com/Flouse/godwoken-polyjuice/blob/47865fc349d9485021b3e75205cfd621c1ada8e1/polyjuice-tests/src/test_cases/pre_compiled_contracts.rs#L163-L697

cmd:

cd polyjuice-tests/
cargo test --release -- test_bn256_add --nocapture 2>&1
cargo test --release -- test_bn256_scalar_mul --nocapture 2>&1
cargo test --release -- test_bn256_pairing --nocapture 2>&1
Test Case Elapsed Time (ms) Used Gas Used Cycles (virtual+execution)
Bn256Add 1 ~27K ~693K
Bn256ScalarMul <2 ~31K ~690K
Bn256Pairing one_point 5 ~105K ~918K
Bn256Pairing two_point_match_2 6 ~141K ~1024K
Bn256Pairing two_point_match_3 7 ~141K ~1024K
Bn256Pairing two_point_match_4 8 ~141K ~1024K
Bn256Pairing ten_point_match_1 22 ~432K ~1874K
Bn256Pairing ten_point_match_2 23 ~436K ~1874K
Bn256Pairing ten_point_match_3 8 ~142K ~1024K

@Flouse Flouse marked this pull request as ready for review September 22, 2021 13:41
@Flouse Flouse changed the title Support bn256_pairing_istanbul pre-compiled contract feat: Support bn256_pairing_istanbul pre-compiled contract Sep 22, 2021
@Flouse Flouse requested review from TheWaWaR and jjyr September 22, 2021 13:58
TheWaWaR
TheWaWaR previously approved these changes Sep 23, 2021
@Flouse Flouse marked this pull request as draft September 30, 2021 02:55
c/contracts.h Outdated Show resolved Hide resolved
c/generator.c Outdated Show resolved Hide resolved
@Flouse Flouse force-pushed the bn256-pairing branch 3 times, most recently from 4dc4d1e to c18cf7a Compare September 21, 2022 17:02
@Flouse Flouse requested a review from magicalne September 22, 2022 05:58
@Flouse Flouse self-assigned this Sep 27, 2022
@Flouse Flouse changed the title feat: Support bn256_pairing_istanbul pre-compiled contract feat: support bn256_pairing precompiled contract by Godwoken syscall Sep 30, 2022
@Flouse Flouse marked this pull request as ready for review October 8, 2022 07:05
jjyr
jjyr previously approved these changes Oct 9, 2022
@Flouse Flouse added the enhancement New feature or request label Oct 9, 2022
@Flouse Flouse requested review from TheWaWaR and XuJiandong October 9, 2022 16:54
magicalne
magicalne previously approved these changes Oct 10, 2022
zeroqn
zeroqn previously approved these changes Oct 12, 2022
@Flouse Flouse dismissed stale reviews from zeroqn and magicalne via 3436a7e October 12, 2022 09:38
Flouse added 19 commits November 7, 2022 10:21
error[E0463]: can't find crate for `core`
  |
  = note: the `riscv64imac-unknown-none-elf` target may not be installed
  = help: consider downloading the target with `rustup target add riscv64imac-unknown-none-elf`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`
the gw prefix can filter out a lot unrelated log
@jjyr jjyr requested review from XuJiandong and zeroqn and removed request for XuJiandong November 7, 2022 02:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants