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

NODE-2604 Add code from wavesplatform/groth16verify #23

Merged
merged 38 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ac05245
- Added code from bn254 at wavesplatform/groth16verify;
vsuharnikov Sep 28, 2023
f5c8908
CI
vsuharnikov Sep 28, 2023
504f5cd
- New tests for groth16;
vsuharnikov Sep 29, 2023
d83c8c8
- Running Rust tests in build;
vsuharnikov Oct 2, 2023
a20f27e
Fix running Rust tests
vsuharnikov Oct 2, 2023
97c7a55
Fix running Rust tests (2)
vsuharnikov Oct 2, 2023
fd690b7
Run Java tests
vsuharnikov Oct 2, 2023
1662eaf
- Build for more platforms;
vsuharnikov Oct 2, 2023
9bdcb8f
Build fix
vsuharnikov Oct 2, 2023
8b635ee
Build fix (2)
vsuharnikov Oct 2, 2023
3ab7d13
Build fix (3)
vsuharnikov Oct 2, 2023
a33ba90
Build fix (4)
vsuharnikov Oct 2, 2023
6492664
Build fix (5)
vsuharnikov Oct 2, 2023
c749dda
Build fix (6)
vsuharnikov Oct 2, 2023
a8a422d
Build fix (7)
vsuharnikov Oct 2, 2023
28f88f0
Build fix (8)
vsuharnikov Oct 2, 2023
372d897
Build fix (9)
vsuharnikov Oct 2, 2023
191bae4
Build fix (10)
vsuharnikov Oct 2, 2023
5441e17
Build fix (11): extra packages
vsuharnikov Oct 2, 2023
549b87c
Build fix (12): extra packages
vsuharnikov Oct 2, 2023
fc70ccd
Build fix (13): windows build
vsuharnikov Oct 2, 2023
ad2d769
Build fix (14): windows build
vsuharnikov Oct 2, 2023
faa3d2b
Build fix (15): windows build
vsuharnikov Oct 2, 2023
12ec4e8
Build fix (16): windows build (x86)
vsuharnikov Oct 3, 2023
0f90103
Build fix (17): windows build (x86), msvc
vsuharnikov Oct 3, 2023
14e4148
Build fix (18): windows build, msvc
vsuharnikov Oct 3, 2023
f954ab3
Build fix (19): all platforms test
vsuharnikov Oct 3, 2023
ea3c71f
Build fix (20): fixed the native libraries directory structure
vsuharnikov Oct 3, 2023
2000724
Publishing (WIP)
vsuharnikov Oct 11, 2023
48079a6
Publishing (2)
vsuharnikov Oct 11, 2023
166cd0d
Publishing (3), snapshot publications work
vsuharnikov Oct 11, 2023
a4099ef
Publishing staging version test
vsuharnikov Oct 12, 2023
cafe871
Publishing staging version test (2)
vsuharnikov Oct 12, 2023
4b7d874
Publishing staging version test (3)
vsuharnikov Oct 12, 2023
dfea3df
Publishing staging version with io.github.gradle-nexus.publish-plugin…
vsuharnikov Oct 12, 2023
2969e87
Publishing staging version with io.github.gradle-nexus.publish-plugin…
vsuharnikov Oct 12, 2023
e7cd793
Publishing staging version with io.github.gradle-nexus.publish-plugin
vsuharnikov Oct 12, 2023
ecc8b0c
Added newlines
vsuharnikov Oct 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
185 changes: 185 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
name: Publish artifacts to Sonatype Repo

on:
push:
branches:
- master
- version-[0-9].[0-9]+.x
tags:
- v[0-9].[0-9]+.[0-9]+
pull_request:

env:
NATIVE_DIR: zwaves_jni/javalib/src/main/resources/META-INF/native
GRADLE_EXTRA_ARGS: --console=plain -Ppr=${{ github.event.number }} -PrefName=${{ github.head_ref }}
# GITHUB_CONTEXT: ${{ toJson(github) }} # For debugging purposes

jobs:
build-native:
name: ${{ matrix.platform }}/${{ matrix.arch }} library
runs-on: ${{ matrix.os }}
env:
# Where a library should be
target-path: ${{ matrix.jni-platform }}/${{ matrix.arch }}

# Rust build target
build-target: ${{ matrix.build-arch }}-${{ matrix.build-platform }}

# Rust target directory
TARGET_DIR: ./target

