diff --git a/CHANGELOG.md b/CHANGELOG.md index 7917297ea..cc9fa6e22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] ### Added - [\#131](https://github.com/Manta-Network/manta-rs/pull/131) Add abstract Phase 1 for Groth16 trusted setup +- [\#175](https://github.com/Manta-Network/manta-rs/pull/175) Add more documentation around `cargo-hakari` ### Changed diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 894de5d90..587e268be 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,7 +43,17 @@ to place each PR in its respective category or use `changelog:skip` if it should ## Pull Requests -See the [`PULL_REQUEST_TEMPLATE.md`](./.github/PULL_REQUEST_TEMPLATE.md) for more details on how to build a good PR. +### Templates + +We use pull-request templates to standardize the PR process. See the [`PULL_REQUEST_TEMPLATE.md`](./.github/PULL_REQUEST_TEMPLATE.md) for more details on how to build a good PR. + +### CI Pipeline + +When writing a new PR, the Continuous Integration (CI) system will trigger linting and tests to run on every commit. See the [`.github/workflows/ci.yml`](./.github/workflows/ci.yml) for more detail on this workflow and see the [`workspace-hack`](./workspace-hack/) directory for dependency upgrade issues. + +#### Updating the Dependency List + +When a dependency on `Cargo.toml` needs to be updated, the CI for a PR will fail because `cargo hakari generate --diff` will return with error code `1`. In this case, the `cargo hakari generate` command should be run on a local machine and the updates pushed to the relevant development branch. Be sure to install `cargo-hakari` with `cargo install cargo-hakari`, just as in the [CI workflow](./../.github/workflows/ci.yml). ## Style Guide diff --git a/manta-accounting/src/transfer/test.rs b/manta-accounting/src/transfer/test.rs index fade4b812..f1c373269 100644 --- a/manta-accounting/src/transfer/test.rs +++ b/manta-accounting/src/transfer/test.rs @@ -371,7 +371,7 @@ where rng, ); Self::new( - has_public_participants(SOURCES, SINKS).then(|| asset.id), + has_public_participants(SOURCES, SINKS).then_some(asset.id), into_array_unchecked(input), into_array_unchecked(senders), into_array_unchecked(receivers), @@ -407,7 +407,7 @@ where rng, ); Self::new( - has_public_participants(SOURCES, SINKS).then(|| distribution.asset_id), + has_public_participants(SOURCES, SINKS).then_some(distribution.asset_id), sample_asset_values(distribution.source_sum, rng), into_array_unchecked(senders), into_array_unchecked(receivers), diff --git a/manta-crypto/src/merkle_tree/tree.rs b/manta-crypto/src/merkle_tree/tree.rs index 0f0ed005a..783a87f5d 100644 --- a/manta-crypto/src/merkle_tree/tree.rs +++ b/manta-crypto/src/merkle_tree/tree.rs @@ -241,7 +241,7 @@ where L: IntoIterator>, { let mut tree = Self::new(parameters); - tree.extend(parameters, leaves).then(move || tree) + tree.extend(parameters, leaves).then_some(tree) } /// Builds a new merkle tree with the given `leaves` returning `None` if the slice diff --git a/manta-pay/src/crypto/poseidon/matrix.rs b/manta-pay/src/crypto/poseidon/matrix.rs index 43f81d6e5..7ab78fb6b 100644 --- a/manta-pay/src/crypto/poseidon/matrix.rs +++ b/manta-pay/src/crypto/poseidon/matrix.rs @@ -330,6 +330,7 @@ impl PartialEq> for Matrix where F: Field + PartialEq, { + #[inline] fn eq(&self, other: &SquareMatrix) -> bool { self.eq(&other.0) } @@ -346,16 +347,19 @@ where F: Field, { /// Returns a new [`SquareMatrix`] representation of `m` if it returns `true` to [`is_square`](Matrix::is_square). + #[inline] pub fn new(m: Matrix) -> Option { - m.is_square().then(|| Self(m)) + m.is_square().then_some(Self::new_unchecked(m)) } /// Builds a new [`SquareMatrix`] without checking whether `m` is a valid square matrix. + #[inline] pub fn new_unchecked(m: Matrix) -> Self { Self(m) } /// Returns the inversion of a matrix. + #[inline] pub fn inverse(&self) -> Option where F: Clone + PartialEq, @@ -367,6 +371,7 @@ where } /// Checks if the matrix is invertible. + #[inline] pub fn is_invertible(&self) -> bool where F: Clone + PartialEq, @@ -459,6 +464,7 @@ impl AsRef> for SquareMatrix where F: Field, { + #[inline] fn as_ref(&self) -> &Matrix { &self.0 } @@ -470,6 +476,7 @@ where { type Target = Matrix; + #[inline] fn deref(&self) -> &Self::Target { &self.0 } @@ -479,6 +486,7 @@ impl PartialEq> for SquareMatrix where F: Field + PartialEq, { + #[inline] fn eq(&self, other: &Matrix) -> bool { self.0.eq(other) } diff --git a/manta-pay/src/simulation/ledger/mod.rs b/manta-pay/src/simulation/ledger/mod.rs index f851a5bef..0d6c19836 100644 --- a/manta-pay/src/simulation/ledger/mod.rs +++ b/manta-pay/src/simulation/ledger/mod.rs @@ -371,7 +371,7 @@ impl TransferLedger for Ledger { &proof, ) .ok()? - .then(move || (Wrap(()), ())) + .then_some((Wrap(()), ())) } #[inline] diff --git a/manta-trusted-setup/src/util.rs b/manta-trusted-setup/src/util.rs index 6168f0238..2357a08d2 100644 --- a/manta-trusted-setup/src/util.rs +++ b/manta-trusted-setup/src/util.rs @@ -372,7 +372,7 @@ pub trait PairingEngineExt: PairingEngine { { let lhs = (lhs.0.into(), lhs.1.into()); let rhs = (rhs.0.into(), rhs.1.into()); - Self::has_same(&lhs, &rhs).then(|| (lhs, rhs)) + Self::has_same(&lhs, &rhs).then_some((lhs, rhs)) } /// Checks if the ratio of `(lhs.0, lhs.1)` from `G1` is the same as the ratio of diff --git a/workspace-hack/Cargo.toml b/workspace-hack/Cargo.toml index b7d9e3f2e..0756740e5 100644 --- a/workspace-hack/Cargo.toml +++ b/workspace-hack/Cargo.toml @@ -19,7 +19,7 @@ anyhow = { version = "1.0.58", features = ["std"] } bitflags = { version = "1.3.2" } blake3 = { version = "1.3.1", default-features = false, features = ["digest", "std"] } block-buffer = { version = "0.9.0", default-features = false, features = ["block-padding"] } -crypto-common = { version = "0.1.5", default-features = false, features = ["std"] } +crypto-common = { version = "0.1.6", default-features = false, features = ["std"] } digest-93f6ce9d446188ac = { package = "digest", version = "0.10.3", features = ["alloc", "block-buffer", "core-api", "mac", "std", "subtle"] } digest-274715c4dabd11b0 = { package = "digest", version = "0.9.0", default-features = false, features = ["alloc", "std"] } futures = { version = "0.3.21", features = ["alloc", "async-await", "executor", "futures-executor", "std"] } @@ -53,7 +53,7 @@ zeroize = { version = "1.5.6", default-features = false, features = ["alloc", "z anyhow = { version = "1.0.58", features = ["std"] } blake3 = { version = "1.3.1", default-features = false, features = ["digest", "std"] } cc = { version = "1.0.73", default-features = false, features = ["jobserver", "parallel"] } -crypto-common = { version = "0.1.5", default-features = false, features = ["std"] } +crypto-common = { version = "0.1.6", default-features = false, features = ["std"] } digest-93f6ce9d446188ac = { package = "digest", version = "0.10.3", features = ["alloc", "block-buffer", "core-api", "mac", "std", "subtle"] } generic-array = { version = "0.14.5", default-features = false, features = ["more_lengths"] } log = { version = "0.4.17", default-features = false, features = ["kv_unstable", "kv_unstable_std", "std", "value-bag"] } diff --git a/workspace-hack/README.md b/workspace-hack/README.md new file mode 100644 index 000000000..e1b70c131 --- /dev/null +++ b/workspace-hack/README.md @@ -0,0 +1,7 @@ +# Workspace Hack + +This crate will never contain any code, it is just used by [`cargo-hakari`](https://github.com/facebookincubator/cargo-guppy/tree/main/tools/cargo-hakari) to speed up CI builds. See [their documentation](https://docs.rs/cargo-hakari/latest/cargo_hakari/about/index.html) for more on how workspace hacks work. + +## Updating the Dependency List + +When a dependency on `Cargo.toml` needs to be updated, the CI for a PR will fail because `cargo hakari generate --diff` will return with error code `1`. In this case, the `cargo hakari generate` command should be run on a local machine and the updates pushed to the relevant development branch. Be sure to install `cargo-hakari` with `cargo install cargo-hakari`, just as in the [CI workflow](./../.github/workflows/ci.yml).