Skip to content

Commit

Permalink
feat: add hakari-related documentation (#175)
Browse files Browse the repository at this point in the history
* fix: upgrade hakari-related documentation
* chore: add CHANGELOG entry
* fix: copy dependency upgrade docs to `CONTRIBUTING.md`
* fix: resolve new clippy issues
  • Loading branch information
bhgomes authored Jul 22, 2022
1 parent 031daac commit e61ad15
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 11 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions manta-accounting/src/transfer/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion manta-crypto/src/merkle_tree/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ where
L: IntoIterator<Item = &'l Leaf<C>>,
{
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
Expand Down
10 changes: 9 additions & 1 deletion manta-pay/src/crypto/poseidon/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ impl<F> PartialEq<SquareMatrix<F>> for Matrix<F>
where
F: Field + PartialEq,
{
#[inline]
fn eq(&self, other: &SquareMatrix<F>) -> bool {
self.eq(&other.0)
}
Expand All @@ -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<F>) -> Option<Self> {
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<F>) -> Self {
Self(m)
}

/// Returns the inversion of a matrix.
#[inline]
pub fn inverse(&self) -> Option<Self>
where
F: Clone + PartialEq,
Expand All @@ -367,6 +371,7 @@ where
}

/// Checks if the matrix is invertible.
#[inline]
pub fn is_invertible(&self) -> bool
where
F: Clone + PartialEq,
Expand Down Expand Up @@ -459,6 +464,7 @@ impl<F> AsRef<Matrix<F>> for SquareMatrix<F>
where
F: Field,
{
#[inline]
fn as_ref(&self) -> &Matrix<F> {
&self.0
}
Expand All @@ -470,6 +476,7 @@ where
{
type Target = Matrix<F>;

#[inline]
fn deref(&self) -> &Self::Target {
&self.0
}
Expand All @@ -479,6 +486,7 @@ impl<F> PartialEq<Matrix<F>> for SquareMatrix<F>
where
F: Field + PartialEq,
{
#[inline]
fn eq(&self, other: &Matrix<F>) -> bool {
self.0.eq(other)
}
Expand Down
2 changes: 1 addition & 1 deletion manta-pay/src/simulation/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ impl TransferLedger<Config> for Ledger {
&proof,
)
.ok()?
.then(move || (Wrap(()), ()))
.then_some((Wrap(()), ()))
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion manta-trusted-setup/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down Expand Up @@ -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"] }
Expand Down
7 changes: 7 additions & 0 deletions workspace-hack/README.md
Original file line number Diff line number Diff line change
@@ -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).

0 comments on commit e61ad15

Please sign in to comment.