# Emit backtraces on panics.
RUST_BACKTRACE: 1
strategy:
matrix:
platform: [ linux, osx, windows ]
arch: [ aarch64, amd64, x86 ]
exclude:
- platform: osx
arch: x86
- platform: windows
arch: aarch64

include:
- platform: linux
os: ubuntu-20.04
build-platform: unknown-linux-gnu
artifact: libzwaves_jni.so
jni-platform: linux64

- platform: linux
arch: aarch64
extra-packages: gcc-aarch64-linux-gnu

- platform: linux
arch: x86
extra-packages: gcc-multilib
jni-platform: linux32

- platform: osx
os: macos-latest
build-platform: apple-darwin
artifact: libzwaves_jni.dylib
jni-platform: osx64

- platform: windows
os: windows-2019
build-platform: pc-windows-msvc # x86 and gcc lead to "undefined reference to _Unwind_Resume"
artifact: zwaves_jni.dll
jni-platform: windows64

- platform: windows
arch: x86
jni-platform: windows32

- arch: aarch64
build-arch: aarch64

- arch: amd64
build-arch: x86_64

- arch: x86
build-arch: i686
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Print debug information
run: |
echo "Build target: ${{ env.build-target }}"
echo "Target path: ${{ env.target-path }}"

- name: Install build tools
if: ${{ matrix.extra-packages }}
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.extra-packages }}

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ env.build-target }}

- name: Enable Rust dependencies caching
uses: Swatinem/rust-cache@v2

- name: Run Rust tests
# Architecture is always x86-64: https://stackoverflow.com/a/71220337
if: matrix.arch == 'amd64'
run: |
cd zwaves_jni
cargo test --lib --target ${{ env.build-target }}

- name: Build native libraries
run: |
cd zwaves_jni
cargo build --release --target ${{ env.build-target }}
cd ..

cp target/${{ env.build-target }}/release/${{ matrix.artifact }} ${{ env.NATIVE_DIR }}/${{ env.target-path }}

- name: Upload result
uses: actions/upload-artifact@v3
with:
name: native-libraries
path: ${{ env.NATIVE_DIR }}/**/*

build-jni:
name: Build JNI library
runs-on: ubuntu-20.04
needs: build-native
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
java-version: 8
distribution: temurin
cache: gradle

- uses: actions/download-artifact@v3
with:
name: native-libraries
path: ${{ env.NATIVE_DIR }}

- name: Print debug information
run: |
cd ./zwaves_jni/javalib

# About -q: https://github.com/gradle/gradle/issues/5098#issuecomment-1084652709
VERSION=$(./gradlew -q $GRADLE_EXTRA_ARGS printVersion)
PUBLISHING_TYPE=$(./gradlew -q $GRADLE_EXTRA_ARGS publishingType)

# echo "$GITHUB_CONTEXT" # For debugging purposes

echo "Gradle extra arguments: ${GRADLE_EXTRA_ARGS}"
echo "Building ${VERSION}, publishing type: ${PUBLISHING_TYPE}"

# Make environment variables available in the next step
echo "PUBLISHING_TYPE=${PUBLISHING_TYPE}" >> $GITHUB_ENV

- name: Run tests
run: |
cd zwaves_jni/javalib
./gradlew ${GRADLE_EXTRA_ARGS} test

- name: Publish snapshot version
if: ${{ env.PUBLISHING_TYPE == 'snapshot' }}
run: |
cd zwaves_jni/javalib
./gradlew ${GRADLE_EXTRA_ARGS} publishToSonatype \
-PsonatypeUsername='${{ secrets.OSSRH_USERNAME }}' \
-PsonatypePassword='${{ secrets.OSSRH_PASSWORD }}' \
-PgpgKey='${{ secrets.OSSRH_GPG_KEY_ASCII }}' \
-PgpgPassphrase='${{ secrets.OSSRH_GPG_PASSPHRASE }}'

- name: Publish staging version
if: ${{ env.PUBLISHING_TYPE == 'staging' }}
run: |
cd zwaves_jni/javalib
./gradlew ${GRADLE_EXTRA_ARGS} publishToSonatype closeAndReleaseSonatypeStagingRepository \
-PsonatypeUsername='${{ secrets.OSSRH_USERNAME }}' \
-PsonatypePassword='${{ secrets.OSSRH_PASSWORD }}' \
-PgpgKey='${{ secrets.OSSRH_GPG_KEY_ASCII }}' \
-PgpgPassphrase='${{ secrets.OSSRH_GPG_PASSPHRASE }}'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ bin/
pkg/
wasm-pack.log
.vscode
.idea
!zwaves_jni/src/bn256/bin
!zwaves_setup/src/bin
7 changes: 7 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
edition = "2018"

