dalek-cryptography / bulletproofs

A pure-Rust implementation of Bulletproofs using Ristretto.
MIT License
1.04k stars 217 forks source link

BulletProofs 1.0.4 does not build when used as a dependency #292

Closed CjS77 closed 5 years ago

CjS77 commented 5 years ago

The relative doc paths are broken when compiling 1.0.4 as a dependency. This was on a Mac with Rust 1.38.0-nightly (4b65a86eb 2019-07-15), but I assume is a global issue. To reproduce:

cargo new --bin test-bp

Edit Cargo.toml:

[package]
name = "test-bp"
version = "0.1.0"
authors = ["CjS77 <CjS77@users.noreply.github.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bulletproofs = "1.0.4"
$ cargo build

   Updating crates.io index
   Compiling typenum v1.10.0
  ...
   Compiling bulletproofs v1.0.4
error: couldn't read /xxx/.cargo/registry/src/github.com-1ecc6299db9ec823/bulletproofs-1.0.4/src/../../docs/range-proof-protocol.md: No such file or directory (os error 2)
 --> /xxx/.cargo/registry/src/github.com-1ecc6299db9ec823/bulletproofs-1.0.4/src/range_proof/mod.rs:2:18
  |
2 | #![doc(include = "../../docs/range-proof-protocol.md")]
  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ couldn't read file
  |
  = help: external doc paths are relative to the crate root

error: aborting due to previous error

error: Could not compile `bulletproofs`.

To learn more, run the command again with --verbose.
CjS77 commented 5 years ago

After playing around, it's something that changed between nightly-2019-07-31 and nightly-2019-07-08. Updating the toolchain resolves the issue.

hdevalence commented 5 years ago

Yup! Sorry for the breakage, in fact this is why the 1.0.4 version exists: versions 1.0.2 and below work on nightlies with the old doc(include) path format, but are broken on new nightlies, while 1.0.4 and above work on new nightlies but are broken on old nightlies. (1.0.3 effectively doesn't exist, it was supposed to be 1.0.4 but I made a mistake while tagging and publishing it, so it's immediately yanked).

tronch0 commented 5 years ago

Hi I got this one too, and I understand from what you suggested that I need to update my nightly version, but I have two questions regarding this matter:

  1. why wasm-pack build cares about docs?
  2. there is a flow or anything that I can make it ignore the docs altogether?
hdevalence commented 5 years ago

Unfortunately, as far as I'm aware, doc(include) annotations add attributes to source items unconditionally, regardless of whether rustc is building docs or not, so adding the annotations makes rustc look for the markdown files regardless of what type of compilation it does.