mirror of
https://github.com/mii443/merkle.rs.git
synced 2025-08-22 16:05:30 +00:00
Update dependencies
This commit is contained in:
39
.travis.yml
39
.travis.yml
@ -1,9 +1,15 @@
|
||||
language: rust
|
||||
|
||||
# Need to cache the whole `.cargo` directory to keep .crates.toml for
|
||||
# cargo-update to work
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.cargo
|
||||
- $HOME/protobuf
|
||||
- $TRAVIS_BUILD_DIR/target
|
||||
- $HOME/.cargo
|
||||
|
||||
# But don't cache the cargo registry
|
||||
before_cache:
|
||||
- rm -rf $HOME/.cargo/registry
|
||||
|
||||
rust:
|
||||
- stable
|
||||
@ -21,23 +27,12 @@ matrix:
|
||||
- env: NAME='nightly'
|
||||
rust: nightly
|
||||
|
||||
- env:
|
||||
- NAME='rustfmt'
|
||||
- PROTOBUF_CODEGEN_VERSION=2.0.0
|
||||
- PATH=$PATH:$HOME/.cargo/bin:$HOME/protobuf/bin
|
||||
rust: nightly-2018-07-22
|
||||
- env: NAME='clippy'
|
||||
rust: stable
|
||||
before_script:
|
||||
- rustup component add rustfmt-preview
|
||||
# Protoc plugin needed to generate proof.rs from proof.proto
|
||||
- cargo install protobuf-codegen --version $PROTOBUF_CODEGEN_VERSION || echo "protobuf-codegen already installed"
|
||||
# TODO: see if we can avoid installing protobuf-codegen and generating
|
||||
# proof.rs in this build by using rustfmt options (see
|
||||
# https://github.com/SpinResearch/merkle.rs/pull/38#issuecomment-391336829,
|
||||
# paragraph 2).
|
||||
- protoc --version
|
||||
- protoc --rust_out src/proto/ protobuf/proof.proto
|
||||
- rustup component add clippy-preview
|
||||
script:
|
||||
- cargo fmt --all -- --check
|
||||
- cargo clippy --all-targets --all-features -- -D warnings
|
||||
|
||||
- env: NAME='kcov'
|
||||
sudo: required # travis-ci/travis-ci#9061
|
||||
@ -58,13 +53,6 @@ matrix:
|
||||
- libiberty-dev
|
||||
- zlib1g-dev
|
||||
|
||||
- env: NAME='clippy'
|
||||
rust: nightly-2018-07-22
|
||||
before_script:
|
||||
- rustup component add clippy-preview
|
||||
script:
|
||||
- cargo clippy --all --all-features -- -D clippy
|
||||
|
||||
env:
|
||||
global:
|
||||
- RUSTFLAGS="-C link-dead-code"
|
||||
@ -78,4 +66,5 @@ script:
|
||||
before_install:
|
||||
- export PATH=$PATH:$HOME/protobuf/bin
|
||||
- export PROTOC_VERSION=$(cat PROTOC_VERSION)
|
||||
- bash install_protobuf.sh
|
||||
- bash ci/install_protobuf.sh
|
||||
|
||||
|
13
Cargo.toml
13
Cargo.toml
@ -18,16 +18,16 @@ categories = ["data-structures", "cryptography"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
ring = "^0.13.0"
|
||||
protobuf = { version = "^2.0.2", optional = true }
|
||||
serde = { version = "^1.0.55", optional = true }
|
||||
serde_derive = { version = "^1.0.55", optional = true }
|
||||
ring = "^0.16.1"
|
||||
protobuf = { version = "^2.8.0", optional = true }
|
||||
serde = { version = "^1.0.97", optional = true }
|
||||
serde_derive = { version = "^1.0.97", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
protoc-rust = { version = "^2.0.2", optional = true }
|
||||
protoc-rust = { version = "^2.8.0", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1.0.17"
|
||||
serde_json = "1.0.40"
|
||||
|
||||
[features]
|
||||
serialization-protobuf = [ "protobuf", "protoc-rust" ]
|
||||
@ -43,4 +43,3 @@ tag-message = "Release version {{version}}."
|
||||
doc-commit-message = "Update documentation."
|
||||
dev-version-ext = "pre"
|
||||
|
||||
|
||||
|
@ -1 +1 @@
|
||||
libprotoc 3.5.1
|
||||
3.7.1
|
||||
|
9
build.rs
9
build.rs
@ -15,7 +15,8 @@ fn has_right_protoc_version(version: &str) -> bool {
|
||||
let version_output = protoc.wait_with_output().unwrap();
|
||||
assert!(version_output.status.success());
|
||||
|
||||
String::from_utf8(version_output.stdout).unwrap().trim() == version.trim()
|
||||
let full_version = String::from_utf8(version_output.stdout).unwrap();
|
||||
full_version.trim() == format!("libprotoc {}", version.trim())
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialization-protobuf")]
|
||||
@ -26,7 +27,8 @@ fn build_protobuf(out_dir: &str, input: &[&str], includes: &[&str]) {
|
||||
input,
|
||||
includes,
|
||||
customize: Default::default(),
|
||||
}).expect("protoc");
|
||||
})
|
||||
.expect("protoc");
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialization-protobuf")]
|
||||
@ -36,13 +38,14 @@ fn build_protobuf_schemata() {
|
||||
let mut version_string = String::new();
|
||||
let mut version_pin =
|
||||
File::open("PROTOC_VERSION").expect("protoc version pin `PROTOC_VERSION` file is missing");
|
||||
|
||||
version_pin
|
||||
.read_to_string(&mut version_string)
|
||||
.expect("cannot read protoc pin file");
|
||||
|
||||
if !has_right_protoc_version(&version_string) {
|
||||
eprintln!(
|
||||
"Build failed because merkle.rs could not find: {}",
|
||||
"Build failed because merkle.rs could not find protobuf version {}",
|
||||
version_string
|
||||
);
|
||||
|
||||
|
22
ci/install_protobuf.sh
Executable file
22
ci/install_protobuf.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
PROTOC_VERSION=$(cat "$(dirname "$(dirname "$0")")/PROTOC_VERSION")
|
||||
|
||||
check_protoc_version () {
|
||||
this_version=$(protoc --version)
|
||||
return $([ "libprotoc $PROTOC_VERSION" = "$this_version" ])
|
||||
}
|
||||
|
||||
if check_protoc_version; then
|
||||
echo "[SUCCESS] protobuf version $PROTOC_VERSION detected."
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "[INFO] Installing protobuf $PROTOC_VERSION to $HOME/protobuf..."
|
||||
|
||||
cd "$TMPDIR"
|
||||
wget "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip"
|
||||
unzip -d "$HOME/protobuf" "protoc-$PROTOC_VERSION-linux-x86_64.zip"
|
||||
|
||||
echo "[SUCCESS] Done."
|
@ -1,18 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
set -e
|
||||
|
||||
PROTOC_VERSION=$(cat PROTOC_VERSION)
|
||||
|
||||
check_protoc_version () {
|
||||
this_version=`protoc --version`
|
||||
return `[ "$PROTOC_VERSION" = "$this_version" ]`
|
||||
}
|
||||
|
||||
if check_protoc_version; then
|
||||
echo $PROTOC_VERSION detected.
|
||||
exit
|
||||
fi
|
||||
|
||||
wget https://github.com/google/protobuf/archive/v3.5.1.tar.gz
|
||||
tar -xzvf v3.5.1.tar.gz
|
||||
cd protobuf-3.5.1 && ./autogen.sh && ./configure --prefix=$HOME/protobuf && make && make install
|
27
src/proof.rs
27
src/proof.rs
@ -8,17 +8,11 @@ use tree::Tree;
|
||||
|
||||
/// An inclusion proof represent the fact that a `value` is a member
|
||||
/// of a `MerkleTree` with root hash `root_hash`, and hash function `algorithm`.
|
||||
#[cfg_attr(
|
||||
feature = "serialization-serde",
|
||||
derive(Serialize, Deserialize)
|
||||
)]
|
||||
#[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Proof<T> {
|
||||
/// The hashing algorithm used in the original `MerkleTree`
|
||||
#[cfg_attr(
|
||||
feature = "serialization-serde",
|
||||
serde(with = "algorithm_serde")
|
||||
)]
|
||||
#[cfg_attr(feature = "serialization-serde", serde(with = "algorithm_serde"))]
|
||||
pub algorithm: &'static Algorithm,
|
||||
|
||||
/// The hash of the root of the original `MerkleTree`
|
||||
@ -48,7 +42,7 @@ mod algorithm_serde {
|
||||
pub fn deserialize<'de, D: Deserializer<'de>>(de: D) -> Result<&'static Algorithm, D::Error> {
|
||||
let alg_str: String = Deserialize::deserialize(de)?;
|
||||
match &*alg_str {
|
||||
"SHA1" => Ok(&digest::SHA1),
|
||||
"SHA1" => Ok(&digest::SHA1_FOR_LEGACY_USE_ONLY),
|
||||
"SHA256" => Ok(&digest::SHA256),
|
||||
"SHA384" => Ok(&digest::SHA384),
|
||||
"SHA512" => Ok(&digest::SHA512),
|
||||
@ -61,7 +55,7 @@ mod algorithm_serde {
|
||||
mod test {
|
||||
use super::*;
|
||||
use ring::digest::{
|
||||
SHA1 as sha1, SHA256 as sha256, SHA384 as sha384, SHA512 as sha512,
|
||||
SHA1_FOR_LEGACY_USE_ONLY as sha1, SHA256 as sha256, SHA384 as sha384, SHA512 as sha512,
|
||||
SHA512_256 as sha512_256,
|
||||
};
|
||||
|
||||
@ -84,7 +78,8 @@ mod algorithm_serde {
|
||||
serialize(alg, &mut serializer).expect(&format!("{:?}", alg));
|
||||
let alg_ = deserialize(&mut serde_json::Deserializer::from_slice(
|
||||
&serializer.into_inner()[..],
|
||||
)).expect(&format!("{:?}", alg));
|
||||
))
|
||||
.expect(&format!("{:?}", alg));
|
||||
|
||||
assert_eq!(*alg, alg_);
|
||||
}
|
||||
@ -168,10 +163,7 @@ impl<T> Proof<T> {
|
||||
/// A `Lemma` holds the hash of a node, the hash of its sibling node,
|
||||
/// and a sub lemma, whose `node_hash`, when combined with this `sibling_hash`
|
||||
/// must be equal to this `node_hash`.
|
||||
#[cfg_attr(
|
||||
feature = "serialization-serde",
|
||||
derive(Serialize, Deserialize)
|
||||
)]
|
||||
#[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct Lemma {
|
||||
pub node_hash: Vec<u8>,
|
||||
@ -327,10 +319,7 @@ impl Lemma {
|
||||
}
|
||||
|
||||
/// Tags a value so that we know from which branch of a `Tree` (if any) it was found.
|
||||
#[cfg_attr(
|
||||
feature = "serialization-serde",
|
||||
derive(Serialize, Deserialize)
|
||||
)]
|
||||
#[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub enum Positioned<T> {
|
||||
/// The value was found in the left branch
|
||||
|
Reference in New Issue
Block a user