max_width = 120
hard_tabs = false
newline_style = "Unix"

imports_granularity = "Crate"
13 changes: 0 additions & 13 deletions zwaves_jni/.cargo/config

This file was deleted.

18 changes: 16 additions & 2 deletions zwaves_jni/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
[package]
name = "zwaves_jni"
version = "0.1.0"
version = "0.2.0"
authors = ["Igor Gulamov <[email protected]>"]
edition = "2018"

[lib]
crate-type = ["cdylib"]
crate-type = ["cdylib", "rlib"]
name = "zwaves_jni"

[[bin]]
path = "src/bn256/bin/show_test_vectors.rs"
name="show_test_vectors"

[dependencies]
bellman = { version = "0.1.0" }
zwaves_primitives = { path = "../zwaves_primitives"}
sapling-crypto = { path = "../sapling-crypto" }
pairing = "0.14"
pairing_ce = "0.18" # for bn256
num = "0.2"
serde = { version = "1.0", features = ["derive"] }
base64 = "0.11.0"
jni = "0.14.0"
byteorder = "1"
rand = "0.4"

# for bn256
[dependencies.ff]
version = "=0.7"
features = ["derive"]
package = "ff_ce"

[dev-dependencies]
test-case = "3.2.1"
9 changes: 0 additions & 9 deletions zwaves_jni/build_all.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
if [ ! -d "osxcross" ]; then
git clone https://github.com/tpoechtrager/osxcross
pushd osxcross
wget -nc https://s3.dockerproject.org/darwin/v2/MacOSX10.10.sdk.tar.xz
mv MacOSX10.10.sdk.tar.xz tarballs/
UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh
popd
fi

cargo build --target=i686-unknown-linux-gnu --release
cp ../target/i686-unknown-linux-gnu/release/libzwaves_jni.so javalib/src/main/resources/META-INF/native/linux32

Expand Down
91 changes: 70 additions & 21 deletions zwaves_jni/javalib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,37 +1,86 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java Library project to get you started.
* For more details take a look at the Java Libraries chapter in the Gradle
* User Manual available at https://docs.gradle.org/5.4.1/userguide/java_library_plugin.html
*/

plugins {
// Apply the java-library plugin to add support for Java Library
id 'java-library'
id "java-library"
id "maven-publish"
id "signing"
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
}

repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
mavenCentral()
}

dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
def pr() { project.findProperty('pr').toString() ?: "" }

// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:27.0.1-jre'
def refName() { project.findProperty('refName').toString() ?: "" }

// Use JUnit test framework
testImplementation 'junit:junit:4.12'
ext {
baseVersion = "0.1.7"

publishingType = {
if (pr()?.isNumber()) "snapshot" else if (refName() == "v${baseVersion}") "staging" else "prohibited"
}

artifactVersion = {
if (pr()?.isNumber()) "${baseVersion}-${pr()}-SNAPSHOT" else baseVersion
}
}

group = "com.wavesplatform"
archivesBaseName = "zwaves"
version = artifactVersion()

dependencies {
testImplementation 'junit:junit:4.12'
}

test {
useJUnit()

maxHeapSize = '1G'
}

tasks.register('printVersion') {
doLast {
println version
}
}

tasks.register('publishingType') {
doLast {
println publishingType()
}
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java

pom {
packaging = 'jar'
url = 'https://github.com/wavesplatform/zwaves'
licenses {
license {
name.set("MIT License")
url.set("LICENSE")
}
}
scm {
connection.set("scm:git:git://github.com/wavesplatform/zwaves.git")
developerConnection.set("scm:git:[email protected]:wavesplatform/zwaves.git")
url.set("https://github.com/wavesplatform/zwaves")
}
}
}
}
}

signing {
useInMemoryPgpKeys(gpgKey, gpgPassphrase)
sign configurations.archives
}

nexusPublishing {
repositories {
sonatype()
}
}
5 changes: 5 additions & 0 deletions zwaves_jni/javalib/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sonatypeRepo=
sonatypeUsername=
sonatypePassword=
gpgKey=
gpgPassphrase=
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Empty file modified zwaves_jni/javalib/gradlew
100644 → 100755
Empty file.
Loading