Skip to content

Commit

Permalink
Workspace inheritance (#683)
Browse files Browse the repository at this point in the history
* Use workspace inheritance for dependencies

* Fix CI: move algebra outside of curves dir

If we clone algebra inside curves, it will look at the curves Cargo.toml
for workspace dependencies. Cloning it outside fixes this.

* Use workspace package for crate information

* Try fix README

* WIP

* remove trailing space

* update crate version numbers to 0.4.2

* bump Rust version

* `algebra` path would overwrite the contents of the parent

change dir to ark-algebra

reference the right filepath in patching step

* clone curves into a separate dir

* update action versions

* remove dir prints

* revert keywords inheritance

---------

Co-authored-by: William Arnold <will748@gmail.com>
Co-authored-by: Weikeng Chen <w.k@berkeley.edu>
Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
  • Loading branch information
4 people authored Sep 19, 2023
1 parent 494830d commit 5f588ef
Show file tree
Hide file tree
Showing 12 changed files with 271 additions and 205 deletions.
43 changes: 22 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- nightly
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Rust (${{ matrix.rust }})
uses: actions-rs/toolchain@v1
Expand All @@ -72,7 +72,7 @@ jobs:
toolchain: ${{ matrix.rust }}
override: true

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
RUSTFLAGS: -Dwarnings
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Rust nightly
uses: actions-rs/toolchain@v1
Expand All @@ -137,7 +137,7 @@ jobs:
toolchain: nightly
override: true

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
Expand All @@ -160,7 +160,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
Expand All @@ -169,7 +169,7 @@ jobs:
target: aarch64-unknown-none
override: true

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
Expand Down Expand Up @@ -215,14 +215,15 @@ jobs:
- ed_on_bls12_377
steps:
- name: Checkout curves
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: arkworks-rs/curves
path: curves

- name: Checkout algebra
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: algebra
path: ark-algebra

- name: Install Rust
uses: actions-rs/toolchain@v1
Expand All @@ -233,19 +234,19 @@ jobs:

- name: Patch cargo.toml
run: |
if grep -q "\[patch.crates-io\]" Cargo.toml ; then
MATCH=$(awk '/\[patch.crates-io\]/{ print NR; exit }' Cargo.toml);
sed -i "$MATCH,\$d" Cargo.toml
if grep -q "\[patch.crates-io\]" curves/Cargo.toml ; then
MATCH=$(awk '/\[patch.crates-io\]/{ print NR; exit }' curves/Cargo.toml);
sed -i "$MATCH,\$d" curves/Cargo.toml
fi
{
echo "[patch.crates-io]";
echo "ark-ff = { path = 'algebra/ff' }";
echo "ark-serialize = { path = 'algebra/serialize' }";
echo "ark-ff-macros = { path = 'algebra/ff-macros' }";
echo "ark-ff-asm = { path = 'algebra/ff-asm' }";
echo "ark-ec = { path = 'algebra/ec' }";
echo "ark-algebra-bench-templates = { path = 'algebra/bench-templates' }"
echo "ark-algebra-test-templates = { path = 'algebra/test-templates' }"
echo "ark-ff = { path = '../ark-algebra/ff' }";
echo "ark-serialize = { path = '../ark-algebra/serialize' }";
echo "ark-ff-macros = { path = '../ark-algebra/ff-macros' }";
echo "ark-ff-asm = { path = '../ark-algebra/ff-asm' }";
echo "ark-ec = { path = '../ark-algebra/ec' }";
echo "ark-algebra-bench-templates = { path = '../ark-algebra/bench-templates' }"
echo "ark-algebra-test-templates = { path = '../ark-algebra/test-templates' }"
echo "ark-bls12-377 = { git = 'https://github.com/arkworks-rs/curves' }"
echo "ark-bls12-381 = { git = 'https://github.com/arkworks-rs/curves' }"
echo "ark-bn254 = { git = 'https://github.com/arkworks-rs/curves' }"
Expand All @@ -256,7 +257,7 @@ jobs:
echo "ark-ed-on-bls12-377 = { git = 'https://github.com/arkworks-rs/curves' }"
echo "ark-std = { git = 'https://github.com/arkworks-rs/std' }"
echo "ark-r1cs-std = { git = 'https://github.com/arkworks-rs/r1cs-std' }"
} >> Cargo.toml
} >> curves/Cargo.toml
- name: Test on ${{ matrix.curve }}
run: "cd ${{ matrix.curve }} && cargo test --all-features"
run: "cd curves/${{ matrix.curve }} && cargo test --all-features"
56 changes: 55 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[workspace]

members = [
"serialize",
"serialize-derive",
Expand All @@ -15,6 +14,61 @@ members = [
"test-curves",
"test-templates",
]
resolver = "2"

[workspace.package]
version = "0.4.2"
authors = [ "arkworks contributors" ]
homepage = "https://arkworks.rs"
repository = "https://github.com/arkworks-rs/algebra"
categories = ["cryptography"]
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT", "doc/katex-header.html"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.70"

[workspace.metadata.docs.rs]
rustdoc-args = [ "--html-in-header katex-header.html" ]

[workspace.dependencies]
ark-ec = { version = "0.4.2", path = "./ec", default-features = false }
ark-ff = { version = "0.4.2", path = "./ff", default-features = false }
ark-ff-asm = { version = "0.4.2", path = "./ff-asm" }
ark-ff-macros = { version = "0.4.2", path = "./ff-macros" }
ark-poly = { version = "0.4.2", path = "./poly", default-features = false }
ark-serialize = { version = "0.4.2", path = "./serialize", default-features = false }
ark-serialize-derive = { version = "0.4.2", path = "./serialize-derive" }
ark-std = { version = "0.4.0", default-features = false }

ark-algebra-bench-templates = { version = "0.4.2", path = "./bench-templates", default-features = false }
ark-algebra-test-templates = { version = "0.4.2", path = "./test-templates", default-features = false }
ark-test-curves = { version = "0.4.2", path = "./test-curves", default-features = false }

num-traits = { version = "0.2", default-features = false }
num-bigint = { version = "0.4", default-features = false }
num-integer = { version = "0.1", default-features = false }

criterion = "0.5.0"
derivative = "2"
digest = { version = "0.10", default-features = false }
hashbrown = "0.14"
hex = "0.4"
itertools = { version = "0.11", default-features = false }
libtest-mimic = "0.6.0"
paste = "1.0"
rayon = "1"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
sha2 = { version = "0.10", default-features = false }
sha3 = { version = "0.10", default-features = false }
blake2 = { version = "0.10", default-features = false }
zeroize = { version = "1", default-features = false }


proc-macro2 = "1.0"
quote = "1.0"
syn = "1.0"

resolver = "2"

Expand Down
34 changes: 18 additions & 16 deletions bench-templates/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
[package]
name = "ark-algebra-bench-templates"
version = "0.4.2"
authors = [ "arkworks contributors" ]
description = "A benchmark library for finite fields and elliptic curves"
homepage = "https://arkworks.rs"
repository = "https://github.com/arkworks-rs/algebra"
documentation = "https://docs.rs/algebra/"
keywords = ["cryptography", "finite-fields", "elliptic-curves", "pairing"]
categories = ["cryptography"]
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.63"
documentation = "https://docs.rs/ark-algebra-bench-templates/"
version.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
categories.workspace = true
include.workspace = true
license.workspace = true
edition.workspace = true
rust-version.workspace = true
rustdocflags.workspace = true


################################# Dependencies ################################

[dependencies]
criterion = { version = "0.5.1", features = [ "html_reports" ] }
ark-std = { version = "0.4.0", default-features = false }
ark-ec = { version = "0.4.2", path = "../ec", default-features = false }
ark-ff = { version = "0.4.2", path = "../ff", default-features = false }
ark-serialize = { version = "0.4.2", path = "../serialize", default-features = false }
paste = { version = "1.0" }
criterion = { workspace = true, features = [ "html_reports" ] }
ark-std.workspace = true
ark-ec.workspace = true
ark-ff.workspace = true
ark-serialize.workspace = true
paste.workspace = true

[features]
asm = [ "ark-ff/asm" ]
Expand Down
55 changes: 28 additions & 27 deletions ec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
[package]
name = "ark-ec"
version = "0.4.2"
authors = [ "arkworks contributors" ]
description = "A library for elliptic curves and pairings"
homepage = "https://arkworks.rs"
repository = "https://github.com/arkworks-rs/algebra"
documentation = "https://docs.rs/ark-ec/"
version.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
categories.workspace = true
include.workspace = true
license.workspace = true
edition.workspace = true
rust-version.workspace = true
rustdocflags.workspace = true
keywords = ["cryptography", "elliptic-curves", "pairing"]
categories = ["cryptography"]
include = ["Cargo.toml", "src", "doc", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.63"

[dependencies]
ark-std = { version = "0.4.0", default-features = false }
ark-serialize = { version = "0.4.2", path = "../serialize", default-features = false }
ark-ff = { version = "0.4.2", path = "../ff", default-features = false }
ark-poly = { version = "0.4.2", path = "../poly", default-features = false }
derivative = { version = "2", features = ["use_core"] }
num-traits = { version = "0.2", default-features = false }
rayon = { version = "1", optional = true }
zeroize = { version = "1", default-features = false, features = ["zeroize_derive"] }
hashbrown = "0.14.0"
itertools = { version = "0.11", default-features = false }
num-bigint = { version = "0.4.3", default-features = false }
ark-std.workspace = true
ark-serialize.workspace = true
ark-ff.workspace = true
ark-poly.workspace = true
derivative = { workspace = true, features = ["use_core"] }
num-bigint.workspace = true
num-traits.workspace = true
rayon = { workspace = true, optional = true }
zeroize = { workspace = true, features = ["zeroize_derive"] }
hashbrown.workspace = true
itertools.workspace = true

[dev-dependencies]
ark-test-curves = { version = "0.4.2", path = "../test-curves", default-features = false, features = ["bls12_381_curve"] }
sha2 = { version = "0.10", default-features = false }
libtest-mimic = "0.6.0"
serde = "1.0.110"
serde_json = "1.0.53"
serde_derive = "1.0.110"
hex = "0.4"
ark-test-curves = { workspace = true, features = ["bls12_381_curve"] }
sha2.workspace = true
libtest-mimic.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_derive.workspace = true
hex.workspace = true

[features]
default = []
Expand Down
23 changes: 12 additions & 11 deletions ff-asm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
[package]
name = "ark-ff-asm"
version = "0.4.2"
authors = [ "arkworks contributors" ]
description = "A library for generating x86-64 assembly for finite field multiplication"
homepage = "https://arkworks.rs"
repository = "https://github.com/arkworks-rs/algebra"
documentation = "https://docs.rs/ark-ff-asm/"
version.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
categories.workspace = true
include.workspace = true
license.workspace = true
edition.workspace = true
rust-version.workspace = true
rustdocflags.workspace = true
keywords = ["cryptography", "finite-fields", "assembly" ]
categories = ["cryptography"]
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"

[dependencies]
quote = "1.0.0"
syn = { version = "1.0.0", features = ["full", "parsing", "extra-traits"]}
quote.workspace = true
syn = { workspace = true, features = ["full", "parsing", "extra-traits"]}

[lib]
proc-macro = true
31 changes: 16 additions & 15 deletions ff-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
[package]
name = "ark-ff-macros"
version = "0.4.2"
authors = [ "arkworks contributors" ]
description = "A library for generating x86-64 assembly for finite field multiplication"
homepage = "https://arkworks.rs"
repository = "https://github.com/arkworks-rs/algebra"
documentation = "https://docs.rs/ark-ff-asm/"
documentation = "https://docs.rs/ark-ff-macros/"
version.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
categories.workspace = true
include.workspace = true
license.workspace = true
edition.workspace = true
rust-version.workspace = true
rustdocflags.workspace = true
keywords = ["cryptography", "finite-fields", "assembly" ]
categories = ["cryptography"]
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"

[dependencies]
quote = "1.0.0"
proc-macro2 = { version = "1" }
syn = { version = "1.0.0", features = ["full", "parsing", "extra-traits"]}
num-bigint = { version = "0.4", default-features = false }
num-traits = { version = "0.2", default-features = false }
quote.workspace = true
proc-macro2.workspace = true
syn = { workspace = true, features = ["full", "parsing", "extra-traits"]}
num-bigint.workspace = true
num-traits.workspace = true

[lib]
proc-macro = true
Loading

0 comments on commit 5f588ef

Please sign in to comment.